@prismicio/react 3.2.2-pr.241.0f293b1 → 3.2.2-pr.242.8d8084e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/PrismicImage.d.ts +60 -58
  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 +63 -67
  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 +68 -66
  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 +53 -49
  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 +16 -11
  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 +12 -7
  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 +52 -47
  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 +19 -39
  36. package/src/PrismicImage.tsx +3 -3
  37. package/src/PrismicLink.tsx +5 -5
  38. package/src/PrismicRichText.tsx +11 -16
  39. package/src/PrismicTable.tsx +9 -9
  40. package/src/PrismicText.tsx +2 -2
  41. package/src/PrismicToolbar.tsx +1 -1
  42. package/src/SliceZone.tsx +2 -2
  43. package/src/index.ts +0 -1
  44. package/src/lib/devMsg.ts +1 -1
  45. package/dist/index.js.map +0 -1
  46. package/dist/lib/devMsg.d.ts +0 -16
  47. package/dist/package.json.js +0 -5
  48. package/dist/package.json.js.map +0 -1
@@ -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 * 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"],"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;;AAwC7B,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,16 +1,18 @@
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
18
  * Renders content from a Prismic rich text field as plain text (no HTML).
@@ -23,4 +25,7 @@ export type PrismicTextProps = {
23
25
  *
24
26
  * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}
25
27
  */
26
- 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 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 * 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"],"names":["_jsx","_Fragment"],"mappings":";;;;AAgCa,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,2QAA2Q,OAC1Q,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,11 +1,13 @@
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
13
  * Renders the Prismic Toolbar script to support draft previews.
@@ -18,4 +20,7 @@ export type PrismicToolbarProps = {
18
20
  *
19
21
  * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}
20
22
  */
21
- 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 * 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"],"names":[],"mappings":";;;AAyBa,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,5 +1,8 @@
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
  *
@@ -12,15 +15,15 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice ? TSlice[
12
15
  *
13
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
20
  * The minimum required properties to represent a Prismic slice from the Prismic
18
21
  * GraphQL API for the `mapSliceZone()` helper.
19
22
  *
20
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
29
  * The minimum required properties to represent a Prismic slice for the
@@ -31,14 +34,14 @@ export type SliceLikeGraphQL<TSliceType extends string = string> = {
31
34
  *
32
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
@@ -49,7 +52,7 @@ export type SliceLike<TSliceType extends string = string> = (SliceLikeRestV2<TSl
49
52
  *
50
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
57
  * React props for a component rendering content from a Prismic slice using the
55
58
  * `<SliceZone>` component.
@@ -58,18 +61,18 @@ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlic
58
61
  * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made
59
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
78
  * A React component to be rendered for each instance of its slice.
@@ -77,7 +80,7 @@ export type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext =
77
80
  * @typeParam TSlice - The type(s) of a slice in the slice zone.
78
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
85
  * A record of slice types mapped to a React component. The component will be
83
86
  * rendered for each instance of its slice.
@@ -88,27 +91,25 @@ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknow
88
91
  * @typeParam TSlice - The type(s) of a slice in the slice zone.
89
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
98
  * @typeParam TSlice - The type(s) of a slice in the slice zone.
98
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
115
  * This slice component can be used as a reminder to provide a proper
@@ -117,9 +118,11 @@ export type SliceZoneProps<TContext = unknown> = {
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
127
  * Renders slices in a slice zone as React components.
125
128
  *
@@ -131,5 +134,7 @@ export declare const TODOSliceComponent: <TSlice extends SliceLike>({ slice, }:
131
134
  *
132
135
  * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}
133
136
  */
134
- export declare const SliceZone: FC<SliceZoneProps>;
135
- 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"}
package/dist/SliceZone.js CHANGED
@@ -1,32 +1,59 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
1
  import { DEV } from "esm-env";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+
4
+ //#region src/SliceZone.tsx
5
+ /**
6
+ * This slice component can be used as a reminder to provide a proper
7
+ * implementation.
8
+ *
9
+ * This is also the default React component rendered when a component mapping
10
+ * cannot be found in `<SliceZone>`.
11
+ */
3
12
  const TODOSliceComponent = ({ slice }) => {
4
- if (!DEV) {
5
- return null;
6
- }
7
- const type = "slice_type" in slice ? slice.slice_type : slice.type;
8
- console.warn(`[SliceZone] Could not find a component for slice type "${type}"`, slice);
9
- return jsxs("section", { "data-slice-zone-todo-component": "", "data-slice-type": type, children: ["Could not find a component for slice type “", type, "”"] });
13
+ if (!DEV) return null;
14
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
15
+ console.warn(`[SliceZone] Could not find a component for slice type "${type}"`, slice);
16
+ return /* @__PURE__ */ jsxs("section", {
17
+ "data-slice-zone-todo-component": "",
18
+ "data-slice-type": type,
19
+ children: [
20
+ "Could not find a component for slice type “",
21
+ type,
22
+ "”"
23
+ ]
24
+ });
10
25
  };
26
+ /**
27
+ * Renders slices in a slice zone as React components.
28
+ *
29
+ * @example
30
+ *
31
+ * ```tsx
32
+ * <SliceZone slices={page.data.slices} components={components} />;
33
+ * ```
34
+ *
35
+ * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}
36
+ */
11
37
  const SliceZone = (props) => {
12
- const { slices = [], components = {}, defaultComponent, context = {} } = props;
13
- const renderedSlices = slices.map((slice, index) => {
14
- const type = "slice_type" in slice ? slice.slice_type : slice.type;
15
- const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
16
- const Comp = components[type] || defaultComponent;
17
- if (!Comp) {
18
- return jsx(TODOSliceComponent, { slice }, key);
19
- }
20
- if (slice.__mapped) {
21
- const { __mapped, ...mappedProps } = slice;
22
- return jsx(Comp, { ...mappedProps }, key);
23
- }
24
- return jsx(Comp, { slice, index, slices, context }, key);
25
- });
26
- return jsx(Fragment, { children: renderedSlices });
38
+ const { slices = [], components = {}, defaultComponent, context = {} } = props;
39
+ return /* @__PURE__ */ jsx(Fragment, { children: slices.map((slice, index) => {
40
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
41
+ const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
42
+ const Comp = components[type] || defaultComponent;
43
+ if (!Comp) return /* @__PURE__ */ jsx(TODOSliceComponent, { slice }, key);
44
+ if (slice.__mapped) {
45
+ const { __mapped, ...mappedProps } = slice;
46
+ return /* @__PURE__ */ jsx(Comp, { ...mappedProps }, key);
47
+ }
48
+ return /* @__PURE__ */ jsx(Comp, {
49
+ slice,
50
+ index,
51
+ slices,
52
+ context
53
+ }, key);
54
+ }) });
27
55
  };
28
- export {
29
- SliceZone,
30
- TODOSliceComponent
31
- };
32
- //# sourceMappingURL=SliceZone.js.map
56
+
57
+ //#endregion
58
+ export { SliceZone, TODOSliceComponent };
59
+ //# sourceMappingURL=SliceZone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SliceZone.js","sources":["../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}) => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type &ldquo;{type}\n\t\t\t&rdquo;\n\t\t</section>\n\t);\n};\n\n/**\n * Renders slices in a slice zone as React components.\n *\n * @example\n *\n * ```tsx\n * <SliceZone slices={page.data.slices} components={components} />;\n * ```\n *\n * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;AAoLO,MAAM,qBAAqB,CAA2B,EAC5D,YAGI;AACJ,MAAI,CAAC,KAAK;AACF,WAAA;AAAA,EAAA;AAGR,QAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,UAAQ,KACP,0DAA0D,IAAI,KAC9D,KAAK;AAGN,SACCA,oDAAwC,IAAE,mBAAkB,MACT,UAAA,CAAA,+CAAA,MAEzC,GAAA,GAAA;AAEZ;AAaa,MAAA,YAAgC,CAAC,UAAS;AAChD,QAAA,EACL,SAAS,CAAA,GACT,aAAa,CAAA,GACb,kBACA,UAAU,OACP;AAEJ,QAAM,iBAAiB,OAAO,IAAI,CAAC,OAAO,UAAS;AAClD,UAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,UAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,KAAK,IAAI,KAAK,UAAU,KAAK,CAAC;AAE/B,UAAA,OACL,WAAW,IAA+B,KAAK;AAEhD,QAAI,CAAC,MAAM;AACV,aAAOC,IAAC,oBAA6B,EAAA,MAAA,GAAL,GAAG;AAAA,IAAA;AAGpC,QAAI,MAAM,UAAU;AACnB,YAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAErC,aAAOA,IAAC,MAAI,EAAA,GAAe,YAAA,GAAT,GAAG;AAAA,IAAA;AAIrB,WAAAA,IAAC,MAAI,EAEJ,OACA,OACA,QACA,WAJK,GAAG;AAAA,EAAA,CAOV;AAED,SAAOA,IAAAC,UAAA,EAAA,UAAG,gBAAc;AACzB;"}
1
+ {"version":3,"file":"SliceZone.js","names":[],"sources":["../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}): ReactNode => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type &ldquo;{type}\n\t\t\t&rdquo;\n\t\t</section>\n\t);\n};\n\n/**\n * Renders slices in a slice zone as React components.\n *\n * @example\n *\n * ```tsx\n * <SliceZone slices={page.data.slices} components={components} />;\n * ```\n *\n * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"mappings":";;;;;;;;;;;AAoLA,MAAa,sBAAgD,EAC5D,YAGgB;AAChB,KAAI,CAAC,IACJ,QAAO;CAGR,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,SAAQ,KACP,0DAA0D,KAAK,IAC/D,MACA;AAED,QACC,qBAAC;EAAQ,kCAA+B;EAAG,mBAAiB;;GAAM;GACf;GAAK;;GAE9C;;;;;;;;;;;;;AAeZ,MAAa,aAAiC,UAAU;CACvD,MAAM,EACL,SAAS,EAAE,EACX,aAAa,EAAE,EACf,kBACA,UAAU,EAAE,KACT;AAkCJ,QAAO,0CAhCgB,OAAO,KAAK,OAAO,UAAU;EACnD,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;EAE9D,MAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;EAErC,MAAM,OACL,WAAW,SAAoC;AAEhD,MAAI,CAAC,KACJ,QAAO,oBAAC,sBAAoC,SAAZ,IAAqB;AAGtD,MAAI,MAAM,UAAU;GACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,UAAO,oBAAC,QAAe,GAAI,eAAT,IAAwB;;AAG3C,SACC,oBAAC;GAEO;GACA;GACC;GACC;KAJJ,IAKJ;GAEF,GAE0B"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,9 @@
1
- export { PrismicLink } from "./PrismicLink.js";
2
- export type { PrismicLinkProps, LinkProps } from "./PrismicLink.js";
3
- export { PrismicTable } from "./PrismicTable.js";
4
- export type { PrismicTableProps } from "./PrismicTable.js";
5
- export { PrismicText } from "./PrismicText.js";
6
- export type { PrismicTextProps } from "./PrismicText.js";
7
- export { PrismicRichText } from "./PrismicRichText.js";
8
- export type { PrismicRichTextProps, RichTextComponents, JSXMapSerializer, JSXFunctionSerializer, } from "./PrismicRichText.js";
9
- export { Element } from "@prismicio/client/richtext";
10
- export { PrismicImage } from "./PrismicImage.js";
11
- export type { PrismicImageProps } from "./PrismicImage.js";
12
- export { SliceZone, TODOSliceComponent } from "./SliceZone.js";
13
- export type { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZoneComponents, SliceZoneLike, SliceZoneProps, } from "./SliceZone.js";
14
- export { PrismicToolbar } from "./PrismicToolbar.js";
15
- export type { PrismicToolbarProps } from "./PrismicToolbar.js";
1
+ import { LinkProps, PrismicLink, PrismicLinkProps } from "./PrismicLink.js";
2
+ import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.js";
3
+ import { PrismicTable, PrismicTableProps } from "./PrismicTable.js";
4
+ import { PrismicText, PrismicTextProps } from "./PrismicText.js";
5
+ import { PrismicImage, PrismicImageProps } from "./PrismicImage.js";
6
+ import { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "./SliceZone.js";
7
+ import { PrismicToolbar, PrismicToolbarProps } from "./PrismicToolbar.js";
8
+ import { Element } from "@prismicio/client/richtext";
9
+ export { Element, type JSXFunctionSerializer, type JSXMapSerializer, type LinkProps, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, PrismicToolbar, type PrismicToolbarProps, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceZone, type SliceZoneComponents, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent };
package/dist/index.js CHANGED
@@ -1,20 +1,10 @@
1
1
  import { PrismicLink } from "./PrismicLink.js";
2
+ import { PrismicRichText } from "./PrismicRichText.js";
2
3
  import { PrismicTable } from "./PrismicTable.js";
3
4
  import { PrismicText } from "./PrismicText.js";
4
- import { PrismicRichText } from "./PrismicRichText.js";
5
- import { Element } from "@prismicio/client/richtext";
6
5
  import { PrismicImage } from "./PrismicImage.js";
7
6
  import { SliceZone, TODOSliceComponent } from "./SliceZone.js";
8
7
  import { PrismicToolbar } from "./PrismicToolbar.js";
9
- export {
10
- Element,
11
- PrismicImage,
12
- PrismicLink,
13
- PrismicRichText,
14
- PrismicTable,
15
- PrismicText,
16
- PrismicToolbar,
17
- SliceZone,
18
- TODOSliceComponent
19
- };
20
- //# sourceMappingURL=index.js.map
8
+ import { Element } from "@prismicio/client/richtext";
9
+
10
+ export { Element, PrismicImage, PrismicLink, PrismicRichText, PrismicTable, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent };