@prismicio/vue 3.1.4 → 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.
Files changed (51) hide show
  1. package/dist/components/PrismicEmbed.cjs.map +1 -1
  2. package/dist/components/PrismicEmbed.d.ts +57 -63
  3. package/dist/components/PrismicEmbed.js.map +1 -1
  4. package/dist/components/PrismicImage.cjs.map +1 -1
  5. package/dist/components/PrismicImage.d.ts +162 -162
  6. package/dist/components/PrismicImage.js.map +1 -1
  7. package/dist/components/PrismicLink.cjs.map +1 -1
  8. package/dist/components/PrismicLink.d.ts +191 -191
  9. package/dist/components/PrismicLink.js.map +1 -1
  10. package/dist/components/PrismicRichText.cjs +7 -2
  11. package/dist/components/PrismicRichText.cjs.map +1 -1
  12. package/dist/components/PrismicRichText.d.ts +160 -139
  13. package/dist/components/PrismicRichText.js +7 -2
  14. package/dist/components/PrismicRichText.js.map +1 -1
  15. package/dist/components/PrismicText.cjs.map +1 -1
  16. package/dist/components/PrismicText.d.ts +117 -117
  17. package/dist/components/PrismicText.js.map +1 -1
  18. package/dist/components/SliceZone.cjs.map +1 -1
  19. package/dist/components/SliceZone.d.ts +357 -359
  20. package/dist/components/SliceZone.js.map +1 -1
  21. package/dist/components/index.d.ts +12 -12
  22. package/dist/composables.d.ts +366 -366
  23. package/dist/createPrismic.cjs +3 -3
  24. package/dist/createPrismic.cjs.map +1 -1
  25. package/dist/createPrismic.d.ts +12 -12
  26. package/dist/createPrismic.js +3 -3
  27. package/dist/createPrismic.js.map +1 -1
  28. package/dist/globalExtensions.d.ts +11 -11
  29. package/dist/index.cjs +16 -16
  30. package/dist/index.d.ts +10 -10
  31. package/dist/index.js +3 -3
  32. package/dist/injectionSymbols.d.ts +9 -9
  33. package/dist/lib/__PRODUCTION__.d.ts +7 -7
  34. package/dist/lib/getSlots.d.ts +14 -14
  35. package/dist/lib/isInternalURL.d.ts +8 -8
  36. package/dist/lib/simplyResolveComponent.cjs.map +1 -1
  37. package/dist/lib/simplyResolveComponent.d.ts +12 -12
  38. package/dist/lib/simplyResolveComponent.js.map +1 -1
  39. package/dist/types.d.ts +366 -357
  40. package/dist/usePrismic.d.ts +21 -21
  41. package/dist/useStatefulPrismicClientMethod.d.ts +64 -64
  42. package/package.json +13 -13
  43. package/src/components/PrismicEmbed.ts +6 -2
  44. package/src/components/PrismicImage.ts +6 -2
  45. package/src/components/PrismicLink.ts +11 -5
  46. package/src/components/PrismicRichText.ts +30 -5
  47. package/src/components/PrismicText.ts +6 -2
  48. package/src/components/SliceZone.ts +5 -2
  49. package/src/createPrismic.ts +3 -6
  50. package/src/lib/simplyResolveComponent.ts +8 -2
  51. 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<{}, {}, 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, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}> | FunctionalComponent<SliceComponentProps<any, unknown>, {}> | DefineComponent<SliceComponentProps<any, unknown>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<SliceComponentProps<any, unknown>>, {
154
- slice: any;
155
- }>;
156
- /**
157
- * A record of Slice types mapped to Vue components. Each components will be
158
- * rendered for each instance of their Slice type.
159
- *
160
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
161
- * @typeParam TContext - Arbitrary data made available to all Slice components
162
- */
163
- export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
164
- [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
165
- };
166
- /**
167
- * Gets an optimized record of Slice types mapped to Vue components. Each
168
- * components will be rendered for each instance of their Slice type.
169
- *
170
- * @remarks
171
- * This is essentially an helper function to ensure {@link markRaw} is correctly
172
- * applied on each components, improving performances.
173
- * @example Defining a slice components:
174
- *
175
- * ```javascript
176
- * import { defineSliceZoneComponents } from "@prismicio/vue";
177
- *
178
- * export default {
179
- * data() {
180
- * components: defineSliceZoneComponents({
181
- * foo: Foo,
182
- * bar: defineAsyncComponent(
183
- * () => new Promise((res) => res(Bar)),
184
- * ),
185
- * baz: "Baz",
186
- * }),
187
- * }
188
- * };
189
- * ```
190
- *
191
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
192
- * @typeParam TContext - Arbitrary data made available to all Slice components
193
- *
194
- * @param components - {@link SliceZoneComponents}
195
- *
196
- * @returns A new optimized record of {@link SliceZoneComponents}
197
- */
198
- export declare const defineSliceZoneComponents: <TSlice extends SliceLike<string> = any, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
199
- /**
200
- * Arguments for a `<SliceZone>` `resolver` function.
201
- */
202
- export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
203
- /**
204
- * The Slice to resolve to a Vue component..
205
- */
206
- slice: TSlice;
207
- /**
208
- * The name of the Slice.
209
- */
210
- sliceName: ExtractSliceType<TSlice>;
211
- /**
212
- * The index of the Slice in the Slice Zone.
213
- */
214
- i: number;
215
- };
216
- /**
217
- * A function that determines the rendered Vue component for each Slice in the
218
- * Slice Zone. If a nullish value is returned, the component will fallback to
219
- * the `components` or `defaultComponent` props to determine the rendered
220
- * component.
221
- *
222
- * @deprecated Use the `components` prop instead.
223
- *
224
- * @param args - Arguments for the resolver function.
225
- *
226
- * @returns The Vue component to render for a Slice.
227
- */
228
- export type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | string | undefined | null;
229
- /**
230
- * Props for `<SliceZone />`.
231
- *
232
- * @typeParam TContext - Arbitrary data made available to all Slice components
233
- */
234
- export type SliceZoneProps<TContext = unknown> = {
235
- /**
236
- * List of Slice data from the Slice Zone.
237
- */
238
- slices: SliceZoneLike;
239
- /**
240
- * A record mapping Slice types to Vue components.
241
- */
242
- components?: SliceZoneComponents;
243
- /**
244
- * A function that determines the rendered Vue component for each Slice in the
245
- * Slice Zone.
246
- *
247
- * @deprecated Use the `components` prop instead.
248
- *
249
- * @param args - Arguments for the resolver function.
250
- *
251
- * @returns The Vue component to render for a Slice.
252
- */
253
- resolver?: SliceZoneResolver<any, TContext>;
254
- /**
255
- * Arbitrary data made available to all Slice components.
256
- */
257
- context?: TContext;
258
- /**
259
- * A component or a functional component rendered if a component mapping from
260
- * the `components` prop cannot be found.
261
- *
262
- * @remarks
263
- * Components will be rendered using the {@link SliceComponentProps} interface.
264
- *
265
- * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
266
- */
267
- defaultComponent?: SliceComponentType<any, TContext>;
268
- /**
269
- * An HTML tag name, a component, or a functional component used to wrap the
270
- * output. The Slice Zone is not wrapped by default.
271
- */
272
- wrapper?: string | ConcreteComponent;
273
- };
274
- /**
275
- * `<SliceZone />` implementation.
276
- *
277
- * @internal
278
- */
279
- export declare const SliceZoneImpl: DefineComponent<{
280
- slices: {
281
- type: PropType<SliceZoneLike<SliceLike<string>>>;
282
- required: true;
283
- };
284
- components: {
285
- type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
286
- default: undefined;
287
- required: false;
288
- };
289
- resolver: {
290
- type: PropType<SliceZoneResolver<any, unknown>>;
291
- default: undefined;
292
- required: false;
293
- };
294
- context: {
295
- type: null;
296
- default: undefined;
297
- required: false;
298
- };
299
- defaultComponent: {
300
- type: PropType<SliceComponentType<any, unknown>>;
301
- default: undefined;
302
- required: false;
303
- };
304
- wrapper: {
305
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>;
306
- default: undefined;
307
- required: false;
308
- };
309
- }, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
310
- [key: string]: any;
311
- }> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
312
- [key: string]: any;
313
- }>[]), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
314
- slices: {
315
- type: PropType<SliceZoneLike<SliceLike<string>>>;
316
- required: true;
317
- };
318
- components: {
319
- type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
320
- default: undefined;
321
- required: false;
322
- };
323
- resolver: {
324
- type: PropType<SliceZoneResolver<any, unknown>>;
325
- default: undefined;
326
- required: false;
327
- };
328
- context: {
329
- type: null;
330
- default: undefined;
331
- required: false;
332
- };
333
- defaultComponent: {
334
- type: PropType<SliceComponentType<any, unknown>>;
335
- default: undefined;
336
- required: false;
337
- };
338
- wrapper: {
339
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>;
340
- default: undefined;
341
- required: false;
342
- };
343
- }>>, {
344
- context: any;
345
- components: SliceZoneComponents<SliceLike<string>, unknown>;
346
- resolver: SliceZoneResolver<any, unknown>;
347
- defaultComponent: SliceComponentType<any, unknown>;
348
- wrapper: string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
349
- }>;
350
- /**
351
- * Component to render a Prismic Slice Zone.
352
- *
353
- * @see Component props {@link SliceZoneProps}
354
- * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}
355
- */
356
- export declare const SliceZone: new () => {
357
- $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & SliceZoneProps;
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 {};