@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.
- package/README.md +4 -4
- package/dist/PrismicEmbed.vue.cjs +25 -0
- package/dist/PrismicEmbed.vue.cjs.map +1 -0
- package/dist/PrismicEmbed.vue.d.ts +19 -0
- package/dist/PrismicEmbed.vue.js +26 -0
- package/dist/PrismicEmbed.vue.js.map +1 -0
- package/dist/PrismicEmbed.vue2.cjs +4 -0
- package/dist/PrismicEmbed.vue2.cjs.map +1 -0
- package/dist/PrismicEmbed.vue2.js +5 -0
- package/dist/PrismicEmbed.vue2.js.map +1 -0
- package/dist/PrismicImage.vue.cjs +84 -0
- package/dist/PrismicImage.vue.cjs.map +1 -0
- package/dist/PrismicImage.vue.d.ts +224 -0
- package/dist/PrismicImage.vue.js +85 -0
- package/dist/PrismicImage.vue.js.map +1 -0
- package/dist/PrismicImage.vue2.cjs +4 -0
- package/dist/PrismicImage.vue2.cjs.map +1 -0
- package/dist/PrismicImage.vue2.js +5 -0
- package/dist/PrismicImage.vue2.js.map +1 -0
- package/dist/PrismicLink.vue.cjs +100 -0
- package/dist/PrismicLink.vue.cjs.map +1 -0
- package/dist/PrismicLink.vue.d.ts +279 -0
- package/dist/PrismicLink.vue.js +101 -0
- package/dist/PrismicLink.vue.js.map +1 -0
- package/dist/PrismicLink.vue2.cjs +4 -0
- package/dist/PrismicLink.vue2.cjs.map +1 -0
- package/dist/PrismicLink.vue2.js +5 -0
- package/dist/PrismicLink.vue2.js.map +1 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs +90 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs.map +1 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.d.ts +8 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js +91 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js.map +1 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs +4 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs.map +1 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js +5 -0
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichText.vue.cjs +85 -0
- package/dist/PrismicRichText/PrismicRichText.vue.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichText.vue.d.ts +57 -0
- package/dist/PrismicRichText/PrismicRichText.vue.js +86 -0
- package/dist/PrismicRichText/PrismicRichText.vue.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichText.vue2.cjs +4 -0
- package/dist/PrismicRichText/PrismicRichText.vue2.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichText.vue2.js +5 -0
- package/dist/PrismicRichText/PrismicRichText.vue2.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs +133 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.d.ts +37 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js +134 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs +4 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js +5 -0
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs +47 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.d.ts +10 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js +48 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs +4 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs.map +1 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js +5 -0
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js.map +1 -0
- package/dist/PrismicRichText/getRichTextComponentProps.cjs +10 -0
- package/dist/PrismicRichText/getRichTextComponentProps.cjs.map +1 -0
- package/dist/PrismicRichText/getRichTextComponentProps.d.ts +49 -0
- package/dist/PrismicRichText/getRichTextComponentProps.js +10 -0
- package/dist/PrismicRichText/getRichTextComponentProps.js.map +1 -0
- package/dist/PrismicRichText/index.d.ts +2 -0
- package/dist/PrismicRichText/types.d.ts +22 -0
- package/dist/PrismicText.vue.cjs +43 -0
- package/dist/PrismicText.vue.cjs.map +1 -0
- package/dist/PrismicText.vue.d.ts +31 -0
- package/dist/PrismicText.vue.js +44 -0
- package/dist/PrismicText.vue.js.map +1 -0
- package/dist/PrismicText.vue2.cjs +4 -0
- package/dist/PrismicText.vue2.cjs.map +1 -0
- package/dist/PrismicText.vue2.js +5 -0
- package/dist/PrismicText.vue2.js.map +1 -0
- package/dist/SliceZone/SliceZone.vue.cjs +63 -0
- package/dist/SliceZone/SliceZone.vue.cjs.map +1 -0
- package/dist/SliceZone/SliceZone.vue.d.ts +41 -0
- package/dist/SliceZone/SliceZone.vue.js +64 -0
- package/dist/SliceZone/SliceZone.vue.js.map +1 -0
- package/dist/SliceZone/SliceZone.vue2.cjs +4 -0
- package/dist/SliceZone/SliceZone.vue2.cjs.map +1 -0
- package/dist/SliceZone/SliceZone.vue2.js +5 -0
- package/dist/SliceZone/SliceZone.vue2.js.map +1 -0
- package/dist/SliceZone/TODOSliceComponent.cjs +29 -0
- package/dist/SliceZone/TODOSliceComponent.cjs.map +1 -0
- package/dist/SliceZone/TODOSliceComponent.d.ts +9 -0
- package/dist/SliceZone/TODOSliceComponent.js +29 -0
- package/dist/SliceZone/TODOSliceComponent.js.map +1 -0
- package/dist/SliceZone/defineSliceZoneComponents.cjs +14 -0
- package/dist/SliceZone/defineSliceZoneComponents.cjs.map +1 -0
- package/dist/SliceZone/defineSliceZoneComponents.d.ts +36 -0
- package/dist/SliceZone/defineSliceZoneComponents.js +14 -0
- package/dist/SliceZone/defineSliceZoneComponents.js.map +1 -0
- package/dist/SliceZone/getSliceComponentProps.cjs +22 -0
- package/dist/SliceZone/getSliceComponentProps.cjs.map +1 -0
- package/dist/SliceZone/getSliceComponentProps.d.ts +66 -0
- package/dist/SliceZone/getSliceComponentProps.js +22 -0
- package/dist/SliceZone/getSliceComponentProps.js.map +1 -0
- package/dist/SliceZone/index.d.ts +4 -0
- package/dist/SliceZone/types.d.ts +97 -0
- package/dist/createPrismic.cjs +17 -50
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.d.ts +10 -0
- package/dist/createPrismic.js +16 -27
- package/dist/createPrismic.js.map +1 -1
- package/dist/index.cjs +21 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.js +19 -38
- package/dist/index.js.map +1 -1
- package/dist/lib/Wrapper.vue.cjs +20 -0
- package/dist/lib/Wrapper.vue.cjs.map +1 -0
- package/dist/lib/Wrapper.vue.d.ts +28 -0
- package/dist/lib/Wrapper.vue.js +21 -0
- package/dist/lib/Wrapper.vue.js.map +1 -0
- package/dist/lib/Wrapper.vue2.cjs +4 -0
- package/dist/lib/Wrapper.vue2.cjs.map +1 -0
- package/dist/lib/Wrapper.vue2.js +5 -0
- package/dist/lib/Wrapper.vue2.js.map +1 -0
- package/dist/lib/devMsg.cjs +8 -0
- package/dist/lib/devMsg.cjs.map +1 -0
- package/dist/lib/devMsg.d.ts +16 -0
- package/dist/lib/devMsg.js +8 -0
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +5 -0
- package/dist/package.json.js.map +1 -0
- package/dist/types.d.ts +32 -56
- package/dist/usePrismic.cjs +3 -2
- package/dist/usePrismic.cjs.map +1 -1
- package/dist/usePrismic.d.ts +8 -0
- package/dist/usePrismic.js +2 -1
- package/dist/usePrismic.js.map +1 -1
- package/package.json +21 -23
- package/src/PrismicEmbed.vue +42 -0
- package/src/PrismicImage.vue +160 -0
- package/src/PrismicLink.vue +191 -0
- package/src/PrismicRichText/DeprecatedPrismicRichText.vue +130 -0
- package/src/PrismicRichText/PrismicRichText.vue +157 -0
- package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +63 -0
- package/src/PrismicRichText/PrismicRichTextSerialize.vue +52 -0
- package/src/PrismicRichText/getRichTextComponentProps.ts +63 -0
- package/src/PrismicRichText/index.ts +3 -0
- package/src/PrismicRichText/types.ts +37 -0
- package/src/PrismicText.vue +63 -0
- package/src/SliceZone/SliceZone.vue +113 -0
- package/src/SliceZone/TODOSliceComponent.ts +49 -0
- package/src/SliceZone/defineSliceZoneComponents.ts +67 -0
- package/src/SliceZone/getSliceComponentProps.ts +98 -0
- package/src/SliceZone/index.ts +13 -0
- package/src/SliceZone/types.ts +163 -0
- package/src/createPrismic.ts +28 -33
- package/src/index.ts +32 -57
- package/src/lib/Wrapper.vue +22 -0
- package/src/lib/devMsg.ts +20 -0
- package/src/types.ts +39 -66
- package/src/usePrismic.ts +8 -1
- package/dist/components/PrismicEmbed.cjs +0 -36
- package/dist/components/PrismicEmbed.cjs.map +0 -1
- package/dist/components/PrismicEmbed.d.ts +0 -59
- package/dist/components/PrismicEmbed.js +0 -36
- package/dist/components/PrismicEmbed.js.map +0 -1
- package/dist/components/PrismicImage.cjs +0 -122
- package/dist/components/PrismicImage.cjs.map +0 -1
- package/dist/components/PrismicImage.d.ts +0 -165
- package/dist/components/PrismicImage.js +0 -122
- package/dist/components/PrismicImage.js.map +0 -1
- package/dist/components/PrismicLink.cjs +0 -120
- package/dist/components/PrismicLink.cjs.map +0 -1
- package/dist/components/PrismicLink.d.ts +0 -198
- package/dist/components/PrismicLink.js +0 -120
- package/dist/components/PrismicLink.js.map +0 -1
- package/dist/components/PrismicRichText.cjs +0 -108
- package/dist/components/PrismicRichText.cjs.map +0 -1
- package/dist/components/PrismicRichText.d.ts +0 -161
- package/dist/components/PrismicRichText.js +0 -108
- package/dist/components/PrismicRichText.js.map +0 -1
- package/dist/components/PrismicText.cjs +0 -57
- package/dist/components/PrismicText.cjs.map +0 -1
- package/dist/components/PrismicText.d.ts +0 -119
- package/dist/components/PrismicText.js +0 -57
- package/dist/components/PrismicText.js.map +0 -1
- package/dist/components/SliceZone.cjs +0 -156
- package/dist/components/SliceZone.cjs.map +0 -1
- package/dist/components/SliceZone.d.ts +0 -377
- package/dist/components/SliceZone.js +0 -156
- package/dist/components/SliceZone.js.map +0 -1
- package/dist/components/index.d.ts +0 -12
- package/dist/composables.cjs +0 -40
- package/dist/composables.cjs.map +0 -1
- package/dist/composables.d.ts +0 -348
- package/dist/composables.js +0 -40
- package/dist/composables.js.map +0 -1
- package/dist/globalExtensions.d.ts +0 -11
- package/dist/injectionSymbols.cjs +0 -5
- package/dist/injectionSymbols.cjs.map +0 -1
- package/dist/injectionSymbols.d.ts +0 -9
- package/dist/injectionSymbols.js +0 -5
- package/dist/injectionSymbols.js.map +0 -1
- package/dist/lib/__PRODUCTION__.cjs +0 -8
- package/dist/lib/__PRODUCTION__.cjs.map +0 -1
- package/dist/lib/__PRODUCTION__.d.ts +0 -7
- package/dist/lib/__PRODUCTION__.js +0 -8
- package/dist/lib/__PRODUCTION__.js.map +0 -1
- package/dist/lib/getSlots.cjs +0 -21
- package/dist/lib/getSlots.cjs.map +0 -1
- package/dist/lib/getSlots.d.ts +0 -14
- package/dist/lib/getSlots.js +0 -21
- package/dist/lib/getSlots.js.map +0 -1
- package/dist/lib/simplyResolveComponent.cjs +0 -8
- package/dist/lib/simplyResolveComponent.cjs.map +0 -1
- package/dist/lib/simplyResolveComponent.d.ts +0 -12
- package/dist/lib/simplyResolveComponent.js +0 -8
- package/dist/lib/simplyResolveComponent.js.map +0 -1
- package/dist/useStatefulPrismicClientMethod.cjs +0 -39
- package/dist/useStatefulPrismicClientMethod.cjs.map +0 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +0 -65
- package/dist/useStatefulPrismicClientMethod.js +0 -39
- package/dist/useStatefulPrismicClientMethod.js.map +0 -1
- package/src/components/PrismicEmbed.ts +0 -90
- package/src/components/PrismicImage.ts +0 -307
- package/src/components/PrismicLink.ts +0 -324
- package/src/components/PrismicRichText.ts +0 -283
- package/src/components/PrismicText.ts +0 -165
- package/src/components/SliceZone.ts +0 -617
- package/src/components/index.ts +0 -42
- package/src/composables.ts +0 -492
- package/src/globalExtensions.ts +0 -12
- package/src/injectionSymbols.ts +0 -17
- package/src/lib/__PRODUCTION__.ts +0 -12
- package/src/lib/getSlots.ts +0 -43
- package/src/lib/simplyResolveComponent.ts +0 -18
- package/src/useStatefulPrismicClientMethod.ts +0 -158
- package/vetur/attributes.json +0 -113
- 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 | (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,41 @@
|
|
|
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 | (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
|
+
type __VLS_Props = SliceZoneProps;
|
|
40
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
41
|
+
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 | (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 @@
|
|
|
1
|
+
{"version":3,"file":"SliceZone.vue2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -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 {};
|