@prismicio/vue 4.3.0 → 5.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +278 -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 +7 -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 +40 -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 +34 -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/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- 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 +42 -58
- package/dist/usePrismic.cjs +3 -2
- package/dist/usePrismic.cjs.map +1 -1
- package/dist/usePrismic.d.ts +13 -5
- package/dist/usePrismic.js +2 -1
- package/dist/usePrismic.js.map +1 -1
- package/package.json +32 -35
- 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 +54 -53
- package/src/index.ts +33 -58
- package/src/lib/Wrapper.vue +22 -0
- package/src/lib/devMsg.ts +20 -0
- package/src/lib/isInternalURL.ts +4 -4
- package/src/types.ts +91 -109
- package/src/usePrismic.ts +16 -9
- 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 -163
- 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 -196
- 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 -375
- 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 -330
- 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 -19
- package/dist/lib/getSlots.cjs.map +0 -1
- package/dist/lib/getSlots.d.ts +0 -14
- package/dist/lib/getSlots.js +0 -19
- 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 -64
- package/dist/useStatefulPrismicClientMethod.js +0 -39
- package/dist/useStatefulPrismicClientMethod.js.map +0 -1
- package/src/components/PrismicEmbed.ts +0 -91
- package/src/components/PrismicImage.ts +0 -309
- package/src/components/PrismicLink.ts +0 -326
- package/src/components/PrismicRichText.ts +0 -282
- package/src/components/PrismicText.ts +0 -167
- package/src/components/SliceZone.ts +0 -619
- package/src/components/index.ts +0 -46
- package/src/composables.ts +0 -474
- 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 -37
- package/src/lib/simplyResolveComponent.ts +0 -23
- package/src/useStatefulPrismicClientMethod.ts +0 -156
- package/vetur/attributes.json +0 -113
- package/vetur/tags.json +0 -60
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, package.jso
|
|
|
17
17
|
[![Conventional Commits][conventional-commits-src]][conventional-commits-href]
|
|
18
18
|
[![License][license-src]][license-href]
|
|
19
19
|
|
|
20
|
-
<!--
|
|
20
|
+
<!-- Replacing link to Prismic with [Prismic][prismic] is useful here -->
|
|
21
21
|
|
|
22
22
|
[Vue][vue] plugin, components, and composables to fetch and present [Prismic][prismic] content.
|
|
23
23
|
|
|
@@ -52,7 +52,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
52
52
|
## License
|
|
53
53
|
|
|
54
54
|
```
|
|
55
|
-
Copyright 2013-
|
|
55
|
+
Copyright 2013-2024 Prismic <contact@prismic.io> (https://prismic.io)
|
|
56
56
|
|
|
57
57
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
58
58
|
you may not use this file except in compliance with the License.
|
|
@@ -71,7 +71,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
71
71
|
|
|
72
72
|
[prismic]: https://prismic.io
|
|
73
73
|
|
|
74
|
-
<!--
|
|
74
|
+
<!-- Replace link with a more useful one if available -->
|
|
75
75
|
|
|
76
76
|
[prismic-docs]: https://prismic.io/docs/technologies/vuejs
|
|
77
77
|
[changelog]: ./CHANGELOG.md
|
|
@@ -83,7 +83,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
83
83
|
[vue-composition]: https://v3.vuejs.org/guide/composition-api-introduction.html
|
|
84
84
|
[vue-options]: https://v3.vuejs.org/guide/introduction.html
|
|
85
85
|
|
|
86
|
-
<!--
|
|
86
|
+
<!-- Replace link with a more useful one if available -->
|
|
87
87
|
|
|
88
88
|
[forum-question]: https://community.prismic.io/c/kits-and-dev-languages/vue-js/16
|
|
89
89
|
[repo-bug-report]: https://github.com/prismicio/prismic-vue/issues/new?assignees=&labels=bug&template=bug_report.md&title=
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const vue = require("vue");
|
|
3
|
+
const client = require("@prismicio/client");
|
|
4
|
+
const defaultWrapper = "div";
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
6
|
+
...{ name: "PrismicEmbed" },
|
|
7
|
+
__name: "PrismicEmbed",
|
|
8
|
+
props: {
|
|
9
|
+
field: {},
|
|
10
|
+
wrapper: {}
|
|
11
|
+
},
|
|
12
|
+
setup(__props) {
|
|
13
|
+
return (_ctx, _cache) => {
|
|
14
|
+
return vue.unref(client.isFilled).embed(_ctx.field) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.wrapper || defaultWrapper), {
|
|
15
|
+
key: 0,
|
|
16
|
+
"data-oembed": _ctx.field.embed_url,
|
|
17
|
+
"data-oembed-type": _ctx.field.type,
|
|
18
|
+
"data-oembed-provider": _ctx.field.provider_name,
|
|
19
|
+
innerHTML: _ctx.field.html
|
|
20
|
+
}, null, 8, ["data-oembed", "data-oembed-type", "data-oembed-provider", "innerHTML"])) : vue.createCommentVNode("", true);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
module.exports = _sfc_main;
|
|
25
|
+
//# sourceMappingURL=PrismicEmbed.vue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicEmbed.vue.cjs","sources":["../src/PrismicEmbed.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { EmbedField } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\n\nimport type { ComponentOrTagName } from \"./types\"\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 or a component used to wrap the output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: ComponentOrTagName\n}\n\ndefineProps<PrismicEmbedProps>()\ndefineOptions({ name: \"PrismicEmbed\" })\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.embed(field)\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\t:data-oembed=\"field.embed_url\"\n\t\t:data-oembed-type=\"field.type\"\n\t\t:data-oembed-provider=\"field.provider_name\"\n\t\tv-html=\"field.html\"\n\t/>\n</template>\n"],"names":[],"mappings":";;;AASA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EmbedField } from '@prismicio/client';
|
|
2
|
+
import { ComponentOrTagName } from './types';
|
|
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 or a component used to wrap the output.
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue `"div"`
|
|
15
|
+
*/
|
|
16
|
+
wrapper?: ComponentOrTagName;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import('vue').DefineComponent<PrismicEmbedProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PrismicEmbedProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineComponent, unref, openBlock, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
|
|
2
|
+
import { isFilled } from "@prismicio/client";
|
|
3
|
+
const defaultWrapper = "div";
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
...{ name: "PrismicEmbed" },
|
|
6
|
+
__name: "PrismicEmbed",
|
|
7
|
+
props: {
|
|
8
|
+
field: {},
|
|
9
|
+
wrapper: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
return (_ctx, _cache) => {
|
|
13
|
+
return unref(isFilled).embed(_ctx.field) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.wrapper || defaultWrapper), {
|
|
14
|
+
key: 0,
|
|
15
|
+
"data-oembed": _ctx.field.embed_url,
|
|
16
|
+
"data-oembed-type": _ctx.field.type,
|
|
17
|
+
"data-oembed-provider": _ctx.field.provider_name,
|
|
18
|
+
innerHTML: _ctx.field.html
|
|
19
|
+
}, null, 8, ["data-oembed", "data-oembed-type", "data-oembed-provider", "innerHTML"])) : createCommentVNode("", true);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
_sfc_main as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=PrismicEmbed.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicEmbed.vue.js","sources":["../src/PrismicEmbed.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { EmbedField } from \"@prismicio/client\"\nimport { isFilled } from \"@prismicio/client\"\n\nimport type { ComponentOrTagName } from \"./types\"\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 or a component used to wrap the output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: ComponentOrTagName\n}\n\ndefineProps<PrismicEmbedProps>()\ndefineOptions({ name: \"PrismicEmbed\" })\n</script>\n\n<template>\n\t<component\n\t\tv-if=\"isFilled.embed(field)\"\n\t\t:is=\"wrapper || defaultWrapper\"\n\t\t:data-oembed=\"field.embed_url\"\n\t\t:data-oembed-type=\"field.type\"\n\t\t:data-oembed-provider=\"field.provider_name\"\n\t\tv-html=\"field.html\"\n\t/>\n</template>\n"],"names":[],"mappings":";;AASA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicEmbed.vue2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicEmbed.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const vue = require("vue");
|
|
3
|
+
const client = require("@prismicio/client");
|
|
4
|
+
const esmEnv = require("esm-env");
|
|
5
|
+
const devMsg = require("./lib/devMsg.cjs");
|
|
6
|
+
const usePrismic = require("./usePrismic.cjs");
|
|
7
|
+
const _hoisted_1 = ["src", "srcset", "alt"];
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
9
|
+
...{ name: "PrismicImage" },
|
|
10
|
+
__name: "PrismicImage",
|
|
11
|
+
props: {
|
|
12
|
+
field: {},
|
|
13
|
+
imgixParams: {},
|
|
14
|
+
alt: {},
|
|
15
|
+
fallbackAlt: {},
|
|
16
|
+
widths: {},
|
|
17
|
+
pixelDensities: {}
|
|
18
|
+
},
|
|
19
|
+
setup(__props) {
|
|
20
|
+
const props = __props;
|
|
21
|
+
const { options } = usePrismic.usePrismic();
|
|
22
|
+
if (esmEnv.DEV) {
|
|
23
|
+
vue.watchEffect(() => {
|
|
24
|
+
if (typeof props.alt === "string" && props.alt !== "") {
|
|
25
|
+
console.warn(
|
|
26
|
+
`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg.devMsg(
|
|
27
|
+
"alt-must-be-an-empty-string"
|
|
28
|
+
)}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (typeof props.fallbackAlt === "string" && props.fallbackAlt !== "") {
|
|
32
|
+
console.warn(
|
|
33
|
+
`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg.devMsg(
|
|
34
|
+
"alt-must-be-an-empty-string"
|
|
35
|
+
)}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (props.widths && props.pixelDensities) {
|
|
39
|
+
console.warn(
|
|
40
|
+
`[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.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const image = vue.computed(() => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (!client.isFilled.imageThumbnail(props.field)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let src;
|
|
51
|
+
let srcSet;
|
|
52
|
+
if (props.widths || !props.pixelDensities) {
|
|
53
|
+
const res = client.asImageWidthSrcSet(props.field, {
|
|
54
|
+
...props.imgixParams,
|
|
55
|
+
widths: props.widths === "defaults" ? (_a = options.components) == null ? void 0 : _a.imageWidthSrcSetDefaults : props.widths
|
|
56
|
+
});
|
|
57
|
+
src = res.src;
|
|
58
|
+
srcSet = res.srcset;
|
|
59
|
+
} else if (props.pixelDensities) {
|
|
60
|
+
const res = client.asImagePixelDensitySrcSet(props.field, {
|
|
61
|
+
...props.imgixParams,
|
|
62
|
+
pixelDensities: props.pixelDensities === "defaults" ? (_b = options.components) == null ? void 0 : _b.imagePixelDensitySrcSetDefaults : props.pixelDensities
|
|
63
|
+
});
|
|
64
|
+
src = res.src;
|
|
65
|
+
srcSet = res.srcset;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
src,
|
|
69
|
+
srcSet,
|
|
70
|
+
alt: props.alt ?? (props.field.alt || props.fallbackAlt)
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
return (_ctx, _cache) => {
|
|
74
|
+
return image.value ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
75
|
+
key: 0,
|
|
76
|
+
src: image.value.src,
|
|
77
|
+
srcset: image.value.srcSet,
|
|
78
|
+
alt: image.value.alt
|
|
79
|
+
}, null, 8, _hoisted_1)) : vue.createCommentVNode("", true);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
module.exports = _sfc_main;
|
|
84
|
+
//# sourceMappingURL=PrismicImage.vue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue.cjs","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\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\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\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 }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\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)\n\t\t}\n\t})\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t}\n})\n</script>\n\n<template>\n\t<img v-if=\"image\" :src=\"image.src\" :srcset=\"image.srcSet\" :alt=\"image.alt\" />\n</template>\n"],"names":["usePrismic","DEV","watchEffect","devMsg","computed","isFilled","asImageWidthSrcSet","asImagePixelDensitySrcSet"],"mappings":";;;;;;;;;;;;;;;;;;;AAuFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAE/B,QAAIC,YAAK;AACRC,UAAAA,YAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQC,OAAA;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqSA,OAAA;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,QAAQC,IAAAA,SAAS,MAAM;;AAC5B,UAAI,CAACC,OAAAA,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAMC,OAAAA,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAMC,OAAAA,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGP,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,MAC7C;AAAA,IAAA,CACA;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ImageField, asImageSrc, asImagePixelDensitySrcSet, asImageWidthSrcSet } from '@prismicio/client';
|
|
2
|
+
/**
|
|
3
|
+
* Props for `<PrismicImage />`.
|
|
4
|
+
*/
|
|
5
|
+
export type PrismicImageProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The Prismic image field or thumbnail to render.
|
|
8
|
+
*/
|
|
9
|
+
field: ImageField | ImageField<string>;
|
|
10
|
+
/**
|
|
11
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
12
|
+
*
|
|
13
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
14
|
+
*/
|
|
15
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
16
|
+
/**
|
|
17
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
18
|
+
*
|
|
19
|
+
* See:
|
|
20
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
21
|
+
*/
|
|
22
|
+
alt?: "";
|
|
23
|
+
/**
|
|
24
|
+
* Declare an image as decorative only if the image field does not have
|
|
25
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
26
|
+
*
|
|
27
|
+
* See:
|
|
28
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
29
|
+
*/
|
|
30
|
+
fallbackAlt?: "";
|
|
31
|
+
} & ({
|
|
32
|
+
/**
|
|
33
|
+
* Widths used to build a `srcset` value for the image field.
|
|
34
|
+
*
|
|
35
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
36
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
37
|
+
* 3840.
|
|
38
|
+
*
|
|
39
|
+
* If the image field contains responsive views, each responsive view can
|
|
40
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
41
|
+
* as the `widths` prop.
|
|
42
|
+
*/
|
|
43
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
44
|
+
/**
|
|
45
|
+
* Not used when the `widths` prop is used.
|
|
46
|
+
*/
|
|
47
|
+
pixelDensities?: never;
|
|
48
|
+
} | {
|
|
49
|
+
/**
|
|
50
|
+
* Not used when the `widths` prop is used.
|
|
51
|
+
*/
|
|
52
|
+
widths?: never;
|
|
53
|
+
/**
|
|
54
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
55
|
+
*
|
|
56
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
57
|
+
* densities will be used: 1, 2, 3.
|
|
58
|
+
*/
|
|
59
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
60
|
+
});
|
|
61
|
+
declare const _default: import('vue').DefineComponent<({
|
|
62
|
+
/**
|
|
63
|
+
* The Prismic image field or thumbnail to render.
|
|
64
|
+
*/
|
|
65
|
+
field: ImageField | ImageField<string>;
|
|
66
|
+
/**
|
|
67
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
68
|
+
*
|
|
69
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
70
|
+
*/
|
|
71
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
72
|
+
/**
|
|
73
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
74
|
+
*
|
|
75
|
+
* See:
|
|
76
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
77
|
+
*/
|
|
78
|
+
alt?: "";
|
|
79
|
+
/**
|
|
80
|
+
* Declare an image as decorative only if the image field does not have
|
|
81
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
82
|
+
*
|
|
83
|
+
* See:
|
|
84
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
85
|
+
*/
|
|
86
|
+
fallbackAlt?: "";
|
|
87
|
+
} & {
|
|
88
|
+
/**
|
|
89
|
+
* Widths used to build a `srcset` value for the image field.
|
|
90
|
+
*
|
|
91
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
92
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
93
|
+
* 3840.
|
|
94
|
+
*
|
|
95
|
+
* If the image field contains responsive views, each responsive view can
|
|
96
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
97
|
+
* as the `widths` prop.
|
|
98
|
+
*/
|
|
99
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
100
|
+
/**
|
|
101
|
+
* Not used when the `widths` prop is used.
|
|
102
|
+
*/
|
|
103
|
+
pixelDensities?: never;
|
|
104
|
+
}) | ({
|
|
105
|
+
/**
|
|
106
|
+
* The Prismic image field or thumbnail to render.
|
|
107
|
+
*/
|
|
108
|
+
field: ImageField | ImageField<string>;
|
|
109
|
+
/**
|
|
110
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
111
|
+
*
|
|
112
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
113
|
+
*/
|
|
114
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
115
|
+
/**
|
|
116
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
117
|
+
*
|
|
118
|
+
* See:
|
|
119
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
120
|
+
*/
|
|
121
|
+
alt?: "";
|
|
122
|
+
/**
|
|
123
|
+
* Declare an image as decorative only if the image field does not have
|
|
124
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
125
|
+
*
|
|
126
|
+
* See:
|
|
127
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
128
|
+
*/
|
|
129
|
+
fallbackAlt?: "";
|
|
130
|
+
} & {
|
|
131
|
+
/**
|
|
132
|
+
* Not used when the `widths` prop is used.
|
|
133
|
+
*/
|
|
134
|
+
widths?: never;
|
|
135
|
+
/**
|
|
136
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
137
|
+
*
|
|
138
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
139
|
+
* densities will be used: 1, 2, 3.
|
|
140
|
+
*/
|
|
141
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
142
|
+
}), {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<({
|
|
143
|
+
/**
|
|
144
|
+
* The Prismic image field or thumbnail to render.
|
|
145
|
+
*/
|
|
146
|
+
field: ImageField | ImageField<string>;
|
|
147
|
+
/**
|
|
148
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
149
|
+
*
|
|
150
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
151
|
+
*/
|
|
152
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
153
|
+
/**
|
|
154
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
155
|
+
*
|
|
156
|
+
* See:
|
|
157
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
158
|
+
*/
|
|
159
|
+
alt?: "";
|
|
160
|
+
/**
|
|
161
|
+
* Declare an image as decorative only if the image field does not have
|
|
162
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
163
|
+
*
|
|
164
|
+
* See:
|
|
165
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
166
|
+
*/
|
|
167
|
+
fallbackAlt?: "";
|
|
168
|
+
} & {
|
|
169
|
+
/**
|
|
170
|
+
* Widths used to build a `srcset` value for the image field.
|
|
171
|
+
*
|
|
172
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
173
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
174
|
+
* 3840.
|
|
175
|
+
*
|
|
176
|
+
* If the image field contains responsive views, each responsive view can
|
|
177
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
178
|
+
* as the `widths` prop.
|
|
179
|
+
*/
|
|
180
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
181
|
+
/**
|
|
182
|
+
* Not used when the `widths` prop is used.
|
|
183
|
+
*/
|
|
184
|
+
pixelDensities?: never;
|
|
185
|
+
}) | ({
|
|
186
|
+
/**
|
|
187
|
+
* The Prismic image field or thumbnail to render.
|
|
188
|
+
*/
|
|
189
|
+
field: ImageField | ImageField<string>;
|
|
190
|
+
/**
|
|
191
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
192
|
+
*
|
|
193
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
194
|
+
*/
|
|
195
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
196
|
+
/**
|
|
197
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
198
|
+
*
|
|
199
|
+
* See:
|
|
200
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
201
|
+
*/
|
|
202
|
+
alt?: "";
|
|
203
|
+
/**
|
|
204
|
+
* Declare an image as decorative only if the image field does not have
|
|
205
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
206
|
+
*
|
|
207
|
+
* See:
|
|
208
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
209
|
+
*/
|
|
210
|
+
fallbackAlt?: "";
|
|
211
|
+
} & {
|
|
212
|
+
/**
|
|
213
|
+
* Not used when the `widths` prop is used.
|
|
214
|
+
*/
|
|
215
|
+
widths?: never;
|
|
216
|
+
/**
|
|
217
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
218
|
+
*
|
|
219
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
220
|
+
* densities will be used: 1, 2, 3.
|
|
221
|
+
*/
|
|
222
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
223
|
+
})> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
224
|
+
export default _default;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineComponent, watchEffect, computed, openBlock, createElementBlock, createCommentVNode } from "vue";
|
|
2
|
+
import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet } from "@prismicio/client";
|
|
3
|
+
import { DEV } from "esm-env";
|
|
4
|
+
import { devMsg } from "./lib/devMsg.js";
|
|
5
|
+
import { usePrismic } from "./usePrismic.js";
|
|
6
|
+
const _hoisted_1 = ["src", "srcset", "alt"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
...{ name: "PrismicImage" },
|
|
9
|
+
__name: "PrismicImage",
|
|
10
|
+
props: {
|
|
11
|
+
field: {},
|
|
12
|
+
imgixParams: {},
|
|
13
|
+
alt: {},
|
|
14
|
+
fallbackAlt: {},
|
|
15
|
+
widths: {},
|
|
16
|
+
pixelDensities: {}
|
|
17
|
+
},
|
|
18
|
+
setup(__props) {
|
|
19
|
+
const props = __props;
|
|
20
|
+
const { options } = usePrismic();
|
|
21
|
+
if (DEV) {
|
|
22
|
+
watchEffect(() => {
|
|
23
|
+
if (typeof props.alt === "string" && props.alt !== "") {
|
|
24
|
+
console.warn(
|
|
25
|
+
`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg(
|
|
26
|
+
"alt-must-be-an-empty-string"
|
|
27
|
+
)}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (typeof props.fallbackAlt === "string" && props.fallbackAlt !== "") {
|
|
31
|
+
console.warn(
|
|
32
|
+
`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg(
|
|
33
|
+
"alt-must-be-an-empty-string"
|
|
34
|
+
)}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (props.widths && props.pixelDensities) {
|
|
38
|
+
console.warn(
|
|
39
|
+
`[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.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const image = computed(() => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (!isFilled.imageThumbnail(props.field)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let src;
|
|
50
|
+
let srcSet;
|
|
51
|
+
if (props.widths || !props.pixelDensities) {
|
|
52
|
+
const res = asImageWidthSrcSet(props.field, {
|
|
53
|
+
...props.imgixParams,
|
|
54
|
+
widths: props.widths === "defaults" ? (_a = options.components) == null ? void 0 : _a.imageWidthSrcSetDefaults : props.widths
|
|
55
|
+
});
|
|
56
|
+
src = res.src;
|
|
57
|
+
srcSet = res.srcset;
|
|
58
|
+
} else if (props.pixelDensities) {
|
|
59
|
+
const res = asImagePixelDensitySrcSet(props.field, {
|
|
60
|
+
...props.imgixParams,
|
|
61
|
+
pixelDensities: props.pixelDensities === "defaults" ? (_b = options.components) == null ? void 0 : _b.imagePixelDensitySrcSetDefaults : props.pixelDensities
|
|
62
|
+
});
|
|
63
|
+
src = res.src;
|
|
64
|
+
srcSet = res.srcset;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
src,
|
|
68
|
+
srcSet,
|
|
69
|
+
alt: props.alt ?? (props.field.alt || props.fallbackAlt)
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
return (_ctx, _cache) => {
|
|
73
|
+
return image.value ? (openBlock(), createElementBlock("img", {
|
|
74
|
+
key: 0,
|
|
75
|
+
src: image.value.src,
|
|
76
|
+
srcset: image.value.srcSet,
|
|
77
|
+
alt: image.value.alt
|
|
78
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("", true);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
_sfc_main as default
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=PrismicImage.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue.js","sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\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\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\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 }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\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)\n\t\t}\n\t})\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t}\n})\n</script>\n\n<template>\n\t<img v-if=\"image\" :src=\"image.src\" :srcset=\"image.srcSet\" :alt=\"image.alt\" />\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuFA,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAE/B,QAAI,KAAK;AACR,kBAAY,MAAM;AACjB,YAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAC9C,kBAAA;AAAA,YACP,qQAAqQ;AAAA,cACpQ;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGD,YAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAAI;AAC9D,kBAAA;AAAA,YACP,qSAAqS;AAAA,cACpS;AAAA,YAAA,CACA;AAAA,UACF;AAAA,QAAA;AAGG,YAAA,MAAM,UAAU,MAAM,gBAAgB;AACjC,kBAAA;AAAA,YACP;AAAA,UACD;AAAA,QAAA;AAAA,MACD,CACA;AAAA,IAAA;AAGI,UAAA,QAAQ,SAAS,MAAM;;AAC5B,UAAI,CAAC,SAAS,eAAe,MAAM,KAAK,GAAG;AAC1C;AAAA,MAAA;AAGG,UAAA;AACA,UAAA;AACJ,UAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;AACpC,cAAA,MAAM,mBAAmB,MAAM,OAAO;AAAA,UAC3C,GAAG,MAAM;AAAA,UACT,QACC,MAAM,WAAW,cACd,aAAQ,eAAR,mBAAoB,2BACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA,WACH,MAAM,gBAAgB;AAC1B,cAAA,MAAM,0BAA0B,MAAM,OAAO;AAAA,UAClD,GAAG,MAAM;AAAA,UACT,gBACC,MAAM,mBAAmB,cACtB,aAAQ,eAAR,mBAAoB,kCACpB,MAAM;AAAA,QAAA,CACV;AAED,cAAM,IAAI;AACV,iBAAS,IAAI;AAAA,MAAA;AAGP,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;AAAA,MAC7C;AAAA,IAAA,CACA;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|