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