@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
package/src/index.ts
CHANGED
|
@@ -1,75 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import PrismicRichText from "./PrismicRichText/PrismicRichText.vue"
|
|
2
|
+
import SliceZone from "./SliceZone/SliceZone.vue"
|
|
3
|
+
|
|
4
|
+
import PrismicEmbed from "./PrismicEmbed.vue"
|
|
5
|
+
import PrismicImage from "./PrismicImage.vue"
|
|
6
|
+
import PrismicLink from "./PrismicLink.vue"
|
|
7
|
+
import PrismicText from "./PrismicText.vue"
|
|
8
|
+
|
|
9
|
+
export type { SliceZoneProps } from "./SliceZone/SliceZone.vue"
|
|
10
|
+
export type { PrismicRichTextProps } from "./PrismicRichText/PrismicRichText.vue"
|
|
11
|
+
|
|
12
|
+
export type { PrismicEmbedProps } from "./PrismicEmbed.vue"
|
|
13
|
+
export type { PrismicImageProps } from "./PrismicImage.vue"
|
|
14
|
+
export type { PrismicLinkProps } from "./PrismicLink.vue"
|
|
15
|
+
export type { PrismicTextProps } from "./PrismicText.vue"
|
|
3
16
|
|
|
4
17
|
export {
|
|
5
|
-
|
|
6
|
-
usePrismicImage,
|
|
7
|
-
usePrismicLink,
|
|
8
|
-
usePrismicText,
|
|
9
|
-
usePrismicRichText,
|
|
10
|
-
// Components
|
|
18
|
+
SliceZone,
|
|
11
19
|
PrismicEmbed,
|
|
12
20
|
PrismicImage,
|
|
13
21
|
PrismicLink,
|
|
14
22
|
PrismicText,
|
|
15
23
|
PrismicRichText,
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { getRichTextComponentProps } from "./PrismicRichText"
|
|
27
|
+
export type {
|
|
28
|
+
VueRichTextSerializer,
|
|
29
|
+
RichTextComponentProps,
|
|
30
|
+
} from "./PrismicRichText"
|
|
31
|
+
|
|
32
|
+
export {
|
|
18
33
|
TODOSliceComponent,
|
|
19
34
|
defineSliceZoneComponents,
|
|
20
|
-
|
|
21
|
-
} from "./
|
|
35
|
+
getSliceComponentProps,
|
|
36
|
+
} from "./SliceZone"
|
|
22
37
|
export type {
|
|
23
|
-
// Composables
|
|
24
|
-
UsePrismicImageOptions,
|
|
25
|
-
UsePrismicLinkOptions,
|
|
26
|
-
UsePrismicTextOptions,
|
|
27
|
-
UsePrismicRichTextOptions,
|
|
28
|
-
// Components
|
|
29
|
-
PrismicEmbedProps,
|
|
30
|
-
PrismicImageProps,
|
|
31
|
-
PrismicLinkProps,
|
|
32
|
-
PrismicTextProps,
|
|
33
|
-
PrismicRichTextProps,
|
|
34
|
-
// Slice Zone
|
|
35
|
-
DefineComponentSliceComponentProps,
|
|
36
38
|
SliceComponentProps,
|
|
37
39
|
SliceComponentType,
|
|
38
|
-
SliceLikeRestV2,
|
|
39
|
-
SliceLikeGraphQL,
|
|
40
40
|
SliceLike,
|
|
41
|
+
SliceLikeGraphQL,
|
|
42
|
+
SliceLikeRestV2,
|
|
41
43
|
SliceZoneComponents,
|
|
42
|
-
SliceZoneResolver,
|
|
43
44
|
SliceZoneLike,
|
|
44
|
-
|
|
45
|
-
} from "./components"
|
|
45
|
+
} from "./SliceZone"
|
|
46
46
|
|
|
47
|
-
export {
|
|
48
|
-
useAllPrismicDocumentsByIDs,
|
|
49
|
-
useAllPrismicDocumentsByUIDs,
|
|
50
|
-
useAllPrismicDocumentsByTag,
|
|
51
|
-
useAllPrismicDocumentsByEveryTag,
|
|
52
|
-
useAllPrismicDocumentsBySomeTags,
|
|
53
|
-
useAllPrismicDocumentsByType,
|
|
54
|
-
useFirstPrismicDocument,
|
|
55
|
-
usePrismicDocumentByID,
|
|
56
|
-
usePrismicDocumentByUID,
|
|
57
|
-
usePrismicDocuments,
|
|
58
|
-
usePrismicDocumentsByIDs,
|
|
59
|
-
usePrismicDocumentsByUIDs,
|
|
60
|
-
usePrismicDocumentsByTag,
|
|
61
|
-
usePrismicDocumentsByEveryTag,
|
|
62
|
-
usePrismicDocumentsBySomeTags,
|
|
63
|
-
usePrismicDocumentsByType,
|
|
64
|
-
useSinglePrismicDocument,
|
|
65
|
-
dangerouslyUseAllPrismicDocuments,
|
|
66
|
-
} from "./composables"
|
|
67
|
-
|
|
68
|
-
export type { ClientComposableReturnType } from "./useStatefulPrismicClientMethod"
|
|
69
|
-
|
|
70
|
-
export { PrismicClientComposableState } from "./types"
|
|
71
47
|
export type { PrismicPluginOptions, PrismicPlugin } from "./types"
|
|
72
48
|
|
|
73
|
-
export {
|
|
74
|
-
|
|
75
|
-
export * from "./globalExtensions"
|
|
49
|
+
export { createPrismic } from "./createPrismic"
|
|
50
|
+
export { usePrismic, prismicKey } from "./usePrismic"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ComponentOrTagName } from "../types"
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
/**
|
|
6
|
+
* An HTML tag name or a component used to wrap the output. Output is not
|
|
7
|
+
* wrapped by default.
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue `"template"` (no wrapper)
|
|
10
|
+
*/
|
|
11
|
+
wrapper?: ComponentOrTagName
|
|
12
|
+
}>()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<component v-if="wrapper" :is="wrapper" v-bind="$attrs">
|
|
17
|
+
<slot />
|
|
18
|
+
</component>
|
|
19
|
+
<template v-else>
|
|
20
|
+
<slot />
|
|
21
|
+
</template>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { version } from "../../package.json"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a `prismic.dev/msg` URL for a given message slug.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* devMsg("missing-param")
|
|
10
|
+
* // => "https://prismic.dev/msg/svelte/v1.2.3/missing-param.md"
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param slug - Slug for the message. This corresponds to a Markdown file in
|
|
14
|
+
* the Git repository's `/messages` directory.
|
|
15
|
+
*
|
|
16
|
+
* @returns The `prismic.dev/msg` URL for the given slug.
|
|
17
|
+
*/
|
|
18
|
+
export const devMsg = (slug: string): string => {
|
|
19
|
+
return `https://prismic.dev/msg/vue/v${version}/${slug}`
|
|
20
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
AsLinkAttrsConfig,
|
|
2
3
|
ClientConfig,
|
|
3
4
|
CreateClient,
|
|
4
5
|
HTMLRichTextFunctionSerializer,
|
|
@@ -18,18 +19,17 @@ import type {
|
|
|
18
19
|
isFilled,
|
|
19
20
|
} from "@prismicio/client"
|
|
20
21
|
import type { App, ConcreteComponent, DefineComponent, Raw, Ref } from "vue"
|
|
21
|
-
|
|
22
22
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
23
23
|
// Imports for @link references:
|
|
24
24
|
import type { RouterLink } from "vue-router"
|
|
25
25
|
|
|
26
|
+
import type { VueRichTextSerializer } from "./PrismicRichText/types"
|
|
27
|
+
|
|
26
28
|
import type {
|
|
27
29
|
SliceComponentProps,
|
|
28
30
|
SliceComponentType,
|
|
29
31
|
TODOSliceComponent,
|
|
30
|
-
} from "./
|
|
31
|
-
|
|
32
|
-
import type { usePrismicDocuments } from "./composables"
|
|
32
|
+
} from "./SliceZone"
|
|
33
33
|
|
|
34
34
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
35
35
|
|
|
@@ -38,16 +38,15 @@ import type { usePrismicDocuments } from "./composables"
|
|
|
38
38
|
*/
|
|
39
39
|
type PrismicPluginComponentsOptions = {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* `
|
|
41
|
+
* The `rel` attribute to apply on links. This prop can be provided a function
|
|
42
|
+
* to use the link's metadata to determine the `rel` value.
|
|
43
43
|
*
|
|
44
|
-
* @defaultValue `"
|
|
44
|
+
* @defaultValue `"noreferrer"` for external links.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
linkRel?: AsLinkAttrsConfig["rel"]
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* An HTML tag name
|
|
50
|
-
* internal links.
|
|
49
|
+
* An HTML tag name or a component used to render internal links.
|
|
51
50
|
*
|
|
52
51
|
* @remarks
|
|
53
52
|
* HTML tag names will be rendered using the anchor tag interface (`href`,
|
|
@@ -58,11 +57,10 @@ type PrismicPluginComponentsOptions = {
|
|
|
58
57
|
*
|
|
59
58
|
* @defaultValue {@link RouterLink}
|
|
60
59
|
*/
|
|
61
|
-
linkInternalComponent?:
|
|
60
|
+
linkInternalComponent?: ComponentOrTagName
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
|
-
* An HTML tag name
|
|
65
|
-
* external links.
|
|
63
|
+
* An HTML tag name or a component used to render external links.
|
|
66
64
|
*
|
|
67
65
|
* @remarks
|
|
68
66
|
* HTML tag names will be rendered using the anchor tag interface (`href`,
|
|
@@ -73,20 +71,7 @@ type PrismicPluginComponentsOptions = {
|
|
|
73
71
|
*
|
|
74
72
|
* @defaultValue `"a"`
|
|
75
73
|
*/
|
|
76
|
-
linkExternalComponent?:
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* An HTML tag name, a component, or a functional component used to render
|
|
80
|
-
* images.
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* HTML tag names and components will be rendered using the `img` tag
|
|
84
|
-
* interface (`src` and `alt` attribute). Components will also receive an
|
|
85
|
-
* additional `copyright` props.
|
|
86
|
-
*
|
|
87
|
-
* @defaultValue `"img"`
|
|
88
|
-
*/
|
|
89
|
-
imageComponent?: string | ConcreteComponent | Raw<DefineComponent>
|
|
74
|
+
linkExternalComponent?: ComponentOrTagName
|
|
90
75
|
|
|
91
76
|
/**
|
|
92
77
|
* Default widths to use when rendering an image with `widths="defaults"`
|
|
@@ -108,6 +93,14 @@ type PrismicPluginComponentsOptions = {
|
|
|
108
93
|
*/
|
|
109
94
|
imagePixelDensitySrcSetDefaults?: number[]
|
|
110
95
|
|
|
96
|
+
/**
|
|
97
|
+
* An optional map of Rich Text block types to Vue Components. It is used to
|
|
98
|
+
* render Rich Text or title fields.
|
|
99
|
+
*
|
|
100
|
+
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/rich-text}
|
|
101
|
+
*/
|
|
102
|
+
richTextComponents?: VueRichTextSerializer
|
|
103
|
+
|
|
111
104
|
/**
|
|
112
105
|
* A component or a functional component rendered if a component mapping from
|
|
113
106
|
* the `components` prop cannot be found.
|
|
@@ -137,23 +130,18 @@ type PrismicPluginOptionsBase = {
|
|
|
137
130
|
* An optional HTML serializer to customize the way rich text fields are
|
|
138
131
|
* rendered.
|
|
139
132
|
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* To provide global components for the `<PrismicRichText />` component, use
|
|
135
|
+
* the `components.richTextComponents` option instead.
|
|
136
|
+
*
|
|
137
|
+
* @deprecated Use `components.richTextComponents` instead.
|
|
138
|
+
*
|
|
140
139
|
* @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
141
140
|
*/
|
|
142
141
|
richTextSerializer?:
|
|
143
142
|
| HTMLRichTextFunctionSerializer
|
|
144
143
|
| HTMLRichTextMapSerializer
|
|
145
144
|
|
|
146
|
-
/**
|
|
147
|
-
* An optional HTML serializer to customize the way rich text fields are
|
|
148
|
-
* rendered.
|
|
149
|
-
*
|
|
150
|
-
* @deprecated Use `richTextSerializer` instead.
|
|
151
|
-
*
|
|
152
|
-
* @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
|
|
153
|
-
*/
|
|
154
|
-
// TODO: Remove in v5
|
|
155
|
-
htmlSerializer?: HTMLRichTextFunctionSerializer | HTMLRichTextMapSerializer
|
|
156
|
-
|
|
157
145
|
/**
|
|
158
146
|
* Whether or not to inject components globally.
|
|
159
147
|
*
|
|
@@ -368,21 +356,21 @@ export type PrismicPluginHelpers = {
|
|
|
368
356
|
asDate: typeof asDate
|
|
369
357
|
|
|
370
358
|
/**
|
|
371
|
-
* Returns the URL of an
|
|
359
|
+
* Returns the URL of an image field with optional image transformations (via
|
|
372
360
|
* Imgix URL parameters). This is `@prismicio/client` {@link asImageSrc}
|
|
373
361
|
* function.
|
|
374
362
|
*/
|
|
375
363
|
asImageSrc: typeof asImageSrc
|
|
376
364
|
|
|
377
365
|
/**
|
|
378
|
-
* Creates a width-based `srcset` from an
|
|
366
|
+
* Creates a width-based `srcset` from an image field with optional image
|
|
379
367
|
* transformations (via Imgix URL parameters). This is `@prismicio/client`
|
|
380
368
|
* {@link asImageWidthSrcSet} function.
|
|
381
369
|
*/
|
|
382
370
|
asImageWidthSrcSet: typeof asImageWidthSrcSet
|
|
383
371
|
|
|
384
372
|
/**
|
|
385
|
-
* Creates a pixel-density-based `srcset` from an
|
|
373
|
+
* Creates a pixel-density-based `srcset` from an image field with optional
|
|
386
374
|
* image transformations (via Imgix URL parameters). This is
|
|
387
375
|
* `@prismicio/client` {@link asImagePixelDensitySrcSet} function.
|
|
388
376
|
*/
|
|
@@ -424,31 +412,6 @@ export type PrismicPlugin = {
|
|
|
424
412
|
} & PrismicPluginClient &
|
|
425
413
|
PrismicPluginHelpers
|
|
426
414
|
|
|
427
|
-
/**
|
|
428
|
-
* States of a `@prismicio/client` composable.
|
|
429
|
-
*/
|
|
430
|
-
export const enum PrismicClientComposableState {
|
|
431
|
-
/**
|
|
432
|
-
* The composable has not started fetching.
|
|
433
|
-
*/
|
|
434
|
-
Idle = "idle",
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* The composable is fetching data.
|
|
438
|
-
*/
|
|
439
|
-
Pending = "pending",
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* The composable sucessfully fetched data.
|
|
443
|
-
*/
|
|
444
|
-
Success = "success",
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* The composable failed to fetch data.
|
|
448
|
-
*/
|
|
449
|
-
Error = "error",
|
|
450
|
-
}
|
|
451
|
-
|
|
452
415
|
// Helpers
|
|
453
416
|
|
|
454
417
|
/**
|
|
@@ -469,3 +432,13 @@ export type VueUseOptions<T> = {
|
|
|
469
432
|
export type VueUseParameters<T> = {
|
|
470
433
|
[K in keyof T]: T extends number ? Ref<T[K]> | T[K] : T[K]
|
|
471
434
|
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* A component or a tag name to be used as props.
|
|
438
|
+
*
|
|
439
|
+
* @internal
|
|
440
|
+
*/
|
|
441
|
+
export type ComponentOrTagName =
|
|
442
|
+
| string
|
|
443
|
+
| ConcreteComponent
|
|
444
|
+
| Raw<DefineComponent>
|
package/src/usePrismic.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type { InjectionKey } from "vue"
|
|
1
2
|
import { inject } from "vue"
|
|
2
3
|
|
|
3
4
|
import type { PrismicPlugin } from "./types"
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* `@prismicio/vue` plugin interface interface location used for
|
|
8
|
+
* {@link usePrismic}.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const prismicKey = Symbol("prismic") as InjectionKey<PrismicPlugin>
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Accesses `@prismicio/vue` plugin interface.
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const vue = require("vue");
|
|
4
|
-
const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
|
|
5
|
-
const defaultWrapper = "div";
|
|
6
|
-
const PrismicEmbedImpl = /* @__PURE__ */ vue.defineComponent({
|
|
7
|
-
name: "PrismicEmbed",
|
|
8
|
-
props: {
|
|
9
|
-
field: {
|
|
10
|
-
type: Object,
|
|
11
|
-
required: true
|
|
12
|
-
},
|
|
13
|
-
wrapper: {
|
|
14
|
-
type: [String, Object, Function],
|
|
15
|
-
default: void 0,
|
|
16
|
-
required: false
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
setup(props) {
|
|
20
|
-
if (!props.field) {
|
|
21
|
-
return () => null;
|
|
22
|
-
}
|
|
23
|
-
return () => {
|
|
24
|
-
return vue.h(simplyResolveComponent.simplyResolveComponent(props.wrapper || defaultWrapper), {
|
|
25
|
-
"data-oembed": props.field.embed_url,
|
|
26
|
-
"data-oembed-type": props.field.type,
|
|
27
|
-
"data-oembed-provider": props.field.provider_name,
|
|
28
|
-
innerHTML: props.field.html || null
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const PrismicEmbed = PrismicEmbedImpl;
|
|
34
|
-
exports.PrismicEmbed = PrismicEmbed;
|
|
35
|
-
exports.PrismicEmbedImpl = PrismicEmbedImpl;
|
|
36
|
-
//# sourceMappingURL=PrismicEmbed.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicEmbed.cjs","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import type { EmbedField } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport { defineComponent, h } from \"vue\"\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\"\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>\n}\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t})\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps\n\t}\n}\n"],"names":["defineComponent","h","simplyResolveComponent"],"mappings":";;;;AAiBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiDA,oBAAAA,gBAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IAAA;AAGd,WAAO,MAAK;AACX,aAAOC,IAAE,EAAAC,uBAAA,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IACF;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,eAAe;;;"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { EmbedField } from "@prismicio/client";
|
|
2
|
-
import type { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
|
|
3
|
-
/**
|
|
4
|
-
* Props for `<PrismicEmbed />`.
|
|
5
|
-
*/
|
|
6
|
-
export type PrismicEmbedProps = {
|
|
7
|
-
/**
|
|
8
|
-
* The Prismic embed field to render.
|
|
9
|
-
*/
|
|
10
|
-
field: EmbedField;
|
|
11
|
-
/**
|
|
12
|
-
* An HTML tag name, a component, or a functional component used to wrap the
|
|
13
|
-
* output.
|
|
14
|
-
*
|
|
15
|
-
* @defaultValue `"div"`
|
|
16
|
-
*/
|
|
17
|
-
wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* `<PrismicEmbed />` implementation.
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export declare const PrismicEmbedImpl: DefineComponent<import("vue").ExtractPropTypes<{
|
|
25
|
-
field: {
|
|
26
|
-
type: PropType<EmbedField>;
|
|
27
|
-
required: true;
|
|
28
|
-
};
|
|
29
|
-
wrapper: {
|
|
30
|
-
type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
|
|
31
|
-
default: undefined;
|
|
32
|
-
required: false;
|
|
33
|
-
};
|
|
34
|
-
}>, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}>), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
-
field: {
|
|
38
|
-
type: PropType<EmbedField>;
|
|
39
|
-
required: true;
|
|
40
|
-
};
|
|
41
|
-
wrapper: {
|
|
42
|
-
type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
|
|
43
|
-
default: undefined;
|
|
44
|
-
required: false;
|
|
45
|
-
};
|
|
46
|
-
}>> & Readonly<{}>, {
|
|
47
|
-
wrapper: string | ConcreteComponent | Raw<DefineComponent>;
|
|
48
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
49
|
-
/**
|
|
50
|
-
* Component to render a Prismic embed field.
|
|
51
|
-
*
|
|
52
|
-
* @see Component props {@link PrismicEmbedProps}
|
|
53
|
-
* @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}
|
|
54
|
-
*/
|
|
55
|
-
export declare const PrismicEmbed: {
|
|
56
|
-
new (): {
|
|
57
|
-
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicEmbedProps;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
2
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
|
|
3
|
-
const defaultWrapper = "div";
|
|
4
|
-
const PrismicEmbedImpl = /* @__PURE__ */ defineComponent({
|
|
5
|
-
name: "PrismicEmbed",
|
|
6
|
-
props: {
|
|
7
|
-
field: {
|
|
8
|
-
type: Object,
|
|
9
|
-
required: true
|
|
10
|
-
},
|
|
11
|
-
wrapper: {
|
|
12
|
-
type: [String, Object, Function],
|
|
13
|
-
default: void 0,
|
|
14
|
-
required: false
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
setup(props) {
|
|
18
|
-
if (!props.field) {
|
|
19
|
-
return () => null;
|
|
20
|
-
}
|
|
21
|
-
return () => {
|
|
22
|
-
return h(simplyResolveComponent(props.wrapper || defaultWrapper), {
|
|
23
|
-
"data-oembed": props.field.embed_url,
|
|
24
|
-
"data-oembed-type": props.field.type,
|
|
25
|
-
"data-oembed-provider": props.field.provider_name,
|
|
26
|
-
innerHTML: props.field.html || null
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const PrismicEmbed = PrismicEmbedImpl;
|
|
32
|
-
export {
|
|
33
|
-
PrismicEmbed,
|
|
34
|
-
PrismicEmbedImpl
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=PrismicEmbed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicEmbed.js","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import type { EmbedField } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport { defineComponent, h } from \"vue\"\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\"\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>\n}\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t})\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps\n\t}\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiD,gCAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IAAA;AAGd,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IACF;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,eAAe;"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const client = require("@prismicio/client");
|
|
4
|
-
const vue = require("vue");
|
|
5
|
-
const __PRODUCTION__ = require("../lib/__PRODUCTION__.cjs");
|
|
6
|
-
const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
|
|
7
|
-
const usePrismic = require("../usePrismic.cjs");
|
|
8
|
-
const defaultImageComponent = "img";
|
|
9
|
-
const usePrismicImage = (props) => {
|
|
10
|
-
const { options } = usePrismic.usePrismic();
|
|
11
|
-
const asImage = vue.computed(() => {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
const field = vue.unref(props.field);
|
|
14
|
-
if (!client.isFilled.image(field)) {
|
|
15
|
-
return {
|
|
16
|
-
src: null,
|
|
17
|
-
srcset: null
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const imgixParams = vue.unref(props.imgixParams);
|
|
21
|
-
const widths = vue.unref(props.widths);
|
|
22
|
-
const pixelDensities = vue.unref(props.pixelDensities);
|
|
23
|
-
if (widths) {
|
|
24
|
-
if (!__PRODUCTION__.__PRODUCTION__ && pixelDensities) {
|
|
25
|
-
console.warn("[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.", props);
|
|
26
|
-
}
|
|
27
|
-
return client.asImageWidthSrcSet(field, {
|
|
28
|
-
...imgixParams,
|
|
29
|
-
widths: widths === "defaults" ? (_a = options.components) == null ? void 0 : _a.imageWidthSrcSetDefaults : widths
|
|
30
|
-
});
|
|
31
|
-
} else if (pixelDensities) {
|
|
32
|
-
return client.asImagePixelDensitySrcSet(field, {
|
|
33
|
-
...imgixParams,
|
|
34
|
-
pixelDensities: pixelDensities === "defaults" ? (_b = options.components) == null ? void 0 : _b.imagePixelDensitySrcSetDefaults : pixelDensities
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
return {
|
|
38
|
-
src: client.asImageSrc(field, imgixParams),
|
|
39
|
-
srcset: null
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const src = vue.computed(() => {
|
|
44
|
-
return asImage.value.src;
|
|
45
|
-
});
|
|
46
|
-
const srcset = vue.computed(() => {
|
|
47
|
-
return asImage.value.srcset;
|
|
48
|
-
});
|
|
49
|
-
const alt = vue.computed(() => {
|
|
50
|
-
return vue.unref(props.field).alt || "";
|
|
51
|
-
});
|
|
52
|
-
const copyright = vue.computed(() => {
|
|
53
|
-
return vue.unref(props.field).copyright || null;
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
src,
|
|
57
|
-
srcset,
|
|
58
|
-
alt,
|
|
59
|
-
copyright
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
const PrismicImageImpl = /* @__PURE__ */ vue.defineComponent({
|
|
63
|
-
name: "PrismicImage",
|
|
64
|
-
props: {
|
|
65
|
-
field: {
|
|
66
|
-
type: Object,
|
|
67
|
-
required: true
|
|
68
|
-
},
|
|
69
|
-
imageComponent: {
|
|
70
|
-
type: [String, Object],
|
|
71
|
-
default: void 0,
|
|
72
|
-
required: false
|
|
73
|
-
},
|
|
74
|
-
imgixParams: {
|
|
75
|
-
type: Object,
|
|
76
|
-
default: void 0,
|
|
77
|
-
required: false
|
|
78
|
-
},
|
|
79
|
-
widths: {
|
|
80
|
-
type: [String, Object],
|
|
81
|
-
default: void 0,
|
|
82
|
-
required: false
|
|
83
|
-
},
|
|
84
|
-
pixelDensities: {
|
|
85
|
-
type: [String, Object],
|
|
86
|
-
default: void 0,
|
|
87
|
-
required: false
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
setup(props) {
|
|
91
|
-
if (!props.field) {
|
|
92
|
-
return () => null;
|
|
93
|
-
}
|
|
94
|
-
const { options } = usePrismic.usePrismic();
|
|
95
|
-
const type = vue.computed(() => {
|
|
96
|
-
var _a;
|
|
97
|
-
return props.imageComponent || ((_a = options.components) == null ? void 0 : _a.imageComponent) || defaultImageComponent;
|
|
98
|
-
});
|
|
99
|
-
const { src, srcset, alt, copyright } = usePrismicImage(props);
|
|
100
|
-
return () => {
|
|
101
|
-
const attributes = {
|
|
102
|
-
src: src.value,
|
|
103
|
-
srcset: srcset.value,
|
|
104
|
-
alt: alt.value
|
|
105
|
-
};
|
|
106
|
-
switch (type.value) {
|
|
107
|
-
case "img":
|
|
108
|
-
return vue.h("img", attributes);
|
|
109
|
-
default:
|
|
110
|
-
return vue.h(simplyResolveComponent.simplyResolveComponent(type.value), {
|
|
111
|
-
...attributes,
|
|
112
|
-
copyright: copyright.value
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
const PrismicImage = PrismicImageImpl;
|
|
119
|
-
exports.PrismicImage = PrismicImage;
|
|
120
|
-
exports.PrismicImageImpl = PrismicImageImpl;
|
|
121
|
-
exports.usePrismicImage = usePrismicImage;
|
|
122
|
-
//# sourceMappingURL=PrismicImage.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.cjs","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import type { ImageField } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport { computed, defineComponent, h, unref } from \"vue\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\"\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\"\n}\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>\n}\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic()\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field)\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t}\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams)\n\t\tconst widths = unref(props.widths)\n\t\tconst pixelDensities = unref(props.pixelDensities)\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.\",\n\t\t\t\t\tprops,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t})\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t})\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t}\n\t\t}\n\t})\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src\n\t})\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset\n\t})\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\"\n\t})\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null\n\t})\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t}\n}\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null\n\t\t}\n\n\t\tconst { options } = usePrismic()\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t)\n\t\t})\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props)\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t}\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes)\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t})\n\t\t\t}\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps\n\t}\n}\n"],"names":["usePrismic","computed","unref","isFilled","__PRODUCTION__","asImageWidthSrcSet","asImagePixelDensitySrcSet","asImageSrc","defineComponent","h","simplyResolveComponent"],"mappings":"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"}
|