@prismicio/react 2.5.2 → 2.6.0-alpha.0
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/PrismicImage.cjs +7 -11
- package/dist/PrismicImage.cjs.map +1 -1
- package/dist/PrismicImage.d.ts +14 -15
- package/dist/PrismicImage.js +6 -10
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicLink.cjs +4 -66
- package/dist/PrismicLink.cjs.map +1 -1
- package/dist/PrismicLink.d.ts +5 -104
- package/dist/PrismicLink.js +4 -65
- package/dist/PrismicLink.js.map +1 -1
- package/dist/PrismicProvider.cjs.map +1 -1
- package/dist/PrismicProvider.d.ts +8 -9
- package/dist/PrismicProvider.js.map +1 -1
- package/dist/PrismicRichText.cjs +4 -71
- package/dist/PrismicRichText.cjs.map +1 -1
- package/dist/PrismicRichText.d.ts +4 -116
- package/dist/PrismicRichText.js +5 -70
- package/dist/PrismicRichText.js.map +1 -1
- package/dist/PrismicText.cjs +4 -4
- package/dist/PrismicText.cjs.map +1 -1
- package/dist/PrismicText.d.ts +2 -2
- package/dist/PrismicText.js +3 -3
- package/dist/PrismicText.js.map +1 -1
- package/dist/PrismicToolbar.cjs +6 -4
- package/dist/PrismicToolbar.cjs.map +1 -1
- package/dist/PrismicToolbar.d.ts +3 -1
- package/dist/PrismicToolbar.js +6 -4
- package/dist/PrismicToolbar.js.map +1 -1
- package/dist/SliceZone.cjs +4 -17
- package/dist/SliceZone.cjs.map +1 -1
- package/dist/SliceZone.d.ts +4 -65
- package/dist/SliceZone.js +4 -17
- package/dist/SliceZone.js.map +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -27
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/react-server/PrismicLink.cjs +59 -0
- package/dist/react-server/PrismicLink.cjs.map +1 -0
- package/dist/react-server/PrismicLink.d.ts +72 -0
- package/dist/react-server/PrismicLink.js +42 -0
- package/dist/react-server/PrismicLink.js.map +1 -0
- package/dist/react-server/PrismicRichText.cjs +92 -0
- package/dist/react-server/PrismicRichText.cjs.map +1 -0
- package/dist/react-server/PrismicRichText.d.ts +104 -0
- package/dist/react-server/PrismicRichText.js +73 -0
- package/dist/react-server/PrismicRichText.js.map +1 -0
- package/dist/react-server/index.d.ts +4 -0
- package/dist/react-server/unsupported.cjs +97 -0
- package/dist/react-server/unsupported.cjs.map +1 -0
- package/dist/react-server/unsupported.d.ts +22 -0
- package/dist/react-server/unsupported.js +97 -0
- package/dist/react-server/unsupported.js.map +1 -0
- package/dist/react-server.cjs +44 -0
- package/dist/react-server.cjs.map +1 -0
- package/dist/react-server.js +41 -0
- package/dist/react-server.js.map +1 -0
- package/dist/useStatefulPrismicClientMethod.cjs +6 -0
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
- package/dist/useStatefulPrismicClientMethod.js +6 -0
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +42 -47
- package/src/PrismicImage.tsx +30 -37
- package/src/PrismicLink.tsx +29 -258
- package/src/PrismicProvider.tsx +9 -8
- package/src/PrismicRichText.tsx +28 -275
- package/src/PrismicText.tsx +4 -5
- package/src/PrismicToolbar.tsx +7 -6
- package/src/SliceZone.tsx +8 -129
- package/src/index.ts +1 -9
- package/src/react-server/PrismicLink.tsx +179 -0
- package/src/react-server/PrismicRichText.tsx +267 -0
- package/src/react-server/index.ts +38 -0
- package/src/react-server/unsupported.ts +98 -0
- package/dist/lib/pascalCase.cjs +0 -10
- package/dist/lib/pascalCase.cjs.map +0 -1
- package/dist/lib/pascalCase.js +0 -10
- package/dist/lib/pascalCase.js.map +0 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as prismic from "@prismicio/client";
|
|
3
|
+
import * as prismicR from "@prismicio/richtext";
|
|
4
|
+
|
|
5
|
+
import { JSXFunctionSerializer, JSXMapSerializer } from "../types";
|
|
6
|
+
import { LinkProps, PrismicLink } from "./PrismicLink";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for `<PrismicRichText>`.
|
|
10
|
+
*/
|
|
11
|
+
export type PrismicRichTextProps<
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,
|
|
14
|
+
> = {
|
|
15
|
+
/**
|
|
16
|
+
* The Prismic Rich Text field to render.
|
|
17
|
+
*/
|
|
18
|
+
field: prismic.RichTextField | null | undefined;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The Link Resolver used to resolve links.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* If your app uses Route Resolvers when querying for your Prismic
|
|
25
|
+
* repository's content, a Link Resolver does not need to be provided.
|
|
26
|
+
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
27
|
+
*/
|
|
28
|
+
linkResolver?: LinkResolverFunction;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A map or function that maps a Rich Text block to a React component.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Prefer using a map serializer over the function serializer when possible.
|
|
35
|
+
* The map serializer is simpler to maintain.
|
|
36
|
+
* @example A map serializer.
|
|
37
|
+
*
|
|
38
|
+
* ```jsx
|
|
39
|
+
* {
|
|
40
|
+
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example A function serializer.
|
|
45
|
+
*
|
|
46
|
+
* ```jsx
|
|
47
|
+
* (type, node, content, children) => {
|
|
48
|
+
* switch (type) {
|
|
49
|
+
* case "heading1": {
|
|
50
|
+
* return <Heading>{children}</Heading>;
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
components?: JSXMapSerializer | JSXFunctionSerializer;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The React component rendered for links when the URL is internal.
|
|
60
|
+
*
|
|
61
|
+
* @defaultValue `<a>`
|
|
62
|
+
*/
|
|
63
|
+
internalLinkComponent?: React.ComponentType<LinkProps>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The React component rendered for links when the URL is external.
|
|
67
|
+
*
|
|
68
|
+
* @defaultValue `<a>`
|
|
69
|
+
*/
|
|
70
|
+
externalLinkComponent?: React.ComponentType<LinkProps>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The value to be rendered when the field is empty. If a fallback is not
|
|
74
|
+
* given, `null` will be rendered.
|
|
75
|
+
*/
|
|
76
|
+
fallback?: React.ReactNode;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type CreateDefaultSerializerArgs<
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,
|
|
82
|
+
> = {
|
|
83
|
+
linkResolver: LinkResolverFunction | undefined;
|
|
84
|
+
internalLinkComponent?: React.ComponentType<LinkProps>;
|
|
85
|
+
externalLinkComponent?: React.ComponentType<LinkProps>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const createDefaultSerializer = <
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
LinkResolverFunction extends prismic.LinkResolverFunction<any>,
|
|
91
|
+
>(
|
|
92
|
+
args: CreateDefaultSerializerArgs<LinkResolverFunction>,
|
|
93
|
+
): JSXFunctionSerializer =>
|
|
94
|
+
prismicR.wrapMapSerializer({
|
|
95
|
+
heading1: ({ children, key }) => <h1 key={key}>{children}</h1>,
|
|
96
|
+
heading2: ({ children, key }) => <h2 key={key}>{children}</h2>,
|
|
97
|
+
heading3: ({ children, key }) => <h3 key={key}>{children}</h3>,
|
|
98
|
+
heading4: ({ children, key }) => <h4 key={key}>{children}</h4>,
|
|
99
|
+
heading5: ({ children, key }) => <h5 key={key}>{children}</h5>,
|
|
100
|
+
heading6: ({ children, key }) => <h6 key={key}>{children}</h6>,
|
|
101
|
+
paragraph: ({ children, key }) => <p key={key}>{children}</p>,
|
|
102
|
+
preformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,
|
|
103
|
+
strong: ({ children, key }) => <strong key={key}>{children}</strong>,
|
|
104
|
+
em: ({ children, key }) => <em key={key}>{children}</em>,
|
|
105
|
+
listItem: ({ children, key }) => <li key={key}>{children}</li>,
|
|
106
|
+
oListItem: ({ children, key }) => <li key={key}>{children}</li>,
|
|
107
|
+
list: ({ children, key }) => <ul key={key}>{children}</ul>,
|
|
108
|
+
oList: ({ children, key }) => <ol key={key}>{children}</ol>,
|
|
109
|
+
image: ({ node, key }) => {
|
|
110
|
+
const img = (
|
|
111
|
+
<img
|
|
112
|
+
src={node.url}
|
|
113
|
+
alt={node.alt ?? undefined}
|
|
114
|
+
data-copyright={node.copyright ? node.copyright : undefined}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<p key={key} className="block-img">
|
|
120
|
+
{node.linkTo ? (
|
|
121
|
+
<PrismicLink
|
|
122
|
+
linkResolver={args.linkResolver}
|
|
123
|
+
internalComponent={args.internalLinkComponent}
|
|
124
|
+
externalComponent={args.externalLinkComponent}
|
|
125
|
+
field={node.linkTo}
|
|
126
|
+
>
|
|
127
|
+
{img}
|
|
128
|
+
</PrismicLink>
|
|
129
|
+
) : (
|
|
130
|
+
img
|
|
131
|
+
)}
|
|
132
|
+
</p>
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
embed: ({ node, key }) => (
|
|
136
|
+
<div
|
|
137
|
+
key={key}
|
|
138
|
+
data-oembed={node.oembed.embed_url}
|
|
139
|
+
data-oembed-type={node.oembed.type}
|
|
140
|
+
data-oembed-provider={node.oembed.provider_name}
|
|
141
|
+
dangerouslySetInnerHTML={{ __html: node.oembed.html ?? "" }}
|
|
142
|
+
/>
|
|
143
|
+
),
|
|
144
|
+
hyperlink: ({ node, children, key }) => (
|
|
145
|
+
<PrismicLink
|
|
146
|
+
key={key}
|
|
147
|
+
field={node.data}
|
|
148
|
+
linkResolver={args.linkResolver}
|
|
149
|
+
internalComponent={args.internalLinkComponent}
|
|
150
|
+
externalComponent={args.externalLinkComponent}
|
|
151
|
+
>
|
|
152
|
+
{children}
|
|
153
|
+
</PrismicLink>
|
|
154
|
+
),
|
|
155
|
+
label: ({ node, children, key }) => (
|
|
156
|
+
<span key={key} className={node.data.label}>
|
|
157
|
+
{children}
|
|
158
|
+
</span>
|
|
159
|
+
),
|
|
160
|
+
span: ({ text, key }) => {
|
|
161
|
+
const result: React.ReactNode[] = [];
|
|
162
|
+
|
|
163
|
+
let i = 0;
|
|
164
|
+
for (const line of text.split("\n")) {
|
|
165
|
+
if (i > 0) {
|
|
166
|
+
result.push(<br key={`${i}__break`} />);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
result.push(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);
|
|
170
|
+
|
|
171
|
+
i++;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return <React.Fragment key={key}>{result}</React.Fragment>;
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* React component that renders content from a Prismic Rich Text field. By
|
|
180
|
+
* default, HTML elements are rendered for each piece of content. A `heading1`
|
|
181
|
+
* block will render an `<h1>` HTML element, for example. Links will use
|
|
182
|
+
* `<PrismicLink>` by default which can be customized using the
|
|
183
|
+
* `internalLinkComponent` and `externalLinkComponent` props.
|
|
184
|
+
*
|
|
185
|
+
* To customize the components that are rendered, provide a map or function
|
|
186
|
+
* serializer to the `components` prop.
|
|
187
|
+
*
|
|
188
|
+
* @remarks
|
|
189
|
+
* This component returns a React fragment with no wrapping element around the
|
|
190
|
+
* content. If you need a wrapper, add a component around `<PrismicRichText>`.
|
|
191
|
+
* @example Rendering a Rich Text field using the default HTMl elements.
|
|
192
|
+
*
|
|
193
|
+
* ```jsx
|
|
194
|
+
* <PrismicRichText field={document.data.content} />;
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @example Rendering a Rich Text field using a custom set of React components.
|
|
198
|
+
*
|
|
199
|
+
* ```jsx
|
|
200
|
+
* <PrismicRichText
|
|
201
|
+
* field={document.data.content}
|
|
202
|
+
* components={{
|
|
203
|
+
* heading1: ({ children }) => <Heading>{children}</Heading>,
|
|
204
|
+
* }}
|
|
205
|
+
* />;
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @param props - Props for the component.
|
|
209
|
+
*
|
|
210
|
+
* @returns The Rich Text field's content as React components.
|
|
211
|
+
*
|
|
212
|
+
* @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}
|
|
213
|
+
* @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
214
|
+
*/
|
|
215
|
+
export function PrismicRichText<
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
+
LinkResolverFunction extends prismic.LinkResolverFunction<any>,
|
|
218
|
+
>({
|
|
219
|
+
linkResolver,
|
|
220
|
+
field,
|
|
221
|
+
fallback,
|
|
222
|
+
components,
|
|
223
|
+
externalLinkComponent,
|
|
224
|
+
internalLinkComponent,
|
|
225
|
+
}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {
|
|
226
|
+
return React.useMemo(() => {
|
|
227
|
+
if (prismic.isFilled.richText(field)) {
|
|
228
|
+
const serializer = prismicR.composeSerializers(
|
|
229
|
+
typeof components === "object"
|
|
230
|
+
? prismicR.wrapMapSerializer(components)
|
|
231
|
+
: components,
|
|
232
|
+
createDefaultSerializer({
|
|
233
|
+
linkResolver,
|
|
234
|
+
internalLinkComponent,
|
|
235
|
+
externalLinkComponent,
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
// The serializer is wrapped in a higher-order function
|
|
240
|
+
// that automatically applies a key to React Elements
|
|
241
|
+
// if one is not already given.
|
|
242
|
+
const serialized = prismicR.serialize<JSX.Element>(
|
|
243
|
+
field,
|
|
244
|
+
(type, node, text, children, key) => {
|
|
245
|
+
const result = serializer(type, node, text, children, key);
|
|
246
|
+
|
|
247
|
+
if (React.isValidElement(result) && result.key == null) {
|
|
248
|
+
return React.cloneElement(result, { key });
|
|
249
|
+
} else {
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
return <>{serialized}</>;
|
|
256
|
+
} else {
|
|
257
|
+
return fallback != null ? <>{fallback}</> : null;
|
|
258
|
+
}
|
|
259
|
+
}, [
|
|
260
|
+
field,
|
|
261
|
+
internalLinkComponent,
|
|
262
|
+
externalLinkComponent,
|
|
263
|
+
components,
|
|
264
|
+
linkResolver,
|
|
265
|
+
fallback,
|
|
266
|
+
]);
|
|
267
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { PrismicLink } from "./PrismicLink";
|
|
2
|
+
export { PrismicRichText } from "./PrismicRichText";
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
PrismicProvider,
|
|
6
|
+
useAllPrismicDocumentsByEveryTag,
|
|
7
|
+
useAllPrismicDocumentsByIDs,
|
|
8
|
+
useAllPrismicDocumentsBySomeTags,
|
|
9
|
+
useAllPrismicDocumentsByTag,
|
|
10
|
+
useAllPrismicDocumentsByType,
|
|
11
|
+
useAllPrismicDocumentsByUIDs,
|
|
12
|
+
useAllPrismicDocumentsDangerously,
|
|
13
|
+
useFirstPrismicDocument,
|
|
14
|
+
usePrismicClient,
|
|
15
|
+
usePrismicContext,
|
|
16
|
+
usePrismicDocumentByID,
|
|
17
|
+
usePrismicDocumentByUID,
|
|
18
|
+
usePrismicDocuments,
|
|
19
|
+
usePrismicDocumentsByEveryTag,
|
|
20
|
+
usePrismicDocumentsByIDs,
|
|
21
|
+
usePrismicDocumentsBySomeTags,
|
|
22
|
+
usePrismicDocumentsByTag,
|
|
23
|
+
usePrismicDocumentsByType,
|
|
24
|
+
usePrismicDocumentsByUIDs,
|
|
25
|
+
usePrismicPreviewResolver,
|
|
26
|
+
useSinglePrismicDocument,
|
|
27
|
+
} from "./unsupported";
|
|
28
|
+
|
|
29
|
+
// The following exports do not have RSC-specific implementations.
|
|
30
|
+
// They are aliases for the default package exports.
|
|
31
|
+
export {
|
|
32
|
+
Element,
|
|
33
|
+
PrismicImage,
|
|
34
|
+
PrismicText,
|
|
35
|
+
PrismicToolbar,
|
|
36
|
+
SliceZone,
|
|
37
|
+
TODOSliceComponent,
|
|
38
|
+
} from "..";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Exports in this file are unsupported in the react-server environment.
|
|
2
|
+
// All environments should export the same functions to maintian API compatability.
|
|
3
|
+
|
|
4
|
+
function buildErrorMessage(fnName: string) {
|
|
5
|
+
return `${fnName} is not supported in Server Components. Remove all uses of ${fnName} in Server Components.`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function buildHookErrorMessage(fnName: string) {
|
|
9
|
+
return `${fnName} is not supported in Server Components. Replace all uses of ${fnName} in Server Components with direct use of \`@prismicio/client\`.`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function PrismicProvider(): JSX.Element {
|
|
13
|
+
throw new Error(buildErrorMessage("<PrismicProvider>"));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function usePrismicContext() {
|
|
17
|
+
throw new Error(buildErrorMessage("usePrismicContext()"));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function usePrismicClient() {
|
|
21
|
+
throw new Error(buildHookErrorMessage("usePrismicClient()"));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function usePrismicPreviewResolver() {
|
|
25
|
+
throw new Error(buildHookErrorMessage("usePrismicPreviewResolver()"));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useAllPrismicDocumentsDangerously() {
|
|
29
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsDangerously()"));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useAllPrismicDocumentsByEveryTag() {
|
|
33
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByEveryTag()"));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function useAllPrismicDocumentsByIDs() {
|
|
37
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByIDs()"));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function useAllPrismicDocumentsBySomeTags() {
|
|
41
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsBySomeTags()"));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function useAllPrismicDocumentsByTag() {
|
|
45
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByTag()"));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useAllPrismicDocumentsByType() {
|
|
49
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByType()"));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function useAllPrismicDocumentsByUIDs() {
|
|
53
|
+
throw new Error(buildHookErrorMessage("useAllPrismicDocumentsByUIDs()"));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function useFirstPrismicDocument() {
|
|
57
|
+
throw new Error(buildHookErrorMessage("useFirstPrismicDocument()"));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function usePrismicDocumentByID() {
|
|
61
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentByID()"));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function usePrismicDocumentByUID() {
|
|
65
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentByUID()"));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function usePrismicDocuments() {
|
|
69
|
+
throw new Error(buildHookErrorMessage("usePrismicDocuments()"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function usePrismicDocumentsByEveryTag() {
|
|
73
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsByEveryTag()"));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function usePrismicDocumentsByIDs() {
|
|
77
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsByIDs()"));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function usePrismicDocumentsBySomeTags() {
|
|
81
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsBySomeTags()"));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function usePrismicDocumentsByTag() {
|
|
85
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsByTag()"));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function usePrismicDocumentsByType() {
|
|
89
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsByType()"));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function usePrismicDocumentsByUIDs() {
|
|
93
|
+
throw new Error(buildHookErrorMessage("usePrismicDocumentsByUIDs()"));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function useSinglePrismicDocument() {
|
|
97
|
+
throw new Error(buildHookErrorMessage("useSinglePrismicDocument()"));
|
|
98
|
+
}
|
package/dist/lib/pascalCase.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const pascalCase = (input) => {
|
|
4
|
-
const camelCased = input.replace(/(?:-|_)(\w)/g, (_, c) => {
|
|
5
|
-
return c ? c.toUpperCase() : "";
|
|
6
|
-
});
|
|
7
|
-
return camelCased[0].toUpperCase() + camelCased.slice(1);
|
|
8
|
-
};
|
|
9
|
-
exports.pascalCase = pascalCase;
|
|
10
|
-
//# sourceMappingURL=pascalCase.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pascalCase.cjs","sources":["../../../src/lib/pascalCase.ts"],"sourcesContent":["// `PascalCase`-related types have been taken from the `type-fest` package.\n//\n// They are copied here to mininize dependencies in this project.\n//\n// See: https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/camel-case.d.ts\n\ntype WordSeparators = \"-\" | \"_\" | \" \";\n\ntype Split<\n\tS extends string,\n\tDelimiter extends string,\n> = S extends `${infer Head}${Delimiter}${infer Tail}`\n\t? [Head, ...Split<Tail, Delimiter>]\n\t: S extends Delimiter\n\t? []\n\t: [S];\n\ntype InnerCamelCaseStringArray<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tParts extends readonly any[],\n\tPreviousPart,\n> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts]\n\t? FirstPart extends undefined\n\t\t? \"\"\n\t\t: FirstPart extends \"\"\n\t\t? InnerCamelCaseStringArray<RemainingParts, PreviousPart>\n\t\t: `${PreviousPart extends \"\"\n\t\t\t\t? FirstPart\n\t\t\t\t: Capitalize<FirstPart>}${InnerCamelCaseStringArray<\n\t\t\t\tRemainingParts,\n\t\t\t\tFirstPart\n\t\t >}`\n\t: \"\";\n\ntype CamelCaseStringArray<Parts extends readonly string[]> = Parts extends [\n\t`${infer FirstPart}`,\n\t...infer RemainingParts,\n]\n\t? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<\n\t\t\tRemainingParts,\n\t\t\tFirstPart\n\t >}`>\n\t: never;\n\ntype CamelCase<K> = K extends string\n\t? CamelCaseStringArray<\n\t\t\tSplit<K extends Uppercase<K> ? Lowercase<K> : K, WordSeparators>\n\t >\n\t: K;\n\n/**\n * Converts a string literal to Pascal case.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/pascal-case.d.ts\n */\nexport type PascalCase<Value> = CamelCase<Value> extends string\n\t? Capitalize<CamelCase<Value>>\n\t: CamelCase<Value>;\n\n/**\n * Converts a string to Pascal case.\n *\n * @param input - The string to convert.\n *\n * @returns `input` as Pascal case.\n */\nexport const pascalCase = <Input extends string>(\n\tinput: Input,\n): PascalCase<Input> => {\n\tconst camelCased = input.replace(/(?:-|_)(\\w)/g, (_, c) => {\n\t\treturn c ? c.toUpperCase() : \"\";\n\t});\n\n\treturn (camelCased[0].toUpperCase() +\n\t\tcamelCased.slice(1)) as PascalCase<Input>;\n};\n"],"names":[],"mappings":";;AAqEa,MAAA,aAAa,CACzB,UACsB;AACtB,QAAM,aAAa,MAAM,QAAQ,gBAAgB,CAAC,GAAG,MAAK;AAClD,WAAA,IAAI,EAAE,YAAA,IAAgB;AAAA,EAAA,CAC7B;AAED,SAAQ,WAAW,GAAG,YACrB,IAAA,WAAW,MAAM,CAAC;AACpB;;"}
|
package/dist/lib/pascalCase.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const pascalCase = (input) => {
|
|
2
|
-
const camelCased = input.replace(/(?:-|_)(\w)/g, (_, c) => {
|
|
3
|
-
return c ? c.toUpperCase() : "";
|
|
4
|
-
});
|
|
5
|
-
return camelCased[0].toUpperCase() + camelCased.slice(1);
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
pascalCase
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=pascalCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pascalCase.js","sources":["../../../src/lib/pascalCase.ts"],"sourcesContent":["// `PascalCase`-related types have been taken from the `type-fest` package.\n//\n// They are copied here to mininize dependencies in this project.\n//\n// See: https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/camel-case.d.ts\n\ntype WordSeparators = \"-\" | \"_\" | \" \";\n\ntype Split<\n\tS extends string,\n\tDelimiter extends string,\n> = S extends `${infer Head}${Delimiter}${infer Tail}`\n\t? [Head, ...Split<Tail, Delimiter>]\n\t: S extends Delimiter\n\t? []\n\t: [S];\n\ntype InnerCamelCaseStringArray<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tParts extends readonly any[],\n\tPreviousPart,\n> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts]\n\t? FirstPart extends undefined\n\t\t? \"\"\n\t\t: FirstPart extends \"\"\n\t\t? InnerCamelCaseStringArray<RemainingParts, PreviousPart>\n\t\t: `${PreviousPart extends \"\"\n\t\t\t\t? FirstPart\n\t\t\t\t: Capitalize<FirstPart>}${InnerCamelCaseStringArray<\n\t\t\t\tRemainingParts,\n\t\t\t\tFirstPart\n\t\t >}`\n\t: \"\";\n\ntype CamelCaseStringArray<Parts extends readonly string[]> = Parts extends [\n\t`${infer FirstPart}`,\n\t...infer RemainingParts,\n]\n\t? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<\n\t\t\tRemainingParts,\n\t\t\tFirstPart\n\t >}`>\n\t: never;\n\ntype CamelCase<K> = K extends string\n\t? CamelCaseStringArray<\n\t\t\tSplit<K extends Uppercase<K> ? Lowercase<K> : K, WordSeparators>\n\t >\n\t: K;\n\n/**\n * Converts a string literal to Pascal case.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/pascal-case.d.ts\n */\nexport type PascalCase<Value> = CamelCase<Value> extends string\n\t? Capitalize<CamelCase<Value>>\n\t: CamelCase<Value>;\n\n/**\n * Converts a string to Pascal case.\n *\n * @param input - The string to convert.\n *\n * @returns `input` as Pascal case.\n */\nexport const pascalCase = <Input extends string>(\n\tinput: Input,\n): PascalCase<Input> => {\n\tconst camelCased = input.replace(/(?:-|_)(\\w)/g, (_, c) => {\n\t\treturn c ? c.toUpperCase() : \"\";\n\t});\n\n\treturn (camelCased[0].toUpperCase() +\n\t\tcamelCased.slice(1)) as PascalCase<Input>;\n};\n"],"names":[],"mappings":"AAqEa,MAAA,aAAa,CACzB,UACsB;AACtB,QAAM,aAAa,MAAM,QAAQ,gBAAgB,CAAC,GAAG,MAAK;AAClD,WAAA,IAAI,EAAE,YAAA,IAAgB;AAAA,EAAA,CAC7B;AAED,SAAQ,WAAW,GAAG,YACrB,IAAA,WAAW,MAAM,CAAC;AACpB;"}
|