@prismicio/react 3.2.2-pr.236.d65a0c3 → 3.2.2-pr.242.79bae2c

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 (69) hide show
  1. package/dist/index.d.ts +9 -15
  2. package/dist/index.js +9 -19
  3. package/dist/package.js +6 -0
  4. package/dist/package.js.map +1 -0
  5. package/dist/src/PrismicImage.d.ts +76 -0
  6. package/dist/src/PrismicImage.d.ts.map +1 -0
  7. package/dist/src/PrismicImage.js +57 -0
  8. package/dist/src/PrismicImage.js.map +1 -0
  9. package/dist/src/PrismicLink.d.ts +84 -0
  10. package/dist/src/PrismicLink.d.ts.map +1 -0
  11. package/dist/src/PrismicLink.js +66 -0
  12. package/dist/src/PrismicLink.js.map +1 -0
  13. package/dist/src/PrismicRichText.d.ts +96 -0
  14. package/dist/src/PrismicRichText.d.ts.map +1 -0
  15. package/dist/src/PrismicRichText.js +133 -0
  16. package/dist/src/PrismicRichText.js.map +1 -0
  17. package/dist/src/PrismicTable.d.ts +69 -0
  18. package/dist/src/PrismicTable.d.ts.map +1 -0
  19. package/dist/src/PrismicTable.js +75 -0
  20. package/dist/src/PrismicTable.js.map +1 -0
  21. package/dist/src/PrismicText.d.ts +31 -0
  22. package/dist/src/PrismicText.d.ts.map +1 -0
  23. package/dist/src/PrismicText.js +33 -0
  24. package/dist/src/PrismicText.js.map +1 -0
  25. package/dist/src/PrismicToolbar.d.ts +26 -0
  26. package/dist/src/PrismicToolbar.d.ts.map +1 -0
  27. package/dist/src/PrismicToolbar.js +37 -0
  28. package/dist/src/PrismicToolbar.js.map +1 -0
  29. package/dist/{SliceZone.d.ts → src/SliceZone.d.ts} +52 -47
  30. package/dist/src/SliceZone.d.ts.map +1 -0
  31. package/dist/src/SliceZone.js +59 -0
  32. package/dist/src/SliceZone.js.map +1 -0
  33. package/dist/src/lib/devMsg.js +25 -0
  34. package/dist/src/lib/devMsg.js.map +1 -0
  35. package/package.json +16 -34
  36. package/src/PrismicImage.tsx +3 -3
  37. package/src/PrismicLink.tsx +5 -5
  38. package/src/PrismicRichText.tsx +9 -9
  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/lib/devMsg.ts +1 -1
  44. package/dist/PrismicImage.d.ts +0 -74
  45. package/dist/PrismicImage.js +0 -50
  46. package/dist/PrismicImage.js.map +0 -1
  47. package/dist/PrismicLink.d.ts +0 -88
  48. package/dist/PrismicLink.js +0 -47
  49. package/dist/PrismicLink.js.map +0 -1
  50. package/dist/PrismicRichText.d.ts +0 -90
  51. package/dist/PrismicRichText.js +0 -79
  52. package/dist/PrismicRichText.js.map +0 -1
  53. package/dist/PrismicTable.d.ts +0 -65
  54. package/dist/PrismicTable.js +0 -28
  55. package/dist/PrismicTable.js.map +0 -1
  56. package/dist/PrismicText.d.ts +0 -26
  57. package/dist/PrismicText.js +0 -26
  58. package/dist/PrismicText.js.map +0 -1
  59. package/dist/PrismicToolbar.d.ts +0 -21
  60. package/dist/PrismicToolbar.js +0 -24
  61. package/dist/PrismicToolbar.js.map +0 -1
  62. package/dist/SliceZone.js +0 -32
  63. package/dist/SliceZone.js.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. package/dist/lib/devMsg.d.ts +0 -16
  66. package/dist/lib/devMsg.js +0 -8
  67. package/dist/lib/devMsg.js.map +0 -1
  68. package/dist/package.json.js +0 -5
  69. package/dist/package.json.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicRichText.js","names":["result: ReactNode[]","PrismicRichText: FC<PrismicRichTextProps>"],"sources":["../../src/PrismicRichText.tsx"],"sourcesContent":["import {\n\tcloneElement,\n\ttype ComponentType,\n\ttype FC,\n\tFragment,\n\tisValidElement,\n\ttype ReactNode,\n} from \"react\";\nimport {\n\tisFilled,\n\ttype LinkResolverFunction,\n\ttype RichTextField,\n\ttype RTAnyNode,\n} from \"@prismicio/client\";\nimport {\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n\ttype RichTextFunctionSerializer,\n\ttype RichTextMapSerializer,\n} from \"@prismicio/client/richtext\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\nimport { type LinkProps, PrismicLink } from \"./PrismicLink.js\";\n\n/**\n * A function mapping rich text block types to React Components. It is used to\n * render rich text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;\n\n/**\n * A map of rich text block types to React Components. It is used to render rich\n * text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type JSXMapSerializer = RichTextMapSerializer<ReactNode>;\n\n/** Props for `<PrismicRichText>`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a rich text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\ntype CreateDefaultSerializerArgs = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: ComponentType<LinkProps>;\n\texternalLinkComponent?: ComponentType<LinkProps>;\n};\n\nconst getDir = (node: RTAnyNode): \"rtl\" | undefined => {\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\treturn \"rtl\";\n\t}\n};\n\nconst createDefaultSerializer = (\n\targs: CreateDefaultSerializerArgs,\n): JSXFunctionSerializer =>\n\twrapMapSerializer<ReactNode>({\n\t\theading1: ({ node, children, key }) => (\n\t\t\t<h1 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h1>\n\t\t),\n\t\theading2: ({ node, children, key }) => (\n\t\t\t<h2 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h2>\n\t\t),\n\t\theading3: ({ node, children, key }) => (\n\t\t\t<h3 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h3>\n\t\t),\n\t\theading4: ({ node, children, key }) => (\n\t\t\t<h4 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h4>\n\t\t),\n\t\theading5: ({ node, children, key }) => (\n\t\t\t<h5 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h5>\n\t\t),\n\t\theading6: ({ node, children, key }) => (\n\t\t\t<h6 key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</h6>\n\t\t),\n\t\tparagraph: ({ node, children, key }) => (\n\t\t\t<p key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t),\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\toListItem: ({ node, children, key }) => (\n\t\t\t<li key={key} dir={getDir(node)}>\n\t\t\t\t{children}\n\t\t\t</li>\n\t\t),\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<Fragment key={`${i}__line`}>{line}</Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <Fragment key={key}>{result}</Fragment>;\n\t\t},\n\t});\n\n/**\n * Renders content from a Prismic rich text field as React components.\n *\n * @example\n *\n * ```tsx\n * <PrismicRichText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to style rich text, use custom components, and use labels for custom formatting: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = (props) => {\n\tconst {\n\t\tlinkResolver,\n\t\tfield,\n\t\tfallback,\n\t\tcomponents,\n\t\texternalLinkComponent,\n\t\tinternalLinkComponent,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in restProps) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tfield,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\tconst serializer = composeSerializers<ReactNode>(\n\t\ttypeof components === \"object\" ? wrapMapSerializer(components) : components,\n\t\tcreateDefaultSerializer({\n\t\t\tlinkResolver,\n\t\t\tinternalLinkComponent,\n\t\t\texternalLinkComponent,\n\t\t}),\n\t);\n\n\t// The serializer is wrapped in a higher-order function that\n\t// automatically applies a key to React Elements if one is not already\n\t// given.\n\tconst serialized = serialize<ReactNode>(\n\t\tfield,\n\t\t(type, node, text, children, key) => {\n\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\tif (isValidElement(result) && result.key == null) {\n\t\t\t\treturn cloneElement(result, { key });\n\t\t\t} else {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t},\n\t);\n\n\tif (!serialized) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{serialized}</>;\n};\n"],"mappings":"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"}
@@ -0,0 +1,69 @@
1
+ import { JSXMapSerializer } from "./PrismicRichText.js";
2
+ import { ComponentType, FC, ReactNode } from "react";
3
+ import { TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client";
4
+
5
+ //#region src/PrismicTable.d.ts
6
+ type TableComponents = {
7
+ table?: ComponentType<{
8
+ table: TableField<"filled">;
9
+ children: ReactNode;
10
+ }>;
11
+ thead?: ComponentType<{
12
+ head: TableFieldHead;
13
+ children: ReactNode;
14
+ }>;
15
+ tbody?: ComponentType<{
16
+ body: TableFieldBody;
17
+ children: ReactNode;
18
+ }>;
19
+ tr?: ComponentType<{
20
+ row: TableFieldHeadRow | TableFieldBodyRow;
21
+ children: ReactNode;
22
+ }>;
23
+ th?: ComponentType<{
24
+ cell: TableFieldHeaderCell;
25
+ children: ReactNode;
26
+ }>;
27
+ td?: ComponentType<{
28
+ cell: TableFieldDataCell;
29
+ children: ReactNode;
30
+ }>;
31
+ };
32
+ /** Props for `<PrismicTable>`. */
33
+ type PrismicTableProps = {
34
+ /** The Prismic table field to render. */
35
+ field: TableField;
36
+ /**
37
+ * An object that maps a table block to a React component.
38
+ *
39
+ * @example A map serializer.
40
+ *
41
+ * ```jsx
42
+ * {
43
+ * table: ({children}) => <table>{children}</table>
44
+ * thead: ({children}) => <thead>{children}</thead>
45
+ * }
46
+ * ```
47
+ */
48
+ components?: JSXMapSerializer & TableComponents;
49
+ /**
50
+ * The value to be rendered when the field is empty. If a fallback is not
51
+ * given, `null` will be rendered.
52
+ */
53
+ fallback?: ReactNode;
54
+ };
55
+ /**
56
+ * Renders content from a Prismic table field as React components.
57
+ *
58
+ * @example
59
+ *
60
+ * ```tsx
61
+ * <PrismicTable field={slice.primary.pricing_table} />;
62
+ * ```
63
+ *
64
+ * @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table}
65
+ */
66
+ declare const PrismicTable: FC<PrismicTableProps>;
67
+ //#endregion
68
+ export { PrismicTable, PrismicTableProps };
69
+ //# sourceMappingURL=PrismicTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicTable.d.ts","names":[],"sources":["../../src/PrismicTable.tsx"],"sourcesContent":[],"mappings":";;;;;KAcK,eAAA;UACI;IADJ,KAAA,EAC2B,UADZ,CAAA,QAAA,CAAA;IACY,QAAA,EAAgC,SAAhC;EAAgC,CAAA,CAAA;EAAvD,KAAA,CAAA,EACA,aADA,CAAA;IACsB,IAAA,EAAA,cAAA;IAA0B,QAAA,EAAA,SAAA;EAAhD,CAAA,CAAA;EACsB,KAAA,CAAA,EAAtB,aAAsB,CAAA;IAA0B,IAAA,EAA1B,cAA0B;IAAhD,QAAA,EAAgD,SAAhD;EAEF,CAAA,CAAA;EAAoB,EAAA,CAAA,EADrB,aACqB,CAAA;IACf,GAAA,EADL,iBACK,GADe,iBACf;IAFN,QAAA,EAEM,SAFN;EAIsB,CAAA,CAAA;EAAgC,EAAA,CAAA,EAAtD,aAAsD,CAAA;IAAtD,IAAA,EAAsB,oBAAtB;IACsB,QAAA,EADgC,SAChC;EAA8B,CAAA,CAAA;EAApD,EAAA,CAAA,EAAA,aAAA,CAAA;IAAa,IAAA,EAAS,kBAAT;IAaP,QAAA,EAb8C,SAa7B;EAErB,CAAA,CAAA;CAcM;;AAMF,KAtBA,iBAAA,GAsBA;EAAS;EAcR,KAAA,EAlCL,UA+DP;;;;;;;;;;;;;eAjDa,mBAAmB;;;;;aAMrB;;;;;;;;;;;;;cAcC,cAAc,GAAG"}
@@ -0,0 +1,75 @@
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
6
+ const defaultComponents = {
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 })
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
+ */
25
+ const PrismicTable = (props) => {
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
+ });
48
+ };
49
+ function TableRow(props) {
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
+ });
71
+ }
72
+
73
+ //#endregion
74
+ export { PrismicTable };
75
+ //# sourceMappingURL=PrismicTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicTable.js","names":["defaultComponents: Required<TableComponents>","PrismicTable: FC<PrismicTableProps>"],"sources":["../../src/PrismicTable.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tisFilled,\n\ttype TableField,\n\ttype TableFieldHead,\n\ttype TableFieldHeadRow,\n\ttype TableFieldBody,\n\ttype TableFieldBodyRow,\n\ttype TableFieldHeaderCell,\n\ttype TableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport { type JSXMapSerializer, PrismicRichText } from \"./PrismicRichText.js\";\n\ntype TableComponents = {\n\ttable?: ComponentType<{ table: TableField<\"filled\">; children: ReactNode }>;\n\tthead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;\n\ttbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;\n\ttr?: ComponentType<{\n\t\trow: TableFieldHeadRow | TableFieldBodyRow;\n\t\tchildren: ReactNode;\n\t}>;\n\tth?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;\n\ttd?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;\n};\n\nconst defaultComponents: Required<TableComponents> = {\n\ttable: ({ children }) => <table>{children}</table>,\n\tthead: ({ children }) => <thead>{children}</thead>,\n\ttbody: ({ children }) => <tbody>{children}</tbody>,\n\ttr: ({ children }) => <tr>{children}</tr>,\n\tth: ({ children }) => <th>{children}</th>,\n\ttd: ({ children }) => <td>{children}</td>,\n};\n\n/** Props for `<PrismicTable>`. */\nexport type PrismicTableProps = {\n\t/** The Prismic table field to render. */\n\tfield: TableField;\n\n\t/**\n\t * An object that maps a table block to a React component.\n\t *\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * table: ({children}) => <table>{children}</table>\n\t * thead: ({children}) => <thead>{children}</thead>\n\t * }\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer & TableComponents;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ReactNode;\n};\n\n/**\n * Renders content from a Prismic table field as React components.\n *\n * @example\n *\n * ```tsx\n * <PrismicTable field={slice.primary.pricing_table} />;\n * ```\n *\n * @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = (props) => {\n\tconst { field, components, fallback = null } = props;\n\n\tif (!isFilled.table(field)) {\n\t\treturn fallback;\n\t}\n\n\tconst {\n\t\ttable: Table,\n\t\tthead: Thead,\n\t\ttbody: Tbody,\n\t} = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Table table={field}>\n\t\t\t{field.head && (\n\t\t\t\t<Thead head={field.head}>\n\t\t\t\t\t{field.head.rows.map((row) => (\n\t\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t\t))}\n\t\t\t\t</Thead>\n\t\t\t)}\n\t\t\t<Tbody body={field.body}>\n\t\t\t\t{field.body.rows.map((row) => (\n\t\t\t\t\t<TableRow key={row.key} row={row} components={components} />\n\t\t\t\t))}\n\t\t\t</Tbody>\n\t\t</Table>\n\t);\n};\n\ntype TableRowProps = {\n\trow: TableFieldHeadRow | TableFieldBodyRow;\n\tcomponents?: JSXMapSerializer & TableComponents;\n};\n\nfunction TableRow(props: TableRowProps) {\n\tconst { row, components } = props;\n\n\tconst { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };\n\n\treturn (\n\t\t<Tr row={row}>\n\t\t\t{row.cells.map((cell) =>\n\t\t\t\tcell.type === \"header\" ? (\n\t\t\t\t\t<Th key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Th>\n\t\t\t\t) : (\n\t\t\t\t\t<Td key={cell.key} cell={cell}>\n\t\t\t\t\t\t<PrismicRichText field={cell.content} components={components} />\n\t\t\t\t\t</Td>\n\t\t\t\t),\n\t\t\t)}\n\t\t</Tr>\n\t);\n}\n"],"mappings":";;;;;AA0BA,MAAMA,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,MAAaC,gBAAuC,UAAU;CAC7D,MAAM,EAAE,OAAO,YAAY,WAAW,SAAS;AAE/C,KAAI,CAAC,SAAS,MAAM,MAAM,CACzB,QAAO;CAGR,MAAM,EACL,OAAO,OACP,OAAO,OACP,OAAO,UACJ;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE3C,QACC,qBAAC;EAAM,OAAO;aACZ,MAAM,QACN,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK,EAET,oBAAC;GAAM,MAAM,MAAM;aACjB,MAAM,KAAK,KAAK,KAAK,QACrB,oBAAC;IAA4B;IAAiB;MAA/B,IAAI,IAAyC,CAC3D;IACK;GACD;;AASV,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,KAAK,eAAe;CAE5B,MAAM,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO;EAAE,GAAG;EAAmB,GAAG;EAAY;AAE1E,QACC,oBAAC;EAAQ;YACP,IAAI,MAAM,KAAK,SACf,KAAK,SAAS,WACb,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,GAEL,oBAAC;GAAwB;aACxB,oBAAC;IAAgB,OAAO,KAAK;IAAqB;KAAc;KADxD,KAAK,IAET,CAEN;GACG"}
@@ -0,0 +1,31 @@
1
+ import { FC } from "react";
2
+ import { RichTextField } from "@prismicio/client";
3
+
4
+ //#region src/PrismicText.d.ts
5
+ /** Props for `<PrismicText>`. */
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;
16
+ };
17
+ /**
18
+ * Renders content from a Prismic rich text field as plain text (no HTML).
19
+ *
20
+ * @example
21
+ *
22
+ * ```tsx
23
+ * <PrismicText field={slice.primary.text} />;
24
+ * ```
25
+ *
26
+ * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}
27
+ */
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"}
@@ -0,0 +1,33 @@
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
+ */
18
+ const PrismicText = (props) => {
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 }) });
29
+ };
30
+
31
+ //#endregion
32
+ export { PrismicText };
33
+ //# sourceMappingURL=PrismicText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicText.js","names":["PrismicText: FC<PrismicTextProps>"],"sources":["../../src/PrismicText.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { asText, isFilled, type RichTextField } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** Props for `<PrismicText>`. */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/** The separator used between blocks. Defaults to `\\n`. */\n\tseparator?: string;\n};\n\n/**\n * Renders content from a Prismic rich text field as plain text (no HTML).\n *\n * @example\n *\n * ```tsx\n * <PrismicText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicText: FC<PrismicTextProps> = (props) => {\n\tconst { field, fallback, separator } = props;\n\n\tif (DEV) {\n\t\tif (\"className\" in props) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicText] className cannot be passed to <PrismicText> since it renders plain text without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t)}.`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof props.field === \"string\") {\n\t\tif (DEV) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a rich text field's value but was provided a different type of field instead (e.g. a key text or select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t\tprops.field,\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif (!isFilled.richText(field)) {\n\t\treturn fallback != null ? <>{fallback}</> : null;\n\t}\n\n\treturn <>{asText(field, { separator })}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAaA,eAAqC,UAAU;CAC3D,MAAM,EAAE,OAAO,UAAU,cAAc;AAEvC,KAAI,KACH;MAAI,eAAe,MAClB,SAAQ,KACP,6IAA6I,OAC5I,gCACA,CAAC,IACF,MAAM,MACN;;AAIH,KAAI,OAAO,MAAM,UAAU,UAAU;AACpC,MAAI,IACH,SAAQ,MACP,2QAA2Q,OAC1Q,yDACA,IACD,MAAM,MACN;AAGF,SAAO;;AAGR,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,0CAAG,WAAY,GAAG;AAG7C,QAAO,0CAAG,OAAO,OAAO,EAAE,WAAW,CAAC,GAAI"}
@@ -0,0 +1,26 @@
1
+ import { FC } from "react";
2
+
3
+ //#region src/PrismicToolbar.d.ts
4
+ /** Props for `<PrismicToolbar>`. */
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;
11
+ };
12
+ /**
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}
22
+ */
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"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
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
+ */
18
+ const PrismicToolbar = (props) => {
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;
33
+ };
34
+
35
+ //#endregion
36
+ export { PrismicToolbar };
37
+ //# sourceMappingURL=PrismicToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrismicToolbar.js","names":["PrismicToolbar: FC<PrismicToolbarProps>"],"sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useEffect } from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/** Props for `<PrismicToolbar>`. */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n};\n\n/**\n * Renders the Prismic Toolbar script to support draft previews.\n *\n * @example\n *\n * ```tsx\n * <PrismicToolbar repositoryName=\"my-repo\" />;\n * ```\n *\n * @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}\n */\nexport const PrismicToolbar: FC<PrismicToolbarProps> = (props) => {\n\tconst { repositoryName } = props;\n\n\tconst src = getToolbarSrc(repositoryName);\n\n\tuseEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during tests.\n\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\tscript._evaluateScript = false;\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAaA,kBAA2C,UAAU;CACjE,MAAM,EAAE,mBAAmB;CAE3B,MAAM,MAAM,cAAc,eAAe;AAEzC,iBAAgB;AAGf,MAAI,CAFmB,SAAS,cAAc,eAAe,IAAI,IAAI,EAEhD;GACpB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,MAAM;AACb,UAAO,QAAQ;AAGf,UAAO,QAAQ,iBAAiB;AAChC,UAAO,QAAQ,iBAAiB;AAIhC,UAAO,kBAAkB;AAEzB,YAAS,KAAK,YAAY,OAAO;;IAEhC,CAAC,gBAAgB,IAAI,CAAC;AAEzB,QAAO"}
@@ -1,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"}
@@ -0,0 +1,59 @@
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
+ */
12
+ const TODOSliceComponent = ({ slice }) => {
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
+ });
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
+ */
37
+ const SliceZone = (props) => {
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
+ }) });
55
+ };
56
+
57
+ //#endregion
58
+ export { SliceZone, TODOSliceComponent };
59
+ //# sourceMappingURL=SliceZone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.js","names":["SliceZone: FC<SliceZoneProps>"],"sources":["../../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}): ReactNode => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type &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,MAAaA,aAAiC,UAAU;CACvD,MAAM,EACL,SAAS,EAAE,EACX,aAAa,EAAE,EACf,kBACA,UAAU,EAAE,KACT;AAkCJ,QAAO,0CAhCgB,OAAO,KAAK,OAAO,UAAU;EACnD,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;EAE9D,MAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;EAErC,MAAM,OACL,WAAW,SAAoC;AAEhD,MAAI,CAAC,KACJ,QAAO,oBAAC,sBAAoC,SAAZ,IAAqB;AAGtD,MAAI,MAAM,UAAU;GACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,UAAO,oBAAC,QAAe,GAAI,eAAT,IAAwB;;AAG3C,SACC,oBAAC;GAEO;GACA;GACC;GACC;KAJJ,IAKJ;GAEF,GAE0B"}
@@ -0,0 +1,25 @@
1
+ import { version } from "../../package.js";
2
+
3
+ //#region src/lib/devMsg.ts
4
+ /**
5
+ * Returns a `prismic.dev/msg` URL for a given message slug.
6
+ *
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * devMsg("missing-param");
11
+ * // => "https://prismic.dev/msg/react/v1.2.3/missing-param"
12
+ * ```
13
+ *
14
+ * @param slug - Slug for the message. This corresponds to a Markdown file in
15
+ * the Git repository's `/messages` directory.
16
+ *
17
+ * @returns The `prismic.dev/msg` URL for the given slug.
18
+ */
19
+ function devMsg(slug) {
20
+ return `https://prismic.dev/msg/react/v${version}/${slug}`;
21
+ }
22
+
23
+ //#endregion
24
+ export { devMsg };
25
+ //# sourceMappingURL=devMsg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devMsg.js","names":[],"sources":["../../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/react/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport function devMsg(slug: string): string {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,OAAO,MAAsB;AAC5C,QAAO,kCAAkC,QAAQ,GAAG"}