@prismicio/vue 4.2.3 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,11 +47,16 @@ const usePrismicLink = (props) => {
47
47
  return null;
48
48
  }
49
49
  });
50
+ const text = vue.computed(() => {
51
+ const field = vue.unref(props.field);
52
+ return field && "text" in field ? field.text : void 0;
53
+ });
50
54
  return {
51
55
  type,
52
56
  href,
53
57
  target,
54
- rel
58
+ rel,
59
+ text
55
60
  };
56
61
  };
57
62
  const PrismicLinkImpl = /* @__PURE__ */ vue.defineComponent({
@@ -96,10 +101,10 @@ const PrismicLinkImpl = /* @__PURE__ */ vue.defineComponent({
96
101
  if (!props.field) {
97
102
  return () => null;
98
103
  }
99
- const { type, href, target, rel } = usePrismicLink(props);
104
+ const { type, href, target, rel, text } = usePrismicLink(props);
100
105
  return () => {
101
106
  const parent = type.value === "a" ? "a" : simplyResolveComponent.simplyResolveComponent(type.value);
102
- const computedSlots = getSlots.getSlots(parent, slots, vue.reactive({ href: href.value }));
107
+ const computedSlots = getSlots.getSlots(parent, slots, vue.reactive({ href: href.value, text: text.value }), text.value);
103
108
  if (typeof parent === "string") {
104
109
  return vue.h(parent, { href: href.value, target: target.value, rel: rel.value }, computedSlots);
105
110
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLink,\n} from \"@prismicio/client\";\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\";\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","re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AO,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,MAEf;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
1
+ {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLink,\n} from \"@prismicio/client\";\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\";\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\t/**\n\t * Resolved link text.\n\t */\n\ttext: ComputedRef<string | undefined>;\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\tconst text = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\treturn field && \"text\" in field ? field.text : undefined;\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t\ttext,\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, text } = 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, text: text.value }),\n\t\t\t\ttext.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":";;;;;;;;AAiCA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA+G1B,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,mBA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QACA,EAAE,IAAI,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,SACjD,aAAa;AAAA,MAEf;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
@@ -84,6 +84,10 @@ export type UsePrismicLinkReturnType = {
84
84
  * Resolved anchor `rel` value.
85
85
  */
86
86
  rel: ComputedRef<string | null>;
87
+ /**
88
+ * Resolved link text.
89
+ */
90
+ text: ComputedRef<string | undefined>;
87
91
  };
88
92
  /**
89
93
  * A low level composable that returns resolved information about a Prismic link
@@ -45,11 +45,16 @@ const usePrismicLink = (props) => {
45
45
  return null;
46
46
  }
47
47
  });
48
+ const text = computed(() => {
49
+ const field = unref(props.field);
50
+ return field && "text" in field ? field.text : void 0;
51
+ });
48
52
  return {
49
53
  type,
50
54
  href,
51
55
  target,
52
- rel
56
+ rel,
57
+ text
53
58
  };
54
59
  };
55
60
  const PrismicLinkImpl = /* @__PURE__ */ defineComponent({
@@ -94,10 +99,10 @@ const PrismicLinkImpl = /* @__PURE__ */ defineComponent({
94
99
  if (!props.field) {
95
100
  return () => null;
96
101
  }
97
- const { type, href, target, rel } = usePrismicLink(props);
102
+ const { type, href, target, rel, text } = usePrismicLink(props);
98
103
  return () => {
99
104
  const parent = type.value === "a" ? "a" : simplyResolveComponent(type.value);
100
- const computedSlots = getSlots(parent, slots, reactive({ href: href.value }));
105
+ const computedSlots = getSlots(parent, slots, reactive({ href: href.value, text: text.value }), text.value);
101
106
  if (typeof parent === "string") {
102
107
  return h(parent, { href: href.value, target: target.value, rel: rel.value }, computedSlots);
103
108
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.js","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLink,\n} from \"@prismicio/client\";\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\";\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":";;;;;;AAiCA,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,IACpE;AAAA,EAAA,CACA;AACK,QAAA,MAAM,SAAS,MAAK;;AACnBC,UAAAA,OAAM,MAAM,MAAM,GAAG;AAEvB,QAAA,OAAOA,SAAQ,aAAa;AACxBA,aAAAA;AAAAA,IAAA,WACG,OAAO,UAAU,UAAU;AAC/B,YAAA,0BAA0B,MAAM,MAAM,uBAAuB;AAE/D,UAAA,OAAO,4BAA4B,aAAa;AAC5C,eAAA;AAAA,MAAA,OACD;AACN,e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AAO,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,MAEf;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,cAAc;"}
1
+ {"version":3,"file":"PrismicLink.js","sources":["../../../src/components/PrismicLink.ts"],"sourcesContent":["import {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLink,\n} from \"@prismicio/client\";\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\";\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\t/**\n\t * Resolved link text.\n\t */\n\ttext: ComputedRef<string | undefined>;\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\tconst text = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\treturn field && \"text\" in field ? field.text : undefined;\n\t});\n\n\treturn {\n\t\ttype,\n\t\thref,\n\t\ttarget,\n\t\trel,\n\t\ttext,\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, text } = 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, text: text.value }),\n\t\t\t\ttext.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":";;;;;;AAiCA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,iCAAiC;AA+G1B,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,UA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MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,KAAK;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,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,IACd;AAEM,UAAA,EAAE,MAAM,MAAM,QAAQ,KAAK,SAAS,eAAe,KAAK;AAE9D,WAAO,MAAK;AACX,YAAM,SACL,KAAK,UAAU,MAAM,MAAM,uBAAuB,KAAK,KAAK;AAC7D,YAAM,gBAAgB,SACrB,QACA,OACA,SAAS,EAAE,MAAM,KAAK,OAAO,MAAM,KAAK,MAAO,CAAA,GAC/C,KAAK,KAAK;AAGP,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,MAEf;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,cAAc;"}
@@ -14,10 +14,7 @@ import { ClientComposableReturnType, ComposableOnlyParameters } from "./useState
14
14
  *
15
15
  * @see Underlying `@prismicio/client` method {@link Client.get}
16
16
  */
17
- export declare const usePrismicDocuments: <TDocument extends PrismicDocument>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
18
- fetchOptions?: import("@prismicio/client").RequestInitLike;
19
- signal?: import("@prismicio/client").AbortSignalLike;
20
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
17
+ export declare const usePrismicDocuments: <TDocument extends PrismicDocument>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
21
18
  /**
22
19
  * A composable that queries content from the Prismic repository and returns
23
20
  * only the first result, if any.
@@ -33,10 +30,7 @@ export declare const usePrismicDocuments: <TDocument extends PrismicDocument>(pa
33
30
  *
34
31
  * @see Underlying `@prismicio/client` method {@link Client.getFirst}
35
32
  */
36
- export declare const useFirstPrismicDocument: <TDocument extends PrismicDocument>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
37
- fetchOptions?: import("@prismicio/client").RequestInitLike;
38
- signal?: import("@prismicio/client").AbortSignalLike;
39
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
33
+ export declare const useFirstPrismicDocument: <TDocument extends PrismicDocument>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
40
34
  /**
41
35
  * A composable that queries a document from the Prismic repository with a
42
36
  * specific ID.
@@ -53,10 +47,7 @@ export declare const useFirstPrismicDocument: <TDocument extends PrismicDocument
53
47
  *
54
48
  * @see Underlying `@prismicio/client` method {@link Client.getByID}
55
49
  */
56
- export declare const usePrismicDocumentByID: <TDocument extends PrismicDocument>(id: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
57
- fetchOptions?: import("@prismicio/client").RequestInitLike;
58
- signal?: import("@prismicio/client").AbortSignalLike;
59
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
50
+ export declare const usePrismicDocumentByID: <TDocument extends PrismicDocument>(id: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
60
51
  /**
61
52
  * A composable that queries documents from the Prismic repository with specific
62
53
  * IDs.
@@ -73,10 +64,7 @@ export declare const usePrismicDocumentByID: <TDocument extends PrismicDocument>
73
64
  *
74
65
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
75
66
  */
76
- export declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocument>(ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
77
- fetchOptions?: import("@prismicio/client").RequestInitLike;
78
- signal?: import("@prismicio/client").AbortSignalLike;
79
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
67
+ export declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocument>(ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
80
68
  /**
81
69
  * A composable that queries all documents from the Prismic repository with
82
70
  * specific IDs.
@@ -95,10 +83,7 @@ export declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocumen
95
83
  */
96
84
  export declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocument>(ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
97
85
  limit?: number;
98
- } & {
99
- fetchOptions?: import("@prismicio/client").RequestInitLike;
100
- signal?: import("@prismicio/client").AbortSignalLike;
101
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
86
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
102
87
  /**
103
88
  * A composable that queries a document from the Prismic repository with a
104
89
  * specific UID and Custom Type.
@@ -116,10 +101,7 @@ export declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocu
116
101
  *
117
102
  * @see Underlying `@prismicio/client` method {@link Client.getByUID}
118
103
  */
119
- export declare const usePrismicDocumentByUID: <TDocument extends PrismicDocument>(documentType: any, uid: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
120
- fetchOptions?: import("@prismicio/client").RequestInitLike;
121
- signal?: import("@prismicio/client").AbortSignalLike;
122
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
104
+ export declare const usePrismicDocumentByUID: <TDocument extends PrismicDocument>(documentType: any, uid: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
123
105
  /**
124
106
  * A composable that queries documents from the Prismic repository with specific
125
107
  * UIDs.
@@ -137,10 +119,7 @@ export declare const usePrismicDocumentByUID: <TDocument extends PrismicDocument
137
119
  *
138
120
  * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
139
121
  */
140
- export declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocument>(documentType: any, uids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
141
- fetchOptions?: import("@prismicio/client").RequestInitLike;
142
- signal?: import("@prismicio/client").AbortSignalLike;
143
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
122
+ export declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocument>(documentType: any, uids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
144
123
  /**
145
124
  * A composable that queries all documents from the Prismic repository with
146
125
  * specific UIDs.
@@ -160,10 +139,7 @@ export declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocume
160
139
  */
161
140
  export declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDocument>(documentType: any, ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
162
141
  limit?: number;
163
- } & {
164
- fetchOptions?: import("@prismicio/client").RequestInitLike;
165
- signal?: import("@prismicio/client").AbortSignalLike;
166
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
142
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
167
143
  /**
168
144
  * A composable that queries a singleton document from the Prismic repository
169
145
  * for a specific Custom Type.
@@ -180,10 +156,7 @@ export declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDoc
180
156
  *
181
157
  * @see Underlying `@prismicio/client` method {@link Client.getSingle}
182
158
  */
183
- export declare const useSinglePrismicDocument: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
184
- fetchOptions?: import("@prismicio/client").RequestInitLike;
185
- signal?: import("@prismicio/client").AbortSignalLike;
186
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
159
+ export declare const useSinglePrismicDocument: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
187
160
  /**
188
161
  * A composable that queries documents from the Prismic repository for a
189
162
  * specific Custom Type.
@@ -200,10 +173,7 @@ export declare const useSinglePrismicDocument: <TDocument extends PrismicDocumen
200
173
  *
201
174
  * @see Underlying `@prismicio/client` method {@link Client.getByType}
202
175
  */
203
- export declare const usePrismicDocumentsByType: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
204
- fetchOptions?: import("@prismicio/client").RequestInitLike;
205
- signal?: import("@prismicio/client").AbortSignalLike;
206
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
176
+ export declare const usePrismicDocumentsByType: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
207
177
  /**
208
178
  * A composable that queries all documents from the Prismic repository for a
209
179
  * specific Custom Type.
@@ -222,10 +192,7 @@ export declare const usePrismicDocumentsByType: <TDocument extends PrismicDocume
222
192
  */
223
193
  export declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
224
194
  limit?: number;
225
- } & {
226
- fetchOptions?: import("@prismicio/client").RequestInitLike;
227
- signal?: import("@prismicio/client").AbortSignalLike;
228
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
195
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
229
196
  /**
230
197
  * A composable that queries documents from the Prismic repository with a
231
198
  * specific tag.
@@ -242,10 +209,7 @@ export declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDoc
242
209
  *
243
210
  * @see Underlying `@prismicio/client` method {@link Client.getByTag}
244
211
  */
245
- export declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocument>(tag: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
246
- fetchOptions?: import("@prismicio/client").RequestInitLike;
247
- signal?: import("@prismicio/client").AbortSignalLike;
248
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
212
+ export declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocument>(tag: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
249
213
  /**
250
214
  * A composable that queries all documents from the Prismic repository with a
251
215
  * specific tag.
@@ -264,10 +228,7 @@ export declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocumen
264
228
  */
265
229
  export declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocument>(tag: string, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
266
230
  limit?: number;
267
- } & {
268
- fetchOptions?: import("@prismicio/client").RequestInitLike;
269
- signal?: import("@prismicio/client").AbortSignalLike;
270
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
231
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
271
232
  /**
272
233
  * A composable that queries documents from the Prismic repository with specific
273
234
  * tags. A document must be tagged with all of the queried tags to be included.
@@ -284,10 +245,7 @@ export declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocu
284
245
  *
285
246
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
286
247
  */
287
- export declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
288
- fetchOptions?: import("@prismicio/client").RequestInitLike;
289
- signal?: import("@prismicio/client").AbortSignalLike;
290
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
248
+ export declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
291
249
  /**
292
250
  * A composable that queries all documents from the Prismic repository with
293
251
  * specific tags. A document must be tagged with all of the queried tags to be
@@ -307,10 +265,7 @@ export declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDo
307
265
  */
308
266
  export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
309
267
  limit?: number;
310
- } & {
311
- fetchOptions?: import("@prismicio/client").RequestInitLike;
312
- signal?: import("@prismicio/client").AbortSignalLike;
313
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
268
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
314
269
  /**
315
270
  * A composable that queries documents from the Prismic repository with specific
316
271
  * tags. A document must be tagged with at least one of the queried tags to be
@@ -328,10 +283,7 @@ export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends Prismi
328
283
  *
329
284
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
330
285
  */
331
- export declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
332
- fetchOptions?: import("@prismicio/client").RequestInitLike;
333
- signal?: import("@prismicio/client").AbortSignalLike;
334
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
286
+ export declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
335
287
  /**
336
288
  * A composable that queries all documents from the Prismic repository with
337
289
  * specific tags. A document must be tagged with at least one of the queried
@@ -351,10 +303,7 @@ export declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDo
351
303
  */
352
304
  export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
353
305
  limit?: number;
354
- } & {
355
- fetchOptions?: import("@prismicio/client").RequestInitLike;
356
- signal?: import("@prismicio/client").AbortSignalLike;
357
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
306
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
358
307
  /**
359
308
  * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be
360
309
  * slower and require more resources than other composables. Prefer using other
@@ -378,7 +327,4 @@ export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends Prismi
378
327
  */
379
328
  export declare const dangerouslyUseAllPrismicDocuments: <TDocument extends PrismicDocument>(params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
380
329
  limit?: number;
381
- } & {
382
- fetchOptions?: import("@prismicio/client").RequestInitLike;
383
- signal?: import("@prismicio/client").AbortSignalLike;
384
- } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
330
+ } & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const getSlots = (parent, slots, defaultPayload) => {
3
+ const getSlots = (parent, slots, defaultPayload, fallback) => {
4
4
  if (typeof parent === "string") {
5
- return slots.default && slots.default(defaultPayload);
5
+ return slots.default ? slots.default(defaultPayload) : fallback;
6
6
  } else {
7
7
  if (slots.default) {
8
8
  const content = slots.default(defaultPayload);
9
- return {
9
+ return content.length ? {
10
10
  ...slots,
11
11
  default: () => content
12
- };
12
+ } : fallback;
13
13
  } else {
14
- return slots;
14
+ return fallback;
15
15
  }
16
16
  }
17
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getSlots.cjs","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"getSlots.cjs","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n\tfallback?: string,\n): VNode[] | undefined | Slots | string => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default ? slots.default(defaultPayload) : fallback;\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn content.length\n\t\t\t\t? {\n\t\t\t\t\t\t...slots,\n\t\t\t\t\t\tdefault: () => content,\n\t\t\t\t }\n\t\t\t\t: fallback;\n\t\t} else {\n\t\t\treturn fallback;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAcO,MAAM,WAAW,CACvB,QACA,OACA,gBACA,aACyC;AACrC,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,UAAU,MAAM,QAAQ,cAAc,IAAI;AAAA,EAAA,OACjD;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAE5C,aAAO,QAAQ,SACZ;AAAA,QACA,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAEf,IAAA;AAAA,IAAA,OACG;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;;"}
@@ -11,4 +11,4 @@ import { ConcreteComponent, Slots, VNode } from "vue";
11
11
  *
12
12
  * @internal
13
13
  */
14
- export declare const getSlots: (parent: string | ConcreteComponent, slots: Slots, defaultPayload?: unknown) => VNode[] | undefined | Slots;
14
+ export declare const getSlots: (parent: string | ConcreteComponent, slots: Slots, defaultPayload?: unknown, fallback?: string) => VNode[] | undefined | Slots | string;
@@ -1,15 +1,15 @@
1
- const getSlots = (parent, slots, defaultPayload) => {
1
+ const getSlots = (parent, slots, defaultPayload, fallback) => {
2
2
  if (typeof parent === "string") {
3
- return slots.default && slots.default(defaultPayload);
3
+ return slots.default ? slots.default(defaultPayload) : fallback;
4
4
  } else {
5
5
  if (slots.default) {
6
6
  const content = slots.default(defaultPayload);
7
- return {
7
+ return content.length ? {
8
8
  ...slots,
9
9
  default: () => content
10
- };
10
+ } : fallback;
11
11
  } else {
12
- return slots;
12
+ return fallback;
13
13
  }
14
14
  }
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getSlots.js","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":"AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"getSlots.js","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n\tfallback?: string,\n): VNode[] | undefined | Slots | string => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default ? slots.default(defaultPayload) : fallback;\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn content.length\n\t\t\t\t? {\n\t\t\t\t\t\t...slots,\n\t\t\t\t\t\tdefault: () => content,\n\t\t\t\t }\n\t\t\t\t: fallback;\n\t\t} else {\n\t\t\treturn fallback;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":"AAcO,MAAM,WAAW,CACvB,QACA,OACA,gBACA,aACyC;AACrC,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,UAAU,MAAM,QAAQ,cAAc,IAAI;AAAA,EAAA,OACjD;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAE5C,aAAO,QAAQ,SACZ;AAAA,QACA,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAEf,IAAA;AAAA,IAAA,OACG;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/vue",
3
- "version": "4.2.3",
3
+ "version": "4.3.0",
4
4
  "description": "Vue plugin, components, and composables to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -57,12 +57,12 @@
57
57
  "test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
58
58
  },
59
59
  "dependencies": {
60
- "@prismicio/client": "^7.4.0",
60
+ "@prismicio/client": "^7.11.0",
61
61
  "isomorphic-unfetch": "^3.1.0",
62
- "vue-router": "^4.3.0"
62
+ "vue-router": "^4.4.3"
63
63
  },
64
64
  "devDependencies": {
65
- "@prismicio/mock": "^0.3.1",
65
+ "@prismicio/mock": "0.4.0",
66
66
  "@size-limit/preset-small-lib": "^8.2.6",
67
67
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
68
68
  "@types/jsdom-global": "^3.0.7",
@@ -70,25 +70,25 @@
70
70
  "@typescript-eslint/parser": "^5.62.0",
71
71
  "@vitejs/plugin-vue": "^4.6.2",
72
72
  "@vitest/coverage-v8": "^0.34.6",
73
- "@vue/compiler-sfc": "^3.4.21",
73
+ "@vue/compiler-sfc": "^3.4.38",
74
74
  "@vue/eslint-config-typescript": "^11.0.3",
75
- "@vue/test-utils": "^2.4.5",
75
+ "@vue/test-utils": "^2.4.6",
76
76
  "eslint": "^8.57.0",
77
77
  "eslint-config-prettier": "^8.10.0",
78
78
  "eslint-plugin-prettier": "^4.2.1",
79
79
  "eslint-plugin-tsdoc": "^0.2.17",
80
- "eslint-plugin-vue": "^9.24.0",
80
+ "eslint-plugin-vue": "^9.27.0",
81
81
  "jsdom": "^24.0.0",
82
82
  "jsdom-global": "^3.0.2",
83
83
  "prettier": "^2.8.8",
84
84
  "prettier-plugin-jsdoc": "^0.4.2",
85
85
  "size-limit": "^8.2.6",
86
86
  "standard-version": "^9.5.0",
87
- "typescript": "^5.4.3",
88
- "vite": "^4.5.3",
87
+ "typescript": "^5.5.4",
88
+ "vite": "^5.4.2",
89
89
  "vite-plugin-sdk": "^0.1.2",
90
90
  "vitest": "^0.34.6",
91
- "vue": "^3.4.21"
91
+ "vue": "^3.4.38"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "vue": "^3.0.0"
@@ -137,6 +137,11 @@ export type UsePrismicLinkReturnType = {
137
137
  * Resolved anchor `rel` value.
138
138
  */
139
139
  rel: ComputedRef<string | null>;
140
+
141
+ /**
142
+ * Resolved link text.
143
+ */
144
+ text: ComputedRef<string | undefined>;
140
145
  };
141
146
 
142
147
  /**
@@ -204,11 +209,18 @@ export const usePrismicLink = (
204
209
  }
205
210
  });
206
211
 
212
+ const text = computed(() => {
213
+ const field = unref(props.field);
214
+
215
+ return field && "text" in field ? field.text : undefined;
216
+ });
217
+
207
218
  return {
208
219
  type,
209
220
  href,
210
221
  target,
211
222
  rel,
223
+ text,
212
224
  };
213
225
  };
214
226
 
@@ -265,7 +277,7 @@ export const PrismicLinkImpl = /*#__PURE__*/ defineComponent({
265
277
  return () => null;
266
278
  }
267
279
 
268
- const { type, href, target, rel } = usePrismicLink(props);
280
+ const { type, href, target, rel, text } = usePrismicLink(props);
269
281
 
270
282
  return () => {
271
283
  const parent =
@@ -273,7 +285,8 @@ export const PrismicLinkImpl = /*#__PURE__*/ defineComponent({
273
285
  const computedSlots = getSlots(
274
286
  parent,
275
287
  slots,
276
- reactive({ href: href.value }),
288
+ reactive({ href: href.value, text: text.value }),
289
+ text.value,
277
290
  );
278
291
 
279
292
  if (typeof parent === "string") {
@@ -16,19 +16,22 @@ export const getSlots = (
16
16
  parent: string | ConcreteComponent,
17
17
  slots: Slots,
18
18
  defaultPayload?: unknown,
19
- ): VNode[] | undefined | Slots => {
19
+ fallback?: string,
20
+ ): VNode[] | undefined | Slots | string => {
20
21
  if (typeof parent === "string") {
21
- return slots.default && slots.default(defaultPayload);
22
+ return slots.default ? slots.default(defaultPayload) : fallback;
22
23
  } else {
23
24
  if (slots.default) {
24
25
  const content = slots.default(defaultPayload);
25
26
 
26
- return {
27
- ...slots,
28
- default: () => content,
29
- };
27
+ return content.length
28
+ ? {
29
+ ...slots,
30
+ default: () => content,
31
+ }
32
+ : fallback;
30
33
  } else {
31
- return slots;
34
+ return fallback;
32
35
  }
33
36
  }
34
37
  };