@prismicio/vue 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/components/PrismicEmbed.cjs.map +1 -1
  2. package/dist/components/PrismicEmbed.d.ts +1 -1
  3. package/dist/components/PrismicEmbed.js.map +1 -1
  4. package/dist/components/PrismicImage.cjs +2 -2
  5. package/dist/components/PrismicImage.cjs.map +1 -1
  6. package/dist/components/PrismicImage.d.ts +4 -4
  7. package/dist/components/PrismicImage.js +2 -2
  8. package/dist/components/PrismicImage.js.map +1 -1
  9. package/dist/components/PrismicLink.cjs +3 -3
  10. package/dist/components/PrismicLink.cjs.map +1 -1
  11. package/dist/components/PrismicLink.d.ts +5 -5
  12. package/dist/components/PrismicLink.js +3 -3
  13. package/dist/components/PrismicLink.js.map +1 -1
  14. package/dist/components/PrismicRichText.cjs +3 -3
  15. package/dist/components/PrismicRichText.cjs.map +1 -1
  16. package/dist/components/PrismicRichText.d.ts +3 -3
  17. package/dist/components/PrismicRichText.js +3 -3
  18. package/dist/components/PrismicRichText.js.map +1 -1
  19. package/dist/components/PrismicText.cjs +1 -1
  20. package/dist/components/PrismicText.cjs.map +1 -1
  21. package/dist/components/PrismicText.d.ts +2 -2
  22. package/dist/components/PrismicText.js +1 -1
  23. package/dist/components/PrismicText.js.map +1 -1
  24. package/dist/components/SliceZone.cjs +1 -1
  25. package/dist/components/SliceZone.cjs.map +1 -1
  26. package/dist/components/SliceZone.d.ts +2 -2
  27. package/dist/components/SliceZone.js +1 -1
  28. package/dist/components/SliceZone.js.map +1 -1
  29. package/dist/composables.cjs.map +1 -1
  30. package/dist/composables.js.map +1 -1
  31. package/dist/createPrismic.cjs.map +1 -1
  32. package/dist/createPrismic.js.map +1 -1
  33. package/dist/injectionSymbols.cjs.map +1 -1
  34. package/dist/injectionSymbols.js.map +1 -1
  35. package/dist/lib/simplyResolveComponent.cjs.map +1 -1
  36. package/dist/lib/simplyResolveComponent.js.map +1 -1
  37. package/dist/types.d.ts +4 -4
  38. package/dist/usePrismic.cjs.map +1 -1
  39. package/dist/usePrismic.js.map +1 -1
  40. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  41. package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
  42. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  43. package/package.json +27 -19
  44. package/src/components/PrismicEmbed.ts +4 -3
  45. package/src/components/PrismicImage.ts +16 -15
  46. package/src/components/PrismicLink.ts +14 -13
  47. package/src/components/PrismicRichText.ts +15 -14
  48. package/src/components/PrismicText.ts +7 -7
  49. package/src/components/SliceZone.ts +7 -6
  50. package/src/composables.ts +2 -5
  51. package/src/createPrismic.ts +15 -15
  52. package/src/injectionSymbols.ts +0 -2
  53. package/src/lib/simplyResolveComponent.ts +1 -1
  54. package/src/types.ts +10 -13
  55. package/src/usePrismic.ts +2 -1
  56. package/src/useStatefulPrismicClientMethod.ts +3 -3
  57. package/vetur/attributes.json +1 -6
  58. package/vetur/tags.json +17 -3
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicEmbed.cjs","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\th,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\";\n\nimport { EmbedField } from \"@prismicio/types\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps;\n\t};\n};\n"],"names":["defineComponent","h","simplyResolveComponent"],"mappings":";;;;AAkBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiDA,oBAAAA,gBAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,WAAO,MAAK;AACX,aAAOC,IAAE,EAAAC,uBAAA,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;;;"}
1
+ {"version":3,"file":"PrismicEmbed.cjs","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tdefineComponent,\n\th,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { EmbedField } from \"@prismicio/types\";\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps;\n\t};\n};\n"],"names":["defineComponent","h","simplyResolveComponent"],"mappings":";;;;AAmBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiDA,oBAAAA,gBAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,WAAO,MAAK;AACX,aAAOC,IAAE,EAAAC,uBAAA,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;;;"}
@@ -45,7 +45,7 @@ export declare const PrismicEmbedImpl: DefineComponent<{
45
45
  };
46
46
  }>>, {
47
47
  wrapper: string | ConcreteComponent | Raw<DefineComponent>;
48
- }>;
48
+ }, {}>;
49
49
  /**
50
50
  * Component to render a Prismic embed field.
51
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicEmbed.js","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\th,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\";\n\nimport { EmbedField } from \"@prismicio/types\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps;\n\t};\n};\n"],"names":[],"mappings":";;AAkBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiD,gCAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;"}
1
+ {"version":3,"file":"PrismicEmbed.js","sources":["../../../src/components/PrismicEmbed.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tdefineComponent,\n\th,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { EmbedField } from \"@prismicio/types\";\n\n/**\n * The default component rendered to wrap the embed.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicEmbed />`.\n */\nexport type PrismicEmbedProps = {\n\t/**\n\t * The Prismic embed field to render.\n\t */\n\tfield: EmbedField;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<PrismicEmbed />` implementation.\n *\n * @internal\n */\nexport const PrismicEmbedImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicEmbed\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<EmbedField>,\n\t\t\trequired: true,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\t\"data-oembed\": props.field.embed_url,\n\t\t\t\t\"data-oembed-type\": props.field.type,\n\t\t\t\t\"data-oembed-provider\": props.field.provider_name,\n\t\t\t\tinnerHTML: props.field.html || null,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic embed field.\n *\n * @see Component props {@link PrismicEmbedProps}\n * @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}\n */\nexport const PrismicEmbed = PrismicEmbedImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicEmbedProps;\n\t};\n};\n"],"names":[],"mappings":";;AAmBA,MAAM,iBAAiB;AAyBhB,MAAM,mBAAiD,gCAAA;AAAA,EAC7D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,eAAe,MAAM,MAAM;AAAA,QAC3B,oBAAoB,MAAM,MAAM;AAAA,QAChC,wBAAwB,MAAM,MAAM;AAAA,QACpC,WAAW,MAAM,MAAM,QAAQ;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
3
  const helpers = require("@prismicio/helpers");
5
- const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
4
+ const vue = require("vue");
6
5
  const __PRODUCTION__ = require("../lib/__PRODUCTION__.cjs");
6
+ const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
7
7
  const usePrismic = require("../usePrismic.cjs");
8
8
  const defaultImageComponent = "img";
9
9
  const usePrismicImage = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.cjs","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tcomputed,\n\tConcreteComponent,\n\tComputedRef,\n\tdefineComponent,\n\th,\n\tPropType,\n\tVNodeProps,\n\tunref,\n\tDefineComponent,\n\tRaw,\n} from \"vue\";\n\nimport { ImageField } from \"@prismicio/types\";\nimport {\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasImagePixelDensitySrcSet,\n\tisFilled,\n} from \"@prismicio/helpers\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { usePrismic } from \"../usePrismic\";\nimport { VueUseOptions } from \"../types\";\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\";\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1];\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\";\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\";\n};\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>;\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>;\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams);\n\t\tconst widths = unref(props.widths);\n\t\tconst pixelDensities = unref(props.pixelDensities);\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.\",\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t});\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t});\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\t});\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src;\n\t});\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset;\n\t});\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\";\n\t});\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null;\n\t});\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t};\n};\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t);\n\t\t});\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props);\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t};\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes);\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t});\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isFilled","__PRODUCTION__","asImageWidthSrcSet","asImagePixelDensitySrcSet","asImageSrc","defineComponent","h","simplyResolveComponent"],"mappings":";;;;;;;AA+BA,MAAM,wBAAwB;AA0GjB,MAAA,kBAAkB,CAC9B,UAC8B;AACxB,QAAA,EAAE,YAAYA,WAAAA;AAEd,QAAA,UAAUC,IAAAA,SAAS,MAAK;;AACvB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,MAAM,KAAK,GAAG;AACpB,aAAA;AAAA,QACN,KAAK;AAAA,QACL,QAAQ;AAAA,MAAA;AAAA,IAET;AAEK,UAAA,cAAcD,IAAAA,MAAM,MAAM,WAAW;AACrC,UAAA,SAASA,IAAAA,MAAM,MAAM,MAAM;AAC3B,UAAA,iBAAiBA,IAAAA,MAAM,MAAM,cAAc;AAEjD,QAAI,QAAQ;AACP,UAAA,CAACE,iCAAkB,gBAAgB;AAC9B,gBAAA,KACP,6MACA,KAAK;AAAA,MAEN;AAED,aAAOC,QAAAA,mBAAmB,OAAO;AAAA,QAChC,GAAG;AAAA,QACH,QACC,WAAW,cACR,aAAQ,eAAR,mBAAoB,2BACpB;AAAA,MAAA,CACJ;AAAA,eACS,gBAAgB;AAC1B,aAAOC,QAAAA,0BAA0B,OAAO;AAAA,QACvC,GAAG;AAAA,QACH,gBACC,mBAAmB,cAChB,aAAQ,eAAR,mBAAoB,kCACpB;AAAA,MAAA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d,UAAA,OAAOC,IAAAA,SAAS,MAAK;;AAC1B,aACC,MAAM,oBACN,aAAQ,eAAR,mBAAoB,mBACpB;AAAA,IAAA,CAED;AAED,UAAM,EAAE,KAAK,QAAQ,KAAK,cAAc,gBAAgB,KAAK;AAE7D,WAAO,MAAK;AACX,YAAM,aAAa;AAAA,QAClB,KAAK,IAAI;AAAA,QACT,QAAQ,OAAO;AAAA,QACf,KAAK,IAAI;AAAA,MAAA;AAGV,cAAQ,KAAK,OAAO;AAAA,QACnB,KAAK;AAEG,iBAAAQ,IAAA,EAAE,OAAO,UAAU;AAAA,QAE3B;AACC,iBAAOA,MAAEC,uBAAAA,uBAAuB,KAAK,KAAK,GAAG;AAAA,YAC5C,GAAG;AAAA,YACH,WAAW,UAAU;AAAA,UAAA,CACrB;AAAA,MACF;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;;;;"}
1
+ {"version":3,"file":"PrismicImage.cjs","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import {\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { ImageField } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\";\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1];\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\";\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\";\n};\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>;\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>;\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams);\n\t\tconst widths = unref(props.widths);\n\t\tconst pixelDensities = unref(props.pixelDensities);\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.\",\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t});\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t});\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\t});\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src;\n\t});\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset;\n\t});\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\";\n\t});\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null;\n\t});\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t};\n};\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t);\n\t\t});\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props);\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t};\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes);\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t});\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isFilled","__PRODUCTION__","asImageWidthSrcSet","asImagePixelDensitySrcSet","asImageSrc","defineComponent","h","simplyResolveComponent"],"mappings":";;;;;;;AAgCA,MAAM,wBAAwB;AA0GjB,MAAA,kBAAkB,CAC9B,UAC8B;AACxB,QAAA,EAAE,YAAYA,WAAAA;AAEd,QAAA,UAAUC,IAAAA,SAAS,MAAK;;AACvB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,MAAM,KAAK,GAAG;AACpB,aAAA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AO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,QAAQ,MAAM;AAAA,MAGrB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,QAAQ;AAAA,MACP,MAAM,CAAC,QAAQ,MAAM;AAAA,MAKrB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,QAAQ,MAAM;AAAA,MAMrB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AAEN,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAEK,UAAA,EAAE,YAAYR,WAAAA;AAEd,UAAA,OAAOC,IAAAA,SAAS,MAAK;;AAC1B,aACC,MAAM,oBACN,aAAQ,eAAR,mBAAoB,mBACpB;AAAA,IAAA,CAED;AAED,UAAM,EAAE,KAAK,QAAQ,KAAK,cAAc,gBAAgB,KAAK;AAE7D,WAAO,MAAK;AACX,YAAM,aAAa;AAAA,QAClB,KAAK,IAAI;AAAA,QACT,QAAQ,OAAO;AAAA,QACf,KAAK,IAAI;AAAA,MAAA;AAGV,cAAQ,KAAK,OAAO;AAAA,QACnB,KAAK;AAEG,iBAAAQ,IAAA,EAAE,OAAO,UAAU;AAAA,QAE3B;AACC,iBAAOA,MAAEC,uBAAAA,uBAAuB,KAAK,KAAK,GAAG;AAAA,YAC5C,GAAG;AAAA,YACH,WAAW,UAAU;AAAA,UAAA,CACrB;AAAA,MACF;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;;;;"}
@@ -1,7 +1,7 @@
1
- import { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, ComputedRef, PropType, VNodeProps, DefineComponent, Raw } from "vue";
2
- import { ImageField } from "@prismicio/types";
3
- import { asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet } from "@prismicio/helpers";
1
+ import { asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet } from "@prismicio/helpers";
2
+ import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
4
3
  import { VueUseOptions } from "../types";
4
+ import { ImageField } from "@prismicio/types";
5
5
  /**
6
6
  * Props for `<PrismicImage />`.
7
7
  */
@@ -150,7 +150,7 @@ export declare const PrismicImageImpl: DefineComponent<{
150
150
  pixelDensities: number[] | "defaults" | undefined;
151
151
  imageComponent: string | ConcreteComponent | Raw<DefineComponent>;
152
152
  imgixParams: import("imgix-url-builder").ImgixURLParams | undefined;
153
- }>;
153
+ }, {}>;
154
154
  /**
155
155
  * Component to render a Prismic image field.
156
156
  *
@@ -1,7 +1,7 @@
1
- import { computed, unref, defineComponent, h } from "vue";
2
1
  import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet, asImageSrc } from "@prismicio/helpers";
3
- import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
2
+ import { computed, unref, defineComponent, h } from "vue";
4
3
  import { __PRODUCTION__ } from "../lib/__PRODUCTION__.js";
4
+ import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
5
5
  import { usePrismic } from "../usePrismic.js";
6
6
  const defaultImageComponent = "img";
7
7
  const usePrismicImage = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.js","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tcomputed,\n\tConcreteComponent,\n\tComputedRef,\n\tdefineComponent,\n\th,\n\tPropType,\n\tVNodeProps,\n\tunref,\n\tDefineComponent,\n\tRaw,\n} from \"vue\";\n\nimport { ImageField } from \"@prismicio/types\";\nimport {\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasImagePixelDensitySrcSet,\n\tisFilled,\n} from \"@prismicio/helpers\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { usePrismic } from \"../usePrismic\";\nimport { VueUseOptions } from \"../types\";\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\";\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1];\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\";\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\";\n};\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>;\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>;\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams);\n\t\tconst widths = unref(props.widths);\n\t\tconst pixelDensities = unref(props.pixelDensities);\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.\",\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t});\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t});\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\t});\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src;\n\t});\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset;\n\t});\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\";\n\t});\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null;\n\t});\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t};\n};\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t);\n\t\t});\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props);\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t};\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes);\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t});\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps;\n\t};\n};\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.js","sources":["../../../src/components/PrismicImage.ts"],"sourcesContent":["import {\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { ImageField } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered for images.\n */\nconst defaultImageComponent = \"img\";\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field to render.\n\t */\n\tfield: ImageField | ImageField<string>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * images.\n\t *\n\t * @remarks\n\t * HTML tag names and components will be rendered using the `img` tag\n\t * interface (`src`, `srcset`, and `alt` attribute). Components will also\n\t * receive an additional `copyright` props.\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"img\"` otherwise.\n\t */\n\timageComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An object of Imgix URL API parameters.\n\t *\n\t * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1];\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following given widths.\n\t *\n\t * @remarks\n\t * A special value of `\"thumbnails\"` is accepted to automatically use image\n\t * widths coming from the API.\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * widths coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `pixelDensities` prop. When both are\n\t * used the `pixelDensities` prop will be ignored.\n\t */\n\twidths?:\n\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t| \"thumbnails\"\n\t\t| \"defaults\";\n\n\t/**\n\t * Adds an additional `srcset` attribute to the image following giving pixel\n\t * densities.\n\t *\n\t * @remarks\n\t * A special value of `\"defaults\"` is accepted to automatically use image\n\t * pixel densities coming from the plugin configuration.\n\t * @remarks\n\t * This prop is not compatible with the `widths` prop. When both are used, the\n\t * `pixelDensities` prop will be ignored.\n\t */\n\tpixelDensities?:\n\t\t| NonNullable<\n\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t >[\"pixelDensities\"]\n\t\t| \"defaults\";\n};\n\n/**\n * Options for {@link usePrismicImage}.\n */\nexport type UsePrismicImageOptions = VueUseOptions<\n\tOmit<PrismicImageProps, \"imageComponent\">\n>;\n\n/**\n * Return type of {@link usePrismicImage}.\n */\nexport type UsePrismicImageReturnType = {\n\t/**\n\t * Resolved image `src` value.\n\t */\n\tsrc: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `srcset` value.\n\t */\n\tsrcset: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved image `alt` value.\n\t */\n\talt: ComputedRef<string>;\n\n\t/**\n\t * Resolved image `copyright` value.\n\t */\n\tcopyright: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns a resolved information about a Prismic\n * image field.\n *\n * @param props - {@link UsePrismicImageOptions}\n *\n * @returns - Resolved image information {@link UsePrismicImageReturnType}\n */\nexport const usePrismicImage = (\n\tprops: UsePrismicImageOptions,\n): UsePrismicImageReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst asImage = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.image(field)) {\n\t\t\treturn {\n\t\t\t\tsrc: null,\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\n\t\tconst imgixParams = unref(props.imgixParams);\n\t\tconst widths = unref(props.widths);\n\t\tconst pixelDensities = unref(props.pixelDensities);\n\n\t\tif (widths) {\n\t\t\tif (!__PRODUCTION__ && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.\",\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths:\n\t\t\t\t\twidths === \"defaults\"\n\t\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t\t: widths,\n\t\t\t});\n\t\t} else if (pixelDensities) {\n\t\t\treturn asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\"\n\t\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t\t: pixelDensities,\n\t\t\t});\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsrc: asImageSrc(field, imgixParams),\n\t\t\t\tsrcset: null,\n\t\t\t};\n\t\t}\n\t});\n\n\tconst src = computed(() => {\n\t\treturn asImage.value.src;\n\t});\n\tconst srcset = computed(() => {\n\t\treturn asImage.value.srcset;\n\t});\n\tconst alt = computed(() => {\n\t\treturn unref(props.field).alt || \"\";\n\t});\n\tconst copyright = computed(() => {\n\t\treturn unref(props.field).copyright || null;\n\t});\n\n\treturn {\n\t\tsrc,\n\t\tsrcset,\n\t\talt,\n\t\tcopyright,\n\t};\n};\n\n/**\n * `<PrismicImage />` implementation.\n *\n * @internal\n */\nexport const PrismicImageImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicImage\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<ImageField | ImageField<string>>,\n\t\t\trequired: true,\n\t\t},\n\t\timageComponent: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\timgixParams: {\n\t\t\ttype: Object as PropType<Parameters<typeof asImageSrc>[1]>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twidths: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tpixelDensities: {\n\t\t\ttype: [String, Object] as PropType<\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst type = computed(() => {\n\t\t\treturn (\n\t\t\t\tprops.imageComponent ||\n\t\t\t\toptions.components?.imageComponent ||\n\t\t\t\tdefaultImageComponent\n\t\t\t);\n\t\t});\n\n\t\tconst { src, srcset, alt, copyright } = usePrismicImage(props);\n\n\t\treturn () => {\n\t\t\tconst attributes = {\n\t\t\t\tsrc: src.value,\n\t\t\t\tsrcset: srcset.value,\n\t\t\t\talt: alt.value,\n\t\t\t};\n\n\t\t\tswitch (type.value) {\n\t\t\t\tcase \"img\":\n\t\t\t\t\t// Fitting img tag interface\n\t\t\t\t\treturn h(\"img\", attributes);\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn h(simplyResolveComponent(type.value), {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcopyright: copyright.value,\n\t\t\t\t\t});\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic image field.\n *\n * @see Component props {@link PrismicImageProps}\n * @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}\n */\nexport const PrismicImage = PrismicImageImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicImageProps;\n\t};\n};\n"],"names":[],"mappings":";;;;;AAgCA,MAAM,wBAAwB;AA0GjB,MAAA,kBAAkB,CAC9B,UAC8B;AACxB,QAAA,EAAE,YAAY;AAEd,QAAA,UAAU,SAAS,MAAK;;AACvB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,QAAI,CAAC,SAAS,MAAM,KAAK,GAAG;AACpB,aAAA;AAAA,QACN,KAAK;AAAA,QACL,QAAQ;AAAA,MAAA;AAAA,IAET;AAEK,UAAA,cAAc,MAAM,MAAM,WAAW;AACrC,UAAA,SAAS,MAAM,MAAM,MAAM;AAC3B,UAAA,iBAAiB,MAAM,MAAM,cAAc;AAEjD,QAAI,QAAQ;AACP,UAAA,CAAC,kBAAkB,gBAAgB;AAC9B,gBAAA,KACP,6MACA,KAAK;AAAA,MAEN;AAED,aAAO,mBAAmB,OAAO;AAAA,QAChC,GAAG;AAAA,QACH,QACC,WAAW,cACR,aAAQ,eAAR,mBAAoB,2BACpB;AAAA,MAAA,CACJ;AAAA,eACS,gBAAgB;AAC1B,aAAO,0BAA0B,OAAO;AAAA,QACvC,GAAG;AAAA,QACH,gBACC,mBAAmB,cAChB,aAAQ,eAAR,mBAAoB,kCACpB;AAAA,MAAA,CACJ;AAAA,IAAA,OACK;AACC,aAAA;AAAA,QACN,KAAK,WAAW,OAAO,WAAW;AAAA,QAClC,QAAQ;AAAA,MAAA;AAAA,IAET;AAAA,EAAA,CACD;AAEK,QAAA,MAAM,SAAS,MAAK;AACzB,WAAO,QAAQ,MAAM;AAAA,EAAA,C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A;AAGV,cAAQ,KAAK,OAAO;AAAA,QACnB,KAAK;AAEG,iBAAA,EAAE,OAAO,UAAU;AAAA,QAE3B;AACC,iBAAO,EAAE,uBAAuB,KAAK,KAAK,GAAG;AAAA,YAC5C,GAAG;AAAA,YACH,WAAW,UAAU;AAAA,UAAA,CACrB;AAAA,MACF;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,eAAe;"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
3
  const helpers = require("@prismicio/helpers");
4
+ const vue = require("vue");
5
+ const getSlots = require("../lib/getSlots.cjs");
5
6
  const isInternalURL = require("../lib/isInternalURL.cjs");
6
- const usePrismic = require("../usePrismic.cjs");
7
7
  const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
8
- const getSlots = require("../lib/getSlots.cjs");
8
+ const usePrismic = require("../usePrismic.cjs");
9
9
  const defaultInternalComponent = "router-link";
10
10
  const defaultExternalComponent = "a";
11
11
  const defaultBlankTargetRelAttribute = "noopener noreferrer";
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tdefineComponent,\n\th,\n\tPropType,\n\tVNodeProps,\n\tunref,\n\treactive,\n\tConcreteComponent,\n\tcomputed,\n\tComputedRef,\n\tRaw,\n\tDefineComponent,\n} from \"vue\";\n\nimport { asLink, LinkResolverFunction } from \"@prismicio/helpers\";\nimport { LinkField, PrismicDocument } from \"@prismicio/types\";\n\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { usePrismic } from \"../usePrismic\";\nimport { VueUseOptions } from \"../types\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { getSlots } from \"../lib/getSlots\";\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\";\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\";\n\n/**\n * The default rel attribute rendered for blank target URLs.\n */\nconst defaultBlankTargetRelAttribute = \"noopener noreferrer\";\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * The Prismic link field or document to render.\n\t */\n\tfield: LinkField | PrismicDocument;\n\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An explicit `target` attribute to apply to the rendered link.\n\t */\n\ttarget?: string | null;\n\n\t/**\n\t * An explicit `rel` attribute to apply to the rendered link.\n\t */\n\trel?: string | null;\n\n\t/**\n\t * Value of the `rel` attribute to use on links rendered with\n\t * `target=\"_blank\"`.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise.\n\t */\n\tblankTargetRelAttribute?: string | null;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * Options for {@link usePrismicLink}.\n */\nexport type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>;\n\n/**\n * Return type of {@link usePrismicLink}.\n */\nexport type UsePrismicLinkReturnType = {\n\t/**\n\t * Suggested component to render for provided link field.\n\t */\n\ttype: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>;\n\n\t/**\n\t * Resolved anchor `href` value.\n\t */\n\thref: ComputedRef<string>;\n\n\t/**\n\t * Resolved anchor `target` value.\n\t */\n\ttarget: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved anchor `rel` value.\n\t */\n\trel: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns resolved information about a Prismic link\n * field.\n *\n * @param props - {@link UsePrismicLinkOptions}\n *\n * @returns - Resolved link information {@link UsePrismicLinkReturnType}\n */\nexport const usePrismicLink = (\n\tprops: UsePrismicLinkOptions,\n): UsePrismicLinkReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst type = computed(() => {\n\t\tconst internalComponent =\n\t\t\tunref(props.internalComponent) ||\n\t\t\toptions.components?.linkInternalComponent ||\n\t\t\tdefaultInternalComponent;\n\n\t\tconst externalComponent =\n\t\t\tunref(props.externalComponent) ||\n\t\t\toptions.components?.linkExternalComponent ||\n\t\t\tdefaultExternalComponent;\n\n\t\treturn href.value && isInternalURL(href.value) && !target.value\n\t\t\t? internalComponent\n\t\t\t: externalComponent;\n\t});\n\tconst href = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\n\t\treturn asLink(field, linkResolver) ?? \"\";\n\t});\n\tconst target = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst target = unref(props.target);\n\n\t\tif (typeof target !== \"undefined\") {\n\t\t\treturn target;\n\t\t} else {\n\t\t\treturn field && \"target\" in field && field.target ? field.target : null;\n\t\t}\n\t});\n\tconst rel = computed(() => {\n\t\tconst rel = unref(props.rel);\n\n\t\tif (typeof rel !== \"undefined\") {\n\t\t\treturn rel;\n\t\t} else if (target.value === \"_blank\") {\n\t\t\tconst blankTargetRelAttribute = unref(props.blankTargetRelAttribute);\n\n\t\t\tif (typeof blankTargetRelAttribute !== \"undefined\") {\n\t\t\t\treturn blankTargetRelAttribute;\n\t\t\t} else {\n\t\t\t\treturn typeof options.components?.linkBlankTargetRelAttribute !==\n\t\t\t\t\t\"undefined\"\n\t\t\t\t\t? options.components.linkBlankTargetRelAttribute\n\t\t\t\t\t: defaultBlankTargetRelAttribute;\n\t\t\t}\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t};\n};\n\n/**\n * `<PrismicLink />` implementation.\n *\n * @internal\n */\nexport const PrismicLinkImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicLink\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<LinkField | PrismicDocument>,\n\t\t\trequired: true,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\trel: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tblankTargetRelAttribute: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tinternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\texternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { type, href, target, rel } = usePrismicLink(props);\n\n\t\treturn () => {\n\t\t\tconst parent =\n\t\t\t\ttype.value === \"a\" ? \"a\" : simplyResolveComponent(type.value);\n\t\t\tconst computedSlots = getSlots(\n\t\t\t\tparent,\n\t\t\t\tslots,\n\t\t\t\treactive({ href: href.value }),\n\t\t\t);\n\n\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t// Fitting anchor tag interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ href: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Fitting Vue Router Link interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ to: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic link field.\n *\n * @see Component props {@link PrismicLinkProps}\n * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}\n */\nexport const PrismicLink = PrismicLinkImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicLinkProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isInternalURL","asLink","target","rel","defineComponent","simplyResolveComponent","getSlots","reactive","h"],"mappings":";;;;;;;;AA4BA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA0G1B,MAAA,iBAAiB,CAC7B,U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AA,OAER;AAEN,eAAOA,IACN,EAAA,QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACjD,aAAa;AAAA,MAEd;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
1
+ {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import { LinkResolverFunction, asLink } from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\treactive,\n\tunref,\n} from \"vue\";\n\nimport { getSlots } from \"../lib/getSlots\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { LinkField, PrismicDocument } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\";\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\";\n\n/**\n * The default rel attribute rendered for blank target URLs.\n */\nconst defaultBlankTargetRelAttribute = \"noopener noreferrer\";\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * The Prismic link field or document to render.\n\t */\n\tfield: LinkField | PrismicDocument;\n\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An explicit `target` attribute to apply to the rendered link.\n\t */\n\ttarget?: string | null;\n\n\t/**\n\t * An explicit `rel` attribute to apply to the rendered link.\n\t */\n\trel?: string | null;\n\n\t/**\n\t * Value of the `rel` attribute to use on links rendered with\n\t * `target=\"_blank\"`.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise.\n\t */\n\tblankTargetRelAttribute?: string | null;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * Options for {@link usePrismicLink}.\n */\nexport type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>;\n\n/**\n * Return type of {@link usePrismicLink}.\n */\nexport type UsePrismicLinkReturnType = {\n\t/**\n\t * Suggested component to render for provided link field.\n\t */\n\ttype: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>;\n\n\t/**\n\t * Resolved anchor `href` value.\n\t */\n\thref: ComputedRef<string>;\n\n\t/**\n\t * Resolved anchor `target` value.\n\t */\n\ttarget: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved anchor `rel` value.\n\t */\n\trel: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns resolved information about a Prismic link\n * field.\n *\n * @param props - {@link UsePrismicLinkOptions}\n *\n * @returns - Resolved link information {@link UsePrismicLinkReturnType}\n */\nexport const usePrismicLink = (\n\tprops: UsePrismicLinkOptions,\n): UsePrismicLinkReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst type = computed(() => {\n\t\tconst internalComponent =\n\t\t\tunref(props.internalComponent) ||\n\t\t\toptions.components?.linkInternalComponent ||\n\t\t\tdefaultInternalComponent;\n\n\t\tconst externalComponent =\n\t\t\tunref(props.externalComponent) ||\n\t\t\toptions.components?.linkExternalComponent ||\n\t\t\tdefaultExternalComponent;\n\n\t\treturn href.value && isInternalURL(href.value) && !target.value\n\t\t\t? internalComponent\n\t\t\t: externalComponent;\n\t});\n\tconst href = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\n\t\treturn asLink(field, linkResolver) ?? \"\";\n\t});\n\tconst target = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst target = unref(props.target);\n\n\t\tif (typeof target !== \"undefined\") {\n\t\t\treturn target;\n\t\t} else {\n\t\t\treturn field && \"target\" in field && field.target ? field.target : null;\n\t\t}\n\t});\n\tconst rel = computed(() => {\n\t\tconst rel = unref(props.rel);\n\n\t\tif (typeof rel !== \"undefined\") {\n\t\t\treturn rel;\n\t\t} else if (target.value === \"_blank\") {\n\t\t\tconst blankTargetRelAttribute = unref(props.blankTargetRelAttribute);\n\n\t\t\tif (typeof blankTargetRelAttribute !== \"undefined\") {\n\t\t\t\treturn blankTargetRelAttribute;\n\t\t\t} else {\n\t\t\t\treturn typeof options.components?.linkBlankTargetRelAttribute !==\n\t\t\t\t\t\"undefined\"\n\t\t\t\t\t? options.components.linkBlankTargetRelAttribute\n\t\t\t\t\t: defaultBlankTargetRelAttribute;\n\t\t\t}\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t};\n};\n\n/**\n * `<PrismicLink />` implementation.\n *\n * @internal\n */\nexport const PrismicLinkImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicLink\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<LinkField | PrismicDocument>,\n\t\t\trequired: true,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\trel: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tblankTargetRelAttribute: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tinternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\texternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { type, href, target, rel } = usePrismicLink(props);\n\n\t\treturn () => {\n\t\t\tconst parent =\n\t\t\t\ttype.value === \"a\" ? \"a\" : simplyResolveComponent(type.value);\n\t\t\tconst computedSlots = getSlots(\n\t\t\t\tparent,\n\t\t\t\tslots,\n\t\t\t\treactive({ href: href.value }),\n\t\t\t);\n\n\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t// Fitting anchor tag interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ href: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Fitting Vue Router Link interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ to: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic link field.\n *\n * @see Component props {@link PrismicLinkProps}\n * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}\n */\nexport const PrismicLink = PrismicLinkImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicLinkProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isInternalURL","asLink","target","rel","defineComponent","simplyResolveComponent","getSlots","reactive","h"],"mappings":";;;;;;;;AA6BA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA0G1B,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,EAAE,YAAYA,WAAAA;AAEd,QAAA,OAAOC,IAAAA,SAAS,MAAK;;AAC1B,UAAM,oBACLC,IAAM,MAAA,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAED,UAAM,oBACLA,IAAM,MAAA,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAEM,WAAA,KAAK,SAASC,cAAc,cAAA,KAAK,KAAK,KAAK,CAAC,OAAO,QACvD,oBACA;AAAA,EAAA,CACH;AACK,QAAA,OAAOF,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAC/B,UAAM,eAAeA,IAAAA,MAAM,MAAM,YAAY,KAAK,QAAQ;AAEnD,WAAAE,eAAO,OAAO,YAAY,KAAK;AAAA,EAA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V;AAAA,IACD,mBAAmB;AAAA,MAClB,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,mBAAmB;AAAA,MAClB,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAO,EAAE,SAAO;AAEjB,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,UAAM,EAAE,MAAM,MAAM,QAAQ,QAAQ,eAAe,KAAK;AAExD,WAAO,MAAK;AACX,YAAM,SACL,KAAK,UAAU,MAAM,MAAMC,uBAAA,uBAAuB,KAAK,KAAK;AACvD,YAAA,gBAAgBC,SAAAA,SACrB,QACA,OACAC,IAAAA,SAAS,EAAE,MAAM,KAAK,MAAO,CAAA,CAAC;AAG3B,UAAA,OAAO,WAAW,UAAU;AAE/B,eAAOC,IACN,EAAA,QACA,EAAE,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACnD,aAAa;AAAA,MAAA,OAER;AAEN,eAAOA,IACN,EAAA,QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACjD,aAAa;AAAA,MAEd;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
@@ -1,7 +1,7 @@
1
- import { AllowedComponentProps, ComponentCustomProps, PropType, VNodeProps, ConcreteComponent, ComputedRef, Raw, DefineComponent } from "vue";
2
1
  import { LinkResolverFunction } from "@prismicio/helpers";
3
- import { LinkField, PrismicDocument } from "@prismicio/types";
2
+ import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
4
3
  import { VueUseOptions } from "../types";
4
+ import { LinkField, PrismicDocument } from "@prismicio/types";
5
5
  /**
6
6
  * Props for `<PrismicLink />`.
7
7
  */
@@ -102,7 +102,7 @@ export declare const usePrismicLink: (props: UsePrismicLinkOptions) => UsePrismi
102
102
  */
103
103
  export declare const PrismicLinkImpl: DefineComponent<{
104
104
  field: {
105
- type: PropType<LinkField | PrismicDocument<Record<string, any>, string, string>>;
105
+ type: PropType<PrismicDocument<Record<string, any>, string, string> | LinkField>;
106
106
  required: true;
107
107
  };
108
108
  linkResolver: {
@@ -139,7 +139,7 @@ export declare const PrismicLinkImpl: DefineComponent<{
139
139
  [key: string]: any;
140
140
  }>), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
141
141
  field: {
142
- type: PropType<LinkField | PrismicDocument<Record<string, any>, string, string>>;
142
+ type: PropType<PrismicDocument<Record<string, any>, string, string> | LinkField>;
143
143
  required: true;
144
144
  };
145
145
  linkResolver: {
@@ -179,7 +179,7 @@ export declare const PrismicLinkImpl: DefineComponent<{
179
179
  blankTargetRelAttribute: string | null;
180
180
  internalComponent: string | ConcreteComponent | Raw<DefineComponent>;
181
181
  externalComponent: string | ConcreteComponent | Raw<DefineComponent>;
182
- }>;
182
+ }, {}>;
183
183
  /**
184
184
  * Component to render a Prismic link field.
185
185
  *
@@ -1,9 +1,9 @@
1
- import { computed, unref, defineComponent, reactive, h } from "vue";
2
1
  import { asLink } from "@prismicio/helpers";
2
+ import { computed, unref, defineComponent, reactive, h } from "vue";
3
+ import { getSlots } from "../lib/getSlots.js";
3
4
  import { isInternalURL } from "../lib/isInternalURL.js";
4
- import { usePrismic } from "../usePrismic.js";
5
5
  import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
6
- import { getSlots } from "../lib/getSlots.js";
6
+ import { usePrismic } from "../usePrismic.js";
7
7
  const defaultInternalComponent = "router-link";
8
8
  const defaultExternalComponent = "a";
9
9
  const defaultBlankTargetRelAttribute = "noopener noreferrer";
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.js","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tdefineComponent,\n\th,\n\tPropType,\n\tVNodeProps,\n\tunref,\n\treactive,\n\tConcreteComponent,\n\tcomputed,\n\tComputedRef,\n\tRaw,\n\tDefineComponent,\n} from \"vue\";\n\nimport { asLink, LinkResolverFunction } from \"@prismicio/helpers\";\nimport { LinkField, PrismicDocument } from \"@prismicio/types\";\n\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { usePrismic } from \"../usePrismic\";\nimport { VueUseOptions } from \"../types\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { getSlots } from \"../lib/getSlots\";\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\";\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\";\n\n/**\n * The default rel attribute rendered for blank target URLs.\n */\nconst defaultBlankTargetRelAttribute = \"noopener noreferrer\";\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * The Prismic link field or document to render.\n\t */\n\tfield: LinkField | PrismicDocument;\n\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An explicit `target` attribute to apply to the rendered link.\n\t */\n\ttarget?: string | null;\n\n\t/**\n\t * An explicit `rel` attribute to apply to the rendered link.\n\t */\n\trel?: string | null;\n\n\t/**\n\t * Value of the `rel` attribute to use on links rendered with\n\t * `target=\"_blank\"`.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise.\n\t */\n\tblankTargetRelAttribute?: string | null;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * Options for {@link usePrismicLink}.\n */\nexport type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>;\n\n/**\n * Return type of {@link usePrismicLink}.\n */\nexport type UsePrismicLinkReturnType = {\n\t/**\n\t * Suggested component to render for provided link field.\n\t */\n\ttype: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>;\n\n\t/**\n\t * Resolved anchor `href` value.\n\t */\n\thref: ComputedRef<string>;\n\n\t/**\n\t * Resolved anchor `target` value.\n\t */\n\ttarget: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved anchor `rel` value.\n\t */\n\trel: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns resolved information about a Prismic link\n * field.\n *\n * @param props - {@link UsePrismicLinkOptions}\n *\n * @returns - Resolved link information {@link UsePrismicLinkReturnType}\n */\nexport const usePrismicLink = (\n\tprops: UsePrismicLinkOptions,\n): UsePrismicLinkReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst type = computed(() => {\n\t\tconst internalComponent =\n\t\t\tunref(props.internalComponent) ||\n\t\t\toptions.components?.linkInternalComponent ||\n\t\t\tdefaultInternalComponent;\n\n\t\tconst externalComponent =\n\t\t\tunref(props.externalComponent) ||\n\t\t\toptions.components?.linkExternalComponent ||\n\t\t\tdefaultExternalComponent;\n\n\t\treturn href.value && isInternalURL(href.value) && !target.value\n\t\t\t? internalComponent\n\t\t\t: externalComponent;\n\t});\n\tconst href = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\n\t\treturn asLink(field, linkResolver) ?? \"\";\n\t});\n\tconst target = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst target = unref(props.target);\n\n\t\tif (typeof target !== \"undefined\") {\n\t\t\treturn target;\n\t\t} else {\n\t\t\treturn field && \"target\" in field && field.target ? field.target : null;\n\t\t}\n\t});\n\tconst rel = computed(() => {\n\t\tconst rel = unref(props.rel);\n\n\t\tif (typeof rel !== \"undefined\") {\n\t\t\treturn rel;\n\t\t} else if (target.value === \"_blank\") {\n\t\t\tconst blankTargetRelAttribute = unref(props.blankTargetRelAttribute);\n\n\t\t\tif (typeof blankTargetRelAttribute !== \"undefined\") {\n\t\t\t\treturn blankTargetRelAttribute;\n\t\t\t} else {\n\t\t\t\treturn typeof options.components?.linkBlankTargetRelAttribute !==\n\t\t\t\t\t\"undefined\"\n\t\t\t\t\t? options.components.linkBlankTargetRelAttribute\n\t\t\t\t\t: defaultBlankTargetRelAttribute;\n\t\t\t}\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t};\n};\n\n/**\n * `<PrismicLink />` implementation.\n *\n * @internal\n */\nexport const PrismicLinkImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicLink\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<LinkField | PrismicDocument>,\n\t\t\trequired: true,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\trel: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tblankTargetRelAttribute: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tinternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\texternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { type, href, target, rel } = usePrismicLink(props);\n\n\t\treturn () => {\n\t\t\tconst parent =\n\t\t\t\ttype.value === \"a\" ? \"a\" : simplyResolveComponent(type.value);\n\t\t\tconst computedSlots = getSlots(\n\t\t\t\tparent,\n\t\t\t\tslots,\n\t\t\t\treactive({ href: href.value }),\n\t\t\t);\n\n\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t// Fitting anchor tag interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ href: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Fitting Vue Router Link interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ to: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic link field.\n *\n * @see Component props {@link PrismicLinkProps}\n * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}\n */\nexport const PrismicLink = PrismicLinkImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicLinkProps;\n\t};\n};\n"],"names":["target","rel"],"mappings":";;;;;;AA4BA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA0G1B,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,EAAE,YAAY;AAEd,QAAA,OAAO,SAAS,MAAK;;AAC1B,UAAM,oBACL,MAAM,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAED,UAAM,oBACL,MAAM,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAEM,WAAA,KAAK,SAAS,cAAc,KAAK,KAAK,KAAK,CAAC,OAAO,QACvD,oBACA;AAAA,EAAA,CACH;AACK,QAAA,OAAO,SAAS,MAAK;AACpB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAC/B,UAAM,eAAe,MAAM,MAAM,YAAY,KAAK,QAAQ;AAEnD,WAAA,OAAO,OAAO,YAAY,KAAK;AAAA,EAAA,CACtC;AACK,QAAA,SAAS,SAAS,MAAK;AACtB,UAAA,QAAQ,MAAM,MAAM,KAAK;AACzBA,UAAAA,UAAS,MAAM,MAAM,MAAM;AAE7B,QAAA,OAAOA,YAAW,aAAa;AAC3BA,aAAAA;AAAAA,IAAA,OACD;AACN,aAAO,SAAS,YAAY,SAAS,MAAM,SAAS,MAAM,SAAS;AAAA,IACnE;AAAA,EAAA,CACD;AACK,QAAA,MAAM,SAAS,MAAK;;AACnBC,UAAAA,OAAM,MA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,eAAe,KAAK;AAExD,WAAO,MAAK;AACX,YAAM,SACL,KAAK,UAAU,MAAM,MAAM,uBAAuB,KAAK,KAAK;AACvD,YAAA,gBAAgB,SACrB,QACA,OACA,SAAS,EAAE,MAAM,KAAK,MAAO,CAAA,CAAC;AAG3B,UAAA,OAAO,WAAW,UAAU;AAE/B,eAAO,EACN,QACA,EAAE,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACnD,aAAa;AAAA,MAAA,OAER;AAEN,eAAO,EACN,QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACjD,aAAa;AAAA,MAEd;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;"}
1
+ {"version":3,"file":"PrismicLink.js","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import { LinkResolverFunction, asLink } from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\treactive,\n\tunref,\n} from \"vue\";\n\nimport { getSlots } from \"../lib/getSlots\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { LinkField, PrismicDocument } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\";\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\";\n\n/**\n * The default rel attribute rendered for blank target URLs.\n */\nconst defaultBlankTargetRelAttribute = \"noopener noreferrer\";\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * The Prismic link field or document to render.\n\t */\n\tfield: LinkField | PrismicDocument;\n\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An explicit `target` attribute to apply to the rendered link.\n\t */\n\ttarget?: string | null;\n\n\t/**\n\t * An explicit `rel` attribute to apply to the rendered link.\n\t */\n\trel?: string | null;\n\n\t/**\n\t * Value of the `rel` attribute to use on links rendered with\n\t * `target=\"_blank\"`.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise.\n\t */\n\tblankTargetRelAttribute?: string | null;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to render\n\t * external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * Options for {@link usePrismicLink}.\n */\nexport type UsePrismicLinkOptions = VueUseOptions<PrismicLinkProps>;\n\n/**\n * Return type of {@link usePrismicLink}.\n */\nexport type UsePrismicLinkReturnType = {\n\t/**\n\t * Suggested component to render for provided link field.\n\t */\n\ttype: ComputedRef<string | ConcreteComponent | Raw<DefineComponent>>;\n\n\t/**\n\t * Resolved anchor `href` value.\n\t */\n\thref: ComputedRef<string>;\n\n\t/**\n\t * Resolved anchor `target` value.\n\t */\n\ttarget: ComputedRef<string | null>;\n\n\t/**\n\t * Resolved anchor `rel` value.\n\t */\n\trel: ComputedRef<string | null>;\n};\n\n/**\n * A low level composable that returns resolved information about a Prismic link\n * field.\n *\n * @param props - {@link UsePrismicLinkOptions}\n *\n * @returns - Resolved link information {@link UsePrismicLinkReturnType}\n */\nexport const usePrismicLink = (\n\tprops: UsePrismicLinkOptions,\n): UsePrismicLinkReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst type = computed(() => {\n\t\tconst internalComponent =\n\t\t\tunref(props.internalComponent) ||\n\t\t\toptions.components?.linkInternalComponent ||\n\t\t\tdefaultInternalComponent;\n\n\t\tconst externalComponent =\n\t\t\tunref(props.externalComponent) ||\n\t\t\toptions.components?.linkExternalComponent ||\n\t\t\tdefaultExternalComponent;\n\n\t\treturn href.value && isInternalURL(href.value) && !target.value\n\t\t\t? internalComponent\n\t\t\t: externalComponent;\n\t});\n\tconst href = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\n\t\treturn asLink(field, linkResolver) ?? \"\";\n\t});\n\tconst target = computed(() => {\n\t\tconst field = unref(props.field);\n\t\tconst target = unref(props.target);\n\n\t\tif (typeof target !== \"undefined\") {\n\t\t\treturn target;\n\t\t} else {\n\t\t\treturn field && \"target\" in field && field.target ? field.target : null;\n\t\t}\n\t});\n\tconst rel = computed(() => {\n\t\tconst rel = unref(props.rel);\n\n\t\tif (typeof rel !== \"undefined\") {\n\t\t\treturn rel;\n\t\t} else if (target.value === \"_blank\") {\n\t\t\tconst blankTargetRelAttribute = unref(props.blankTargetRelAttribute);\n\n\t\t\tif (typeof blankTargetRelAttribute !== \"undefined\") {\n\t\t\t\treturn blankTargetRelAttribute;\n\t\t\t} else {\n\t\t\t\treturn typeof options.components?.linkBlankTargetRelAttribute !==\n\t\t\t\t\t\"undefined\"\n\t\t\t\t\t? options.components.linkBlankTargetRelAttribute\n\t\t\t\t\t: defaultBlankTargetRelAttribute;\n\t\t\t}\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t};\n};\n\n/**\n * `<PrismicLink />` implementation.\n *\n * @internal\n */\nexport const PrismicLinkImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicLink\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Object as PropType<LinkField | PrismicDocument>,\n\t\t\trequired: true,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\trel: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tblankTargetRelAttribute: {\n\t\t\ttype: String as PropType<string | null>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tinternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\texternalComponent: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.field) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { type, href, target, rel } = usePrismicLink(props);\n\n\t\treturn () => {\n\t\t\tconst parent =\n\t\t\t\ttype.value === \"a\" ? \"a\" : simplyResolveComponent(type.value);\n\t\t\tconst computedSlots = getSlots(\n\t\t\t\tparent,\n\t\t\t\tslots,\n\t\t\t\treactive({ href: href.value }),\n\t\t\t);\n\n\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t// Fitting anchor tag interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ href: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Fitting Vue Router Link interface\n\t\t\t\treturn h(\n\t\t\t\t\tparent,\n\t\t\t\t\t{ to: href.value, target: target.value, rel: rel.value },\n\t\t\t\t\tcomputedSlots,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic link field.\n *\n * @see Component props {@link PrismicLinkProps}\n * @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}\n */\nexport const PrismicLink = PrismicLinkImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicLinkProps;\n\t};\n};\n"],"names":["target","rel"],"mappings":";;;;;;AA6BA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA0G1B,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,EAAE,YAAY;AAEd,QAAA,OAAO,SAAS,MAAK;;AAC1B,UAAM,oBACL,MAAM,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAED,UAAM,oBACL,MAAM,MAAM,iBAAiB,OAC7B,aAAQ,eAAR,mBAAoB,0BACpB;AAEM,WAAA,KAAK,SAAS,cAAc,KAAK,KAAK,KAAK,CAAC,OAAO,QACvD,oBACA;AAAA,EAAA,CACH;AAC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MACT,UAAU;AAAA,IACV;AAAA,IACD,yBAAyB;AAAA,MACxB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,mBAAmB;AAAA,MAClB,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,mBAAmB;AAAA,MAClB,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAO,EAAE,SAAO;AAEjB,QAAA,CAAC,MAAM,OAAO;AACjB,aAAO,MAAM;AAAA,IACb;AAED,UAAM,EAAE,MAAM,MAAM,QAAQ,QAAQ,eAAe,KAAK;AAExD,WAAO,MAAK;AACX,YAAM,SACL,KAAK,UAAU,MAAM,MAAM,uBAAuB,KAAK,KAAK;AACvD,YAAA,gBAAgB,SACrB,QACA,OACA,SAAS,EAAE,MAAM,KAAK,MAAO,CAAA,CAAC;AAG3B,UAAA,OAAO,WAAW,UAAU;AAE/B,eAAO,EACN,QACA,EAAE,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACnD,aAAa;AAAA,MAAA,OAER;AAEN,eAAO,EACN,QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACjD,aAAa;AAAA,MAEd;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const helpers = require("@prismicio/helpers");
3
4
  const vue = require("vue");
4
5
  const vueRouter = require("vue-router");
5
- const helpers = require("@prismicio/helpers");
6
- const usePrismic = require("../usePrismic.cjs");
7
- const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
8
6
  const isInternalURL = require("../lib/isInternalURL.cjs");
7
+ const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
8
+ const usePrismic = require("../usePrismic.cjs");
9
9
  const defaultWrapper = "div";
10
10
  const usePrismicRichText = (props) => {
11
11
  const { options } = usePrismic.usePrismic();
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tcomputed,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\th,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tPropType,\n\tRaw,\n\tref,\n\tunref,\n\tVNodeProps,\n\twatch,\n} from \"vue\";\nimport { routerKey } from \"vue-router\";\n\nimport {\n\tasHTML,\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tisFilled,\n\tLinkResolverFunction,\n} from \"@prismicio/helpers\";\nimport { RichTextField } from \"@prismicio/types\";\n\nimport { VueUseOptions } from \"../types\";\nimport { usePrismic } from \"../usePrismic\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\tserializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `serializer` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\thtmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The HTML value to be rendered when the field is empty. If a fallback is not\n\t * given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextOptions = VueUseOptions<\n\tOmit<PrismicRichTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextReturnType = {\n\t/**\n\t * Serialized rich text field as HTML.\n\t */\n\thtml: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as HTML.\n *\n * @param props - {@link UsePrismicRichTextOptions}\n *\n * @returns - Serialized rich text field as HTML\n * {@link UsePrismicRichTextReturnType}\n */\nexport const usePrismicRichText = (\n\tprops: UsePrismicRichTextOptions,\n): UsePrismicRichTextReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst html = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\t\tconst serializer =\n\t\t\tunref(props.serializer) ??\n\t\t\tunref(props.htmlSerializer) ??\n\t\t\toptions.richTextSerializer ??\n\t\t\toptions.htmlSerializer;\n\n\t\treturn asHTML(unref(field), linkResolver, serializer);\n\t});\n\n\treturn {\n\t\thtml,\n\t};\n};\n\n/**\n * `<PrismicRichText />` implementation.\n *\n * @internal\n */\nexport const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicRichText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tserializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\thtmlSerializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { html } = usePrismicRichText(props);\n\n\t\tconst root = ref<HTMLElement | Comment | Component | null>(null);\n\n\t\tconst maybeRouter = inject(routerKey, null);\n\t\tif (maybeRouter) {\n\t\t\ttype InternalLink = {\n\t\t\t\telement: HTMLAnchorElement;\n\t\t\t\tlistener: EventListener;\n\t\t\t};\n\t\t\tlet links: InternalLink[] = [];\n\n\t\t\tconst navigate: EventListener = function (\n\t\t\t\tthis: { href: string },\n\t\t\t\tevent: Event,\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tmaybeRouter.push(this.href);\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tconst node: HTMLElement | Comment | null =\n\t\t\t\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value;\n\t\t\t\tif (node && \"querySelectorAll\" in node) {\n\t\t\t\t\t// Get all internal link tags and add listeners on them\n\t\t\t\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t\t\t\t.map((element) => {\n\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\");\n\n\t\t\t\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\t\t\t\tconst listener = navigate.bind({ href });\n\t\t\t\t\t\t\t\telement.addEventListener(\"click\", listener);\n\n\t\t\t\t\t\t\t\treturn { element, listener };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((link): link is InternalLink => link as boolean);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tlinks.forEach(({ element, listener }) =>\n\t\t\t\t\telement.removeEventListener(\"click\", listener),\n\t\t\t\t);\n\t\t\t\tlinks = [];\n\t\t\t};\n\n\t\t\twatch(\n\t\t\t\thtml,\n\t\t\t\t() => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tnextTick(addListeners);\n\t\t\t\t},\n\t\t\t\t{ immediate: true },\n\t\t\t);\n\n\t\t\tonBeforeUnmount(() => {\n\t\t\t\tremoveListeners();\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\tinnerHTML: html.value,\n\t\t\t\tref: root,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as HTML.\n *\n * @see Component props {@link PrismicRichTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicRichText = PrismicRichTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicRichTextProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isFilled","asHTML","defineComponent","ref","inject","routerKey","isInternalURL","watch","nextTick","onBeforeUnmount","h","simplyResolveComponent"],"mappings":";;;;;;;;AAuCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,YAAYA,WAAAA;AAEd,QAAA,OAAOC,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,SAAS,KAAK,GAAG;AACvB,aAAAD,UAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,UAAM,eAAeA,IAAAA,MAAM,MAAM,YAAY,KAAK,QAAQ;AACpD,UAAA,aACLA,IAAM,MAAA,MAAM,UAAU,KACtBA,IAAM,MAAA,MAAM,cAAc,KAC1B,QAAQ,sBACR,QAAQ;AAET,WAAOE,QAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAG,cAAc,UAAU;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,sBAAoDG,oBAAAA,gBAAA;AAAA,EAChE,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACX,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAA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E,WAAW,KAAA,CAAM;AAGpBC,UAAAA,gBAAgB,MAAK;;OAEpB;AAAA,IACD;AAED,WAAO,MAAK;AACX,aAAOC,IAAE,EAAAC,uBAAA,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,WAAW,KAAK;AAAA,QAChB,KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,kBAAkB;;;;"}
1
+ {"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tasHTML,\n\tisFilled,\n} from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tref,\n\tunref,\n\twatch,\n} from \"vue\";\nimport { routerKey } from \"vue-router\";\n\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { RichTextField } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\tserializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `serializer` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\thtmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The HTML value to be rendered when the field is empty. If a fallback is not\n\t * given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextOptions = VueUseOptions<\n\tOmit<PrismicRichTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextReturnType = {\n\t/**\n\t * Serialized rich text field as HTML.\n\t */\n\thtml: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as HTML.\n *\n * @param props - {@link UsePrismicRichTextOptions}\n *\n * @returns - Serialized rich text field as HTML\n * {@link UsePrismicRichTextReturnType}\n */\nexport const usePrismicRichText = (\n\tprops: UsePrismicRichTextOptions,\n): UsePrismicRichTextReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst html = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\t\tconst serializer =\n\t\t\tunref(props.serializer) ??\n\t\t\tunref(props.htmlSerializer) ??\n\t\t\toptions.richTextSerializer ??\n\t\t\toptions.htmlSerializer;\n\n\t\treturn asHTML(unref(field), linkResolver, serializer);\n\t});\n\n\treturn {\n\t\thtml,\n\t};\n};\n\n/**\n * `<PrismicRichText />` implementation.\n *\n * @internal\n */\nexport const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicRichText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tserializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\thtmlSerializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { html } = usePrismicRichText(props);\n\n\t\tconst root = ref<HTMLElement | Comment | Component | null>(null);\n\n\t\tconst maybeRouter = inject(routerKey, null);\n\t\tif (maybeRouter) {\n\t\t\ttype InternalLink = {\n\t\t\t\telement: HTMLAnchorElement;\n\t\t\t\tlistener: EventListener;\n\t\t\t};\n\t\t\tlet links: InternalLink[] = [];\n\n\t\t\tconst navigate: EventListener = function (\n\t\t\t\tthis: { href: string },\n\t\t\t\tevent: Event,\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tmaybeRouter.push(this.href);\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tconst node: HTMLElement | Comment | null =\n\t\t\t\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value;\n\t\t\t\tif (node && \"querySelectorAll\" in node) {\n\t\t\t\t\t// Get all internal link tags and add listeners on them\n\t\t\t\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t\t\t\t.map((element) => {\n\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\");\n\n\t\t\t\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\t\t\t\tconst listener = navigate.bind({ href });\n\t\t\t\t\t\t\t\telement.addEventListener(\"click\", listener);\n\n\t\t\t\t\t\t\t\treturn { element, listener };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((link): link is InternalLink => link as boolean);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tlinks.forEach(({ element, listener }) =>\n\t\t\t\t\telement.removeEventListener(\"click\", listener),\n\t\t\t\t);\n\t\t\t\tlinks = [];\n\t\t\t};\n\n\t\t\twatch(\n\t\t\t\thtml,\n\t\t\t\t() => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tnextTick(addListeners);\n\t\t\t\t},\n\t\t\t\t{ immediate: true },\n\t\t\t);\n\n\t\t\tonBeforeUnmount(() => {\n\t\t\t\tremoveListeners();\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\tinnerHTML: html.value,\n\t\t\t\tref: root,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as HTML.\n *\n * @see Component props {@link PrismicRichTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicRichText = PrismicRichTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicRichTextProps;\n\t};\n};\n"],"names":["usePrismic","computed","unref","isFilled","asHTML","defineComponent","ref","inject","routerKey","isInternalURL","watch","nextTick","onBeforeUnmount","h","simplyResolveComponent"],"mappings":";;;;;;;;AAwCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,YAAYA,WAAAA;AAEd,QAAA,OAAOC,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,SAAS,KAAK,GAAG;AACvB,aAAAD,UAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,UAAM,eAAeA,IAAAA,MAAM,MAAM,YAAY,KAAK,QAAQ;AACpD,UAAA,aACLA,IAAM,MAAA,MAAM,UAAU,KACtBA,IAAM,MAAA,MAAM,cAAc,KAC1B,QAAQ,sBACR,QAAQ;AAET,WAAOE,QAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAG,cAAc,UAAU;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,sBAAoDG,oBAAAA,gBAAA;AAAA,EAChE,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACX,MAAM,CAAC,UAAU,MAA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,SAAS,QAAQ,CAAC;AAE/C,gBAAQ,CAAA;AAAA;AAGTC,UAAA,MACC,MACA,MAAK;;AAEJC,YAAA,SAAS,YAAY;AAAA,MAAA,GAEtB,EAAE,WAAW,KAAA,CAAM;AAGpBC,UAAAA,gBAAgB,MAAK;;OAEpB;AAAA,IACD;AAED,WAAO,MAAK;AACX,aAAOC,IAAE,EAAAC,uBAAA,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,WAAW,KAAK;AAAA,QAChB,KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,kBAAkB;;;;"}
@@ -1,7 +1,7 @@
1
- import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
2
1
  import { HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction } from "@prismicio/helpers";
3
- import { RichTextField } from "@prismicio/types";
2
+ import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
4
3
  import { VueUseOptions } from "../types";
4
+ import { RichTextField } from "@prismicio/types";
5
5
  /**
6
6
  * Props for `<PrismicRichText />`.
7
7
  */
@@ -148,7 +148,7 @@ export declare const PrismicRichTextImpl: DefineComponent<{
148
148
  fallback: string;
149
149
  serializer: HTMLFunctionSerializer | HTMLMapSerializer;
150
150
  htmlSerializer: HTMLFunctionSerializer | HTMLMapSerializer;
151
- }>;
151
+ }, {}>;
152
152
  /**
153
153
  * Component to render a Prismic rich text field as HTML.
154
154
  *
@@ -1,9 +1,9 @@
1
+ import { isFilled, asHTML } from "@prismicio/helpers";
1
2
  import { computed, unref, defineComponent, ref, inject, watch, nextTick, onBeforeUnmount, h } from "vue";
2
3
  import { routerKey } from "vue-router";
3
- import { isFilled, asHTML } from "@prismicio/helpers";
4
- import { usePrismic } from "../usePrismic.js";
5
- import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
6
4
  import { isInternalURL } from "../lib/isInternalURL.js";
5
+ import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
6
+ import { usePrismic } from "../usePrismic.js";
7
7
  const defaultWrapper = "div";
8
8
  const usePrismicRichText = (props) => {
9
9
  const { options } = usePrismic();
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tcomputed,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\th,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tPropType,\n\tRaw,\n\tref,\n\tunref,\n\tVNodeProps,\n\twatch,\n} from \"vue\";\nimport { routerKey } from \"vue-router\";\n\nimport {\n\tasHTML,\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tisFilled,\n\tLinkResolverFunction,\n} from \"@prismicio/helpers\";\nimport { RichTextField } from \"@prismicio/types\";\n\nimport { VueUseOptions } from \"../types\";\nimport { usePrismic } from \"../usePrismic\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\tserializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `serializer` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\thtmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The HTML value to be rendered when the field is empty. If a fallback is not\n\t * given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextOptions = VueUseOptions<\n\tOmit<PrismicRichTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextReturnType = {\n\t/**\n\t * Serialized rich text field as HTML.\n\t */\n\thtml: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as HTML.\n *\n * @param props - {@link UsePrismicRichTextOptions}\n *\n * @returns - Serialized rich text field as HTML\n * {@link UsePrismicRichTextReturnType}\n */\nexport const usePrismicRichText = (\n\tprops: UsePrismicRichTextOptions,\n): UsePrismicRichTextReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst html = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\t\tconst serializer =\n\t\t\tunref(props.serializer) ??\n\t\t\tunref(props.htmlSerializer) ??\n\t\t\toptions.richTextSerializer ??\n\t\t\toptions.htmlSerializer;\n\n\t\treturn asHTML(unref(field), linkResolver, serializer);\n\t});\n\n\treturn {\n\t\thtml,\n\t};\n};\n\n/**\n * `<PrismicRichText />` implementation.\n *\n * @internal\n */\nexport const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicRichText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tserializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\thtmlSerializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { html } = usePrismicRichText(props);\n\n\t\tconst root = ref<HTMLElement | Comment | Component | null>(null);\n\n\t\tconst maybeRouter = inject(routerKey, null);\n\t\tif (maybeRouter) {\n\t\t\ttype InternalLink = {\n\t\t\t\telement: HTMLAnchorElement;\n\t\t\t\tlistener: EventListener;\n\t\t\t};\n\t\t\tlet links: InternalLink[] = [];\n\n\t\t\tconst navigate: EventListener = function (\n\t\t\t\tthis: { href: string },\n\t\t\t\tevent: Event,\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tmaybeRouter.push(this.href);\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tconst node: HTMLElement | Comment | null =\n\t\t\t\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value;\n\t\t\t\tif (node && \"querySelectorAll\" in node) {\n\t\t\t\t\t// Get all internal link tags and add listeners on them\n\t\t\t\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t\t\t\t.map((element) => {\n\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\");\n\n\t\t\t\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\t\t\t\tconst listener = navigate.bind({ href });\n\t\t\t\t\t\t\t\telement.addEventListener(\"click\", listener);\n\n\t\t\t\t\t\t\t\treturn { element, listener };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((link): link is InternalLink => link as boolean);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tlinks.forEach(({ element, listener }) =>\n\t\t\t\t\telement.removeEventListener(\"click\", listener),\n\t\t\t\t);\n\t\t\t\tlinks = [];\n\t\t\t};\n\n\t\t\twatch(\n\t\t\t\thtml,\n\t\t\t\t() => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tnextTick(addListeners);\n\t\t\t\t},\n\t\t\t\t{ immediate: true },\n\t\t\t);\n\n\t\t\tonBeforeUnmount(() => {\n\t\t\t\tremoveListeners();\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\tinnerHTML: html.value,\n\t\t\t\tref: root,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as HTML.\n *\n * @see Component props {@link PrismicRichTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicRichText = PrismicRichTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicRichTextProps;\n\t};\n};\n"],"names":[],"mappings":";;;;;;AAuCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,YAAY;AAEd,QAAA,OAAO,SAAS,MAAK;AACpB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,QAAI,CAAC,SAAS,SAAS,KAAK,GAAG;AACvB,aAAA,MAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,UAAM,eAAe,MAAM,MAAM,YAAY,KAAK,QAAQ;AACpD,UAAA,aACL,MAAM,MAAM,UAAU,KACtB,MAAM,MAAM,cAAc,KAC1B,QAAQ,sBACR,QAAQ;AAET,WAAO,OAAO,MAAM,KAAK,GAAG,cAAc,UAAU;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,sBAAoD,gCAAA;AAAA,EAChE,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACX,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;A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KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,kBAAkB;"}
1
+ {"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tasHTML,\n\tisFilled,\n} from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tref,\n\tunref,\n\twatch,\n} from \"vue\";\nimport { routerKey } from \"vue-router\";\n\nimport { isInternalURL } from \"../lib/isInternalURL\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { RichTextField } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\";\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\tserializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `serializer` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\thtmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The HTML value to be rendered when the field is empty. If a fallback is not\n\t * given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextOptions = VueUseOptions<\n\tOmit<PrismicRichTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextReturnType = {\n\t/**\n\t * Serialized rich text field as HTML.\n\t */\n\thtml: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as HTML.\n *\n * @param props - {@link UsePrismicRichTextOptions}\n *\n * @returns - Serialized rich text field as HTML\n * {@link UsePrismicRichTextReturnType}\n */\nexport const usePrismicRichText = (\n\tprops: UsePrismicRichTextOptions,\n): UsePrismicRichTextReturnType => {\n\tconst { options } = usePrismic();\n\n\tconst html = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver;\n\t\tconst serializer =\n\t\t\tunref(props.serializer) ??\n\t\t\tunref(props.htmlSerializer) ??\n\t\t\toptions.richTextSerializer ??\n\t\t\toptions.htmlSerializer;\n\n\t\treturn asHTML(unref(field), linkResolver, serializer);\n\t});\n\n\treturn {\n\t\thtml,\n\t};\n};\n\n/**\n * `<PrismicRichText />` implementation.\n *\n * @internal\n */\nexport const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicRichText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tserializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\thtmlSerializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { html } = usePrismicRichText(props);\n\n\t\tconst root = ref<HTMLElement | Comment | Component | null>(null);\n\n\t\tconst maybeRouter = inject(routerKey, null);\n\t\tif (maybeRouter) {\n\t\t\ttype InternalLink = {\n\t\t\t\telement: HTMLAnchorElement;\n\t\t\t\tlistener: EventListener;\n\t\t\t};\n\t\t\tlet links: InternalLink[] = [];\n\n\t\t\tconst navigate: EventListener = function (\n\t\t\t\tthis: { href: string },\n\t\t\t\tevent: Event,\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tmaybeRouter.push(this.href);\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tconst node: HTMLElement | Comment | null =\n\t\t\t\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value;\n\t\t\t\tif (node && \"querySelectorAll\" in node) {\n\t\t\t\t\t// Get all internal link tags and add listeners on them\n\t\t\t\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t\t\t\t.map((element) => {\n\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\");\n\n\t\t\t\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\t\t\t\tconst listener = navigate.bind({ href });\n\t\t\t\t\t\t\t\telement.addEventListener(\"click\", listener);\n\n\t\t\t\t\t\t\t\treturn { element, listener };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((link): link is InternalLink => link as boolean);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tlinks.forEach(({ element, listener }) =>\n\t\t\t\t\telement.removeEventListener(\"click\", listener),\n\t\t\t\t);\n\t\t\t\tlinks = [];\n\t\t\t};\n\n\t\t\twatch(\n\t\t\t\thtml,\n\t\t\t\t() => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tnextTick(addListeners);\n\t\t\t\t},\n\t\t\t\t{ immediate: true },\n\t\t\t);\n\n\t\t\tonBeforeUnmount(() => {\n\t\t\t\tremoveListeners();\n\t\t\t});\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\tinnerHTML: html.value,\n\t\t\t\tref: root,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as HTML.\n *\n * @see Component props {@link PrismicRichTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicRichText = PrismicRichTextImpl as unknown as {\n\tnew (): {\n\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use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
3
  const helpers = require("@prismicio/helpers");
4
+ const vue = require("vue");
5
5
  const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
6
6
  const defaultWrapper = "div";
7
7
  const usePrismicText = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tcomputed,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\th,\n\tPropType,\n\tRaw,\n\tunref,\n\tVNode,\n\tVNodeProps,\n} from \"vue\";\n\nimport { asText, isFilled } from \"@prismicio/helpers\";\nimport { RichTextField } from \"@prismicio/types\";\n\nimport { VueUseOptions } from \"../types\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\n/**\n * The default component rendered to wrap the text output.\n */\nconst defaultWrapper = \"div\";\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue `\" \"` (a space)\n\t */\n\tseparator?: string;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The string value to be rendered when the field is empty. If a fallback is\n\t * not given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicText}.\n */\nexport type UsePrismicTextOptions = VueUseOptions<\n\tOmit<PrismicTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicText}.\n */\nexport type UsePrismicTextReturnType = {\n\t/**\n\t * Serialized rich text field as plain text.\n\t */\n\ttext: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as plain\n * text.\n *\n * @param props - {@link UsePrismicTextOptions}\n *\n * @returns - Serialized rich text field as plain text\n * {@link UsePrismicTextReturnType}\n */\nexport const usePrismicText = (\n\tprops: UsePrismicTextOptions,\n): UsePrismicTextReturnType => {\n\tconst text = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\treturn asText(unref(field), unref(props.separator));\n\t});\n\n\treturn {\n\t\ttext,\n\t};\n};\n\n/**\n * `<PrismicText />` implementation.\n *\n * @internal\n */\nexport const PrismicTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tseparator: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { text } = usePrismicText(props);\n\n\t\treturn () => {\n\t\t\tconst parent = simplyResolveComponent(props.wrapper || defaultWrapper);\n\n\t\t\t// This works but is absurd\n\t\t\t// if (typeof parent === \"string\") {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// } else {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// }\n\n\t\t\treturn h(parent as VNode, null, {\n\t\t\t\tdefault: () => text.value,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as plain text.\n *\n * @see Component props {@link PrismicTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicText = PrismicTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicTextProps;\n\t};\n};\n"],"names":["computed","unref","isFilled","asText","defineComponent","simplyResolveComponent","h"],"mappings":";;;;;AAyBA,MAAM,iBAAiB;AA0DV,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,OAAOA,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,SAAS,KAAK,GAAG;AACvB,aAAAD,UAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,WAAOE,QAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAGA,IAAAA,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,kBAAgDG,oBAAAA,gBAAA;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,eAAe,KAAK;AAErC,WAAO,MAAK;AACX,YAAM,SAASC,uBAAA,uBAAuB,MAAM,WAAW,cAAc;AAS9D,aAAAC,IAAA,EAAE,QAAiB,MAAM;AAAA,QAC/B,SAAS,MAAM,KAAK;AAAA,MAAA,CACpB;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
1
+ {"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { asText, isFilled } from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { RichTextField } from \"@prismicio/types\";\n\n/**\n * The default component rendered to wrap the text output.\n */\nconst defaultWrapper = \"div\";\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue `\" \"` (a space)\n\t */\n\tseparator?: string;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The string value to be rendered when the field is empty. If a fallback is\n\t * not given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicText}.\n */\nexport type UsePrismicTextOptions = VueUseOptions<\n\tOmit<PrismicTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicText}.\n */\nexport type UsePrismicTextReturnType = {\n\t/**\n\t * Serialized rich text field as plain text.\n\t */\n\ttext: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as plain\n * text.\n *\n * @param props - {@link UsePrismicTextOptions}\n *\n * @returns - Serialized rich text field as plain text\n * {@link UsePrismicTextReturnType}\n */\nexport const usePrismicText = (\n\tprops: UsePrismicTextOptions,\n): UsePrismicTextReturnType => {\n\tconst text = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\treturn asText(unref(field), unref(props.separator));\n\t});\n\n\treturn {\n\t\ttext,\n\t};\n};\n\n/**\n * `<PrismicText />` implementation.\n *\n * @internal\n */\nexport const PrismicTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tseparator: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { text } = usePrismicText(props);\n\n\t\treturn () => {\n\t\t\tconst parent = simplyResolveComponent(props.wrapper || defaultWrapper);\n\n\t\t\t// This works but is absurd\n\t\t\t// if (typeof parent === \"string\") {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// } else {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// }\n\n\t\t\treturn h(parent as VNode, null, {\n\t\t\t\tdefault: () => text.value,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as plain text.\n *\n * @see Component props {@link PrismicTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicText = PrismicTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicTextProps;\n\t};\n};\n"],"names":["computed","unref","isFilled","asText","defineComponent","simplyResolveComponent","h"],"mappings":";;;;;AAyBA,MAAM,iBAAiB;AA0DV,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,OAAOA,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,QAAA,SAAS,SAAS,KAAK,GAAG;AACvB,aAAAD,UAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,WAAOE,QAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAGA,IAAAA,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,kBAAgDG,oBAAAA,gBAAA;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,eAAe,KAAK;AAErC,WAAO,MAAK;AACX,YAAM,SAASC,uBAAA,uBAAuB,MAAM,WAAW,cAAc;AAS9D,aAAAC,IAAA,EAAE,QAAiB,MAAM;AAAA,QAC/B,SAAS,MAAM,KAAK;AAAA,MAAA,CACpB;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}