@prismicio/react 3.2.2-pr.242.79bae2c → 3.2.2-pr.242.8d8084e
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/PrismicImage.d.ts.map +1 -0
- package/dist/PrismicImage.js.map +1 -0
- package/dist/PrismicLink.d.ts.map +1 -0
- package/dist/PrismicLink.js.map +1 -0
- package/dist/PrismicRichText.d.ts.map +1 -0
- package/dist/PrismicRichText.js.map +1 -0
- package/dist/PrismicTable.d.ts.map +1 -0
- package/dist/PrismicTable.js.map +1 -0
- package/dist/PrismicText.d.ts.map +1 -0
- package/dist/PrismicText.js.map +1 -0
- package/dist/PrismicToolbar.d.ts.map +1 -0
- package/dist/PrismicToolbar.js.map +1 -0
- package/dist/SliceZone.d.ts.map +1 -0
- package/dist/SliceZone.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/{src/lib → lib}/devMsg.js +1 -1
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +10 -12
- package/dist/src/PrismicImage.d.ts.map +0 -1
- package/dist/src/PrismicImage.js.map +0 -1
- package/dist/src/PrismicLink.d.ts.map +0 -1
- package/dist/src/PrismicLink.js.map +0 -1
- package/dist/src/PrismicRichText.d.ts.map +0 -1
- package/dist/src/PrismicRichText.js.map +0 -1
- package/dist/src/PrismicTable.d.ts.map +0 -1
- package/dist/src/PrismicTable.js.map +0 -1
- package/dist/src/PrismicText.d.ts.map +0 -1
- package/dist/src/PrismicText.js.map +0 -1
- package/dist/src/PrismicToolbar.d.ts.map +0 -1
- package/dist/src/PrismicToolbar.js.map +0 -1
- package/dist/src/SliceZone.d.ts.map +0 -1
- package/dist/src/SliceZone.js.map +0 -1
- package/dist/src/lib/devMsg.js.map +0 -1
- /package/dist/{src/PrismicImage.d.ts → PrismicImage.d.ts} +0 -0
- /package/dist/{src/PrismicImage.js → PrismicImage.js} +0 -0
- /package/dist/{src/PrismicLink.d.ts → PrismicLink.d.ts} +0 -0
- /package/dist/{src/PrismicLink.js → PrismicLink.js} +0 -0
- /package/dist/{src/PrismicRichText.d.ts → PrismicRichText.d.ts} +0 -0
- /package/dist/{src/PrismicRichText.js → PrismicRichText.js} +0 -0
- /package/dist/{src/PrismicTable.d.ts → PrismicTable.d.ts} +0 -0
- /package/dist/{src/PrismicTable.js → PrismicTable.js} +0 -0
- /package/dist/{src/PrismicText.d.ts → PrismicText.d.ts} +0 -0
- /package/dist/{src/PrismicText.js → PrismicText.js} +0 -0
- /package/dist/{src/PrismicToolbar.d.ts → PrismicToolbar.d.ts} +0 -0
- /package/dist/{src/PrismicToolbar.js → PrismicToolbar.js} +0 -0
- /package/dist/{src/SliceZone.d.ts → SliceZone.d.ts} +0 -0
- /package/dist/{src/SliceZone.js → SliceZone.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.d.ts","names":[],"sources":["../src/PrismicImage.tsx"],"sourcesContent":[],"mappings":";;;;KAiBK,cAAA,GAAiB,KACrB,YAAY,kBAAkB,qCAG9B,KACC,YAAY,kBAAkB;;AAL3B,KAUO,iBAAA,GAAoB,IAVb,CAWlB,cAXkB,CAAA,KAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,KAAA,CAAA,GAAA;EACY;EAAlB,KAAA,EAcL,eAdK,GAAA,IAAA,GAAA,SAAA;EAAZ;;;;;EAGA,WAAA,CAAA,EAAA,QAAI,MAkBwB,cAlBxB,GAkByC,cAlBzC,CAkBwD,CAlBxD,CAAA,GAAA,IAAA,EAMO;EACX;;;;;;EAkCW,GAAA,CAAA,EAAA,EAAA;EAeyB;;;;;;;EAiCxB,WAAA,CAAA,EAAA,EAmFZ;;;;;aAnIW;;;;;;;;;;;;;WAeL,YAAY,kBAAkB;;;;;;;;;;;;kBAe9B,YACA,kBAAkB;;;;;;;;;;;;;cAiBZ,cAAc,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.js","names":["PrismicImage"],"sources":["../src/PrismicImage.tsx"],"sourcesContent":["import {\n\ttype ForwardedRef,\n\tforwardRef,\n\ttype ComponentProps,\n\ttype FC,\n\ttype ReactNode,\n} from \"react\";\nimport {\n\ttype ImageFieldImage,\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\ntype ImgixURLParams = Omit<\n\tNonNullable<Parameters<typeof asImageWidthSrcSet>[1]>,\n\t\"widths\"\n> &\n\tOmit<\n\t\tNonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>,\n\t\t\"pixelDensities\"\n\t>;\n\n/** Props for `<PrismicImage>`. */\nexport type PrismicImageProps = Omit<\n\tComponentProps<\"img\">,\n\t\"src\" | \"srcset\" | \"alt\"\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 * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths (in pixels) used to build a `srcset` value for the image\n\t\t\t\t * field.\n\t\t\t\t *\n\t\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used:\n\t\t\t\t * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n\t\t\t\t *\n\t\t\t\t * If the image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * Renders an optimized image from a Prismic image field.\n *\n * @example\n *\n * ```tsx\n * <PrismicImage field={slice.primary.photo} />;\n * ```\n *\n * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}\n */\nexport const PrismicImage: FC<PrismicImageProps> = forwardRef(\n\tfunction PrismicImage(\n\t\tprops: PrismicImageProps,\n\t\tref: ForwardedRef<HTMLImageElement>,\n\t) {\n\t\tconst {\n\t\t\tfield,\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\timgixParams = {},\n\t\t\twidths,\n\t\t\tpixelDensities,\n\t\t\tfallback,\n\t\t\t...restProps\n\t\t} = props;\n\n\t\tif (DEV) {\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\n\t\t\tif (widths && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t\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\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = asImageWidthSrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = asImagePixelDensitySrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8GA,MAAa,eAAsC,WAClD,SAASA,eACR,OACA,KACC;CACD,MAAM,EACL,OACA,KACA,aACA,cAAc,EAAE,EAChB,QACA,gBACA,UACA,GAAG,cACA;AAEJ,KAAI,KAAK;AACR,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,qQAAqQ,OACpQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,qSAAqS,OACpS,8BACA,GACD;AAGF,MAAI,UAAU,eACb,SAAQ,KACP,4MACA;;AAIH,KAAI,CAAC,SAAS,eAAe,MAAM,CAClC,QAAO,4CAAG,WAAY;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC;CAI/D,IAAI;CACJ,IAAI;AAEJ,KAAI,UAAU,CAAC,gBAAgB;EAC9B,MAAM,MAAM,mBAAmB,OAAO;GACrC,GAAG;GACH,QAAQ,WAAW,aAAa,SAAY;GAC5C,CAAmB;AAEpB,QAAM,IAAI;AACV,WAAS,IAAI;YACH,gBAAgB;EAC1B,MAAM,MAAM,0BAA0B,OAAO;GAC5C,GAAG;GACH,gBACC,mBAAmB,aAAa,SAAY;GAC7C,CAAmB;AAEpB,QAAM,IAAI;AACV,WAAS,IAAI;;AAGd,QACC,oBAAC;EACK;EACA;EACG;EACR,KAAK,QAAQ,MAAM,OAAO;EAC1B,GAAI;GACH;EAGJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicLink.d.ts","names":[],"sources":["../src/PrismicLink.tsx"],"sourcesContent":[],"mappings":";;;;;cAoBM,gBAAA;AANqB;AASV,UAAA,SAAA,CAAS;EAoBd;EACoC,IAAA,EAAA,MAAA;EAAtB;;;;EAGA,MAAA,CAAA,EAhBhB,yBAgBgB;EADtB;;;;EA4BiB,GAAA,CAAA,EAAA,MAAA;EAGc;EAAd,QAAA,CAAA,EArCT,SAqCS;;AASP,KA3CF,gBA2CE,CAAA,yBA1CY,cA0CZ,CAAA,OA1CkC,gBA0ClC,CAAA,EAAA,yBAzCY,cAyCZ,CAAA,OAzCkC,gBAyClC,CAAA,CAAA,GAxCV,IAwCU,CAvCb,sBAuCa,GAvCY,sBAuCZ,EAAA,KAAA,GAAA,MAAA,GAAA,UAAA,CAAA,GAAA;EAKH;;;;AAsBX;EAsFgD,GAAA,CAAA,EAAA,MAAA,GAhJhC,iBAgJgC,CAAA,KAAA,CAAA;EAAtB;;;;;;;;;EAMZ,YAAA,CAAA,EA3IE,oBA2IF;;;;;;;sBAnIO,cAAc;;sBAGd,cAAc;;;;;aAMvB;;YAGE;;;;SAKH;;;;QAKD;UACE;;;;;;;;;;;;;;cAgBC,uCAsFa,sBAAsB,4CACtB,sBAAsB,0BAExC,iBAAiB,wBAAwB;QACzC,aAAa;MAEhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicLink.js","names":["PrismicLink"],"sources":["../src/PrismicLink.tsx"],"sourcesContent":["import {\n\ttype ComponentProps,\n\ttype ComponentType,\n\ttype ForwardedRef,\n\ttype HTMLAttributeAnchorTarget,\n\ttype ReactNode,\n\tforwardRef,\n} from \"react\";\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n\ttype AsLinkAttrsConfig,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** The default component rendered for internal and external links. */\nconst defaultComponent = \"a\";\n\n/** Props provided to a component when rendered with `<PrismicLink>`. */\nexport interface LinkProps {\n\t/** The URL to link. */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/** Children for the component. */\n\tchildren?: ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n> = Omit<\n\tInternalComponentProps & ExternalComponentProps,\n\t\"rel\" | \"href\" | \"children\"\n> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: ComponentType<InternalComponentProps>;\n\n\t/** The component rendered for external URLs. Defaults to `<a>`. */\n\texternalComponent?: ComponentType<ExternalComponentProps>;\n\n\t/**\n\t * The children to render for the link. If no children are provided, the\n\t * link's `text` property will be used.\n\t */\n\tchildren?: ReactNode;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\n/**\n * Renders a link from a Prismic link field or page.\n *\n * @example\n *\n * ```tsx\n * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;\n * ```\n *\n * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}\n */\nexport const PrismicLink = forwardRef(function PrismicLink<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: ForwardedRef<Element>,\n) {\n\tconst {\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\t(\"text\" in field\n\t\t\t\t\t? Object.keys(field).length > 2\n\t\t\t\t\t: Object.keys(field).length > 1) &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as ComponentType<LinkProps>;\n\tconst Component = href\n\t\t? isInternalURL(href)\n\t\t\t? InternalComponent\n\t\t\t: ExternalComponent\n\t\t: InternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</Component>\n\t);\n}) as <\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: ForwardedRef<Element>;\n\t},\n) => ReactNode;\n\n/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport function isInternalURL(url: string): boolean {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url);\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url);\n\n\treturn isInternal && !isSpecialLink;\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,mBAAmB;;;;;;;;;;;;AA6FzB,MAAa,cAAc,WAAW,SAASA,cAI9C,OACA,KACC;CACD,MAAM,EACL,OACA,UAAU,KACV,cACA,mBACA,mBACA,UACA,GAAG,cACA;AAEJ,KAAI,KACH;MAAI,OACH;OAAI,CAAC,MAAM,WAAW;AACrB,YAAQ,MACP,yEACA,MACA;AACD,UAAM,IAAI,MACT,8IAA8I,OAC7I,0BACA,GACD;eAEA,UAAU,QACR,OAAO,KAAK,MAAM,CAAC,SAAS,IAC5B,OAAO,KAAK,MAAM,CAAC,SAAS,MAC/B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,OAE9C,SAAQ,KACP,uJAAuJ,OACtJ,0BACA,IACD,MACA;aAEQ,KACV;OAAI,EAAE,SAAS,OAAO,QAAQ,KAC7B,SAAQ,KACP,0JAA0J,OACzJ,0BACA,IACD,IACA;;;CAKJ,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,KAAK;EAC7B;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;EAC3D,CAAC;CAEF,IAAI,MAA0B;AAC9B,KAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,WAClD,OAAM,UAAU;CAGjB,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,MAAM,oBAAqB,qBAC1B;CACD,MAAM,oBAAqB,qBAC1B;AAOD,QACC,oBAPiB,OACf,cAAc,KAAK,GAClB,oBACA,oBACD;EAGc;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YAC9D,cAAc,QAAQ,WAAW,OAAO;GAC9B;EAEZ;;;;;;;;AAiBF,SAAgB,cAAc,KAAsB;CACnD,MAAM,aAAa,gBAAgB,KAAK,IAAI;CAC5C,MAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,IAAI;AAE9D,QAAO,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicRichText.d.ts","names":[],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AAiCA;AAQA;AAGA;;AAagB,KAxBJ,qBAAA,GAAwB,0BAwBpB,CAxB+C,SAwB/C,CAAA;;;;;;;AAiDJ,KAjEA,gBAAA,GAAmB,qBAiEnB,CAjEyC,SAiEzC,CAAA;;AAqJC,KAnND,oBAAA,GAmNqB;;SAjNzB;;;;;;;;;;iBAWQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6BF,mBAAmB;;;;;;0BAOR,cAAc;;;;;;0BAOd,cAAc;;;;;aAM3B;;;;;;;;;;;;;cAqJC,iBAAiB,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicRichText.js","names":[],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":["import {\n\tcloneElement,\n\ttype ComponentType,\n\ttype FC,\n\tFragment,\n\tisValidElement,\n\ttype ReactNode,\n} from \"react\";\nimport {\n\tisFilled,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\ttype RTAnyNode,\n} from \"@prismicio/client\";\nimport {\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n\ttype RichTextFunctionSerializer,\n\ttype RichTextMapSerializer,\n} from \"@prismicio/client/richtext\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\nimport { type LinkProps, PrismicLink } from \"./PrismicLink.js\";\n\n/**\n * A function mapping rich text block types to React Components. It is used to\n * render rich text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;\n\n/**\n * A map of rich text block types to React Components. It is used to render rich\n * text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXMapSerializer = RichTextMapSerializer<ReactNode>;\n\n/** Props for `<PrismicRichText>`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a rich text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\ntype CreateDefaultSerializerArgs = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\texternalLinkComponent?: ComponentType<LinkProps>;\n};\n\nconst getDir = (node: RTAnyNode): \"rtl\" | undefined => {\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\treturn \"rtl\";\n\t}\n};\n\nconst createDefaultSerializer = (\n\targs: CreateDefaultSerializerArgs,\n): JSXFunctionSerializer =>\n\twrapMapSerializer<ReactNode>({\n\t\theading1: ({ node, children, key }) => (\n\t\t\t<h1 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h1>\n\t\t),\n\t\theading2: ({ node, children, key }) => (\n\t\t\t<h2 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h2>\n\t\t),\n\t\theading3: ({ node, children, key }) => (\n\t\t\t<h3 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h3>\n\t\t),\n\t\theading4: ({ node, children, key }) => (\n\t\t\t<h4 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h4>\n\t\t),\n\t\theading5: ({ node, children, key }) => (\n\t\t\t<h5 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h5>\n\t\t),\n\t\theading6: ({ node, children, key }) => (\n\t\t\t<h6 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h6>\n\t\t),\n\t\tparagraph: ({ node, children, key }) => (\n\t\t\t<p key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t),\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\toListItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<Fragment key={`${i}__line`}>{line}</Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <Fragment key={key}>{result}</Fragment>;\n\t\t},\n\t});\n\n/**\n * Renders content from a Prismic rich text field as React components.\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 custom formatting: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = (props) => {\n\tconst {\n\t\tlinkResolver,\n\t\tfield,\n\t\tfallback,\n\t\tcomponents,\n\t\texternalLinkComponent,\n\t\tinternalLinkComponent,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in restProps) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tfield,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\tconst serializer = composeSerializers<ReactNode>(\n\t\ttypeof components === \"object\" ? wrapMapSerializer(components) : components,\n\t\tcreateDefaultSerializer({\n\t\t\tlinkResolver,\n\t\t\tinternalLinkComponent,\n\t\t\texternalLinkComponent,\n\t\t}),\n\t);\n\n\t// The serializer is wrapped in a higher-order function that\n\t// automatically applies a key to React Elements if one is not already\n\t// given.\n\tconst serialized = serialize<ReactNode>(\n\t\tfield,\n\t\t(type, node, text, children, key) => {\n\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\tif (isValidElement(result) && result.key == null) {\n\t\t\t\treturn cloneElement(result, { key });\n\t\t\t} else {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t},\n\t);\n\n\tif (!serialized) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{serialized}</>;\n};\n"],"mappings":";;;;;;;;;AAmHA,MAAM,UAAU,SAAuC;AACtD,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,QAAO;;AAIT,MAAM,2BACL,SAEA,kBAA6B;CAC5B,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,YAAY,EAAE,MAAM,UAAU,UAC7B,oBAAC;EAAY,KAAK,OAAO,KAAK;EAC5B;IADM,IAEJ;CAEL,eAAe,EAAE,MAAM,UAAU,oBAAC,mBAAe,KAAK,QAAX,IAAsB;CACjE,SAAS,EAAE,UAAU,UAAU,oBAAC,YAAkB,YAAN,IAAwB;CACpE,KAAK,EAAE,UAAU,UAAU,oBAAC,Q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CAAA;EAAoB,EAAA,CAAA,EADrB,aACqB,CAAA;IACf,GAAA,EADL,iBACK,GADe,iBACf;IAFN,QAAA,EAEM,SAFN;EAIsB,CAAA,CAAA;EAAgC,EAAA,CAAA,EAAtD,aAAsD,CAAA;IAAtD,IAAA,EAAsB,oBAAtB;IACsB,QAAA,EADgC,SAChC;EAA8B,CAAA,CAAA;EAApD,EAAA,CAAA,EAAA,aAAA,CAAA;IAAa,IAAA,EAAS,kBAAT;IAaP,QAAA,EAb8C,SAa7B;EAErB,CAAA,CAAA;CAcM;;AAMF,KAtBA,iBAAA,GAsBA;EAAS;EAcR,KAAA,EAlCL,UA+DP;;;;;;;;;;;;;eAjDa,mBAAmB;;;;;aAMrB;;;;;;;;;;;;;cAcC,cAAc,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicTable.js","names":[],"sources":["../src/PrismicTable.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tisFilled,\n\ttype TableField,\n\ttype TableFieldHead,\n\ttype TableFieldHeadRow,\n\ttype TableFieldBody,\n\ttype TableFieldBodyRow,\n\ttype TableFieldHeaderCell,\n\ttype TableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport { type JSXMapSerializer, PrismicRichText } from \"./PrismicRichText.js\";\n\ntype 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\nconst defaultComponents: Required<TableComponents> = {\n\ttable: ({ children }) => <table>{children}</table>,\n\tthead: ({ children }) => <thead>{children}</thead>,\n\ttbody: ({ children }) => <tbody>{children}</tbody>,\n\ttr: ({ children }) => <tr>{children}</tr>,\n\tth: ({ children }) => <th>{children}</th>,\n\ttd: ({ children }) => <td>{children}</td>,\n};\n\n/** Props for `<PrismicTable>`. */\nexport type PrismicTableProps = {\n\t/** The Prismic table field to render. */\n\tfield: TableField;\n\n\t/**\n\t * An object that maps a table block to a React component.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * table: ({children}) => <table>{children}</table>\n\t * thead: ({children}) => <thead>{children}</thead>\n\t * }\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer & TableComponents;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\n/**\n * Renders content from a Prismic table field as React components.\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: {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = (props) => {\n\tconst { field, components, fallback = null } = props;\n\n\tif (!isFilled.table(field)) {\n\t\treturn fallback;\n\t}\n\n\tconst {\n\t\ttable: Table,\n\t\tthead: Thead,\n\t\ttbody: Tbody,\n\t} = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Table table={field}>\n\t\t\t{field.head && (\n\t\t\t\t<Thead head={field.head}>\n\t\t\t\t\t{field.head.rows.map((row) => (\n\t\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t\t))}\n\t\t\t\t</Thead>\n\t\t\t)}\n\t\t\t<Tbody body={field.body}>\n\t\t\t\t{field.body.rows.map((row) => (\n\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t))}\n\t\t\t</Tbody>\n\t\t</Table>\n\t);\n};\n\ntype TableRowProps = {\n\trow: TableFieldHeadRow | TableFieldBodyRow;\n\tcomponents?: JSXMapSerializer & TableComponents;\n};\n\nfunction TableRow(props: TableRowProps) {\n\tconst { row, components } = props;\n\n\tconst { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Tr row={row}>\n\t\t\t{row.cells.map((cell) =>\n\t\t\t\tcell.type === \"header\" ? (\n\t\t\t\t\t<Th key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Th>\n\t\t\t\t) : (\n\t\t\t\t\t<Td key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Td>\n\t\t\t\t),\n\t\t\t)}\n\t\t</Tr>\n\t);\n}\n"],"mappings":";;;;;AA0BA,MAAM,oBAA+C;CACpD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC;;;;;;;;;;;;AAuCD,MAAa,gBAAuC,UAAU;CAC7D,MAAM,EAAE,OAAO,YAAY,WAAW,SAAS;AAE/C,KAAI,CAAC,SAAS,MAAM,MAAM,CACzB,QAAO;CAGR,MAAM,EACL,OAAO,OACP,OAAO,OACP,OAAO,UACJ;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE3C,QACC,qBAAC;EAAM,OAAO;aACZ,MAAM,QACN,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK,EAET,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK;GACD;;AASV,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,KAAK,eAAe;CAE5B,MAAM,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE1E,QACC,oBAAC;EAAQ;YACP,IAAI,MAAM,KAAK,SACf,KAAK,SAAS,WACb,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,GAEL,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,CAEN;GACG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicText.d.ts","names":[],"sources":["../src/PrismicText.tsx"],"sourcesContent":[],"mappings":";;;;;KAOY,gBAAA;EAAA;EAyBC,KAAA,EAvBL,aAuDP,GAAA,IAhC4B,GAAA,SAAA;;;;;;;;;;;;;;;;;;;;cAAhB,aAAa,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicText.js","names":[],"sources":["../src/PrismicText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { asText, isFilled, type RichTextField } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** Props for `<PrismicText>`. */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/** The separator used between blocks. Defaults to `\\n`. */\n\tseparator?: string;\n};\n\n/**\n * Renders content from a Prismic rich text field as plain text (no HTML).\n *\n * @example\n *\n * ```tsx\n * <PrismicText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicText: FC<PrismicTextProps> = (props) => {\n\tconst { field, fallback, separator } = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in props) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof props.field === \"string\") {\n\t\tif (DEV) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{asText(field, { separator })}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAa,eAAqC,UAAU;CAC3D,MAAM,EAAE,OAAO,UAAU,cAAc;AAEvC,KAAI,KACH;MAAI,eAAe,MAClB,SAAQ,KACP,6IAA6I,OAC5I,gCACA,CAAC,IACF,MAAM,MACN;;AAIH,KAAI,OAAO,MAAM,UAAU,UAAU;AACpC,MAAI,IACH,SAAQ,MACP,2QAA2Q,OAC1Q,yDACA,IACD,MAAM,MACN;AAGF,SAAO;;AAGR,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,0CAAG,WAAY,GAAG;AAG7C,QAAO,0CAAG,OAAO,OAAO,EAAE,WAAW,CAAC,GAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicToolbar.d.ts","names":[],"sources":["../src/PrismicToolbar.tsx"],"sourcesContent":[],"mappings":";;;;KAMY,mBAAA;EAAA;AAmBZ;;;;;;;;;;;;;;;;cAAa,gBAAgB,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicToolbar.js","names":[],"sources":["../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useEffect } from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/** Props for `<PrismicToolbar>`. */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n};\n\n/**\n * Renders the Prismic Toolbar script to support draft previews.\n *\n * @example\n *\n * ```tsx\n * <PrismicToolbar repositoryName=\"my-repo\" />;\n * ```\n *\n * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}\n */\nexport const PrismicToolbar: FC<PrismicToolbarProps> = (props) => {\n\tconst { repositoryName } = props;\n\n\tconst src = getToolbarSrc(repositoryName);\n\n\tuseEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during tests.\n\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\tscript._evaluateScript = false;\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EAAE,mBAAmB;CAE3B,MAAM,MAAM,cAAc,eAAe;AAEzC,iBAAgB;AAGf,MAAI,CAFmB,SAAS,cAAc,eAAe,IAAI,IAAI,EAE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AAA,CAAA,GAAA;EAAhB;EACH,KAAA,EA7DK,MA6DL;EAJwC;EAAkB,KAAA,EAAA,MAAA;EAcjD;EAEF,MAAA,EA/DD,aA+DC,CA9DR,MA8DQ,SA9DO,gBA8DP,GA9D0B,gBA8D1B,GA9D6C,eA8D7C,CAAA;EAImB;;;;EAOT,OAAA,EAlEV,QAkEU;CAGT;;AAUX;;;;;AAsBC,KA5FW,kBA4FX,CAAA,eA1Fe,SA0Ff,GAAA,GAAA,EAAA,WAAA,OAAA,CAAA,GAxFG,aAwFH,CAxFiB,mBAwFjB,CAxFqC,MAwFrC,EAxF6C,QAwF7C,CAAA,CAAA;AAaD;;;;;;;;;;KAzFY,mCACI,YAAY,iDAaZ,iBAAiB,UAAU,mBACxC,QAAQ,QAAQ,UAAU,4BACvB,YACA,QAAQ,QAAQ,UAAU,aAC7B;;;;;;;KAUS;;WAEF;;eAII,eAAe;;;;;qBAOT,cAAc,yBAAyB;;YAGhD;;;;;;;;;cAUE,oCAAqC;;;SAG1C;MACJ;;;;;;;;;;;;cA+BS,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceZone.js","names":[],"sources":["../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}): ReactNode => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type “{type}\n\t\t\t”\n\t\t</section>\n\t);\n};\n\n/**\n * Renders slices in a slice zone as React components.\n *\n * @example\n *\n * ```tsx\n * <SliceZone slices={page.data.slices} components={components} />;\n * ```\n *\n * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"mappings":";;;;;;;;;;;AAoLA,MAAa,sBAAgD,EAC5D,YAGgB;AAChB,KAAI,CAAC,IACJ,QAAO;CAGR,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,SAAQ,KACP,0DAA0D,KAAK,IAC/D,MACA;AAED,QACC,qBAAC;EAAQ,kCAA+B;EAAG,mBAAiB;;GAAM;GACf;GAAK;;GAE9C;;;;;;;;;;;;;AAeZ,MAAa,aAAiC,UAAU;CACvD,MAAM,EACL,SAAS,EAAE,EACX,aAAa,EAAE,EACf,kBACA,UAAU,EAAE,KACT;AAkCJ,QAAO,0CAhCgB,OAAO,KAAK,OAAO,UAAU;EACnD,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;EAE9D,MAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;EAErC,MAAM,OACL,WAAW,SAAoC;AAEhD,MAAI,CAAC,KACJ,QAAO,oBAAC,sBAAoC,SAAZ,IAAqB;AAGtD,MAAI,MAAM,UAAU;GACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,UAAO,oBAAC,QAAe,GAAI,eAAT,IAAwB;;AAG3C,SACC,oBAAC;GAEO;GACA;GACC;GACC;KAJJ,IAKJ;GAEF,GAE0B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LinkProps, PrismicLink, PrismicLinkProps } from "./
|
|
2
|
-
import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps } from "./
|
|
3
|
-
import { PrismicTable, PrismicTableProps } from "./
|
|
4
|
-
import { PrismicText, PrismicTextProps } from "./
|
|
5
|
-
import { PrismicImage, PrismicImageProps } from "./
|
|
6
|
-
import { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "./
|
|
7
|
-
import { PrismicToolbar, PrismicToolbarProps } from "./
|
|
1
|
+
import { LinkProps, PrismicLink, PrismicLinkProps } from "./PrismicLink.js";
|
|
2
|
+
import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.js";
|
|
3
|
+
import { PrismicTable, PrismicTableProps } from "./PrismicTable.js";
|
|
4
|
+
import { PrismicText, PrismicTextProps } from "./PrismicText.js";
|
|
5
|
+
import { PrismicImage, PrismicImageProps } from "./PrismicImage.js";
|
|
6
|
+
import { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "./SliceZone.js";
|
|
7
|
+
import { PrismicToolbar, PrismicToolbarProps } from "./PrismicToolbar.js";
|
|
8
8
|
import { Element } from "@prismicio/client/richtext";
|
|
9
9
|
export { Element, type JSXFunctionSerializer, type JSXMapSerializer, type LinkProps, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, PrismicToolbar, type PrismicToolbarProps, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceZone, type SliceZoneComponents, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PrismicLink } from "./
|
|
2
|
-
import { PrismicRichText } from "./
|
|
3
|
-
import { PrismicTable } from "./
|
|
4
|
-
import { PrismicText } from "./
|
|
5
|
-
import { PrismicImage } from "./
|
|
6
|
-
import { SliceZone, TODOSliceComponent } from "./
|
|
7
|
-
import { PrismicToolbar } from "./
|
|
1
|
+
import { PrismicLink } from "./PrismicLink.js";
|
|
2
|
+
import { PrismicRichText } from "./PrismicRichText.js";
|
|
3
|
+
import { PrismicTable } from "./PrismicTable.js";
|
|
4
|
+
import { PrismicText } from "./PrismicText.js";
|
|
5
|
+
import { PrismicImage } from "./PrismicImage.js";
|
|
6
|
+
import { SliceZone, TODOSliceComponent } from "./SliceZone.js";
|
|
7
|
+
import { PrismicToolbar } from "./PrismicToolbar.js";
|
|
8
8
|
import { Element } from "@prismicio/client/richtext";
|
|
9
9
|
|
|
10
10
|
export { Element, PrismicImage, PrismicLink, PrismicRichText, PrismicTable, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devMsg.js","names":[],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/react/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport function devMsg(slug: string): string {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,OAAO,MAAsB;AAC5C,QAAO,kCAAkC,QAAQ,GAAG"}
|
package/dist/package.js
CHANGED
package/dist/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/react",
|
|
3
|
-
"version": "3.2.2-pr.242.
|
|
3
|
+
"version": "3.2.2-pr.242.8d8084e",
|
|
4
4
|
"description": "React components and hooks to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
".": "./dist/index.js",
|
|
20
20
|
"./package.json": "./package.json"
|
|
21
21
|
},
|
|
22
|
-
"main": "./dist/index.js",
|
|
23
|
-
"module": "./dist/index.js",
|
|
24
22
|
"types": "./dist/index.d.ts",
|
|
25
23
|
"typesVersions": {
|
|
26
24
|
"*": {
|
|
@@ -52,19 +50,19 @@
|
|
|
52
50
|
"esm-env": "^1.2.2"
|
|
53
51
|
},
|
|
54
52
|
"devDependencies": {
|
|
55
|
-
"@playwright/test": "^1.
|
|
53
|
+
"@playwright/test": "^1.57.0",
|
|
56
54
|
"@prismicio/client": "^7.17.0",
|
|
57
|
-
"@trivago/prettier-plugin-sort-imports": "^6.0.
|
|
58
|
-
"@types/react": "^19.2.
|
|
55
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
56
|
+
"@types/react": "^19.2.8",
|
|
59
57
|
"@types/react-dom": "^19.2.3",
|
|
60
|
-
"dotenv": "^
|
|
61
|
-
"oxlint": "^1.
|
|
62
|
-
"playwright": "^1.
|
|
58
|
+
"dotenv": "^17.2.3",
|
|
59
|
+
"oxlint": "^1.39.0",
|
|
60
|
+
"playwright": "^1.57.0",
|
|
63
61
|
"prettier": "^3.7.4",
|
|
64
|
-
"prettier-plugin-jsdoc": "^1.
|
|
62
|
+
"prettier-plugin-jsdoc": "^1.8.0",
|
|
65
63
|
"react": "^19.2.1",
|
|
66
|
-
"react-dom": "^19.2.
|
|
67
|
-
"tsdown": "^0.
|
|
64
|
+
"react-dom": "^19.2.3",
|
|
65
|
+
"tsdown": "^0.19.0",
|
|
68
66
|
"typescript": "^5.9.3"
|
|
69
67
|
},
|
|
70
68
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.d.ts","names":[],"sources":["../../src/PrismicImage.tsx"],"sourcesContent":[],"mappings":";;;;KAiBK,cAAA,GAAiB,KACrB,YAAY,kBAAkB,qCAG9B,KACC,YAAY,kBAAkB;;AAL3B,KAUO,iBAAA,GAAoB,IAVb,CAWlB,cAXkB,CAAA,KAAA,CAAA,EAAA,KAAA,GAAA,QAAA,GAAA,KAAA,CAAA,GAAA;EACY;EAAlB,KAAA,EAcL,eAdK,GAAA,IAAA,GAAA,SAAA;EAAZ;;;;;EAGA,WAAA,CAAA,EAAA,QAAI,MAkBwB,cAlBxB,GAkByC,cAlBzC,CAkBwD,CAlBxD,CAAA,GAAA,IAAA,EAMO;EACX;;;;;;EAkCW,GAAA,CAAA,EAAA,EAAA;EAeyB;;;;;;;EAiCxB,WAAA,CAAA,EAAA,EAmFZ;;;;;aAnIW;;;;;;;;;;;;;WAeL,YAAY,kBAAkB;;;;;;;;;;;;kBAe9B,YACA,kBAAkB;;;;;;;;;;;;;cAiBZ,cAAc,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.js","names":["PrismicImage: FC<PrismicImageProps>","PrismicImage","src: string | undefined","srcSet: string | undefined"],"sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import {\n\ttype ForwardedRef,\n\tforwardRef,\n\ttype ComponentProps,\n\ttype FC,\n\ttype ReactNode,\n} from \"react\";\nimport {\n\ttype ImageFieldImage,\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\ntype ImgixURLParams = Omit<\n\tNonNullable<Parameters<typeof asImageWidthSrcSet>[1]>,\n\t\"widths\"\n> &\n\tOmit<\n\t\tNonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>,\n\t\t\"pixelDensities\"\n\t>;\n\n/** Props for `<PrismicImage>`. */\nexport type PrismicImageProps = Omit<\n\tComponentProps<\"img\">,\n\t\"src\" | \"srcset\" | \"alt\"\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 * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths (in pixels) used to build a `srcset` value for the image\n\t\t\t\t * field.\n\t\t\t\t *\n\t\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used:\n\t\t\t\t * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n\t\t\t\t *\n\t\t\t\t * If the image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * Renders an optimized image from a Prismic image field.\n *\n * @example\n *\n * ```tsx\n * <PrismicImage field={slice.primary.photo} />;\n * ```\n *\n * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}\n */\nexport const PrismicImage: FC<PrismicImageProps> = forwardRef(\n\tfunction PrismicImage(\n\t\tprops: PrismicImageProps,\n\t\tref: ForwardedRef<HTMLImageElement>,\n\t) {\n\t\tconst {\n\t\t\tfield,\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\timgixParams = {},\n\t\t\twidths,\n\t\t\tpixelDensities,\n\t\t\tfallback,\n\t\t\t...restProps\n\t\t} = props;\n\n\t\tif (DEV) {\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\n\t\t\tif (widths && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t\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\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = asImageWidthSrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = asImagePixelDensitySrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8GA,MAAaA,eAAsC,WAClD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,gBA2CE,CAAA,yBA1CY,cA0CZ,CAAA,OA1CkC,gBA0ClC,CAAA,EAAA,yBAzCY,cAyCZ,CAAA,OAzCkC,gBAyClC,CAAA,CAAA,GAxCV,IAwCU,CAvCb,sBAuCa,GAvCY,sBAuCZ,EAAA,KAAA,GAAA,MAAA,GAAA,UAAA,CAAA,GAAA;EAKH;;;;AAsBX;EAsFgD,GAAA,CAAA,EAAA,MAAA,GAhJhC,iBAgJgC,CAAA,KAAA,CAAA;EAAtB;;;;;;;;;EAMZ,YAAA,CAAA,EA3IE,oBA2IF;;;;;;;sBAnIO,cAAc;;sBAGd,cAAc;;;;;aAMvB;;YAGE;;;;SAKH;;;;QAKD;UACE;;;;;;;;;;;;;;cAgBC,uCAsFa,sBAAsB,4CACtB,sBAAsB,0BAExC,iBAAiB,wBAAwB;QACzC,aAAa;MAEhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.js","names":["PrismicLink","rel: string | undefined"],"sources":["../../src/PrismicLink.tsx"],"sourcesContent":["import {\n\ttype ComponentProps,\n\ttype ComponentType,\n\ttype ForwardedRef,\n\ttype HTMLAttributeAnchorTarget,\n\ttype ReactNode,\n\tforwardRef,\n} from \"react\";\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n\ttype AsLinkAttrsConfig,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** The default component rendered for internal and external links. */\nconst defaultComponent = \"a\";\n\n/** Props provided to a component when rendered with `<PrismicLink>`. */\nexport interface LinkProps {\n\t/** The URL to link. */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/** Children for the component. */\n\tchildren?: ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n> = Omit<\n\tInternalComponentProps & ExternalComponentProps,\n\t\"rel\" | \"href\" | \"children\"\n> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: ComponentType<InternalComponentProps>;\n\n\t/** The component rendered for external URLs. Defaults to `<a>`. */\n\texternalComponent?: ComponentType<ExternalComponentProps>;\n\n\t/**\n\t * The children to render for the link. If no children are provided, the\n\t * link's `text` property will be used.\n\t */\n\tchildren?: ReactNode;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\n/**\n * Renders a link from a Prismic link field or page.\n *\n * @example\n *\n * ```tsx\n * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;\n * ```\n *\n * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}\n */\nexport const PrismicLink = forwardRef(function PrismicLink<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: ForwardedRef<Element>,\n) {\n\tconst {\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\t(\"text\" in field\n\t\t\t\t\t? Object.keys(field).length > 2\n\t\t\t\t\t: Object.keys(field).length > 1) &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as ComponentType<LinkProps>;\n\tconst Component = href\n\t\t? isInternalURL(href)\n\t\t\t? InternalComponent\n\t\t\t: ExternalComponent\n\t\t: InternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</Component>\n\t);\n}) as <\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: ForwardedRef<Element>;\n\t},\n) => ReactNode;\n\n/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport function isInternalURL(url: string): boolean {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url);\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url);\n\n\treturn isInternal && !isSpecialLink;\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,mBAAmB;;;;;;;;;;;;AA6FzB,MAAa,cAAc,WAAW,SAASA,cAI9C,OACA,KACC;CACD,MAAM,EACL,OACA,UAAU,KACV,c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qBAAA,GAAwB,0BAwBpB,CAxB+C,SAwB/C,CAAA;;;;;;;AAiDJ,KAjEA,gBAAA,GAAmB,qBAiEnB,CAjEyC,SAiEzC,CAAA;;AAqJC,KAnND,oBAAA,GAmNqB;;SAjNzB;;;;;;;;;;iBAWQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6BF,mBAAmB;;;;;;0BAOR,cAAc;;;;;;0BAOd,cAAc;;;;;aAM3B;;;;;;;;;;;;;cAqJC,iBAAiB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.js","names":["result: ReactNode[]","PrismicRichText: FC<PrismicRichTextProps>"],"sources":["../../src/PrismicRichText.tsx"],"sourcesContent":["import {\n\tcloneElement,\n\ttype ComponentType,\n\ttype FC,\n\tFragment,\n\tisValidElement,\n\ttype ReactNode,\n} from \"react\";\nimport {\n\tisFilled,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\ttype RTAnyNode,\n} from \"@prismicio/client\";\nimport {\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n\ttype RichTextFunctionSerializer,\n\ttype RichTextMapSerializer,\n} from \"@prismicio/client/richtext\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\nimport { type LinkProps, PrismicLink } from \"./PrismicLink.js\";\n\n/**\n * A function mapping rich text block types to React Components. It is used to\n * render rich text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;\n\n/**\n * A map of rich text block types to React Components. It is used to render rich\n * text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXMapSerializer = RichTextMapSerializer<ReactNode>;\n\n/** Props for `<PrismicRichText>`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a rich text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\ntype CreateDefaultSerializerArgs = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\texternalLinkComponent?: ComponentType<LinkProps>;\n};\n\nconst getDir = (node: RTAnyNode): \"rtl\" | undefined => {\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\treturn \"rtl\";\n\t}\n};\n\nconst createDefaultSerializer = (\n\targs: CreateDefaultSerializerArgs,\n): JSXFunctionSerializer =>\n\twrapMapSerializer<ReactNode>({\n\t\theading1: ({ node, children, key }) => (\n\t\t\t<h1 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h1>\n\t\t),\n\t\theading2: ({ node, children, key }) => (\n\t\t\t<h2 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h2>\n\t\t),\n\t\theading3: ({ node, children, key }) => (\n\t\t\t<h3 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h3>\n\t\t),\n\t\theading4: ({ node, children, key }) => (\n\t\t\t<h4 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h4>\n\t\t),\n\t\theading5: ({ node, children, key }) => (\n\t\t\t<h5 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h5>\n\t\t),\n\t\theading6: ({ node, children, key }) => (\n\t\t\t<h6 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h6>\n\t\t),\n\t\tparagraph: ({ node, children, key }) => (\n\t\t\t<p key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t),\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\toListItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<Fragment key={`${i}__line`}>{line}</Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <Fragment key={key}>{result}</Fragment>;\n\t\t},\n\t});\n\n/**\n * Renders content from a Prismic rich text field as React components.\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 custom formatting: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = (props) => {\n\tconst {\n\t\tlinkResolver,\n\t\tfield,\n\t\tfallback,\n\t\tcomponents,\n\t\texternalLinkComponent,\n\t\tinternalLinkComponent,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in restProps) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tfield,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\tconst serializer = composeSerializers<ReactNode>(\n\t\ttypeof components === \"object\" ? wrapMapSerializer(components) : components,\n\t\tcreateDefaultSerializer({\n\t\t\tlinkResolver,\n\t\t\tinternalLinkComponent,\n\t\t\texternalLinkComponent,\n\t\t}),\n\t);\n\n\t// The serializer is wrapped in a higher-order function that\n\t// automatically applies a key to React Elements if one is not already\n\t// given.\n\tconst serialized = serialize<ReactNode>(\n\t\tfield,\n\t\t(type, node, text, children, key) => {\n\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\tif (isValidElement(result) && result.key == null) {\n\t\t\t\treturn cloneElement(result, { key });\n\t\t\t} else {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t},\n\t);\n\n\tif (!serialized) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{serialized}</>;\n};\n"],"mappings":";;;;;;;;;AAmHA,MAAM,UAAU,SAAuC;AACtD,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,QAAO;;AAIT,MAAM,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B;;;;;aAMrB;;;;;;;;;;;;;cAcC,cAAc,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicTable.js","names":["defaultComponents: Required<TableComponents>","PrismicTable: FC<PrismicTableProps>"],"sources":["../../src/PrismicTable.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tisFilled,\n\ttype TableField,\n\ttype TableFieldHead,\n\ttype TableFieldHeadRow,\n\ttype TableFieldBody,\n\ttype TableFieldBodyRow,\n\ttype TableFieldHeaderCell,\n\ttype TableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport { type JSXMapSerializer, PrismicRichText } from \"./PrismicRichText.js\";\n\ntype 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\nconst defaultComponents: Required<TableComponents> = {\n\ttable: ({ children }) => <table>{children}</table>,\n\tthead: ({ children }) => <thead>{children}</thead>,\n\ttbody: ({ children }) => <tbody>{children}</tbody>,\n\ttr: ({ children }) => <tr>{children}</tr>,\n\tth: ({ children }) => <th>{children}</th>,\n\ttd: ({ children }) => <td>{children}</td>,\n};\n\n/** Props for `<PrismicTable>`. */\nexport type PrismicTableProps = {\n\t/** The Prismic table field to render. */\n\tfield: TableField;\n\n\t/**\n\t * An object that maps a table block to a React component.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * table: ({children}) => <table>{children}</table>\n\t * thead: ({children}) => <thead>{children}</thead>\n\t * }\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer & TableComponents;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\n/**\n * Renders content from a Prismic table field as React components.\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: {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = (props) => {\n\tconst { field, components, fallback = null } = props;\n\n\tif (!isFilled.table(field)) {\n\t\treturn fallback;\n\t}\n\n\tconst {\n\t\ttable: Table,\n\t\tthead: Thead,\n\t\ttbody: Tbody,\n\t} = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Table table={field}>\n\t\t\t{field.head && (\n\t\t\t\t<Thead head={field.head}>\n\t\t\t\t\t{field.head.rows.map((row) => (\n\t\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t\t))}\n\t\t\t\t</Thead>\n\t\t\t)}\n\t\t\t<Tbody body={field.body}>\n\t\t\t\t{field.body.rows.map((row) => (\n\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t))}\n\t\t\t</Tbody>\n\t\t</Table>\n\t);\n};\n\ntype TableRowProps = {\n\trow: TableFieldHeadRow | TableFieldBodyRow;\n\tcomponents?: JSXMapSerializer & TableComponents;\n};\n\nfunction TableRow(props: TableRowProps) {\n\tconst { row, components } = props;\n\n\tconst { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Tr row={row}>\n\t\t\t{row.cells.map((cell) =>\n\t\t\t\tcell.type === \"header\" ? (\n\t\t\t\t\t<Th key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Th>\n\t\t\t\t) : (\n\t\t\t\t\t<Td key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Td>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K,IAET,CAEN;GACG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.d.ts","names":[],"sources":["../../src/PrismicText.tsx"],"sourcesContent":[],"mappings":";;;;;KAOY,gBAAA;EAAA;EAyBC,KAAA,EAvBL,aAuDP,GAAA,IAhC4B,GAAA,SAAA;;;;;;;;;;;;;;;;;;;;cAAhB,aAAa,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.js","names":["PrismicText: FC<PrismicTextProps>"],"sources":["../../src/PrismicText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { asText, isFilled, type RichTextField } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** Props for `<PrismicText>`. */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/** The separator used between blocks. Defaults to `\\n`. */\n\tseparator?: string;\n};\n\n/**\n * Renders content from a Prismic rich text field as plain text (no HTML).\n *\n * @example\n *\n * ```tsx\n * <PrismicText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicText: FC<PrismicTextProps> = (props) => {\n\tconst { field, fallback, separator } = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in props) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof props.field === \"string\") {\n\t\tif (DEV) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{asText(field, { separator })}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAaA,eAAqC,UAAU;CAC3D,MAAM,EAAE,OAAO,UAAU,cAAc;AAEvC,KAAI,KACH;MAAI,eAAe,MAClB,SAAQ,KACP,6IAA6I,OAC5I,gCACA,CAAC,IACF,MAAM,MACN;;AAIH,KAAI,OAAO,MAAM,UAAU,UAAU;AACpC,MAAI,IACH,SAAQ,MACP,2QAA2Q,OAC1Q,yDACA,IACD,MAAM,MACN;AAGF,SAAO;;AAGR,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,0CAAG,WAAY,GAAG;AAG7C,QAAO,0CAAG,OAAO,OAAO,EAAE,WAAW,CAAC,GAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicToolbar.d.ts","names":[],"sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":[],"mappings":";;;;KAMY,mBAAA;EAAA;AAmBZ;;;;;;;;;;;;;;;;cAAa,gBAAgB,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicToolbar.js","names":["PrismicToolbar: FC<PrismicToolbarProps>"],"sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useEffect } from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/** Props for `<PrismicToolbar>`. */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n};\n\n/**\n * Renders the Prismic Toolbar script to support draft previews.\n *\n * @example\n *\n * ```tsx\n * <PrismicToolbar repositoryName=\"my-repo\" />;\n * ```\n *\n * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}\n */\nexport const PrismicToolbar: FC<PrismicToolbarProps> = (props) => {\n\tconst { repositoryName } = props;\n\n\tconst src = getToolbarSrc(repositoryName);\n\n\tuseEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during tests.\n\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\tscript._evaluateScript = false;\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAaA,kBAA2C,UAAU;CACjE,MAAM,EAAE,mBAAmB;CAE3B,MAAM,MAAM,cAAc,eAAe;AAEzC,iBAAgB;AAGf,MAAI,CAFmB,SAAS,cAAc,eAAe,IAAI,IAAI,EAEhD;GACpB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,MAAM;AACb,UAAO,QAAQ;AAGf,UAAO,QAAQ,iBAAiB;AAChC,UAAO,QAAQ,iBAAiB;AAIhC,UAAO,kBAAkB;AAEzB,YAAS,KAAK,YAAY,OAAO;;IAEhC,CAAC,gBAAgB,IAAI,CAAC;AAEzB,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.d.ts","names":[],"sources":["../../src/SliceZone.tsx"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GAxFG,aAwFH,CAxFiB,mBAwFjB,CAxFqC,MAwFrC,EAxF6C,QAwF7C,CAAA,CAAA;AAaD;;;;;;;;;;KAzFY,mCACI,YAAY,iDAaZ,iBAAiB,UAAU,mBACxC,QAAQ,QAAQ,UAAU,4BACvB,YACA,QAAQ,QAAQ,UAAU,aAC7B;;;;;;;KAUS;;WAEF;;eAII,eAAe;;;;;qBAOT,cAAc,yBAAyB;;YAGhD;;;;;;;;;cAUE,oCAAqC;;;SAG1C;MACJ;;;;;;;;;;;;cA+BS,WAAW,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.js","names":["SliceZone: FC<SliceZoneProps>"],"sources":["../../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}): ReactNode => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type “{type}\n\t\t\t”\n\t\t</section>\n\t);\n};\n\n/**\n * Renders slices in a slice zone as React components.\n *\n * @example\n *\n * ```tsx\n * <SliceZone slices={page.data.slices} components={components} />;\n * ```\n *\n * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"mappings":";;;;;;;;;;;AAoLA,MAAa,sBAAgD,EAC5D,YAGgB;AAChB,KAAI,CAAC,IACJ,QAAO;CAGR,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,SAAQ,KACP,0DAA0D,KAAK,IAC/D,MACA;AAED,QACC,qBAAC;EAAQ,kCAA+B;EAAG,mBAAiB;;GAAM;GACf;GAAK;;GAE9C;;;;;;;;;;;;;AAeZ,MAAaA,aAAiC,UAAU;CACvD,MAAM,EACL,SAAS,EAAE,EACX,aAAa,EAAE,EACf,kBACA,UAAU,EAAE,KACT;AAkCJ,QAAO,0CAhCgB,OAAO,KAAK,OAAO,UAAU;EACnD,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;EAE9D,MAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;EAErC,MAAM,OACL,WAAW,SAAoC;AAEhD,MAAI,CAAC,KACJ,QAAO,oBAAC,sBAAoC,SAAZ,IAAqB;AAGtD,MAAI,MAAM,UAAU;GACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,UAAO,oBAAC,QAAe,GAAI,eAAT,IAAwB;;AAG3C,SACC,oBAAC;GAEO;GACA;GACC;GACC;KAJJ,IAKJ;GAEF,GAE0B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.js","names":[],"sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/react/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport function devMsg(slug: string): string {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,OAAO,MAAsB;AAC5C,QAAO,kCAAkC,QAAQ,GAAG"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|