@prismicio/react 2.5.2 → 2.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/PrismicImage.cjs +7 -11
  2. package/dist/PrismicImage.cjs.map +1 -1
  3. package/dist/PrismicImage.d.ts +14 -15
  4. package/dist/PrismicImage.js +6 -10
  5. package/dist/PrismicImage.js.map +1 -1
  6. package/dist/PrismicLink.cjs +4 -66
  7. package/dist/PrismicLink.cjs.map +1 -1
  8. package/dist/PrismicLink.d.ts +5 -104
  9. package/dist/PrismicLink.js +4 -65
  10. package/dist/PrismicLink.js.map +1 -1
  11. package/dist/PrismicProvider.cjs.map +1 -1
  12. package/dist/PrismicProvider.d.ts +8 -9
  13. package/dist/PrismicProvider.js.map +1 -1
  14. package/dist/PrismicRichText.cjs +4 -71
  15. package/dist/PrismicRichText.cjs.map +1 -1
  16. package/dist/PrismicRichText.d.ts +4 -116
  17. package/dist/PrismicRichText.js +5 -70
  18. package/dist/PrismicRichText.js.map +1 -1
  19. package/dist/PrismicText.cjs +4 -4
  20. package/dist/PrismicText.cjs.map +1 -1
  21. package/dist/PrismicText.d.ts +2 -2
  22. package/dist/PrismicText.js +3 -3
  23. package/dist/PrismicText.js.map +1 -1
  24. package/dist/PrismicToolbar.cjs +6 -4
  25. package/dist/PrismicToolbar.cjs.map +1 -1
  26. package/dist/PrismicToolbar.d.ts +3 -1
  27. package/dist/PrismicToolbar.js +6 -4
  28. package/dist/PrismicToolbar.js.map +1 -1
  29. package/dist/SliceZone.cjs +4 -17
  30. package/dist/SliceZone.cjs.map +1 -1
  31. package/dist/SliceZone.d.ts +4 -65
  32. package/dist/SliceZone.js +4 -17
  33. package/dist/SliceZone.js.map +1 -1
  34. package/dist/index.cjs +0 -2
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.ts +2 -27
  37. package/dist/index.js +1 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/package.json.cjs +1 -1
  40. package/dist/package.json.js +1 -1
  41. package/dist/react-server/PrismicLink.cjs +59 -0
  42. package/dist/react-server/PrismicLink.cjs.map +1 -0
  43. package/dist/react-server/PrismicLink.d.ts +72 -0
  44. package/dist/react-server/PrismicLink.js +42 -0
  45. package/dist/react-server/PrismicLink.js.map +1 -0
  46. package/dist/react-server/PrismicRichText.cjs +92 -0
  47. package/dist/react-server/PrismicRichText.cjs.map +1 -0
  48. package/dist/react-server/PrismicRichText.d.ts +104 -0
  49. package/dist/react-server/PrismicRichText.js +73 -0
  50. package/dist/react-server/PrismicRichText.js.map +1 -0
  51. package/dist/react-server/index.d.ts +4 -0
  52. package/dist/react-server/unsupported.cjs +97 -0
  53. package/dist/react-server/unsupported.cjs.map +1 -0
  54. package/dist/react-server/unsupported.d.ts +22 -0
  55. package/dist/react-server/unsupported.js +97 -0
  56. package/dist/react-server/unsupported.js.map +1 -0
  57. package/dist/react-server.cjs +44 -0
  58. package/dist/react-server.cjs.map +1 -0
  59. package/dist/react-server.js +41 -0
  60. package/dist/react-server.js.map +1 -0
  61. package/dist/useStatefulPrismicClientMethod.cjs +6 -0
  62. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  63. package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
  64. package/dist/useStatefulPrismicClientMethod.js +6 -0
  65. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  66. package/package.json +42 -47
  67. package/src/PrismicImage.tsx +30 -37
  68. package/src/PrismicLink.tsx +29 -258
  69. package/src/PrismicProvider.tsx +9 -8
  70. package/src/PrismicRichText.tsx +28 -275
  71. package/src/PrismicText.tsx +4 -5
  72. package/src/PrismicToolbar.tsx +7 -6
  73. package/src/SliceZone.tsx +8 -129
  74. package/src/index.ts +1 -9
  75. package/src/react-server/PrismicLink.tsx +179 -0
  76. package/src/react-server/PrismicRichText.tsx +267 -0
  77. package/src/react-server/index.ts +38 -0
  78. package/src/react-server/unsupported.ts +98 -0
  79. package/dist/lib/pascalCase.cjs +0 -10
  80. package/dist/lib/pascalCase.cjs.map +0 -1
  81. package/dist/lib/pascalCase.js +0 -10
  82. package/dist/lib/pascalCase.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ import * as React from "react";
2
+ import { LinkField, LinkResolverFunction, PrismicDocument, AsLinkAttrsConfig } from "@prismicio/client";
3
+ /**
4
+ * The default component rendered for internal and external links.
5
+ */
6
+ export declare const defaultComponent = "a";
7
+ /**
8
+ * Props provided to a component when rendered with `<PrismicLink>`.
9
+ */
10
+ export interface LinkProps {
11
+ /**
12
+ * The URL to link.
13
+ */
14
+ href: string;
15
+ /**
16
+ * The `target` attribute for anchor elements. If the Prismic field is
17
+ * configured to open in a new window, this prop defaults to `_blank`.
18
+ */
19
+ target?: React.HTMLAttributeAnchorTarget;
20
+ /**
21
+ * The `rel` attribute for anchor elements. If the `target` prop is set to
22
+ * `"_blank"`, this prop defaults to `"noopener noreferrer"`.
23
+ */
24
+ rel?: string;
25
+ /**
26
+ * Children for the component. *
27
+ */
28
+ children?: React.ReactNode;
29
+ }
30
+ export type PrismicLinkProps<InternalComponentProps = React.ComponentProps<typeof defaultComponent>, ExternalComponentProps = React.ComponentProps<typeof defaultComponent>> = Omit<InternalComponentProps & ExternalComponentProps, "rel" | "href"> & {
31
+ /**
32
+ * The `rel` attribute for the link. By default, `"noreferrer"` is provided if
33
+ * the link's URL is external. This prop can be provided a function to use the
34
+ * link's metadata to determine the `rel` value.
35
+ */
36
+ rel?: string | AsLinkAttrsConfig["rel"];
37
+ /**
38
+ * The Link Resolver used to resolve links.
39
+ *
40
+ * @remarks
41
+ * If your app uses Route Resolvers when querying for your Prismic
42
+ * repository's content, a Link Resolver does not need to be provided.
43
+ * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
44
+ */
45
+ linkResolver?: LinkResolverFunction;
46
+ /**
47
+ * The component rendered for internal URLs. Defaults to `<a>`.
48
+ *
49
+ * If your app uses a client-side router that requires a special Link
50
+ * component, provide the Link component to this prop.
51
+ */
52
+ internalComponent?: React.ElementType<InternalComponentProps>;
53
+ /**
54
+ * The component rendered for external URLs. Defaults to `<a>`.
55
+ */
56
+ externalComponent?: React.ComponentType<ExternalComponentProps>;
57
+ } & ({
58
+ document: PrismicDocument | null | undefined;
59
+ href?: never;
60
+ field?: never;
61
+ } | {
62
+ field: LinkField | null | undefined;
63
+ href?: never;
64
+ document?: never;
65
+ } | {
66
+ href: LinkProps["href"];
67
+ field?: LinkField | null | undefined;
68
+ document?: never;
69
+ });
70
+ export declare const PrismicLink: <InternalComponentProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, ExternalComponentProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>>(props: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {
71
+ ref?: React.ForwardedRef<Element> | undefined;
72
+ }) => JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { asLinkAttrs } from "@prismicio/client";
4
+ import { __PRODUCTION__ } from "../lib/__PRODUCTION__.js";
5
+ import { devMsg } from "../lib/devMsg.js";
6
+ import { isInternalURL } from "../lib/isInternalURL.js";
7
+ const defaultComponent = "a";
8
+ const PrismicLink = React.forwardRef(function PrismicLink2({ field, document: doc, linkResolver, internalComponent, externalComponent, ...restProps }, ref) {
9
+ if (!__PRODUCTION__) {
10
+ if (field) {
11
+ if (!field.link_type) {
12
+ console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
13
+ `, field);
14
+ throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg("missing-link-properties")}`);
15
+ } else if (Object.keys(field).length > 1 && !("url" in field || "uid" in field || "id" in field)) {
16
+ console.warn(`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, field);
17
+ }
18
+ } else if (doc) {
19
+ if (!("url" in doc || "id" in doc)) {
20
+ console.warn(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, doc);
21
+ }
22
+ }
23
+ }
24
+ const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? doc, {
25
+ linkResolver,
26
+ rel: typeof restProps.rel === "function" ? restProps.rel : void 0
27
+ });
28
+ let rel = computedRel;
29
+ if ("rel" in restProps && typeof restProps.rel !== "function") {
30
+ rel = restProps.rel;
31
+ }
32
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
33
+ const InternalComponent = internalComponent || defaultComponent;
34
+ const ExternalComponent = externalComponent || defaultComponent;
35
+ const Component = href && isInternalURL(href) ? InternalComponent : ExternalComponent;
36
+ return /* @__PURE__ */ jsx(Component, { ref, ...attrs, ...restProps, href, rel });
37
+ });
38
+ export {
39
+ PrismicLink,
40
+ defaultComponent
41
+ };
42
+ //# sourceMappingURL=PrismicLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicLink.js","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\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?: React.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/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<InternalComponentProps & ExternalComponentProps, \"rel\" | \"href\"> & {\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 * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\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?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\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\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\t{\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\t...restProps\n\t}: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tif (!__PRODUCTION__) {\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\tObject.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 React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel} />\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["PrismicLink"],"mappings":";;;;;;AAgBO,MAAM,mBAAmB;AAgFzB,MAAM,cAAc,MAAM,WAAW,SAASA,aAIpD,EACC,OACA,UAAU,KACV,cACA,mBACA,mBACA,GAAG,UAAA,GAEJ,KAAgC;AAEhC,MAAI,CAAC,gBAAgB;AACpB,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8I,OAC7I,yBAAyB,GACvB;AAAA,MAGJ,WAAA,OAAO,KAAK,KAAK,EAAE,SAAS,KAC5B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJ,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0J,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQ,cAAc,IAAI,IAAI,oBAAoB;AAGlD,SAAA,oBAAC,aAAU,KAAc,GAAA,OAAO,GAAI,WAAW,MAAY,IAAS,CAAA;AAEtE,CAAC;"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const prismic = require("@prismicio/client");
6
+ const prismicR = require("@prismicio/richtext");
7
+ const PrismicLink = require("./PrismicLink.cjs");
8
+ function _interopNamespaceDefault(e) {
9
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
+ if (e) {
11
+ for (const k in e) {
12
+ if (k !== "default") {
13
+ const d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: () => e[k]
17
+ });
18
+ }
19
+ }
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
25
+ const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
26
+ const prismicR__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicR);
27
+ const createDefaultSerializer = (args) => prismicR__namespace.wrapMapSerializer({
28
+ heading1: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { children }, key),
29
+ heading2: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { children }, key),
30
+ heading3: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { children }, key),
31
+ heading4: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { children }, key),
32
+ heading5: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { children }, key),
33
+ heading6: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("h6", { children }, key),
34
+ paragraph: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("p", { children }, key),
35
+ preformatted: ({ node, key }) => /* @__PURE__ */ jsxRuntime.jsx("pre", { children: node.text }, key),
36
+ strong: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { children }, key),
37
+ em: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("em", { children }, key),
38
+ listItem: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children }, key),
39
+ oListItem: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children }, key),
40
+ list: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { children }, key),
41
+ oList: ({ children, key }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { children }, key),
42
+ image: ({ node, key }) => {
43
+ const img = /* @__PURE__ */ jsxRuntime.jsx("img", { src: node.url, alt: node.alt ?? void 0, "data-copyright": node.copyright ? node.copyright : void 0 });
44
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "block-img", children: node.linkTo ? /* @__PURE__ */ jsxRuntime.jsx(PrismicLink.PrismicLink, { linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, field: node.linkTo, children: img }) : img }, key);
45
+ },
46
+ embed: ({ node, key }) => /* @__PURE__ */ jsxRuntime.jsx("div", { "data-oembed": node.oembed.embed_url, "data-oembed-type": node.oembed.type, "data-oembed-provider": node.oembed.provider_name, dangerouslySetInnerHTML: { __html: node.oembed.html ?? "" } }, key),
47
+ hyperlink: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx(PrismicLink.PrismicLink, { field: node.data, linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, children }, key),
48
+ label: ({ node, children, key }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: node.data.label, children }, key),
49
+ span: ({ text, key }) => {
50
+ const result = [];
51
+ let i = 0;
52
+ for (const line of text.split("\n")) {
53
+ if (i > 0) {
54
+ result.push(/* @__PURE__ */ jsxRuntime.jsx("br", {}, `${i}__break`));
55
+ }
56
+ result.push(/* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: line }, `${i}__line`));
57
+ i++;
58
+ }
59
+ return /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: result }, key);
60
+ }
61
+ });
62
+ function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent }) {
63
+ return React__namespace.useMemo(() => {
64
+ if (prismic__namespace.isFilled.richText(field)) {
65
+ const serializer = prismicR__namespace.composeSerializers(typeof components === "object" ? prismicR__namespace.wrapMapSerializer(components) : components, createDefaultSerializer({
66
+ linkResolver,
67
+ internalLinkComponent,
68
+ externalLinkComponent
69
+ }));
70
+ const serialized = prismicR__namespace.serialize(field, (type, node, text, children, key) => {
71
+ const result = serializer(type, node, text, children, key);
72
+ if (React__namespace.isValidElement(result) && result.key == null) {
73
+ return React__namespace.cloneElement(result, { key });
74
+ } else {
75
+ return result;
76
+ }
77
+ });
78
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: serialized });
79
+ } else {
80
+ return fallback != null ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback }) : null;
81
+ }
82
+ }, [
83
+ field,
84
+ internalLinkComponent,
85
+ externalLinkComponent,
86
+ components,
87
+ linkResolver,
88
+ fallback
89
+ ]);
90
+ }
91
+ exports.PrismicRichText = PrismicRichText;
92
+ //# sourceMappingURL=PrismicRichText.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.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 * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\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 * @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?: React.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?: React.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?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ children, key }) => <h1 key={key}>{children}</h1>,\n\t\theading2: ({ children, key }) => <h2 key={key}>{children}</h2>,\n\t\theading3: ({ children, key }) => <h3 key={key}>{children}</h3>,\n\t\theading4: ({ children, key }) => <h4 key={key}>{children}</h4>,\n\t\theading5: ({ children, key }) => <h5 key={key}>{children}</h5>,\n\t\theading6: ({ children, key }) => <h6 key={key}>{children}</h6>,\n\t\tparagraph: ({ children, key }) => <p key={key}>{children}</p>,\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: ({ children, key }) => <li key={key}>{children}</li>,\n\t\toListItem: ({ children, key }) => <li key={key}>{children}</li>,\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: React.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(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":["prismicR","jsx","PrismicLink","React","prismic","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,0BAA0B,CAI/B,SAEAA,oBAAS,kBAAkB;AAAA,EAC1B,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAC,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAA,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAA,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAA,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAA,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAAA,2BAAA,IAAC,MAAc,EAAA,SAAA,GAAN,G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WAAW,MAAM,MAAM,MAAM,UAAU,GAAG;AAEzD,YAAIG,iBAAM,eAAe,MAAM,KAAK,OAAO,OAAO,MAAM;AACvD,iBAAOA,iBAAM,aAAa,QAAQ,EAAE,IAAK,CAAA;AAAA,QAAA,OACnC;AACC,iBAAA;AAAA,QACP;AAAA,MAAA,CACD;AAGF,mEAAU,UAAW,WAAA,CAAA;AAAA,IAAA,OACf;AACN,aAAO,YAAY,OAAUF,+BAAAI,WAAAA,UAAA,EAAA,UAAA,UAAS,IAAM;AAAA,IAC5C;AAAA,EAAA,GACC;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;"}
@@ -0,0 +1,104 @@
1
+ import * as React from "react";
2
+ import * as prismic from "@prismicio/client";
3
+ import { JSXFunctionSerializer, JSXMapSerializer } from "../types";
4
+ import { LinkProps } from "./PrismicLink";
5
+ /**
6
+ * Props for `<PrismicRichText>`.
7
+ */
8
+ export type PrismicRichTextProps<LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction> = {
9
+ /**
10
+ * The Prismic Rich Text field to render.
11
+ */
12
+ field: prismic.RichTextField | null | undefined;
13
+ /**
14
+ * The Link Resolver used to resolve links.
15
+ *
16
+ * @remarks
17
+ * If your app uses Route Resolvers when querying for your Prismic
18
+ * repository's content, a Link Resolver does not need to be provided.
19
+ * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
20
+ */
21
+ linkResolver?: LinkResolverFunction;
22
+ /**
23
+ * A map or function that maps a Rich Text block to a React component.
24
+ *
25
+ * @remarks
26
+ * Prefer using a map serializer over the function serializer when possible.
27
+ * The map serializer is simpler to maintain.
28
+ * @example A map serializer.
29
+ *
30
+ * ```jsx
31
+ * {
32
+ * heading1: ({children}) => <Heading>{children}</Heading>
33
+ * }
34
+ * ```
35
+ *
36
+ * @example A function serializer.
37
+ *
38
+ * ```jsx
39
+ * (type, node, content, children) => {
40
+ * switch (type) {
41
+ * case "heading1": {
42
+ * return <Heading>{children}</Heading>;
43
+ * }
44
+ * }
45
+ * };
46
+ * ```
47
+ */
48
+ components?: JSXMapSerializer | JSXFunctionSerializer;
49
+ /**
50
+ * The React component rendered for links when the URL is internal.
51
+ *
52
+ * @defaultValue `<a>`
53
+ */
54
+ internalLinkComponent?: React.ComponentType<LinkProps>;
55
+ /**
56
+ * The React component rendered for links when the URL is external.
57
+ *
58
+ * @defaultValue `<a>`
59
+ */
60
+ externalLinkComponent?: React.ComponentType<LinkProps>;
61
+ /**
62
+ * The value to be rendered when the field is empty. If a fallback is not
63
+ * given, `null` will be rendered.
64
+ */
65
+ fallback?: React.ReactNode;
66
+ };
67
+ /**
68
+ * React component that renders content from a Prismic Rich Text field. By
69
+ * default, HTML elements are rendered for each piece of content. A `heading1`
70
+ * block will render an `<h1>` HTML element, for example. Links will use
71
+ * `<PrismicLink>` by default which can be customized using the
72
+ * `internalLinkComponent` and `externalLinkComponent` props.
73
+ *
74
+ * To customize the components that are rendered, provide a map or function
75
+ * serializer to the `components` prop.
76
+ *
77
+ * @remarks
78
+ * This component returns a React fragment with no wrapping element around the
79
+ * content. If you need a wrapper, add a component around `<PrismicRichText>`.
80
+ * @example Rendering a Rich Text field using the default HTMl elements.
81
+ *
82
+ * ```jsx
83
+ * <PrismicRichText field={document.data.content} />;
84
+ * ```
85
+ *
86
+ * @example Rendering a Rich Text field using a custom set of React components.
87
+ *
88
+ * ```jsx
89
+ * <PrismicRichText
90
+ * field={document.data.content}
91
+ * components={{
92
+ * heading1: ({ children }) => <Heading>{children}</Heading>,
93
+ * }}
94
+ * />;
95
+ * ```
96
+ *
97
+ * @param props - Props for the component.
98
+ *
99
+ * @returns The Rich Text field's content as React components.
100
+ *
101
+ * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
102
+ * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
103
+ */
104
+ export declare function PrismicRichText<LinkResolverFunction extends prismic.LinkResolverFunction<any>>({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, }: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null;
@@ -0,0 +1,73 @@
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import * as prismic from "@prismicio/client";
4
+ import * as prismicR from "@prismicio/richtext";
5
+ import { PrismicLink } from "./PrismicLink.js";
6
+ const createDefaultSerializer = (args) => prismicR.wrapMapSerializer({
7
+ heading1: ({ children, key }) => /* @__PURE__ */ jsx("h1", { children }, key),
8
+ heading2: ({ children, key }) => /* @__PURE__ */ jsx("h2", { children }, key),
9
+ heading3: ({ children, key }) => /* @__PURE__ */ jsx("h3", { children }, key),
10
+ heading4: ({ children, key }) => /* @__PURE__ */ jsx("h4", { children }, key),
11
+ heading5: ({ children, key }) => /* @__PURE__ */ jsx("h5", { children }, key),
12
+ heading6: ({ children, key }) => /* @__PURE__ */ jsx("h6", { children }, key),
13
+ paragraph: ({ children, key }) => /* @__PURE__ */ jsx("p", { children }, key),
14
+ preformatted: ({ node, key }) => /* @__PURE__ */ jsx("pre", { children: node.text }, key),
15
+ strong: ({ children, key }) => /* @__PURE__ */ jsx("strong", { children }, key),
16
+ em: ({ children, key }) => /* @__PURE__ */ jsx("em", { children }, key),
17
+ listItem: ({ children, key }) => /* @__PURE__ */ jsx("li", { children }, key),
18
+ oListItem: ({ children, key }) => /* @__PURE__ */ jsx("li", { children }, key),
19
+ list: ({ children, key }) => /* @__PURE__ */ jsx("ul", { children }, key),
20
+ oList: ({ children, key }) => /* @__PURE__ */ jsx("ol", { children }, key),
21
+ image: ({ node, key }) => {
22
+ const img = /* @__PURE__ */ jsx("img", { src: node.url, alt: node.alt ?? void 0, "data-copyright": node.copyright ? node.copyright : void 0 });
23
+ return /* @__PURE__ */ jsx("p", { className: "block-img", children: node.linkTo ? /* @__PURE__ */ jsx(PrismicLink, { linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, field: node.linkTo, children: img }) : img }, key);
24
+ },
25
+ embed: ({ node, key }) => /* @__PURE__ */ jsx("div", { "data-oembed": node.oembed.embed_url, "data-oembed-type": node.oembed.type, "data-oembed-provider": node.oembed.provider_name, dangerouslySetInnerHTML: { __html: node.oembed.html ?? "" } }, key),
26
+ hyperlink: ({ node, children, key }) => /* @__PURE__ */ jsx(PrismicLink, { field: node.data, linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, children }, key),
27
+ label: ({ node, children, key }) => /* @__PURE__ */ jsx("span", { className: node.data.label, children }, key),
28
+ span: ({ text, key }) => {
29
+ const result = [];
30
+ let i = 0;
31
+ for (const line of text.split("\n")) {
32
+ if (i > 0) {
33
+ result.push(/* @__PURE__ */ jsx("br", {}, `${i}__break`));
34
+ }
35
+ result.push(/* @__PURE__ */ jsx(React.Fragment, { children: line }, `${i}__line`));
36
+ i++;
37
+ }
38
+ return /* @__PURE__ */ jsx(React.Fragment, { children: result }, key);
39
+ }
40
+ });
41
+ function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent }) {
42
+ return React.useMemo(() => {
43
+ if (prismic.isFilled.richText(field)) {
44
+ const serializer = prismicR.composeSerializers(typeof components === "object" ? prismicR.wrapMapSerializer(components) : components, createDefaultSerializer({
45
+ linkResolver,
46
+ internalLinkComponent,
47
+ externalLinkComponent
48
+ }));
49
+ const serialized = prismicR.serialize(field, (type, node, text, children, key) => {
50
+ const result = serializer(type, node, text, children, key);
51
+ if (React.isValidElement(result) && result.key == null) {
52
+ return React.cloneElement(result, { key });
53
+ } else {
54
+ return result;
55
+ }
56
+ });
57
+ return /* @__PURE__ */ jsx(Fragment, { children: serialized });
58
+ } else {
59
+ return fallback != null ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
60
+ }
61
+ }, [
62
+ field,
63
+ internalLinkComponent,
64
+ externalLinkComponent,
65
+ components,
66
+ linkResolver,
67
+ fallback
68
+ ]);
69
+ }
70
+ export {
71
+ PrismicRichText
72
+ };
73
+ //# sourceMappingURL=PrismicRichText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicRichText.js","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.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 * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\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 * @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?: React.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?: React.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?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ children, key }) => <h1 key={key}>{children}</h1>,\n\t\theading2: ({ children, key }) => <h2 key={key}>{children}</h2>,\n\t\theading3: ({ children, key }) => <h3 key={key}>{children}</h3>,\n\t\theading4: ({ children, key }) => <h4 key={key}>{children}</h4>,\n\t\theading5: ({ children, key }) => <h5 key={key}>{children}</h5>,\n\t\theading6: ({ children, key }) => <h6 key={key}>{children}</h6>,\n\t\tparagraph: ({ children, key }) => <p key={key}>{children}</p>,\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: ({ children, key }) => <li key={key}>{children}</li>,\n\t\toListItem: ({ children, key }) => <li key={key}>{children}</li>,\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: React.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(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":[],"mappings":";;;;;AAuFA,MAAM,0BAA0B,CAI/B,SAEA,SAAS,kBAAkB;AAAA,EAC1B,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MAAc,EAAA,SAAA,GAAN,GAAe;AAAA,EACzD,UAAU,CAAC,EAAE,UAAU,IAAU,MAAA,oBAAC,MA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Q,EAAE,IAAK,CAAA;AAAA,QAAA,OACnC;AACC,iBAAA;AAAA,QACP;AAAA,MAAA,CACD;AAGF,6CAAU,UAAW,WAAA,CAAA;AAAA,IAAA,OACf;AACN,aAAO,YAAY,OAAU,oBAAA,UAAA,EAAA,UAAA,UAAS,IAAM;AAAA,IAC5C;AAAA,EAAA,GACC;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
@@ -0,0 +1,4 @@
1
+ export { PrismicLink } from "./PrismicLink";
2
+ export { PrismicRichText } from "./PrismicRichText";
3
+ export { PrismicProvider, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useAllPrismicDocumentsDangerously, useFirstPrismicDocument, usePrismicClient, usePrismicContext, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicPreviewResolver, useSinglePrismicDocument, } from "./unsupported";
4
+ export { Element, PrismicImage, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent, } from "..";
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function buildErrorMessage(fnName) {
4
+ return `${fnName} is not supported in Server Components. Remove all uses of ${fnName} in Server Components.`;
5
+ }
6
+ function buildHookErrorMessage(fnName) {
7
+ return `${fnName} is not supported in Server Components. Replace all uses of ${fnName} in Server Components with direct use of \`@prismicio/client\`.`;
8
+ }
9
+ function PrismicProvider() {
10
+ throw new Error(buildErrorMessage("<PrismicProvider>"));
11
+ }
12
+ function usePrismicContext() {
13
+ throw new Error(buildErrorMessage("usePrismicContext()"));
14
+ }
15
+ function usePrismicClient() {
16
+ throw new Error(buildHookErrorMessage("usePrismicClient()"));
17
+ }
18
+ function usePrismicPreviewResolver() {
19
+ throw new Error(buildHookErrorMessage("usePrismicPreviewResolver()"));
20
+ }
21
+ function useAllPrismicDocumentsDangerously() {
22
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsDangerously()"));
23
+ }
24
+ function useAllPrismicDocumentsByEveryTag() {
25
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByEveryTag()"));
26
+ }
27
+ function useAllPrismicDocumentsByIDs() {
28
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByIDs()"));
29
+ }
30
+ function useAllPrismicDocumentsBySomeTags() {
31
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsBySomeTags()"));
32
+ }
33
+ function useAllPrismicDocumentsByTag() {
34
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByTag()"));
35
+ }
36
+ function useAllPrismicDocumentsByType() {
37
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByType()"));
38
+ }
39
+ function useAllPrismicDocumentsByUIDs() {
40
+ throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByUIDs()"));
41
+ }
42
+ function useFirstPrismicDocument() {
43
+ throw new Error(buildHookErrorMessage("useFirstPrismicDocument()"));
44
+ }
45
+ function usePrismicDocumentByID() {
46
+ throw new Error(buildHookErrorMessage("usePrismicDocumentByID()"));
47
+ }
48
+ function usePrismicDocumentByUID() {
49
+ throw new Error(buildHookErrorMessage("usePrismicDocumentByUID()"));
50
+ }
51
+ function usePrismicDocuments() {
52
+ throw new Error(buildHookErrorMessage("usePrismicDocuments()"));
53
+ }
54
+ function usePrismicDocumentsByEveryTag() {
55
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsByEveryTag()"));
56
+ }
57
+ function usePrismicDocumentsByIDs() {
58
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsByIDs()"));
59
+ }
60
+ function usePrismicDocumentsBySomeTags() {
61
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsBySomeTags()"));
62
+ }
63
+ function usePrismicDocumentsByTag() {
64
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsByTag()"));
65
+ }
66
+ function usePrismicDocumentsByType() {
67
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsByType()"));
68
+ }
69
+ function usePrismicDocumentsByUIDs() {
70
+ throw new Error(buildHookErrorMessage("usePrismicDocumentsByUIDs()"));
71
+ }
72
+ function useSinglePrismicDocument() {
73
+ throw new Error(buildHookErrorMessage("useSinglePrismicDocument()"));
74
+ }
75
+ exports.PrismicProvider = PrismicProvider;
76
+ exports.useAllPrismicDocumentsByEveryTag = useAllPrismicDocumentsByEveryTag;
77
+ exports.useAllPrismicDocumentsByIDs = useAllPrismicDocumentsByIDs;
78
+ exports.useAllPrismicDocumentsBySomeTags = useAllPrismicDocumentsBySomeTags;
79
+ exports.useAllPrismicDocumentsByTag = useAllPrismicDocumentsByTag;
80
+ exports.useAllPrismicDocumentsByType = useAllPrismicDocumentsByType;
81
+ exports.useAllPrismicDocumentsByUIDs = useAllPrismicDocumentsByUIDs;
82
+ exports.useAllPrismicDocumentsDangerously = useAllPrismicDocumentsDangerously;
83
+ exports.useFirstPrismicDocument = useFirstPrismicDocument;
84
+ exports.usePrismicClient = usePrismicClient;
85
+ exports.usePrismicContext = usePrismicContext;
86
+ exports.usePrismicDocumentByID = usePrismicDocumentByID;
87
+ exports.usePrismicDocumentByUID = usePrismicDocumentByUID;
88
+ exports.usePrismicDocuments = usePrismicDocuments;
89
+ exports.usePrismicDocumentsByEveryTag = usePrismicDocumentsByEveryTag;
90
+ exports.usePrismicDocumentsByIDs = usePrismicDocumentsByIDs;
91
+ exports.usePrismicDocumentsBySomeTags = usePrismicDocumentsBySomeTags;
92
+ exports.usePrismicDocumentsByTag = usePrismicDocumentsByTag;
93
+ exports.usePrismicDocumentsByType = usePrismicDocumentsByType;
94
+ exports.usePrismicDocumentsByUIDs = usePrismicDocumentsByUIDs;
95
+ exports.usePrismicPreviewResolver = usePrismicPreviewResolver;
96
+ exports.useSinglePrismicDocument = useSinglePrismicDocument;
97
+ //# sourceMappingURL=unsupported.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported.cjs","sources":["../../../src/react-server/unsupported.ts"],"sourcesContent":["// Exports in this file are unsupported in the react-server environment.\n// All environments should export the same functions to maintian API compatability.\n\nfunction buildErrorMessage(fnName: string) {\n\treturn `${fnName} is not supported in Server Components. Remove all uses of ${fnName} in Server Components.`;\n}\n\nfunction buildHookErrorMessage(fnName: string) {\n\treturn `${fnName} is not supported in Server Components. Replace all uses of ${fnName} in Server Components with direct use of \\`@prismicio/client\\`.`;\n}\n\nexport function PrismicProvider(): JSX.Element {\n\tthrow new Error(buildErrorMessage(\"<PrismicProvider>\"));\n}\n\nexport function usePrismicContext() {\n\tthrow new Error(buildErrorMessage(\"usePrismicContext()\"));\n}\n\nexport function usePrismicClient() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicClient()\"));\n}\n\nexport function usePrismicPreviewResolver() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicPreviewResolver()\"));\n}\n\nexport function useAllPrismicDocumentsDangerously() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsDangerously()\"));\n}\n\nexport function useAllPrismicDocumentsByEveryTag() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsByEveryTag()\"));\n}\n\nexport function useAllPrismicDocumentsByIDs() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsByIDs()\"));\n}\n\nexport function useAllPrismicDocumentsBySomeTags() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsBySomeTags()\"));\n}\n\nexport function useAllPrismicDocumentsByTag() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsByTag()\"));\n}\n\nexport function useAllPrismicDocumentsByType() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsByType()\"));\n}\n\nexport function useAllPrismicDocumentsByUIDs() {\n\tthrow new Error(buildHookErrorMessage(\"useAllPrismicDocumentsByUIDs()\"));\n}\n\nexport function useFirstPrismicDocument() {\n\tthrow new Error(buildHookErrorMessage(\"useFirstPrismicDocument()\"));\n}\n\nexport function usePrismicDocumentByID() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentByID()\"));\n}\n\nexport function usePrismicDocumentByUID() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentByUID()\"));\n}\n\nexport function usePrismicDocuments() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocuments()\"));\n}\n\nexport function usePrismicDocumentsByEveryTag() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsByEveryTag()\"));\n}\n\nexport function usePrismicDocumentsByIDs() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsByIDs()\"));\n}\n\nexport function usePrismicDocumentsBySomeTags() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsBySomeTags()\"));\n}\n\nexport function usePrismicDocumentsByTag() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsByTag()\"));\n}\n\nexport function usePrismicDocumentsByType() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsByType()\"));\n}\n\nexport function usePrismicDocumentsByUIDs() {\n\tthrow new Error(buildHookErrorMessage(\"usePrismicDocumentsByUIDs()\"));\n}\n\nexport function useSinglePrismicDocument() {\n\tthrow new Error(buildHookErrorMessage(\"useSinglePrismicDocument()\"));\n}\n"],"names":[],"mappings":";;AAGA,SAAS,kBAAkB,QAAc;AACxC,SAAO,GAAG,oEAAoE;AAC/E;AAEA,SAAS,sBAAsB,QAAc;AAC5C,SAAO,GAAG,qEAAqE;AAChF;SAEgB,kBAAe;AAC9B,QAAM,IAAI,MAAM,kBAAkB,mBAAmB,CAAC;AACvD;SAEgB,oBAAiB;AAChC,QAAM,IAAI,MAAM,kBAAkB,qBAAqB,CAAC;AACz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,6BAA6B,CAAC;AACrE;SAEgB,4BAAyB;AACxC,QAAM,IAAI,MAAM,sBAAsB,6BAA6B,CAAC;AACrE;SAEgB,2BAAwB;AACvC,QAAM,IAAI,MAAM,sBAAsB,4BAA4B,CAAC;AACpE;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,22 @@
1
+ export declare function PrismicProvider(): JSX.Element;
2
+ export declare function usePrismicContext(): void;
3
+ export declare function usePrismicClient(): void;
4
+ export declare function usePrismicPreviewResolver(): void;
5
+ export declare function useAllPrismicDocumentsDangerously(): void;
6
+ export declare function useAllPrismicDocumentsByEveryTag(): void;
7
+ export declare function useAllPrismicDocumentsByIDs(): void;
8
+ export declare function useAllPrismicDocumentsBySomeTags(): void;
9
+ export declare function useAllPrismicDocumentsByTag(): void;
10
+ export declare function useAllPrismicDocumentsByType(): void;
11
+ export declare function useAllPrismicDocumentsByUIDs(): void;
12
+ export declare function useFirstPrismicDocument(): void;
13
+ export declare function usePrismicDocumentByID(): void;
14
+ export declare function usePrismicDocumentByUID(): void;
15
+ export declare function usePrismicDocuments(): void;
16
+ export declare function usePrismicDocumentsByEveryTag(): void;
17
+ export declare function usePrismicDocumentsByIDs(): void;
18
+ export declare function usePrismicDocumentsBySomeTags(): void;
19
+ export declare function usePrismicDocumentsByTag(): void;
20
+ export declare function usePrismicDocumentsByType(): void;
21
+ export declare function usePrismicDocumentsByUIDs(): void;
22
+ export declare function useSinglePrismicDocument(): void;