@prismicio/react 2.9.2 → 3.0.0-alpha.1
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/README.md +10 -11
- package/dist/PrismicImage.d.ts +18 -633
- package/dist/PrismicImage.js +32 -33
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicLink.d.ts +77 -6
- package/dist/PrismicLink.js +42 -7
- package/dist/PrismicLink.js.map +1 -1
- package/dist/PrismicRichText.d.ts +117 -4
- package/dist/PrismicRichText.js +74 -8
- package/dist/PrismicRichText.js.map +1 -1
- package/dist/PrismicText.d.ts +9 -14
- package/dist/PrismicText.js +13 -14
- package/dist/PrismicText.js.map +1 -1
- package/dist/PrismicToolbar.d.ts +3 -12
- package/dist/PrismicToolbar.js +7 -9
- package/dist/PrismicToolbar.js.map +1 -1
- package/dist/SliceZone.d.ts +16 -70
- package/dist/SliceZone.js +17 -38
- package/dist/SliceZone.js.map +1 -1
- package/dist/index.d.ts +13 -21
- package/dist/index.js +2 -29
- package/dist/index.js.map +1 -1
- package/dist/lib/devMsg.d.ts +2 -2
- package/dist/lib/devMsg.js +2 -2
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +54 -71
- package/src/PrismicImage.tsx +80 -65
- package/src/PrismicLink.tsx +196 -26
- package/src/PrismicRichText.tsx +333 -32
- package/src/PrismicText.tsx +25 -31
- package/src/PrismicToolbar.tsx +9 -29
- package/src/SliceZone.tsx +59 -151
- package/src/index.ts +17 -53
- package/src/lib/devMsg.ts +3 -3
- package/dist/PrismicImage.cjs +0 -68
- package/dist/PrismicImage.cjs.map +0 -1
- package/dist/PrismicLink.cjs +0 -29
- package/dist/PrismicLink.cjs.map +0 -1
- package/dist/PrismicProvider.cjs +0 -41
- package/dist/PrismicProvider.cjs.map +0 -1
- package/dist/PrismicProvider.d.ts +0 -83
- package/dist/PrismicProvider.js +0 -24
- package/dist/PrismicProvider.js.map +0 -1
- package/dist/PrismicRichText.cjs +0 -30
- package/dist/PrismicRichText.cjs.map +0 -1
- package/dist/PrismicText.cjs +0 -44
- package/dist/PrismicText.cjs.map +0 -1
- package/dist/PrismicToolbar.cjs +0 -43
- package/dist/PrismicToolbar.cjs.map +0 -1
- package/dist/SliceZone.cjs +0 -53
- package/dist/SliceZone.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +0 -16
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js +0 -13
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs +0 -22
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js +0 -22
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs +0 -46
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js +0 -46
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +0 -47
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +0 -28
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs +0 -21
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js +0 -21
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +0 -27
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +0 -24
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +0 -24
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js +0 -7
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +0 -9
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs +0 -13
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js +0 -13
- package/dist/_node_modules/@prismicio/client/dist/richtext/asText.js.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +0 -1
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +0 -10
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildPixelDensitySrcSet.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.cjs +0 -29
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.js +0 -29
- package/dist/_node_modules/imgix-url-builder/dist/buildURL.js.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.cjs.map +0 -1
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js +0 -10
- package/dist/_node_modules/imgix-url-builder/dist/buildWidthSrcSet.js.map +0 -1
- package/dist/clientHooks.cjs +0 -40
- package/dist/clientHooks.cjs.map +0 -1
- package/dist/clientHooks.d.ts +0 -321
- package/dist/clientHooks.js +0 -40
- package/dist/clientHooks.js.map +0 -1
- package/dist/index.cjs +0 -48
- package/dist/index.cjs.map +0 -1
- package/dist/lib/devMsg.cjs +0 -8
- package/dist/lib/devMsg.cjs.map +0 -1
- package/dist/lib/isInternalURL.cjs +0 -9
- package/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isInternalURL.js +0 -9
- package/dist/lib/isInternalURL.js.map +0 -1
- package/dist/lib/pascalCase.cjs +0 -10
- package/dist/lib/pascalCase.cjs.map +0 -1
- package/dist/lib/pascalCase.d.ts +0 -26
- package/dist/lib/pascalCase.js +0 -10
- package/dist/lib/pascalCase.js.map +0 -1
- package/dist/package.json.cjs +0 -5
- package/dist/package.json.cjs.map +0 -1
- package/dist/react-server/PrismicLink.cjs +0 -59
- package/dist/react-server/PrismicLink.cjs.map +0 -1
- package/dist/react-server/PrismicLink.d.ts +0 -77
- package/dist/react-server/PrismicLink.js +0 -42
- package/dist/react-server/PrismicLink.js.map +0 -1
- package/dist/react-server/PrismicRichText.cjs +0 -102
- package/dist/react-server/PrismicRichText.cjs.map +0 -1
- package/dist/react-server/PrismicRichText.d.ts +0 -104
- package/dist/react-server/PrismicRichText.js +0 -84
- package/dist/react-server/PrismicRichText.js.map +0 -1
- package/dist/react-server/index.d.ts +0 -4
- package/dist/react-server/unsupported.cjs +0 -97
- package/dist/react-server/unsupported.cjs.map +0 -1
- package/dist/react-server/unsupported.d.ts +0 -22
- package/dist/react-server/unsupported.js +0 -97
- package/dist/react-server/unsupported.js.map +0 -1
- package/dist/react-server.cjs +0 -44
- package/dist/react-server.cjs.map +0 -1
- package/dist/react-server.js +0 -41
- package/dist/react-server.js.map +0 -1
- package/dist/types.d.ts +0 -19
- package/dist/usePrismicClient.cjs +0 -13
- package/dist/usePrismicClient.cjs.map +0 -1
- package/dist/usePrismicClient.d.ts +0 -11
- package/dist/usePrismicClient.js +0 -13
- package/dist/usePrismicClient.js.map +0 -1
- package/dist/usePrismicContext.cjs +0 -26
- package/dist/usePrismicContext.cjs.map +0 -1
- package/dist/usePrismicContext.d.ts +0 -8
- package/dist/usePrismicContext.js +0 -9
- package/dist/usePrismicContext.js.map +0 -1
- package/dist/usePrismicPreviewResolver.cjs +0 -44
- package/dist/usePrismicPreviewResolver.cjs.map +0 -1
- package/dist/usePrismicPreviewResolver.d.ts +0 -45
- package/dist/usePrismicPreviewResolver.js +0 -27
- package/dist/usePrismicPreviewResolver.js.map +0 -1
- package/dist/useStatefulPrismicClientMethod.cjs +0 -91
- package/dist/useStatefulPrismicClientMethod.cjs.map +0 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +0 -44
- package/dist/useStatefulPrismicClientMethod.js +0 -74
- package/dist/useStatefulPrismicClientMethod.js.map +0 -1
- package/src/PrismicProvider.tsx +0 -132
- package/src/clientHooks.ts +0 -472
- package/src/lib/isInternalURL.ts +0 -14
- package/src/lib/pascalCase.ts +0 -79
- package/src/react-server/PrismicLink.tsx +0 -197
- package/src/react-server/PrismicRichText.tsx +0 -326
- package/src/react-server/index.ts +0 -38
- package/src/react-server/unsupported.ts +0 -184
- package/src/types.ts +0 -24
- package/src/usePrismicClient.ts +0 -30
- package/src/usePrismicContext.ts +0 -13
- package/src/usePrismicPreviewResolver.ts +0 -93
- package/src/useStatefulPrismicClientMethod.ts +0 -196
package/src/SliceZone.tsx
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { ComponentType } from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { pascalCase, PascalCase } from "./lib/pascalCase";
|
|
1
|
+
import type { ComponentType, FC } from "react";
|
|
2
|
+
import type { Slice } from "@prismicio/client";
|
|
3
|
+
import { DEV } from "esm-env";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Returns the type of a `SliceLike` type.
|
|
8
7
|
*
|
|
9
8
|
* @typeParam Slice - The Slice from which the type will be extracted.
|
|
10
9
|
*/
|
|
11
|
-
type ExtractSliceType<TSlice extends SliceLike> = TSlice extends
|
|
10
|
+
type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice
|
|
12
11
|
? TSlice["slice_type"]
|
|
13
12
|
: TSlice extends SliceLikeGraphQL
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
? TSlice["type"]
|
|
14
|
+
: never;
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
@@ -21,7 +20,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends prismic.Slice
|
|
|
21
20
|
* @typeParam SliceType - Type name of the Slice.
|
|
22
21
|
*/
|
|
23
22
|
export type SliceLikeRestV2<TSliceType extends string = string> = Pick<
|
|
24
|
-
|
|
23
|
+
Slice<TSliceType>,
|
|
25
24
|
"id" | "slice_type"
|
|
26
25
|
>;
|
|
27
26
|
|
|
@@ -32,7 +31,7 @@ export type SliceLikeRestV2<TSliceType extends string = string> = Pick<
|
|
|
32
31
|
* @typeParam SliceType - Type name of the Slice.
|
|
33
32
|
*/
|
|
34
33
|
export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
35
|
-
type:
|
|
34
|
+
type: Slice<TSliceType>["slice_type"];
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -78,23 +77,16 @@ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> =
|
|
|
78
77
|
* available to all Slice components.
|
|
79
78
|
*/
|
|
80
79
|
export type SliceComponentProps<
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
80
|
TSlice extends SliceLike = SliceLike,
|
|
83
81
|
TContext = unknown,
|
|
84
82
|
> = {
|
|
85
|
-
/**
|
|
86
|
-
* Slice data for this component.
|
|
87
|
-
*/
|
|
83
|
+
/** Slice data for this component. */
|
|
88
84
|
slice: TSlice;
|
|
89
85
|
|
|
90
|
-
/**
|
|
91
|
-
* The index of the Slice in the Slice Zone.
|
|
92
|
-
*/
|
|
86
|
+
/** The index of the Slice in the Slice Zone. */
|
|
93
87
|
index: number;
|
|
94
88
|
|
|
95
|
-
/**
|
|
96
|
-
* All Slices from the Slice Zone to which the Slice belongs.
|
|
97
|
-
*/
|
|
89
|
+
/** All Slices from the Slice Zone to which the Slice belongs. */
|
|
98
90
|
// TODO: We have to keep this list of Slices general due to circular
|
|
99
91
|
// reference limtiations. If we had another generic to determine the full
|
|
100
92
|
// union of Slice types, it would include TSlice. This causes TypeScript to
|
|
@@ -120,7 +112,7 @@ export type SliceComponentType<
|
|
|
120
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
113
|
TSlice extends SliceLike = any,
|
|
122
114
|
TContext = unknown,
|
|
123
|
-
> =
|
|
115
|
+
> = ComponentType<SliceComponentProps<TSlice, TContext>>;
|
|
124
116
|
|
|
125
117
|
/**
|
|
126
118
|
* A record of Slice types mapped to a React component. The component will be
|
|
@@ -128,6 +120,7 @@ export type SliceComponentType<
|
|
|
128
120
|
*
|
|
129
121
|
* @deprecated This type is no longer used by `@prismicio/react`. Prefer using
|
|
130
122
|
* `Record<string, SliceComponentType<any>>` instead.
|
|
123
|
+
*
|
|
131
124
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
132
125
|
* @typeParam TContext - Arbitrary data made available to all Slice components.
|
|
133
126
|
*/
|
|
@@ -153,49 +146,6 @@ export type SliceZoneComponents<
|
|
|
153
146
|
>;
|
|
154
147
|
};
|
|
155
148
|
|
|
156
|
-
/**
|
|
157
|
-
* Arguments for a `<SliceZone>` `resolver` function.
|
|
158
|
-
*/
|
|
159
|
-
type SliceZoneResolverArgs<
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
-
TSlice extends SliceLike = any,
|
|
162
|
-
> = {
|
|
163
|
-
/**
|
|
164
|
-
* The Slice to resolve to a React component.
|
|
165
|
-
*/
|
|
166
|
-
slice: TSlice;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The name of the Slice.
|
|
170
|
-
*/
|
|
171
|
-
sliceName: PascalCase<ExtractSliceType<TSlice>>;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* The index of the Slice in the Slice Zone.
|
|
175
|
-
*/
|
|
176
|
-
i: number;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* A function that determines the rendered React component for each Slice in the
|
|
181
|
-
* Slice Zone. If a nullish value is returned, the component will fallback to
|
|
182
|
-
* the `components` or `defaultComponent` props to determine the rendered
|
|
183
|
-
* component.
|
|
184
|
-
*
|
|
185
|
-
* @deprecated Use the `components` prop instead.
|
|
186
|
-
*
|
|
187
|
-
* @param args - Arguments for the resolver function.
|
|
188
|
-
*
|
|
189
|
-
* @returns The React component to render for a Slice.
|
|
190
|
-
*/
|
|
191
|
-
export type SliceZoneResolver<
|
|
192
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
193
|
-
TSlice extends SliceLike = any,
|
|
194
|
-
> = (
|
|
195
|
-
args: SliceZoneResolverArgs<TSlice>,
|
|
196
|
-
) => // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
-
ComponentType<any> | undefined | null;
|
|
198
|
-
|
|
199
149
|
/**
|
|
200
150
|
* React props for the `<SliceZone>` component.
|
|
201
151
|
*
|
|
@@ -203,30 +153,13 @@ ComponentType<any> | undefined | null;
|
|
|
203
153
|
* @typeParam TContext - Arbitrary data made available to all Slice components.
|
|
204
154
|
*/
|
|
205
155
|
export type SliceZoneProps<TContext = unknown> = {
|
|
206
|
-
/**
|
|
207
|
-
* List of Slice data from the Slice Zone.
|
|
208
|
-
*/
|
|
156
|
+
/** List of Slice data from the Slice Zone. */
|
|
209
157
|
slices?: SliceZoneLike;
|
|
210
158
|
|
|
211
|
-
/**
|
|
212
|
-
* A record mapping Slice types to React components.
|
|
213
|
-
*/
|
|
159
|
+
/** A record mapping Slice types to React components. */
|
|
214
160
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
161
|
components?: Record<string, ComponentType<any>>;
|
|
216
162
|
|
|
217
|
-
/**
|
|
218
|
-
* A function that determines the rendered React component for each Slice in
|
|
219
|
-
* the Slice Zone.
|
|
220
|
-
*
|
|
221
|
-
* @deprecated Use the `components` prop instead.
|
|
222
|
-
*
|
|
223
|
-
* @param args - Arguments for the resolver function.
|
|
224
|
-
*
|
|
225
|
-
* @returns The React component to render for a Slice.
|
|
226
|
-
*/
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
-
resolver?: SliceZoneResolver<any>;
|
|
229
|
-
|
|
230
163
|
/**
|
|
231
164
|
* The React component rendered if a component mapping from the `components`
|
|
232
165
|
* prop cannot be found.
|
|
@@ -234,9 +167,7 @@ export type SliceZoneProps<TContext = unknown> = {
|
|
|
234
167
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
168
|
defaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;
|
|
236
169
|
|
|
237
|
-
/**
|
|
238
|
-
* Arbitrary data made available to all Slice components.
|
|
239
|
-
*/
|
|
170
|
+
/** Arbitrary data made available to all Slice components. */
|
|
240
171
|
context?: TContext;
|
|
241
172
|
};
|
|
242
173
|
|
|
@@ -251,27 +182,24 @@ export const TODOSliceComponent = <TSlice extends SliceLike>({
|
|
|
251
182
|
slice,
|
|
252
183
|
}: {
|
|
253
184
|
slice: TSlice;
|
|
254
|
-
})
|
|
255
|
-
if (
|
|
256
|
-
typeof process !== "undefined" &&
|
|
257
|
-
process.env.NODE_ENV === "development"
|
|
258
|
-
) {
|
|
259
|
-
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
260
|
-
|
|
261
|
-
console.warn(
|
|
262
|
-
`[SliceZone] Could not find a component for Slice type "${type}"`,
|
|
263
|
-
slice,
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
return (
|
|
267
|
-
<section data-slice-zone-todo-component="" data-slice-type={type}>
|
|
268
|
-
Could not find a component for Slice type “{type}
|
|
269
|
-
”
|
|
270
|
-
</section>
|
|
271
|
-
);
|
|
272
|
-
} else {
|
|
185
|
+
}) => {
|
|
186
|
+
if (!DEV) {
|
|
273
187
|
return null;
|
|
274
188
|
}
|
|
189
|
+
|
|
190
|
+
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
191
|
+
|
|
192
|
+
console.warn(
|
|
193
|
+
`[SliceZone] Could not find a component for Slice type "${type}"`,
|
|
194
|
+
slice,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<section data-slice-zone-todo-component="" data-slice-type={type}>
|
|
199
|
+
Could not find a component for Slice type “{type}
|
|
200
|
+
”
|
|
201
|
+
</section>
|
|
202
|
+
);
|
|
275
203
|
};
|
|
276
204
|
|
|
277
205
|
/**
|
|
@@ -289,65 +217,45 @@ export const TODOSliceComponent = <TSlice extends SliceLike>({
|
|
|
289
217
|
*
|
|
290
218
|
* @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}
|
|
291
219
|
*/
|
|
292
|
-
export
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
// TODO: Remove in v3 when the `resolver` prop is removed.
|
|
300
|
-
if (process.env.NODE_ENV === "development") {
|
|
301
|
-
if (resolver) {
|
|
302
|
-
console.warn(
|
|
303
|
-
"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.",
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
220
|
+
export const SliceZone: FC<SliceZoneProps> = (props) => {
|
|
221
|
+
const {
|
|
222
|
+
slices = [],
|
|
223
|
+
components = {},
|
|
224
|
+
defaultComponent,
|
|
225
|
+
context = {},
|
|
226
|
+
} = props;
|
|
307
227
|
|
|
308
228
|
const renderedSlices = slices.map((slice, index) => {
|
|
309
229
|
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
310
230
|
|
|
311
|
-
let Comp = components[type as keyof typeof components] || defaultComponent;
|
|
312
|
-
|
|
313
|
-
// TODO: Remove `resolver` in v3 in favor of `components`.
|
|
314
|
-
if (resolver) {
|
|
315
|
-
const resolvedComp = resolver({
|
|
316
|
-
slice,
|
|
317
|
-
sliceName: pascalCase(type),
|
|
318
|
-
i: index,
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
if (resolvedComp) {
|
|
322
|
-
Comp = resolvedComp as typeof Comp;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
231
|
const key =
|
|
327
232
|
"id" in slice && slice.id
|
|
328
233
|
? slice.id
|
|
329
234
|
: `${index}-${JSON.stringify(slice)}`;
|
|
330
235
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const { __mapped, ...mappedProps } = slice;
|
|
236
|
+
const Comp =
|
|
237
|
+
components[type as keyof typeof components] || defaultComponent;
|
|
334
238
|
|
|
335
|
-
|
|
336
|
-
} else {
|
|
337
|
-
return (
|
|
338
|
-
<Comp
|
|
339
|
-
key={key}
|
|
340
|
-
slice={slice}
|
|
341
|
-
index={index}
|
|
342
|
-
slices={slices}
|
|
343
|
-
context={context}
|
|
344
|
-
/>
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
239
|
+
if (!Comp) {
|
|
348
240
|
return <TODOSliceComponent key={key} slice={slice} />;
|
|
349
241
|
}
|
|
242
|
+
|
|
243
|
+
if (slice.__mapped) {
|
|
244
|
+
const { __mapped, ...mappedProps } = slice;
|
|
245
|
+
|
|
246
|
+
return <Comp key={key} {...mappedProps} />;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<Comp
|
|
251
|
+
key={key}
|
|
252
|
+
slice={slice}
|
|
253
|
+
index={index}
|
|
254
|
+
slices={slices}
|
|
255
|
+
context={context}
|
|
256
|
+
/>
|
|
257
|
+
);
|
|
350
258
|
});
|
|
351
259
|
|
|
352
260
|
return <>{renderedSlices}</>;
|
|
353
|
-
}
|
|
261
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
PrismicProviderProps,
|
|
4
|
-
PrismicContextValue,
|
|
5
|
-
} from "./PrismicProvider";
|
|
6
|
-
|
|
7
|
-
export { usePrismicContext } from "./usePrismicContext";
|
|
8
|
-
|
|
9
|
-
export { usePrismicClient } from "./usePrismicClient";
|
|
10
|
-
|
|
11
|
-
export { PrismicLink } from "./PrismicLink";
|
|
12
|
-
export type { PrismicLinkProps, LinkProps } from "./PrismicLink";
|
|
1
|
+
export { PrismicLink } from "./PrismicLink.js";
|
|
2
|
+
export type { PrismicLinkProps, LinkProps } from "./PrismicLink.js";
|
|
13
3
|
|
|
14
|
-
export { PrismicText } from "./PrismicText";
|
|
15
|
-
export type { PrismicTextProps } from "./PrismicText";
|
|
4
|
+
export { PrismicText } from "./PrismicText.js";
|
|
5
|
+
export type { PrismicTextProps } from "./PrismicText.js";
|
|
16
6
|
|
|
17
|
-
export { PrismicRichText } from "./PrismicRichText";
|
|
18
|
-
export type {
|
|
7
|
+
export { PrismicRichText } from "./PrismicRichText.js";
|
|
8
|
+
export type {
|
|
9
|
+
PrismicRichTextProps,
|
|
10
|
+
JSXMapSerializer,
|
|
11
|
+
JSXFunctionSerializer,
|
|
12
|
+
} from "./PrismicRichText.js";
|
|
19
13
|
|
|
20
|
-
export { Element } from "@prismicio/richtext";
|
|
14
|
+
export { Element } from "@prismicio/client/richtext";
|
|
21
15
|
|
|
22
|
-
export { PrismicImage } from "./PrismicImage";
|
|
23
|
-
export type { PrismicImageProps } from "./PrismicImage";
|
|
16
|
+
export { PrismicImage } from "./PrismicImage.js";
|
|
17
|
+
export type { PrismicImageProps } from "./PrismicImage.js";
|
|
24
18
|
|
|
25
|
-
export { SliceZone, TODOSliceComponent } from "./SliceZone";
|
|
19
|
+
export { SliceZone, TODOSliceComponent } from "./SliceZone.js";
|
|
26
20
|
export type {
|
|
27
21
|
SliceComponentProps,
|
|
28
22
|
SliceComponentType,
|
|
@@ -32,37 +26,7 @@ export type {
|
|
|
32
26
|
SliceZoneComponents,
|
|
33
27
|
SliceZoneLike,
|
|
34
28
|
SliceZoneProps,
|
|
35
|
-
} from "./SliceZone";
|
|
29
|
+
} from "./SliceZone.js";
|
|
36
30
|
|
|
37
|
-
export { PrismicToolbar } from "./PrismicToolbar";
|
|
38
|
-
export type { PrismicToolbarProps } from "./PrismicToolbar";
|
|
39
|
-
|
|
40
|
-
export { usePrismicPreviewResolver } from "./usePrismicPreviewResolver";
|
|
41
|
-
export type { UsePrismicPreviewResolverArgs } from "./usePrismicPreviewResolver";
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
useAllPrismicDocumentsDangerously,
|
|
45
|
-
useAllPrismicDocumentsByEveryTag,
|
|
46
|
-
useAllPrismicDocumentsByIDs,
|
|
47
|
-
useAllPrismicDocumentsBySomeTags,
|
|
48
|
-
useAllPrismicDocumentsByTag,
|
|
49
|
-
useAllPrismicDocumentsByType,
|
|
50
|
-
useAllPrismicDocumentsByUIDs,
|
|
51
|
-
useFirstPrismicDocument,
|
|
52
|
-
usePrismicDocumentByID,
|
|
53
|
-
usePrismicDocumentByUID,
|
|
54
|
-
usePrismicDocuments,
|
|
55
|
-
usePrismicDocumentsByEveryTag,
|
|
56
|
-
usePrismicDocumentsByIDs,
|
|
57
|
-
usePrismicDocumentsBySomeTags,
|
|
58
|
-
usePrismicDocumentsByTag,
|
|
59
|
-
usePrismicDocumentsByType,
|
|
60
|
-
usePrismicDocumentsByUIDs,
|
|
61
|
-
useSinglePrismicDocument,
|
|
62
|
-
} from "./clientHooks";
|
|
63
|
-
|
|
64
|
-
export type {
|
|
65
|
-
JSXMapSerializer,
|
|
66
|
-
JSXFunctionSerializer,
|
|
67
|
-
PrismicClientHookState,
|
|
68
|
-
} from "./types";
|
|
31
|
+
export { PrismicToolbar } from "./PrismicToolbar.js";
|
|
32
|
+
export type { PrismicToolbarProps } from "./PrismicToolbar.js";
|
package/src/lib/devMsg.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { version } from "../../package.json";
|
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* devMsg("missing-param");
|
|
10
|
-
* // => "https://prismic.dev/msg/react/v1.2.3/missing-param
|
|
10
|
+
* // => "https://prismic.dev/msg/react/v1.2.3/missing-param"
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* @param slug - Slug for the message. This corresponds to a Markdown file in
|
|
@@ -15,6 +15,6 @@ import { version } from "../../package.json";
|
|
|
15
15
|
*
|
|
16
16
|
* @returns The `prismic.dev/msg` URL for the given slug.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export function devMsg(slug: string) {
|
|
19
19
|
return `https://prismic.dev/msg/react/v${version}/${slug}`;
|
|
20
|
-
}
|
|
20
|
+
}
|
package/dist/PrismicImage.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const devMsg = require("./lib/devMsg.cjs");
|
|
6
|
-
const isFilled = require('./_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
|
|
7
|
-
const asImageWidthSrcSet = require('./_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs');
|
|
8
|
-
const asImagePixelDensitySrcSet = require('./_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs');
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
|
-
if (e) {
|
|
12
|
-
for (const k in e) {
|
|
13
|
-
if (k !== "default") {
|
|
14
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: () => e[k]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
-
const PrismicImage = React__namespace.forwardRef(function PrismicImage2({ field, alt, fallbackAlt, imgixParams = {}, widths, pixelDensities, ...restProps }, ref) {
|
|
27
|
-
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
28
|
-
if (typeof alt === "string" && alt !== "") {
|
|
29
|
-
console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
30
|
-
}
|
|
31
|
-
if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
|
|
32
|
-
console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
33
|
-
}
|
|
34
|
-
if (widths && pixelDensities) {
|
|
35
|
-
console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (isFilled.imageThumbnail(field)) {
|
|
39
|
-
const resolvedImgixParams = imgixParams;
|
|
40
|
-
for (const x in imgixParams) {
|
|
41
|
-
if (resolvedImgixParams[x] === null) {
|
|
42
|
-
resolvedImgixParams[x] = void 0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
let src;
|
|
46
|
-
let srcSet;
|
|
47
|
-
if (widths || !pixelDensities) {
|
|
48
|
-
const res = asImageWidthSrcSet.asImageWidthSrcSet(field, {
|
|
49
|
-
...resolvedImgixParams,
|
|
50
|
-
widths: widths === "defaults" ? void 0 : widths
|
|
51
|
-
});
|
|
52
|
-
src = res.src;
|
|
53
|
-
srcSet = res.srcset;
|
|
54
|
-
} else if (pixelDensities) {
|
|
55
|
-
const res = asImagePixelDensitySrcSet.asImagePixelDensitySrcSet(field, {
|
|
56
|
-
...resolvedImgixParams,
|
|
57
|
-
pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
|
|
58
|
-
});
|
|
59
|
-
src = res.src;
|
|
60
|
-
srcSet = res.srcset;
|
|
61
|
-
}
|
|
62
|
-
return /* @__PURE__ */ jsxRuntime.jsx("img", { ref, src, srcSet, alt: alt ?? (field.alt || fallbackAlt), ...restProps });
|
|
63
|
-
} else {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
exports.PrismicImage = PrismicImage;
|
|
68
|
-
//# sourceMappingURL=PrismicImage.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.cjs","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport { ImgixURLParams } from \"imgix-url-builder\";\n\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\t{\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams = {},\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t}: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): React.JSX.Element | null {\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env.NODE_ENV === \"development\"\n\t) {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tconst resolvedImgixParams = imgixParams;\n\t\tfor (const x in imgixParams) {\n\t\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t\t}\n\t\t}\n\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["React","PrismicImage","devMsg","prismic.isFilled.imageThumbnail","prismic.asImageWidthSrcSet","prismic.asImagePixelDensitySrcSet","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyGO,MAAM,eAAeA,iBAAM,WAAW,SAASC,cACrD,EACC,OACA,KACA,aACA,cAAc,CACd,GAAA,QACA,gBACA,GAAG,aAEJ,KAAyC;AAEzC,MACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,QAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;AAC1C,cAAQ,KACP,qQAAqQC,OACpQ,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqSA,OACpS,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAIC,SAAAA,eAAgC,KAAK,GAAG;AAC3C,UAAM,sBAAsB;AAC5B,eAAW,KAAK,aAAa;AACxB,UAAA,oBAAoB,CAAqC,MAAM,MAAM;AACxE,4BAAoB,CAAqC,IAAI;AAAA,MAC7D;AAAA,IACD;AAEG,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAMC,mBAAQ,mBAAmB,OAAO;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC1B;AAEnB,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAMC,0BAAQ,0BAA0B,OAAO;AAAA,QACpD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC3B;AAEnB,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAAC,2BAAA,IAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF,CAAC;;"}
|
package/dist/PrismicLink.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const PrismicLink$1 = require("./react-server/PrismicLink.cjs");
|
|
6
|
-
const usePrismicContext = require("./usePrismicContext.cjs");
|
|
7
|
-
function _interopNamespaceDefault(e) {
|
|
8
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
-
if (e) {
|
|
10
|
-
for (const k in e) {
|
|
11
|
-
if (k !== "default") {
|
|
12
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: () => e[k]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
24
|
-
const PrismicLink = React__namespace.forwardRef(function PrismicLink2(props, ref) {
|
|
25
|
-
const context = usePrismicContext.usePrismicContext();
|
|
26
|
-
return /* @__PURE__ */ jsxRuntime.jsx(PrismicLink$1.PrismicLink, { ref, linkResolver: context.linkResolver, internalComponent: context.internalLinkComponent, externalComponent: context.externalLinkComponent, ...props });
|
|
27
|
-
});
|
|
28
|
-
exports.PrismicLink = PrismicLink;
|
|
29
|
-
//# sourceMappingURL=PrismicLink.cjs.map
|
package/dist/PrismicLink.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.cjs","sources":["../../src/PrismicLink.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport {\n\tPrismicLink as ServerPrismicLink,\n\tLinkProps,\n\tPrismicLinkProps,\n\tdefaultComponent,\n} from \"./react-server/PrismicLink\";\n\nimport { usePrismicContext } from \"./usePrismicContext\";\n\nexport type { LinkProps, PrismicLinkProps };\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n) {\n\tconst context = usePrismicContext();\n\n\treturn (\n\t\t<ServerPrismicLink\n\t\t\tref={ref}\n\t\t\tlinkResolver={context.linkResolver}\n\t\t\tinternalComponent={context.internalLinkComponent}\n\t\t\texternalComponent={context.externalLinkComponent}\n\t\t\t{...props}\n\t\t/>\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => React.JSX.Element;\n"],"names":["React","PrismicLink","usePrismicContext","jsx","ServerPrismicLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,cAAcA,iBAAM,WAAW,SAASC,aAIpD,OACA,KAAgC;AAEhC,QAAM,UAAUC,kBAAAA;AAEhB,SACEC,2BAAAA,IAAAC,cAAAA,aAAA,EACA,KACA,cAAc,QAAQ,cACtB,mBAAmB,QAAQ,uBAC3B,mBAAmB,QAAQ,uBAC3B,GAAI,MAAM,CAAA;AAGb,CAAC;;"}
|
package/dist/PrismicProvider.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
22
|
-
const PrismicContext = React__namespace.createContext({});
|
|
23
|
-
const PrismicProvider = ({ client, linkResolver, richTextComponents, internalLinkComponent, externalLinkComponent, children }) => {
|
|
24
|
-
const value = React__namespace.useMemo(() => ({
|
|
25
|
-
client,
|
|
26
|
-
linkResolver,
|
|
27
|
-
richTextComponents,
|
|
28
|
-
internalLinkComponent,
|
|
29
|
-
externalLinkComponent
|
|
30
|
-
}), [
|
|
31
|
-
client,
|
|
32
|
-
linkResolver,
|
|
33
|
-
richTextComponents,
|
|
34
|
-
internalLinkComponent,
|
|
35
|
-
externalLinkComponent
|
|
36
|
-
]);
|
|
37
|
-
return /* @__PURE__ */ jsxRuntime.jsx(PrismicContext.Provider, { value, children });
|
|
38
|
-
};
|
|
39
|
-
exports.PrismicContext = PrismicContext;
|
|
40
|
-
exports.PrismicProvider = PrismicProvider;
|
|
41
|
-
//# sourceMappingURL=PrismicProvider.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicProvider.cjs","sources":["../../src/PrismicProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"./types\";\nimport { LinkProps } from \"./PrismicLink\";\n\n/**\n * React context value containing shared configuration for `@prismicio/react`\n * components and hooks.\n */\nexport type PrismicContextValue<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * A `@prismicio/client` instance used to fetch content from a Prismic\n\t * repository. This is used by `@prismicio/react` hooks, such as\n\t * `usePrismicDocuments()`.\n\t */\n\tclient?: prismic.Client;\n\n\t/**\n\t * A Link Resolver used to resolve links for `<PrismicLink>` and\n\t * `<PrismicRichText>`.\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 * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\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 * @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>{chidlren}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\trichTextComponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The component rendered by `<PrismicLink>` for internal URLs. Defaults to\n\t * `<a>`.\n\t */\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The component rendered by `<PrismicLink>` for external URLs. Defaults to\n\t * `<a>`.\n\t */\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * Children for the component.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * React context containing shared configuration for `@prismicio/react`\n * components and hooks.\n */\nexport const PrismicContext = React.createContext<PrismicContextValue>({});\n\n/**\n * Props for `<PrismicProvider>`.\n */\nexport type PrismicProviderProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction<any>,\n> = PrismicContextValue<LinkResolverFunction>;\n\n/**\n * React context provider to share configuration for `@prismicio/react`\n * components and hooks.\n *\n * @returns A React context provider with shared configuration.\n */\nexport const PrismicProvider = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tclient,\n\tlinkResolver,\n\trichTextComponents,\n\tinternalLinkComponent,\n\texternalLinkComponent,\n\tchildren,\n}: PrismicProviderProps<LinkResolverFunction>): React.JSX.Element => {\n\tconst value = React.useMemo<PrismicContextValue<LinkResolverFunction>>(\n\t\t() => ({\n\t\t\tclient,\n\t\t\tlinkResolver,\n\t\t\trichTextComponents,\n\t\t\tinternalLinkComponent,\n\t\t\texternalLinkComponent,\n\t\t}),\n\t\t[\n\t\t\tclient,\n\t\t\tlinkResolver,\n\t\t\trichTextComponents,\n\t\t\tinternalLinkComponent,\n\t\t\texternalLinkComponent,\n\t\t],\n\t);\n\n\treturn (\n\t\t<PrismicContext.Provider value={value}>{children}</PrismicContext.Provider>\n\t);\n};\n"],"names":["React","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoFO,MAAM,iBAAiBA,iBAAM,cAAmC,EAAE;AAgB5D,MAAA,kBAAkB,CAG7B,EACD,QACA,cACA,oBACA,uBACA,uBACA,eACmE;AAC7D,QAAA,QAAQA,iBAAM,QACnB,OAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IAED;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAGF,SACEC,2BAAAA,IAAA,eAAe,UAAf,EAAwB,OAAe,SAAS,CAAA;AAEnD;;;"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as prismic from "@prismicio/client";
|
|
3
|
-
import { JSXFunctionSerializer, JSXMapSerializer } from "./types";
|
|
4
|
-
import { LinkProps } from "./PrismicLink";
|
|
5
|
-
/**
|
|
6
|
-
* React context value containing shared configuration for `@prismicio/react`
|
|
7
|
-
* components and hooks.
|
|
8
|
-
*/
|
|
9
|
-
export type PrismicContextValue<LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction> = {
|
|
10
|
-
/**
|
|
11
|
-
* A `@prismicio/client` instance used to fetch content from a Prismic
|
|
12
|
-
* repository. This is used by `@prismicio/react` hooks, such as
|
|
13
|
-
* `usePrismicDocuments()`.
|
|
14
|
-
*/
|
|
15
|
-
client?: prismic.Client;
|
|
16
|
-
/**
|
|
17
|
-
* A Link Resolver used to resolve links for `<PrismicLink>` and
|
|
18
|
-
* `<PrismicRichText>`.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* If your app uses Route Resolvers when querying for your Prismic
|
|
22
|
-
* repository's content, a Link Resolver does not need to be provided.
|
|
23
|
-
* @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
|
|
24
|
-
*/
|
|
25
|
-
linkResolver?: LinkResolverFunction;
|
|
26
|
-
/**
|
|
27
|
-
* A map or function that maps a Rich Text block to a React component.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* Prefer using a map serializer over the function serializer when possible.
|
|
31
|
-
* The map serializer is simpler to maintain.
|
|
32
|
-
* @example A map serializer.
|
|
33
|
-
*
|
|
34
|
-
* ```jsx
|
|
35
|
-
* {
|
|
36
|
-
* heading1: ({children}) => <Heading>{children}</Heading>
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example A function serializer.
|
|
41
|
-
*
|
|
42
|
-
* ```jsx
|
|
43
|
-
* (type, node, content, children) => {
|
|
44
|
-
* switch (type) {
|
|
45
|
-
* case "heading1": {
|
|
46
|
-
* return <Heading>{chidlren}</Heading>;
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* };
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
richTextComponents?: JSXMapSerializer | JSXFunctionSerializer;
|
|
53
|
-
/**
|
|
54
|
-
* The component rendered by `<PrismicLink>` for internal URLs. Defaults to
|
|
55
|
-
* `<a>`.
|
|
56
|
-
*/
|
|
57
|
-
internalLinkComponent?: React.ComponentType<LinkProps>;
|
|
58
|
-
/**
|
|
59
|
-
* The component rendered by `<PrismicLink>` for external URLs. Defaults to
|
|
60
|
-
* `<a>`.
|
|
61
|
-
*/
|
|
62
|
-
externalLinkComponent?: React.ComponentType<LinkProps>;
|
|
63
|
-
/**
|
|
64
|
-
* Children for the component.
|
|
65
|
-
*/
|
|
66
|
-
children?: React.ReactNode;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* React context containing shared configuration for `@prismicio/react`
|
|
70
|
-
* components and hooks.
|
|
71
|
-
*/
|
|
72
|
-
export declare const PrismicContext: React.Context<PrismicContextValue<prismic.LinkResolverFunction>>;
|
|
73
|
-
/**
|
|
74
|
-
* Props for `<PrismicProvider>`.
|
|
75
|
-
*/
|
|
76
|
-
export type PrismicProviderProps<LinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction<any>> = PrismicContextValue<LinkResolverFunction>;
|
|
77
|
-
/**
|
|
78
|
-
* React context provider to share configuration for `@prismicio/react`
|
|
79
|
-
* components and hooks.
|
|
80
|
-
*
|
|
81
|
-
* @returns A React context provider with shared configuration.
|
|
82
|
-
*/
|
|
83
|
-
export declare const PrismicProvider: <LinkResolverFunction extends prismic.LinkResolverFunction<any>>({ client, linkResolver, richTextComponents, internalLinkComponent, externalLinkComponent, children, }: PrismicProviderProps<LinkResolverFunction>) => React.JSX.Element;
|