@prismicio/vue 4.3.1 → 5.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.
Files changed (242) hide show
  1. package/README.md +4 -4
  2. package/dist/PrismicEmbed.vue.cjs +25 -0
  3. package/dist/PrismicEmbed.vue.cjs.map +1 -0
  4. package/dist/PrismicEmbed.vue.d.ts +19 -0
  5. package/dist/PrismicEmbed.vue.js +26 -0
  6. package/dist/PrismicEmbed.vue.js.map +1 -0
  7. package/dist/PrismicEmbed.vue2.cjs +4 -0
  8. package/dist/PrismicEmbed.vue2.cjs.map +1 -0
  9. package/dist/PrismicEmbed.vue2.js +5 -0
  10. package/dist/PrismicEmbed.vue2.js.map +1 -0
  11. package/dist/PrismicImage.vue.cjs +84 -0
  12. package/dist/PrismicImage.vue.cjs.map +1 -0
  13. package/dist/PrismicImage.vue.d.ts +224 -0
  14. package/dist/PrismicImage.vue.js +85 -0
  15. package/dist/PrismicImage.vue.js.map +1 -0
  16. package/dist/PrismicImage.vue2.cjs +4 -0
  17. package/dist/PrismicImage.vue2.cjs.map +1 -0
  18. package/dist/PrismicImage.vue2.js +5 -0
  19. package/dist/PrismicImage.vue2.js.map +1 -0
  20. package/dist/PrismicLink.vue.cjs +100 -0
  21. package/dist/PrismicLink.vue.cjs.map +1 -0
  22. package/dist/PrismicLink.vue.d.ts +279 -0
  23. package/dist/PrismicLink.vue.js +101 -0
  24. package/dist/PrismicLink.vue.js.map +1 -0
  25. package/dist/PrismicLink.vue2.cjs +4 -0
  26. package/dist/PrismicLink.vue2.cjs.map +1 -0
  27. package/dist/PrismicLink.vue2.js +5 -0
  28. package/dist/PrismicLink.vue2.js.map +1 -0
  29. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs +90 -0
  30. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs.map +1 -0
  31. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.d.ts +8 -0
  32. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js +91 -0
  33. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js.map +1 -0
  34. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs +4 -0
  35. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs.map +1 -0
  36. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js +5 -0
  37. package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js.map +1 -0
  38. package/dist/PrismicRichText/PrismicRichText.vue.cjs +85 -0
  39. package/dist/PrismicRichText/PrismicRichText.vue.cjs.map +1 -0
  40. package/dist/PrismicRichText/PrismicRichText.vue.d.ts +57 -0
  41. package/dist/PrismicRichText/PrismicRichText.vue.js +86 -0
  42. package/dist/PrismicRichText/PrismicRichText.vue.js.map +1 -0
  43. package/dist/PrismicRichText/PrismicRichText.vue2.cjs +4 -0
  44. package/dist/PrismicRichText/PrismicRichText.vue2.cjs.map +1 -0
  45. package/dist/PrismicRichText/PrismicRichText.vue2.js +5 -0
  46. package/dist/PrismicRichText/PrismicRichText.vue2.js.map +1 -0
  47. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs +133 -0
  48. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs.map +1 -0
  49. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.d.ts +37 -0
  50. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js +134 -0
  51. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js.map +1 -0
  52. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs +4 -0
  53. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs.map +1 -0
  54. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js +5 -0
  55. package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js.map +1 -0
  56. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs +47 -0
  57. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs.map +1 -0
  58. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.d.ts +10 -0
  59. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js +48 -0
  60. package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js.map +1 -0
  61. package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs +4 -0
  62. package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs.map +1 -0
  63. package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js +5 -0
  64. package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js.map +1 -0
  65. package/dist/PrismicRichText/getRichTextComponentProps.cjs +10 -0
  66. package/dist/PrismicRichText/getRichTextComponentProps.cjs.map +1 -0
  67. package/dist/PrismicRichText/getRichTextComponentProps.d.ts +49 -0
  68. package/dist/PrismicRichText/getRichTextComponentProps.js +10 -0
  69. package/dist/PrismicRichText/getRichTextComponentProps.js.map +1 -0
  70. package/dist/PrismicRichText/index.d.ts +2 -0
  71. package/dist/PrismicRichText/types.d.ts +22 -0
  72. package/dist/PrismicText.vue.cjs +43 -0
  73. package/dist/PrismicText.vue.cjs.map +1 -0
  74. package/dist/PrismicText.vue.d.ts +31 -0
  75. package/dist/PrismicText.vue.js +44 -0
  76. package/dist/PrismicText.vue.js.map +1 -0
  77. package/dist/PrismicText.vue2.cjs +4 -0
  78. package/dist/PrismicText.vue2.cjs.map +1 -0
  79. package/dist/PrismicText.vue2.js +5 -0
  80. package/dist/PrismicText.vue2.js.map +1 -0
  81. package/dist/SliceZone/SliceZone.vue.cjs +63 -0
  82. package/dist/SliceZone/SliceZone.vue.cjs.map +1 -0
  83. package/dist/SliceZone/SliceZone.vue.d.ts +41 -0
  84. package/dist/SliceZone/SliceZone.vue.js +64 -0
  85. package/dist/SliceZone/SliceZone.vue.js.map +1 -0
  86. package/dist/SliceZone/SliceZone.vue2.cjs +4 -0
  87. package/dist/SliceZone/SliceZone.vue2.cjs.map +1 -0
  88. package/dist/SliceZone/SliceZone.vue2.js +5 -0
  89. package/dist/SliceZone/SliceZone.vue2.js.map +1 -0
  90. package/dist/SliceZone/TODOSliceComponent.cjs +29 -0
  91. package/dist/SliceZone/TODOSliceComponent.cjs.map +1 -0
  92. package/dist/SliceZone/TODOSliceComponent.d.ts +9 -0
  93. package/dist/SliceZone/TODOSliceComponent.js +29 -0
  94. package/dist/SliceZone/TODOSliceComponent.js.map +1 -0
  95. package/dist/SliceZone/defineSliceZoneComponents.cjs +14 -0
  96. package/dist/SliceZone/defineSliceZoneComponents.cjs.map +1 -0
  97. package/dist/SliceZone/defineSliceZoneComponents.d.ts +36 -0
  98. package/dist/SliceZone/defineSliceZoneComponents.js +14 -0
  99. package/dist/SliceZone/defineSliceZoneComponents.js.map +1 -0
  100. package/dist/SliceZone/getSliceComponentProps.cjs +22 -0
  101. package/dist/SliceZone/getSliceComponentProps.cjs.map +1 -0
  102. package/dist/SliceZone/getSliceComponentProps.d.ts +66 -0
  103. package/dist/SliceZone/getSliceComponentProps.js +22 -0
  104. package/dist/SliceZone/getSliceComponentProps.js.map +1 -0
  105. package/dist/SliceZone/index.d.ts +4 -0
  106. package/dist/SliceZone/types.d.ts +97 -0
  107. package/dist/createPrismic.cjs +17 -50
  108. package/dist/createPrismic.cjs.map +1 -1
  109. package/dist/createPrismic.d.ts +10 -0
  110. package/dist/createPrismic.js +16 -27
  111. package/dist/createPrismic.js.map +1 -1
  112. package/dist/index.cjs +21 -40
  113. package/dist/index.cjs.map +1 -1
  114. package/dist/index.d.ts +19 -9
  115. package/dist/index.js +19 -38
  116. package/dist/index.js.map +1 -1
  117. package/dist/lib/Wrapper.vue.cjs +20 -0
  118. package/dist/lib/Wrapper.vue.cjs.map +1 -0
  119. package/dist/lib/Wrapper.vue.d.ts +28 -0
  120. package/dist/lib/Wrapper.vue.js +21 -0
  121. package/dist/lib/Wrapper.vue.js.map +1 -0
  122. package/dist/lib/Wrapper.vue2.cjs +4 -0
  123. package/dist/lib/Wrapper.vue2.cjs.map +1 -0
  124. package/dist/lib/Wrapper.vue2.js +5 -0
  125. package/dist/lib/Wrapper.vue2.js.map +1 -0
  126. package/dist/lib/devMsg.cjs +8 -0
  127. package/dist/lib/devMsg.cjs.map +1 -0
  128. package/dist/lib/devMsg.d.ts +16 -0
  129. package/dist/lib/devMsg.js +8 -0
  130. package/dist/lib/devMsg.js.map +1 -0
  131. package/dist/package.json.cjs +5 -0
  132. package/dist/package.json.cjs.map +1 -0
  133. package/dist/package.json.js +5 -0
  134. package/dist/package.json.js.map +1 -0
  135. package/dist/types.d.ts +32 -56
  136. package/dist/usePrismic.cjs +3 -2
  137. package/dist/usePrismic.cjs.map +1 -1
  138. package/dist/usePrismic.d.ts +8 -0
  139. package/dist/usePrismic.js +2 -1
  140. package/dist/usePrismic.js.map +1 -1
  141. package/package.json +21 -23
  142. package/src/PrismicEmbed.vue +42 -0
  143. package/src/PrismicImage.vue +160 -0
  144. package/src/PrismicLink.vue +191 -0
  145. package/src/PrismicRichText/DeprecatedPrismicRichText.vue +130 -0
  146. package/src/PrismicRichText/PrismicRichText.vue +157 -0
  147. package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +63 -0
  148. package/src/PrismicRichText/PrismicRichTextSerialize.vue +52 -0
  149. package/src/PrismicRichText/getRichTextComponentProps.ts +63 -0
  150. package/src/PrismicRichText/index.ts +3 -0
  151. package/src/PrismicRichText/types.ts +37 -0
  152. package/src/PrismicText.vue +63 -0
  153. package/src/SliceZone/SliceZone.vue +113 -0
  154. package/src/SliceZone/TODOSliceComponent.ts +49 -0
  155. package/src/SliceZone/defineSliceZoneComponents.ts +67 -0
  156. package/src/SliceZone/getSliceComponentProps.ts +98 -0
  157. package/src/SliceZone/index.ts +13 -0
  158. package/src/SliceZone/types.ts +163 -0
  159. package/src/createPrismic.ts +28 -33
  160. package/src/index.ts +32 -57
  161. package/src/lib/Wrapper.vue +22 -0
  162. package/src/lib/devMsg.ts +20 -0
  163. package/src/types.ts +39 -66
  164. package/src/usePrismic.ts +8 -1
  165. package/dist/components/PrismicEmbed.cjs +0 -36
  166. package/dist/components/PrismicEmbed.cjs.map +0 -1
  167. package/dist/components/PrismicEmbed.d.ts +0 -59
  168. package/dist/components/PrismicEmbed.js +0 -36
  169. package/dist/components/PrismicEmbed.js.map +0 -1
  170. package/dist/components/PrismicImage.cjs +0 -122
  171. package/dist/components/PrismicImage.cjs.map +0 -1
  172. package/dist/components/PrismicImage.d.ts +0 -165
  173. package/dist/components/PrismicImage.js +0 -122
  174. package/dist/components/PrismicImage.js.map +0 -1
  175. package/dist/components/PrismicLink.cjs +0 -120
  176. package/dist/components/PrismicLink.cjs.map +0 -1
  177. package/dist/components/PrismicLink.d.ts +0 -198
  178. package/dist/components/PrismicLink.js +0 -120
  179. package/dist/components/PrismicLink.js.map +0 -1
  180. package/dist/components/PrismicRichText.cjs +0 -108
  181. package/dist/components/PrismicRichText.cjs.map +0 -1
  182. package/dist/components/PrismicRichText.d.ts +0 -161
  183. package/dist/components/PrismicRichText.js +0 -108
  184. package/dist/components/PrismicRichText.js.map +0 -1
  185. package/dist/components/PrismicText.cjs +0 -57
  186. package/dist/components/PrismicText.cjs.map +0 -1
  187. package/dist/components/PrismicText.d.ts +0 -119
  188. package/dist/components/PrismicText.js +0 -57
  189. package/dist/components/PrismicText.js.map +0 -1
  190. package/dist/components/SliceZone.cjs +0 -156
  191. package/dist/components/SliceZone.cjs.map +0 -1
  192. package/dist/components/SliceZone.d.ts +0 -377
  193. package/dist/components/SliceZone.js +0 -156
  194. package/dist/components/SliceZone.js.map +0 -1
  195. package/dist/components/index.d.ts +0 -12
  196. package/dist/composables.cjs +0 -40
  197. package/dist/composables.cjs.map +0 -1
  198. package/dist/composables.d.ts +0 -348
  199. package/dist/composables.js +0 -40
  200. package/dist/composables.js.map +0 -1
  201. package/dist/globalExtensions.d.ts +0 -11
  202. package/dist/injectionSymbols.cjs +0 -5
  203. package/dist/injectionSymbols.cjs.map +0 -1
  204. package/dist/injectionSymbols.d.ts +0 -9
  205. package/dist/injectionSymbols.js +0 -5
  206. package/dist/injectionSymbols.js.map +0 -1
  207. package/dist/lib/__PRODUCTION__.cjs +0 -8
  208. package/dist/lib/__PRODUCTION__.cjs.map +0 -1
  209. package/dist/lib/__PRODUCTION__.d.ts +0 -7
  210. package/dist/lib/__PRODUCTION__.js +0 -8
  211. package/dist/lib/__PRODUCTION__.js.map +0 -1
  212. package/dist/lib/getSlots.cjs +0 -21
  213. package/dist/lib/getSlots.cjs.map +0 -1
  214. package/dist/lib/getSlots.d.ts +0 -14
  215. package/dist/lib/getSlots.js +0 -21
  216. package/dist/lib/getSlots.js.map +0 -1
  217. package/dist/lib/simplyResolveComponent.cjs +0 -8
  218. package/dist/lib/simplyResolveComponent.cjs.map +0 -1
  219. package/dist/lib/simplyResolveComponent.d.ts +0 -12
  220. package/dist/lib/simplyResolveComponent.js +0 -8
  221. package/dist/lib/simplyResolveComponent.js.map +0 -1
  222. package/dist/useStatefulPrismicClientMethod.cjs +0 -39
  223. package/dist/useStatefulPrismicClientMethod.cjs.map +0 -1
  224. package/dist/useStatefulPrismicClientMethod.d.ts +0 -65
  225. package/dist/useStatefulPrismicClientMethod.js +0 -39
  226. package/dist/useStatefulPrismicClientMethod.js.map +0 -1
  227. package/src/components/PrismicEmbed.ts +0 -90
  228. package/src/components/PrismicImage.ts +0 -307
  229. package/src/components/PrismicLink.ts +0 -324
  230. package/src/components/PrismicRichText.ts +0 -283
  231. package/src/components/PrismicText.ts +0 -165
  232. package/src/components/SliceZone.ts +0 -617
  233. package/src/components/index.ts +0 -42
  234. package/src/composables.ts +0 -492
  235. package/src/globalExtensions.ts +0 -12
  236. package/src/injectionSymbols.ts +0 -17
  237. package/src/lib/__PRODUCTION__.ts +0 -12
  238. package/src/lib/getSlots.ts +0 -43
  239. package/src/lib/simplyResolveComponent.ts +0 -18
  240. package/src/useStatefulPrismicClientMethod.ts +0 -158
  241. package/vetur/attributes.json +0 -113
  242. package/vetur/tags.json +0 -60
@@ -1,165 +0,0 @@
1
- import type { ImageField } from "@prismicio/client";
2
- import { asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet } from "@prismicio/client";
3
- import type { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
4
- import type { VueUseOptions } from "../types";
5
- /**
6
- * Props for `<PrismicImage />`.
7
- */
8
- export type PrismicImageProps = {
9
- /**
10
- * The Prismic image field to render.
11
- */
12
- field: ImageField | ImageField<string>;
13
- /**
14
- * An HTML tag name, a component, or a functional component used to render
15
- * images.
16
- *
17
- * @remarks
18
- * HTML tag names and components will be rendered using the `img` tag
19
- * interface (`src`, `srcset`, and `alt` attribute). Components will also
20
- * receive an additional `copyright` props.
21
- *
22
- * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `"img"` otherwise.
23
- */
24
- imageComponent?: string | ConcreteComponent | Raw<DefineComponent>;
25
- /**
26
- * An object of Imgix URL API parameters.
27
- *
28
- * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
29
- */
30
- imgixParams?: Parameters<typeof asImageSrc>[1];
31
- /**
32
- * Adds an additional `srcset` attribute to the image following given widths.
33
- *
34
- * @remarks
35
- * A special value of `"thumbnails"` is accepted to automatically use image
36
- * widths coming from the API.
37
- * @remarks
38
- * A special value of `"defaults"` is accepted to automatically use image
39
- * widths coming from the plugin configuration.
40
- * @remarks
41
- * This prop is not compatible with the `pixelDensities` prop. When both are
42
- * used the `pixelDensities` prop will be ignored.
43
- */
44
- widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
45
- /**
46
- * Adds an additional `srcset` attribute to the image following giving pixel
47
- * densities.
48
- *
49
- * @remarks
50
- * A special value of `"defaults"` is accepted to automatically use image
51
- * pixel densities coming from the plugin configuration.
52
- * @remarks
53
- * This prop is not compatible with the `widths` prop. When both are used, the
54
- * `pixelDensities` prop will be ignored.
55
- */
56
- pixelDensities?: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
57
- };
58
- /**
59
- * Options for {@link usePrismicImage}.
60
- */
61
- export type UsePrismicImageOptions = VueUseOptions<Omit<PrismicImageProps, "imageComponent">>;
62
- /**
63
- * Return type of {@link usePrismicImage}.
64
- */
65
- export type UsePrismicImageReturnType = {
66
- /**
67
- * Resolved image `src` value.
68
- */
69
- src: ComputedRef<string | null>;
70
- /**
71
- * Resolved image `srcset` value.
72
- */
73
- srcset: ComputedRef<string | null>;
74
- /**
75
- * Resolved image `alt` value.
76
- */
77
- alt: ComputedRef<string>;
78
- /**
79
- * Resolved image `copyright` value.
80
- */
81
- copyright: ComputedRef<string | null>;
82
- };
83
- /**
84
- * A low level composable that returns a resolved information about a Prismic
85
- * image field.
86
- *
87
- * @param props - {@link UsePrismicImageOptions}
88
- *
89
- * @returns - Resolved image information {@link UsePrismicImageReturnType}
90
- */
91
- export declare const usePrismicImage: (props: UsePrismicImageOptions) => UsePrismicImageReturnType;
92
- /**
93
- * `<PrismicImage />` implementation.
94
- *
95
- * @internal
96
- */
97
- export declare const PrismicImageImpl: DefineComponent<import("vue").ExtractPropTypes<{
98
- field: {
99
- type: PropType<ImageField | ImageField<string>>;
100
- required: true;
101
- };
102
- imageComponent: {
103
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
104
- default: undefined;
105
- required: false;
106
- };
107
- imgixParams: {
108
- type: PropType<Parameters<typeof asImageSrc>[1]>;
109
- default: undefined;
110
- required: false;
111
- };
112
- widths: {
113
- type: PropType<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults">;
114
- default: undefined;
115
- required: false;
116
- };
117
- pixelDensities: {
118
- type: PropType<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults">;
119
- default: undefined;
120
- required: false;
121
- };
122
- }>, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
123
- [key: string]: any;
124
- }>), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
125
- field: {
126
- type: PropType<ImageField | ImageField<string>>;
127
- required: true;
128
- };
129
- imageComponent: {
130
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
131
- default: undefined;
132
- required: false;
133
- };
134
- imgixParams: {
135
- type: PropType<Parameters<typeof asImageSrc>[1]>;
136
- default: undefined;
137
- required: false;
138
- };
139
- widths: {
140
- type: PropType<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults">;
141
- default: undefined;
142
- required: false;
143
- };
144
- pixelDensities: {
145
- type: PropType<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults">;
146
- default: undefined;
147
- required: false;
148
- };
149
- }>> & Readonly<{}>, {
150
- widths: number[] | "thumbnails" | "defaults" | undefined;
151
- pixelDensities: number[] | "defaults" | undefined;
152
- imageComponent: string | ConcreteComponent | Raw<DefineComponent>;
153
- imgixParams: import("imgix-url-builder/*").ImgixURLParams | undefined;
154
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
155
- /**
156
- * Component to render a Prismic image field.
157
- *
158
- * @see Component props {@link PrismicImageProps}
159
- * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}
160
- */
161
- export declare const PrismicImage: {
162
- new (): {
163
- $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicImageProps;
164
- };
165
- };
@@ -1,122 +0,0 @@
1
- import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet, asImageSrc } from "@prismicio/client";
2
- import { computed, unref, defineComponent, h } from "vue";
3
- import { __PRODUCTION__ } from "../lib/__PRODUCTION__.js";
4
- import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
5
- import { usePrismic } from "../usePrismic.js";
6
- const defaultImageComponent = "img";
7
- const usePrismicImage = (props) => {
8
- const { options } = usePrismic();
9
- const asImage = computed(() => {
10
- var _a, _b;
11
- const field = unref(props.field);
12
- if (!isFilled.image(field)) {
13
- return {
14
- src: null,
15
- srcset: null
16
- };
17
- }
18
- const imgixParams = unref(props.imgixParams);
19
- const widths = unref(props.widths);
20
- const pixelDensities = unref(props.pixelDensities);
21
- if (widths) {
22
- if (!__PRODUCTION__ && pixelDensities) {
23
- 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.", props);
24
- }
25
- return asImageWidthSrcSet(field, {
26
- ...imgixParams,
27
- widths: widths === "defaults" ? (_a = options.components) == null ? void 0 : _a.imageWidthSrcSetDefaults : widths
28
- });
29
- } else if (pixelDensities) {
30
- return asImagePixelDensitySrcSet(field, {
31
- ...imgixParams,
32
- pixelDensities: pixelDensities === "defaults" ? (_b = options.components) == null ? void 0 : _b.imagePixelDensitySrcSetDefaults : pixelDensities
33
- });
34
- } else {
35
- return {
36
- src: asImageSrc(field, imgixParams),
37
- srcset: null
38
- };
39
- }
40
- });
41
- const src = computed(() => {
42
- return asImage.value.src;
43
- });
44
- const srcset = computed(() => {
45
- return asImage.value.srcset;
46
- });
47
- const alt = computed(() => {
48
- return unref(props.field).alt || "";
49
- });
50
- const copyright = computed(() => {
51
- return unref(props.field).copyright || null;
52
- });
53
- return {
54
- src,
55
- srcset,
56
- alt,
57
- copyright
58
- };
59
- };
60
- const PrismicImageImpl = /* @__PURE__ */ defineComponent({
61
- name: "PrismicImage",
62
- props: {
63
- field: {
64
- type: Object,
65
- required: true
66
- },
67
- imageComponent: {
68
- type: [String, Object],
69
- default: void 0,
70
- required: false
71
- },
72
- imgixParams: {
73
- type: Object,
74
- default: void 0,
75
- required: false
76
- },
77
- widths: {
78
- type: [String, Object],
79
- default: void 0,
80
- required: false
81
- },
82
- pixelDensities: {
83
- type: [String, Object],
84
- default: void 0,
85
- required: false
86
- }
87
- },
88
- setup(props) {
89
- if (!props.field) {
90
- return () => null;
91
- }
92
- const { options } = usePrismic();
93
- const type = computed(() => {
94
- var _a;
95
- return props.imageComponent || ((_a = options.components) == null ? void 0 : _a.imageComponent) || defaultImageComponent;
96
- });
97
- const { src, srcset, alt, copyright } = usePrismicImage(props);
98
- return () => {
99
- const attributes = {
100
- src: src.value,
101
- srcset: srcset.value,
102
- alt: alt.value
103
- };
104
- switch (type.value) {
105
- case "img":
106
- return h("img", attributes);
107
- default:
108
- return h(simplyResolveComponent(type.value), {
109
- ...attributes,
110
- copyright: copyright.value
111
- });
112
- }
113
- };
114
- }
115
- });
116
- const PrismicImage = PrismicImageImpl;
117
- export {
118
- PrismicImage,
119
- PrismicImageImpl,
120
- usePrismicImage
121
- };
122
- //# sourceMappingURL=PrismicImage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrismicImage.js","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import type { ImageField } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport { computed, defineComponent, h, unref } from \"vue\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\"\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\"\n}\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>\n}\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic()\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field)\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t}\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams)\n\t\tconst widths = unref(props.widths)\n\t\tconst pixelDensities = unref(props.pixelDensities)\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\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\t\tprops,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t})\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t})\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t}\n\t\t}\n\t})\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src\n\t})\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset\n\t})\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\"\n\t})\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null\n\t})\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t}\n}\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null\n\t\t}\n\n\t\tconst { options } = usePrismic()\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t)\n\t\t})\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props)\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t}\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes)\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t})\n\t\t\t}\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps\n\t}\n}\n"],"names":[],"mappings":";;;;;AA6BA,MAAM,wBAAwB;AA2GjB,MAAA,kBAAkB,CAC9B,UAC8B;AACxB,QAAA,EAAE,QAAO,IAAK;AAEd,QAAA,UAAU,SAAS,MAAK;;AACvB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,QAAI,CAAC,SAAS,MAAM,KAAK,GAAG;AACpB,aAAA;AAAA,QACN,KAAK;AAAA,QACL,QAAQ;AAAA;;AAIJ,UAAA,cAAc,MAAM,MAAM,WAAW;AACrC,UAAA,SAAS,MAAM,MAAM,MAAM;AAC3B,UAAA,iBAAiB,MAAM,MAAM,cAAc;AAEjD,QAAI,QAAQ;AACP,UA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AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,QAAQ,MAAM;AAAA,MAMrB,SAAS;AAAA,MACT,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IAAA;AAGR,UAAA,EAAE,QAAO,IAAK;AAEd,UAAA,OAAO,SAAS,MAAK;;AAC1B,aACC,MAAM,oBACN,aAAQ,eAAR,mBAAoB,mBACpB;AAAA,IAAA,CAED;AAED,UAAM,EAAE,KAAK,QAAQ,KAAK,UAAS,IAAK,gBAAgB,KAAK;AAE7D,WAAO,MAAK;AACX,YAAM,aAAa;AAAA,QAClB,KAAK,IAAI;AAAA,QACT,QAAQ,OAAO;AAAA,QACf,KAAK,IAAI;AAAA;AAGV,cAAQ,KAAK,OAAO;AAAA,QACnB,KAAK;AAEG,iBAAA,EAAE,OAAO,UAAU;AAAA,QAE3B;AACC,iBAAO,EAAE,uBAAuB,KAAK,KAAK,GAAG;AAAA,YAC5C,GAAG;AAAA,YACH,WAAW,UAAU;AAAA,UAAA,CACrB;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,eAAe;"}
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const client = require("@prismicio/client");
4
- const vue = require("vue");
5
- const getSlots = require("../lib/getSlots.cjs");
6
- const isInternalURL = require("../lib/isInternalURL.cjs");
7
- const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
8
- const usePrismic = require("../usePrismic.cjs");
9
- const defaultInternalComponent = "router-link";
10
- const defaultExternalComponent = "a";
11
- const defaultBlankTargetRelAttribute = "noopener noreferrer";
12
- const usePrismicLink = (props) => {
13
- const { options } = usePrismic.usePrismic();
14
- const type = vue.computed(() => {
15
- var _a, _b;
16
- const internalComponent = vue.unref(props.internalComponent) || ((_a = options.components) == null ? void 0 : _a.linkInternalComponent) || defaultInternalComponent;
17
- const externalComponent = vue.unref(props.externalComponent) || ((_b = options.components) == null ? void 0 : _b.linkExternalComponent) || defaultExternalComponent;
18
- return href.value && isInternalURL.isInternalURL(href.value) && !target.value ? internalComponent : externalComponent;
19
- });
20
- const href = vue.computed(() => {
21
- const field = vue.unref(props.field);
22
- const linkResolver = vue.unref(props.linkResolver) ?? options.linkResolver;
23
- return client.asLink(field, linkResolver) ?? "";
24
- });
25
- const target = vue.computed(() => {
26
- const field = vue.unref(props.field);
27
- const target2 = vue.unref(props.target);
28
- if (typeof target2 !== "undefined") {
29
- return target2;
30
- } else {
31
- return field && "target" in field && field.target ? field.target : null;
32
- }
33
- });
34
- const rel = vue.computed(() => {
35
- var _a;
36
- const rel2 = vue.unref(props.rel);
37
- if (typeof rel2 !== "undefined") {
38
- return rel2;
39
- } else if (target.value === "_blank") {
40
- const blankTargetRelAttribute = vue.unref(props.blankTargetRelAttribute);
41
- if (typeof blankTargetRelAttribute !== "undefined") {
42
- return blankTargetRelAttribute;
43
- } else {
44
- return typeof ((_a = options.components) == null ? void 0 : _a.linkBlankTargetRelAttribute) !== "undefined" ? options.components.linkBlankTargetRelAttribute : defaultBlankTargetRelAttribute;
45
- }
46
- } else {
47
- return null;
48
- }
49
- });
50
- const text = vue.computed(() => {
51
- const field = vue.unref(props.field);
52
- return field && "text" in field ? field.text : void 0;
53
- });
54
- return {
55
- type,
56
- href,
57
- target,
58
- rel,
59
- text
60
- };
61
- };
62
- const PrismicLinkImpl = /* @__PURE__ */ vue.defineComponent({
63
- name: "PrismicLink",
64
- props: {
65
- field: {
66
- type: Object,
67
- required: true
68
- },
69
- linkResolver: {
70
- type: Function,
71
- default: void 0,
72
- required: false
73
- },
74
- target: {
75
- type: String,
76
- default: void 0,
77
- required: false
78
- },
79
- rel: {
80
- type: String,
81
- default: void 0,
82
- required: false
83
- },
84
- blankTargetRelAttribute: {
85
- type: String,
86
- default: void 0,
87
- required: false
88
- },
89
- internalComponent: {
90
- type: [String, Object, Function],
91
- default: void 0,
92
- required: false
93
- },
94
- externalComponent: {
95
- type: [String, Object, Function],
96
- default: void 0,
97
- required: false
98
- }
99
- },
100
- setup(props, { slots }) {
101
- if (!props.field) {
102
- return () => null;
103
- }
104
- const { type, href, target, rel, text } = usePrismicLink(props);
105
- return () => {
106
- const parent = type.value === "a" ? "a" : simplyResolveComponent.simplyResolveComponent(type.value);
107
- const computedSlots = getSlots.getSlots(parent, slots, vue.reactive({ href: href.value, text: text.value }), text.value);
108
- if (typeof parent === "string") {
109
- return vue.h(parent, { href: href.value, target: target.value, rel: rel.value }, computedSlots);
110
- } else {
111
- return vue.h(parent, { to: href.value, target: target.value, rel: rel.value }, computedSlots);
112
- }
113
- };
114
- }
115
- });
116
- const PrismicLink = PrismicLinkImpl;
117
- exports.PrismicLink = PrismicLink;
118
- exports.PrismicLinkImpl = PrismicLinkImpl;
119
- exports.usePrismicLink = usePrismicLink;
120
- //# sourceMappingURL=PrismicLink.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import type {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\"\nimport { asLink } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport { computed, defineComponent, h, reactive, unref } from \"vue\"\n\nimport { getSlots } from \"../lib/getSlots\"\nimport { isInternalURL } from \"../lib/isInternalURL\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\"\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\"\n\n/**\n * The default rel attribute rendered for blank target URLs.\n */\nconst defaultBlankTargetRelAttribute = \"noopener noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * The Prismic link field or document to render.\n\t */\n\tfield: LinkField | PrismicDocument\n\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An explicit `target` attribute to apply to the rendered link.\n\t */\n\ttarget?: string | null\n\n\t/**\n\t * An explicit `rel` attribute to apply to the rendered link.\n\t */\n\trel?: string | null\n\n\t/**\n\t * Value of the `rel` attribute to use on links rendered with\n\t * `target=\"_blank\"`.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise.\n\t */\n\tblankTargetRelAttribute?: string | null\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: string | ConcreteComponent | Raw<DefineComponent>\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: string | ConcreteComponent | Raw<DefineComponent>\n}\n\n/**\n * Options for {@link usePrismicLink}.\n */\nexport type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>\n\n/**\n * Return type of {@link usePrismicLink}.\n */\nexport type UsePrismicLinkReturnType = {\n\t/**\n\t * Suggested component to render for provided link field.\n\t */\n\ttype: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>\n\n\t/**\n\t * Resolved anchor `href` value.\n\t */\n\thref: ComputedRef<string>\n\n\t/**\n\t * Resolved anchor `target` value.\n\t */\n\ttarget: ComputedRef<string | null>\n\n\t/**\n\t * Resolved anchor `rel` value.\n\t */\n\trel: ComputedRef<string | null>\n\n\t/**\n\t * Resolved link text.\n\t */\n\ttext: ComputedRef<string | undefined>\n}\n\n/**\n * A low level composable that returns resolved information about a Prismic link\n * field.\n *\n * @param props - {@link UsePrismicLinkOptions}\n *\n * @returns - Resolved link information {@link UsePrismicLinkReturnType}\n */\nexport const usePrismicLink = (\n\tprops: UsePrismicLinkOptions,\n): UsePrismicLinkReturnType => {\n\tconst { options } = usePrismic()\n\n\tconst type = computed(() => {\n\t\tconst internalComponent =\n\t\t\tunref(props.internalComponent) ||\n\t\t\toptions.components?.linkInternalComponent ||\n\t\t\tdefaultInternalComponent\n\n\t\tconst externalComponent =\n\t\t\tunref(props.externalComponent) ||\n\t\t\toptions.components?.linkExternalComponent ||\n\t\t\tdefaultExternalComponent\n\n\t\treturn href.value && isInternalURL(href.value) && !target.value\n\t\t\t? internalComponent\n\t\t\t: externalComponent\n\t})\n\tconst href = computed(() => {\n\t\tconst field = unref(props.field)\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver\n\n\t\treturn asLink(field, linkResolver) ?? \"\"\n\t})\n\tconst target = computed(() => {\n\t\tconst field = unref(props.field)\n\t\tconst target = unref(props.target)\n\n\t\tif (typeof target !== \"undefined\") {\n\t\t\treturn target\n\t\t} else {\n\t\t\treturn field && \"target\" in field && field.target ? field.target : null\n\t\t}\n\t})\n\tconst rel = computed(() => {\n\t\tconst rel = unref(props.rel)\n\n\t\tif (typeof rel !== \"undefined\") {\n\t\t\treturn rel\n\t\t} else if (target.value === \"_blank\") {\n\t\t\tconst blankTargetRelAttribute = unref(props.blankTargetRelAttribute)\n\n\t\t\tif (typeof blankTargetRelAttribute !== \"undefined\") {\n\t\t\t\treturn blankTargetRelAttribute\n\t\t\t} else {\n\t\t\t\treturn typeof options.components?.linkBlankTargetRelAttribute !==\n\t\t\t\t\t\"undefined\"\n\t\t\t\t\t? options.components.linkBlankTargetRelAttribute\n\t\t\t\t\t: defaultBlankTargetRelAttribute\n\t\t\t}\n\t\t} else {\n\t\t\treturn null\n\t\t}\n\t})\n\n\tconst text = computed(() => {\n\t\tconst field = unref(props.field)\n\n\t\treturn field && \"text\" in field ? field.text : undefined\n\t})\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t\ttext,\n\t}\n}\n\n/**\n * `<PrismicLink />` implementation.\n *\n * @internal\n */\nexport const PrismicLinkImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicLink\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<LinkField | PrismicDocument>,\n\t\t\trequired: true,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\trel: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tblankTargetRelAttribute: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tinternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\texternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null\n\t\t}\n\n\t\tconst { type, href, target, rel, text } = usePrismicLink(props)\n\n\t\treturn () => {\n\t\t\tconst parent =\n\t\t\t\ttype.value === \"a\" ? \"a\" : simplyResolveComponent(type.value)\n\t\t\tconst computedSlots = getSlots(\n\t\t\t\tparent,\n\t\t\t\tslots,\n\t\t\t\treactive({ href: href.value, text: text.value }),\n\t\t\t\ttext.value,\n\t\t\t)\n\n\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t// Fitting anchor tag interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ href: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\t// Fitting Vue Router Link interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ to: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic link field.\n *\n * @see Component props {@link PrismicLinkProps}\n * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}\n */\nexport const PrismicLink = PrismicLinkImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicLinkProps\n\t}\n}\n"],"names":["usePrismic","computed","unref","isInternalURL","asLink","target","rel","defineComponent","simplyResolveComponent","getSlots","reactive","h"],"mappings":";;;;;;;;AA6BA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,uBAAuB,KAAK,KAAK;AAC7D,YAAM,gBAAgBC,SAAAA,SACrB,QACA,OACAC,IAAAA,SAAS,EAAE,MAAM,KAAK,OAAO,MAAM,KAAK,MAAA,CAAO,GAC/C,KAAK,KAAK;AAGP,UAAA,OAAO,WAAW,UAAU;AAE/B,eAAOC,IACN,EAAA,QACA,EAAE,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,MAAA,GACnD,aAAa;AAAA,MAAA,OAER;AAEN,eAAOA,IACN,EAAA,QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,MAAA,GACjD,aAAa;AAAA,MAAA;AAAA,IAGhB;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,cAAc;;;;"}
@@ -1,198 +0,0 @@
1
- import type { LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
2
- import type { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
3
- import type { VueUseOptions } from "../types";
4
- /**
5
- * Props for `<PrismicLink />`.
6
- */
7
- export type PrismicLinkProps = {
8
- /**
9
- * The Prismic link field or document to render.
10
- */
11
- field: LinkField | PrismicDocument;
12
- /**
13
- * A link resolver function used to resolve links when not using the route
14
- * resolver parameter with `@prismicio/client`.
15
- *
16
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
17
- *
18
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
19
- */
20
- linkResolver?: LinkResolverFunction;
21
- /**
22
- * An explicit `target` attribute to apply to the rendered link.
23
- */
24
- target?: string | null;
25
- /**
26
- * An explicit `rel` attribute to apply to the rendered link.
27
- */
28
- rel?: string | null;
29
- /**
30
- * Value of the `rel` attribute to use on links rendered with
31
- * `target="_blank"`.
32
- *
33
- * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `"noopener noreferrer"` otherwise.
34
- */
35
- blankTargetRelAttribute?: string | null;
36
- /**
37
- * An HTML tag name, a component, or a functional component used to render
38
- * internal links.
39
- *
40
- * @remarks
41
- * HTML tag names will be rendered using the anchor tag interface (`href`,
42
- * `target`, and `rel` attributes).
43
- * @remarks
44
- * Components will be rendered using Vue Router {@link RouterLink} interface
45
- * (`to` props).
46
- *
47
- * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.
48
- */
49
- internalComponent?: string | ConcreteComponent | Raw<DefineComponent>;
50
- /**
51
- * An HTML tag name, a component, or a functional component used to render
52
- * external links.
53
- *
54
- * @remarks
55
- * HTML tag names will be rendered using the anchor tag interface (`href`,
56
- * `target`, and `rel` attributes).
57
- * @remarks
58
- * Components will be rendered using Vue Router {@link RouterLink} interface
59
- * (`to` props).
60
- *
61
- * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `"a"` otherwise.
62
- */
63
- externalComponent?: string | ConcreteComponent | Raw<DefineComponent>;
64
- };
65
- /**
66
- * Options for {@link usePrismicLink}.
67
- */
68
- export type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>;
69
- /**
70
- * Return type of {@link usePrismicLink}.
71
- */
72
- export type UsePrismicLinkReturnType = {
73
- /**
74
- * Suggested component to render for provided link field.
75
- */
76
- type: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>;
77
- /**
78
- * Resolved anchor `href` value.
79
- */
80
- href: ComputedRef<string>;
81
- /**
82
- * Resolved anchor `target` value.
83
- */
84
- target: ComputedRef<string | null>;
85
- /**
86
- * Resolved anchor `rel` value.
87
- */
88
- rel: ComputedRef<string | null>;
89
- /**
90
- * Resolved link text.
91
- */
92
- text: ComputedRef<string | undefined>;
93
- };
94
- /**
95
- * A low level composable that returns resolved information about a Prismic link
96
- * field.
97
- *
98
- * @param props - {@link UsePrismicLinkOptions}
99
- *
100
- * @returns - Resolved link information {@link UsePrismicLinkReturnType}
101
- */
102
- export declare const usePrismicLink: (props: UsePrismicLinkOptions) => UsePrismicLinkReturnType;
103
- /**
104
- * `<PrismicLink />` implementation.
105
- *
106
- * @internal
107
- */
108
- export declare const PrismicLinkImpl: DefineComponent<import("vue").ExtractPropTypes<{
109
- field: {
110
- type: PropType<LinkField | PrismicDocument>;
111
- required: true;
112
- };
113
- linkResolver: {
114
- type: PropType<LinkResolverFunction>;
115
- default: undefined;
116
- required: false;
117
- };
118
- target: {
119
- type: PropType<string | null>;
120
- default: undefined;
121
- required: false;
122
- };
123
- rel: {
124
- type: PropType<string | null>;
125
- default: undefined;
126
- required: false;
127
- };
128
- blankTargetRelAttribute: {
129
- type: PropType<string | null>;
130
- default: undefined;
131
- required: false;
132
- };
133
- internalComponent: {
134
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
135
- default: undefined;
136
- required: false;
137
- };
138
- externalComponent: {
139
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
140
- default: undefined;
141
- required: false;
142
- };
143
- }>, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
144
- [key: string]: any;
145
- }>), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
146
- field: {
147
- type: PropType<LinkField | PrismicDocument>;
148
- required: true;
149
- };
150
- linkResolver: {
151
- type: PropType<LinkResolverFunction>;
152
- default: undefined;
153
- required: false;
154
- };
155
- target: {
156
- type: PropType<string | null>;
157
- default: undefined;
158
- required: false;
159
- };
160
- rel: {
161
- type: PropType<string | null>;
162
- default: undefined;
163
- required: false;
164
- };
165
- blankTargetRelAttribute: {
166
- type: PropType<string | null>;
167
- default: undefined;
168
- required: false;
169
- };
170
- internalComponent: {
171
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
172
- default: undefined;
173
- required: false;
174
- };
175
- externalComponent: {
176
- type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
177
- default: undefined;
178
- required: false;
179
- };
180
- }>> & Readonly<{}>, {
181
- target: string | null;
182
- linkResolver: LinkResolverFunction;
183
- rel: string | null;
184
- blankTargetRelAttribute: string | null;
185
- internalComponent: string | ConcreteComponent | Raw<DefineComponent>;
186
- externalComponent: string | ConcreteComponent | Raw<DefineComponent>;
187
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
188
- /**
189
- * Component to render a Prismic link field.
190
- *
191
- * @see Component props {@link PrismicLinkProps}
192
- * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
193
- */
194
- export declare const PrismicLink: {
195
- new (): {
196
- $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicLinkProps;
197
- };
198
- };