@prismicio/vue 5.3.0-pr.88.ee9acb6 → 5.3.0-pr.89.d0f4ac2

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 (134) hide show
  1. package/dist/PrismicImage.vue.d.cts +15 -49
  2. package/dist/PrismicImage.vue.d.cts.map +1 -1
  3. package/dist/PrismicLink.vue.d.cts +57 -52
  4. package/dist/PrismicLink.vue.d.cts.map +1 -1
  5. package/dist/PrismicRichText/PrismicRichText.vue.d.cts +14 -14
  6. package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -1
  7. package/dist/PrismicRichText/types.d.cts +25 -26
  8. package/dist/PrismicRichText/types.d.cts.map +1 -1
  9. package/dist/PrismicTable/PrismicTable.vue.d.cts +8 -9
  10. package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -1
  11. package/dist/PrismicTable/types.d.cts +7 -8
  12. package/dist/PrismicTable/types.d.cts.map +1 -1
  13. package/dist/PrismicText.vue.d.cts +2 -6
  14. package/dist/PrismicText.vue.d.cts.map +1 -1
  15. package/dist/SliceZone/SliceZone.vue.d.cts +3 -14
  16. package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -1
  17. package/dist/SliceZone/types.d.cts +3 -9
  18. package/dist/SliceZone/types.d.cts.map +1 -1
  19. package/dist/createPrismic.d.cts +61 -0
  20. package/dist/createPrismic.d.cts.map +1 -0
  21. package/dist/index.cjs +4 -1
  22. package/dist/index.d.cts +4 -2
  23. package/dist/index.d.ts +4 -2
  24. package/dist/index.js +2 -1
  25. package/dist/package.cjs +1 -1
  26. package/dist/package.cjs.map +1 -1
  27. package/dist/package.js +1 -1
  28. package/dist/package.js.map +1 -1
  29. package/dist/src/PrismicImage.cjs.map +1 -1
  30. package/dist/src/PrismicImage.js.map +1 -1
  31. package/dist/src/PrismicImage.vue.d.ts +15 -49
  32. package/dist/src/PrismicImage.vue.d.ts.map +1 -1
  33. package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  34. package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/src/PrismicLink.cjs.map +1 -1
  36. package/dist/src/PrismicLink.js.map +1 -1
  37. package/dist/src/PrismicLink.vue.d.ts +57 -52
  38. package/dist/src/PrismicLink.vue.d.ts.map +1 -1
  39. package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs +6 -10
  40. package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  41. package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js +6 -10
  42. package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
  43. package/dist/src/PrismicRichText/PrismicRichText.cjs.map +1 -1
  44. package/dist/src/PrismicRichText/PrismicRichText.js.map +1 -1
  45. package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts +18 -18
  46. package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
  47. package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +11 -5
  48. package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  49. package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js +11 -5
  50. package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -1
  51. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.cjs.map +1 -1
  52. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.js.map +1 -1
  53. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs +2 -2
  54. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  55. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js +2 -2
  56. package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  57. package/dist/src/PrismicRichText/PrismicRichTextSerialize.cjs.map +1 -1
  58. package/dist/src/PrismicRichText/PrismicRichTextSerialize.js.map +1 -1
  59. package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs +10 -4
  60. package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  61. package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js +11 -5
  62. package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -1
  63. package/dist/src/PrismicRichText/index.d.ts +1 -1
  64. package/dist/src/PrismicRichText/types.d.ts +25 -26
  65. package/dist/src/PrismicRichText/types.d.ts.map +1 -1
  66. package/dist/src/PrismicTable/PrismicTable.cjs.map +1 -1
  67. package/dist/src/PrismicTable/PrismicTable.js.map +1 -1
  68. package/dist/src/PrismicTable/PrismicTable.vue.d.ts +10 -11
  69. package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
  70. package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +18 -10
  71. package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  72. package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js +19 -11
  73. package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  74. package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs +12 -30
  75. package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs.map +1 -1
  76. package/dist/src/PrismicTable/PrismicTableDefaultComponents.js +12 -30
  77. package/dist/src/PrismicTable/PrismicTableDefaultComponents.js.map +1 -1
  78. package/dist/src/PrismicTable/PrismicTableRow.cjs.map +1 -1
  79. package/dist/src/PrismicTable/PrismicTableRow.js.map +1 -1
  80. package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  81. package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/src/PrismicTable/index.d.ts +1 -0
  83. package/dist/src/PrismicTable/types.d.ts +7 -8
  84. package/dist/src/PrismicTable/types.d.ts.map +1 -1
  85. package/dist/src/PrismicText.cjs.map +1 -1
  86. package/dist/src/PrismicText.js.map +1 -1
  87. package/dist/src/PrismicText.vue.d.ts +2 -6
  88. package/dist/src/PrismicText.vue.d.ts.map +1 -1
  89. package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  90. package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.js.map +1 -1
  91. package/dist/src/SliceZone/SliceZone.cjs.map +1 -1
  92. package/dist/src/SliceZone/SliceZone.js.map +1 -1
  93. package/dist/src/SliceZone/SliceZone.vue.d.ts +3 -14
  94. package/dist/src/SliceZone/SliceZone.vue.d.ts.map +1 -1
  95. package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  96. package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js.map +1 -1
  97. package/dist/src/SliceZone/types.d.ts +3 -9
  98. package/dist/src/SliceZone/types.d.ts.map +1 -1
  99. package/dist/src/createPrismic.cjs +33 -0
  100. package/dist/src/createPrismic.cjs.map +1 -0
  101. package/dist/src/createPrismic.d.ts +63 -0
  102. package/dist/src/createPrismic.d.ts.map +1 -0
  103. package/dist/src/createPrismic.js +32 -0
  104. package/dist/src/createPrismic.js.map +1 -0
  105. package/dist/src/lib/isInternalURL.cjs +2 -6
  106. package/dist/src/lib/isInternalURL.cjs.map +1 -1
  107. package/dist/src/lib/isInternalURL.js +2 -6
  108. package/dist/src/lib/isInternalURL.js.map +1 -1
  109. package/dist/src/types.cjs.map +1 -1
  110. package/dist/src/types.d.ts +11 -1
  111. package/dist/src/types.d.ts.map +1 -1
  112. package/dist/src/types.js.map +1 -1
  113. package/dist/types.d.cts +11 -1
  114. package/dist/types.d.cts.map +1 -1
  115. package/package.json +1 -3
  116. package/src/PrismicImage.vue +5 -16
  117. package/src/PrismicLink.vue +26 -26
  118. package/src/PrismicRichText/PrismicRichText.vue +33 -23
  119. package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +8 -4
  120. package/src/PrismicRichText/PrismicRichTextSerialize.vue +4 -3
  121. package/src/PrismicRichText/index.ts +1 -1
  122. package/src/PrismicRichText/types.ts +57 -29
  123. package/src/PrismicTable/PrismicTable.vue +31 -23
  124. package/src/PrismicTable/PrismicTableDefaultComponents.ts +14 -39
  125. package/src/PrismicTable/PrismicTableRow.vue +2 -2
  126. package/src/PrismicTable/index.ts +2 -0
  127. package/src/PrismicTable/types.ts +41 -23
  128. package/src/PrismicText.vue +2 -6
  129. package/src/SliceZone/SliceZone.vue +3 -14
  130. package/src/SliceZone/types.ts +3 -9
  131. package/src/createPrismic.ts +86 -0
  132. package/src/index.ts +5 -1
  133. package/src/lib/isInternalURL.ts +2 -6
  134. package/src/types.ts +13 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.js","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\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 external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\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 * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The Vue component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The Vue component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || defaultInternalComponent\n\t\t: props.externalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"PrismicLink.js","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./createPrismic\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\tcomponentsConfig?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\tcomponentsConfig?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
@@ -3,18 +3,16 @@ import * as vue16 from "vue";
3
3
  import { AsLinkAttrsConfig, LinkField, LinkResolverFunction, PrismicDocument } from "@prismicio/client";
4
4
 
5
5
  //#region src/PrismicLink.vue.d.ts
6
-
7
- /**
8
- * Props for `<PrismicLink />`.
9
- */
6
+ /** Props for `<PrismicLink />`. */
10
7
  type PrismicLinkProps = {
11
8
  /**
12
- * A link resolver function used to resolve links when not using the route
13
- * resolver parameter with `@prismicio/client`.
9
+ * The link resolver used to resolve links.
14
10
  *
15
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
11
+ * @remarks
12
+ * If your app uses route resolvers when querying for your Prismic
13
+ * repository's content, a link resolver does not need to be provided.
16
14
  *
17
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
15
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
18
16
  */
19
17
  linkResolver?: LinkResolverFunction;
20
18
  /**
@@ -24,27 +22,26 @@ type PrismicLinkProps = {
24
22
  */
25
23
  rel?: string | AsLinkAttrsConfig["rel"];
26
24
  /**
27
- * The Vue component rendered for links when the URL is internal.
25
+ * The component rendered for internal URLs.
26
+ *
27
+ * If your app uses a client-side router that requires a special Link
28
+ * component, provide the Link component to this prop.
28
29
  *
29
30
  * @defaultValue `<RouterLink>`
30
31
  */
31
32
  internalComponent?: ComponentOrTagName;
32
33
  /**
33
- * The Vue component rendered for links when the URL is external.
34
+ * The component rendered for external URLs.
34
35
  *
35
36
  * @defaultValue `<a>`
36
37
  */
37
38
  externalComponent?: ComponentOrTagName;
38
39
  } & ({
39
- /**
40
- * The Prismic link field to render.
41
- */
40
+ /** The Prismic link field to render. */
42
41
  field: LinkField;
43
42
  document?: never;
44
43
  } | {
45
- /**
46
- * The Prismic document to render as a link.
47
- */
44
+ /** The Prismic document to render as a link. */
48
45
  document: PrismicDocument;
49
46
  field?: never;
50
47
  });
@@ -54,12 +51,13 @@ type __VLS_Slots = {} & {
54
51
  };
55
52
  declare const __VLS_base: vue16.DefineComponent<({
56
53
  /**
57
- * A link resolver function used to resolve links when not using the route
58
- * resolver parameter with `@prismicio/client`.
54
+ * The link resolver used to resolve links.
59
55
  *
60
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
56
+ * @remarks
57
+ * If your app uses route resolvers when querying for your Prismic
58
+ * repository's content, a link resolver does not need to be provided.
61
59
  *
62
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
60
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
63
61
  */
64
62
  linkResolver?: LinkResolverFunction;
65
63
  /**
@@ -69,31 +67,33 @@ declare const __VLS_base: vue16.DefineComponent<({
69
67
  */
70
68
  rel?: string | AsLinkAttrsConfig["rel"];
71
69
  /**
72
- * The Vue component rendered for links when the URL is internal.
70
+ * The component rendered for internal URLs.
71
+ *
72
+ * If your app uses a client-side router that requires a special Link
73
+ * component, provide the Link component to this prop.
73
74
  *
74
75
  * @defaultValue `<RouterLink>`
75
76
  */
76
77
  internalComponent?: ComponentOrTagName;
77
78
  /**
78
- * The Vue component rendered for links when the URL is external.
79
+ * The component rendered for external URLs.
79
80
  *
80
81
  * @defaultValue `<a>`
81
82
  */
82
83
  externalComponent?: ComponentOrTagName;
83
84
  } & {
84
- /**
85
- * The Prismic link field to render.
86
- */
85
+ /** The Prismic link field to render. */
87
86
  field: LinkField;
88
87
  document?: never;
89
88
  }) | ({
90
89
  /**
91
- * A link resolver function used to resolve links when not using the route
92
- * resolver parameter with `@prismicio/client`.
90
+ * The link resolver used to resolve links.
93
91
  *
94
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
92
+ * @remarks
93
+ * If your app uses route resolvers when querying for your Prismic
94
+ * repository's content, a link resolver does not need to be provided.
95
95
  *
96
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
96
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
97
97
  */
98
98
  linkResolver?: LinkResolverFunction;
99
99
  /**
@@ -103,31 +103,33 @@ declare const __VLS_base: vue16.DefineComponent<({
103
103
  */
104
104
  rel?: string | AsLinkAttrsConfig["rel"];
105
105
  /**
106
- * The Vue component rendered for links when the URL is internal.
106
+ * The component rendered for internal URLs.
107
+ *
108
+ * If your app uses a client-side router that requires a special Link
109
+ * component, provide the Link component to this prop.
107
110
  *
108
111
  * @defaultValue `<RouterLink>`
109
112
  */
110
113
  internalComponent?: ComponentOrTagName;
111
114
  /**
112
- * The Vue component rendered for links when the URL is external.
115
+ * The component rendered for external URLs.
113
116
  *
114
117
  * @defaultValue `<a>`
115
118
  */
116
119
  externalComponent?: ComponentOrTagName;
117
120
  } & {
118
- /**
119
- * The Prismic document to render as a link.
120
- */
121
+ /** The Prismic document to render as a link. */
121
122
  document: PrismicDocument;
122
123
  field?: never;
123
124
  }), {}, {}, {}, {}, vue16.ComponentOptionsMixin, vue16.ComponentOptionsMixin, {}, string, vue16.PublicProps, Readonly<({
124
125
  /**
125
- * A link resolver function used to resolve links when not using the route
126
- * resolver parameter with `@prismicio/client`.
126
+ * The link resolver used to resolve links.
127
127
  *
128
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
128
+ * @remarks
129
+ * If your app uses route resolvers when querying for your Prismic
130
+ * repository's content, a link resolver does not need to be provided.
129
131
  *
130
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
132
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
131
133
  */
132
134
  linkResolver?: LinkResolverFunction;
133
135
  /**
@@ -137,31 +139,33 @@ declare const __VLS_base: vue16.DefineComponent<({
137
139
  */
138
140
  rel?: string | AsLinkAttrsConfig["rel"];
139
141
  /**
140
- * The Vue component rendered for links when the URL is internal.
142
+ * The component rendered for internal URLs.
143
+ *
144
+ * If your app uses a client-side router that requires a special Link
145
+ * component, provide the Link component to this prop.
141
146
  *
142
147
  * @defaultValue `<RouterLink>`
143
148
  */
144
149
  internalComponent?: ComponentOrTagName;
145
150
  /**
146
- * The Vue component rendered for links when the URL is external.
151
+ * The component rendered for external URLs.
147
152
  *
148
153
  * @defaultValue `<a>`
149
154
  */
150
155
  externalComponent?: ComponentOrTagName;
151
156
  } & {
152
- /**
153
- * The Prismic link field to render.
154
- */
157
+ /** The Prismic link field to render. */
155
158
  field: LinkField;
156
159
  document?: never;
157
160
  }) | ({
158
161
  /**
159
- * A link resolver function used to resolve links when not using the route
160
- * resolver parameter with `@prismicio/client`.
162
+ * The link resolver used to resolve links.
161
163
  *
162
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
164
+ * @remarks
165
+ * If your app uses route resolvers when querying for your Prismic
166
+ * repository's content, a link resolver does not need to be provided.
163
167
  *
164
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
168
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
165
169
  */
166
170
  linkResolver?: LinkResolverFunction;
167
171
  /**
@@ -171,21 +175,22 @@ declare const __VLS_base: vue16.DefineComponent<({
171
175
  */
172
176
  rel?: string | AsLinkAttrsConfig["rel"];
173
177
  /**
174
- * The Vue component rendered for links when the URL is internal.
178
+ * The component rendered for internal URLs.
179
+ *
180
+ * If your app uses a client-side router that requires a special Link
181
+ * component, provide the Link component to this prop.
175
182
  *
176
183
  * @defaultValue `<RouterLink>`
177
184
  */
178
185
  internalComponent?: ComponentOrTagName;
179
186
  /**
180
- * The Vue component rendered for links when the URL is external.
187
+ * The component rendered for external URLs.
181
188
  *
182
189
  * @defaultValue `<a>`
183
190
  */
184
191
  externalComponent?: ComponentOrTagName;
185
192
  } & {
186
- /**
187
- * The Prismic document to render as a link.
188
- */
193
+ /** The Prismic document to render as a link. */
189
194
  document: PrismicDocument;
190
195
  field?: never;
191
196
  })> & Readonly<{}>, {}, {}, {}, {}, string, vue16.ComponentProvideOptions, false, {}, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.vue.d.ts","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":[],"mappings":";;;;;;;;AA8JA;AASgB,KATJ,gBAAA,GASI;EAOA;;;;;;AA8Bf;AA0EqB;EAOhB,YAAA,CAEJ,EAxHc,oBAwHd;EAxHc;;;;;EAAA,GAAA,CAAA,EAAA,MAAA,GAOA,iBAPA,CAAA,KAAA,CAAA;EAOA;;;;;sBAOK;;;;;;EAaX,iBAAA,CAAA,EANW,kBAMX;CA3BM,GAAA,CAAA;EAOA;;;EA2BH,KAAA,EAPH,SAOG;;;;;;EAuFP,QAAA,EAvFO,eAuF6D;EAAxB,KAAA,CAAA,EAAA,KAAA;CAAY,CAAA;YAV1D,OAUuB,EAAA,CAAA,CAAA;KATtB,WAAA,GASqC,CAAA,CAAA,GAAA;EAAA,OAAA,CAAA,EAAA,CACF,KAAA,EAAA,OATX,OASD,EAAA,GAAY,GAAA;AAAxC,CAAA;cAJM,kBAAU;;;;;;;;;iBAtHA;;;;;;iBAOA;;;;;;sBAOK;;;;;;sBAOA;;;;;SAMX;;;;;;;;;;;iBA3BM;;;;;;iBAOA;;;;;;sBAOK;;;;;;sBAOA;;;;;YAaR;;oBAAe,KAAA,CAAA,qBAAA;;;;;;;;;iBAlCZ;;;;;;iBAOA;;;;;;sBAOK;;;;;;sBAOA;;;;;SAMX;;;;;;;;;;;iBA3BM;;;;;;iBAOA;;;;;;sBAOK;;;;;;sBAOA;;;;;YAaR;;;cAuFP,cAAqB,uBAAuB,YAAY;cAApB,iBACd;KACvB,wBAAwB;;YAEnB"}
1
+ {"version":3,"file":"PrismicLink.vue.d.ts","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":[],"mappings":";;;;;;KAwJY,gBAAA;EAAA;;;;;;;;AA8CX;EAiFI,YAAA,CAAA,EArHW,oBAsHoB;EAK9B;;;;;EA/FI,GAAA,CAAA,EAAA,MAAA,GArBM,iBAqBN,CAAA,KAAA,CAAA;EA5BM;;;;;;;;EAAA,iBAAA,CAAA,EAiBK,kBAjBL;EAOA;;;;;EAAA,iBAAA,CAAA,EAiBK,kBAjBL;CAUK,GAAA,CAAA;EAOA;EASR,KAAA,EALH,SAKG;;;;UA0FG,EA1FH,eA0FG;EAAA,KAAA,CAAA,EAAA,KAAA;AAAA,CAAA,CAAA;YAPZ,OAU8C,EAAA,CAAA,CAAA;KAT7C,WAAA,GASyD,CAAA,CAAA,GAAA;EAAnC,OAAA,CAAA,EAAA,CAAA,KAAA,EAAA,OARE,OAQF,EAAA,GAAA,GAAA;CAAe;AAAA,cAHpC,UAIkC,QAJxB,eAIwB,CAAA,CAAA;EACnC;;;;;;;;;iBAhIW;;;;;;iBAOA;;;;;;;;;sBAUK;;;;;;sBAOA;;;SAIX;;;;;;;;;;;;iBA5BM;;;;;;iBAOA;;;;;;;;;sBAUK;;;;;;sBAOA;;;YASR;;oBAAe,KAAA,CAAA,qBAAA;;;;;;;;;;iBAjCZ;;;;;;iBAOA;;;;;;;;;sBAUK;;;;;;sBAOA;;;SAIX;;;;;;;;;;;;iBA5BM;;;;;;iBAOA;;;;;;;;;sBAUK;;;;;;sBAOA;;;YASR;;;cA6FP,cAAqB,uBAAuB,YAAY;cAApB,iBACd;KACvB,wBAAwB;;YAEnB"}
@@ -1,19 +1,14 @@
1
+ const require_createPrismic = require('./createPrismic.cjs');
1
2
  const require_isInternalURL = require('./lib/isInternalURL.cjs');
2
3
  let vue = require("vue");
3
4
  let __prismicio_client = require("@prismicio/client");
4
5
 
5
6
  //#region src/PrismicLink.vue?vue&type=script&setup=true&lang.ts
6
- /**
7
- * The default component rendered for internal URLs.
8
- */
7
+ /** The default component rendered for internal URLs. */
9
8
  const defaultInternalComponent = "router-link";
10
- /**
11
- * The default component rendered for external URLs.
12
- */
9
+ /** The default component rendered for external URLs. */
13
10
  const defaultExternalComponent = "a";
14
- /**
15
- * The default rel attribute rendered for external URLs.
16
- */
11
+ /** The default rel attribute rendered for external URLs. */
17
12
  const defaultExternalRelAttribute = "noreferrer";
18
13
  var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
19
14
  name: "PrismicLink",
@@ -46,6 +41,7 @@ var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
46
41
  },
47
42
  setup(__props) {
48
43
  const props = __props;
44
+ const { componentsConfig } = require_createPrismic.usePrismic();
49
45
  const rawAttrs = (0, vue.computed)(() => {
50
46
  return (0, __prismicio_client.asLinkAttrs)(props.field || props.document, {
51
47
  linkResolver: props.linkResolver,
@@ -56,7 +52,7 @@ var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
56
52
  });
57
53
  });
58
54
  const component = (0, vue.computed)(() => {
59
- return require_isInternalURL.isInternalURL(rawAttrs.value.href || "") ? props.internalComponent || defaultInternalComponent : props.externalComponent || defaultExternalComponent;
55
+ return require_isInternalURL.isInternalURL(rawAttrs.value.href || "") ? props.internalComponent || componentsConfig?.linkInternalComponent || defaultInternalComponent : props.externalComponent || componentsConfig?.linkExternalComponent || defaultExternalComponent;
60
56
  });
61
57
  const attrs = (0, vue.computed)(() => {
62
58
  return component.value === "a" ? {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\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 external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\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 * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The Vue component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The Vue component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || defaultInternalComponent\n\t\t: props.externalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;;;AAiBA,MAAM,2BAA2B;;;;AAKjC,MAAM,2BAA2B;;;;AAKjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDpC,MAAM,QAAQ;EAGd,MAAM,mCAA0B;AAC/B,8CAAmB,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM;IACpB,IAAI,MAAM;AACT,SAAI,MAAM,IACT,QAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,KAAK,GAAG,MAAM;AAGlE,YAAO,KAAK,aAAa,8BAA8B;;IAExD,CAAA;IACD;EAED,MAAM,oCAA2B;AAChC,UAAO,oCAAc,SAAS,MAAM,QAAQ,GAAE,GAC3C,MAAM,qBAAqB,2BAC3B,MAAM,qBAAqB;IAC9B;EAGD,MAAM,gCAAuB;AAC5B,UAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB,GACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB;IACF;;sFAIgB,UAAA,MAAS,sDAAU,MAAA,MAAK,CAAA,EAAA;oCAGhC,qBAAA,KAAA,QAAA,WAAA,EAAA,QAAA,mDADH,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,OAAS,EAAA,EAAA"}
1
+ {"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./createPrismic\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\tcomponentsConfig?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\tcomponentsConfig?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;;AAiBA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,qBAAqB,kCAAW;EAExC,MAAM,mCAA0B;AAC/B,8CAAmB,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM;IACpB,IAAI,MAAM;AACT,SAAI,MAAM,IACT,QAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,KAAK,GAAG,MAAM;AAGlE,YAAO,KAAK,aAAa,8BAA8B;;IAExD,CAAA;IACD;EAED,MAAM,oCAA2B;AAChC,UAAO,oCAAc,SAAS,MAAM,QAAQ,GAAE,GAC3C,MAAM,qBACN,kBAAkB,yBAClB,2BACA,MAAM,qBACN,kBAAkB,yBAClB;IACH;EAGD,MAAM,gCAAuB;AAC5B,UAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB,GACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB;IACF;;sFAIgB,UAAA,MAAS,sDAAU,MAAA,MAAK,CAAA,EAAA;oCAGhC,qBAAA,KAAA,QAAA,WAAA,EAAA,QAAA,mDADH,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,OAAS,EAAA,EAAA"}
@@ -1,19 +1,14 @@
1
+ import { usePrismic } from "./createPrismic.js";
1
2
  import { isInternalURL } from "./lib/isInternalURL.js";
2
3
  import { computed, createBlock, createTextVNode, defineComponent, guardReactiveProps, normalizeProps, openBlock, renderSlot, resolveDynamicComponent, toDisplayString, withCtx } from "vue";
3
4
  import { asLinkAttrs } from "@prismicio/client";
4
5
 
5
6
  //#region src/PrismicLink.vue?vue&type=script&setup=true&lang.ts
6
- /**
7
- * The default component rendered for internal URLs.
8
- */
7
+ /** The default component rendered for internal URLs. */
9
8
  const defaultInternalComponent = "router-link";
10
- /**
11
- * The default component rendered for external URLs.
12
- */
9
+ /** The default component rendered for external URLs. */
13
10
  const defaultExternalComponent = "a";
14
- /**
15
- * The default rel attribute rendered for external URLs.
16
- */
11
+ /** The default rel attribute rendered for external URLs. */
17
12
  const defaultExternalRelAttribute = "noreferrer";
18
13
  var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
19
14
  name: "PrismicLink",
@@ -46,6 +41,7 @@ var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
46
41
  },
47
42
  setup(__props) {
48
43
  const props = __props;
44
+ const { componentsConfig } = usePrismic();
49
45
  const rawAttrs = computed(() => {
50
46
  return asLinkAttrs(props.field || props.document, {
51
47
  linkResolver: props.linkResolver,
@@ -56,7 +52,7 @@ var PrismicLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
56
52
  });
57
53
  });
58
54
  const component = computed(() => {
59
- return isInternalURL(rawAttrs.value.href || "") ? props.internalComponent || defaultInternalComponent : props.externalComponent || defaultExternalComponent;
55
+ return isInternalURL(rawAttrs.value.href || "") ? props.internalComponent || componentsConfig?.linkInternalComponent || defaultInternalComponent : props.externalComponent || componentsConfig?.linkExternalComponent || defaultExternalComponent;
60
56
  });
61
57
  const attrs = computed(() => {
62
58
  return component.value === "a" ? {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\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 external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\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 * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The Vue component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The Vue component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent || defaultInternalComponent\n\t\t: props.externalComponent || defaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;;;AAiBA,MAAM,2BAA2B;;;;AAKjC,MAAM,2BAA2B;;;;AAKjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDpC,MAAM,QAAQ;EAGd,MAAM,WAAW,eAAe;AAC/B,UAAO,YAAY,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM;IACpB,IAAI,MAAM;AACT,SAAI,MAAM,IACT,QAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,KAAK,GAAG,MAAM;AAGlE,YAAO,KAAK,aAAa,8BAA8B;;IAExD,CAAA;IACD;EAED,MAAM,YAAY,eAAe;AAChC,UAAO,cAAc,SAAS,MAAM,QAAQ,GAAE,GAC3C,MAAM,qBAAqB,2BAC3B,MAAM,qBAAqB;IAC9B;EAGD,MAAM,QAAQ,eAAe;AAC5B,UAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB,GACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB;IACF;;uBAIA,YAIY,wBAJI,UAAA,MAAS,EAAA,eAAA,mBAAU,MAAA,MAAK,CAAA,EAAA;2BAGhC,CAFP,WAEO,KAAA,QAAA,WAAA,EAAA,QAAA,iCADH,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,OAAS,EAAA,EAAA"}
1
+ {"version":3,"file":"PrismicLink.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./createPrismic\"\n\n/** The default component rendered for internal URLs. */\nconst defaultInternalComponent = \"router-link\"\n\n/** The default component rendered for external URLs. */\nconst defaultExternalComponent = \"a\"\n\n/** The default rel attribute rendered for external URLs. */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/** Props for `<PrismicLink />`. */\nexport type PrismicLinkProps = {\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * The component rendered for internal URLs.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t *\n\t * @defaultValue `<RouterLink>`\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * The component rendered for external URLs.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/** The Prismic link field to render. */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/** The Prismic document to render as a link. */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver,\n\t\trel(args) {\n\t\t\tif (props.rel) {\n\t\t\t\treturn typeof props.rel === \"function\" ? props.rel(args) : props.rel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\tcomponentsConfig?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\tcomponentsConfig?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":";;;;;;;AAiBA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;;AAGjC,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDpC,MAAM,QAAQ;EAGd,MAAM,EAAE,qBAAqB,YAAW;EAExC,MAAM,WAAW,eAAe;AAC/B,UAAO,YAAY,MAAM,SAAS,MAAM,UAAU;IACjD,cAAc,MAAM;IACpB,IAAI,MAAM;AACT,SAAI,MAAM,IACT,QAAO,OAAO,MAAM,QAAQ,aAAa,MAAM,IAAI,KAAK,GAAG,MAAM;AAGlE,YAAO,KAAK,aAAa,8BAA8B;;IAExD,CAAA;IACD;EAED,MAAM,YAAY,eAAe;AAChC,UAAO,cAAc,SAAS,MAAM,QAAQ,GAAE,GAC3C,MAAM,qBACN,kBAAkB,yBAClB,2BACA,MAAM,qBACN,kBAAkB,yBAClB;IACH;EAGD,MAAM,QAAQ,eAAe;AAC5B,UAAO,UAAU,UAAU,MACxB;IACA,MAAM,SAAS,MAAM;IACrB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB,GACC;IACA,IAAI,SAAS,MAAM;IACnB,QAAQ,SAAS,MAAM;IACvB,KAAK,SAAS,MAAM;IACrB;IACF;;uBAIA,YAIY,wBAJI,UAAA,MAAS,EAAA,eAAA,mBAAU,MAAA,MAAK,CAAA,EAAA;2BAGhC,CAFP,WAEO,KAAA,QAAA,WAAA,EAAA,QAAA,iCADH,MAAM,SAAK,UAAc,MAAM,QAAQ,MAAM,MAAM,OAAO,OAAS,EAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.cjs","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { type ComponentOrTagName, isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponent,\n\tVueRichTextSerializer,\n\tVueShorthand,\n} from \"./types\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\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 object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = props.components?.[type]\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tprops: {\n\t\t\tlinkResolver: props.linkResolver,\n\t\t\tshorthand: maybeComponentOrShorthand as VueShorthand,\n\t\t},\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponent>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"PrismicRichText.cjs","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport type { ComponentOrTagName, VueComponentShorthand } from \"../types\"\nimport { isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponents,\n\tVueRichTextComponent,\n\tVueRichTextComponents,\n} from \"./types\"\n\nimport { usePrismic } from \"../createPrismic\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a\n\t * shorthand definition.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * paragraph: { class: 'prose'},\n\t * strong: { as: 'em', class: 'font-bold' },\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst resolvedComponents = computed<VueRichTextComponents>(() => {\n\treturn { ...componentsConfig?.defaultComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| VueRichTextComponent\n\t\t| VueComponentShorthand\n\t\t| undefined\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.js","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { type ComponentOrTagName, isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponent,\n\tVueRichTextSerializer,\n\tVueShorthand,\n} from \"./types\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\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 object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = props.components?.[type]\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tprops: {\n\t\t\tlinkResolver: props.linkResolver,\n\t\t\tshorthand: maybeComponentOrShorthand as VueShorthand,\n\t\t},\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponent>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"PrismicRichText.js","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport type { ComponentOrTagName, VueComponentShorthand } from \"../types\"\nimport { isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponents,\n\tVueRichTextComponent,\n\tVueRichTextComponents,\n} from \"./types\"\n\nimport { usePrismic } from \"../createPrismic\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a\n\t * shorthand definition.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * paragraph: { class: 'prose'},\n\t * strong: { as: 'em', class: 'font-bold' },\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst resolvedComponents = computed<VueRichTextComponents>(() => {\n\treturn { ...componentsConfig?.defaultComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| VueRichTextComponent\n\t\t| VueComponentShorthand\n\t\t| undefined\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":""}
@@ -1,46 +1,46 @@
1
1
  import { ComponentOrTagName } from "../types.js";
2
- import { VueRichTextSerializer } from "./types.js";
3
- import * as vue0 from "vue";
2
+ import { VueRichTextComponents } from "./types.js";
3
+ import * as vue4 from "vue";
4
4
  import { PropType } from "vue";
5
5
  import { LinkResolverFunction, RichTextField } from "@prismicio/client";
6
6
 
7
7
  //#region src/PrismicRichText/PrismicRichText.vue.d.ts
8
- /**
9
- * Props for `<PrismicRichText />`.
10
- */
8
+ /** Props for `<PrismicRichText />`. */
11
9
  type PrismicRichTextProps = {
12
- /**
13
- * The Prismic rich text or title field to render.
14
- */
10
+ /** The Prismic rich text field to render. */
15
11
  field: RichTextField | null | undefined;
16
12
  /**
17
- * A link resolver function used to resolve link when not using the route
18
- * resolver parameter with `@prismicio/client`.
13
+ * The link resolver used to resolve links.
19
14
  *
20
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
15
+ * @remarks
16
+ * If your app uses route resolvers when querying for your Prismic
17
+ * repository's content, a link resolver does not need to be provided.
21
18
  *
22
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
19
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
23
20
  */
24
21
  linkResolver?: LinkResolverFunction;
25
22
  /**
26
- * An object that maps a rich text block type to a Vue component.
23
+ * An object that maps a rich text block type to a Vue component or a
24
+ * shorthand definition.
27
25
  *
28
26
  * @example
29
27
  *
30
28
  * ```javascript
31
29
  * {
32
30
  * heading1: Heading1,
31
+ * paragraph: { class: 'prose'},
32
+ * strong: { as: 'em', class: 'font-bold' },
33
33
  * }
34
34
  * ```
35
35
  */
36
- components?: VueRichTextSerializer;
36
+ components?: VueRichTextComponents;
37
37
  /**
38
38
  * The value to be rendered when the field is empty. If a fallback is not
39
- * given, `null` (nothing) will be rendered.
39
+ * given, `null` will be rendered.
40
40
  */
41
41
  fallback?: ComponentOrTagName;
42
42
  };
43
- declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
43
+ declare const __VLS_export: vue4.DefineComponent<vue4.ExtractPropTypes<{
44
44
  field: {
45
45
  type: PropType<PrismicRichTextProps["field"]>;
46
46
  };
@@ -53,7 +53,7 @@ declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
53
53
  fallback: {
54
54
  type: PropType<PrismicRichTextProps["fallback"]>;
55
55
  };
56
- }>, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
56
+ }>, {}, {}, {}, {}, vue4.ComponentOptionsMixin, vue4.ComponentOptionsMixin, {}, string, vue4.PublicProps, Readonly<vue4.ExtractPropTypes<{
57
57
  field: {
58
58
  type: PropType<PrismicRichTextProps["field"]>;
59
59
  };
@@ -66,7 +66,7 @@ declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
66
66
  fallback: {
67
67
  type: PropType<PrismicRichTextProps["fallback"]>;
68
68
  };
69
- }>> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
69
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, vue4.ComponentProvideOptions, true, {}, any>;
70
70
  declare const _default: typeof __VLS_export;
71
71
  //#endregion
72
72
  export { PrismicRichTextProps, _default };
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.vue.d.ts","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":[],"mappings":";;;;;;;;;;AA4JY,KAAA,oBAAA,GAAoB;EAIxB;;;EA6BI,KAAA,EA7BJ,aA6BI,GAAA,IAAA,GAAA,SAAA;EAAkB;AAC7B;;;;;;;EA4HE,YAAA,CAAA,EAhJa,oBAgJb;EADmC;;;;;;;;;;;EACnC,UAAA,CAAA,EAnIW,qBAmIX;EADmC;;;;aA5H1B;;cAgHN,YAAY,OAAA,eAAA,CAY4B,IAAA,CAZ5B,gBAAA,CAAA;EAAA,KAAA,EAAA;UAGU,SAAS;;;UAGjB,SAAS;;;UAGX,SAAS;;;UAGW,SACnC;;oBAbe,IAAA,CAAA,qBAAA,qEAY4B,IAAA,CAAA;;UATlB,SAAS;;;UAGjB,SAAS;;;UAGX,SAAS;;;UAGW,SACnC;;;cAbe,iBAkBU"}
1
+ {"version":3,"file":"PrismicRichText.vue.d.ts","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":[],"mappings":";;;;;;;;KAuKY,oBAAA;;EAAA,KAAA,EAEJ,aAFI,GAAoB,IAAA,GAAA,SAAA;EAExB;;;;;AAkCP;;;;EA4HmB,YAAA,CAAA,EAnJJ,oBAmJI;EAGO;;;;;;;;;;;;;;EAIxB,UAAA,CAAA,EA1IW,qBA0IX;EADmC;;;;aAnI1B;;cAuHN,YAAY,OAAA,eAAA,CAY4B,IAAA,CAZ5B,gBAAA,CAAA;EAAA,KAAA,EAAA;UAGU,SAAS;;;UAGjB,SAAS;;;UAGX,SAAS;;;UAGW,SACnC;;oBAbe,IAAA,CAAA,qBAAA,qEAY4B,IAAA,CAAA;;UATlB,SAAS;;;UAGjB,SAAS;;;UAGX,SAAS;;;UAGW,SACnC;;;cAbe,iBAkBU"}
@@ -1,4 +1,5 @@
1
1
  const require_types = require('../types.cjs');
2
+ const require_createPrismic = require('../createPrismic.cjs');
2
3
  const require_PrismicRichTextDefaultComponent = require('./PrismicRichTextDefaultComponent.cjs');
3
4
  const require_PrismicRichTextSerialize = require('./PrismicRichTextSerialize.cjs');
4
5
  let vue = require("vue");
@@ -20,18 +21,23 @@ var PrismicRichText_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ *
20
21
  },
21
22
  setup(__props) {
22
23
  const props = __props;
24
+ const { componentsConfig } = require_createPrismic.usePrismic();
25
+ const resolvedComponents = (0, vue.computed)(() => {
26
+ return {
27
+ ...componentsConfig?.defaultComponents,
28
+ ...props.components
29
+ };
30
+ });
23
31
  const children = (0, vue.computed)(() => {
24
32
  return (0, __prismicio_client_richtext.asTree)(props.field || []).children;
25
33
  });
26
34
  function getInternalComponent(type) {
27
- const maybeComponentOrShorthand = props.components?.[type];
35
+ const maybeComponentOrShorthand = resolvedComponents.value?.[type];
28
36
  if (require_types.isVueComponent(maybeComponentOrShorthand)) return { is: maybeComponentOrShorthand };
29
37
  return {
30
38
  is: require_PrismicRichTextDefaultComponent.default,
31
- props: {
32
- linkResolver: props.linkResolver,
33
- shorthand: maybeComponentOrShorthand
34
- }
39
+ linkResolver: props.linkResolver,
40
+ shorthand: maybeComponentOrShorthand
35
41
  };
36
42
  }
37
43
  const internalComponents = (0, vue.computed)(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport { type ComponentOrTagName, isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponent,\n\tVueRichTextSerializer,\n\tVueShorthand,\n} from \"./types\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\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 object that maps a rich text block type to a Vue component.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextSerializer\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` (nothing) will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = props.components?.[type]\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tprops: {\n\t\t\tlinkResolver: props.linkResolver,\n\t\t\tshorthand: maybeComponentOrShorthand as VueShorthand,\n\t\t},\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponent>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EA6DA,MAAM,QAAQ;EAkBd,MAAM,mCAA0B;AAC/B,kDAAc,MAAM,SAAS,EAAE,CAAC,CAAC;IACjC;EAED,SAAS,qBAAqB,MAAqC;GAClE,MAAM,4BAA4B,MAAM,aAAa;AAErD,OAAI,6BAAe,0BAA0B,CAC5C,QAAO,EAAE,IAAI,2BAA0B;AAGxC,UAAO;IACN,IAAI;IACJ,OAAO;KACN,cAAc,MAAM;KACpB,WAAW;KACX;IACF;;EAGD,MAAM,6CAAkE;AACvE,UAAO;IACN,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,WAAW,qBAAqB,YAAY;IAC5C,cAAc,qBAAqB,eAAe;IAClD,QAAQ,qBAAqB,SAAS;IACtC,IAAI,qBAAqB,KAAK;IAC9B,aAAa,qBAAqB,WAAW;IAC7C,eAAe,qBAAqB,YAAY;IAChD,mBAAmB,qBAAqB,OAAO;IAC/C,qBAAqB,qBAAqB,QAAQ;IAClD,OAAO,qBAAqB,QAAQ;IACpC,OAAO,qBAAqB,QAAQ;IACpC,WAAW,qBAAqB,YAAY;IAC5C,OAAO,qBAAqB,QAAQ;IACpC,MAAM,qBAAqB,OAAO;IACnC;IACA;;UAKO,SAAA,MAAS,qDAGd,0CAAA;;IAFA,UAAU,SAAA;IACV,uBAAqB,mBAAA;uDAED,QAAA,wFAAe,QAAA,SAAQ,EAAA,EAAA,KAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"PrismicRichText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/PrismicRichText/PrismicRichText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type {\n\tLinkResolverFunction,\n\tRichTextField,\n\tRichTextNodeType,\n} from \"@prismicio/client\"\nimport { asTree } from \"@prismicio/client/richtext\"\nimport type { PropType } from \"vue\"\nimport { computed } from \"vue\"\n\nimport type { ComponentOrTagName, VueComponentShorthand } from \"../types\"\nimport { isVueComponent } from \"../types\"\nimport type {\n\tInternalVueRichTextComponents,\n\tVueRichTextComponent,\n\tVueRichTextComponents,\n} from \"./types\"\n\nimport { usePrismic } from \"../createPrismic\"\n\nimport PrismicRichTextDefaultComponent from \"./PrismicRichTextDefaultComponent.vue\"\nimport PrismicRichTextSerialize from \"./PrismicRichTextSerialize.vue\"\n\n/** Props for `<PrismicRichText />`. */\nexport type PrismicRichTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * The link resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses route resolvers when querying for your Prismic\n\t * repository's content, a link resolver does not need to be provided.\n\t *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An object that maps a rich text block type to a Vue component or a\n\t * shorthand definition.\n\t *\n\t * @example\n\t *\n\t * ```javascript\n\t * {\n\t * heading1: Heading1,\n\t * paragraph: { class: 'prose'},\n\t * strong: { as: 'em', class: 'font-bold' },\n\t * }\n\t * ```\n\t */\n\tcomponents?: VueRichTextComponents\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: ComponentOrTagName\n}\n\n// We're forced to declare props using the JavaScript syntax because `@vue/compiler-sfc`\n// has limitations for inferring types from complex objects.\nconst props = defineProps({\n\tfield: {\n\t\ttype: Array as unknown as PropType<PrismicRichTextProps[\"field\"]>,\n\t},\n\tlinkResolver: {\n\t\ttype: Function as PropType<PrismicRichTextProps[\"linkResolver\"]>,\n\t},\n\tcomponents: {\n\t\ttype: Object as PropType<PrismicRichTextProps[\"components\"]>,\n\t},\n\tfallback: {\n\t\ttype: [String, Object, Function] as PropType<\n\t\t\tPrismicRichTextProps[\"fallback\"]\n\t\t>,\n\t},\n})\ndefineOptions({ name: \"PrismicRichText\" })\n\nconst { componentsConfig } = usePrismic()\n\nconst resolvedComponents = computed<VueRichTextComponents>(() => {\n\treturn { ...componentsConfig?.defaultComponents, ...props.components }\n})\n\nconst children = computed(() => {\n\treturn asTree(props.field || []).children\n})\n\nfunction getInternalComponent(type: keyof typeof RichTextNodeType) {\n\tconst maybeComponentOrShorthand = resolvedComponents.value?.[type] as\n\t\t| VueRichTextComponent\n\t\t| VueComponentShorthand\n\t\t| undefined\n\n\tif (isVueComponent(maybeComponentOrShorthand)) {\n\t\treturn { is: maybeComponentOrShorthand }\n\t}\n\n\treturn {\n\t\tis: PrismicRichTextDefaultComponent,\n\t\tlinkResolver: props.linkResolver,\n\t\tshorthand: maybeComponentOrShorthand,\n\t}\n}\n\nconst internalComponents = computed<InternalVueRichTextComponents>(() => {\n\treturn {\n\t\theading1: getInternalComponent(\"heading1\"),\n\t\theading2: getInternalComponent(\"heading2\"),\n\t\theading3: getInternalComponent(\"heading3\"),\n\t\theading4: getInternalComponent(\"heading4\"),\n\t\theading5: getInternalComponent(\"heading5\"),\n\t\theading6: getInternalComponent(\"heading6\"),\n\t\tparagraph: getInternalComponent(\"paragraph\"),\n\t\tpreformatted: getInternalComponent(\"preformatted\"),\n\t\tstrong: getInternalComponent(\"strong\"),\n\t\tem: getInternalComponent(\"em\"),\n\t\t\"list-item\": getInternalComponent(\"listItem\"),\n\t\t\"o-list-item\": getInternalComponent(\"oListItem\"),\n\t\t\"group-list-item\": getInternalComponent(\"list\"),\n\t\t\"group-o-list-item\": getInternalComponent(\"oList\"),\n\t\timage: getInternalComponent(\"image\"),\n\t\tembed: getInternalComponent(\"embed\"),\n\t\thyperlink: getInternalComponent(\"hyperlink\"),\n\t\tlabel: getInternalComponent(\"label\"),\n\t\tspan: getInternalComponent(\"span\"),\n\t}\n})\n</script>\n\n<template>\n\t<PrismicRichTextSerialize\n\t\tv-if=\"children.length\"\n\t\t:children=\"children\"\n\t\t:internal-components=\"internalComponents\"\n\t/>\n\t<component v-else-if=\"fallback\" :is=\"fallback\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAgEA,MAAM,QAAQ;EAkBd,MAAM,EAAE,qBAAqB,kCAAW;EAExC,MAAM,6CAA2D;AAChE,UAAO;IAAE,GAAG,kBAAkB;IAAmB,GAAG,MAAM;IAAW;IACrE;EAED,MAAM,mCAA0B;AAC/B,kDAAc,MAAM,SAAS,EAAE,CAAC,CAAC;IACjC;EAED,SAAS,qBAAqB,MAAqC;GAClE,MAAM,4BAA4B,mBAAmB,QAAQ;AAK7D,OAAI,6BAAe,0BAA0B,CAC5C,QAAO,EAAE,IAAI,2BAA0B;AAGxC,UAAO;IACN,IAAI;IACJ,cAAc,MAAM;IACpB,WAAW;IACZ;;EAGD,MAAM,6CAAmE;AACxE,UAAO;IACN,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,UAAU,qBAAqB,WAAW;IAC1C,WAAW,qBAAqB,YAAY;IAC5C,cAAc,qBAAqB,eAAe;IAClD,QAAQ,qBAAqB,SAAS;IACtC,IAAI,qBAAqB,KAAK;IAC9B,aAAa,qBAAqB,WAAW;IAC7C,eAAe,qBAAqB,YAAY;IAChD,mBAAmB,qBAAqB,OAAO;IAC/C,qBAAqB,qBAAqB,QAAQ;IAClD,OAAO,qBAAqB,QAAQ;IACpC,OAAO,qBAAqB,QAAQ;IACpC,WAAW,qBAAqB,YAAY;IAC5C,OAAO,qBAAqB,QAAQ;IACpC,MAAM,qBAAqB,OAAO;IACnC;IACA;;UAKO,SAAA,MAAS,qDAGd,0CAAA;;IAFA,UAAU,SAAA;IACV,uBAAqB,mBAAA;uDAED,QAAA,wFAAe,QAAA,SAAQ,EAAA,EAAA,KAAA,GAAA,CAAA"}