@prismicio/vue 3.0.0-alpha.5 → 3.0.0-beta.2

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.
@@ -22,10 +22,13 @@ import {
22
22
  *
23
23
  * @remarks
24
24
  * An additional `@prismicio/client` instance can be provided at `params.client`.
25
+ *
25
26
  * @typeParam TDocument - Type of Prismic documents returned
27
+ *
26
28
  * @param params - Parameters to filter, sort, and paginate results
27
29
  *
28
30
  * @returns The composable payload {@link ClientComposableReturnType}
31
+ *
29
32
  * @see Underlying `@prismicio/client` method {@link Client.get}
30
33
  */
31
34
  export const usePrismicDocuments = <TDocument extends PrismicDocument>(
@@ -41,10 +44,13 @@ export const usePrismicDocuments = <TDocument extends PrismicDocument>(
41
44
  *
42
45
  * @remarks
43
46
  * An additional `@prismicio/client` instance can be provided at `params.client`.
47
+ *
44
48
  * @typeParam TDocument - Type of the Prismic document returned
49
+ *
45
50
  * @param params - Parameters to filter, sort, and paginate results
46
51
  *
47
52
  * @returns The composable payload {@link ClientComposableReturnType}
53
+ *
48
54
  * @see Underlying `@prismicio/client` method {@link Client.getFirst}
49
55
  */
50
56
  export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
@@ -59,11 +65,14 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
59
65
  *
60
66
  * @remarks
61
67
  * An additional `@prismicio/client` instance can be provided at `params.client`.
68
+ *
62
69
  * @typeParam TDocument - Type of the Prismic document returned
70
+ *
63
71
  * @param id - ID of the document
64
72
  * @param params - Parameters to filter, sort, and paginate results
65
73
  *
66
74
  * @returns The composable payload {@link ClientComposableReturnType}
75
+ *
67
76
  * @see Underlying `@prismicio/client` method {@link Client.getByID}
68
77
  */
69
78
  export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
@@ -79,11 +88,14 @@ export const usePrismicDocumentByID = <TDocument extends PrismicDocument>(
79
88
  *
80
89
  * @remarks
81
90
  * An additional `@prismicio/client` instance can be provided at `params.client`.
91
+ *
82
92
  * @typeParam TDocument - Type of Prismic documents returned
93
+ *
83
94
  * @param ids - A list of document IDs
84
95
  * @param params - Parameters to filter, sort, and paginate results
85
96
  *
86
97
  * @returns The composable payload {@link ClientComposableReturnType}
98
+ *
87
99
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
88
100
  */
89
101
  export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
@@ -99,11 +111,14 @@ export const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
99
111
  *
100
112
  * @remarks
101
113
  * An additional `@prismicio/client` instance can be provided at `params.client`.
114
+ *
102
115
  * @typeParam TDocument - Type of Prismic documents returned
116
+ *
103
117
  * @param ids - A list of document IDs
104
118
  * @param params - Parameters to filter and sort results
105
119
  *
106
120
  * @returns The composable payload {@link ClientComposableReturnType}
121
+ *
107
122
  * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
108
123
  */
109
124
  export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
@@ -121,12 +136,15 @@ export const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(
121
136
  *
122
137
  * @remarks
123
138
  * An additional `@prismicio/client` instance can be provided at `params.client`.
139
+ *
124
140
  * @typeParam TDocument - Type of the Prismic document returned
141
+ *
125
142
  * @param documentType - The API ID of the document's Custom Type
126
143
  * @param uid - UID of the document
127
144
  * @param params - Parameters to filter, sort, and paginate results
128
145
  *
129
146
  * @returns The composable payload {@link ClientComposableReturnType}
147
+ *
130
148
  * @see Underlying `@prismicio/client` method {@link Client.getByUID}
131
149
  */
132
150
  export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
@@ -143,12 +161,15 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
143
161
  *
144
162
  * @remarks
145
163
  * An additional `@prismicio/client` instance can be provided at `params.client`.
164
+ *
146
165
  * @typeParam TDocument - Type of Prismic documents returned
166
+ *
147
167
  * @param documentType - The API ID of the document's Custom Type
148
168
  * @param uids - A list of document UIDs
149
169
  * @param params - Parameters to filter, sort, and paginate results
150
170
  *
151
171
  * @returns The composable payload {@link ClientComposableReturnType}
172
+ *
152
173
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
153
174
  */
154
175
  export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
@@ -165,12 +186,15 @@ export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
165
186
  *
166
187
  * @remarks
167
188
  * An additional `@prismicio/client` instance can be provided at `params.client`.
189
+ *
168
190
  * @typeParam TDocument - Type of Prismic documents returned
191
+ *
169
192
  * @param documentType - The API ID of the document's Custom Type
170
193
  * @param uids - A list of document UIDs
171
194
  * @param params - Parameters to filter and sort results
172
195
  *
173
196
  * @returns The composable payload {@link ClientComposableReturnType}
197
+ *
174
198
  * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
175
199
  */
176
200
  export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
@@ -189,11 +213,14 @@ export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
189
213
  *
190
214
  * @remarks
191
215
  * An additional `@prismicio/client` instance can be provided at `params.client`.
216
+ *
192
217
  * @typeParam TDocument - Type of the Prismic document returned
218
+ *
193
219
  * @param documentType - The API ID of the singleton Custom Type
194
220
  * @param params - Parameters to filter, sort, and paginate results
195
221
  *
196
222
  * @returns The composable payload {@link ClientComposableReturnType}
223
+ *
197
224
  * @see Underlying `@prismicio/client` method {@link Client.getSingle}
198
225
  */
199
226
  export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
@@ -210,11 +237,14 @@ export const useSinglePrismicDocument = <TDocument extends PrismicDocument>(
210
237
  *
211
238
  * @remarks
212
239
  * An additional `@prismicio/client` instance can be provided at `params.client`.
240
+ *
213
241
  * @typeParam TDocument - Type of Prismic documents returned
242
+ *
214
243
  * @param documentType - The API ID of the Custom Type
215
244
  * @param params - Parameters to filter, sort, and paginate results
216
245
  *
217
246
  * @returns The composable payload {@link ClientComposableReturnType}
247
+ *
218
248
  * @see Underlying `@prismicio/client` method {@link Client.getByType}
219
249
  */
220
250
  export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
@@ -231,11 +261,14 @@ export const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(
231
261
  *
232
262
  * @remarks
233
263
  * An additional `@prismicio/client` instance can be provided at `params.client`.
264
+ *
234
265
  * @typeParam TDocument - Type of Prismic documents returned
266
+ *
235
267
  * @param documentType - The API ID of the Custom Type
236
268
  * @param params - Parameters to filter and sort results
237
269
  *
238
270
  * @returns The composable payload {@link ClientComposableReturnType}
271
+ *
239
272
  * @see Underlying `@prismicio/client` method {@link Client.getAllByType}
240
273
  */
241
274
  export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
@@ -252,11 +285,14 @@ export const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(
252
285
  *
253
286
  * @remarks
254
287
  * An additional `@prismicio/client` instance can be provided at `params.client`.
288
+ *
255
289
  * @typeParam TDocument - Type of Prismic documents returned
290
+ *
256
291
  * @param tag - The tag that must be included on a document
257
292
  * @param params - Parameters to filter, sort, and paginate results
258
293
  *
259
294
  * @returns The composable payload {@link ClientComposableReturnType}
295
+ *
260
296
  * @see Underlying `@prismicio/client` method {@link Client.getByTag}
261
297
  */
262
298
  export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
@@ -273,11 +309,14 @@ export const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(
273
309
  *
274
310
  * @remarks
275
311
  * An additional `@prismicio/client` instance can be provided at `params.client`.
312
+ *
276
313
  * @typeParam TDocument - Type of Prismic documents returned
314
+ *
277
315
  * @param tag - The tag that must be included on a document
278
316
  * @param params - Parameters to filter and sort results
279
317
  *
280
318
  * @returns The composable payload {@link ClientComposableReturnType}
319
+ *
281
320
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}
282
321
  */
283
322
  export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
@@ -295,11 +334,14 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
295
334
  *
296
335
  * @remarks
297
336
  * An additional `@prismicio/client` instance can be provided at `params.client`.
337
+ *
298
338
  * @typeParam TDocument - Type of Prismic documents returned
339
+ *
299
340
  * @param tags - A list of tags that must be included on a document
300
341
  * @param params - Parameters to filter, sort, and paginate results
301
342
  *
302
343
  * @returns The composable payload {@link ClientComposableReturnType}
344
+ *
303
345
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
304
346
  */
305
347
  export const usePrismicDocumentsByEveryTag = <
@@ -319,11 +361,14 @@ export const usePrismicDocumentsByEveryTag = <
319
361
  *
320
362
  * @remarks
321
363
  * An additional `@prismicio/client` instance can be provided at `params.client`.
364
+ *
322
365
  * @typeParam TDocument - Type of Prismic documents returned
366
+ *
323
367
  * @param tags - A list of tags that must be included on a document
324
368
  * @param params - Parameters to filter and sort results
325
369
  *
326
370
  * @returns The composable payload {@link ClientComposableReturnType}
371
+ *
327
372
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
328
373
  */
329
374
  export const useAllPrismicDocumentsByEveryTag = <
@@ -343,11 +388,14 @@ export const useAllPrismicDocumentsByEveryTag = <
343
388
  *
344
389
  * @remarks
345
390
  * An additional `@prismicio/client` instance can be provided at `params.client`.
391
+ *
346
392
  * @typeParam TDocument - Type of Prismic documents returned
393
+ *
347
394
  * @param tags - A list of tags that must be included on a document
348
395
  * @param params - Parameters to filter, sort, and paginate results
349
396
  *
350
397
  * @returns The composable payload {@link ClientComposableReturnType}
398
+ *
351
399
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
352
400
  */
353
401
  export const usePrismicDocumentsBySomeTags = <
@@ -368,11 +416,14 @@ export const usePrismicDocumentsBySomeTags = <
368
416
  *
369
417
  * @remarks
370
418
  * An additional `@prismicio/client` instance can be provided at `params.client`.
419
+ *
371
420
  * @typeParam TDocument - Type of Prismic documents returned
421
+ *
372
422
  * @param tags - A list of tags that must be included on a document
373
423
  * @param params - Parameters to filter and sort results
374
424
  *
375
425
  * @returns The composable payload {@link ClientComposableReturnType}
426
+ *
376
427
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
377
428
  */
378
429
  export const useAllPrismicDocumentsBySomeTags = <
@@ -396,10 +447,13 @@ export const useAllPrismicDocumentsBySomeTags = <
396
447
  *
397
448
  * @remarks
398
449
  * An additional `@prismicio/client` instance can be provided at `params.client`.
450
+ *
399
451
  * @typeParam TDocument - Type of Prismic documents returned
452
+ *
400
453
  * @param params - Parameters to filter and sort results
401
454
  *
402
455
  * @returns The composable payload {@link ClientComposableReturnType}
456
+ *
403
457
  * @see Underlying `@prismicio/client` method {@link Client.getAll}
404
458
  */
405
459
  export const dangerouslyUseAllPrismicDocuments = <
@@ -9,10 +9,13 @@ import {
9
9
  FetchLike,
10
10
  } from "@prismicio/client";
11
11
  import {
12
- asDate,
12
+ asText,
13
13
  asHTML,
14
14
  asLink,
15
- asText,
15
+ asDate,
16
+ asImageSrc,
17
+ asImageWidthSrcSet,
18
+ asImagePixelDensitySrcSet,
16
19
  documentToLinkField,
17
20
  } from "@prismicio/helpers";
18
21
 
@@ -38,6 +41,7 @@ import type {
38
41
  * @param options - {@link PrismicPluginOptions}
39
42
  *
40
43
  * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}
44
+ *
41
45
  * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}
42
46
  * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}
43
47
  */
@@ -97,7 +101,9 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
97
101
  return asLink(linkField, linkResolver || options.linkResolver);
98
102
  },
99
103
  asDate,
100
-
104
+ asImageSrc,
105
+ asImageWidthSrcSet,
106
+ asImagePixelDensitySrcSet,
101
107
  documentToLinkField,
102
108
  };
103
109
 
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export { usePrismic } from "./usePrismic";
3
3
 
4
4
  export {
5
5
  // Composables
6
+ usePrismicImage,
6
7
  usePrismicLink,
7
8
  usePrismicText,
8
9
  usePrismicRichText,
@@ -15,12 +16,13 @@ export {
15
16
  // Slice Zone
16
17
  getSliceComponentProps,
17
18
  TODOSliceComponent,
18
- getSliceZoneComponents,
19
+ defineSliceZoneComponents,
19
20
  SliceZoneImpl,
20
21
  SliceZone,
21
22
  } from "./components";
22
23
  export type {
23
24
  // Composables
25
+ UsePrismicImageOptions,
24
26
  UsePrismicLinkOptions,
25
27
  UsePrismicTextOptions,
26
28
  UsePrismicRichTextOptions,
@@ -36,6 +38,7 @@ export type {
36
38
  SliceComponentType,
37
39
  SliceLike,
38
40
  SliceZoneComponents,
41
+ SliceZoneResolver,
39
42
  SliceZoneLike,
40
43
  SliceZoneProps,
41
44
  } from "./components";
@@ -9,6 +9,7 @@ import { ConcreteComponent, Slots, VNode } from "vue";
9
9
  * @param defaultParams - The parameters to provide to the default slot
10
10
  *
11
11
  * @returns The appropriate slots object/array
12
+ *
12
13
  * @internal
13
14
  */
14
15
  export const getSlots = (
@@ -7,6 +7,7 @@ import { ConcreteComponent, resolveDynamicComponent, VNode } from "vue";
7
7
  * @param component - An HTML tag name, a component, or a functional component
8
8
  *
9
9
  * @returns Resolved component as a {@link VNode} or provided `string`.
10
+ *
10
11
  * @internal
11
12
  */
12
13
  export const simplyResolveComponent = (
package/src/types.ts CHANGED
@@ -15,6 +15,9 @@ import type {
15
15
  HTMLFunctionSerializer,
16
16
  HTMLMapSerializer,
17
17
  LinkResolverFunction,
18
+ asImageSrc,
19
+ asImageWidthSrcSet,
20
+ asImagePixelDensitySrcSet,
18
21
  } from "@prismicio/helpers";
19
22
 
20
23
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -25,6 +28,7 @@ import type { RouterLink } from "vue-router";
25
28
 
26
29
  import type {
27
30
  SliceComponentProps,
31
+ SliceComponentType,
28
32
  TODOSliceComponent,
29
33
  } from "./components/SliceZone";
30
34
 
@@ -88,9 +92,10 @@ type PrismicPluginComponentsOptions = {
88
92
  *
89
93
  * @remarks
90
94
  * Components will be rendered using the {@link SliceComponentProps} interface.
95
+ *
91
96
  * @defaultValue `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}
92
97
  */
93
- sliceZoneDefaultComponent?: string | ConcreteComponent;
98
+ sliceZoneDefaultComponent?: SliceComponentType;
94
99
  };
95
100
 
96
101
  /**
@@ -307,6 +312,26 @@ export type PrismicPluginHelpers = {
307
312
  */
308
313
  asDate: typeof asDate;
309
314
 
315
+ /**
316
+ * Returns the URL of an Image field with optional image transformations (via
317
+ * Imgix URL parameters). This is `@prismicio/helpers` {@link asImageSrc} function.
318
+ */
319
+ asImageSrc: typeof asImageSrc;
320
+
321
+ /**
322
+ * Creates a width-based `srcset` from an Image field with optional image
323
+ * transformations (via Imgix URL parameters). This is `@prismicio/helpers`
324
+ * {@link asImageWidthSrcSet} function.
325
+ */
326
+ asImageWidthSrcSet: typeof asImageWidthSrcSet;
327
+
328
+ /**
329
+ * Creates a pixel-density-based `srcset` from an Image field with optional
330
+ * image transformations (via Imgix URL parameters). This is
331
+ * `@prismicio/helpers` {@link asImagePixelDensitySrcSet} function.
332
+ */
333
+ asImagePixelDensitySrcSet: typeof asImagePixelDensitySrcSet;
334
+
310
335
  /**
311
336
  * Converts a document into a link field. This is `@prismicio/helpers`
312
337
  * {@link documentToLinkField} function.
@@ -91,10 +91,12 @@ const isParams = (
91
91
  * @typeParam TClientMethodName - A method name from `@prismicio/client`
92
92
  * @typeParam TClientMethodArguments - The method expected arguments
93
93
  * @typeParam TClientMethodReturnType - The method expected return type
94
+ *
94
95
  * @param method - The `@prismicio/client` method name to use
95
96
  * @param args - The arguments to use with requested method
96
97
  *
97
98
  * @returns The composable payload {@link ClientComposableReturnType}
99
+ *
98
100
  * @internal
99
101
  */
100
102
  export const useStatefulPrismicClientMethod = <
@@ -16,9 +16,17 @@
16
16
  "type": "string | object | function",
17
17
  "description": "An HTML tag name, a component, or a functional component used to render images. Defaults to the one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise."
18
18
  },
19
- "prismic-image/image-component-additional-props": {
19
+ "prismic-image/imgix-params": {
20
20
  "type": "object",
21
- "description": "A map of additional props to pass to the component used to render images when using one."
21
+ "description": "An object of Imgix URL API parameters."
22
+ },
23
+ "prismic-image/widths": {
24
+ "type": "array | string",
25
+ "description": "Adds an additional `srcset` attribute to the image following given widths."
26
+ },
27
+ "prismic-image/pixel-densities": {
28
+ "type": "array | string",
29
+ "description": "Adds an additional `srcset` attribute to the image following giving pixel densities."
22
30
  },
23
31
 
24
32
  "prismic-link/field": {
package/vetur/tags.json CHANGED
@@ -7,7 +7,9 @@
7
7
  "attributes": [
8
8
  "field",
9
9
  "image-component",
10
- "image-component-additional-props"
10
+ "imgix-params",
11
+ "widths",
12
+ "pixel-densities"
11
13
  ],
12
14
  "description": "Component to render a Prismic image field."
13
15
  },