@prismicio/react 2.5.0 → 2.5.2

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 (103) hide show
  1. package/dist/PrismicImage.cjs +67 -0
  2. package/dist/PrismicImage.cjs.map +1 -0
  3. package/dist/PrismicImage.d.ts +163 -0
  4. package/dist/PrismicImage.js +49 -0
  5. package/dist/PrismicImage.js.map +1 -0
  6. package/dist/PrismicLink.cjs +91 -0
  7. package/dist/PrismicLink.cjs.map +1 -0
  8. package/dist/PrismicLink.d.ts +105 -0
  9. package/dist/PrismicLink.js +73 -0
  10. package/dist/PrismicLink.js.map +1 -0
  11. package/dist/PrismicProvider.cjs +41 -0
  12. package/dist/PrismicProvider.cjs.map +1 -0
  13. package/dist/PrismicProvider.d.ts +84 -0
  14. package/dist/PrismicProvider.js +24 -0
  15. package/dist/PrismicProvider.js.map +1 -0
  16. package/dist/PrismicRichText.cjs +97 -0
  17. package/dist/PrismicRichText.cjs.map +1 -0
  18. package/dist/PrismicRichText.d.ts +116 -0
  19. package/dist/PrismicRichText.js +78 -0
  20. package/dist/PrismicRichText.js.map +1 -0
  21. package/dist/PrismicText.cjs +42 -0
  22. package/dist/PrismicText.cjs.map +1 -0
  23. package/dist/PrismicText.d.ts +39 -0
  24. package/dist/PrismicText.js +24 -0
  25. package/dist/PrismicText.js.map +1 -0
  26. package/dist/PrismicToolbar.cjs +41 -0
  27. package/dist/PrismicToolbar.cjs.map +1 -0
  28. package/dist/PrismicToolbar.d.ts +21 -0
  29. package/dist/PrismicToolbar.js +24 -0
  30. package/dist/PrismicToolbar.js.map +1 -0
  31. package/dist/SliceZone.cjs +58 -0
  32. package/dist/SliceZone.cjs.map +1 -0
  33. package/dist/SliceZone.d.ts +188 -0
  34. package/dist/SliceZone.js +41 -0
  35. package/dist/SliceZone.js.map +1 -0
  36. package/dist/clientHooks.cjs +40 -0
  37. package/dist/clientHooks.cjs.map +1 -0
  38. package/dist/clientHooks.d.ts +357 -0
  39. package/dist/clientHooks.js +40 -0
  40. package/dist/clientHooks.js.map +1 -0
  41. package/dist/index.cjs +46 -574
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.ts +23 -1267
  44. package/dist/index.js +46 -519
  45. package/dist/index.js.map +1 -1
  46. package/dist/lib/__PRODUCTION__.cjs +8 -0
  47. package/dist/lib/__PRODUCTION__.cjs.map +1 -0
  48. package/dist/lib/__PRODUCTION__.d.ts +7 -0
  49. package/dist/lib/__PRODUCTION__.js +8 -0
  50. package/dist/lib/__PRODUCTION__.js.map +1 -0
  51. package/dist/lib/devMsg.cjs +8 -0
  52. package/dist/lib/devMsg.cjs.map +1 -0
  53. package/dist/lib/devMsg.d.ts +16 -0
  54. package/dist/lib/devMsg.js +8 -0
  55. package/dist/lib/devMsg.js.map +1 -0
  56. package/dist/lib/invariant.cjs +15 -0
  57. package/dist/lib/invariant.cjs.map +1 -0
  58. package/dist/lib/invariant.d.ts +24 -0
  59. package/dist/lib/invariant.js +15 -0
  60. package/dist/lib/invariant.js.map +1 -0
  61. package/dist/lib/isInternalURL.cjs +9 -0
  62. package/dist/lib/isInternalURL.cjs.map +1 -0
  63. package/dist/lib/isInternalURL.d.ts +8 -0
  64. package/dist/lib/isInternalURL.js +9 -0
  65. package/dist/lib/isInternalURL.js.map +1 -0
  66. package/dist/lib/pascalCase.cjs +10 -0
  67. package/dist/lib/pascalCase.cjs.map +1 -0
  68. package/dist/lib/pascalCase.d.ts +26 -0
  69. package/dist/lib/pascalCase.js +10 -0
  70. package/dist/lib/pascalCase.js.map +1 -0
  71. package/dist/package.json.cjs +5 -0
  72. package/dist/package.json.cjs.map +1 -0
  73. package/dist/package.json.js +5 -0
  74. package/dist/package.json.js.map +1 -0
  75. package/dist/types.d.ts +19 -0
  76. package/dist/usePrismicClient.cjs +12 -0
  77. package/dist/usePrismicClient.cjs.map +1 -0
  78. package/dist/usePrismicClient.d.ts +11 -0
  79. package/dist/usePrismicClient.js +12 -0
  80. package/dist/usePrismicClient.js.map +1 -0
  81. package/dist/usePrismicContext.cjs +26 -0
  82. package/dist/usePrismicContext.cjs.map +1 -0
  83. package/dist/usePrismicContext.d.ts +8 -0
  84. package/dist/usePrismicContext.js +9 -0
  85. package/dist/usePrismicContext.js.map +1 -0
  86. package/dist/usePrismicPreviewResolver.cjs +44 -0
  87. package/dist/usePrismicPreviewResolver.cjs.map +1 -0
  88. package/dist/usePrismicPreviewResolver.d.ts +45 -0
  89. package/dist/usePrismicPreviewResolver.js +27 -0
  90. package/dist/usePrismicPreviewResolver.js.map +1 -0
  91. package/dist/useStatefulPrismicClientMethod.cjs +89 -0
  92. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -0
  93. package/dist/useStatefulPrismicClientMethod.d.ts +44 -0
  94. package/dist/useStatefulPrismicClientMethod.js +72 -0
  95. package/dist/useStatefulPrismicClientMethod.js.map +1 -0
  96. package/package.json +43 -41
  97. package/src/PrismicImage.tsx +2 -1
  98. package/src/PrismicLink.tsx +0 -1
  99. package/src/PrismicProvider.tsx +6 -3
  100. package/src/PrismicText.tsx +2 -1
  101. package/src/SliceZone.tsx +8 -4
  102. package/src/clientHooks.ts +52 -44
  103. package/src/useStatefulPrismicClientMethod.ts +2 -1
@@ -0,0 +1,39 @@
1
+ import * as prismicT from "@prismicio/types";
2
+ /**
3
+ * Props for `<PrismicText>`.
4
+ */
5
+ export type PrismicTextProps = {
6
+ /**
7
+ * The Prismic Rich Text field to render.
8
+ */
9
+ field: prismicT.RichTextField | null | undefined;
10
+ /**
11
+ * The string rendered when the field is empty. If a fallback is not given,
12
+ * `null` will be rendered.
13
+ */
14
+ fallback?: string;
15
+ /**
16
+ * The separator used between blocks. Defaults to `\n`.
17
+ */
18
+ separator?: string;
19
+ };
20
+ /**
21
+ * React component that renders content from a Prismic Rich Text field as plain
22
+ * text.
23
+ *
24
+ * @remarks
25
+ * This component returns a React fragment with no wrapping element around the
26
+ * content. If you need a wrapper, add a component around `<PrismicText>`.
27
+ * @example Rendering a Rich Text field as plain text.
28
+ *
29
+ * ```jsx
30
+ * <PrismicText field={document.data.content} />;
31
+ * ```
32
+ *
33
+ * @param props - Props for the component.
34
+ *
35
+ * @returns The Rich Text field's content as plain text.
36
+ *
37
+ * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
38
+ */
39
+ export declare const PrismicText: (props: PrismicTextProps) => JSX.Element | null;
@@ -0,0 +1,24 @@
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import * as prismicH from "@prismicio/helpers";
4
+ import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
5
+ import { devMsg } from "./lib/devMsg.js";
6
+ const PrismicText = (props) => {
7
+ if (!__PRODUCTION__) {
8
+ if (typeof props.field === "string") {
9
+ throw new Error(`[PrismicText] The "field" prop only accepts a Rich Text or Title 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("prismictext-works-only-with-rich-text-and-title-fields")}`);
10
+ }
11
+ }
12
+ return React.useMemo(() => {
13
+ if (prismicH.isFilled.richText(props.field)) {
14
+ const text = prismicH.asText(props.field, props.separator);
15
+ return /* @__PURE__ */ jsx(Fragment, { children: text });
16
+ } else {
17
+ return props.fallback != null ? /* @__PURE__ */ jsx(Fragment, { children: props.fallback }) : null;
18
+ }
19
+ }, [props.field, props.fallback, props.separator]);
20
+ };
21
+ export {
22
+ PrismicText
23
+ };
24
+ //# sourceMappingURL=PrismicText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicText.js","sources":["../../src/PrismicText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as prismicH from \"@prismicio/helpers\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicText>`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismicT.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/**\n\t * The separator used between blocks. Defaults to `\\n`.\n\t */\n\tseparator?: string;\n};\n\n/**\n * React component that renders content from a Prismic Rich Text field as plain\n * text.\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 `<PrismicText>`.\n * @example Rendering a Rich Text field as plain text.\n *\n * ```jsx\n * <PrismicText field={document.data.content} />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as plain text.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText = (props: PrismicTextProps): JSX.Element | null => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or Title 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);\n\t\t}\n\t}\n\n\treturn React.useMemo(() => {\n\t\tif (prismicH.isFilled.richText(props.field)) {\n\t\t\tconst text = prismicH.asText(props.field, props.separator);\n\n\t\t\treturn <>{text}</>;\n\t\t} else {\n\t\t\treturn props.fallback != null ? <>{props.fallback}</> : null;\n\t\t}\n\t}, [props.field, props.fallback, props.separator]);\n};\n"],"names":[],"mappings":";;;;;AA+Ca,MAAA,cAAc,CAAC,UAA+C;AAC1E,MAAI,CAAC,gBAAgB;AAChB,QAAA,OAAO,MAAM,UAAU,UAAU;AACpC,YAAM,IAAI,MACT,oRAAoR,OACnR,wDAAwD,GACtD;AAAA,IAEJ;AAAA,EACD;AAEM,SAAA,MAAM,QAAQ,MAAK;AACzB,QAAI,SAAS,SAAS,SAAS,MAAM,KAAK,GAAG;AAC5C,YAAM,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,SAAS;AAEzD,6CAAU,UAAK,KAAA,CAAA;AAAA,IAAA,OACT;AACN,aAAO,MAAM,YAAY,OAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,SAAS,CAAA,IAAM;AAAA,IACxD;AAAA,EAAA,GACC,CAAC,MAAM,OAAO,MAAM,UAAU,MAAM,SAAS,CAAC;AAClD;"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ function _interopNamespaceDefault(e) {
5
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
+ if (e) {
7
+ for (const k in e) {
8
+ if (k !== "default") {
9
+ const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
+ const PrismicToolbar = ({ repositoryName, type = "new" }) => {
22
+ const src = `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}${type === "new" ? "&new=true" : ""}`;
23
+ React__namespace.useEffect(() => {
24
+ const existingScript = document.querySelector(`script[src="${src}"]`);
25
+ if (!existingScript) {
26
+ const script = document.createElement("script");
27
+ script.src = src;
28
+ script.defer = true;
29
+ script.dataset.prismicToolbar = "";
30
+ script.dataset.repositoryName = repositoryName;
31
+ script.dataset.type = type;
32
+ if (process.env.NODE_ENV === "test") {
33
+ script._evaluateScript = false;
34
+ }
35
+ document.body.appendChild(script);
36
+ }
37
+ }, [repositoryName, type, src]);
38
+ return null;
39
+ };
40
+ exports.PrismicToolbar = PrismicToolbar;
41
+ //# sourceMappingURL=PrismicToolbar.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicToolbar.cjs","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["import * as React from \"react\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\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\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n\ttype = \"new\",\n}: PrismicToolbarProps): null => {\n\tconst src = `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}${\n\t\ttype === \"new\" ? \"&new=true\" : \"\"\n\t}`;\n\n\tReact.useEffect(() => {\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\t\t\tscript.dataset.type = type;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, type, src]);\n\n\treturn null;\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,iBAAiB,CAAC,EAC9B,gBACA,OAAO,YACwB;AAC/B,QAAM,MAAM,iDAAiD,iBAC5D,SAAS,QAAQ,cAAc;AAGhCA,mBAAM,UAAU,MAAK;AACpB,UAAM,iBAAiB,SAAS,cAAc,eAAe,OAAO;AAEpE,QAAI,CAAC,gBAAgB;AACd,YAAA,SAAS,SAAS,cAAc,QAAQ;AAC9C,aAAO,MAAM;AACb,aAAO,QAAQ;AAGf,aAAO,QAAQ,iBAAiB;AAChC,aAAO,QAAQ,iBAAiB;AAChC,aAAO,QAAQ,OAAO;AAUlB,UAAA,QAAQ,IAAI,aAAa,QAAQ;AAEpC,eAAO,kBAAkB;AAAA,MACzB;AAEQ,eAAA,KAAK,YAAY,MAAM;AAAA,IAChC;AAAA,EACC,GAAA,CAAC,gBAAgB,MAAM,GAAG,CAAC;AAEvB,SAAA;AACR;;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Props for `<PrismicToolbar>`.
3
+ */
4
+ export type PrismicToolbarProps = {
5
+ /**
6
+ * The name of the Prismic repository. For example, `"my-repo"` if the
7
+ * repository URL is `my-repo.prismic.io`.
8
+ */
9
+ repositoryName: string;
10
+ /**
11
+ * The type of toolbar needed for the repository. Defaults to `"new"`.
12
+ *
13
+ * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}
14
+ */
15
+ type?: "new" | "legacy";
16
+ };
17
+ /**
18
+ * React component that injects the Prismic Toolbar into the app. This component
19
+ * can be placed anywhere in the React tree.
20
+ */
21
+ export declare const PrismicToolbar: ({ repositoryName, type, }: PrismicToolbarProps) => null;
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ const PrismicToolbar = ({ repositoryName, type = "new" }) => {
3
+ const src = `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}${type === "new" ? "&new=true" : ""}`;
4
+ React.useEffect(() => {
5
+ const existingScript = document.querySelector(`script[src="${src}"]`);
6
+ if (!existingScript) {
7
+ const script = document.createElement("script");
8
+ script.src = src;
9
+ script.defer = true;
10
+ script.dataset.prismicToolbar = "";
11
+ script.dataset.repositoryName = repositoryName;
12
+ script.dataset.type = type;
13
+ if (process.env.NODE_ENV === "test") {
14
+ script._evaluateScript = false;
15
+ }
16
+ document.body.appendChild(script);
17
+ }
18
+ }, [repositoryName, type, src]);
19
+ return null;
20
+ };
21
+ export {
22
+ PrismicToolbar
23
+ };
24
+ //# sourceMappingURL=PrismicToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicToolbar.js","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["import * as React from \"react\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\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\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n\ttype = \"new\",\n}: PrismicToolbarProps): null => {\n\tconst src = `https://static.cdn.prismic.io/prismic.js?repo=${repositoryName}${\n\t\ttype === \"new\" ? \"&new=true\" : \"\"\n\t}`;\n\n\tReact.useEffect(() => {\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\t\t\tscript.dataset.type = type;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, type, src]);\n\n\treturn null;\n};\n"],"names":[],"mappings":";AAwBO,MAAM,iBAAiB,CAAC,EAC9B,gBACA,OAAO,YACwB;AAC/B,QAAM,MAAM,iDAAiD,iBAC5D,SAAS,QAAQ,cAAc;AAGhC,QAAM,UAAU,MAAK;AACpB,UAAM,iBAAiB,SAAS,cAAc,eAAe,OAAO;AAEpE,QAAI,CAAC,gBAAgB;AACd,YAAA,SAAS,SAAS,cAAc,QAAQ;AAC9C,aAAO,MAAM;AACb,aAAO,QAAQ;AAGf,aAAO,QAAQ,iBAAiB;AAChC,aAAO,QAAQ,iBAAiB;AAChC,aAAO,QAAQ,OAAO;AAUlB,UAAA,QAAQ,IAAI,aAAa,QAAQ;AAEpC,eAAO,kBAAkB;AAAA,MACzB;AAEQ,eAAA,KAAK,YAAY,MAAM;AAAA,IAChC;AAAA,EACC,GAAA,CAAC,gBAAgB,MAAM,GAAG,CAAC;AAEvB,SAAA;AACR;"}
@@ -0,0 +1,58 @@
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 __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
6
+ const pascalCase = require("./lib/pascalCase.cjs");
7
+ function _interopNamespaceDefault(e) {
8
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
+ if (e) {
10
+ for (const k in e) {
11
+ if (k !== "default") {
12
+ const d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: () => e[k]
16
+ });
17
+ }
18
+ }
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
24
+ const TODOSliceComponent = __PRODUCTION__.__PRODUCTION__ ? () => null : ({ slice }) => {
25
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
26
+ React__namespace.useEffect(() => {
27
+ console.warn(`[SliceZone] Could not find a component for Slice type "${type}"`, slice);
28
+ }, [slice, type]);
29
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "data-slice-zone-todo-component": "", "data-slice-type": type, children: [
30
+ "Could not find a component for Slice type “",
31
+ type,
32
+ "”"
33
+ ] });
34
+ };
35
+ const SliceZone = ({ slices = [], components = {}, resolver, defaultComponent = TODOSliceComponent, context = {} }) => {
36
+ const renderedSlices = React__namespace.useMemo(() => {
37
+ return slices.map((slice, index) => {
38
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
39
+ let Comp = components[type] || defaultComponent;
40
+ if (resolver) {
41
+ const resolvedComp = resolver({
42
+ slice,
43
+ sliceName: pascalCase.pascalCase(type),
44
+ i: index
45
+ });
46
+ if (resolvedComp) {
47
+ Comp = resolvedComp;
48
+ }
49
+ }
50
+ const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
51
+ return /* @__PURE__ */ jsxRuntime.jsx(Comp, { slice, index, slices, context }, key);
52
+ });
53
+ }, [components, context, defaultComponent, slices, resolver]);
54
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderedSlices });
55
+ };
56
+ exports.SliceZone = SliceZone;
57
+ exports.TODOSliceComponent = TODOSliceComponent;
58
+ //# sourceMappingURL=SliceZone.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.cjs","sources":["../../src/SliceZone.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { pascalCase, PascalCase } from \"./lib/pascalCase\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<Slice extends SliceLike> = Slice extends SliceLikeRestV2\n\t? Slice[\"slice_type\"]\n\t: Slice extends SliceLikeGraphQL\n\t? Slice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<SliceType extends string = string> = {\n\tslice_type: prismicT.Slice<SliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<SliceType extends string = string> = {\n\ttype: prismicT.Slice<SliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLike<SliceType extends string = string> =\n\t| SliceLikeRestV2<SliceType>\n\t| SliceLikeGraphQL<SliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/types` 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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\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<SliceLike>;\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> = React.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 * @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 * 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 = __PRODUCTION__\n\t? () => null\n\t: <TSlice extends SliceLike, TContext>({\n\t\t\tslice,\n\t }: SliceComponentProps<TSlice, TContext>): JSX.Element | null => {\n\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\tReact.useEffect(() => {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type}\"`,\n\t\t\t\t\tslice,\n\t\t\t\t);\n\t\t\t}, [slice, type]);\n\n\t\t\treturn (\n\t\t\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\t\t\tCould not find a component for Slice type &ldquo;{type}\n\t\t\t\t\t&rdquo;\n\t\t\t\t</section>\n\t\t\t);\n\t };\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\ntype SliceZoneResolverArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n> = {\n\t/**\n\t * The Slice to resolve to a React component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: PascalCase<ExtractSliceType<TSlice>>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered React component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The React component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (args: SliceZoneResolverArgs<TSlice>) =>\n\t| SliceComponentType<\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t >\n\t| undefined\n\t| null;\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/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices?: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to React components.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, SliceComponentType<any, TContext>>;\n\n\t/**\n\t * A function that determines the rendered React component for each Slice in\n\t * the Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The React component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\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?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n};\n\n/**\n * Renders content from a Prismic Slice Zone using React components for each\n * type of Slice.\n *\n * If a component is not provided for a type of Slice, a default component can\n * be provided. A fallback component is provided by default that will not be\n * rendered in a production build of your app.\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 *\n * @returns The Slice Zone's content as React components.\n *\n * @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}\n */\nexport const SliceZone = <TContext,>({\n\tslices = [],\n\tcomponents = {},\n\tresolver,\n\tdefaultComponent = TODOSliceComponent,\n\tcontext = {} as TContext,\n}: SliceZoneProps<TContext>): JSX.Element => {\n\tconst renderedSlices = React.useMemo(() => {\n\t\treturn slices.map((slice, index) => {\n\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\tlet Comp =\n\t\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\tif (resolver) {\n\t\t\t\tconst resolvedComp = resolver({\n\t\t\t\t\tslice,\n\t\t\t\t\tsliceName: pascalCase(type),\n\t\t\t\t\ti: index,\n\t\t\t\t});\n\n\t\t\t\tif (resolvedComp) {\n\t\t\t\t\tComp = resolvedComp as typeof Comp;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst key =\n\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t? slice.id\n\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\treturn (\n\t\t\t\t<Comp\n\t\t\t\t\tkey={key}\n\t\t\t\t\tslice={slice}\n\t\t\t\t\tindex={index}\n\t\t\t\t\tslices={slices}\n\t\t\t\t\tcontext={context}\n\t\t\t\t/>\n\t\t\t);\n\t\t});\n\t}, [components, context, defaultComponent, slices, resolver]);\n\n\treturn <>{renderedSlices}</>;\n};\n"],"names":["__PRODUCTION__","React","jsxs","pascalCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2JO,MAAM,qBAAqBA,eAAAA,iBAC/B,MAAM,OACN,CAAqC,EACrC,YACgE;AAChE,QAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9DC,mBAAM,UAAU,MAAK;AACZ,YAAA,KACP,0DAA0D,SAC1D,KAAK;AAAA,EAAA,GAEJ,CAAC,OAAO,IAAI,CAAC;AAEhB,SACEC,2BAAAA,KAAA,WAAA,EAAQ,kCAA+B,IAAG,mBAAiB,MAC3D,UAAA;AAAA,IAAA;AAAA,IAAkD;AAAA,IAClD;AAAA,EACD,EAAA,CAAA;AAED;AA6GI,MAAM,YAAY,CAAY,EACpC,SAAS,CAAA,GACT,aAAa,CAAA,GACb,UACA,mBAAmB,oBACnB,UAAU,SACiC;AACrC,QAAA,iBAAiBD,iBAAM,QAAQ,MAAK;AACzC,WAAO,OAAO,IAAI,CAAC,OAAO,UAAS;AAClC,YAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE1D,UAAA,OACH,WAAW,SAAoC;AAGhD,UAAI,UAAU;AACb,cAAM,eAAe,SAAS;AAAA,UAC7B;AAAA,UACA,WAAWE,sBAAW,IAAI;AAAA,UAC1B,GAAG;AAAA,QAAA,CACH;AAED,YAAI,cAAc;AACV,iBAAA;AAAA,QACP;AAAA,MACD;AAEK,YAAA,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,SAAS,KAAK,UAAU,KAAK;AAEpC,4CACE,MAEA,EAAA,OACA,OACA,QACA,WAJK,GAIY;AAAA,IAAA,CAGnB;AAAA,EAAA,GACC,CAAC,YAAY,SAAS,kBAAkB,QAAQ,QAAQ,CAAC;AAE5D,+DAAU,UAAe,eAAA,CAAA;AAC1B;;;"}
@@ -0,0 +1,188 @@
1
+ import * as React from "react";
2
+ import * as prismicT from "@prismicio/types";
3
+ import { PascalCase } from "./lib/pascalCase";
4
+ /**
5
+ * Returns the type of a `SliceLike` type.
6
+ *
7
+ * @typeParam Slice - The Slice from which the type will be extracted.
8
+ */
9
+ type ExtractSliceType<Slice extends SliceLike> = Slice extends SliceLikeRestV2 ? Slice["slice_type"] : Slice extends SliceLikeGraphQL ? Slice["type"] : never;
10
+ /**
11
+ * The minimum required properties to represent a Prismic Slice from the Prismic
12
+ * Rest API V2 for the `<SliceZone>` component.
13
+ *
14
+ * If using Prismic's Rest API V2, use the `Slice` export from
15
+ * `@prismicio/types` for a full interface.
16
+ *
17
+ * @typeParam SliceType - Type name of the Slice.
18
+ */
19
+ export type SliceLikeRestV2<SliceType extends string = string> = {
20
+ slice_type: prismicT.Slice<SliceType>["slice_type"];
21
+ id?: string;
22
+ };
23
+ /**
24
+ * The minimum required properties to represent a Prismic Slice from the Prismic
25
+ * GraphQL API for the `<SliceZone>` component.
26
+ *
27
+ * @typeParam SliceType - Type name of the Slice.
28
+ */
29
+ export type SliceLikeGraphQL<SliceType extends string = string> = {
30
+ type: prismicT.Slice<SliceType>["slice_type"];
31
+ };
32
+ /**
33
+ * The minimum required properties to represent a Prismic Slice for the
34
+ * `<SliceZone>` component.
35
+ *
36
+ * If using Prismic's Rest API V2, use the `Slice` export from
37
+ * `@prismicio/types` for a full interface.
38
+ *
39
+ * @typeParam SliceType - Type name of the Slice.
40
+ */
41
+ export type SliceLike<SliceType extends string = string> = SliceLikeRestV2<SliceType> | SliceLikeGraphQL<SliceType>;
42
+ /**
43
+ * A looser version of the `SliceZone` type from `@prismicio/types` using
44
+ * `SliceLike`.
45
+ *
46
+ * If using Prismic's Rest API V2, use the `SliceZone` export from
47
+ * `@prismicio/types` for the full type.
48
+ *
49
+ * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
50
+ */
51
+ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
52
+ /**
53
+ * React props for a component rendering content from a Prismic Slice using the
54
+ * `<SliceZone>` component.
55
+ *
56
+ * @typeParam TSlice - The Slice passed as a prop.
57
+ * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made
58
+ * available to all Slice components.
59
+ */
60
+ export type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
61
+ /**
62
+ * Slice data for this component.
63
+ */
64
+ slice: TSlice;
65
+ /**
66
+ * The index of the Slice in the Slice Zone.
67
+ */
68
+ index: number;
69
+ /**
70
+ * All Slices from the Slice Zone to which the Slice belongs.
71
+ */
72
+ slices: SliceZoneLike<SliceLike>;
73
+ /**
74
+ * Arbitrary data passed to `<SliceZone>` and made available to all Slice
75
+ * components.
76
+ */
77
+ context: TContext;
78
+ };
79
+ /**
80
+ * A React component to be rendered for each instance of its Slice.
81
+ *
82
+ * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
83
+ * @typeParam TContext - Arbitrary data made available to all Slice components.
84
+ */
85
+ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = React.ComponentType<SliceComponentProps<TSlice, TContext>>;
86
+ /**
87
+ * A record of Slice types mapped to a React component. The component will be
88
+ * rendered for each instance of its Slice.
89
+ *
90
+ * @deprecated This type is no longer used by `@prismicio/react`. Prefer using
91
+ * `Record<string, SliceComponentType<any>>` instead.
92
+ * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
93
+ * @typeParam TContext - Arbitrary data made available to all Slice components.
94
+ */
95
+ export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
96
+ [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>> extends never ? SliceLike : Extract<TSlice, SliceLike<SliceType>>, TContext>;
97
+ };
98
+ /**
99
+ * This Slice component can be used as a reminder to provide a proper
100
+ * implementation.
101
+ *
102
+ * This is also the default React component rendered when a component mapping
103
+ * cannot be found in `<SliceZone>`.
104
+ */
105
+ export declare const TODOSliceComponent: <TSlice extends SliceLike<string>, TContext>({ slice, }: SliceComponentProps<TSlice, TContext>) => JSX.Element | null;
106
+ /**
107
+ * Arguments for a `<SliceZone>` `resolver` function.
108
+ */
109
+ type SliceZoneResolverArgs<TSlice extends SliceLike = any> = {
110
+ /**
111
+ * The Slice to resolve to a React component.
112
+ */
113
+ slice: TSlice;
114
+ /**
115
+ * The name of the Slice.
116
+ */
117
+ sliceName: PascalCase<ExtractSliceType<TSlice>>;
118
+ /**
119
+ * The index of the Slice in the Slice Zone.
120
+ */
121
+ i: number;
122
+ };
123
+ /**
124
+ * A function that determines the rendered React component for each Slice in the
125
+ * Slice Zone. If a nullish value is returned, the component will fallback to
126
+ * the `components` or `defaultComponent` props to determine the rendered
127
+ * component.
128
+ *
129
+ * @deprecated Use the `components` prop instead.
130
+ *
131
+ * @param args - Arguments for the resolver function.
132
+ *
133
+ * @returns The React component to render for a Slice.
134
+ */
135
+ export type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | undefined | null;
136
+ /**
137
+ * React props for the `<SliceZone>` component.
138
+ *
139
+ * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
140
+ * @typeParam TContext - Arbitrary data made available to all Slice components.
141
+ */
142
+ export type SliceZoneProps<TContext = unknown> = {
143
+ /**
144
+ * List of Slice data from the Slice Zone.
145
+ */
146
+ slices?: SliceZoneLike;
147
+ /**
148
+ * A record mapping Slice types to React components.
149
+ */
150
+ components?: Record<string, SliceComponentType<any, TContext>>;
151
+ /**
152
+ * A function that determines the rendered React component for each Slice in
153
+ * the Slice Zone.
154
+ *
155
+ * @deprecated Use the `components` prop instead.
156
+ *
157
+ * @param args - Arguments for the resolver function.
158
+ *
159
+ * @returns The React component to render for a Slice.
160
+ */
161
+ resolver?: SliceZoneResolver<any, TContext>;
162
+ /**
163
+ * The React component rendered if a component mapping from the `components`
164
+ * prop cannot be found.
165
+ */
166
+ defaultComponent?: SliceComponentType<any, TContext>;
167
+ /**
168
+ * Arbitrary data made available to all Slice components.
169
+ */
170
+ context?: TContext;
171
+ };
172
+ /**
173
+ * Renders content from a Prismic Slice Zone using React components for each
174
+ * type of Slice.
175
+ *
176
+ * If a component is not provided for a type of Slice, a default component can
177
+ * be provided. A fallback component is provided by default that will not be
178
+ * rendered in a production build of your app.
179
+ *
180
+ * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
181
+ * @typeParam TContext - Arbitrary data made available to all Slice components.
182
+ *
183
+ * @returns The Slice Zone's content as React components.
184
+ *
185
+ * @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}
186
+ */
187
+ export declare const SliceZone: <TContext>({ slices, components, resolver, defaultComponent, context, }: SliceZoneProps<TContext>) => JSX.Element;
188
+ export {};
@@ -0,0 +1,41 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
4
+ import { pascalCase } from "./lib/pascalCase.js";
5
+ const TODOSliceComponent = __PRODUCTION__ ? () => null : ({ slice }) => {
6
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
7
+ React.useEffect(() => {
8
+ console.warn(`[SliceZone] Could not find a component for Slice type "${type}"`, slice);
9
+ }, [slice, type]);
10
+ return /* @__PURE__ */ jsxs("section", { "data-slice-zone-todo-component": "", "data-slice-type": type, children: [
11
+ "Could not find a component for Slice type “",
12
+ type,
13
+ "”"
14
+ ] });
15
+ };
16
+ const SliceZone = ({ slices = [], components = {}, resolver, defaultComponent = TODOSliceComponent, context = {} }) => {
17
+ const renderedSlices = React.useMemo(() => {
18
+ return slices.map((slice, index) => {
19
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
20
+ let Comp = components[type] || defaultComponent;
21
+ if (resolver) {
22
+ const resolvedComp = resolver({
23
+ slice,
24
+ sliceName: pascalCase(type),
25
+ i: index
26
+ });
27
+ if (resolvedComp) {
28
+ Comp = resolvedComp;
29
+ }
30
+ }
31
+ const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
32
+ return /* @__PURE__ */ jsx(Comp, { slice, index, slices, context }, key);
33
+ });
34
+ }, [components, context, defaultComponent, slices, resolver]);
35
+ return /* @__PURE__ */ jsx(Fragment, { children: renderedSlices });
36
+ };
37
+ export {
38
+ SliceZone,
39
+ TODOSliceComponent
40
+ };
41
+ //# sourceMappingURL=SliceZone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.js","sources":["../../src/SliceZone.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { pascalCase, PascalCase } from \"./lib/pascalCase\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<Slice extends SliceLike> = Slice extends SliceLikeRestV2\n\t? Slice[\"slice_type\"]\n\t: Slice extends SliceLikeGraphQL\n\t? Slice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<SliceType extends string = string> = {\n\tslice_type: prismicT.Slice<SliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<SliceType extends string = string> = {\n\ttype: prismicT.Slice<SliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLike<SliceType extends string = string> =\n\t| SliceLikeRestV2<SliceType>\n\t| SliceLikeGraphQL<SliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/types` 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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\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<SliceLike>;\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> = React.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 * @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 * 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 = __PRODUCTION__\n\t? () => null\n\t: <TSlice extends SliceLike, TContext>({\n\t\t\tslice,\n\t }: SliceComponentProps<TSlice, TContext>): JSX.Element | null => {\n\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\tReact.useEffect(() => {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type}\"`,\n\t\t\t\t\tslice,\n\t\t\t\t);\n\t\t\t}, [slice, type]);\n\n\t\t\treturn (\n\t\t\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\t\t\tCould not find a component for Slice type &ldquo;{type}\n\t\t\t\t\t&rdquo;\n\t\t\t\t</section>\n\t\t\t);\n\t };\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\ntype SliceZoneResolverArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n> = {\n\t/**\n\t * The Slice to resolve to a React component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: PascalCase<ExtractSliceType<TSlice>>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered React component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The React component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (args: SliceZoneResolverArgs<TSlice>) =>\n\t| SliceComponentType<\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t >\n\t| undefined\n\t| null;\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/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices?: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to React components.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, SliceComponentType<any, TContext>>;\n\n\t/**\n\t * A function that determines the rendered React component for each Slice in\n\t * the Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The React component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\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?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n};\n\n/**\n * Renders content from a Prismic Slice Zone using React components for each\n * type of Slice.\n *\n * If a component is not provided for a type of Slice, a default component can\n * be provided. A fallback component is provided by default that will not be\n * rendered in a production build of your app.\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 *\n * @returns The Slice Zone's content as React components.\n *\n * @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}\n */\nexport const SliceZone = <TContext,>({\n\tslices = [],\n\tcomponents = {},\n\tresolver,\n\tdefaultComponent = TODOSliceComponent,\n\tcontext = {} as TContext,\n}: SliceZoneProps<TContext>): JSX.Element => {\n\tconst renderedSlices = React.useMemo(() => {\n\t\treturn slices.map((slice, index) => {\n\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\tlet Comp =\n\t\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\tif (resolver) {\n\t\t\t\tconst resolvedComp = resolver({\n\t\t\t\t\tslice,\n\t\t\t\t\tsliceName: pascalCase(type),\n\t\t\t\t\ti: index,\n\t\t\t\t});\n\n\t\t\t\tif (resolvedComp) {\n\t\t\t\t\tComp = resolvedComp as typeof Comp;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst key =\n\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t? slice.id\n\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\treturn (\n\t\t\t\t<Comp\n\t\t\t\t\tkey={key}\n\t\t\t\t\tslice={slice}\n\t\t\t\t\tindex={index}\n\t\t\t\t\tslices={slices}\n\t\t\t\t\tcontext={context}\n\t\t\t\t/>\n\t\t\t);\n\t\t});\n\t}, [components, context, defaultComponent, slices, resolver]);\n\n\treturn <>{renderedSlices}</>;\n};\n"],"names":[],"mappings":";;;;AA2JO,MAAM,qBAAqB,iBAC/B,MAAM,OACN,CAAqC,EACrC,YACgE;AAChE,QAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,QAAM,UAAU,MAAK;AACZ,YAAA,KACP,0DAA0D,SAC1D,KAAK;AAAA,EAAA,GAEJ,CAAC,OAAO,IAAI,CAAC;AAEhB,SACE,qBAAA,WAAA,EAAQ,kCAA+B,IAAG,mBAAiB,MAC3D,UAAA;AAAA,IAAA;AAAA,IAAkD;AAAA,IAClD;AAAA,EACD,EAAA,CAAA;AAED;AA6GI,MAAM,YAAY,CAAY,EACpC,SAAS,CAAA,GACT,aAAa,CAAA,GACb,UACA,mBAAmB,oBACnB,UAAU,SACiC;AACrC,QAAA,iBAAiB,MAAM,QAAQ,MAAK;AACzC,WAAO,OAAO,IAAI,CAAC,OAAO,UAAS;AAClC,YAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE1D,UAAA,OACH,WAAW,SAAoC;AAGhD,UAAI,UAAU;AACb,cAAM,eAAe,SAAS;AAAA,UAC7B;AAAA,UACA,WAAW,WAAW,IAAI;AAAA,UAC1B,GAAG;AAAA,QAAA,CACH;AAED,YAAI,cAAc;AACV,iBAAA;AAAA,QACP;AAAA,MACD;AAEK,YAAA,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,SAAS,KAAK,UAAU,KAAK;AAEpC,iCACE,MAEA,EAAA,OACA,OACA,QACA,WAJK,GAIY;AAAA,IAAA,CAGnB;AAAA,EAAA,GACC,CAAC,YAAY,SAAS,kBAAkB,QAAQ,QAAQ,CAAC;AAE5D,yCAAU,UAAe,eAAA,CAAA;AAC1B;"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const useStatefulPrismicClientMethod = require("./useStatefulPrismicClientMethod.cjs");
4
+ const usePrismicDocuments = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("get", args);
5
+ const useFirstPrismicDocument = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getFirst", args);
6
+ const useAllPrismicDocumentsDangerously = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("dangerouslyGetAll", args);
7
+ const usePrismicDocumentByID = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByID", args);
8
+ const usePrismicDocumentsByIDs = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByIDs", args);
9
+ const useAllPrismicDocumentsByIDs = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllByIDs", args);
10
+ const usePrismicDocumentByUID = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByUID", args);
11
+ const usePrismicDocumentsByUIDs = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByUIDs", args);
12
+ const useAllPrismicDocumentsByUIDs = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllByUIDs", args);
13
+ const useSinglePrismicDocument = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getSingle", args);
14
+ const usePrismicDocumentsByType = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByType", args);
15
+ const useAllPrismicDocumentsByType = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllByType", args);
16
+ const usePrismicDocumentsByTag = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByTag", args);
17
+ const useAllPrismicDocumentsByTag = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllByTag", args);
18
+ const usePrismicDocumentsBySomeTags = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getBySomeTags", args);
19
+ const useAllPrismicDocumentsBySomeTags = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllBySomeTags", args);
20
+ const usePrismicDocumentsByEveryTag = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getByEveryTag", args);
21
+ const useAllPrismicDocumentsByEveryTag = (...args) => useStatefulPrismicClientMethod.useStatefulPrismicClientMethod("getAllByEveryTag", args);
22
+ exports.useAllPrismicDocumentsByEveryTag = useAllPrismicDocumentsByEveryTag;
23
+ exports.useAllPrismicDocumentsByIDs = useAllPrismicDocumentsByIDs;
24
+ exports.useAllPrismicDocumentsBySomeTags = useAllPrismicDocumentsBySomeTags;
25
+ exports.useAllPrismicDocumentsByTag = useAllPrismicDocumentsByTag;
26
+ exports.useAllPrismicDocumentsByType = useAllPrismicDocumentsByType;
27
+ exports.useAllPrismicDocumentsByUIDs = useAllPrismicDocumentsByUIDs;
28
+ exports.useAllPrismicDocumentsDangerously = useAllPrismicDocumentsDangerously;
29
+ exports.useFirstPrismicDocument = useFirstPrismicDocument;
30
+ exports.usePrismicDocumentByID = usePrismicDocumentByID;
31
+ exports.usePrismicDocumentByUID = usePrismicDocumentByUID;
32
+ exports.usePrismicDocuments = usePrismicDocuments;
33
+ exports.usePrismicDocumentsByEveryTag = usePrismicDocumentsByEveryTag;
34
+ exports.usePrismicDocumentsByIDs = usePrismicDocumentsByIDs;
35
+ exports.usePrismicDocumentsBySomeTags = usePrismicDocumentsBySomeTags;
36
+ exports.usePrismicDocumentsByTag = usePrismicDocumentsByTag;
37
+ exports.usePrismicDocumentsByType = usePrismicDocumentsByType;
38
+ exports.usePrismicDocumentsByUIDs = usePrismicDocumentsByUIDs;
39
+ exports.useSinglePrismicDocument = useSinglePrismicDocument;
40
+ //# sourceMappingURL=clientHooks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientHooks.cjs","sources":["../../src/clientHooks.ts"],"sourcesContent":["import type * as prismicT from \"@prismicio/types\";\n\nimport {\n\tClientHookReturnType,\n\tClientMethodParameters,\n\tHookOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n/**\n * A hook that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.get}\n */\nexport const usePrismicDocuments = <TDocument extends prismicT.PrismicDocument>(\n\t...args: [params?: ClientMethodParameters<\"get\">[0] & HookOnlyParameters]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns only the\n * first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getFirst}\n */\nexport const useFirstPrismicDocument = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [params?: ClientMethodParameters<\"getFirst\">[0] & HookOnlyParameters]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAll}\n */\nexport const useAllPrismicDocumentsDangerously = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tHookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByID}\n */\nexport const usePrismicDocumentByID = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentByUID = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific UIDs\n * of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentsByUIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * UIDs of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const useAllPrismicDocumentsByUIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A hook that queries a singleton document from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getSingle}\n */\nexport const useSinglePrismicDocument = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A hook that queries documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByType}\n */\nexport const usePrismicDocumentsByType = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTag}\n */\nexport const usePrismicDocumentsByTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n"],"names":["useStatefulPrismicClientMethod"],"mappings":";;;AAuBO,MAAM,sBAAsB,IAC/B,SAEHA,+BAAAA,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IAGnC,SAEHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,oCAAoC,IAG7C,SAKHA,+BAAAA,+BAA+B,qBAAqB,IAAI;AAkBlD,MAAM,yBAAyB,IAGlC,SAKHA,+BAAAA,+BAA+B,WAAW,IAAI;AAiBxC,MAAM,2BAA2B,IAGpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKHA,+BAAAA,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IAGnC,SAMHA,+BAAAA,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IAGrC,SAMHA,+BAAAA,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IAGxC,SAMHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IAGrC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IAGxC,SAKHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKHA,+BAAAA,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,gCAAgC,IAGzC,SAKHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAKHA,+BAAAA,+BAA+B,oBAAoB,IAAI;AAkBjD,MAAM,gCAAgC,IAGzC,SAKHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAkB9C,MAAM,mCAAmC,IAG5C,SAKHA,+BAAA,+BAA+B,oBAAoB,IAAI;;;;;;;;;;;;;;;;;;;"}