@prismicio/vue 3.1.3 → 3.2.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/README.md +1 -1
- package/dist/components/PrismicEmbed.cjs.map +1 -1
- package/dist/components/PrismicEmbed.d.ts +57 -63
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +162 -162
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +191 -191
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs +7 -2
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +160 -139
- package/dist/components/PrismicRichText.js +7 -2
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +117 -117
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +357 -359
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/components/index.d.ts +12 -12
- package/dist/composables.d.ts +366 -366
- package/dist/createPrismic.cjs +3 -3
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.d.ts +12 -12
- package/dist/createPrismic.js +3 -3
- package/dist/createPrismic.js.map +1 -1
- package/dist/globalExtensions.d.ts +11 -11
- package/dist/index.cjs +16 -16
- package/dist/index.d.ts +10 -10
- package/dist/index.js +3 -3
- package/dist/injectionSymbols.d.ts +9 -9
- package/dist/lib/__PRODUCTION__.d.ts +7 -7
- package/dist/lib/getSlots.d.ts +14 -14
- package/dist/lib/isInternalURL.d.ts +8 -8
- package/dist/lib/simplyResolveComponent.cjs.map +1 -1
- package/dist/lib/simplyResolveComponent.d.ts +12 -12
- package/dist/lib/simplyResolveComponent.js.map +1 -1
- package/dist/types.d.ts +366 -357
- package/dist/usePrismic.d.ts +21 -21
- package/dist/useStatefulPrismicClientMethod.d.ts +64 -64
- package/package.json +15 -15
- package/src/components/PrismicEmbed.ts +6 -2
- package/src/components/PrismicImage.ts +6 -2
- package/src/components/PrismicLink.ts +11 -5
- package/src/components/PrismicRichText.ts +30 -5
- package/src/components/PrismicText.ts +6 -2
- package/src/components/SliceZone.ts +8 -2
- package/src/createPrismic.ts +3 -6
- package/src/lib/simplyResolveComponent.ts +8 -2
- package/src/types.ts +15 -4
|
@@ -1,359 +1,357 @@
|
|
|
1
|
-
import { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, DefineComponent, FunctionalComponent, PropType, VNodeProps } from "vue";
|
|
2
|
-
import { Slice } from "@prismicio/types";
|
|
3
|
-
/**
|
|
4
|
-
* Returns the type of a `SliceLike` type.
|
|
5
|
-
*
|
|
6
|
-
* @typeParam TSlice - The Slice from which the type will be extracted.
|
|
7
|
-
*/
|
|
8
|
-
type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
|
|
9
|
-
/**
|
|
10
|
-
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
11
|
-
* Rest API V2 for the `<SliceZone>` component.
|
|
12
|
-
*
|
|
13
|
-
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
14
|
-
* `@prismicio/types` for a full interface.
|
|
15
|
-
*
|
|
16
|
-
* @typeParam TSliceType - Type name of the Slice.
|
|
17
|
-
*/
|
|
18
|
-
export type SliceLikeRestV2<TSliceType extends string = string> = {
|
|
19
|
-
slice_type: Slice<TSliceType>["slice_type"];
|
|
20
|
-
id?: string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
24
|
-
* GraphQL API for the `<SliceZone>` component.
|
|
25
|
-
*
|
|
26
|
-
* @typeParam TSliceType - Type name of the Slice.
|
|
27
|
-
*/
|
|
28
|
-
export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
29
|
-
type: Slice<TSliceType>["slice_type"];
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* The minimum required properties to represent a Prismic Slice for the
|
|
33
|
-
* `<SliceZone />` component.
|
|
34
|
-
*
|
|
35
|
-
* If using Prismic's REST API, use the `Slice` export from `@prismicio/types`
|
|
36
|
-
* for a full interface.
|
|
37
|
-
*
|
|
38
|
-
* @typeParam TSliceType - Type name of the Slice
|
|
39
|
-
*/
|
|
40
|
-
export type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>;
|
|
41
|
-
/**
|
|
42
|
-
* A looser version of the `SliceZone` type from `@prismicio/types` using
|
|
43
|
-
* `SliceLike`.
|
|
44
|
-
*
|
|
45
|
-
* If using Prismic's REST API, use the `SliceZone` export from
|
|
46
|
-
* `@prismicio/types` for the full type.
|
|
47
|
-
*
|
|
48
|
-
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
49
|
-
*/
|
|
50
|
-
export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
|
|
51
|
-
/**
|
|
52
|
-
* Vue props for a component rendering content from a Prismic Slice using the
|
|
53
|
-
* `<SliceZone />` component.
|
|
54
|
-
*
|
|
55
|
-
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
56
|
-
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
57
|
-
* available to all Slice components
|
|
58
|
-
*/
|
|
59
|
-
export type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
60
|
-
/**
|
|
61
|
-
* Slice data for this component.
|
|
62
|
-
*/
|
|
63
|
-
slice: TSlice;
|
|
64
|
-
/**
|
|
65
|
-
* The index of the Slice in the Slice Zone.
|
|
66
|
-
*/
|
|
67
|
-
index: number;
|
|
68
|
-
/**
|
|
69
|
-
* All Slices from the Slice Zone to which the Slice belongs.
|
|
70
|
-
*/
|
|
71
|
-
slices: SliceZoneLike<SliceLike>;
|
|
72
|
-
/**
|
|
73
|
-
* Arbitrary data passed to `<SliceZone />` and made available to all Slice
|
|
74
|
-
* components.
|
|
75
|
-
*/
|
|
76
|
-
context: TContext;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Native Vue props for a component rendering content from a Prismic Slice using
|
|
80
|
-
* the `<SliceZone />` component.
|
|
81
|
-
*
|
|
82
|
-
* @typeParam TSlice - The Slice type
|
|
83
|
-
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
84
|
-
* available to all Slice components
|
|
85
|
-
*/
|
|
86
|
-
export type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
87
|
-
slice: {
|
|
88
|
-
type: PropType<SliceComponentProps<TSlice, TContext>["slice"]>;
|
|
89
|
-
required: true;
|
|
90
|
-
};
|
|
91
|
-
index: {
|
|
92
|
-
type: PropType<SliceComponentProps<TSlice, TContext>["index"]>;
|
|
93
|
-
required: true;
|
|
94
|
-
};
|
|
95
|
-
slices: {
|
|
96
|
-
type: PropType<SliceComponentProps<TSlice, TContext>["slices"]>;
|
|
97
|
-
required: true;
|
|
98
|
-
};
|
|
99
|
-
context: {
|
|
100
|
-
type: PropType<SliceComponentProps<TSlice, TContext>["context"]>;
|
|
101
|
-
required: true;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Gets native Vue props for a component rendering content from a Prismic Slice
|
|
106
|
-
* using the `<SliceZone />` component. Props are: `["slice", "index", "slices",
|
|
107
|
-
* "context"]`
|
|
108
|
-
*
|
|
109
|
-
* @example Defining a new slice component:
|
|
110
|
-
*
|
|
111
|
-
* ```javascript
|
|
112
|
-
* import { getSliceComponentProps } from "@prismicio/vue";
|
|
113
|
-
*
|
|
114
|
-
* export default {
|
|
115
|
-
* props: getSliceComponentProps(),
|
|
116
|
-
* };
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* @example Defining a new slice component with visual hint:
|
|
120
|
-
*
|
|
121
|
-
* ```javascript
|
|
122
|
-
* import { getSliceComponentProps } from "@prismicio/vue";
|
|
123
|
-
*
|
|
124
|
-
* export default {
|
|
125
|
-
* props: getSliceComponentProps(["slice", "index", "slices", "context"]),
|
|
126
|
-
* };
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* @typeParam TSlice - The Slice type
|
|
130
|
-
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
131
|
-
* available to all Slice components
|
|
132
|
-
* @param propsHint - An optional array of prop names used for the sole purpose
|
|
133
|
-
* of having a visual hint of which props are made available to the slice,
|
|
134
|
-
* this parameters doesn't have any effect
|
|
135
|
-
*
|
|
136
|
-
* @returns Props object to use with {@link defineComponent}
|
|
137
|
-
*/
|
|
138
|
-
export declare const getSliceComponentProps: <TSlice extends SliceLike<string> = any, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
|
|
139
|
-
/**
|
|
140
|
-
* A Vue component to be rendered for each instance of its Slice.
|
|
141
|
-
*
|
|
142
|
-
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
143
|
-
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
144
|
-
*/
|
|
145
|
-
export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
|
|
146
|
-
/**
|
|
147
|
-
* This Slice component can be used as a reminder to provide a proper
|
|
148
|
-
* implementation.
|
|
149
|
-
*
|
|
150
|
-
* This is also the default Vue component rendered when a component mapping
|
|
151
|
-
* cannot be found in `<SliceZone />`.
|
|
152
|
-
*/
|
|
153
|
-
export declare const TODOSliceComponent:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* @
|
|
193
|
-
*
|
|
194
|
-
* @
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
223
|
-
*
|
|
224
|
-
* @
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* @
|
|
248
|
-
*
|
|
249
|
-
* @
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
[key: string]: any;
|
|
311
|
-
}>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
* Component
|
|
352
|
-
*
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
};
|
|
359
|
-
export {};
|
|
1
|
+
import { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, DefineComponent, FunctionalComponent, PropType, Raw, VNodeProps } from "vue";
|
|
2
|
+
import { Slice } from "@prismicio/types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the type of a `SliceLike` type.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TSlice - The Slice from which the type will be extracted.
|
|
7
|
+
*/
|
|
8
|
+
type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
|
|
9
|
+
/**
|
|
10
|
+
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
11
|
+
* Rest API V2 for the `<SliceZone>` component.
|
|
12
|
+
*
|
|
13
|
+
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
14
|
+
* `@prismicio/types` for a full interface.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam TSliceType - Type name of the Slice.
|
|
17
|
+
*/
|
|
18
|
+
export type SliceLikeRestV2<TSliceType extends string = string> = {
|
|
19
|
+
slice_type: Slice<TSliceType>["slice_type"];
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
24
|
+
* GraphQL API for the `<SliceZone>` component.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam TSliceType - Type name of the Slice.
|
|
27
|
+
*/
|
|
28
|
+
export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
29
|
+
type: Slice<TSliceType>["slice_type"];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The minimum required properties to represent a Prismic Slice for the
|
|
33
|
+
* `<SliceZone />` component.
|
|
34
|
+
*
|
|
35
|
+
* If using Prismic's REST API, use the `Slice` export from `@prismicio/types`
|
|
36
|
+
* for a full interface.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam TSliceType - Type name of the Slice
|
|
39
|
+
*/
|
|
40
|
+
export type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>;
|
|
41
|
+
/**
|
|
42
|
+
* A looser version of the `SliceZone` type from `@prismicio/types` using
|
|
43
|
+
* `SliceLike`.
|
|
44
|
+
*
|
|
45
|
+
* If using Prismic's REST API, use the `SliceZone` export from
|
|
46
|
+
* `@prismicio/types` for the full type.
|
|
47
|
+
*
|
|
48
|
+
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
49
|
+
*/
|
|
50
|
+
export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
|
|
51
|
+
/**
|
|
52
|
+
* Vue props for a component rendering content from a Prismic Slice using the
|
|
53
|
+
* `<SliceZone />` component.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
56
|
+
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
57
|
+
* available to all Slice components
|
|
58
|
+
*/
|
|
59
|
+
export type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
60
|
+
/**
|
|
61
|
+
* Slice data for this component.
|
|
62
|
+
*/
|
|
63
|
+
slice: TSlice;
|
|
64
|
+
/**
|
|
65
|
+
* The index of the Slice in the Slice Zone.
|
|
66
|
+
*/
|
|
67
|
+
index: number;
|
|
68
|
+
/**
|
|
69
|
+
* All Slices from the Slice Zone to which the Slice belongs.
|
|
70
|
+
*/
|
|
71
|
+
slices: SliceZoneLike<SliceLike>;
|
|
72
|
+
/**
|
|
73
|
+
* Arbitrary data passed to `<SliceZone />` and made available to all Slice
|
|
74
|
+
* components.
|
|
75
|
+
*/
|
|
76
|
+
context: TContext;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Native Vue props for a component rendering content from a Prismic Slice using
|
|
80
|
+
* the `<SliceZone />` component.
|
|
81
|
+
*
|
|
82
|
+
* @typeParam TSlice - The Slice type
|
|
83
|
+
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
84
|
+
* available to all Slice components
|
|
85
|
+
*/
|
|
86
|
+
export type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
|
|
87
|
+
slice: {
|
|
88
|
+
type: PropType<SliceComponentProps<TSlice, TContext>["slice"]>;
|
|
89
|
+
required: true;
|
|
90
|
+
};
|
|
91
|
+
index: {
|
|
92
|
+
type: PropType<SliceComponentProps<TSlice, TContext>["index"]>;
|
|
93
|
+
required: true;
|
|
94
|
+
};
|
|
95
|
+
slices: {
|
|
96
|
+
type: PropType<SliceComponentProps<TSlice, TContext>["slices"]>;
|
|
97
|
+
required: true;
|
|
98
|
+
};
|
|
99
|
+
context: {
|
|
100
|
+
type: PropType<SliceComponentProps<TSlice, TContext>["context"]>;
|
|
101
|
+
required: true;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Gets native Vue props for a component rendering content from a Prismic Slice
|
|
106
|
+
* using the `<SliceZone />` component. Props are: `["slice", "index", "slices",
|
|
107
|
+
* "context"]`
|
|
108
|
+
*
|
|
109
|
+
* @example Defining a new slice component:
|
|
110
|
+
*
|
|
111
|
+
* ```javascript
|
|
112
|
+
* import { getSliceComponentProps } from "@prismicio/vue";
|
|
113
|
+
*
|
|
114
|
+
* export default {
|
|
115
|
+
* props: getSliceComponentProps(),
|
|
116
|
+
* };
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example Defining a new slice component with visual hint:
|
|
120
|
+
*
|
|
121
|
+
* ```javascript
|
|
122
|
+
* import { getSliceComponentProps } from "@prismicio/vue";
|
|
123
|
+
*
|
|
124
|
+
* export default {
|
|
125
|
+
* props: getSliceComponentProps(["slice", "index", "slices", "context"]),
|
|
126
|
+
* };
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @typeParam TSlice - The Slice type
|
|
130
|
+
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
131
|
+
* available to all Slice components
|
|
132
|
+
* @param propsHint - An optional array of prop names used for the sole purpose
|
|
133
|
+
* of having a visual hint of which props are made available to the slice,
|
|
134
|
+
* this parameters doesn't have any effect
|
|
135
|
+
*
|
|
136
|
+
* @returns Props object to use with {@link defineComponent}
|
|
137
|
+
*/
|
|
138
|
+
export declare const getSliceComponentProps: <TSlice extends SliceLike<string> = any, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
|
|
139
|
+
/**
|
|
140
|
+
* A Vue component to be rendered for each instance of its Slice.
|
|
141
|
+
*
|
|
142
|
+
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
143
|
+
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
144
|
+
*/
|
|
145
|
+
export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = DefineComponent<{}, {}, any> | DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
|
|
146
|
+
/**
|
|
147
|
+
* This Slice component can be used as a reminder to provide a proper
|
|
148
|
+
* implementation.
|
|
149
|
+
*
|
|
150
|
+
* This is also the default Vue component rendered when a component mapping
|
|
151
|
+
* cannot be found in `<SliceZone />`.
|
|
152
|
+
*/
|
|
153
|
+
export declare const TODOSliceComponent: DefineComponent<{}, {}, any> | FunctionalComponent<SliceComponentProps<any, unknown>, {}> | DefineComponent<SliceComponentProps<any, unknown>>;
|
|
154
|
+
/**
|
|
155
|
+
* A record of Slice types mapped to Vue components. Each components will be
|
|
156
|
+
* rendered for each instance of their Slice type.
|
|
157
|
+
*
|
|
158
|
+
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
159
|
+
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
160
|
+
*/
|
|
161
|
+
export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
|
|
162
|
+
[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Gets an optimized record of Slice types mapped to Vue components. Each
|
|
166
|
+
* components will be rendered for each instance of their Slice type.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* This is essentially an helper function to ensure {@link markRaw} is correctly
|
|
170
|
+
* applied on each components, improving performances.
|
|
171
|
+
* @example Defining a slice components:
|
|
172
|
+
*
|
|
173
|
+
* ```javascript
|
|
174
|
+
* import { defineSliceZoneComponents } from "@prismicio/vue";
|
|
175
|
+
*
|
|
176
|
+
* export default {
|
|
177
|
+
* data() {
|
|
178
|
+
* components: defineSliceZoneComponents({
|
|
179
|
+
* foo: Foo,
|
|
180
|
+
* bar: defineAsyncComponent(
|
|
181
|
+
* () => new Promise((res) => res(Bar)),
|
|
182
|
+
* ),
|
|
183
|
+
* baz: "Baz",
|
|
184
|
+
* }),
|
|
185
|
+
* }
|
|
186
|
+
* };
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
190
|
+
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
191
|
+
*
|
|
192
|
+
* @param components - {@link SliceZoneComponents}
|
|
193
|
+
*
|
|
194
|
+
* @returns A new optimized record of {@link SliceZoneComponents}
|
|
195
|
+
*/
|
|
196
|
+
export declare const defineSliceZoneComponents: <TSlice extends SliceLike<string> = any, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
|
|
197
|
+
/**
|
|
198
|
+
* Arguments for a `<SliceZone>` `resolver` function.
|
|
199
|
+
*/
|
|
200
|
+
export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
|
|
201
|
+
/**
|
|
202
|
+
* The Slice to resolve to a Vue component..
|
|
203
|
+
*/
|
|
204
|
+
slice: TSlice;
|
|
205
|
+
/**
|
|
206
|
+
* The name of the Slice.
|
|
207
|
+
*/
|
|
208
|
+
sliceName: ExtractSliceType<TSlice>;
|
|
209
|
+
/**
|
|
210
|
+
* The index of the Slice in the Slice Zone.
|
|
211
|
+
*/
|
|
212
|
+
i: number;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* A function that determines the rendered Vue component for each Slice in the
|
|
216
|
+
* Slice Zone. If a nullish value is returned, the component will fallback to
|
|
217
|
+
* the `components` or `defaultComponent` props to determine the rendered
|
|
218
|
+
* component.
|
|
219
|
+
*
|
|
220
|
+
* @deprecated Use the `components` prop instead.
|
|
221
|
+
*
|
|
222
|
+
* @param args - Arguments for the resolver function.
|
|
223
|
+
*
|
|
224
|
+
* @returns The Vue component to render for a Slice.
|
|
225
|
+
*/
|
|
226
|
+
export type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | string | undefined | null;
|
|
227
|
+
/**
|
|
228
|
+
* Props for `<SliceZone />`.
|
|
229
|
+
*
|
|
230
|
+
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
231
|
+
*/
|
|
232
|
+
export type SliceZoneProps<TContext = unknown> = {
|
|
233
|
+
/**
|
|
234
|
+
* List of Slice data from the Slice Zone.
|
|
235
|
+
*/
|
|
236
|
+
slices: SliceZoneLike;
|
|
237
|
+
/**
|
|
238
|
+
* A record mapping Slice types to Vue components.
|
|
239
|
+
*/
|
|
240
|
+
components?: SliceZoneComponents;
|
|
241
|
+
/**
|
|
242
|
+
* A function that determines the rendered Vue component for each Slice in the
|
|
243
|
+
* Slice Zone.
|
|
244
|
+
*
|
|
245
|
+
* @deprecated Use the `components` prop instead.
|
|
246
|
+
*
|
|
247
|
+
* @param args - Arguments for the resolver function.
|
|
248
|
+
*
|
|
249
|
+
* @returns The Vue component to render for a Slice.
|
|
250
|
+
*/
|
|
251
|
+
resolver?: SliceZoneResolver<any, TContext>;
|
|
252
|
+
/**
|
|
253
|
+
* Arbitrary data made available to all Slice components.
|
|
254
|
+
*/
|
|
255
|
+
context?: TContext;
|
|
256
|
+
/**
|
|
257
|
+
* A component or a functional component rendered if a component mapping from
|
|
258
|
+
* the `components` prop cannot be found.
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* Components will be rendered using the {@link SliceComponentProps} interface.
|
|
262
|
+
*
|
|
263
|
+
* @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
|
|
264
|
+
*/
|
|
265
|
+
defaultComponent?: SliceComponentType<any, TContext>;
|
|
266
|
+
/**
|
|
267
|
+
* An HTML tag name, a component, or a functional component used to wrap the
|
|
268
|
+
* output. The Slice Zone is not wrapped by default.
|
|
269
|
+
*/
|
|
270
|
+
wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* `<SliceZone />` implementation.
|
|
274
|
+
*
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
export declare const SliceZoneImpl: DefineComponent<{
|
|
278
|
+
slices: {
|
|
279
|
+
type: PropType<SliceZoneLike<SliceLike<string>>>;
|
|
280
|
+
required: true;
|
|
281
|
+
};
|
|
282
|
+
components: {
|
|
283
|
+
type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
|
|
284
|
+
default: undefined;
|
|
285
|
+
required: false;
|
|
286
|
+
};
|
|
287
|
+
resolver: {
|
|
288
|
+
type: PropType<SliceZoneResolver<any, unknown>>;
|
|
289
|
+
default: undefined;
|
|
290
|
+
required: false;
|
|
291
|
+
};
|
|
292
|
+
context: {
|
|
293
|
+
type: null;
|
|
294
|
+
default: undefined;
|
|
295
|
+
required: false;
|
|
296
|
+
};
|
|
297
|
+
defaultComponent: {
|
|
298
|
+
type: PropType<SliceComponentType<any, unknown>>;
|
|
299
|
+
default: undefined;
|
|
300
|
+
required: false;
|
|
301
|
+
};
|
|
302
|
+
wrapper: {
|
|
303
|
+
type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
|
|
304
|
+
default: undefined;
|
|
305
|
+
required: false;
|
|
306
|
+
};
|
|
307
|
+
}, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
308
|
+
[key: string]: any;
|
|
309
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
310
|
+
[key: string]: any;
|
|
311
|
+
}>[]), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
312
|
+
slices: {
|
|
313
|
+
type: PropType<SliceZoneLike<SliceLike<string>>>;
|
|
314
|
+
required: true;
|
|
315
|
+
};
|
|
316
|
+
components: {
|
|
317
|
+
type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
|
|
318
|
+
default: undefined;
|
|
319
|
+
required: false;
|
|
320
|
+
};
|
|
321
|
+
resolver: {
|
|
322
|
+
type: PropType<SliceZoneResolver<any, unknown>>;
|
|
323
|
+
default: undefined;
|
|
324
|
+
required: false;
|
|
325
|
+
};
|
|
326
|
+
context: {
|
|
327
|
+
type: null;
|
|
328
|
+
default: undefined;
|
|
329
|
+
required: false;
|
|
330
|
+
};
|
|
331
|
+
defaultComponent: {
|
|
332
|
+
type: PropType<SliceComponentType<any, unknown>>;
|
|
333
|
+
default: undefined;
|
|
334
|
+
required: false;
|
|
335
|
+
};
|
|
336
|
+
wrapper: {
|
|
337
|
+
type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
|
|
338
|
+
default: undefined;
|
|
339
|
+
required: false;
|
|
340
|
+
};
|
|
341
|
+
}>>, {
|
|
342
|
+
context: any;
|
|
343
|
+
components: SliceZoneComponents<SliceLike<string>, unknown>;
|
|
344
|
+
resolver: SliceZoneResolver<any, unknown>;
|
|
345
|
+
defaultComponent: SliceComponentType<any, unknown>;
|
|
346
|
+
wrapper: string | ConcreteComponent | Raw<DefineComponent>;
|
|
347
|
+
}>;
|
|
348
|
+
/**
|
|
349
|
+
* Component to render a Prismic Slice Zone.
|
|
350
|
+
*
|
|
351
|
+
* @see Component props {@link SliceZoneProps}
|
|
352
|
+
* @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}
|
|
353
|
+
*/
|
|
354
|
+
export declare const SliceZone: new () => {
|
|
355
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & SliceZoneProps;
|
|
356
|
+
};
|
|
357
|
+
export {};
|