@prismicio/vue 3.0.0-beta.2 → 3.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -243,82 +243,6 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
243
243
  */
244
244
  wrapper?: string | ConcreteComponent;
245
245
  };
246
- /**
247
- * `<SliceZone />` implementation.
248
- *
249
- * @internal
250
- */
251
- declare const SliceZoneImpl: DefineComponent<{
252
- slices: {
253
- type: PropType<SliceZoneLike<SliceLike<string>>>;
254
- required: true;
255
- };
256
- components: {
257
- type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
258
- default: undefined;
259
- required: false;
260
- };
261
- resolver: {
262
- type: PropType<SliceZoneResolver<SliceLike<string>, unknown>>;
263
- default: undefined;
264
- required: false;
265
- };
266
- context: {
267
- type: null;
268
- default: undefined;
269
- required: false;
270
- };
271
- defaultComponent: {
272
- type: PropType<SliceComponentType<SliceLike<string>, unknown>>;
273
- default: undefined;
274
- required: false;
275
- };
276
- wrapper: {
277
- type: PropType<string | ConcreteComponent<{}, any, any, vue.ComputedOptions, vue.MethodOptions>>;
278
- default: undefined;
279
- required: false;
280
- };
281
- }, (() => null) | (() => vue.VNode<vue.RendererNode, vue.RendererElement, {
282
- [key: string]: any;
283
- }> | vue.VNode<vue.RendererNode, vue.RendererElement, {
284
- [key: string]: any;
285
- }>[]), unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
286
- slices: {
287
- type: PropType<SliceZoneLike<SliceLike<string>>>;
288
- required: true;
289
- };
290
- components: {
291
- type: PropType<SliceZoneComponents<SliceLike<string>, unknown>>;
292
- default: undefined;
293
- required: false;
294
- };
295
- resolver: {
296
- type: PropType<SliceZoneResolver<SliceLike<string>, unknown>>;
297
- default: undefined;
298
- required: false;
299
- };
300
- context: {
301
- type: null;
302
- default: undefined;
303
- required: false;
304
- };
305
- defaultComponent: {
306
- type: PropType<SliceComponentType<SliceLike<string>, unknown>>;
307
- default: undefined;
308
- required: false;
309
- };
310
- wrapper: {
311
- type: PropType<string | ConcreteComponent<{}, any, any, vue.ComputedOptions, vue.MethodOptions>>;
312
- default: undefined;
313
- required: false;
314
- };
315
- }>>, {
316
- wrapper: string | ConcreteComponent<{}, any, any, vue.ComputedOptions, vue.MethodOptions>;
317
- context: any;
318
- components: SliceZoneComponents<SliceLike<string>, unknown>;
319
- resolver: SliceZoneResolver<SliceLike<string>, unknown>;
320
- defaultComponent: SliceComponentType<SliceLike<string>, unknown>;
321
- }>;
322
246
  /**
323
247
  * Component to render a Prismic Slice Zone.
324
248
  *
@@ -375,6 +299,23 @@ declare type PrismicPluginComponentsOptions = {
375
299
  * @defaultValue `"img"`
376
300
  */
377
301
  imageComponent?: string | ConcreteComponent;
302
+ /**
303
+ * Default widths to use when rendering an image with `widths="defaults"`
304
+ *
305
+ * @remarks
306
+ * Consider configuring image widths within your content type definition and
307
+ * using `widths="auto"` instead to give content writers the ability to crop
308
+ * images in the editor.
309
+ * @defaultValue `@prismicio/helpers` defaults
310
+ */
311
+ imageWidthSrcSetDefaults?: number[];
312
+ /**
313
+ * Default pixel densities to use when rendering an image with
314
+ * `pixel-densities="defaults"`
315
+ *
316
+ * @defaultValue `@prismicio/helpers` defaults
317
+ */
318
+ imagePixelDensitySrcSetDefaults?: number[];
378
319
  /**
379
320
  * A component or a functional component rendered if a component mapping from
380
321
  * the `components` prop cannot be found.
@@ -740,7 +681,7 @@ declare type PrismicImageProps = {
740
681
  * coming from the API.
741
682
  * @remarks
742
683
  * A special value of `"defaults"` is accepted to automatically use image
743
- * widths coming from `@prismicio/helpers`
684
+ * widths coming from the plugin configuration.
744
685
  * @remarks
745
686
  * This prop is not compatible with the `pixelDensities` prop. When both are
746
687
  * used the `pixelDensities` prop will be ignored.
@@ -751,7 +692,7 @@ declare type PrismicImageProps = {
751
692
  *
752
693
  * @remarks
753
694
  * A special value of `"defaults"` is accepted to automatically use image
754
- * pixel densities coming from `@prismicio/helpers`
695
+ * pixel densities coming from the plugin configuration.
755
696
  * @remarks
756
697
  * This prop is not compatible with the `widths` prop. When both are used, the
757
698
  * `pixelDensities` prop will be ignored.
@@ -1517,4 +1458,4 @@ declare module "@vue/runtime-core" {
1517
1458
  }
1518
1459
  }
1519
1460
 
1520
- export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceZone, SliceZoneComponents, SliceZoneImpl, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
1461
+ export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getEndpoint, createClient, predicate, cookie } from '@prismicio/client';
1
+ import { createClient, predicate, cookie } from '@prismicio/client';
2
2
  import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet, asImageSrc, asLink, asText, asHTML, asDate, documentToLinkField } from '@prismicio/helpers';
3
3
  import { resolveDynamicComponent, defineComponent, h, inject, computed, unref, reactive, ref, watch, nextTick, onBeforeUnmount, watchEffect, markRaw, shallowRef, isRef } from 'vue';
4
4
  import { routerKey } from 'vue-router';
@@ -45,7 +45,9 @@ const usePrismic = () => {
45
45
 
46
46
  const defaultImageComponent = "img";
47
47
  const usePrismicImage = (props) => {
48
+ const { options } = usePrismic();
48
49
  const asImage = computed(() => {
50
+ var _a, _b;
49
51
  const field = unref(props.field);
50
52
  if (!isFilled.image(field)) {
51
53
  return {
@@ -66,13 +68,13 @@ const usePrismicImage = (props) => {
66
68
  const { url, dimensions, alt: alt2, copyright: copyright2 } = field;
67
69
  return asImageWidthSrcSet({ url, dimensions, alt: alt2, copyright: copyright2 }, {
68
70
  ...imgixParams,
69
- widths: widths === "defaults" ? void 0 : widths
71
+ widths: widths === "defaults" ? (_a = options.components) == null ? void 0 : _a.imageWidthSrcSetDefaults : widths
70
72
  });
71
73
  }
72
74
  } else if (pixelDensities) {
73
75
  return asImagePixelDensitySrcSet(field, {
74
76
  ...imgixParams,
75
- pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
77
+ pixelDensities: pixelDensities === "defaults" ? (_b = options.components) == null ? void 0 : _b.imagePixelDensitySrcSetDefaults : pixelDensities
76
78
  });
77
79
  } else {
78
80
  return {
@@ -437,7 +439,7 @@ const getSliceComponentProps = (propsHint) => ({
437
439
  }
438
440
  });
439
441
  const TODOSliceComponent = __PRODUCTION__ ? () => null : /* @__PURE__ */ defineComponent({
440
- name: "TODOSliceCOmponent",
442
+ name: "TODOSliceComponent",
441
443
  props: getSliceComponentProps(),
442
444
  setup(props) {
443
445
  watchEffect(() => {
@@ -545,23 +547,18 @@ const createPrismic = (options) => {
545
547
  if (options.client) {
546
548
  client = options.client;
547
549
  } else {
548
- const endpoint = /^(https?:)?\/\//gim.test(options.endpoint) ? options.endpoint : getEndpoint(options.endpoint);
549
- if (options.clientConfig && typeof options.clientConfig.fetch === "function") {
550
- client = createClient(endpoint, options.clientConfig);
551
- } else {
552
- client = createClient(endpoint, {
553
- ...options.clientConfig,
554
- fetch: async (endpoint2, options2) => {
555
- let fetchFunction;
556
- if (typeof globalThis.fetch === "function") {
557
- fetchFunction = globalThis.fetch;
558
- } else {
559
- fetchFunction = (await import('isomorphic-unfetch')).default;
560
- }
561
- return await fetchFunction(endpoint2, options2);
550
+ client = createClient(options.endpoint, {
551
+ fetch: async (endpoint, options2) => {
552
+ let fetchFunction;
553
+ if (typeof globalThis.fetch === "function") {
554
+ fetchFunction = globalThis.fetch;
555
+ } else {
556
+ fetchFunction = (await import('isomorphic-unfetch')).default;
562
557
  }
563
- });
564
- }
558
+ return await fetchFunction(endpoint, options2);
559
+ },
560
+ ...options.clientConfig
561
+ });
565
562
  }
566
563
  const prismicClient = {
567
564
  client,
@@ -660,5 +657,5 @@ const usePrismicDocumentsBySomeTags = (...args) => useStatefulPrismicClientMetho
660
657
  const useAllPrismicDocumentsBySomeTags = (...args) => useStatefulPrismicClientMethod("getAllBySomeTags", args);
661
658
  const dangerouslyUseAllPrismicDocuments = (...args) => useStatefulPrismicClientMethod("dangerouslyGetAll", args);
662
659
 
663
- export { PrismicClientComposableState, PrismicEmbed, PrismicImage, PrismicLink, PrismicRichText, PrismicText, SliceZone, SliceZoneImpl, TODOSliceComponent, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
660
+ export { PrismicClientComposableState, PrismicEmbed, PrismicImage, PrismicLink, PrismicRichText, PrismicText, SliceZone, TODOSliceComponent, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
664
661
  //# sourceMappingURL=index.js.map