@prismicio/vue 4.2.2 → 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.
- package/dist/components/PrismicEmbed.d.ts +4 -2
- package/dist/components/PrismicImage.d.ts +11 -9
- package/dist/components/PrismicLink.cjs +8 -3
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +10 -4
- package/dist/components/PrismicLink.js +8 -3
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.d.ts +8 -6
- package/dist/components/PrismicText.d.ts +4 -2
- package/dist/components/SliceZone.d.ts +17 -15
- package/dist/composables.d.ts +32 -86
- package/dist/globalExtensions.d.ts +1 -1
- package/dist/lib/getSlots.cjs +5 -5
- package/dist/lib/getSlots.cjs.map +1 -1
- package/dist/lib/getSlots.d.ts +1 -1
- package/dist/lib/getSlots.js +5 -5
- package/dist/lib/getSlots.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
- package/package.json +10 -10
- package/src/components/PrismicLink.ts +15 -2
- package/src/globalExtensions.ts +1 -1
- package/src/lib/getSlots.ts +10 -7
|
@@ -52,6 +52,8 @@ export declare const PrismicEmbedImpl: DefineComponent<{
|
|
|
52
52
|
* @see Component props {@link PrismicEmbedProps}
|
|
53
53
|
* @see Templating embed fields {@link https://prismic.io/docs/technologies/vue-template-content#embeds}
|
|
54
54
|
*/
|
|
55
|
-
export declare const PrismicEmbed:
|
|
56
|
-
|
|
55
|
+
export declare const PrismicEmbed: {
|
|
56
|
+
new (): {
|
|
57
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicEmbedProps;
|
|
58
|
+
};
|
|
57
59
|
};
|
|
@@ -103,17 +103,17 @@ export declare const PrismicImageImpl: DefineComponent<{
|
|
|
103
103
|
required: false;
|
|
104
104
|
};
|
|
105
105
|
imgixParams: {
|
|
106
|
-
type: PropType<
|
|
106
|
+
type: PropType<Parameters<typeof asImageSrc>[1]>;
|
|
107
107
|
default: undefined;
|
|
108
108
|
required: false;
|
|
109
109
|
};
|
|
110
110
|
widths: {
|
|
111
|
-
type: PropType<
|
|
111
|
+
type: PropType<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults">;
|
|
112
112
|
default: undefined;
|
|
113
113
|
required: false;
|
|
114
114
|
};
|
|
115
115
|
pixelDensities: {
|
|
116
|
-
type: PropType<
|
|
116
|
+
type: PropType<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults">;
|
|
117
117
|
default: undefined;
|
|
118
118
|
required: false;
|
|
119
119
|
};
|
|
@@ -130,17 +130,17 @@ export declare const PrismicImageImpl: DefineComponent<{
|
|
|
130
130
|
required: false;
|
|
131
131
|
};
|
|
132
132
|
imgixParams: {
|
|
133
|
-
type: PropType<
|
|
133
|
+
type: PropType<Parameters<typeof asImageSrc>[1]>;
|
|
134
134
|
default: undefined;
|
|
135
135
|
required: false;
|
|
136
136
|
};
|
|
137
137
|
widths: {
|
|
138
|
-
type: PropType<
|
|
138
|
+
type: PropType<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults">;
|
|
139
139
|
default: undefined;
|
|
140
140
|
required: false;
|
|
141
141
|
};
|
|
142
142
|
pixelDensities: {
|
|
143
|
-
type: PropType<
|
|
143
|
+
type: PropType<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults">;
|
|
144
144
|
default: undefined;
|
|
145
145
|
required: false;
|
|
146
146
|
};
|
|
@@ -148,7 +148,7 @@ export declare const PrismicImageImpl: DefineComponent<{
|
|
|
148
148
|
widths: number[] | "thumbnails" | "defaults" | undefined;
|
|
149
149
|
pixelDensities: number[] | "defaults" | undefined;
|
|
150
150
|
imageComponent: string | ConcreteComponent | Raw<DefineComponent>;
|
|
151
|
-
imgixParams: import("imgix-url-builder").ImgixURLParams | undefined;
|
|
151
|
+
imgixParams: import("imgix-url-builder/*").ImgixURLParams | undefined;
|
|
152
152
|
}, {}>;
|
|
153
153
|
/**
|
|
154
154
|
* Component to render a Prismic image field.
|
|
@@ -156,6 +156,8 @@ export declare const PrismicImageImpl: DefineComponent<{
|
|
|
156
156
|
* @see Component props {@link PrismicImageProps}
|
|
157
157
|
* @see Templating image fields {@link https://prismic.io/docs/technologies/vue-template-content#images}
|
|
158
158
|
*/
|
|
159
|
-
export declare const PrismicImage:
|
|
160
|
-
|
|
159
|
+
export declare const PrismicImage: {
|
|
160
|
+
new (): {
|
|
161
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicImageProps;
|
|
162
|
+
};
|
|
161
163
|
};
|
|
@@ -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","reactive","h"],"mappings":"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"}
|
|
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":"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"}
|
|
@@ -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
|
|
@@ -101,7 +105,7 @@ export declare const usePrismicLink: (props: UsePrismicLinkOptions) => UsePrismi
|
|
|
101
105
|
*/
|
|
102
106
|
export declare const PrismicLinkImpl: DefineComponent<{
|
|
103
107
|
field: {
|
|
104
|
-
type: PropType<
|
|
108
|
+
type: PropType<LinkField | PrismicDocument>;
|
|
105
109
|
required: true;
|
|
106
110
|
};
|
|
107
111
|
linkResolver: {
|
|
@@ -138,7 +142,7 @@ export declare const PrismicLinkImpl: DefineComponent<{
|
|
|
138
142
|
[key: string]: any;
|
|
139
143
|
}>), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
140
144
|
field: {
|
|
141
|
-
type: PropType<
|
|
145
|
+
type: PropType<LinkField | PrismicDocument>;
|
|
142
146
|
required: true;
|
|
143
147
|
};
|
|
144
148
|
linkResolver: {
|
|
@@ -185,6 +189,8 @@ export declare const PrismicLinkImpl: DefineComponent<{
|
|
|
185
189
|
* @see Component props {@link PrismicLinkProps}
|
|
186
190
|
* @see Templating link fields {@link https://prismic.io/docs/technologies/vue-template-content#links-and-content-relationships}
|
|
187
191
|
*/
|
|
188
|
-
export declare const PrismicLink:
|
|
189
|
-
|
|
192
|
+
export declare const PrismicLink: {
|
|
193
|
+
new (): {
|
|
194
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicLinkProps;
|
|
195
|
+
};
|
|
190
196
|
};
|
|
@@ -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":"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"}
|
|
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,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,eAAO,SAAO,aAAQ,eAAR,mBAAoB,iCACjC,cACE,QAAQ,WAAW,8BACnB;AAAA,MACJ;AAAA,IAAA,OACM;AACC,aAAA;AAAA,IACR;AAAA,EAAA,CACA;AAEK,QAAA,OAAO,SAAS,MAAK;AACpB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,WAAO,SAAS,UAAU,QAAQ,MAAM,OAAO;AAAA,EAAA,CAC/C;AAEM,SAAA;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEF;AAOO,MAAM,kBAAgD,gCAAA;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,QAAQ;AAAA,MACP,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;"}
|
|
@@ -88,12 +88,12 @@ export declare const PrismicRichTextImpl: DefineComponent<{
|
|
|
88
88
|
required: false;
|
|
89
89
|
};
|
|
90
90
|
serializer: {
|
|
91
|
-
type: PropType<
|
|
91
|
+
type: PropType<HTMLFunctionSerializer | HTMLMapSerializer>;
|
|
92
92
|
default: undefined;
|
|
93
93
|
required: false;
|
|
94
94
|
};
|
|
95
95
|
htmlSerializer: {
|
|
96
|
-
type: PropType<
|
|
96
|
+
type: PropType<HTMLFunctionSerializer | HTMLMapSerializer>;
|
|
97
97
|
default: undefined;
|
|
98
98
|
required: false;
|
|
99
99
|
};
|
|
@@ -121,12 +121,12 @@ export declare const PrismicRichTextImpl: DefineComponent<{
|
|
|
121
121
|
required: false;
|
|
122
122
|
};
|
|
123
123
|
serializer: {
|
|
124
|
-
type: PropType<
|
|
124
|
+
type: PropType<HTMLFunctionSerializer | HTMLMapSerializer>;
|
|
125
125
|
default: undefined;
|
|
126
126
|
required: false;
|
|
127
127
|
};
|
|
128
128
|
htmlSerializer: {
|
|
129
|
-
type: PropType<
|
|
129
|
+
type: PropType<HTMLFunctionSerializer | HTMLMapSerializer>;
|
|
130
130
|
default: undefined;
|
|
131
131
|
required: false;
|
|
132
132
|
};
|
|
@@ -154,6 +154,8 @@ export declare const PrismicRichTextImpl: DefineComponent<{
|
|
|
154
154
|
* @see Component props {@link PrismicRichTextProps}
|
|
155
155
|
* @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
|
|
156
156
|
*/
|
|
157
|
-
export declare const PrismicRichText:
|
|
158
|
-
|
|
157
|
+
export declare const PrismicRichText: {
|
|
158
|
+
new (): {
|
|
159
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicRichTextProps;
|
|
160
|
+
};
|
|
159
161
|
};
|
|
@@ -112,6 +112,8 @@ export declare const PrismicTextImpl: DefineComponent<{
|
|
|
112
112
|
* @see Component props {@link PrismicTextProps}
|
|
113
113
|
* @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
|
|
114
114
|
*/
|
|
115
|
-
export declare const PrismicText:
|
|
116
|
-
|
|
115
|
+
export declare const PrismicText: {
|
|
116
|
+
new (): {
|
|
117
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicTextProps;
|
|
118
|
+
};
|
|
117
119
|
};
|
|
@@ -143,7 +143,7 @@ export type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, T
|
|
|
143
143
|
*
|
|
144
144
|
* @returns Props object to use with {@link defineComponent}
|
|
145
145
|
*/
|
|
146
|
-
export declare const getSliceComponentProps: <TSlice extends SliceLike
|
|
146
|
+
export declare const getSliceComponentProps: <TSlice extends SliceLike = any, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
|
|
147
147
|
/**
|
|
148
148
|
* A Vue component to be rendered for each instance of its Slice.
|
|
149
149
|
*
|
|
@@ -160,9 +160,9 @@ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknow
|
|
|
160
160
|
*/
|
|
161
161
|
export declare const TODOSliceComponent: import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any, any> | FunctionalComponent<any, {}, any, {}> | {
|
|
162
162
|
new (...args: any[]): any;
|
|
163
|
-
__isFragment?:
|
|
164
|
-
__isTeleport?:
|
|
165
|
-
__isSuspense?:
|
|
163
|
+
__isFragment?: never;
|
|
164
|
+
__isTeleport?: never;
|
|
165
|
+
__isSuspense?: never;
|
|
166
166
|
} | FunctionalComponent<{
|
|
167
167
|
slice: SliceLike;
|
|
168
168
|
}, {}, any, {}> | FunctionalComponent<SliceComponentProps<any, unknown>, {}, any, {}>;
|
|
@@ -209,7 +209,7 @@ export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext =
|
|
|
209
209
|
*
|
|
210
210
|
* @returns A new optimized record of {@link SliceZoneComponents}
|
|
211
211
|
*/
|
|
212
|
-
export declare const defineSliceZoneComponents: <TSlice extends SliceLike
|
|
212
|
+
export declare const defineSliceZoneComponents: <TSlice extends SliceLike = any, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
|
|
213
213
|
/**
|
|
214
214
|
* Arguments for a `<SliceZone>` `resolver` function.
|
|
215
215
|
*/
|
|
@@ -292,16 +292,16 @@ export type SliceZoneProps<TContext = unknown> = {
|
|
|
292
292
|
*/
|
|
293
293
|
export declare const SliceZoneImpl: DefineComponent<{
|
|
294
294
|
slices: {
|
|
295
|
-
type: PropType<SliceZoneLike<SliceLike
|
|
295
|
+
type: PropType<SliceZoneLike<SliceLike & Record<string, unknown>>>;
|
|
296
296
|
required: true;
|
|
297
297
|
};
|
|
298
298
|
components: {
|
|
299
|
-
type: PropType<SliceZoneComponents
|
|
299
|
+
type: PropType<SliceZoneComponents>;
|
|
300
300
|
default: undefined;
|
|
301
301
|
required: false;
|
|
302
302
|
};
|
|
303
303
|
resolver: {
|
|
304
|
-
type: PropType<SliceZoneResolver
|
|
304
|
+
type: PropType<SliceZoneResolver>;
|
|
305
305
|
default: undefined;
|
|
306
306
|
required: false;
|
|
307
307
|
};
|
|
@@ -311,7 +311,7 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
311
311
|
required: false;
|
|
312
312
|
};
|
|
313
313
|
defaultComponent: {
|
|
314
|
-
type: PropType<SliceComponentType
|
|
314
|
+
type: PropType<SliceComponentType>;
|
|
315
315
|
default: undefined;
|
|
316
316
|
required: false;
|
|
317
317
|
};
|
|
@@ -326,16 +326,16 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
326
326
|
[key: string]: any;
|
|
327
327
|
}>[]), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
328
328
|
slices: {
|
|
329
|
-
type: PropType<SliceZoneLike<SliceLike
|
|
329
|
+
type: PropType<SliceZoneLike<SliceLike & Record<string, unknown>>>;
|
|
330
330
|
required: true;
|
|
331
331
|
};
|
|
332
332
|
components: {
|
|
333
|
-
type: PropType<SliceZoneComponents
|
|
333
|
+
type: PropType<SliceZoneComponents>;
|
|
334
334
|
default: undefined;
|
|
335
335
|
required: false;
|
|
336
336
|
};
|
|
337
337
|
resolver: {
|
|
338
|
-
type: PropType<SliceZoneResolver
|
|
338
|
+
type: PropType<SliceZoneResolver>;
|
|
339
339
|
default: undefined;
|
|
340
340
|
required: false;
|
|
341
341
|
};
|
|
@@ -345,7 +345,7 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
345
345
|
required: false;
|
|
346
346
|
};
|
|
347
347
|
defaultComponent: {
|
|
348
|
-
type: PropType<SliceComponentType
|
|
348
|
+
type: PropType<SliceComponentType>;
|
|
349
349
|
default: undefined;
|
|
350
350
|
required: false;
|
|
351
351
|
};
|
|
@@ -367,7 +367,9 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
367
367
|
* @see Component props {@link SliceZoneProps}
|
|
368
368
|
* @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}
|
|
369
369
|
*/
|
|
370
|
-
export declare const SliceZone:
|
|
371
|
-
|
|
370
|
+
export declare const SliceZone: {
|
|
371
|
+
new (): {
|
|
372
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & SliceZoneProps;
|
|
373
|
+
};
|
|
372
374
|
};
|
|
373
375
|
export {};
|
package/dist/composables.d.ts
CHANGED
|
@@ -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
|
|
18
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
19
|
-
signal?: any;
|
|
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<Rec
|
|
|
33
30
|
*
|
|
34
31
|
* @see Underlying `@prismicio/client` method {@link Client.getFirst}
|
|
35
32
|
*/
|
|
36
|
-
export declare const useFirstPrismicDocument: <TDocument extends PrismicDocument
|
|
37
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
38
|
-
signal?: any;
|
|
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
|
|
57
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
58
|
-
signal?: any;
|
|
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
|
|
77
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
78
|
-
signal?: any;
|
|
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.
|
|
@@ -93,12 +81,9 @@ export declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocumen
|
|
|
93
81
|
*
|
|
94
82
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
|
|
95
83
|
*/
|
|
96
|
-
export declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocument
|
|
97
|
-
limit?: number
|
|
98
|
-
} &
|
|
99
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
100
|
-
signal?: any;
|
|
101
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
84
|
+
export declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocument>(ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
|
|
85
|
+
limit?: number;
|
|
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
|
|
120
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
121
|
-
signal?: any;
|
|
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
|
|
141
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
142
|
-
signal?: any;
|
|
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.
|
|
@@ -158,12 +137,9 @@ export declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocume
|
|
|
158
137
|
*
|
|
159
138
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
|
|
160
139
|
*/
|
|
161
|
-
export declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDocument
|
|
162
|
-
limit?: number
|
|
163
|
-
} &
|
|
164
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
165
|
-
signal?: any;
|
|
166
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
140
|
+
export declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDocument>(documentType: any, ids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
|
|
141
|
+
limit?: number;
|
|
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
|
|
184
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
185
|
-
signal?: any;
|
|
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
|
|
204
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
205
|
-
signal?: any;
|
|
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.
|
|
@@ -220,12 +190,9 @@ export declare const usePrismicDocumentsByType: <TDocument extends PrismicDocume
|
|
|
220
190
|
*
|
|
221
191
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByType}
|
|
222
192
|
*/
|
|
223
|
-
export declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDocument
|
|
224
|
-
limit?: number
|
|
225
|
-
} &
|
|
226
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
227
|
-
signal?: any;
|
|
228
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
193
|
+
export declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDocument>(documentType: any, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
|
|
194
|
+
limit?: number;
|
|
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
|
|
246
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
247
|
-
signal?: any;
|
|
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.
|
|
@@ -262,12 +226,9 @@ export declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocumen
|
|
|
262
226
|
*
|
|
263
227
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByTag}
|
|
264
228
|
*/
|
|
265
|
-
export declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocument
|
|
266
|
-
limit?: number
|
|
267
|
-
} &
|
|
268
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
269
|
-
signal?: any;
|
|
270
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
229
|
+
export declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocument>(tag: string, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
|
|
230
|
+
limit?: number;
|
|
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
|
|
288
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
289
|
-
signal?: any;
|
|
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
|
|
@@ -305,12 +263,9 @@ export declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDo
|
|
|
305
263
|
*
|
|
306
264
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
|
|
307
265
|
*/
|
|
308
|
-
export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends PrismicDocument
|
|
309
|
-
limit?: number
|
|
310
|
-
} &
|
|
311
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
312
|
-
signal?: any;
|
|
313
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
266
|
+
export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
|
|
267
|
+
limit?: number;
|
|
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
|
|
332
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
333
|
-
signal?: any;
|
|
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
|
|
@@ -349,12 +301,9 @@ export declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDo
|
|
|
349
301
|
*
|
|
350
302
|
* @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
|
|
351
303
|
*/
|
|
352
|
-
export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends PrismicDocument
|
|
353
|
-
limit?: number
|
|
354
|
-
} &
|
|
355
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
356
|
-
signal?: any;
|
|
357
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
304
|
+
export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends PrismicDocument>(tags: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
|
|
305
|
+
limit?: number;
|
|
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
|
|
@@ -376,9 +325,6 @@ export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends Prismi
|
|
|
376
325
|
*
|
|
377
326
|
* @see Underlying `@prismicio/client` method {@link Client.getAll}
|
|
378
327
|
*/
|
|
379
|
-
export declare const dangerouslyUseAllPrismicDocuments: <TDocument extends PrismicDocument
|
|
380
|
-
limit?: number
|
|
381
|
-
} &
|
|
382
|
-
fetchOptions?: import("@prismicio/client").RequestInitLike | undefined;
|
|
383
|
-
signal?: any;
|
|
384
|
-
} & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
|
328
|
+
export declare const dangerouslyUseAllPrismicDocuments: <TDocument extends PrismicDocument>(params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
|
|
329
|
+
limit?: number;
|
|
330
|
+
} & import("@prismicio/client/dist/BaseClient").FetchParams & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
|
package/dist/lib/getSlots.cjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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;;"}
|
package/dist/lib/getSlots.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/getSlots.js
CHANGED
|
@@ -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
|
|
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
|
|
12
|
+
return fallback;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
};
|
package/dist/lib/getSlots.js.map
CHANGED
|
@@ -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
|
|
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;"}
|
|
@@ -60,5 +60,5 @@ export type ClientComposableReturnType<TData = unknown> = {
|
|
|
60
60
|
*
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
|
-
export declare const useStatefulPrismicClientMethod: <TClientMethodName extends keyof
|
|
63
|
+
export declare const useStatefulPrismicClientMethod: <TClientMethodName extends keyof ClientMethods, TClientMethodArguments extends ClientMethodParameters<TClientMethodName>, TClientMethodReturnType extends UnwrapPromise<ClientMethodReturnType<TClientMethodName>>>(methodName: TClientMethodName, args: TClientMethodArguments) => ClientComposableReturnType<TClientMethodReturnType>;
|
|
64
64
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "4.
|
|
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.
|
|
60
|
+
"@prismicio/client": "^7.11.0",
|
|
61
61
|
"isomorphic-unfetch": "^3.1.0",
|
|
62
|
-
"vue-router": "^4.3
|
|
62
|
+
"vue-router": "^4.4.3"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@prismicio/mock": "
|
|
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.
|
|
73
|
+
"@vue/compiler-sfc": "^3.4.38",
|
|
74
74
|
"@vue/eslint-config-typescript": "^11.0.3",
|
|
75
|
-
"@vue/test-utils": "^2.4.
|
|
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.
|
|
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
|
|
88
|
-
"vite": "^4.
|
|
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.
|
|
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") {
|
package/src/globalExtensions.ts
CHANGED
package/src/lib/getSlots.ts
CHANGED
|
@@ -16,19 +16,22 @@ export const getSlots = (
|
|
|
16
16
|
parent: string | ConcreteComponent,
|
|
17
17
|
slots: Slots,
|
|
18
18
|
defaultPayload?: unknown,
|
|
19
|
-
|
|
19
|
+
fallback?: string,
|
|
20
|
+
): VNode[] | undefined | Slots | string => {
|
|
20
21
|
if (typeof parent === "string") {
|
|
21
|
-
return slots.default
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return content.length
|
|
28
|
+
? {
|
|
29
|
+
...slots,
|
|
30
|
+
default: () => content,
|
|
31
|
+
}
|
|
32
|
+
: fallback;
|
|
30
33
|
} else {
|
|
31
|
-
return
|
|
34
|
+
return fallback;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
};
|