@prismicio/vue 4.3.0 → 5.0.0-alpha.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 (245) 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 +278 -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 +7 -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 +40 -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 +34 -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/lib/isInternalURL.cjs.map +1 -1
  132. package/dist/lib/isInternalURL.js.map +1 -1
  133. package/dist/package.json.cjs +5 -0
  134. package/dist/package.json.cjs.map +1 -0
  135. package/dist/package.json.js +5 -0
  136. package/dist/package.json.js.map +1 -0
  137. package/dist/types.d.ts +42 -58
  138. package/dist/usePrismic.cjs +3 -2
  139. package/dist/usePrismic.cjs.map +1 -1
  140. package/dist/usePrismic.d.ts +13 -5
  141. package/dist/usePrismic.js +2 -1
  142. package/dist/usePrismic.js.map +1 -1
  143. package/package.json +32 -35
  144. package/src/PrismicEmbed.vue +42 -0
  145. package/src/PrismicImage.vue +160 -0
  146. package/src/PrismicLink.vue +191 -0
  147. package/src/PrismicRichText/DeprecatedPrismicRichText.vue +130 -0
  148. package/src/PrismicRichText/PrismicRichText.vue +157 -0
  149. package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +63 -0
  150. package/src/PrismicRichText/PrismicRichTextSerialize.vue +52 -0
  151. package/src/PrismicRichText/getRichTextComponentProps.ts +63 -0
  152. package/src/PrismicRichText/index.ts +3 -0
  153. package/src/PrismicRichText/types.ts +37 -0
  154. package/src/PrismicText.vue +63 -0
  155. package/src/SliceZone/SliceZone.vue +113 -0
  156. package/src/SliceZone/TODOSliceComponent.ts +49 -0
  157. package/src/SliceZone/defineSliceZoneComponents.ts +67 -0
  158. package/src/SliceZone/getSliceComponentProps.ts +98 -0
  159. package/src/SliceZone/index.ts +13 -0
  160. package/src/SliceZone/types.ts +163 -0
  161. package/src/createPrismic.ts +54 -53
  162. package/src/index.ts +33 -58
  163. package/src/lib/Wrapper.vue +22 -0
  164. package/src/lib/devMsg.ts +20 -0
  165. package/src/lib/isInternalURL.ts +4 -4
  166. package/src/types.ts +91 -109
  167. package/src/usePrismic.ts +16 -9
  168. package/dist/components/PrismicEmbed.cjs +0 -36
  169. package/dist/components/PrismicEmbed.cjs.map +0 -1
  170. package/dist/components/PrismicEmbed.d.ts +0 -59
  171. package/dist/components/PrismicEmbed.js +0 -36
  172. package/dist/components/PrismicEmbed.js.map +0 -1
  173. package/dist/components/PrismicImage.cjs +0 -122
  174. package/dist/components/PrismicImage.cjs.map +0 -1
  175. package/dist/components/PrismicImage.d.ts +0 -163
  176. package/dist/components/PrismicImage.js +0 -122
  177. package/dist/components/PrismicImage.js.map +0 -1
  178. package/dist/components/PrismicLink.cjs +0 -120
  179. package/dist/components/PrismicLink.cjs.map +0 -1
  180. package/dist/components/PrismicLink.d.ts +0 -196
  181. package/dist/components/PrismicLink.js +0 -120
  182. package/dist/components/PrismicLink.js.map +0 -1
  183. package/dist/components/PrismicRichText.cjs +0 -108
  184. package/dist/components/PrismicRichText.cjs.map +0 -1
  185. package/dist/components/PrismicRichText.d.ts +0 -161
  186. package/dist/components/PrismicRichText.js +0 -108
  187. package/dist/components/PrismicRichText.js.map +0 -1
  188. package/dist/components/PrismicText.cjs +0 -57
  189. package/dist/components/PrismicText.cjs.map +0 -1
  190. package/dist/components/PrismicText.d.ts +0 -119
  191. package/dist/components/PrismicText.js +0 -57
  192. package/dist/components/PrismicText.js.map +0 -1
  193. package/dist/components/SliceZone.cjs +0 -156
  194. package/dist/components/SliceZone.cjs.map +0 -1
  195. package/dist/components/SliceZone.d.ts +0 -375
  196. package/dist/components/SliceZone.js +0 -156
  197. package/dist/components/SliceZone.js.map +0 -1
  198. package/dist/components/index.d.ts +0 -12
  199. package/dist/composables.cjs +0 -40
  200. package/dist/composables.cjs.map +0 -1
  201. package/dist/composables.d.ts +0 -330
  202. package/dist/composables.js +0 -40
  203. package/dist/composables.js.map +0 -1
  204. package/dist/globalExtensions.d.ts +0 -11
  205. package/dist/injectionSymbols.cjs +0 -5
  206. package/dist/injectionSymbols.cjs.map +0 -1
  207. package/dist/injectionSymbols.d.ts +0 -9
  208. package/dist/injectionSymbols.js +0 -5
  209. package/dist/injectionSymbols.js.map +0 -1
  210. package/dist/lib/__PRODUCTION__.cjs +0 -8
  211. package/dist/lib/__PRODUCTION__.cjs.map +0 -1
  212. package/dist/lib/__PRODUCTION__.d.ts +0 -7
  213. package/dist/lib/__PRODUCTION__.js +0 -8
  214. package/dist/lib/__PRODUCTION__.js.map +0 -1
  215. package/dist/lib/getSlots.cjs +0 -19
  216. package/dist/lib/getSlots.cjs.map +0 -1
  217. package/dist/lib/getSlots.d.ts +0 -14
  218. package/dist/lib/getSlots.js +0 -19
  219. package/dist/lib/getSlots.js.map +0 -1
  220. package/dist/lib/simplyResolveComponent.cjs +0 -8
  221. package/dist/lib/simplyResolveComponent.cjs.map +0 -1
  222. package/dist/lib/simplyResolveComponent.d.ts +0 -12
  223. package/dist/lib/simplyResolveComponent.js +0 -8
  224. package/dist/lib/simplyResolveComponent.js.map +0 -1
  225. package/dist/useStatefulPrismicClientMethod.cjs +0 -39
  226. package/dist/useStatefulPrismicClientMethod.cjs.map +0 -1
  227. package/dist/useStatefulPrismicClientMethod.d.ts +0 -64
  228. package/dist/useStatefulPrismicClientMethod.js +0 -39
  229. package/dist/useStatefulPrismicClientMethod.js.map +0 -1
  230. package/src/components/PrismicEmbed.ts +0 -91
  231. package/src/components/PrismicImage.ts +0 -309
  232. package/src/components/PrismicLink.ts +0 -326
  233. package/src/components/PrismicRichText.ts +0 -282
  234. package/src/components/PrismicText.ts +0 -167
  235. package/src/components/SliceZone.ts +0 -619
  236. package/src/components/index.ts +0 -46
  237. package/src/composables.ts +0 -474
  238. package/src/globalExtensions.ts +0 -12
  239. package/src/injectionSymbols.ts +0 -17
  240. package/src/lib/__PRODUCTION__.ts +0 -12
  241. package/src/lib/getSlots.ts +0 -37
  242. package/src/lib/simplyResolveComponent.ts +0 -23
  243. package/src/useStatefulPrismicClientMethod.ts +0 -156
  244. package/vetur/attributes.json +0 -113
  245. package/vetur/tags.json +0 -60
@@ -1,619 +0,0 @@
1
- import { Slice } from "@prismicio/client";
2
- import {
3
- AllowedComponentProps,
4
- ComponentCustomProps,
5
- ConcreteComponent,
6
- DefineComponent,
7
- FunctionalComponent,
8
- PropType,
9
- Raw,
10
- VNodeProps,
11
- computed,
12
- defineAsyncComponent,
13
- defineComponent,
14
- h,
15
- markRaw,
16
- watchEffect,
17
- } from "vue";
18
-
19
- import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
20
- import { simplyResolveComponent } from "../lib/simplyResolveComponent";
21
-
22
- import { usePrismic } from "../usePrismic";
23
-
24
- /**
25
- * Returns the type of a `SliceLike` type.
26
- *
27
- * @typeParam TSlice - The Slice from which the type will be extracted.
28
- */
29
- type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
30
- ? TSlice["slice_type"]
31
- : TSlice extends SliceLikeGraphQL
32
- ? TSlice["type"]
33
- : never;
34
-
35
- /**
36
- * The minimum required properties to represent a Prismic Slice from the Prismic
37
- * Rest API V2 for the `<SliceZone>` component.
38
- *
39
- * If using Prismic's Rest API V2, use the `Slice` export from
40
- * `@prismicio/client` for a full interface.
41
- *
42
- * @typeParam TSliceType - Type name of the Slice.
43
- */
44
- export type SliceLikeRestV2<TSliceType extends string = string> = Pick<
45
- Slice<TSliceType>,
46
- "id" | "slice_type"
47
- >;
48
-
49
- /**
50
- * The minimum required properties to represent a Prismic Slice from the Prismic
51
- * GraphQL API for the `<SliceZone>` component.
52
- *
53
- * @typeParam TSliceType - Type name of the Slice.
54
- */
55
- export type SliceLikeGraphQL<TSliceType extends string = string> = {
56
- type: Slice<TSliceType>["slice_type"];
57
- };
58
-
59
- /**
60
- * The minimum required properties to represent a Prismic Slice for the
61
- * `<SliceZone />` component.
62
- *
63
- * If using Prismic's Rest API V2, use the `Slice` export from
64
- * `@prismicio/client` for a full interface.
65
- *
66
- * @typeParam TSliceType - Type name of the Slice
67
- */
68
- export type SliceLike<TSliceType extends string = string> = (
69
- | SliceLikeRestV2<TSliceType>
70
- | SliceLikeGraphQL<TSliceType>
71
- ) & {
72
- /**
73
- * If `true`, this Slice has been modified from its original value using a
74
- * mapper and `@prismicio/client`'s `mapSliceZone()`.
75
- *
76
- * @internal
77
- */
78
- __mapped?: true;
79
- };
80
-
81
- /**
82
- * A looser version of the `SliceZone` type from `@prismicio/client` using
83
- * `SliceLike`.
84
- *
85
- * If using Prismic's REST API, use the `SliceZone` export from
86
- * `@prismicio/client` for the full type.
87
- *
88
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
89
- */
90
- export type SliceZoneLike<TSlice extends SliceLike = SliceLike> =
91
- readonly TSlice[];
92
-
93
- /**
94
- * Vue props for a component rendering content from a Prismic Slice using the
95
- * `<SliceZone />` component.
96
- *
97
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
98
- * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
99
- * available to all Slice components
100
- */
101
- export type SliceComponentProps<
102
- TSlice extends SliceLike = SliceLike,
103
- TContext = unknown,
104
- > = {
105
- /**
106
- * Slice data for this component.
107
- */
108
- slice: TSlice;
109
-
110
- /**
111
- * The index of the Slice in the Slice Zone.
112
- */
113
- index: number;
114
-
115
- /**
116
- * All Slices from the Slice Zone to which the Slice belongs.
117
- */
118
- // TODO: We have to keep this list of Slices general due to circular
119
- // reference limtiations. If we had another generic to determine the full
120
- // union of Slice types, it would include TSlice. This causes TypeScript to
121
- // throw a compilation error.
122
- slices: SliceZoneLike<
123
- TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2
124
- >;
125
-
126
- /**
127
- * Arbitrary data passed to `<SliceZone />` and made available to all Slice
128
- * components.
129
- */
130
- context: TContext;
131
- };
132
-
133
- /**
134
- * Native Vue props for a component rendering content from a Prismic Slice using
135
- * the `<SliceZone />` component.
136
- *
137
- * @typeParam TSlice - The Slice type
138
- * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
139
- * available to all Slice components
140
- */
141
- export type DefineComponentSliceComponentProps<
142
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
- TSlice extends SliceLike = any,
144
- TContext = unknown,
145
- > = {
146
- slice: {
147
- type: PropType<SliceComponentProps<TSlice, TContext>["slice"]>;
148
- required: true;
149
- };
150
- index: {
151
- type: PropType<SliceComponentProps<TSlice, TContext>["index"]>;
152
- required: true;
153
- };
154
- slices: {
155
- type: PropType<SliceComponentProps<TSlice, TContext>["slices"]>;
156
- required: true;
157
- };
158
- context: {
159
- type: PropType<SliceComponentProps<TSlice, TContext>["context"]>;
160
- required: true;
161
- };
162
- };
163
-
164
- /**
165
- * Gets native Vue props for a component rendering content from a Prismic Slice
166
- * using the `<SliceZone />` component.
167
- *
168
- * Props are: `["slice", "index", "slices", "context"]`
169
- *
170
- * @example
171
- *
172
- * ```javascript
173
- * // Defining a new slice component
174
- * import { getSliceComponentProps } from "@prismicio/vue";
175
- *
176
- * export default {
177
- * props: getSliceComponentProps(),
178
- * };
179
- * ```
180
- *
181
- * @example
182
- *
183
- * ```javascript
184
- * // Defining a new slice component with visual hint
185
- * import { getSliceComponentProps } from "@prismicio/vue";
186
- *
187
- * export default {
188
- * props: getSliceComponentProps(["slice", "index", "slices", "context"]),
189
- * };
190
- * ```
191
- *
192
- * @typeParam TSlice - The Slice type
193
- * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
194
- * available to all Slice components
195
- * @param propsHint - An optional array of prop names used for the sole purpose
196
- * of having a visual hint of which props are made available to the slice,
197
- * this parameters doesn't have any effect
198
- *
199
- * @returns Props object to use with {@link defineComponent}
200
- */
201
- export const getSliceComponentProps = <
202
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- TSlice extends SliceLike = any,
204
- TContext = unknown,
205
- >(
206
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
207
- propsHint?: ["slice", "index", "slices", "context"],
208
- ): DefineComponentSliceComponentProps<TSlice, TContext> => ({
209
- slice: {
210
- type: Object as PropType<SliceComponentProps<TSlice, TContext>["slice"]>,
211
- required: true,
212
- },
213
- index: {
214
- type: Number as PropType<SliceComponentProps<TSlice, TContext>["index"]>,
215
- required: true,
216
- },
217
- slices: {
218
- type: Array as PropType<SliceComponentProps<TSlice, TContext>["slices"]>,
219
- required: true,
220
- },
221
- context: {
222
- type: null as unknown as PropType<
223
- SliceComponentProps<TSlice, TContext>["context"]
224
- >,
225
- required: true,
226
- },
227
- });
228
-
229
- /**
230
- * A Vue component to be rendered for each instance of its Slice.
231
- *
232
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
233
- * @typeParam TContext - Arbitrary data made available to all Slice components
234
- */
235
- export type SliceComponentType<
236
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
237
- TSlice extends SliceLike = any,
238
- TContext = unknown,
239
- > =
240
- // For reference within TypeScript files when `*.vue` type cannot be inferred
241
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
242
- | DefineComponent<{}, {}, any>
243
- // Likewise, for reference with TypeScript files.
244
- | ReturnType<typeof defineAsyncComponent>
245
- | DefineComponent<SliceComponentProps<TSlice, TContext>>
246
- | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
247
-
248
- /**
249
- * This Slice component can be used as a reminder to provide a proper
250
- * implementation.
251
- *
252
- * This is also the default Vue component rendered when a component mapping
253
- * cannot be found in `<SliceZone />`.
254
- */
255
- export const TODOSliceComponent = __PRODUCTION__
256
- ? ((() => null) as FunctionalComponent<{
257
- slice: SliceLike;
258
- }>)
259
- : /*#__PURE__*/ (defineComponent({
260
- name: "TODOSliceComponent",
261
- props: {
262
- slice: {
263
- type: Object as PropType<SliceLike>,
264
- required: true,
265
- },
266
- },
267
- setup(props) {
268
- const type = computed(() => {
269
- return "slice_type" in props.slice
270
- ? props.slice.slice_type
271
- : props.slice.type;
272
- });
273
-
274
- watchEffect(() => {
275
- console.warn(
276
- `[SliceZone] Could not find a component for Slice type "${type.value}"`,
277
- props.slice,
278
- );
279
- });
280
-
281
- return () => {
282
- return h(
283
- "section",
284
- {
285
- "data-slice-zone-todo-component": "",
286
- "data-slice-type": type.value,
287
- },
288
- [`Could not find a component for Slice type "${type.value}"`],
289
- );
290
- };
291
- },
292
- }) as SliceComponentType);
293
-
294
- /**
295
- * A record of Slice types mapped to Vue components. Each components will be
296
- * rendered for each instance of their Slice type.
297
- *
298
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
299
- * @typeParam TContext - Arbitrary data made available to all Slice components
300
- */
301
- export type SliceZoneComponents<
302
- TSlice extends SliceLike = SliceLike,
303
- TContext = unknown,
304
- > =
305
- // This is purposely not wrapped in Partial to ensure a component is provided
306
- // for all Slice types. <SliceZone /> will render a default component if one is
307
- // not provided, but it *should* be a type error if an explicit component is
308
- // missing.
309
- //
310
- // If a developer purposely does not want to provide a component, they can
311
- // assign it to the TODOSliceComponent exported from this package. This
312
- // signals to future developers that it is a placeholder and should be
313
- // implemented.
314
- {
315
- [SliceType in ExtractSliceType<TSlice>]:
316
- | SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>
317
- | string;
318
- };
319
-
320
- /**
321
- * Gets an optimized record of Slice types mapped to Vue components. Each
322
- * components will be rendered for each instance of their Slice type.
323
- *
324
- * @remarks
325
- * This is essentially an helper function to ensure {@link markRaw} is correctly
326
- * applied on each components, improving performances.
327
- * @example
328
- *
329
- * ```javascript
330
- * // Defining a slice components
331
- * import { defineSliceZoneComponents } from "@prismicio/vue";
332
- *
333
- * export default {
334
- * data() {
335
- * components: defineSliceZoneComponents({
336
- * foo: Foo,
337
- * bar: defineAsyncComponent(
338
- * () => new Promise((res) => res(Bar)),
339
- * ),
340
- * baz: "Baz",
341
- * }),
342
- * }
343
- * };
344
- * ```
345
- *
346
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
347
- * @typeParam TContext - Arbitrary data made available to all Slice components
348
- *
349
- * @param components - {@link SliceZoneComponents}
350
- *
351
- * @returns A new optimized record of {@link SliceZoneComponents}
352
- */
353
- export const defineSliceZoneComponents = <
354
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
355
- TSlice extends SliceLike = any,
356
- TContext = unknown,
357
- >(
358
- components: SliceZoneComponents<TSlice, TContext>,
359
- ): SliceZoneComponents<TSlice, TContext> => {
360
- const result = {} as SliceZoneComponents<TSlice, TContext>;
361
-
362
- let type: keyof typeof components;
363
- for (type in components) {
364
- const component = components[type];
365
- result[type] =
366
- typeof component === "string"
367
- ? component
368
- : markRaw(
369
- component as SliceComponentType<
370
- Extract<TSlice, SliceLike<typeof type>>,
371
- TContext
372
- >,
373
- );
374
- }
375
-
376
- return result;
377
- };
378
-
379
- /**
380
- * Arguments for a `<SliceZone>` `resolver` function.
381
- */
382
- export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
383
- /**
384
- * The Slice to resolve to a Vue component..
385
- */
386
- slice: TSlice;
387
-
388
- /**
389
- * The name of the Slice.
390
- */
391
- sliceName: ExtractSliceType<TSlice>;
392
-
393
- /**
394
- * The index of the Slice in the Slice Zone.
395
- */
396
- i: number;
397
- };
398
-
399
- /**
400
- * A function that determines the rendered Vue component for each Slice in the
401
- * Slice Zone. If a nullish value is returned, the component will fallback to
402
- * the `components` or `defaultComponent` props to determine the rendered
403
- * component.
404
- *
405
- * @deprecated Use the `components` prop instead.
406
- *
407
- * @param args - Arguments for the resolver function.
408
- *
409
- * @returns The Vue component to render for a Slice.
410
- */
411
- export type SliceZoneResolver<
412
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
413
- TSlice extends SliceLike = any,
414
- TContext = unknown,
415
- > = (
416
- args: SliceZoneResolverArgs<TSlice>,
417
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
418
- ) => SliceComponentType<any, TContext> | string | undefined | null;
419
-
420
- /**
421
- * Props for `<SliceZone />`.
422
- *
423
- * @typeParam TContext - Arbitrary data made available to all Slice components
424
- */
425
- export type SliceZoneProps<TContext = unknown> = {
426
- /**
427
- * List of Slice data from the Slice Zone.
428
- */
429
- slices: SliceZoneLike;
430
-
431
- /**
432
- * A record mapping Slice types to Vue components.
433
- */
434
- components?: SliceZoneComponents;
435
-
436
- /**
437
- * A function that determines the rendered Vue component for each Slice in the
438
- * Slice Zone.
439
- *
440
- * @deprecated Use the `components` prop instead.
441
- *
442
- * @param args - Arguments for the resolver function.
443
- *
444
- * @returns The Vue component to render for a Slice.
445
- */
446
- // TODO: Remove in v5 when the `resolver` prop is removed.
447
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
448
- resolver?: SliceZoneResolver<any, TContext>;
449
-
450
- /**
451
- * Arbitrary data made available to all Slice components.
452
- */
453
- context?: TContext;
454
-
455
- /**
456
- * A component or a functional component rendered if a component mapping from
457
- * the `components` prop cannot be found.
458
- *
459
- * @remarks
460
- * Components will be rendered using the {@link SliceComponentProps} interface.
461
- *
462
- * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
463
- */
464
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
465
- defaultComponent?: SliceComponentType<any, TContext>;
466
-
467
- /**
468
- * An HTML tag name, a component, or a functional component used to wrap the
469
- * output. The Slice Zone is not wrapped by default.
470
- */
471
- wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
472
- };
473
-
474
- /**
475
- * `<SliceZone />` implementation.
476
- *
477
- * @internal
478
- */
479
- export const SliceZoneImpl = /*#__PURE__*/ defineComponent({
480
- name: "SliceZone",
481
- props: {
482
- slices: {
483
- type: Array as PropType<
484
- SliceZoneLike<SliceLike & Record<string, unknown>>
485
- >,
486
- required: true,
487
- },
488
- components: {
489
- type: Object as PropType<SliceZoneComponents>,
490
- default: undefined,
491
- required: false,
492
- },
493
- resolver: {
494
- type: Function as PropType<SliceZoneResolver>,
495
- default: undefined,
496
- required: false,
497
- },
498
- context: {
499
- type: null,
500
- default: undefined,
501
- required: false,
502
- },
503
- defaultComponent: {
504
- type: Object as PropType<SliceComponentType>,
505
- default: undefined,
506
- required: false,
507
- },
508
- wrapper: {
509
- type: [String, Object, Function] as PropType<
510
- string | ConcreteComponent | Raw<DefineComponent>
511
- >,
512
- default: undefined,
513
- required: false,
514
- },
515
- },
516
- setup(props) {
517
- // Prevent fatal if user didn't check for field, throws `Invalid prop` warn
518
- if (!props.slices) {
519
- return () => null;
520
- }
521
-
522
- // TODO: Remove in v3 when the `resolver` prop is removed.
523
- if (!__PRODUCTION__) {
524
- if (props.resolver) {
525
- console.warn(
526
- "The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.",
527
- );
528
- }
529
- }
530
-
531
- const { options } = usePrismic();
532
-
533
- const renderedSlices = computed(() => {
534
- return props.slices.map((slice, index) => {
535
- const type =
536
- "slice_type" in slice ? (slice.slice_type as string) : slice.type;
537
-
538
- let component =
539
- props.components && type in props.components
540
- ? props.components[type]
541
- : props.defaultComponent ||
542
- options.components?.sliceZoneDefaultComponent;
543
-
544
- // TODO: Remove `resolver` in v5 in favor of `components`.
545
- if (props.resolver) {
546
- const resolvedComponent = props.resolver({
547
- slice,
548
- sliceName: type,
549
- i: index,
550
- });
551
-
552
- if (resolvedComponent) {
553
- component = resolvedComponent;
554
- }
555
- }
556
-
557
- const key =
558
- "id" in slice && typeof slice.id === "string"
559
- ? slice.id
560
- : `${index}-${JSON.stringify(slice)}`;
561
-
562
- if (component) {
563
- if (slice.__mapped) {
564
- const { __mapped, ...mappedProps } = slice;
565
-
566
- return h(simplyResolveComponent(component as ConcreteComponent), {
567
- key,
568
- ...mappedProps,
569
- });
570
- }
571
-
572
- return h(simplyResolveComponent(component as ConcreteComponent), {
573
- key,
574
- slice,
575
- index,
576
- context: props.context,
577
- slices: props.slices,
578
- });
579
- } else {
580
- return h(
581
- simplyResolveComponent(TODOSliceComponent as ConcreteComponent),
582
- { key, slice },
583
- );
584
- }
585
- });
586
- });
587
-
588
- return () => {
589
- if (props.wrapper) {
590
- const parent = simplyResolveComponent(props.wrapper);
591
-
592
- if (typeof parent === "string") {
593
- return h(parent, null, renderedSlices.value);
594
- } else {
595
- return h(parent, null, { default: () => renderedSlices.value });
596
- }
597
- } else {
598
- return renderedSlices.value;
599
- }
600
- };
601
- },
602
- });
603
-
604
- // export the public type for h/tsx inference
605
- // also to avoid inline import() in generated d.ts files
606
- /**
607
- * Component to render a Prismic Slice Zone.
608
- *
609
- * @see Component props {@link SliceZoneProps}
610
- * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}
611
- */
612
- export const SliceZone = SliceZoneImpl as unknown as {
613
- new (): {
614
- $props: AllowedComponentProps &
615
- ComponentCustomProps &
616
- VNodeProps &
617
- SliceZoneProps;
618
- };
619
- };
@@ -1,46 +0,0 @@
1
- export { PrismicEmbedImpl, PrismicEmbed } from "./PrismicEmbed";
2
- export type { PrismicEmbedProps } from "./PrismicEmbed";
3
-
4
- export {
5
- usePrismicImage,
6
- PrismicImageImpl,
7
- PrismicImage,
8
- } from "./PrismicImage";
9
- export type { UsePrismicImageOptions, PrismicImageProps } from "./PrismicImage";
10
-
11
- export { usePrismicLink, PrismicLinkImpl, PrismicLink } from "./PrismicLink";
12
- export type { UsePrismicLinkOptions, PrismicLinkProps } from "./PrismicLink";
13
-
14
- export { usePrismicText, PrismicTextImpl, PrismicText } from "./PrismicText";
15
- export type { UsePrismicTextOptions, PrismicTextProps } from "./PrismicText";
16
-
17
- export {
18
- usePrismicRichText,
19
- PrismicRichTextImpl,
20
- PrismicRichText,
21
- } from "./PrismicRichText";
22
- export type {
23
- UsePrismicRichTextOptions,
24
- PrismicRichTextProps,
25
- } from "./PrismicRichText";
26
-
27
- export {
28
- getSliceComponentProps,
29
- TODOSliceComponent,
30
- defineSliceZoneComponents,
31
- SliceZoneImpl,
32
- SliceZone,
33
- } from "./SliceZone";
34
- export type {
35
- DefineComponentSliceComponentProps,
36
- SliceComponentProps,
37
- SliceComponentType,
38
- SliceLikeRestV2,
39
- SliceLikeGraphQL,
40
- SliceLike,
41
- SliceZoneComponents,
42
- SliceZoneResolverArgs,
43
- SliceZoneResolver,
44
- SliceZoneLike,
45
- SliceZoneProps,
46
- } from "./SliceZone";