@prismicio/react 3.2.2-pr.241.fab3732 → 3.2.2-pr.242.531bab1

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.
@@ -18,11 +18,7 @@ type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;
18
18
  *
19
19
  * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
20
20
  */
21
- type RichTextComponents = RichTextMapSerializer<ReactNode>;
22
- /**
23
- * @deprecated Use `RichTextComponents` instead.
24
- */
25
- type JSXMapSerializer = RichTextComponents;
21
+ type JSXMapSerializer = RichTextMapSerializer<ReactNode>;
26
22
  /** Props for `<PrismicRichText>`. */
27
23
  type PrismicRichTextProps = {
28
24
  /** The Prismic rich text field to render. */
@@ -64,7 +60,7 @@ type PrismicRichTextProps = {
64
60
  * };
65
61
  * ```
66
62
  */
67
- components?: RichTextComponents | JSXFunctionSerializer;
63
+ components?: JSXMapSerializer | JSXFunctionSerializer;
68
64
  /**
69
65
  * The React component rendered for links when the URL is internal.
70
66
  *
@@ -96,5 +92,5 @@ type PrismicRichTextProps = {
96
92
  */
97
93
  declare const PrismicRichText: FC<PrismicRichTextProps>;
98
94
  //#endregion
99
- export { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps, RichTextComponents };
95
+ export { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps };
100
96
  //# sourceMappingURL=PrismicRichText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.d.ts","names":[],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AA+BA;AAQA;AAKA;AAGA;AAEQ,KAlBI,qBAAA,GAAwB,0BAkB5B,CAlBuD,SAkBvD,CAAA;;;;;;;AAsDiB,KAhEb,kBAAA,GAAqB,qBAgER,CAhE8B,SAgE9B,CAAA;;;AA2JzB;KAtNY,gBAAA,GAAmB;;KAGnB,oBAAA;;SAEJ;;;;;;;;;;iBAWQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6BF,qBAAqB;;;;;;0BAOV,cAAc;;;;;;0BAOd,cAAc;;;;;aAM3B;;;;;;;;;;;;;cAqJC,iBAAiB,GAAG"}
1
+ {"version":3,"file":"PrismicRichText.d.ts","names":[],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;AAiCA;AAQA;AAGA;;AAagB,KAxBJ,qBAAA,GAAwB,0BAwBpB,CAxB+C,SAwB/C,CAAA;;;;;;;AAiDJ,KAjEA,gBAAA,GAAmB,qBAiEnB,CAjEyC,SAiEzC,CAAA;;AAqJC,KAnND,oBAAA,GAmNqB;;SAjNzB;;;;;;;;;;iBAWQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA6BF,mBAAmB;;;;;;0BAOR,cAAc;;;;;;0BAOd,cAAc;;;;;aAM3B;;;;;;;;;;;;;cAqJC,iBAAiB,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.js","names":[],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":["import { type LinkProps, PrismicLink } from \"./PrismicLink.js\";\nimport { devMsg } from \"./lib/devMsg.js\";\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\";\nimport {\n\tcloneElement,\n\ttype ComponentType,\n\ttype FC,\n\tFragment,\n\tisValidElement,\n\ttype ReactNode,\n} from \"react\";\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 RichTextComponents = RichTextMapSerializer<ReactNode>;\n\n/**\n * @deprecated Use `RichTextComponents` instead.\n */\nexport type JSXMapSerializer = RichTextComponents;\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?: RichTextComponents | 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":";;;;;;;;;AAsHA,MAAM,UAAU,SAAuC;AACtD,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,QAAO;;AAIT,MAAM,2BACL,SAEA,kBAA6B;CAC5B,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,YAAY,EAAE,MAAM,UAAU,UAC7B,oBAAC;EAAY,KAAK,OAAO,KAAK;EAC5B;IADM,IAEJ;CAEL,eAAe,EAAE,MAAM,UAAU,oBAAC,mBAAe,KAAK,QAAX,IAAsB;CACjE,SAAS,EAAE,UAAU,UAAU,oBAAC,YAAkB,YAAN,IAAwB;CACpE,KAAK,EAAE,UAAU,UAAU,oBAAC,QAAc,YAAN,IAAoB;CACxD,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,YAAY,EAAE,MAAM,UAAU,UAC7B,oBAAC;EAA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CACnE,MAAM,EACL,cACA,OACA,UACA,YACA,uBACA,uBACA,GAAG,cACA;AAEJ,KAAI,KACH;MAAI,eAAe,UAClB,SAAQ,KACP,mJAAmJ,OAClJ,gCACA,CAAC,IACF,MACA;;AAIH,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,4CAAG,WAAY,GAAG;CAG7C,MAAM,aAAa,mBAClB,OAAO,eAAe,WAAW,kBAAkB,WAAW,GAAG,YACjE,wBAAwB;EACvB;EACA;EACA;EACA,CAAC,CACF;CAKD,MAAM,aAAa,UAClB,QACC,MAAM,MAAM,MAAM,UAAU,QAAQ;EACpC,MAAM,SAAS,WAAW,MAAM,MAAM,MAAM,UAAU,IAAI;AAE1D,MAAI,eAAe,OAAO,IAAI,OAAO,OAAO,KAC3C,QAAO,aAAa,QAAQ,EAAE,KAAK,CAAC;MAEpC,QAAO;GAGT;AAED,KAAI,CAAC,WACJ,QAAO,YAAY,OAAO,4CAAG,WAAY,GAAG;AAG7C,QAAO,4CAAG,aAAc"}
1
+ {"version":3,"file":"PrismicRichText.js","names":[],"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":";;;;;;;;;AAmHA,MAAM,UAAU,SAAuC;AACtD,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,QAAO;;AAIT,MAAM,2BACL,SAEA,kBAA6B;CAC5B,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,YAAY,EAAE,MAAM,UAAU,UAC7B,oBAAC;EAAY,KAAK,OAAO,KAAK;EAC5B;IADM,IAEJ;CAEL,eAAe,EAAE,MAAM,UAAU,oBAAC,mBAAe,KAAK,QAAX,IAAsB;CACjE,SAAS,EAAE,UAAU,UAAU,oBAAC,YAAkB,YAAN,IAAwB;CACpE,KAAK,EAAE,UAAU,UAAU,oBAAC,QAAc,YAAN,IAAoB;CACxD,WAAW,EAAE,MAAM,UAAU,UAC5B,oBAAC;EAAa,KAAK,OAAO,KAAK;EAC7B;IADO,IAEJ;CAEN,YAAY,EAAE,MAAM,UAAU,UAC7B,oBAAC;EAAa,KAAK,OAAO,KAA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ACA,OACA,UACA,YACA,uBACA,uBACA,GAAG,cACA;AAEJ,KAAI,KACH;MAAI,eAAe,UAClB,SAAQ,KACP,mJAAmJ,OAClJ,gCACA,CAAC,IACF,MACA;;AAIH,KAAI,CAAC,SAAS,SAAS,MAAM,CAC5B,QAAO,YAAY,OAAO,4CAAG,WAAY,GAAG;CAG7C,MAAM,aAAa,mBAClB,OAAO,eAAe,WAAW,kBAAkB,WAAW,GAAG,YACjE,wBAAwB;EACvB;EACA;EACA;EACA,CAAC,CACF;CAKD,MAAM,aAAa,UAClB,QACC,MAAM,MAAM,MAAM,UAAU,QAAQ;EACpC,MAAM,SAAS,WAAW,MAAM,MAAM,MAAM,UAAU,IAAI;AAE1D,MAAI,eAAe,OAAO,IAAI,OAAO,OAAO,KAC3C,QAAO,aAAa,QAAQ,EAAE,KAAK,CAAC;MAEpC,QAAO;GAGT;AAED,KAAI,CAAC,WACJ,QAAO,YAAY,OAAO,4CAAG,WAAY,GAAG;AAG7C,QAAO,4CAAG,aAAc"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { LinkProps, PrismicLink, PrismicLinkProps } from "./PrismicLink.js";
2
- import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps, RichTextComponents } from "./PrismicRichText.js";
2
+ import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.js";
3
3
  import { PrismicTable, PrismicTableProps } from "./PrismicTable.js";
4
4
  import { PrismicText, PrismicTextProps } from "./PrismicText.js";
5
5
  import { PrismicImage, PrismicImageProps } from "./PrismicImage.js";
6
6
  import { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "./SliceZone.js";
7
7
  import { PrismicToolbar, PrismicToolbarProps } from "./PrismicToolbar.js";
8
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 RichTextComponents, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceZone, type SliceZoneComponents, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent };
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/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.2.2-pr.241.fab3732";
2
+ var version = "3.2.2-pr.242.531bab1";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/react",
3
- "version": "3.2.2-pr.241.fab3732",
3
+ "version": "3.2.2-pr.242.531bab1",
4
4
  "description": "React components and hooks to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -1,5 +1,11 @@
1
- import { type LinkProps, PrismicLink } from "./PrismicLink.js";
2
- import { devMsg } from "./lib/devMsg.js";
1
+ import {
2
+ cloneElement,
3
+ type ComponentType,
4
+ type FC,
5
+ Fragment,
6
+ isValidElement,
7
+ type ReactNode,
8
+ } from "react";
3
9
  import {
4
10
  isFilled,
5
11
  type LinkResolverFunction,
@@ -14,14 +20,10 @@ import {
14
20
  type RichTextMapSerializer,
15
21
  } from "@prismicio/client/richtext";
16
22
  import { DEV } from "esm-env";
17
- import {
18
- cloneElement,
19
- type ComponentType,
20
- type FC,
21
- Fragment,
22
- isValidElement,
23
- type ReactNode,
24
- } from "react";
23
+
24
+ import { devMsg } from "./lib/devMsg.js";
25
+
26
+ import { type LinkProps, PrismicLink } from "./PrismicLink.js";
25
27
 
26
28
  /**
27
29
  * A function mapping rich text block types to React Components. It is used to
@@ -37,12 +39,7 @@ export type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;
37
39
  *
38
40
  * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
39
41
  */
40
- export type RichTextComponents = RichTextMapSerializer<ReactNode>;
41
-
42
- /**
43
- * @deprecated Use `RichTextComponents` instead.
44
- */
45
- export type JSXMapSerializer = RichTextComponents;
42
+ export type JSXMapSerializer = RichTextMapSerializer<ReactNode>;
46
43
 
47
44
  /** Props for `<PrismicRichText>`. */
48
45
  export type PrismicRichTextProps = {
@@ -87,7 +84,7 @@ export type PrismicRichTextProps = {
87
84
  * };
88
85
  * ```
89
86
  */
90
- components?: RichTextComponents | JSXFunctionSerializer;
87
+ components?: JSXMapSerializer | JSXFunctionSerializer;
91
88
 
92
89
  /**
93
90
  * The React component rendered for links when the URL is internal.
package/src/index.ts CHANGED
@@ -10,7 +10,6 @@ export type { PrismicTextProps } from "./PrismicText.js";
10
10
  export { PrismicRichText } from "./PrismicRichText.js";
11
11
  export type {
12
12
  PrismicRichTextProps,
13
- RichTextComponents,
14
13
  JSXMapSerializer,
15
14
  JSXFunctionSerializer,
16
15
  } from "./PrismicRichText.js";