@prismicio/react 3.2.2-pr.241.0f293b1 → 3.2.2-pr.242.afe79ea
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.
- package/dist/index.d.ts +9 -15
- package/dist/index.js +9 -19
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/src/PrismicImage.d.ts +76 -0
- package/dist/src/PrismicImage.d.ts.map +1 -0
- package/dist/src/PrismicImage.js +57 -0
- package/dist/src/PrismicImage.js.map +1 -0
- package/dist/src/PrismicLink.d.ts +84 -0
- package/dist/src/PrismicLink.d.ts.map +1 -0
- package/dist/src/PrismicLink.js +66 -0
- package/dist/src/PrismicLink.js.map +1 -0
- package/dist/src/PrismicRichText.d.ts +96 -0
- package/dist/src/PrismicRichText.d.ts.map +1 -0
- package/dist/src/PrismicRichText.js +133 -0
- package/dist/src/PrismicRichText.js.map +1 -0
- package/dist/src/PrismicTable.d.ts +69 -0
- package/dist/src/PrismicTable.d.ts.map +1 -0
- package/dist/src/PrismicTable.js +75 -0
- package/dist/src/PrismicTable.js.map +1 -0
- package/dist/src/PrismicText.d.ts +31 -0
- package/dist/src/PrismicText.d.ts.map +1 -0
- package/dist/src/PrismicText.js +33 -0
- package/dist/src/PrismicText.js.map +1 -0
- package/dist/src/PrismicToolbar.d.ts +26 -0
- package/dist/src/PrismicToolbar.d.ts.map +1 -0
- package/dist/src/PrismicToolbar.js +37 -0
- package/dist/src/PrismicToolbar.js.map +1 -0
- package/dist/{SliceZone.d.ts → src/SliceZone.d.ts} +52 -47
- package/dist/src/SliceZone.d.ts.map +1 -0
- package/dist/src/SliceZone.js +59 -0
- package/dist/src/SliceZone.js.map +1 -0
- package/dist/src/lib/devMsg.js +25 -0
- package/dist/src/lib/devMsg.js.map +1 -0
- package/package.json +17 -35
- package/src/PrismicImage.tsx +3 -3
- package/src/PrismicLink.tsx +5 -5
- package/src/PrismicRichText.tsx +11 -16
- package/src/PrismicTable.tsx +9 -9
- package/src/PrismicText.tsx +2 -2
- package/src/PrismicToolbar.tsx +1 -1
- package/src/SliceZone.tsx +2 -2
- package/src/index.ts +0 -1
- package/src/lib/devMsg.ts +1 -1
- package/dist/PrismicImage.d.ts +0 -74
- package/dist/PrismicImage.js +0 -50
- package/dist/PrismicImage.js.map +0 -1
- package/dist/PrismicLink.d.ts +0 -88
- package/dist/PrismicLink.js +0 -47
- package/dist/PrismicLink.js.map +0 -1
- package/dist/PrismicRichText.d.ts +0 -94
- package/dist/PrismicRichText.js +0 -79
- package/dist/PrismicRichText.js.map +0 -1
- package/dist/PrismicTable.d.ts +0 -65
- package/dist/PrismicTable.js +0 -28
- package/dist/PrismicTable.js.map +0 -1
- package/dist/PrismicText.d.ts +0 -26
- package/dist/PrismicText.js +0 -26
- package/dist/PrismicText.js.map +0 -1
- package/dist/PrismicToolbar.d.ts +0 -21
- package/dist/PrismicToolbar.js +0 -24
- package/dist/PrismicToolbar.js.map +0 -1
- package/dist/SliceZone.js +0 -32
- package/dist/SliceZone.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/devMsg.js +0 -8
- package/dist/lib/devMsg.js.map +0 -1
- package/dist/package.json.js +0 -5
- package/dist/package.json.js.map +0 -1
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ComponentType, FC, ReactNode } from "react";
|
|
2
|
-
import { LinkResolverFunction, RichTextField } from "@prismicio/client";
|
|
3
|
-
import { RichTextFunctionSerializer, RichTextMapSerializer } from "@prismicio/client/richtext";
|
|
4
|
-
import { LinkProps } from "./PrismicLink.js";
|
|
5
|
-
/**
|
|
6
|
-
* A function mapping rich text block types to React Components. It is used to
|
|
7
|
-
* render rich text fields.
|
|
8
|
-
*
|
|
9
|
-
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
|
|
10
|
-
*/
|
|
11
|
-
export type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;
|
|
12
|
-
/**
|
|
13
|
-
* A map of rich text block types to React Components. It is used to render rich
|
|
14
|
-
* text fields.
|
|
15
|
-
*
|
|
16
|
-
* @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
|
|
17
|
-
*/
|
|
18
|
-
export type RichTextComponents = RichTextMapSerializer<ReactNode>;
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Use `RichTextComponents` instead.
|
|
21
|
-
*/
|
|
22
|
-
export type JSXMapSerializer = RichTextComponents;
|
|
23
|
-
/** Props for `<PrismicRichText>`. */
|
|
24
|
-
export type PrismicRichTextProps = {
|
|
25
|
-
/** The Prismic rich text field to render. */
|
|
26
|
-
field: RichTextField | null | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* The link resolver used to resolve links.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* If your app uses route resolvers when querying for your Prismic
|
|
32
|
-
* repository's content, a link resolver does not need to be provided.
|
|
33
|
-
*
|
|
34
|
-
* @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
|
|
35
|
-
*/
|
|
36
|
-
linkResolver?: LinkResolverFunction;
|
|
37
|
-
/**
|
|
38
|
-
* A map or function that maps a rich text block to a React component.
|
|
39
|
-
*
|
|
40
|
-
* @remarks
|
|
41
|
-
* Prefer using a map serializer over the function serializer when possible.
|
|
42
|
-
* The map serializer is simpler to maintain.
|
|
43
|
-
*
|
|
44
|
-
* @example A map serializer.
|
|
45
|
-
*
|
|
46
|
-
* ```jsx
|
|
47
|
-
* {
|
|
48
|
-
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @example A function serializer.
|
|
53
|
-
*
|
|
54
|
-
* ```jsx
|
|
55
|
-
* (type, node, content, children) => {
|
|
56
|
-
* switch (type) {
|
|
57
|
-
* case "heading1": {
|
|
58
|
-
* return <Heading>{children}</Heading>;
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* };
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
components?: RichTextComponents | JSXFunctionSerializer;
|
|
65
|
-
/**
|
|
66
|
-
* The React component rendered for links when the URL is internal.
|
|
67
|
-
*
|
|
68
|
-
* @defaultValue `<a>`
|
|
69
|
-
*/
|
|
70
|
-
internalLinkComponent?: ComponentType<LinkProps>;
|
|
71
|
-
/**
|
|
72
|
-
* The React component rendered for links when the URL is external.
|
|
73
|
-
*
|
|
74
|
-
* @defaultValue `<a>`
|
|
75
|
-
*/
|
|
76
|
-
externalLinkComponent?: ComponentType<LinkProps>;
|
|
77
|
-
/**
|
|
78
|
-
* The value to be rendered when the field is empty. If a fallback is not
|
|
79
|
-
* given, `null` will be rendered.
|
|
80
|
-
*/
|
|
81
|
-
fallback?: ReactNode;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Renders content from a Prismic rich text field as React components.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
*
|
|
88
|
-
* ```tsx
|
|
89
|
-
* <PrismicRichText field={slice.primary.text} />;
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @see Learn how to style rich text, use custom components, and use labels for custom formatting: {@link https://prismic.io/docs/fields/rich-text}
|
|
93
|
-
*/
|
|
94
|
-
export declare const PrismicRichText: FC<PrismicRichTextProps>;
|
package/dist/PrismicRichText.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { isValidElement, cloneElement, Fragment as Fragment$1 } from "react";
|
|
3
|
-
import { isFilled } from "@prismicio/client";
|
|
4
|
-
import { composeSerializers, wrapMapSerializer, serialize } from "@prismicio/client/richtext";
|
|
5
|
-
import { DEV } from "esm-env";
|
|
6
|
-
import { devMsg } from "./lib/devMsg.js";
|
|
7
|
-
import { PrismicLink } from "./PrismicLink.js";
|
|
8
|
-
const getDir = (node) => {
|
|
9
|
-
if ("direction" in node && node.direction === "rtl") {
|
|
10
|
-
return "rtl";
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const createDefaultSerializer = (args) => wrapMapSerializer({
|
|
14
|
-
heading1: ({ node, children, key }) => jsx("h1", { dir: getDir(node), children }, key),
|
|
15
|
-
heading2: ({ node, children, key }) => jsx("h2", { dir: getDir(node), children }, key),
|
|
16
|
-
heading3: ({ node, children, key }) => jsx("h3", { dir: getDir(node), children }, key),
|
|
17
|
-
heading4: ({ node, children, key }) => jsx("h4", { dir: getDir(node), children }, key),
|
|
18
|
-
heading5: ({ node, children, key }) => jsx("h5", { dir: getDir(node), children }, key),
|
|
19
|
-
heading6: ({ node, children, key }) => jsx("h6", { dir: getDir(node), children }, key),
|
|
20
|
-
paragraph: ({ node, children, key }) => jsx("p", { dir: getDir(node), children }, key),
|
|
21
|
-
preformatted: ({ node, key }) => jsx("pre", { children: node.text }, key),
|
|
22
|
-
strong: ({ children, key }) => jsx("strong", { children }, key),
|
|
23
|
-
em: ({ children, key }) => jsx("em", { children }, key),
|
|
24
|
-
listItem: ({ node, children, key }) => jsx("li", { dir: getDir(node), children }, key),
|
|
25
|
-
oListItem: ({ node, children, key }) => jsx("li", { dir: getDir(node), children }, key),
|
|
26
|
-
list: ({ children, key }) => jsx("ul", { children }, key),
|
|
27
|
-
oList: ({ children, key }) => jsx("ol", { children }, key),
|
|
28
|
-
image: ({ node, key }) => {
|
|
29
|
-
const img = jsx("img", { src: node.url, alt: node.alt ?? void 0, "data-copyright": node.copyright ? node.copyright : void 0 });
|
|
30
|
-
return jsx("p", { className: "block-img", children: node.linkTo ? jsx(PrismicLink, { linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, field: node.linkTo, children: img }) : img }, key);
|
|
31
|
-
},
|
|
32
|
-
embed: ({ node, key }) => jsx("div", { "data-oembed": node.oembed.embed_url, "data-oembed-type": node.oembed.type, "data-oembed-provider": node.oembed.provider_name, dangerouslySetInnerHTML: { __html: node.oembed.html ?? "" } }, key),
|
|
33
|
-
hyperlink: ({ node, children, key }) => jsx(PrismicLink, { field: node.data, linkResolver: args.linkResolver, internalComponent: args.internalLinkComponent, externalComponent: args.externalLinkComponent, children }, key),
|
|
34
|
-
label: ({ node, children, key }) => jsx("span", { className: node.data.label, children }, key),
|
|
35
|
-
span: ({ text, key }) => {
|
|
36
|
-
const result = [];
|
|
37
|
-
let i = 0;
|
|
38
|
-
for (const line of text.split("\n")) {
|
|
39
|
-
if (i > 0) {
|
|
40
|
-
result.push(jsx("br", {}, `${i}__break`));
|
|
41
|
-
}
|
|
42
|
-
result.push(jsx(Fragment$1, { children: line }, `${i}__line`));
|
|
43
|
-
i++;
|
|
44
|
-
}
|
|
45
|
-
return jsx(Fragment$1, { children: result }, key);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const PrismicRichText = (props) => {
|
|
49
|
-
const { linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps } = props;
|
|
50
|
-
if (DEV) {
|
|
51
|
-
if ("className" in restProps) {
|
|
52
|
-
console.warn(`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg("classname-is-not-a-valid-prop")}.`, field);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (!isFilled.richText(field)) {
|
|
56
|
-
return fallback != null ? jsx(Fragment, { children: fallback }) : null;
|
|
57
|
-
}
|
|
58
|
-
const serializer = composeSerializers(typeof components === "object" ? wrapMapSerializer(components) : components, createDefaultSerializer({
|
|
59
|
-
linkResolver,
|
|
60
|
-
internalLinkComponent,
|
|
61
|
-
externalLinkComponent
|
|
62
|
-
}));
|
|
63
|
-
const serialized = serialize(field, (type, node, text, children, key) => {
|
|
64
|
-
const result = serializer(type, node, text, children, key);
|
|
65
|
-
if (isValidElement(result) && result.key == null) {
|
|
66
|
-
return cloneElement(result, { key });
|
|
67
|
-
} else {
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
if (!serialized) {
|
|
72
|
-
return fallback != null ? jsx(Fragment, { children: fallback }) : null;
|
|
73
|
-
}
|
|
74
|
-
return jsx(Fragment, { children: serialized });
|
|
75
|
-
};
|
|
76
|
-
export {
|
|
77
|
-
PrismicRichText
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=PrismicRichText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.js","sources":["../src/PrismicRichText.tsx"],"sourcesContent":["import {\n\tcloneElement,\n\tComponentType,\n\tFC,\n\tFragment,\n\tisValidElement,\n\tReactNode,\n} from \"react\";\nimport {\n\tisFilled,\n\tLinkResolverFunction,\n\tRichTextField,\n\tRTAnyNode,\n} from \"@prismicio/client\";\nimport {\n\tcomposeSerializers,\n\tserialize,\n\twrapMapSerializer,\n\tRichTextFunctionSerializer,\n\tRichTextMapSerializer,\n} from \"@prismicio/client/richtext\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\nimport { 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 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"],"names":["_jsx","Fragment","_Fragment"],"mappings":"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"}
|
package/dist/PrismicTable.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ComponentType, FC, ReactNode } from "react";
|
|
2
|
-
import { TableField, TableFieldHead, TableFieldHeadRow, TableFieldBody, TableFieldBodyRow, TableFieldHeaderCell, TableFieldDataCell } from "@prismicio/client";
|
|
3
|
-
import { JSXMapSerializer } from "./PrismicRichText.js";
|
|
4
|
-
type TableComponents = {
|
|
5
|
-
table?: ComponentType<{
|
|
6
|
-
table: TableField<"filled">;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}>;
|
|
9
|
-
thead?: ComponentType<{
|
|
10
|
-
head: TableFieldHead;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}>;
|
|
13
|
-
tbody?: ComponentType<{
|
|
14
|
-
body: TableFieldBody;
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
}>;
|
|
17
|
-
tr?: ComponentType<{
|
|
18
|
-
row: TableFieldHeadRow | TableFieldBodyRow;
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
}>;
|
|
21
|
-
th?: ComponentType<{
|
|
22
|
-
cell: TableFieldHeaderCell;
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
}>;
|
|
25
|
-
td?: ComponentType<{
|
|
26
|
-
cell: TableFieldDataCell;
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
}>;
|
|
29
|
-
};
|
|
30
|
-
/** Props for `<PrismicTable>`. */
|
|
31
|
-
export type PrismicTableProps = {
|
|
32
|
-
/** The Prismic table field to render. */
|
|
33
|
-
field: TableField;
|
|
34
|
-
/**
|
|
35
|
-
* An object that maps a table block to a React component.
|
|
36
|
-
*
|
|
37
|
-
* @example A map serializer.
|
|
38
|
-
*
|
|
39
|
-
* ```jsx
|
|
40
|
-
* {
|
|
41
|
-
* table: ({children}) => <table>{children}</table>
|
|
42
|
-
* thead: ({children}) => <thead>{children}</thead>
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
components?: JSXMapSerializer & TableComponents;
|
|
47
|
-
/**
|
|
48
|
-
* The value to be rendered when the field is empty. If a fallback is not
|
|
49
|
-
* given, `null` will be rendered.
|
|
50
|
-
*/
|
|
51
|
-
fallback?: ReactNode;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Renders content from a Prismic table field as React components.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
*
|
|
58
|
-
* ```tsx
|
|
59
|
-
* <PrismicTable field={slice.primary.pricing_table} />;
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table}
|
|
63
|
-
*/
|
|
64
|
-
export declare const PrismicTable: FC<PrismicTableProps>;
|
|
65
|
-
export {};
|
package/dist/PrismicTable.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isFilled } from "@prismicio/client";
|
|
3
|
-
import { PrismicRichText } from "./PrismicRichText.js";
|
|
4
|
-
const defaultComponents = {
|
|
5
|
-
table: ({ children }) => jsx("table", { children }),
|
|
6
|
-
thead: ({ children }) => jsx("thead", { children }),
|
|
7
|
-
tbody: ({ children }) => jsx("tbody", { children }),
|
|
8
|
-
tr: ({ children }) => jsx("tr", { children }),
|
|
9
|
-
th: ({ children }) => jsx("th", { children }),
|
|
10
|
-
td: ({ children }) => jsx("td", { children })
|
|
11
|
-
};
|
|
12
|
-
const PrismicTable = (props) => {
|
|
13
|
-
const { field, components, fallback = null } = props;
|
|
14
|
-
if (!isFilled.table(field)) {
|
|
15
|
-
return fallback;
|
|
16
|
-
}
|
|
17
|
-
const { table: Table, thead: Thead, tbody: Tbody } = { ...defaultComponents, ...components };
|
|
18
|
-
return jsxs(Table, { table: field, children: [field.head && jsx(Thead, { head: field.head, children: field.head.rows.map((row) => jsx(TableRow, { row, components }, row.key)) }), jsx(Tbody, { body: field.body, children: field.body.rows.map((row) => jsx(TableRow, { row, components }, row.key)) })] });
|
|
19
|
-
};
|
|
20
|
-
function TableRow(props) {
|
|
21
|
-
const { row, components } = props;
|
|
22
|
-
const { tr: Tr, th: Th, td: Td } = { ...defaultComponents, ...components };
|
|
23
|
-
return jsx(Tr, { row, children: row.cells.map((cell) => cell.type === "header" ? jsx(Th, { cell, children: jsx(PrismicRichText, { field: cell.content, components }) }, cell.key) : jsx(Td, { cell, children: jsx(PrismicRichText, { field: cell.content, components }) }, cell.key)) });
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
PrismicTable
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=PrismicTable.js.map
|
package/dist/PrismicTable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
package/dist/PrismicText.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { RichTextField } from "@prismicio/client";
|
|
3
|
-
/** 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;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Renders content from a Prismic rich text field as plain text (no HTML).
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <PrismicText field={slice.primary.text} />;
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @see Learn how to display rich text as plain text or React components: {@link https://prismic.io/docs/fields/rich-text}
|
|
25
|
-
*/
|
|
26
|
-
export declare const PrismicText: FC<PrismicTextProps>;
|
package/dist/PrismicText.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { isFilled, asText } from "@prismicio/client";
|
|
3
|
-
import { DEV } from "esm-env";
|
|
4
|
-
import { devMsg } from "./lib/devMsg.js";
|
|
5
|
-
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
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=PrismicText.js.map
|
package/dist/PrismicText.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
package/dist/PrismicToolbar.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
/** 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;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Renders the Prismic Toolbar script to support draft previews.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* ```tsx
|
|
16
|
-
* <PrismicToolbar repositoryName="my-repo" />;
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @see Learn how to set up preview functionality and the toolbar's role in preview sessions: {@link https://prismic.io/docs/previews}
|
|
20
|
-
*/
|
|
21
|
-
export declare const PrismicToolbar: FC<PrismicToolbarProps>;
|
package/dist/PrismicToolbar.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { getToolbarSrc } from "@prismicio/client";
|
|
4
|
-
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;
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
PrismicToolbar
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=PrismicToolbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
package/dist/SliceZone.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { DEV } from "esm-env";
|
|
3
|
-
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, "”"] });
|
|
10
|
-
};
|
|
11
|
-
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 });
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
SliceZone,
|
|
30
|
-
TODOSliceComponent
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=SliceZone.js.map
|
package/dist/SliceZone.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 “{type}\n\t\t\t”\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;"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/lib/devMsg.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* devMsg("missing-param");
|
|
8
|
-
* // => "https://prismic.dev/msg/react/v1.2.3/missing-param"
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @param slug - Slug for the message. This corresponds to a Markdown file in
|
|
12
|
-
* the Git repository's `/messages` directory.
|
|
13
|
-
*
|
|
14
|
-
* @returns The `prismic.dev/msg` URL for the given slug.
|
|
15
|
-
*/
|
|
16
|
-
export declare function devMsg(slug: string): string;
|
package/dist/lib/devMsg.js
DELETED
package/dist/lib/devMsg.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devMsg.js","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) {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"names":[],"mappings":";AAiBM,SAAU,OAAO,MAAY;AAC3B,SAAA,kCAAkC,OAAO,IAAI,IAAI;AACzD;"}
|
package/dist/package.json.js
DELETED
package/dist/package.json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|