@prismicio/react 3.2.1 → 3.2.2-canary.8d3ad6d

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 (47) hide show
  1. package/dist/PrismicImage.d.ts +66 -72
  2. package/dist/PrismicImage.d.ts.map +1 -0
  3. package/dist/PrismicImage.js +54 -47
  4. package/dist/PrismicImage.js.map +1 -1
  5. package/dist/PrismicLink.d.ts +71 -64
  6. package/dist/PrismicLink.d.ts.map +1 -0
  7. package/dist/PrismicLink.js +59 -40
  8. package/dist/PrismicLink.js.map +1 -1
  9. package/dist/PrismicRichText.d.ts +79 -100
  10. package/dist/PrismicRichText.d.ts.map +1 -0
  11. package/dist/PrismicRichText.js +125 -71
  12. package/dist/PrismicRichText.js.map +1 -1
  13. package/dist/PrismicTable.d.ts +58 -76
  14. package/dist/PrismicTable.d.ts.map +1 -0
  15. package/dist/PrismicTable.js +68 -21
  16. package/dist/PrismicTable.js.map +1 -1
  17. package/dist/PrismicText.d.ts +21 -25
  18. package/dist/PrismicText.d.ts.map +1 -0
  19. package/dist/PrismicText.js +30 -23
  20. package/dist/PrismicText.js.map +1 -1
  21. package/dist/PrismicToolbar.d.ts +21 -9
  22. package/dist/PrismicToolbar.d.ts.map +1 -0
  23. package/dist/PrismicToolbar.js +32 -19
  24. package/dist/PrismicToolbar.js.map +1 -1
  25. package/dist/SliceZone.d.ts +84 -83
  26. package/dist/SliceZone.d.ts.map +1 -0
  27. package/dist/SliceZone.js +54 -27
  28. package/dist/SliceZone.js.map +1 -1
  29. package/dist/index.d.ts +9 -15
  30. package/dist/index.js +4 -14
  31. package/dist/lib/devMsg.js +23 -6
  32. package/dist/lib/devMsg.js.map +1 -1
  33. package/dist/package.js +6 -0
  34. package/dist/package.js.map +1 -0
  35. package/package.json +21 -41
  36. package/src/PrismicImage.tsx +17 -25
  37. package/src/PrismicLink.tsx +21 -10
  38. package/src/PrismicRichText.tsx +26 -53
  39. package/src/PrismicTable.tsx +14 -36
  40. package/src/PrismicText.tsx +9 -18
  41. package/src/PrismicToolbar.tsx +10 -3
  42. package/src/SliceZone.tsx +46 -50
  43. package/src/lib/devMsg.ts +1 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/lib/devMsg.d.ts +0 -16
  46. package/dist/package.json.js +0 -5
  47. package/dist/package.json.js.map +0 -1
@@ -1,28 +1,75 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { isFilled } from "@prismicio/client";
3
1
  import { PrismicRichText } from "./PrismicRichText.js";
2
+ import { isFilled } from "@prismicio/client";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+
5
+ //#region src/PrismicTable.tsx
4
6
  const defaultComponents = {
5
- table: ({ children }) => jsx("table", { children }),
6
- thead: ({ children }) => jsx("thead", { children }),
7
- tbody: ({ children }) => jsx("tbody", { children }),
8
- tr: ({ children }) => jsx("tr", { children }),
9
- th: ({ children }) => jsx("th", { children }),
10
- td: ({ children }) => jsx("td", { children })
7
+ table: ({ children }) => /* @__PURE__ */ jsx("table", { children }),
8
+ thead: ({ children }) => /* @__PURE__ */ jsx("thead", { children }),
9
+ tbody: ({ children }) => /* @__PURE__ */ jsx("tbody", { children }),
10
+ tr: ({ children }) => /* @__PURE__ */ jsx("tr", { children }),
11
+ th: ({ children }) => /* @__PURE__ */ jsx("th", { children }),
12
+ td: ({ children }) => /* @__PURE__ */ jsx("td", { children })
11
13
  };
14
+ /**
15
+ * Renders content from a Prismic table field as React components.
16
+ *
17
+ * @example
18
+ *
19
+ * ```tsx
20
+ * <PrismicTable field={slice.primary.pricing_table} />;
21
+ * ```
22
+ *
23
+ * @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table}
24
+ */
12
25
  const PrismicTable = (props) => {
13
- const { field, components, fallback = null } = props;
14
- if (!isFilled.table(field)) {
15
- return fallback;
16
- }
17
- const { table: Table, thead: Thead, tbody: Tbody } = { ...defaultComponents, ...components };
18
- return jsxs(Table, { table: field, children: [field.head && jsx(Thead, { head: field.head, children: field.head.rows.map((row) => jsx(TableRow, { row, components }, row.key)) }), jsx(Tbody, { body: field.body, children: field.body.rows.map((row) => jsx(TableRow, { row, components }, row.key)) })] });
26
+ const { field, components, fallback = null } = props;
27
+ if (!isFilled.table(field)) return fallback;
28
+ const { table: Table, thead: Thead, tbody: Tbody } = {
29
+ ...defaultComponents,
30
+ ...components
31
+ };
32
+ return /* @__PURE__ */ jsxs(Table, {
33
+ table: field,
34
+ children: [field.head && /* @__PURE__ */ jsx(Thead, {
35
+ head: field.head,
36
+ children: field.head.rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
37
+ row,
38
+ components
39
+ }, row.key))
40
+ }), /* @__PURE__ */ jsx(Tbody, {
41
+ body: field.body,
42
+ children: field.body.rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
43
+ row,
44
+ components
45
+ }, row.key))
46
+ })]
47
+ });
19
48
  };
20
49
  function TableRow(props) {
21
- const { row, components } = props;
22
- const { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };
23
- return jsx(Tr, { row, children: row.cells.map((cell) => cell.type === "header" ? jsx(Th, { cell, children: jsx(PrismicRichText, { field: cell.content, components }) }, cell.key) : jsx(Td, { cell, children: jsx(PrismicRichText, { field: cell.content, components }) }, cell.key)) });
50
+ const { row, components } = props;
51
+ const { tr: Tr, th: Th, td: Td } = {
52
+ ...defaultComponents,
53
+ ...components
54
+ };
55
+ return /* @__PURE__ */ jsx(Tr, {
56
+ row,
57
+ children: row.cells.map((cell) => cell.type === "header" ? /* @__PURE__ */ jsx(Th, {
58
+ cell,
59
+ children: /* @__PURE__ */ jsx(PrismicRichText, {
60
+ field: cell.content,
61
+ components
62
+ })
63
+ }, cell.key) : /* @__PURE__ */ jsx(Td, {
64
+ cell,
65
+ children: /* @__PURE__ */ jsx(PrismicRichText, {
66
+ field: cell.content,
67
+ components
68
+ })
69
+ }, cell.key))
70
+ });
24
71
  }
25
- export {
26
- PrismicTable
27
- };
28
- //# sourceMappingURL=PrismicTable.js.map
72
+
73
+ //#endregion
74
+ export { PrismicTable };
75
+ //# sourceMappingURL=PrismicTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicTable.js","sources":["../src/PrismicTable.tsx"],"sourcesContent":["import { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tisFilled,\n\tTableField,\n\tTableFieldHead,\n\tTableFieldHeadRow,\n\tTableFieldBody,\n\tTableFieldBodyRow,\n\tTableFieldHeaderCell,\n\tTableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport { JSXMapSerializer, PrismicRichText } from \"./PrismicRichText.js\";\n\ntype TableComponents = {\n\ttable?: ComponentType<{ table: TableField<\"filled\">; children: ReactNode }>;\n\tthead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;\n\ttbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;\n\ttr?: ComponentType<{\n\t\trow: TableFieldHeadRow | TableFieldBodyRow;\n\t\tchildren: ReactNode;\n\t}>;\n\tth?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;\n\ttd?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;\n};\n\nconst defaultComponents: Required<TableComponents> = {\n\ttable: ({ children }) => <table>{children}</table>,\n\tthead: ({ children }) => <thead>{children}</thead>,\n\ttbody: ({ children }) => <tbody>{children}</tbody>,\n\ttr: ({ children }) => <tr>{children}</tr>,\n\tth: ({ children }) => <th>{children}</th>,\n\ttd: ({ children }) => <td>{children}</td>,\n};\n\n/** Props for `<PrismicTable>`. */\nexport type PrismicTableProps = {\n\t/** The Prismic table field to render. */\n\tfield: TableField;\n\n\t/**\n\t * An object that maps a table block to a React component.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * table: ({children}) => <table>{children}</table>\n\t * thead: ({children}) => <thead>{children}</thead>\n\t * }\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer & TableComponents;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\n/**\n * React component that renders content from a Prismic table field. By default,\n * HTML elements are rendered for each piece of content. A `tbody` block will\n * render a `<tbody>` HTML element, for example.\n *\n * To customize the components that are rendered, provide a map serializer to\n * the `components` prop.\n *\n * @example Rendering a table field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicTable field={document.data.my_table} />;\n * ```\n *\n * @example Rendering a table field using a custom set of React components.\n *\n * ```jsx\n * <PrismicTable\n * \tfield={document.data.my_table}\n * \tcomponents={{\n * \t\ttbody: ({ children }) => (\n * \t\t\t<tbody className=\"my-class\">{children}</tbody>\n * \t\t),\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The table field's content as React components.\n *\n * @see Learn about table fields {@link https://prismic.io/docs/core-concepts/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = (props) => {\n\tconst { field, components, fallback = null } = props;\n\n\tif (!isFilled.table(field)) {\n\t\treturn fallback;\n\t}\n\n\tconst {\n\t\ttable: Table,\n\t\tthead: Thead,\n\t\ttbody: Tbody,\n\t} = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Table table={field}>\n\t\t\t{field.head && (\n\t\t\t\t<Thead head={field.head}>\n\t\t\t\t\t{field.head.rows.map((row) => (\n\t\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t\t))}\n\t\t\t\t</Thead>\n\t\t\t)}\n\t\t\t<Tbody body={field.body}>\n\t\t\t\t{field.body.rows.map((row) => (\n\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t))}\n\t\t\t</Tbody>\n\t\t</Table>\n\t);\n};\n\ntype TableRowProps = {\n\trow: TableFieldHeadRow | TableFieldBodyRow;\n\tcomponents?: JSXMapSerializer & TableComponents;\n};\n\nfunction TableRow(props: TableRowProps) {\n\tconst { row, components } = props;\n\n\tconst { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Tr row={row}>\n\t\t\t{row.cells.map((cell) =>\n\t\t\t\tcell.type === \"header\" ? (\n\t\t\t\t\t<Th key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Th>\n\t\t\t\t) : (\n\t\t\t\t\t<Td key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Td>\n\t\t\t\t),\n\t\t\t)}\n\t\t</Tr>\n\t);\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;AA0BA,MAAM,oBAA+C;AAAA,EACpD,OAAO,CAAC,EAAE,eAAeA,IAAQ,SAAA,EAAA,UAAiB;AAAA,EAClD,OAAO,CAAC,EAAE,eAAeA,IAAQ,SAAA,EAAA,UAAiB;AAAA,EAClD,OAAO,CAAC,EAAE,eAAeA,IAAQ,SAAA,EAAA,UAAiB;AAAA,EAClD,IAAI,CAAC,EAAE,eAAeA,IAAK,MAAA,EAAA,UAAc;AAAA,EACzC,IAAI,CAAC,EAAE,eAAeA,IAAK,MAAA,EAAA,UAAc;AAAA,EACzC,IAAI,CAAC,EAAE,SAAA,MAAeA,IAAK,MAAA,EAAA,SAAc,CAAA;;AA8D7B,MAAA,eAAsC,CAAC,UAAS;AAC5D,QAAM,EAAE,OAAO,YAAY,WAAW,KAAS,IAAA;AAE/C,MAAI,CAAC,SAAS,MAAM,KAAK,GAAG;AACpB,WAAA;AAAA,EAAA;AAGR,QAAM,EACL,OAAO,OACP,OAAO,OACP,OAAO,UACJ,EAAE,GAAG,mBAAmB,GAAG,WAAU;AAEzC,SACCC,KAAC,OAAK,EAAC,OAAO,kBACZ,MAAM,QACND,IAAC,OAAK,EAAC,MAAM,MAAM,MACjB,UAAA,MAAM,KAAK,KAAK,IAAI,CAAC,QACrBA,IAAC,UAAQ,EAAe,KAAU,WAAsB,GAAzC,IAAI,GAAG,CACtB,EAAA,CACM,GAETA,IAAC,OAAM,EAAA,MAAM,MAAM,MAAI,UACrB,MAAM,KAAK,KAAK,IAAI,CAAC,QACrBA,IAAC,YAAuB,KAAU,WAAnB,GAAA,IAAI,GAAG,CACtB,EAAC,CAAA,CACK,EAAA,CACD;AAEV;AAOA,SAAS,SAAS,OAAoB;AAC/B,QAAA,EAAE,KAAK,WAAA,IAAe;AAE5B,QAAM,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,EAAE,GAAG,mBAAmB,GAAG,WAAU;AAGvE,SAAAA,IAAC,MAAG,KACF,UAAA,IAAI,MAAM,IAAI,CAAC,SACf,KAAK,SAAS,WACbA,IAAC,IAAE,EAAgB,gBAClBA,IAAC,mBAAgB,OAAO,KAAK,SAAS,WAAsB,CAAA,KADpD,KAAK,GAAG,IAIjBA,IAAC,MAAkB,MAClB,UAAAA,IAAC,iBAAe,EAAC,OAAO,KAAK,SAAS,iBAD9B,KAAK,GAAG,CAGjB,GACD;AAGJ;"}
1
+ {"version":3,"file":"PrismicTable.js","names":[],"sources":["../src/PrismicTable.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tisFilled,\n\ttype TableField,\n\ttype TableFieldHead,\n\ttype TableFieldHeadRow,\n\ttype TableFieldBody,\n\ttype TableFieldBodyRow,\n\ttype TableFieldHeaderCell,\n\ttype TableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport { type JSXMapSerializer, PrismicRichText } from \"./PrismicRichText.js\";\n\ntype TableComponents = {\n\ttable?: ComponentType<{ table: TableField<\"filled\">; children: ReactNode }>;\n\tthead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;\n\ttbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;\n\ttr?: ComponentType<{\n\t\trow: TableFieldHeadRow | TableFieldBodyRow;\n\t\tchildren: ReactNode;\n\t}>;\n\tth?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;\n\ttd?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;\n};\n\nconst defaultComponents: Required<TableComponents> = {\n\ttable: ({ children }) => <table>{children}</table>,\n\tthead: ({ children }) => <thead>{children}</thead>,\n\ttbody: ({ children }) => <tbody>{children}</tbody>,\n\ttr: ({ children }) => <tr>{children}</tr>,\n\tth: ({ children }) => <th>{children}</th>,\n\ttd: ({ children }) => <td>{children}</td>,\n};\n\n/** Props for `<PrismicTable>`. */\nexport type PrismicTableProps = {\n\t/** The Prismic table field to render. */\n\tfield: TableField;\n\n\t/**\n\t * An object that maps a table block to a React component.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * table: ({children}) => <table>{children}</table>\n\t * thead: ({children}) => <thead>{children}</thead>\n\t * }\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer & TableComponents;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\n/**\n * Renders content from a Prismic table field as React components.\n *\n * @example\n *\n * ```tsx\n * <PrismicTable field={slice.primary.pricing_table} />;\n * ```\n *\n * @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = (props) => {\n\tconst { field, components, fallback = null } = props;\n\n\tif (!isFilled.table(field)) {\n\t\treturn fallback;\n\t}\n\n\tconst {\n\t\ttable: Table,\n\t\tthead: Thead,\n\t\ttbody: Tbody,\n\t} = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Table table={field}>\n\t\t\t{field.head && (\n\t\t\t\t<Thead head={field.head}>\n\t\t\t\t\t{field.head.rows.map((row) => (\n\t\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t\t))}\n\t\t\t\t</Thead>\n\t\t\t)}\n\t\t\t<Tbody body={field.body}>\n\t\t\t\t{field.body.rows.map((row) => (\n\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t))}\n\t\t\t</Tbody>\n\t\t</Table>\n\t);\n};\n\ntype TableRowProps = {\n\trow: TableFieldHeadRow | TableFieldBodyRow;\n\tcomponents?: JSXMapSerializer & TableComponents;\n};\n\nfunction TableRow(props: TableRowProps) {\n\tconst { row, components } = props;\n\n\tconst { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Tr row={row}>\n\t\t\t{row.cells.map((cell) =>\n\t\t\t\tcell.type === \"header\" ? (\n\t\t\t\t\t<Th key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Th>\n\t\t\t\t) : (\n\t\t\t\t\t<Td key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Td>\n\t\t\t\t),\n\t\t\t)}\n\t\t</Tr>\n\t);\n}\n"],"mappings":";;;;;AA0BA,MAAM,oBAA+C;CACpD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,QAAQ,EAAE,eAAe,oBAAC,WAAO,WAAiB;CAClD,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC,KAAK,EAAE,eAAe,oBAAC,QAAI,WAAc;CACzC;;;;;;;;;;;;AAuCD,MAAa,gBAAuC,UAAU;CAC7D,MAAM,EAAE,OAAO,YAAY,WAAW,SAAS;AAE/C,KAAI,CAAC,SAAS,MAAM,MAAM,CACzB,QAAO;CAGR,MAAM,EACL,OAAO,OACP,OAAO,OACP,OAAO,UACJ;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE3C,QACC,qBAAC;EAAM,OAAO;aACZ,MAAM,QACN,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK,EAET,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK;GACD;;AASV,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,KAAK,eAAe;CAE5B,MAAM,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE1E,QACC,oBAAC;EAAQ;YACP,IAAI,MAAM,KAAK,SACf,KAAK,SAAS,WACb,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,GAEL,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,CAEN;GACG"}
@@ -1,35 +1,31 @@
1
1
  import { FC } from "react";
2
2
  import { RichTextField } from "@prismicio/client";
3
+
4
+ //#region src/PrismicText.d.ts
3
5
  /** Props for `<PrismicText>`. */
4
- export type PrismicTextProps = {
5
- /** The Prismic Rich Text field to render. */
6
- field: RichTextField | null | undefined;
7
- /**
8
- * The string rendered when the field is empty. If a fallback is not given,
9
- * `null` will be rendered.
10
- */
11
- fallback?: string;
12
- /** The separator used between blocks. Defaults to `\n`. */
13
- separator?: string;
6
+ type PrismicTextProps = {
7
+ /** The Prismic rich text field to render. */
8
+ field: RichTextField | null | undefined;
9
+ /**
10
+ * The string rendered when the field is empty. If a fallback is not given,
11
+ * `null` will be rendered.
12
+ */
13
+ fallback?: string;
14
+ /** The separator used between blocks. Defaults to `\n`. */
15
+ separator?: string;
14
16
  };
15
17
  /**
16
- * React component that renders content from a Prismic Rich Text field as plain
17
- * text.
18
+ * Renders content from a Prismic rich text field as plain text (no HTML).
18
19
  *
19
- * @remarks
20
- * This component returns a React fragment with no wrapping element around the
21
- * content. If you need a wrapper, add a component around `<PrismicText>`.
20
+ * @example
22
21
  *
23
- * @example Rendering a Rich Text field as plain text.
24
- *
25
- * ```jsx
26
- * <PrismicText field={document.data.content} />;
22
+ * ```tsx
23
+ * <PrismicText field={slice.primary.text} />;
27
24
  * ```
28
25
  *
29
- * @param props - Props for the component.
30
- *
31
- * @returns The Rich Text field's content as plain text.
32
- *
33
- * @see Learn about Rich Text fields {@link https://io/docs/core-concepts/rich-text-title}
26
+ * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}
34
27
  */
35
- export declare const PrismicText: FC<PrismicTextProps>;
28
+ declare const PrismicText: FC<PrismicTextProps>;
29
+ //#endregion
30
+ export { PrismicText, PrismicTextProps };
31
+ //# sourceMappingURL=PrismicText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicText.d.ts","names":[],"sources":["../src/PrismicText.tsx"],"sourcesContent":[],"mappings":";;;;;KAOY,gBAAA;EAAA;EAyBC,KAAA,EAvBL,aAuDP,GAAA,IAhC4B,GAAA,SAAA;;;;;;;;;;;;;;;;;;;;cAAhB,aAAa,GAAG"}
@@ -1,26 +1,33 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { isFilled, asText } from "@prismicio/client";
3
- import { DEV } from "esm-env";
4
1
  import { devMsg } from "./lib/devMsg.js";
2
+ import { asText, isFilled } from "@prismicio/client";
3
+ import { DEV } from "esm-env";
4
+ import { Fragment, jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/PrismicText.tsx
7
+ /**
8
+ * Renders content from a Prismic rich text field as plain text (no HTML).
9
+ *
10
+ * @example
11
+ *
12
+ * ```tsx
13
+ * <PrismicText field={slice.primary.text} />;
14
+ * ```
15
+ *
16
+ * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}
17
+ */
5
18
  const PrismicText = (props) => {
6
- const { field, fallback, separator } = props;
7
- if (DEV) {
8
- if ("className" in props) {
9
- console.warn(`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg("classname-is-not-a-valid-prop")}.`, props.field);
10
- }
11
- }
12
- if (typeof props.field === "string") {
13
- if (DEV) {
14
- console.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")}`, props.field);
15
- }
16
- return null;
17
- }
18
- if (!isFilled.richText(field)) {
19
- return fallback != null ? jsx(Fragment, { children: fallback }) : null;
20
- }
21
- return jsx(Fragment, { children: asText(field, { separator }) });
22
- };
23
- export {
24
- PrismicText
19
+ const { field, fallback, separator } = props;
20
+ if (DEV) {
21
+ if ("className" in props) console.warn(`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg("classname-is-not-a-valid-prop")}.`, props.field);
22
+ }
23
+ if (typeof props.field === "string") {
24
+ if (DEV) console.error(`[PrismicText] The "field" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg("prismictext-works-only-with-rich-text-and-title-fields")}`, props.field);
25
+ return null;
26
+ }
27
+ if (!isFilled.richText(field)) return fallback != null ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
28
+ return /* @__PURE__ */ jsx(Fragment, { children: asText(field, { separator }) });
25
29
  };
26
- //# sourceMappingURL=PrismicText.js.map
30
+
31
+ //#endregion
32
+ export { PrismicText };
33
+ //# sourceMappingURL=PrismicText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicText.js","sources":["../src/PrismicText.tsx"],"sourcesContent":["import { FC } from \"react\";\nimport { asText, isFilled, RichTextField } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** Props for `<PrismicText>`. */\nexport type PrismicTextProps = {\n\t/** The Prismic Rich Text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/** The separator used between blocks. Defaults to `\\n`. */\n\tseparator?: string;\n};\n\n/**\n * 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 *\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://io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText: FC<PrismicTextProps> = (props) => {\n\tconst { field, fallback, separator } = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in props) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof props.field === \"string\") {\n\t\tif (DEV) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text 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\tprops.field,\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{asText(field, { separator })}</>;\n};\n"],"names":["_jsx","_Fragment"],"mappings":";;;;AAyCa,MAAA,cAAoC,CAAC,UAAS;AAC1D,QAAM,EAAE,OAAO,UAAU,UAAc,IAAA;AAEvC,MAAI,KAAK;AACR,QAAI,eAAe,OAAO;AACzB,cAAQ,KACP,6IAA6I,OAC5I,+BAA+B,CAC/B,KACD,MAAM,KAAK;AAAA,IAAA;AAAA,EAEb;AAGG,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,QAAI,KAAK;AACR,cAAQ,MACP,oRAAoR,OACnR,wDAAwD,CACxD,IACD,MAAM,KAAK;AAAA,IAAA;AAIN,WAAA;AAAA,EAAA;AAGR,MAAI,CAAC,SAAS,SAAS,KAAK,GAAG;AACvB,WAAA,YAAY,OAAOA,IAAGC,UAAA,EAAA,UAAA,SAAY,CAAA,IAAG;AAAA,EAAA;AAGtC,SAAAD,IAAAC,UAAA,EAAA,UAAG,OAAO,OAAO,EAAE,UAAW,CAAA,GAAC;AACvC;"}
1
+ {"version":3,"file":"PrismicText.js","names":[],"sources":["../src/PrismicText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { asText, isFilled, type RichTextField } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** Props for `<PrismicText>`. */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/** The separator used between blocks. Defaults to `\\n`. */\n\tseparator?: string;\n};\n\n/**\n * Renders content from a Prismic rich text field as plain text (no HTML).\n *\n * @example\n *\n * ```tsx\n * <PrismicText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicText: FC<PrismicTextProps> = (props) => {\n\tconst { field, fallback, separator } = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in props) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof props.field === \"string\") {\n\t\tif (DEV) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{asText(field, { separator })}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAa,eAAqC,UAAU;CAC3D,MAAM,EAAE,OAAO,UAAU,cAAc;AAEvC,KAAI,KACH;MAAI,eAAe,MAClB,SAAQ,KACP,6IAA6I,OAC5I,gCACA,CAAC,IACF,MAAM,MACN;;AAIH,KAAI,OAAO,MAAM,UAAU,UAAU;AACpC,MAAI,IACH,SAAQ,MACP,2QAA2Q,OAC1Q,yDACA,IACD,MAAM,MACN;AAGF,SAAO;;AAGR,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,0CAAG,WAAY,GAAG;AAG7C,QAAO,0CAAG,OAAO,OAAO,EAAE,WAAW,CAAC,GAAI"}
@@ -1,14 +1,26 @@
1
1
  import { FC } from "react";
2
+
3
+ //#region src/PrismicToolbar.d.ts
2
4
  /** Props for `<PrismicToolbar>`. */
3
- export type PrismicToolbarProps = {
4
- /**
5
- * The name of the Prismic repository. For example, `"my-repo"` if the
6
- * repository URL is `my-repo.prismic.io`.
7
- */
8
- repositoryName: string;
5
+ type PrismicToolbarProps = {
6
+ /**
7
+ * The name of the Prismic repository. For example, `"my-repo"` if the
8
+ * repository URL is `my-repo.prismic.io`.
9
+ */
10
+ repositoryName: string;
9
11
  };
10
12
  /**
11
- * React component that injects the Prismic Toolbar into the app. This component
12
- * can be placed anywhere in the React tree.
13
+ * Renders the Prismic Toolbar script to support draft previews.
14
+ *
15
+ * @example
16
+ *
17
+ * ```tsx
18
+ * <PrismicToolbar repositoryName="my-repo" />;
19
+ * ```
20
+ *
21
+ * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}
13
22
  */
14
- export declare const PrismicToolbar: FC<PrismicToolbarProps>;
23
+ declare const PrismicToolbar: FC<PrismicToolbarProps>;
24
+ //#endregion
25
+ export { PrismicToolbar, PrismicToolbarProps };
26
+ //# sourceMappingURL=PrismicToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicToolbar.d.ts","names":[],"sources":["../src/PrismicToolbar.tsx"],"sourcesContent":[],"mappings":";;;;KAMY,mBAAA;EAAA;AAmBZ;;;;;;;;;;;;;;;;cAAa,gBAAgB,GAAG"}
@@ -1,24 +1,37 @@
1
1
  "use client";
2
+
2
3
  import { useEffect } from "react";
3
4
  import { getToolbarSrc } from "@prismicio/client";
5
+
6
+ //#region src/PrismicToolbar.tsx
7
+ /**
8
+ * Renders the Prismic Toolbar script to support draft previews.
9
+ *
10
+ * @example
11
+ *
12
+ * ```tsx
13
+ * <PrismicToolbar repositoryName="my-repo" />;
14
+ * ```
15
+ *
16
+ * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}
17
+ */
4
18
  const PrismicToolbar = (props) => {
5
- const { repositoryName } = props;
6
- const src = getToolbarSrc(repositoryName);
7
- useEffect(() => {
8
- const existingScript = document.querySelector(`script[src="${src}"]`);
9
- if (!existingScript) {
10
- const script = document.createElement("script");
11
- script.src = src;
12
- script.defer = true;
13
- script.dataset.prismicToolbar = "";
14
- script.dataset.repositoryName = repositoryName;
15
- script._evaluateScript = false;
16
- document.body.appendChild(script);
17
- }
18
- }, [repositoryName, src]);
19
- return null;
19
+ const { repositoryName } = props;
20
+ const src = getToolbarSrc(repositoryName);
21
+ useEffect(() => {
22
+ if (!document.querySelector(`script[src="${src}"]`)) {
23
+ const script = document.createElement("script");
24
+ script.src = src;
25
+ script.defer = true;
26
+ script.dataset.prismicToolbar = "";
27
+ script.dataset.repositoryName = repositoryName;
28
+ script._evaluateScript = false;
29
+ document.body.appendChild(script);
30
+ }
31
+ }, [repositoryName, src]);
32
+ return null;
20
33
  };
21
- export {
22
- PrismicToolbar
23
- };
24
- //# sourceMappingURL=PrismicToolbar.js.map
34
+
35
+ //#endregion
36
+ export { PrismicToolbar };
37
+ //# sourceMappingURL=PrismicToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicToolbar.js","sources":["../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, useEffect } from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/** Props for `<PrismicToolbar>`. */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n};\n\n/**\n * 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: FC<PrismicToolbarProps> = (props) => {\n\tconst { repositoryName } = props;\n\n\tconst src = getToolbarSrc(repositoryName);\n\n\tuseEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during tests.\n\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\tscript._evaluateScript = false;\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"names":[],"mappings":";;;AAkBa,MAAA,iBAA0C,CAAC,UAAS;AAC1D,QAAA,EAAE,mBAAmB;AAErB,QAAA,MAAM,cAAc,cAAc;AAExC,YAAU,MAAK;AACd,UAAM,iBAAiB,SAAS,cAAc,eAAe,GAAG,IAAI;AAEpE,QAAI,CAAC,gBAAgB;AACd,YAAA,SAAS,SAAS,cAAc,QAAQ;AAC9C,aAAO,MAAM;AACb,aAAO,QAAQ;AAGf,aAAO,QAAQ,iBAAiB;AAChC,aAAO,QAAQ,iBAAiB;AAIhC,aAAO,kBAAkB;AAEhB,eAAA,KAAK,YAAY,MAAM;AAAA,IAAA;AAAA,EACjC,GACE,CAAC,gBAAgB,GAAG,CAAC;AAEjB,SAAA;AACR;"}
1
+ {"version":3,"file":"PrismicToolbar.js","names":[],"sources":["../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useEffect } from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/** Props for `<PrismicToolbar>`. */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n};\n\n/**\n * Renders the Prismic Toolbar script to support draft previews.\n *\n * @example\n *\n * ```tsx\n * <PrismicToolbar repositoryName=\"my-repo\" />;\n * ```\n *\n * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}\n */\nexport const PrismicToolbar: FC<PrismicToolbarProps> = (props) => {\n\tconst { repositoryName } = props;\n\n\tconst src = getToolbarSrc(repositoryName);\n\n\tuseEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during tests.\n\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\tscript._evaluateScript = false;\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAa,kBAA2C,UAAU;CACjE,MAAM,EAAE,mBAAmB;CAE3B,MAAM,MAAM,cAAc,eAAe;AAEzC,iBAAgB;AAGf,MAAI,CAFmB,SAAS,cAAc,eAAe,IAAI,IAAI,EAEhD;GACpB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,MAAM;AACb,UAAO,QAAQ;AAGf,UAAO,QAAQ,iBAAiB;AAChC,UAAO,QAAQ,iBAAiB;AAIhC,UAAO,kBAAkB;AAEzB,YAAS,KAAK,YAAY,OAAO;;IAEhC,CAAC,gBAAgB,IAAI,CAAC;AAEzB,QAAO"}
@@ -1,139 +1,140 @@
1
- import type { ComponentType, FC } from "react";
2
- import type { Slice } from "@prismicio/client";
1
+ import { ComponentType, FC, ReactNode } from "react";
2
+ import { Slice } from "@prismicio/client";
3
+
4
+ //#region src/SliceZone.d.ts
5
+
3
6
  /**
4
7
  * Returns the type of a `SliceLike` type.
5
8
  *
6
- * @typeParam Slice - The Slice from which the type will be extracted.
9
+ * @typeParam TSlice - The slice from which the type will be extracted.
7
10
  */
8
11
  type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
9
12
  /**
10
- * The minimum required properties to represent a Prismic Slice from the Prismic
11
- * Rest API V2 for the `unstable_mapSliceZone()` helper.
13
+ * The minimum required properties to represent a Prismic slice from the Prismic
14
+ * Content API for the `mapSliceZone()` helper.
12
15
  *
13
- * @typeParam SliceType - Type name of the Slice.
16
+ * @typeParam SliceType - Type name of the slice.
14
17
  */
15
- export type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
18
+ type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
16
19
  /**
17
- * The minimum required properties to represent a Prismic Slice from the Prismic
18
- * GraphQL API for the `unstable_mapSliceZone()` helper.
20
+ * The minimum required properties to represent a Prismic slice from the Prismic
21
+ * GraphQL API for the `mapSliceZone()` helper.
19
22
  *
20
- * @typeParam SliceType - Type name of the Slice.
23
+ * @typeParam SliceType - Type name of the slice.
21
24
  */
22
- export type SliceLikeGraphQL<TSliceType extends string = string> = {
23
- type: Slice<TSliceType>["slice_type"];
25
+ type SliceLikeGraphQL<TSliceType extends string = string> = {
26
+ type: Slice<TSliceType>["slice_type"];
24
27
  };
25
28
  /**
26
- * The minimum required properties to represent a Prismic Slice for the
27
- * `unstable_mapSliceZone()` helper.
29
+ * The minimum required properties to represent a Prismic slice for the
30
+ * `mapSliceZone()` helper.
28
31
  *
29
- * If using Prismic's Rest API V2, use the `Slice` export from
32
+ * If using Prismic's Content API, use the `Slice` export from
30
33
  * `@prismicio/client` for a full interface.
31
34
  *
32
- * @typeParam SliceType - Type name of the Slice.
35
+ * @typeParam SliceType - Type name of the slice.
33
36
  */
34
- export type SliceLike<TSliceType extends string = string> = (SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>) & {
35
- /**
36
- * If `true`, this Slice has been modified from its original value using a
37
- * mapper and `@prismicio/client`'s `mapSliceZone()`.
38
- *
39
- * @internal
40
- */
41
- __mapped?: true;
37
+ type SliceLike<TSliceType extends string = string> = (SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>) & {
38
+ /**
39
+ * If `true`, this slice has been modified from its original value using a
40
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
41
+ *
42
+ * @internal
43
+ */
44
+ __mapped?: true;
42
45
  };
43
46
  /**
44
47
  * A looser version of the `SliceZone` type from `@prismicio/client` using
45
48
  * `SliceLike`.
46
49
  *
47
- * If using Prismic's Rest API V2, use the `SliceZone` export from
50
+ * If using Prismic's Content API, use the `SliceZone` export from
48
51
  * `@prismicio/client` for the full type.
49
52
  *
50
- * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
53
+ * @typeParam TSlice - The type(s) of a slice in the slice zone.
51
54
  */
52
- export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
55
+ type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
53
56
  /**
54
- * React props for a component rendering content from a Prismic Slice using the
57
+ * React props for a component rendering content from a Prismic slice using the
55
58
  * `<SliceZone>` component.
56
59
  *
57
- * @typeParam TSlice - The Slice passed as a prop.
60
+ * @typeParam TSlice - The slice passed as a prop.
58
61
  * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made
59
- * available to all Slice components.
62
+ * available to all slice components.
60
63
  */
61
- export type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
62
- /** Slice data for this component. */
63
- slice: TSlice;
64
- /** The index of the Slice in the Slice Zone. */
65
- index: number;
66
- /** All Slices from the Slice Zone to which the Slice belongs. */
67
- slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
68
- /**
69
- * Arbitrary data passed to `<SliceZone>` and made available to all Slice
70
- * components.
71
- */
72
- context: TContext;
64
+ type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
65
+ /** Slice data for this component. */
66
+ slice: TSlice;
67
+ /** The index of the slice in the slice zone. */
68
+ index: number;
69
+ /** All slices from the slice zone to which the slice belongs. */
70
+ slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
71
+ /**
72
+ * Arbitrary data passed to `<SliceZone>` and made available to all slice
73
+ * components.
74
+ */
75
+ context: TContext;
73
76
  };
74
77
  /**
75
- * A React component to be rendered for each instance of its Slice.
78
+ * A React component to be rendered for each instance of its slice.
76
79
  *
77
- * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
78
- * @typeParam TContext - Arbitrary data made available to all Slice components.
80
+ * @typeParam TSlice - The type(s) of a slice in the slice zone.
81
+ * @typeParam TContext - Arbitrary data made available to all slice components.
79
82
  */
80
- export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = ComponentType<SliceComponentProps<TSlice, TContext>>;
83
+ type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = ComponentType<SliceComponentProps<TSlice, TContext>>;
81
84
  /**
82
- * A record of Slice types mapped to a React component. The component will be
83
- * rendered for each instance of its Slice.
85
+ * A record of slice types mapped to a React component. The component will be
86
+ * rendered for each instance of its slice.
84
87
  *
85
88
  * @deprecated This type is no longer used by `@prismicio/react`. Prefer using
86
89
  * `Record<string, SliceComponentType<any>>` instead.
87
90
  *
88
- * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
89
- * @typeParam TContext - Arbitrary data made available to all Slice components.
91
+ * @typeParam TSlice - The type(s) of a slice in the slice zone.
92
+ * @typeParam TContext - Arbitrary data made available to all slice components.
90
93
  */
91
- export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
92
- [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>> extends never ? SliceLike : Extract<TSlice, SliceLike<SliceType>>, TContext>;
93
- };
94
+ type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = { [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>> extends never ? SliceLike : Extract<TSlice, SliceLike<SliceType>>, TContext> };
94
95
  /**
95
96
  * React props for the `<SliceZone>` component.
96
97
  *
97
- * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
98
- * @typeParam TContext - Arbitrary data made available to all Slice components.
98
+ * @typeParam TSlice - The type(s) of a slice in the slice zone.
99
+ * @typeParam TContext - Arbitrary data made available to all slice components.
99
100
  */
100
- export type SliceZoneProps<TContext = unknown> = {
101
- /** List of Slice data from the Slice Zone. */
102
- slices?: SliceZoneLike;
103
- /** A record mapping Slice types to React components. */
104
- components?: Record<string, ComponentType<any>>;
105
- /**
106
- * The React component rendered if a component mapping from the `components`
107
- * prop cannot be found.
108
- */
109
- defaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;
110
- /** Arbitrary data made available to all Slice components. */
111
- context?: TContext;
101
+ type SliceZoneProps<TContext = unknown> = {
102
+ /** List of slice data from the slice zone. */
103
+ slices?: SliceZoneLike;
104
+ /** A record mapping slice types to React components. */
105
+ components?: Record<string, ComponentType<any>>;
106
+ /**
107
+ * The React component rendered if a component mapping from the `components`
108
+ * prop cannot be found.
109
+ */
110
+ defaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;
111
+ /** Arbitrary data made available to all slice components. */
112
+ context?: TContext;
112
113
  };
113
114
  /**
114
- * This Slice component can be used as a reminder to provide a proper
115
+ * This slice component can be used as a reminder to provide a proper
115
116
  * implementation.
116
117
  *
117
118
  * This is also the default React component rendered when a component mapping
118
119
  * cannot be found in `<SliceZone>`.
119
120
  */
120
- export declare const TODOSliceComponent: <TSlice extends SliceLike>({ slice, }: {
121
- slice: TSlice;
122
- }) => import("react/jsx-runtime").JSX.Element | null;
121
+ declare const TODOSliceComponent: <TSlice extends SliceLike>({
122
+ slice
123
+ }: {
124
+ slice: TSlice;
125
+ }) => ReactNode;
123
126
  /**
124
- * Renders content from a Prismic Slice Zone using React components for each
125
- * type of Slice.
126
- *
127
- * If a component is not provided for a type of Slice, a default component can
128
- * be provided. A fallback component is provided by default that will not be
129
- * rendered in a production build of your app.
127
+ * Renders slices in a slice zone as React components.
130
128
  *
131
- * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
132
- * @typeParam TContext - Arbitrary data made available to all Slice components.
129
+ * @example
133
130
  *
134
- * @returns The Slice Zone's content as React components.
131
+ * ```tsx
132
+ * <SliceZone slices={page.data.slices} components={components} />;
133
+ * ```
135
134
  *
136
- * @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}
135
+ * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}
137
136
  */
138
- export declare const SliceZone: FC<SliceZoneProps>;
139
- export {};
137
+ declare const SliceZone: FC<SliceZoneProps>;
138
+ //#endregion
139
+ export { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent };
140
+ //# sourceMappingURL=SliceZone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.d.ts","names":[],"sources":["../src/SliceZone.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAC+C;;;KAQ1C,gBAA4D,CAAA,eAA5B,SAA4B,CAAA,GAAf,MAAe,SAAA,KAAA,GAC9D,MAD8D,CAAA,YAAA,CAAA,GAE9D,MAF8D,SAE/C,gBAF+C,GAG7D,MAH6D,CAAA,MAAA,CAAA,GAAA,KAAA;;;;;;AAYjE;AACO,KADK,eACL,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAD2D,IAC3D,CAAN,KAAM,CAAA,UAAA,CAAA,EAAA,IAAA,GAAA,YAAA,CAAA;;;;AAUP;AAaA;;AACG,KAdS,gBAcT,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EACiB,IAAA,EAdb,KAca,CAdP,UAcO,CAAA,CAAA,YAAA,CAAA;CAAjB;;AAoBH;;;;;AAWA;;;AAKQ,KAtCI,SAsCJ,CAAA,mBAAA,MAAA,GAAA,MAAA,CAAA,GAAA,CArCL,eAqCK,CArCW,UAqCX,CAAA,GApCL,gBAoCK,CApCY,UAoCZ,CAAA,CAAA,GAAA;EAWN;;;;;;EAOgB,QAAA,CAAA,EAAA,IAAA;AASlB,CAAA;;;;;;;AAgBA;;;AAciC,KAzErB,aAyEqB,CAAA,eAzEQ,SAyER,GAzEoB,SAyEpB,CAAA,GAAA,SAxEvB,MAwEuB,EAAA;;;;;;;;;AAGX,KAjEV,mBAiEU,CAAA,eAhEN,SAgEM,GAhEM,SAgEN,EAAA,WAAA,OAAA,CAAA,GAAA;EAAhB;EACH,KAAA,EA7DK,MA6DL;EAJwC;EAAkB,KAAA,EAAA,MAAA;EAcjD;EAEF,MAAA,EA/DD,aA+DC,CA9DR,MA8DQ,SA9DO,gBA8DP,GA9D0B,gBA8D1B,GA9D6C,eA8D7C,CAAA;EAImB;;;;EAOT,OAAA,EAlEV,QAkEU;CAGT;;AAUX;;;;;AAsBC,KA5FW,kBA4FX,CAAA,eA1Fe,SA0Ff,GAAA,GAAA,EAAA,WAAA,OAAA,CAAA,GAxFG,aAwFH,CAxFiB,mBAwFjB,CAxFqC,MAwFrC,EAxF6C,QAwF7C,CAAA,CAAA;AAaD;;;;;;;;;;KAzFY,mCACI,YAAY,iDAaZ,iBAAiB,UAAU,mBACxC,QAAQ,QAAQ,UAAU,4BACvB,YACA,QAAQ,QAAQ,UAAU,aAC7B;;;;;;;KAUS;;WAEF;;eAII,eAAe;;;;;qBAOT,cAAc,yBAAyB;;YAGhD;;;;;;;;;cAUE,oCAAqC;;;SAG1C;MACJ;;;;;;;;;;;;cA+BS,WAAW,GAAG"}