@prismicio/vue 6.1.4 → 6.1.5-canary.19702e8
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 +7 -1
- package/dist/PrismicImage.cjs.map +1 -1
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicImage.vue.d.cts +2 -2
- package/dist/PrismicImage.vue.d.cts.map +1 -1
- package/dist/PrismicImage.vue.d.ts +2 -2
- package/dist/PrismicImage.vue.d.ts.map +1 -1
- package/dist/PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicImage.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicLink.cjs.map +1 -1
- package/dist/PrismicLink.js.map +1 -1
- package/dist/PrismicLink.vue.d.cts +4 -4
- package/dist/PrismicLink.vue.d.cts.map +1 -1
- package/dist/PrismicLink.vue.d.ts +4 -4
- package/dist/PrismicLink.vue.d.ts.map +1 -1
- package/dist/PrismicLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +2 -2
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.ts +2 -2
- package/dist/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.js.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicRichText/getRichTextComponentProps.d.cts +1 -2
- package/dist/PrismicRichText/getRichTextComponentProps.d.cts.map +1 -1
- package/dist/PrismicRichText/getRichTextComponentProps.d.ts +1 -2
- package/dist/PrismicRichText/getRichTextComponentProps.d.ts.map +1 -1
- package/dist/PrismicRichText/types.d.cts +3 -4
- package/dist/PrismicRichText/types.d.cts.map +1 -1
- package/dist/PrismicRichText/types.d.ts +3 -4
- package/dist/PrismicRichText/types.d.ts.map +1 -1
- package/dist/PrismicTable/PrismicTable.cjs.map +1 -1
- package/dist/PrismicTable/PrismicTable.js.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue.d.cts +2 -2
- package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue.d.ts +2 -2
- package/dist/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicTable/PrismicTableRow.cjs.map +1 -1
- package/dist/PrismicTable/PrismicTableRow.js.map +1 -1
- package/dist/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/PrismicTable/getTableComponentProps.d.cts +7 -7
- package/dist/PrismicTable/getTableComponentProps.d.cts.map +1 -1
- package/dist/PrismicTable/getTableComponentProps.d.ts +7 -7
- package/dist/PrismicTable/getTableComponentProps.d.ts.map +1 -1
- package/dist/PrismicTable/types.d.cts +1 -2
- package/dist/PrismicTable/types.d.cts.map +1 -1
- package/dist/PrismicTable/types.d.ts +1 -2
- package/dist/PrismicTable/types.d.ts.map +1 -1
- package/dist/PrismicText.cjs.map +1 -1
- package/dist/PrismicText.js.map +1 -1
- package/dist/PrismicText.vue.d.cts +2 -2
- package/dist/PrismicText.vue.d.cts.map +1 -1
- package/dist/PrismicText.vue.d.ts +2 -2
- package/dist/PrismicText.vue.d.ts.map +1 -1
- package/dist/PrismicText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/PrismicText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/SliceSimulator.vue.d.cts +2 -2
- package/dist/SliceSimulator.vue.d.cts.map +1 -1
- package/dist/SliceSimulator.vue.d.ts +2 -2
- package/dist/SliceSimulator.vue.d.ts.map +1 -1
- package/dist/SliceSimulator.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/SliceSimulator.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/SliceZone/SliceZone.cjs.map +1 -1
- package/dist/SliceZone/SliceZone.js.map +1 -1
- package/dist/SliceZone/SliceZone.vue.d.cts +2 -2
- package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -1
- package/dist/SliceZone/SliceZone.vue.d.ts +2 -2
- package/dist/SliceZone/SliceZone.vue.d.ts.map +1 -1
- package/dist/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/SliceZone/TODOSliceComponent.d.cts +1 -2
- package/dist/SliceZone/TODOSliceComponent.d.cts.map +1 -1
- package/dist/SliceZone/TODOSliceComponent.d.ts +1 -2
- package/dist/SliceZone/TODOSliceComponent.d.ts.map +1 -1
- package/dist/SliceZone/defineSliceZoneComponents.d.cts +1 -2
- package/dist/SliceZone/defineSliceZoneComponents.d.cts.map +1 -1
- package/dist/SliceZone/defineSliceZoneComponents.d.ts +1 -2
- package/dist/SliceZone/defineSliceZoneComponents.d.ts.map +1 -1
- package/dist/SliceZone/getSliceComponentProps.d.cts +1 -2
- package/dist/SliceZone/getSliceComponentProps.d.cts.map +1 -1
- package/dist/SliceZone/getSliceComponentProps.d.ts +1 -2
- package/dist/SliceZone/getSliceComponentProps.d.ts.map +1 -1
- package/dist/SliceZone/types.d.cts +7 -8
- package/dist/SliceZone/types.d.cts.map +1 -1
- package/dist/SliceZone/types.d.ts +7 -8
- package/dist/SliceZone/types.d.ts.map +1 -1
- package/dist/createPrismic.d.cts +4 -5
- package/dist/createPrismic.d.cts.map +1 -1
- package/dist/createPrismic.d.ts +4 -5
- package/dist/createPrismic.d.ts.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -27,6 +27,12 @@ Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, package.jso
|
|
|
27
27
|
npm install @prismicio/vue
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
Using an AI agent? Teach it how to use `@prismicio/vue` by installing the Prismic skill:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx skills add --global --yes prismicio/skills
|
|
34
|
+
```
|
|
35
|
+
|
|
30
36
|
## Documentation
|
|
31
37
|
|
|
32
38
|
To discover what's new on this package check out [the changelog][changelog]. For full documentation, visit the [official Prismic documentation][prismic-docs].
|
|
@@ -48,7 +54,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
48
54
|
## License
|
|
49
55
|
|
|
50
56
|
```
|
|
51
|
-
Copyright 2013-
|
|
57
|
+
Copyright 2013-2026 Prismic <contact@prismic.io> (https://prismic.io)
|
|
52
58
|
|
|
53
59
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
54
60
|
you may not use this file except in compliance with the License.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.cjs","names":[],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicImage.cjs","names":["_sfc_main"],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":""}
|
package/dist/PrismicImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.js","names":[],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicImage.js","names":["_sfc_main"],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImageField, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet } from "@prismicio/client";
|
|
2
2
|
//#region src/PrismicImage.vue.d.ts
|
|
3
3
|
/** Props for `<PrismicImage />`. */
|
|
4
|
-
type PrismicImageProps = {
|
|
4
|
+
export type PrismicImageProps = {
|
|
5
5
|
/** The Prismic image field or thumbnail to render. */
|
|
6
6
|
field: ImageField | ImageField<string>;
|
|
7
7
|
/**
|
|
@@ -238,5 +238,5 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
238
238
|
})> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
239
239
|
declare const _default: typeof __VLS_export;
|
|
240
240
|
//#endregion
|
|
241
|
-
export {
|
|
241
|
+
export { _default as default };
|
|
242
242
|
//# sourceMappingURL=PrismicImage.vue.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.vue.d.cts","names":[],"sources":["../src/PrismicImage.vue"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue.d.cts","names":[],"sources":["../src/PrismicImage.vue"],"mappings":";;;YAgMY;;EAEX,OAAO,aAAa;;;;;;EAOpB,cAAc,kBAAkB;;;;;;EAOhC;;;;;;;EAQA;;;;;;EAOA;;;;;;EAOA;;;;;;;;;;;EAYE,SACG,YAAY,kBAAkB;EAGjC;;EAGA;;;;;;;EAOA,gBACG,YAAY,kBAAkB;;cA0H9B,4BAAY;;EAzLV,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;;;;;;;;;;EAaJ,SAAA,YAAY,kBAAkB;EAGhB;;;EApDZ,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;EAmBE;;;;;;;EAQN,gBAAA,YAAY,kBAAkB;;;EA/D5B,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;;;;;;;;;;EAaJ,SAAA,YAAY,kBAAkB;EAGhB;;;EApDZ,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;EAmBE;;;;;;;EAQN,gBAAA,YAAY,kBAAkB;MA4HlC,oDAAA;cACmB,iBAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImageField, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet } from "@prismicio/client";
|
|
2
2
|
//#region src/PrismicImage.vue.d.ts
|
|
3
3
|
/** Props for `<PrismicImage />`. */
|
|
4
|
-
type PrismicImageProps = {
|
|
4
|
+
export type PrismicImageProps = {
|
|
5
5
|
/** The Prismic image field or thumbnail to render. */
|
|
6
6
|
field: ImageField | ImageField<string>;
|
|
7
7
|
/**
|
|
@@ -238,5 +238,5 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
238
238
|
})> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
239
239
|
declare const _default: typeof __VLS_export;
|
|
240
240
|
//#endregion
|
|
241
|
-
export {
|
|
241
|
+
export { _default as default };
|
|
242
242
|
//# sourceMappingURL=PrismicImage.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.vue.d.ts","names":[],"sources":["../src/PrismicImage.vue"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue.d.ts","names":[],"sources":["../src/PrismicImage.vue"],"mappings":";;;YAgMY;;EAEX,OAAO,aAAa;;;;;;EAOpB,cAAc,kBAAkB;;;;;;EAOhC;;;;;;;EAQA;;;;;;EAOA;;;;;;EAOA;;;;;;;;;;;EAYE,SACG,YAAY,kBAAkB;EAGjC;;EAGA;;;;;;;EAOA,gBACG,YAAY,kBAAkB;;cA0H9B,4BAAY;;EAzLV,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;;;;;;;;;;EAaJ,SAAA,YAAY,kBAAkB;EAGhB;;;EApDZ,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;EAmBE;;;;;;;EAQN,gBAAA,YAAY,kBAAkB;;;EA/D5B,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;;;;;;;;;;EAaJ,SAAA,YAAY,kBAAkB;EAGhB;;;EApDZ,OAAA,aAAa;;;;;;EAON,cAAA,kBAAkB;;;;;;EAO1B;;;;;;;EAQQ;;;;;;EAON;;;;;;EAOC;;EAmBE;;;;;;;EAQN,gBAAA,YAAY,kBAAkB;MA4HlC,oDAAA;cACmB,iBAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,MAAM,QAAQ;EAGd,
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.cjs","names":["DEV","devMsg","computed","isFilled","asImageWidthSrcSet","asImagePixelDensitySrcSet","_openBlock","_createElementBlock","_createCommentVNode"],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,MAAM,QAAQ;EAGd,IAAIA,QAAAA,KACH,CAAA,GAAA,IAAA,YAAA,OAAkB;GACjB,IAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAClD,QAAQ,KACP,qQAAqQC,eAAAA,OACpQ,6BACD,GACD;GAGD,IAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAClE,QAAQ,KACP,qSAAqSA,eAAAA,OACpS,6BACD,GACD;GAGD,IAAI,MAAM,UAAU,MAAM,gBACzB,QAAQ,KACP,2MACD;EAEF,CAAC;EAGF,MAAM,WAAW,UAA2D;GAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;QACD;IACN,MAAM,SAAS,OAAO,SAAS,KAAK;IAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;SAEA,OAAO;GAET;EACD;EAEA,MAAM,SAAA,GAAQC,IAAAA,SAAAA,OAAe;GAC5B,IAAI,CAACC,kBAAAA,SAAS,eAAe,MAAM,KAAK,GACvC;GAGD,IAAI;GACJ,IAAI;GACJ,IAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;IAC1C,MAAM,OAAA,GAAMC,kBAAAA,mBAAAA,CAAmB,MAAM,OAAO;KAC3C,GAAG,MAAM;KACT,QAAQ,MAAM,WAAW,aAAa,KAAA,IAAY,MAAM;IACzD,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd,OAAO,IAAI,MAAM,gBAAgB;IAChC,MAAM,OAAA,GAAMC,kBAAAA,0BAAAA,CAA0B,MAAM,OAAO;KAClD,GAAG,MAAM;KACT,gBAAgB,MAAM,mBAAmB,aAAa,KAAA,IAAY,MAAM;IACzE,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd;GAEA,MAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;GAEjE,MAAM,cAAc,QAAQ,MAAM,KAAK;GACvC,MAAM,eAAe,QAAQ,MAAM,MAAM;GAEzC,IAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;GAC1D,IAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;GAE5D,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;QACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;GAGhC,OAAO;IACN;IACA;IACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;IAC5C,OAAO,KAAK,MAAM,aAAa;IAC/B,QAAQ,KAAK,MAAM,cAAc;GAClC;EACD,CAAC;;GAKO,OAAA,MAAA,UAAA,GADPC,IAAAA,UAAAA,CAAA,IAAA,GAAAC,IAAAA,mBAAAA,CAOE,OAAA;;IALA,KAAK,MAAA,MAAM;IACX,QAAQ,MAAA,MAAM;IACd,KAAK,MAAA,MAAM;IACX,OAAO,MAAA,MAAM;IACb,QAAQ,MAAA,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,MAAM,QAAQ;EAGd,IAAI,KACH,kBAAkB;GACjB,IAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAClD,QAAQ,KACP,qQAAqQ,OACpQ,6BACD,GACD;GAGD,IAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAClE,QAAQ,KACP,qSAAqS,OACpS,6BACD,GACD;GAGD,IAAI,MAAM,UAAU,MAAM,gBACzB,QAAQ,KACP,2MACD;EAEF,CAAC;EAGF,MAAM,WAAW,UAA2D;GAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;QACD;IACN,MAAM,SAAS,OAAO,SAAS,KAAK;IAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;SAEA,OAAO;GAET;EACD;EAEA,MAAM,QAAQ,eAAe;GAC5B,IAAI,CAAC,SAAS,eAAe,MAAM,KAAK,GACvC;GAGD,IAAI;GACJ,IAAI;GACJ,IAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;IAC1C,MAAM,MAAM,mBAAmB,MAAM,OAAO;KAC3C,GAAG,MAAM;KACT,QAAQ,MAAM,WAAW,aAAa,KAAA,IAAY,MAAM;IACzD,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd,OAAO,IAAI,MAAM,gBAAgB;IAChC,MAAM,MAAM,0BAA0B,MAAM,OAAO;KAClD,GAAG,MAAM;KACT,gBAAgB,MAAM,mBAAmB,aAAa,KAAA,IAAY,MAAM;IACzE,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd;GAEA,MAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;GAEjE,MAAM,cAAc,QAAQ,MAAM,KAAK;GACvC,MAAM,eAAe,QAAQ,MAAM,MAAM;GAEzC,IAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;GAC1D,IAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;GAE5D,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;QACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;GAGhC,OAAO;IACN;IACA;IACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;IAC5C,OAAO,KAAK,MAAM,aAAa;IAC/B,QAAQ,KAAK,MAAM,cAAc;GAClC;EACD,CAAC;;GAKO,OAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createCommentVNode"],"sources":["../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/** Props for `<PrismicImage />`. */\nexport type PrismicImageProps = {\n\t/** The Prismic image field or thumbnail to render. */\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: 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 alternative text by\n\t * providing `fallbackAlt=\"\"`.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths (in pixels) used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used: 640, 750, 828, 1080,\n\t\t\t * 1200, 1920, 2048, 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can be used as a width\n\t\t\t * in the resulting `srcset` by passing `\"thumbnails\"` 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\tpixelDensities?: never\n\t }\n\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 densities will be\n\t\t\t * used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\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 castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn undefined\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: props.widths === \"defaults\" ? undefined : 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: props.pixelDensities === \"defaults\" ? undefined : props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,MAAM,QAAQ;EAGd,IAAI,KACH,kBAAkB;GACjB,IAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,IAClD,QAAQ,KACP,qQAAqQ,OACpQ,6BACD,GACD;GAGD,IAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,IAClE,QAAQ,KACP,qSAAqS,OACpS,6BACD,GACD;GAGD,IAAI,MAAM,UAAU,MAAM,gBACzB,QAAQ,KACP,2MACD;EAEF,CAAC;EAGF,MAAM,WAAW,UAA2D;GAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aACjD,OAAO;QACD;IACN,MAAM,SAAS,OAAO,SAAS,KAAK;IAEpC,IAAI,OAAO,MAAM,MAAM,GACtB;SAEA,OAAO;GAET;EACD;EAEA,MAAM,QAAQ,eAAe;GAC5B,IAAI,CAAC,SAAS,eAAe,MAAM,KAAK,GACvC;GAGD,IAAI;GACJ,IAAI;GACJ,IAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;IAC1C,MAAM,MAAM,mBAAmB,MAAM,OAAO;KAC3C,GAAG,MAAM;KACT,QAAQ,MAAM,WAAW,aAAa,KAAA,IAAY,MAAM;IACzD,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd,OAAO,IAAI,MAAM,gBAAgB;IAChC,MAAM,MAAM,0BAA0B,MAAM,OAAO;KAClD,GAAG,MAAM;KACT,gBAAgB,MAAM,mBAAmB,aAAa,KAAA,IAAY,MAAM;IACzE,CAAC;IAED,MAAM,IAAI;IACV,SAAS,IAAI;GACd;GAEA,MAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;GAEjE,MAAM,cAAc,QAAQ,MAAM,KAAK;GACvC,MAAM,eAAe,QAAQ,MAAM,MAAM;GAEzC,IAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;GAC1D,IAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;GAE5D,IAAI,eAAe,QAAQ,gBAAgB,MAC1C,iBAAiB,cAAc;QACzB,IAAI,eAAe,QAAQ,gBAAgB,MACjD,gBAAgB,eAAe;GAGhC,OAAO;IACN;IACA;IACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;IAC5C,OAAO,KAAK,MAAM,aAAa;IAC/B,QAAQ,KAAK,MAAM,cAAc;GAClC;EACD,CAAC;;GAKO,OAAA,MAAA,SADPA,UAAA,GAAAC,mBAOE,OAAA;;IALA,KAAK,MAAA,MAAM;IACX,QAAQ,MAAA,MAAM;IACd,KAAK,MAAA,MAAM;IACX,OAAO,MAAA,MAAM;IACb,QAAQ,MAAA,MAAM"}
|
package/dist/PrismicLink.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.cjs","names":[],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicLink.cjs","names":["_sfc_main"],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|
package/dist/PrismicLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.js","names":[],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicLink.js","names":["_sfc_main"],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|
|
@@ -2,7 +2,7 @@ import { ComponentOrTagName } from "./types.cjs";
|
|
|
2
2
|
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
3
3
|
//#region src/PrismicLink.vue.d.ts
|
|
4
4
|
/** Props for `<PrismicLink />`. */
|
|
5
|
-
type PrismicLinkProps = {
|
|
5
|
+
export type PrismicLinkProps = {
|
|
6
6
|
/**
|
|
7
7
|
* The link resolver used to resolve links.
|
|
8
8
|
*
|
|
@@ -42,9 +42,9 @@ type PrismicLinkProps = {
|
|
|
42
42
|
document: PrismicDocument;
|
|
43
43
|
field?: never;
|
|
44
44
|
});
|
|
45
|
-
declare var
|
|
45
|
+
declare var __VLS_7: {};
|
|
46
46
|
type __VLS_Slots = {} & {
|
|
47
|
-
default?: (props: typeof
|
|
47
|
+
default?: (props: typeof __VLS_7) => any;
|
|
48
48
|
};
|
|
49
49
|
declare const __VLS_base: import("vue").DefineComponent<({
|
|
50
50
|
/**
|
|
@@ -195,5 +195,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
197
|
//#endregion
|
|
198
|
-
export {
|
|
198
|
+
export { _default as default };
|
|
199
199
|
//# sourceMappingURL=PrismicLink.vue.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue.d.cts","names":[],"sources":["../src/PrismicLink.vue"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue.d.cts","names":[],"sources":["../src/PrismicLink.vue"],"mappings":";;;;YAgJY;;;;;;;;;EASX,eAAe;;;;;;EAOf,eAAe;;;;;;;;;EAUf,oBAAoB;;;;;;EAOpB,oBAAoB;;;EAIlB,OAAO;EACP;;;EAIA,UAAU;EACV;;YAyEC;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU;;;;;;;;;EAhHA,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EAIX,OAAA;EACI;;;;;;;;;;EA7BE,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EASR,UAAA;EACF;;;;;;;;;;EAlCK,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EAIX,OAAA;EACI;;;;;;;;;;EA7BE,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EASR,UAAA;EACF;MAgFT,oDAAA;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -2,7 +2,7 @@ import { ComponentOrTagName } from "./types.js";
|
|
|
2
2
|
import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
|
|
3
3
|
//#region src/PrismicLink.vue.d.ts
|
|
4
4
|
/** Props for `<PrismicLink />`. */
|
|
5
|
-
type PrismicLinkProps = {
|
|
5
|
+
export type PrismicLinkProps = {
|
|
6
6
|
/**
|
|
7
7
|
* The link resolver used to resolve links.
|
|
8
8
|
*
|
|
@@ -42,9 +42,9 @@ type PrismicLinkProps = {
|
|
|
42
42
|
document: PrismicDocument;
|
|
43
43
|
field?: never;
|
|
44
44
|
});
|
|
45
|
-
declare var
|
|
45
|
+
declare var __VLS_7: {};
|
|
46
46
|
type __VLS_Slots = {} & {
|
|
47
|
-
default?: (props: typeof
|
|
47
|
+
default?: (props: typeof __VLS_7) => any;
|
|
48
48
|
};
|
|
49
49
|
declare const __VLS_base: import("vue").DefineComponent<({
|
|
50
50
|
/**
|
|
@@ -195,5 +195,5 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
197
|
//#endregion
|
|
198
|
-
export {
|
|
198
|
+
export { _default as default };
|
|
199
199
|
//# sourceMappingURL=PrismicLink.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue.d.ts","names":[],"sources":["../src/PrismicLink.vue"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue.d.ts","names":[],"sources":["../src/PrismicLink.vue"],"mappings":";;;;YAgJY;;;;;;;;;EASX,eAAe;;;;;;EAOf,eAAe;;;;;;;;;EAUf,oBAAoB;;;;;;EAOpB,oBAAoB;;;EAIlB,OAAO;EACP;;;EAIA,UAAU;EACV;;YAyEC;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU;;;;;;;;;EAhHA,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EAIX,OAAA;EACI;;;;;;;;;;EA7BE,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EASR,UAAA;EACF;;;;;;;;;;EAlCK,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EAIX,OAAA;EACI;;;;;;;;;;EA7BE,eAAA;;;;;;EAOT,eAAS;;;;;;;;;EAUK,oBAAA;;;;;;EAOA,oBAAA;;;EASR,UAAA;EACF;MAgFT,oDAAA;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;AAeA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,cAAc,oBAAoB,
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.cjs","names":["usePrismic","computed","asLinkAttrs","isInternalURL","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_withCtx","_renderSlot","_createTextVNode","_toDisplayString"],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;AAeA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,cAAc,oBAAoB,eAAeA,sBAAAA,WAAW;EAEpE,MAAM,YAAA,GAAWC,IAAAA,SAAAA,OAAe;GAC/B,QAAA,GAAOC,kBAAAA,YAAAA,CAAY,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM,gBAAgB;IACpC,IAAI,MAAM;KACT,IAAI,MAAM,KACT,OAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,IAAI,IAAI,MAAM;KAGlE,OAAO,KAAK,aAAa,8BAA8B,KAAA;IACxD;GACD,CAAC;EACF,CAAC;EAED,MAAM,aAAA,GAAYD,IAAAA,SAAAA,OAAe;GAChC,OAAOE,sBAAAA,cAAc,SAAS,MAAM,QAAQ,EAAE,IAC3C,MAAM,qBAAqB,YAAY,yBAAyB,2BAChE,MAAM,qBAAqB,YAAY,yBAAyB;EACpE,CAAC;EAGD,MAAM,SAAA,GAAQF,IAAAA,SAAAA,OAAe;GAC5B,OAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB,IACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB;EACH,CAAC;;GAIA,QAAA,GAAAG,IAAAA,UAAAA,CAAA,IAAA,GAAAC,IAAAA,YAAAA,EAAAA,GAIYC,IAAAA,wBAAAA,CAJI,UAAA,KAAS,IAAA,GAAAC,IAAAA,eAAAA,EAAAA,GAAAC,IAAAA,mBAAAA,CAAU,MAAA,KAAK,CAAA,GAAA;IACvC,UAAA,GAAAC,IAAAA,QAAAA,OAEO,EAAA,GAFPC,IAAAA,WAAAA,CAEO,KAAA,QAAA,WAAA,CAAA,SAAA,EAAA,GADHC,IAAAA,gBAAAA,EAAAA,GAAAC,IAAAA,gBAAAA,CAAA,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAA,CAAS,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;AAeA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,cAAc,oBAAoB,eAAe,WAAW;EAEpE,MAAM,WAAW,eAAe;GAC/B,OAAO,YAAY,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM,gBAAgB;IACpC,IAAI,MAAM;KACT,IAAI,MAAM,KACT,OAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,IAAI,IAAI,MAAM;KAGlE,OAAO,KAAK,aAAa,8BAA8B,KAAA;IACxD;GACD,CAAC;EACF,CAAC;EAED,MAAM,YAAY,eAAe;GAChC,OAAO,cAAc,SAAS,MAAM,QAAQ,EAAE,IAC3C,MAAM,qBAAqB,YAAY,yBAAyB,2BAChE,MAAM,qBAAqB,YAAY,yBAAyB;EACpE,CAAC;EAGD,MAAM,QAAQ,eAAe;GAC5B,OAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB,IACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB;EACH,CAAC;;GAIA,
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_withCtx","_renderSlot","_createTextVNode","_toDisplayString"],"sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"./createPrismic\"\nimport { isInternalURL } from \"./lib/isInternalURL\"\nimport type { ComponentOrTagName } from \"./types\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if the link's URL is\n\t * external. This prop can be provided a function to use the link's metadata to determine the\n\t * `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link component, provide the Link\n\t * component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { linkResolver: pluginLinkResolver, components } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || pluginLinkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || components?.linkInternalComponent || defaultInternalComponent\n\t\t: props.externalComponent || components?.linkExternalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;AAeA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,cAAc,oBAAoB,eAAe,WAAW;EAEpE,MAAM,WAAW,eAAe;GAC/B,OAAO,YAAY,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM,gBAAgB;IACpC,IAAI,MAAM;KACT,IAAI,MAAM,KACT,OAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,IAAI,IAAI,MAAM;KAGlE,OAAO,KAAK,aAAa,8BAA8B,KAAA;IACxD;GACD,CAAC;EACF,CAAC;EAED,MAAM,YAAY,eAAe;GAChC,OAAO,cAAc,SAAS,MAAM,QAAQ,EAAE,IAC3C,MAAM,qBAAqB,YAAY,yBAAyB,2BAChE,MAAM,qBAAqB,YAAY,yBAAyB;EACpE,CAAC;EAGD,MAAM,QAAQ,eAAe;GAC5B,OAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB,IACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;GACrB;EACH,CAAC;;GAIA,OAAAA,UAAA,GAAAC,YAIYC,wBAJI,UAAA,KAAS,GAAAC,eAAAC,mBAAU,MAAA,KAAK,CAAA,GAAA;IACvC,SAAAC,cAEO,CAFPC,WAEO,KAAA,QAAA,WAAA,CAAA,SAAA,CADHC,gBAAAC,gBAAA,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAA,CAAS,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.cjs","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicRichText.cjs","names":["_sfc_main"],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.js","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PrismicRichText.js","names":["_sfc_main"],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
|
|
@@ -4,7 +4,7 @@ import { LinkResolverFunction, RichTextField } from "@prismicio/client";
|
|
|
4
4
|
import { PropType } from "vue";
|
|
5
5
|
//#region src/PrismicRichText/PrismicRichText.vue.d.ts
|
|
6
6
|
/** Props for `<PrismicRichText />`. */
|
|
7
|
-
type PrismicRichTextProps = {
|
|
7
|
+
export type PrismicRichTextProps = {
|
|
8
8
|
/** The Prismic rich text field to render. */
|
|
9
9
|
field: RichTextField | null | undefined;
|
|
10
10
|
/**
|
|
@@ -64,5 +64,5 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
65
|
declare const _default: typeof __VLS_export;
|
|
66
66
|
//#endregion
|
|
67
|
-
export {
|
|
67
|
+
export { _default as default };
|
|
68
68
|
//# sourceMappingURL=PrismicRichText.vue.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.vue.d.cts","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"PrismicRichText.vue.d.cts","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"mappings":";;;;;;YAiJY;;EAEX,OAAO;;;;;;;;;EAUP,eAAe;;;;;;;;;;;;;EAcf,aAAa;;;;;EAMb,WAAW;;cA+GN,4BAAY,8BAAA;;IAGU,MAAA,SAAS;;;IAGjB,MAAA,SAAS;;;IAGX,MAAA,SAAS;;;IAGW,MAAA,SAAS;;;;IATnB,MAAA,SAAS;;;IAGjB,MAAA,SAAS;;;IAGX,MAAA,SAAS;;;IAGW,MAAA,SAAS;;MAG7C,oDAAA;cACmB,iBAAO"}
|
|
@@ -4,7 +4,7 @@ import { PropType } from "vue";
|
|
|
4
4
|
import { LinkResolverFunction, RichTextField } from "@prismicio/client";
|
|
5
5
|
//#region src/PrismicRichText/PrismicRichText.vue.d.ts
|
|
6
6
|
/** Props for `<PrismicRichText />`. */
|
|
7
|
-
type PrismicRichTextProps = {
|
|
7
|
+
export type PrismicRichTextProps = {
|
|
8
8
|
/** The Prismic rich text field to render. */
|
|
9
9
|
field: RichTextField | null | undefined;
|
|
10
10
|
/**
|
|
@@ -64,5 +64,5 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
65
|
declare const _default: typeof __VLS_export;
|
|
66
66
|
//#endregion
|
|
67
|
-
export {
|
|
67
|
+
export { _default as default };
|
|
68
68
|
//# sourceMappingURL=PrismicRichText.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.vue.d.ts","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"PrismicRichText.vue.d.ts","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"mappings":";;;;;;YAiJY;;EAEX,OAAO;;;;;;;;;EAUP,eAAe;;;;;;;;;;;;;EAcf,aAAa;;;;;EAMb,WAAW;;cA+GN,4BAAY,8BAAA;;IAGU,MAAA,SAAS;;;IAGjB,MAAA,SAAS;;;IAGX,MAAA,SAAS;;;IAGW,MAAA,SAAS;;;;IATnB,MAAA,SAAS;;;IAGjB,MAAA,SAAS;;;IAGX,MAAA,SAAS;;;IAGW,MAAA,SAAS;;MAG7C,oDAAA;cACmB,iBAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,QAAQ;EAgBd,MAAM,EACL,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.cjs","names":["usePrismic","computed","asTree","isComponent","PrismicRichTextDefaultComponent","_openBlock","_createBlock","PrismicRichTextSerialize","_resolveDynamicComponent","_createCommentVNode"],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,QAAQ;EAgBd,MAAM,EACL,YAAY,EAAE,yBACXA,sBAAAA,WAAW;EAEf,MAAM,sBAAA,GAAqBC,IAAAA,SAAAA,OAAmC;GAC7D,OAAO;IAAE,GAAG;IAAoB,GAAG,MAAM;GAAW;EACrD,CAAC;EAED,MAAM,YAAA,GAAWA,IAAAA,SAAAA,OAAe;GAC/B,QAAA,GAAOC,2BAAAA,OAAAA,CAAO,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;EAClC,CAAC;EAED,SAAS,qBAAqB,MAAqC;GAClE,MAAM,4BAA4B,mBAAmB,QAAQ;GAK7D,IAAIC,cAAAA,YAAY,yBAAyB,GACxC,OAAO,EAAE,IAAI,0BAA0B;GAGxC,OAAO;IACN,IAAIC,wCAAAA;IACJ,cAAc,MAAM;IACpB,WAAW;GACZ;EACD;EAEA,MAAM,sBAAA,GAAqBH,IAAAA,SAAAA,OAA2C;GACrE,OAAO;IACN,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,WAAW,qBAAqB,WAAW;IAC3C,cAAc,qBAAqB,cAAc;IACjD,QAAQ,qBAAqB,QAAQ;IACrC,IAAI,qBAAqB,IAAI;IAC7B,aAAa,qBAAqB,UAAU;IAC5C,eAAe,qBAAqB,WAAW;IAC/C,mBAAmB,qBAAqB,MAAM;IAC9C,qBAAqB,qBAAqB,OAAO;IACjD,OAAO,qBAAqB,OAAO;IACnC,OAAO,qBAAqB,OAAO;IACnC,WAAW,qBAAqB,WAAW;IAC3C,OAAO,qBAAqB,OAAO;IACnC,MAAM,qBAAqB,MAAM;GAClC;EACD,CAAC;;GAKO,OAAA,SAAA,MAAS,WAAA,GADhBI,IAAAA,UAAAA,CAAA,IAAA,GAAAC,IAAAA,YAAAA,CAIEC,iCAAAA,SAAA;;IAFA,UAAU,SAAA;IACV,uBAAqB,mBAAA;GAED,GAAA,MAAA,GAAA,CAAA,YAAA,qBAAA,CAAA,KAAA,QAAA,aAAA,GAAtBF,IAAAA,UAAAA,CAAA,IAAA,GAAAC,IAAAA,YAAAA,EAAAA,GAAiDE,IAAAA,wBAAAA,CAAZ,QAAA,QAAQ,GAAA,EAAA,KAAA,EAAA,CAAA,MAAA,GAAA,IAAA,mBAAA,CAAA,QAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,QAAQ;EAgBd,MAAM,EACL,YAAY,EAAE,yBACX,WAAW;EAEf,MAAM,qBAAqB,eAAmC;GAC7D,OAAO;IAAE,GAAG;IAAoB,GAAG,MAAM;GAAW;EACrD,CAAC;EAED,MAAM,WAAW,eAAe;GAC/B,OAAO,OAAO,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;EAClC,CAAC;EAED,SAAS,qBAAqB,MAAqC;GAClE,MAAM,4BAA4B,mBAAmB,QAAQ;GAK7D,IAAI,YAAY,yBAAyB,GACxC,OAAO,EAAE,IAAI,0BAA0B;GAGxC,OAAO;IACN,
|
|
1
|
+
{"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.js","names":["PrismicRichTextDefaultComponent","_openBlock","_createBlock","PrismicRichTextSerialize","_resolveDynamicComponent","_createCommentVNode"],"sources":["../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkResolverFunction, RichTextField, RichTextNodeType } from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { usePrismic } from \"../createPrismic\"\nimport type { ComponentOrTagName, ComponentShorthand } from \"../types\"\nimport { isComponent } from \"../types\"\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\nimport type { InternalRichTextComponents, RichTextComponent, RichTextComponents } from \"./types\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic repository's content, a link\n\t * resolver does not need to be provided.\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a shorthand definition.\n\t *\n\t * @example\n\t * \t```javascript\n\t * \t;({\n\t * \t\theading1: Heading1,\n\t * \t\tparagraph: { class: \"prose\" },\n\t * \t\tstrong: { as: \"em\", class: \"font-bold\" }\n\t * \t})\n\t * \t```\n\t */\n\tcomponents?: RichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not given, `null` will be\n\t * rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<PrismicRichTextProps[\"fallback\"]>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst {\n\tcomponents: { richTextComponents },\n} = usePrismic()\n\nconst resolvedComponents = computed<RichTextComponents>(() => {\n\treturn { ...richTextComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| RichTextComponent\n\t\t| ComponentShorthand\n\t\t| undefined\n\n\tif (isComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,QAAQ;EAgBd,MAAM,EACL,YAAY,EAAE,yBACX,WAAW;EAEf,MAAM,qBAAqB,eAAmC;GAC7D,OAAO;IAAE,GAAG;IAAoB,GAAG,MAAM;GAAW;EACrD,CAAC;EAED,MAAM,WAAW,eAAe;GAC/B,OAAO,OAAO,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;EAClC,CAAC;EAED,SAAS,qBAAqB,MAAqC;GAClE,MAAM,4BAA4B,mBAAmB,QAAQ;GAK7D,IAAI,YAAY,yBAAyB,GACxC,OAAO,EAAE,IAAI,0BAA0B;GAGxC,OAAO;IACN,IAAIA;IACJ,cAAc,MAAM;IACpB,WAAW;GACZ;EACD;EAEA,MAAM,qBAAqB,eAA2C;GACrE,OAAO;IACN,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,UAAU,qBAAqB,UAAU;IACzC,WAAW,qBAAqB,WAAW;IAC3C,cAAc,qBAAqB,cAAc;IACjD,QAAQ,qBAAqB,QAAQ;IACrC,IAAI,qBAAqB,IAAI;IAC7B,aAAa,qBAAqB,UAAU;IAC5C,eAAe,qBAAqB,WAAW;IAC/C,mBAAmB,qBAAqB,MAAM;IAC9C,qBAAqB,qBAAqB,OAAO;IACjD,OAAO,qBAAqB,OAAO;IACnC,OAAO,qBAAqB,OAAO;IACnC,WAAW,qBAAqB,WAAW;IAC3C,OAAO,qBAAqB,OAAO;IACnC,MAAM,qBAAqB,MAAM;GAClC;EACD,CAAC;;GAKO,OAAA,SAAA,MAAS,UADhBC,UAAA,GAAAC,YAIEC,kCAAA;;IAFA,UAAU,SAAA;IACV,uBAAqB,mBAAA;GAED,GAAA,MAAA,GAAA,CAAA,YAAA,qBAAA,CAAA,KAAA,QAAA,YAAtBF,UAAA,GAAAC,YAAiDE,wBAAZ,QAAA,QAAQ,GAAA,EAAA,KAAA,EAAA,CAAA,KAAA,mBAAA,QAAA,IAAA"}
|