@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
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ const vue = require("vue");
3
+ const Wrapper_vue_vue_type_script_setup_true_lang = require("../lib/Wrapper.vue.cjs");
4
+ const usePrismic = require("../usePrismic.cjs");
5
+ const TODOSliceComponent = require("./TODOSliceComponent.cjs");
6
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
7
+ ...{ name: "SliceZone" },
8
+ __name: "SliceZone",
9
+ props: {
10
+ slices: {},
11
+ components: {},
12
+ defaultComponent: {},
13
+ context: {},
14
+ wrapper: {}
15
+ },
16
+ setup(__props) {
17
+ const props = __props;
18
+ const { options } = usePrismic.usePrismic();
19
+ const renderedSlices = vue.computed(() => {
20
+ return props.slices.map((slice, index) => {
21
+ var _a, _b;
22
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
23
+ const key = "id" in slice && typeof slice.id === "string" ? slice.id : `${index}-${JSON.stringify(slice)}`;
24
+ const is = ((_a = props.components) == null ? void 0 : _a[type]) || props.defaultComponent || ((_b = options.components) == null ? void 0 : _b.sliceZoneDefaultComponent);
25
+ if (!is) {
26
+ return { is: TODOSliceComponent.TODOSliceComponent, key, props: { slice } };
27
+ }
28
+ if (slice.__mapped) {
29
+ const { __mapped, ...mappedProps } = slice;
30
+ return { is, key, props: mappedProps };
31
+ }
32
+ return {
33
+ is,
34
+ key,
35
+ props: {
36
+ slice,
37
+ index,
38
+ context: props.context,
39
+ slices: props.slices
40
+ }
41
+ };
42
+ });
43
+ });
44
+ return (_ctx, _cache) => {
45
+ return _ctx.slices ? (vue.openBlock(), vue.createBlock(Wrapper_vue_vue_type_script_setup_true_lang, {
46
+ key: 0,
47
+ wrapper: _ctx.wrapper
48
+ }, {
49
+ default: vue.withCtx(() => [
50
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(renderedSlices.value, (renderedSlice) => {
51
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderedSlice.is), vue.mergeProps({
52
+ key: renderedSlice.key,
53
+ ref_for: true
54
+ }, renderedSlice.props), null, 16);
55
+ }), 128))
56
+ ]),
57
+ _: 1
58
+ }, 8, ["wrapper"])) : vue.createCommentVNode("", true);
59
+ };
60
+ }
61
+ });
62
+ module.exports = _sfc_main;
63
+ //# sourceMappingURL=SliceZone.vue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.vue.cjs","sources":["../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike<SliceLike & Record<string, unknown>>\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<SliceZone />` is\n\t * not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst { options } = usePrismic()\n\nconst renderedSlices = computed(() => {\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is =\n\t\t\tprops.components?.[type] ||\n\t\t\tprops.defaultComponent ||\n\t\t\toptions.components?.sliceZoneDefaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<Wrapper v-if=\"slices\" :wrapper=\"wrapper\">\n\t\t<component\n\t\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t\t:is=\"renderedSlice.is\"\n\t\t\t:key=\"renderedSlice.key\"\n\t\t\tv-bind=\"renderedSlice.props\"\n\t\t/>\n\t</Wrapper>\n</template>\n"],"names":["usePrismic","computed","TODOSliceComponent"],"mappings":";;;;;;;;;;;;;;;;AA2DA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAEzB,UAAA,iBAAiBC,IAAAA,SAAS,MAAM;AACrC,aAAO,MAAM,OAAO,IAAI,CAAC,OAAO,UAAU;;AACzC,cAAM,OACL,gBAAgB,QAAS,MAAM,aAAwB,MAAM;AAE9D,cAAM,MACL,QAAQ,SAAS,OAAO,MAAM,OAAO,WAClC,MAAM,KACN,GAAG,KAAK,IAAI,KAAK,UAAU,KAAK,CAAC;AAE/B,cAAA,OACL,WAAM,eAAN,mBAAmB,UACnB,MAAM,sBACN,aAAQ,eAAR,mBAAoB;AAErB,YAAI,CAAC,IAAI;AACR,iBAAO,EAAE,IAAIC,mBAAA,oBAAoB,KAAK,OAAO,EAAE,QAAQ;AAAA,QAAA;AAGxD,YAAI,MAAM,UAAU;AACnB,gBAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAErC,iBAAO,EAAE,IAAI,KAAK,OAAO,YAAY;AAAA,QAAA;AAG/B,eAAA;AAAA,UACN;AAAA,UACA;AAAA,UACA,OAAO;AAAA,YACN;AAAA,YACA;AAAA,YACA,SAAS,MAAM;AAAA,YACf,QAAQ,MAAM;AAAA,UAAA;AAAA,QAEhB;AAAA,MAAA,CACA;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,40 @@
1
+ import { ComponentOrTagName } from '../types';
2
+ import { SliceComponentType, SliceLike, SliceZoneComponents, SliceZoneLike } from './types';
3
+ /**
4
+ * Props for `<SliceZone />`.
5
+ *
6
+ * @typeParam TContext - Arbitrary data made available to all Slice components
7
+ */
8
+ export type SliceZoneProps<TContext = unknown> = {
9
+ /**
10
+ * List of Slice data from the Slice Zone.
11
+ */
12
+ slices: SliceZoneLike<SliceLike & Record<string, unknown>>;
13
+ /**
14
+ * A record mapping Slice types to Vue components.
15
+ */
16
+ components?: SliceZoneComponents;
17
+ /**
18
+ * The Vue component rendered if a component mapping from the `components`
19
+ * prop cannot be found.
20
+ *
21
+ * @remarks
22
+ * Components will be rendered using the {@link SliceComponentProps} interface.
23
+ *
24
+ * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
25
+ */
26
+ defaultComponent?: SliceComponentType<any, TContext>;
27
+ /**
28
+ * Arbitrary data made available to all Slice components.
29
+ */
30
+ context?: TContext;
31
+ /**
32
+ * An HTML tag name or a component used to wrap the output. `<SliceZone />` is
33
+ * not wrapped by default.
34
+ *
35
+ * @defaultValue `"template"` (no wrapper)
36
+ */
37
+ wrapper?: ComponentOrTagName;
38
+ };
39
+ declare const _default: import('vue').DefineComponent<SliceZoneProps<unknown>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SliceZoneProps<unknown>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
40
+ export default _default;
@@ -0,0 +1,64 @@
1
+ import { defineComponent, computed, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, resolveDynamicComponent, mergeProps, createCommentVNode } from "vue";
2
+ import _sfc_main$1 from "../lib/Wrapper.vue.js";
3
+ import { usePrismic } from "../usePrismic.js";
4
+ import { TODOSliceComponent } from "./TODOSliceComponent.js";
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ ...{ name: "SliceZone" },
7
+ __name: "SliceZone",
8
+ props: {
9
+ slices: {},
10
+ components: {},
11
+ defaultComponent: {},
12
+ context: {},
13
+ wrapper: {}
14
+ },
15
+ setup(__props) {
16
+ const props = __props;
17
+ const { options } = usePrismic();
18
+ const renderedSlices = computed(() => {
19
+ return props.slices.map((slice, index) => {
20
+ var _a, _b;
21
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
22
+ const key = "id" in slice && typeof slice.id === "string" ? slice.id : `${index}-${JSON.stringify(slice)}`;
23
+ const is = ((_a = props.components) == null ? void 0 : _a[type]) || props.defaultComponent || ((_b = options.components) == null ? void 0 : _b.sliceZoneDefaultComponent);
24
+ if (!is) {
25
+ return { is: TODOSliceComponent, key, props: { slice } };
26
+ }
27
+ if (slice.__mapped) {
28
+ const { __mapped, ...mappedProps } = slice;
29
+ return { is, key, props: mappedProps };
30
+ }
31
+ return {
32
+ is,
33
+ key,
34
+ props: {
35
+ slice,
36
+ index,
37
+ context: props.context,
38
+ slices: props.slices
39
+ }
40
+ };
41
+ });
42
+ });
43
+ return (_ctx, _cache) => {
44
+ return _ctx.slices ? (openBlock(), createBlock(_sfc_main$1, {
45
+ key: 0,
46
+ wrapper: _ctx.wrapper
47
+ }, {
48
+ default: withCtx(() => [
49
+ (openBlock(true), createElementBlock(Fragment, null, renderList(renderedSlices.value, (renderedSlice) => {
50
+ return openBlock(), createBlock(resolveDynamicComponent(renderedSlice.is), mergeProps({
51
+ key: renderedSlice.key,
52
+ ref_for: true
53
+ }, renderedSlice.props), null, 16);
54
+ }), 128))
55
+ ]),
56
+ _: 1
57
+ }, 8, ["wrapper"])) : createCommentVNode("", true);
58
+ };
59
+ }
60
+ });
61
+ export {
62
+ _sfc_main as default
63
+ };
64
+ //# sourceMappingURL=SliceZone.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.vue.js","sources":["../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport Wrapper from \"../lib/Wrapper.vue\"\n\nimport type { ComponentOrTagName } from \"../types\"\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike<SliceLike & Record<string, unknown>>\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext\n\n\t/**\n\t * An HTML tag name or a component used to wrap the output. `<SliceZone />` is\n\t * not wrapped by default.\n\t *\n\t * @defaultValue `\"template\"` (no wrapper)\n\t */\n\twrapper?: ComponentOrTagName\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst { options } = usePrismic()\n\nconst renderedSlices = computed(() => {\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is =\n\t\t\tprops.components?.[type] ||\n\t\t\tprops.defaultComponent ||\n\t\t\toptions.components?.sliceZoneDefaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<Wrapper v-if=\"slices\" :wrapper=\"wrapper\">\n\t\t<component\n\t\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t\t:is=\"renderedSlice.is\"\n\t\t\t:key=\"renderedSlice.key\"\n\t\t\tv-bind=\"renderedSlice.props\"\n\t\t/>\n\t</Wrapper>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2DA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAEzB,UAAA,iBAAiB,SAAS,MAAM;AACrC,aAAO,MAAM,OAAO,IAAI,CAAC,OAAO,UAAU;;AACzC,cAAM,OACL,gBAAgB,QAAS,MAAM,aAAwB,MAAM;AAE9D,cAAM,MACL,QAAQ,SAAS,OAAO,MAAM,OAAO,WAClC,MAAM,KACN,GAAG,KAAK,IAAI,KAAK,UAAU,KAAK,CAAC;AAE/B,cAAA,OACL,WAAM,eAAN,mBAAmB,UACnB,MAAM,sBACN,aAAQ,eAAR,mBAAoB;AAErB,YAAI,CAAC,IAAI;AACR,iBAAO,EAAE,IAAI,oBAAoB,KAAK,OAAO,EAAE,QAAQ;AAAA,QAAA;AAGxD,YAAI,MAAM,UAAU;AACnB,gBAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAErC,iBAAO,EAAE,IAAI,KAAK,OAAO,YAAY;AAAA,QAAA;AAG/B,eAAA;AAAA,UACN;AAAA,UACA;AAAA,UACA,OAAO;AAAA,YACN;AAAA,YACA;AAAA,YACA,SAAS,MAAM;AAAA,YACf,QAAQ,MAAM;AAAA,UAAA;AAAA,QAEhB;AAAA,MAAA,CACA;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ const SliceZone_vue_vue_type_script_setup_true_lang = require("./SliceZone.vue.cjs");
3
+ module.exports = SliceZone_vue_vue_type_script_setup_true_lang;
4
+ //# sourceMappingURL=SliceZone.vue2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.vue2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./SliceZone.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
5
+ //# sourceMappingURL=SliceZone.vue2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceZone.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const esmEnv = require("esm-env");
4
+ const vue = require("vue");
5
+ const TODOSliceComponent = esmEnv.DEV ? /* @__PURE__ */ vue.defineComponent({
6
+ name: "TODOSliceComponent",
7
+ props: {
8
+ slice: {
9
+ type: Object,
10
+ required: true
11
+ }
12
+ },
13
+ setup(props) {
14
+ const type = vue.computed(() => {
15
+ return "slice_type" in props.slice ? props.slice.slice_type : props.slice.type;
16
+ });
17
+ vue.watchEffect(() => {
18
+ console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
19
+ });
20
+ return () => {
21
+ return vue.h("section", {
22
+ "data-slice-zone-todo-component": "",
23
+ "data-slice-type": type.value
24
+ }, [`Could not find a component for Slice type "${type.value}"`]);
25
+ };
26
+ }
27
+ }) : () => null;
28
+ exports.TODOSliceComponent = TODOSliceComponent;
29
+ //# sourceMappingURL=TODOSliceComponent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TODOSliceComponent.cjs","sources":["../../../src/SliceZone/TODOSliceComponent.ts"],"sourcesContent":["import { DEV } from \"esm-env\"\nimport type { PropType } from \"vue\"\nimport { computed, defineComponent, h, watchEffect } from \"vue\"\n\nimport type { SliceComponentType, SliceLike } from \"./types\"\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = DEV\n\t? /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type\n\t\t\t\t})\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t)\n\t\t\t\t})\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t}) as SliceComponentType)\n\t: ((() => null) as SliceComponentType)\n"],"names":["DEV","defineComponent","computed","watchEffect","h"],"mappings":";;;;AAaa,MAAA,qBAAqBA,aACAC,oCAAA;AAAA,EAC/B,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AACJ,UAAA,OAAOC,IAAAA,SAAS,MAAK;AAC1B,aAAO,gBAAgB,MAAM,QAC1B,MAAM,MAAM,aACZ,MAAM,MAAM;AAAA,IAAA,CACf;AAEDC,QAAAA,YAAY,MAAK;AAChB,cAAQ,KACP,0DAA0D,KAAK,KAAK,KACpE,MAAM,KAAK;AAAA,IAAA,CAEZ;AAED,WAAO,MAAK;AACX,aAAOC,IAAAA,EACN,WACA;AAAA,QACC,kCAAkC;AAAA,QAClC,mBAAmB,KAAK;AAAA,MAAA,GAEzB,CAAC,8CAA8C,KAAK,KAAK,GAAG,CAAC;AAAA,IAE/D;AAAA,EAAA;CAED,IACE,MAAM;;"}
@@ -0,0 +1,9 @@
1
+ import type { SliceComponentType } from "./types";
2
+ /**
3
+ * This Slice component can be used as a reminder to provide a proper
4
+ * implementation.
5
+ *
6
+ * This is also the default Vue component rendered when a component mapping
7
+ * cannot be found in `<SliceZone />`.
8
+ */
9
+ export declare const TODOSliceComponent: SliceComponentType;
@@ -0,0 +1,29 @@
1
+ import { DEV } from "esm-env";
2
+ import { defineComponent, computed, watchEffect, h } from "vue";
3
+ const TODOSliceComponent = DEV ? /* @__PURE__ */ defineComponent({
4
+ name: "TODOSliceComponent",
5
+ props: {
6
+ slice: {
7
+ type: Object,
8
+ required: true
9
+ }
10
+ },
11
+ setup(props) {
12
+ const type = computed(() => {
13
+ return "slice_type" in props.slice ? props.slice.slice_type : props.slice.type;
14
+ });
15
+ watchEffect(() => {
16
+ console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
17
+ });
18
+ return () => {
19
+ return h("section", {
20
+ "data-slice-zone-todo-component": "",
21
+ "data-slice-type": type.value
22
+ }, [`Could not find a component for Slice type "${type.value}"`]);
23
+ };
24
+ }
25
+ }) : () => null;
26
+ export {
27
+ TODOSliceComponent
28
+ };
29
+ //# sourceMappingURL=TODOSliceComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TODOSliceComponent.js","sources":["../../../src/SliceZone/TODOSliceComponent.ts"],"sourcesContent":["import { DEV } from \"esm-env\"\nimport type { PropType } from \"vue\"\nimport { computed, defineComponent, h, watchEffect } from \"vue\"\n\nimport type { SliceComponentType, SliceLike } from \"./types\"\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = DEV\n\t? /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type\n\t\t\t\t})\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t)\n\t\t\t\t})\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t}) as SliceComponentType)\n\t: ((() => null) as SliceComponentType)\n"],"names":[],"mappings":";;AAaa,MAAA,qBAAqB,MACA,gCAAA;AAAA,EAC/B,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AACJ,UAAA,OAAO,SAAS,MAAK;AAC1B,aAAO,gBAAgB,MAAM,QAC1B,MAAM,MAAM,aACZ,MAAM,MAAM;AAAA,IAAA,CACf;AAED,gBAAY,MAAK;AAChB,cAAQ,KACP,0DAA0D,KAAK,KAAK,KACpE,MAAM,KAAK;AAAA,IAAA,CAEZ;AAED,WAAO,MAAK;AACX,aAAO,EACN,WACA;AAAA,QACC,kCAAkC;AAAA,QAClC,mBAAmB,KAAK;AAAA,MAAA,GAEzB,CAAC,8CAA8C,KAAK,KAAK,GAAG,CAAC;AAAA,IAE/D;AAAA,EAAA;CAED,IACE,MAAM;"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const defineSliceZoneComponents = (components) => {
5
+ const result = {};
6
+ let type;
7
+ for (type in components) {
8
+ const component = components[type];
9
+ result[type] = typeof component === "string" ? component : vue.markRaw(component);
10
+ }
11
+ return result;
12
+ };
13
+ exports.defineSliceZoneComponents = defineSliceZoneComponents;
14
+ //# sourceMappingURL=defineSliceZoneComponents.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineSliceZoneComponents.cjs","sources":["../../../src/SliceZone/defineSliceZoneComponents.ts"],"sourcesContent":["import { markRaw } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n} from \"./types\"\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n *\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>\n\n\tlet type: keyof typeof components\n\tfor (type in components) {\n\t\tconst component = components[type]\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t\t)\n\t}\n\n\treturn result\n}\n"],"names":["markRaw"],"mappings":";;;AA0Ca,MAAA,4BAA4B,CAKxC,eAC0C;AAC1C,QAAM,SAAS,CAAA;AAEX,MAAA;AACJ,OAAK,QAAQ,YAAY;AAClB,UAAA,YAAY,WAAW,IAAI;AACjC,WAAO,IAAI,IACV,OAAO,cAAc,WAClB,YACAA,YACA,SAGC;AAAA,EAAA;AAIC,SAAA;AACR;;"}
@@ -0,0 +1,36 @@
1
+ import type { SliceLike, SliceZoneComponents } from "./types";
2
+ /**
3
+ * Gets an optimized record of Slice types mapped to Vue components. Each
4
+ * components will be rendered for each instance of their Slice type.
5
+ *
6
+ * @remarks
7
+ * This is essentially an helper function to ensure {@link markRaw} is correctly
8
+ * applied on each components, improving performances.
9
+ *
10
+ * @example
11
+ *
12
+ * ```javascript
13
+ * // Defining a slice components
14
+ * import { defineSliceZoneComponents } from "@prismicio/vue";
15
+ *
16
+ * export default {
17
+ * data() {
18
+ * components: defineSliceZoneComponents({
19
+ * foo: Foo,
20
+ * bar: defineAsyncComponent(
21
+ * () => new Promise((res) => res(Bar)),
22
+ * ),
23
+ * baz: "Baz",
24
+ * }),
25
+ * }
26
+ * };
27
+ * ```
28
+ *
29
+ * @typeParam TSlice - The type(s) of slices in the Slice Zone
30
+ * @typeParam TContext - Arbitrary data made available to all Slice components
31
+ *
32
+ * @param components - {@link SliceZoneComponents}
33
+ *
34
+ * @returns A new optimized record of {@link SliceZoneComponents}
35
+ */
36
+ export declare const defineSliceZoneComponents: <TSlice extends SliceLike = any, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
@@ -0,0 +1,14 @@
1
+ import { markRaw } from "vue";
2
+ const defineSliceZoneComponents = (components) => {
3
+ const result = {};
4
+ let type;
5
+ for (type in components) {
6
+ const component = components[type];
7
+ result[type] = typeof component === "string" ? component : markRaw(component);
8
+ }
9
+ return result;
10
+ };
11
+ export {
12
+ defineSliceZoneComponents
13
+ };
14
+ //# sourceMappingURL=defineSliceZoneComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineSliceZoneComponents.js","sources":["../../../src/SliceZone/defineSliceZoneComponents.ts"],"sourcesContent":["import { markRaw } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n} from \"./types\"\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n *\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>\n\n\tlet type: keyof typeof components\n\tfor (type in components) {\n\t\tconst component = components[type]\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t\t)\n\t}\n\n\treturn result\n}\n"],"names":[],"mappings":";AA0Ca,MAAA,4BAA4B,CAKxC,eAC0C;AAC1C,QAAM,SAAS,CAAA;AAEX,MAAA;AACJ,OAAK,QAAQ,YAAY;AAClB,UAAA,YAAY,WAAW,IAAI;AACjC,WAAO,IAAI,IACV,OAAO,cAAc,WAClB,YACA,QACA,SAGC;AAAA,EAAA;AAIC,SAAA;AACR;"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const getSliceComponentProps = (propsHint) => ({
4
+ slice: {
5
+ type: Object,
6
+ required: true
7
+ },
8
+ index: {
9
+ type: Number,
10
+ required: true
11
+ },
12
+ slices: {
13
+ type: Array,
14
+ required: true
15
+ },
16
+ context: {
17
+ type: null,
18
+ required: true
19
+ }
20
+ });
21
+ exports.getSliceComponentProps = getSliceComponentProps;
22
+ //# sourceMappingURL=getSliceComponentProps.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSliceComponentProps.cjs","sources":["../../../src/SliceZone/getSliceComponentProps.ts"],"sourcesContent":["import type { PropType } from \"vue\"\n\nimport type { SliceComponentProps, SliceLike } from \"./types\"\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\ntype DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>\n\t\trequired: true\n\t}\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>\n\t\trequired: true\n\t}\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>\n\t\trequired: true\n\t}\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>\n\t\trequired: true\n\t}\n}\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```typescript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * defineProps(getSliceComponentProps())\n * ```\n *\n * @example\n *\n * ```typescript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * defineProps(\n * \tgetSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * )\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n *\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with `defineProps()`\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n})\n"],"names":[],"mappings":";;AAuEa,MAAA,yBAAyB,CAMrC,eAC2D;AAAA,EAC3D,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,QAAQ;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,SAAS;AAAA,IACR,MAAM;AAAA,IAGN,UAAU;AAAA,EAAA;AAEX;;"}
@@ -0,0 +1,66 @@
1
+ import type { PropType } from "vue";
2
+ import type { SliceComponentProps, SliceLike } from "./types";
3
+ /**
4
+ * Native Vue props for a component rendering content from a Prismic Slice using
5
+ * the `<SliceZone />` component.
6
+ *
7
+ * @typeParam TSlice - The Slice type
8
+ * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
9
+ * available to all Slice components
10
+ */
11
+ type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
12
+ slice: {
13
+ type: PropType<SliceComponentProps<TSlice, TContext>["slice"]>;
14
+ required: true;
15
+ };
16
+ index: {
17
+ type: PropType<SliceComponentProps<TSlice, TContext>["index"]>;
18
+ required: true;
19
+ };
20
+ slices: {
21
+ type: PropType<SliceComponentProps<TSlice, TContext>["slices"]>;
22
+ required: true;
23
+ };
24
+ context: {
25
+ type: PropType<SliceComponentProps<TSlice, TContext>["context"]>;
26
+ required: true;
27
+ };
28
+ };
29
+ /**
30
+ * Gets native Vue props for a component rendering content from a Prismic Slice
31
+ * using the `<SliceZone />` component.
32
+ *
33
+ * Props are: `["slice", "index", "slices", "context"]`
34
+ *
35
+ * @example
36
+ *
37
+ * ```typescript
38
+ * // Defining a new slice component
39
+ * import { getSliceComponentProps } from "@prismicio/vue"
40
+ *
41
+ * defineProps(getSliceComponentProps())
42
+ * ```
43
+ *
44
+ * @example
45
+ *
46
+ * ```typescript
47
+ * // Defining a new slice component with visual hint
48
+ * import { getSliceComponentProps } from "@prismicio/vue"
49
+ *
50
+ * defineProps(
51
+ * getSliceComponentProps(["slice", "index", "slices", "context"]),
52
+ * )
53
+ * ```
54
+ *
55
+ * @typeParam TSlice - The Slice type
56
+ * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
57
+ * available to all Slice components
58
+ *
59
+ * @param propsHint - An optional array of prop names used for the sole purpose
60
+ * of having a visual hint of which props are made available to the slice,
61
+ * this parameters doesn't have any effect
62
+ *
63
+ * @returns Props object to use with `defineProps()`
64
+ */
65
+ export declare const getSliceComponentProps: <TSlice extends SliceLike = any, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
66
+ export {};
@@ -0,0 +1,22 @@
1
+ const getSliceComponentProps = (propsHint) => ({
2
+ slice: {
3
+ type: Object,
4
+ required: true
5
+ },
6
+ index: {
7
+ type: Number,
8
+ required: true
9
+ },
10
+ slices: {
11
+ type: Array,
12
+ required: true
13
+ },
14
+ context: {
15
+ type: null,
16
+ required: true
17
+ }
18
+ });
19
+ export {
20
+ getSliceComponentProps
21
+ };
22
+ //# sourceMappingURL=getSliceComponentProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSliceComponentProps.js","sources":["../../../src/SliceZone/getSliceComponentProps.ts"],"sourcesContent":["import type { PropType } from \"vue\"\n\nimport type { SliceComponentProps, SliceLike } from \"./types\"\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\ntype DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>\n\t\trequired: true\n\t}\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>\n\t\trequired: true\n\t}\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>\n\t\trequired: true\n\t}\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>\n\t\trequired: true\n\t}\n}\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```typescript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * defineProps(getSliceComponentProps())\n * ```\n *\n * @example\n *\n * ```typescript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * defineProps(\n * \tgetSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * )\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n *\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with `defineProps()`\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n})\n"],"names":[],"mappings":"AAuEa,MAAA,yBAAyB,CAMrC,eAC2D;AAAA,EAC3D,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,QAAQ;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,SAAS;AAAA,IACR,MAAM;AAAA,IAGN,UAAU;AAAA,EAAA;AAEX;"}
@@ -0,0 +1,4 @@
1
+ export { TODOSliceComponent } from "./TODOSliceComponent";
2
+ export { getSliceComponentProps } from "./getSliceComponentProps";
3
+ export { defineSliceZoneComponents } from "./defineSliceZoneComponents";
4
+ export type { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZoneComponents, SliceZoneLike, } from "./types";
@@ -0,0 +1,97 @@
1
+ import type { Slice } from "@prismicio/client";
2
+ import type { DefineComponent, FunctionalComponent, defineAsyncComponent } from "vue";
3
+ /**
4
+ * Returns the type of a `SliceLike` type.
5
+ *
6
+ * @typeParam TSlice - The Slice from which the type will be extracted.
7
+ */
8
+ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
9
+ /**
10
+ * The minimum required properties to represent a Prismic Slice from the Prismic
11
+ * Rest API V2 for the `unstable_mapSliceZone()` helper.
12
+ *
13
+ * @typeParam SliceType - Type name of the Slice.
14
+ */
15
+ export type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
16
+ /**
17
+ * The minimum required properties to represent a Prismic Slice from the Prismic
18
+ * GraphQL API for the `unstable_mapSliceZone()` helper.
19
+ *
20
+ * @typeParam SliceType - Type name of the Slice.
21
+ */
22
+ export type SliceLikeGraphQL<TSliceType extends string = string> = {
23
+ type: Slice<TSliceType>["slice_type"];
24
+ };
25
+ /**
26
+ * The minimum required properties to represent a Prismic Slice for the
27
+ * `<SliceZone />` component.
28
+ *
29
+ * If using Prismic's Rest API V2, use the `Slice` export from
30
+ * `@prismicio/client` for a full interface.
31
+ *
32
+ * @typeParam TSliceType - Type name of the Slice
33
+ */
34
+ export type SliceLike<TSliceType extends string = string> = (SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>) & {
35
+ /**
36
+ * If `true`, this Slice has been modified from its original value using a
37
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
38
+ *
39
+ * @internal
40
+ */
41
+ __mapped?: true;
42
+ };
43
+ /**
44
+ * A looser version of the `SliceZone` type from `@prismicio/client` using
45
+ * `SliceLike`.
46
+ *
47
+ * If using Prismic's REST API, use the `SliceZone` export from
48
+ * `@prismicio/client` for the full type.
49
+ *
50
+ * @typeParam TSlice - The type(s) of slices in the Slice Zone
51
+ */
52
+ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
53
+ /**
54
+ * Vue props for a component rendering content from a Prismic Slice using the
55
+ * `<SliceZone />` component.
56
+ *
57
+ * @typeParam TSlice - The type(s) of slices in the Slice Zone
58
+ * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
59
+ * available to all Slice components
60
+ */
61
+ export type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
62
+ /**
63
+ * Slice data for this component.
64
+ */
65
+ slice: TSlice;
66
+ /**
67
+ * The index of the Slice in the Slice Zone.
68
+ */
69
+ index: number;
70
+ /**
71
+ * All Slices from the Slice Zone to which the Slice belongs.
72
+ */
73
+ slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
74
+ /**
75
+ * Arbitrary data passed to `<SliceZone />` and made available to all Slice
76
+ * components.
77
+ */
78
+ context: TContext;
79
+ };
80
+ /**
81
+ * A Vue component to be rendered for each instance of its Slice.
82
+ *
83
+ * @typeParam TSlice - The type(s) of slices in the Slice Zone
84
+ * @typeParam TContext - Arbitrary data made available to all Slice components
85
+ */
86
+ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = DefineComponent<{}, {}, any> | ReturnType<typeof defineAsyncComponent> | DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent;
87
+ /**
88
+ * A record of Slice types mapped to Vue components. Each components will be
89
+ * rendered for each instance of their Slice type.
90
+ *
91
+ * @typeParam TSlice - The type(s) of slices in the Slice Zone
92
+ * @typeParam TContext - Arbitrary data made available to all Slice components
93
+ */
94
+ export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
95
+ [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>> extends never ? SliceLike : Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
96
+ };
97
+ export {};