@prismicio/vue 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/PrismicEmbed.cjs.map +1 -1
- package/dist/components/PrismicEmbed.d.ts +1 -1
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs +2 -2
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +4 -4
- package/dist/components/PrismicImage.js +2 -2
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs +3 -3
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +5 -5
- package/dist/components/PrismicLink.js +3 -3
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs +3 -3
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +3 -3
- package/dist/components/PrismicRichText.js +3 -3
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs +1 -1
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +2 -2
- package/dist/components/PrismicText.js +1 -1
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs +1 -1
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +2 -2
- package/dist/components/SliceZone.js +1 -1
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/composables.cjs.map +1 -1
- package/dist/composables.js.map +1 -1
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.js.map +1 -1
- package/dist/injectionSymbols.cjs.map +1 -1
- package/dist/injectionSymbols.js.map +1 -1
- package/dist/lib/simplyResolveComponent.cjs.map +1 -1
- package/dist/lib/simplyResolveComponent.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/usePrismic.cjs.map +1 -1
- package/dist/usePrismic.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +1 -1
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +27 -19
- package/src/components/PrismicEmbed.ts +4 -3
- package/src/components/PrismicImage.ts +16 -15
- package/src/components/PrismicLink.ts +14 -13
- package/src/components/PrismicRichText.ts +15 -14
- package/src/components/PrismicText.ts +7 -7
- package/src/components/SliceZone.ts +7 -6
- package/src/composables.ts +2 -5
- package/src/createPrismic.ts +15 -15
- package/src/injectionSymbols.ts +0 -2
- package/src/lib/simplyResolveComponent.ts +1 -1
- package/src/types.ts +10 -13
- package/src/usePrismic.ts +2 -1
- package/src/useStatefulPrismicClientMethod.ts +3 -3
- package/vetur/attributes.json +1 -6
- package/vetur/tags.json +17 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNode, VNodeProps } from "vue";
|
|
2
|
-
import { RichTextField } from "@prismicio/types";
|
|
3
2
|
import { VueUseOptions } from "../types";
|
|
3
|
+
import { RichTextField } from "@prismicio/types";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `<PrismicText />`.
|
|
6
6
|
*/
|
|
@@ -105,7 +105,7 @@ export declare const PrismicTextImpl: DefineComponent<{
|
|
|
105
105
|
field: RichTextField | null | undefined;
|
|
106
106
|
separator: string;
|
|
107
107
|
fallback: string;
|
|
108
|
-
}>;
|
|
108
|
+
}, {}>;
|
|
109
109
|
/**
|
|
110
110
|
* Component to render a Prismic rich text field as plain text.
|
|
111
111
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computed, unref, defineComponent, h } from "vue";
|
|
2
1
|
import { isFilled, asText } from "@prismicio/helpers";
|
|
2
|
+
import { computed, unref, defineComponent, h } from "vue";
|
|
3
3
|
import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
|
|
4
4
|
const defaultWrapper = "div";
|
|
5
5
|
const usePrismicText = (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.js","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\
|
|
1
|
+
{"version":3,"file":"PrismicText.js","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { asText, isFilled } from \"@prismicio/helpers\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\nimport { RichTextField } from \"@prismicio/types\";\n\n/**\n * The default component rendered to wrap the text output.\n */\nconst defaultWrapper = \"div\";\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined;\n\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue `\" \"` (a space)\n\t */\n\tseparator?: string;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n\n\t/**\n\t * The string value to be rendered when the field is empty. If a fallback is\n\t * not given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string;\n};\n\n/**\n * Options for {@link usePrismicText}.\n */\nexport type UsePrismicTextOptions = VueUseOptions<\n\tOmit<PrismicTextProps, \"wrapper\">\n>;\n\n/**\n * Return type of {@link usePrismicText}.\n */\nexport type UsePrismicTextReturnType = {\n\t/**\n\t * Serialized rich text field as plain text.\n\t */\n\ttext: ComputedRef<string>;\n};\n\n/**\n * A low level composable that returns a serialized rich text field as plain\n * text.\n *\n * @param props - {@link UsePrismicTextOptions}\n *\n * @returns - Serialized rich text field as plain text\n * {@link UsePrismicTextReturnType}\n */\nexport const usePrismicText = (\n\tprops: UsePrismicTextOptions,\n): UsePrismicTextReturnType => {\n\tconst text = computed(() => {\n\t\tconst field = unref(props.field);\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\";\n\t\t}\n\n\t\treturn asText(unref(field), unref(props.separator));\n\t});\n\n\treturn {\n\t\ttext,\n\t};\n};\n\n/**\n * `<PrismicText />` implementation.\n *\n * @internal\n */\nexport const PrismicTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tseparator: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { text } = usePrismicText(props);\n\n\t\treturn () => {\n\t\t\tconst parent = simplyResolveComponent(props.wrapper || defaultWrapper);\n\n\t\t\t// This works but is absurd\n\t\t\t// if (typeof parent === \"string\") {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// } else {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// }\n\n\t\t\treturn h(parent as VNode, null, {\n\t\t\t\tdefault: () => text.value,\n\t\t\t});\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as plain text.\n *\n * @see Component props {@link PrismicTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicText = PrismicTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicTextProps;\n\t};\n};\n"],"names":[],"mappings":";;;AAyBA,MAAM,iBAAiB;AA0DV,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,OAAO,SAAS,MAAK;AACpB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,QAAI,CAAC,SAAS,SAAS,KAAK,GAAG;AACvB,aAAA,MAAM,MAAM,QAAQ,KAAK;AAAA,IAChC;AAED,WAAO,OAAO,MAAM,KAAK,GAAG,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,kBAAgD,gCAAA;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,eAAe,KAAK;AAErC,WAAO,MAAK;AACX,YAAM,SAAS,uBAAuB,MAAM,WAAW,cAAc;AAS9D,aAAA,EAAE,QAAiB,MAAM;AAAA,QAC/B,SAAS,MAAM,KAAK;AAAA,MAAA,CACpB;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("vue");
|
|
4
|
-
const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
|
|
5
4
|
const __PRODUCTION__ = require("../lib/__PRODUCTION__.cjs");
|
|
5
|
+
const simplyResolveComponent = require("../lib/simplyResolveComponent.cjs");
|
|
6
6
|
const usePrismic = require("../usePrismic.cjs");
|
|
7
7
|
const getSliceComponentProps = (propsHint) => ({
|
|
8
8
|
slice: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tcomputed,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\tFunctionalComponent,\n\th,\n\tmarkRaw,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\twatchEffect,\n} from \"vue\";\n\nimport { Slice } from \"@prismicio/types\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/types`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/types` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component. Props are: `[\"slice\", \"index\", \"slices\",\n * \"context\"]`\n *\n * @example Defining a new slice component:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example Defining a new slice component with visual hint:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example Defining a slice components:\n *\n * ```javascript\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":["__PRODUCTION__","defineComponent","computed","watchEffect","h","markRaw","usePrismic","simplyResolveComponent"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { Slice } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/types`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/types` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component. Props are: `[\"slice\", \"index\", \"slices\",\n * \"context\"]`\n *\n * @example Defining a new slice component:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example Defining a new slice component with visual hint:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example Defining a slice components:\n *\n * ```javascript\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":["__PRODUCTION__","defineComponent","computed","watchEffect","h","markRaw","usePrismic","simplyResolveComponent"],"mappings":"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"}
|
|
@@ -150,7 +150,7 @@ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknow
|
|
|
150
150
|
* This is also the default Vue component rendered when a component mapping
|
|
151
151
|
* cannot be found in `<SliceZone />`.
|
|
152
152
|
*/
|
|
153
|
-
export declare const TODOSliceComponent: DefineComponent<{}, {}, any> | FunctionalComponent<SliceComponentProps<any, unknown>, {}> | DefineComponent<SliceComponentProps<any, unknown>>;
|
|
153
|
+
export declare const TODOSliceComponent: DefineComponent<{}, {}, any> | FunctionalComponent<SliceComponentProps<any, unknown>, {}, any> | DefineComponent<SliceComponentProps<any, unknown>>;
|
|
154
154
|
/**
|
|
155
155
|
* A record of Slice types mapped to Vue components. Each components will be
|
|
156
156
|
* rendered for each instance of their Slice type.
|
|
@@ -344,7 +344,7 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
344
344
|
resolver: SliceZoneResolver<any, unknown>;
|
|
345
345
|
defaultComponent: SliceComponentType<any, unknown>;
|
|
346
346
|
wrapper: string | ConcreteComponent | Raw<DefineComponent>;
|
|
347
|
-
}>;
|
|
347
|
+
}, {}>;
|
|
348
348
|
/**
|
|
349
349
|
* Component to render a Prismic Slice Zone.
|
|
350
350
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, computed, watchEffect, h, markRaw } from "vue";
|
|
2
|
-
import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
|
|
3
2
|
import { __PRODUCTION__ } from "../lib/__PRODUCTION__.js";
|
|
3
|
+
import { simplyResolveComponent } from "../lib/simplyResolveComponent.js";
|
|
4
4
|
import { usePrismic } from "../usePrismic.js";
|
|
5
5
|
const getSliceComponentProps = (propsHint) => ({
|
|
6
6
|
slice: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tcomputed,\n\tConcreteComponent,\n\tDefineComponent,\n\tdefineComponent,\n\tFunctionalComponent,\n\th,\n\tmarkRaw,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\twatchEffect,\n} from \"vue\";\n\nimport { Slice } from \"@prismicio/types\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/types`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/types` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component. Props are: `[\"slice\", \"index\", \"slices\",\n * \"context\"]`\n *\n * @example Defining a new slice component:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example Defining a new slice component with visual hint:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example Defining a slice components:\n *\n * ```javascript\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { Slice } from \"@prismicio/types\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/types` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/types`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/types` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/types` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component. Props are: `[\"slice\", \"index\", \"slices\",\n * \"context\"]`\n *\n * @example Defining a new slice component:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example Defining a new slice component with visual hint:\n *\n * ```javascript\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example Defining a slice components:\n *\n * ```javascript\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":[],"mappings":"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"}
|
package/dist/composables.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composables.cjs","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// Imports for @link references:\n\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport { PrismicDocument, Query } from \"@prismicio/types\";\n\nimport {\n\tClientMethodParameters,\n\tClientComposableReturnType,\n\tuseStatefulPrismicClientMethod,\n\tComposableOnlyParameters,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":["useStatefulPrismicClientMethod"],"mappings":";;;AAiCO,MAAM,sBAAsB,IAC/B,SAIHA,+BAAAA,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKHA,+BAAAA,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMHA,+BAAAA,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMHA,+BAAAA,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMHA,+BAAAA,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMHA,+BAAAA,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMHA,+BAAAA,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMHA,+BAAAA,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKHA,+BAAA,+BAA+B,qBAAqB,IAAI;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"composables.cjs","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport { PrismicDocument, Query } from \"@prismicio/types\";\n\nimport {\n\tClientComposableReturnType,\n\tClientMethodParameters,\n\tComposableOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":["useStatefulPrismicClientMethod"],"mappings":";;;AA8BO,MAAM,sBAAsB,IAC/B,SAIHA,+BAAAA,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKHA,+BAAAA,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMHA,+BAAAA,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMHA,+BAAAA,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMHA,+BAAAA,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKHA,+BAAAA,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMHA,+BAAAA,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKHA,+BAAAA,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMHA,+BAAAA,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMHA,+BAAAA,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMHA,+BAAAA,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMHA,+BAAAA,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKHA,+BAAA,+BAA+B,qBAAqB,IAAI;;;;;;;;;;;;;;;;;;;"}
|
package/dist/composables.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composables.js","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// Imports for @link references:\n\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport { PrismicDocument, Query } from \"@prismicio/types\";\n\nimport {\n\tClientMethodParameters,\n\tClientComposableReturnType,\n\tuseStatefulPrismicClientMethod,\n\tComposableOnlyParameters,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":[],"mappings":";AAiCO,MAAM,sBAAsB,IAC/B,SAIH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKH,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;"}
|
|
1
|
+
{"version":3,"file":"composables.js","sources":["../../src/composables.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport { PrismicDocument, Query } from \"@prismicio/types\";\n\nimport {\n\tClientComposableReturnType,\n\tClientMethodParameters,\n\tComposableOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n// Composables\n\n/**\n * A composable that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.get}\n */\nexport const usePrismicDocuments = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A composable that queries content from the Prismic repository and returns\n * only the first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getFirst}\n */\nexport const useFirstPrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"getFirst\">[0] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByID}\n */\nexport const usePrismicDocumentByID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tids: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A composable that queries a document from the Prismic repository with a\n * specific UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByUID}\n */\nexport const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByIDs}\n */\nexport const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific UIDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByUIDs\">[0],\n\t\tids: ClientMethodParameters<\"getAllByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getAllByUIDs\">[2] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A composable that queries a singleton document from the Prismic repository\n * for a specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getSingle}\n */\nexport const useSinglePrismicDocument = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A composable that queries documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByType}\n */\nexport const usePrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTag}\n */\nexport const usePrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & ComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with a\n * specific tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with all of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n\n/**\n * A composable that queries documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A composable that queries all documents from the Prismic repository with\n * specific tags. A document must be tagged with at least one of the queried\n * tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\ttags: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be\n * slower and require more resources than other composables. Prefer using other\n * composables that filter by predicates such as\n * `useAllPrismicDocumentsByType`.\n *\n * A composable that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link Client.getAll}\n */\nexport const dangerouslyUseAllPrismicDocuments = <\n\tTDocument extends PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tComposableOnlyParameters,\n\t]\n): ClientComposableReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n"],"names":[],"mappings":";AA8BO,MAAM,sBAAsB,IAC/B,SAIH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IACnC,SAIH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,yBAAyB,IAClC,SAKH,+BAA+B,WAAW,IAAI;AAkBxC,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IACnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IACrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IACxC,SAOH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IACrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IACxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IACpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IACvC,SAMH,+BAA+B,eAAe,IAAI;AAkB5C,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAmBjD,MAAM,gCAAgC,IAGzC,SAMH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAMH,+BAA+B,oBAAoB,IAAI;AAuBjD,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tcookie,\n\tcreateClient,\n\tpredicate,\n} from \"@prismicio/client\";\nimport {\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasText,\n\tdocumentToLinkField,\n} from \"@prismicio/helpers\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tpredicate,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, linkResolver, htmlSerializer) => {\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\tlinkResolver || options.linkResolver,\n\t\t\t\thtmlSerializer || options.richTextSerializer || options.htmlSerializer,\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, linkResolver) => {\n\t\t\treturn asLink(linkField, linkResolver || options.linkResolver);\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["client","createClient","options","predicate","cookie","asText","asHTML","asLink","asDate","asImageSrc","asImageWidthSrcSet","asImagePixelDensitySrcSet","documentToLinkField","prismicKey","PrismicLink","PrismicEmbed","PrismicImage","PrismicText","PrismicRichText","SliceZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAAA;AACJ,MAAI,QAAQ,QAAQ;AACnBA,eAAS,QAAQ;AAAA,EAAA,OACX;AACGA,eAAAC,OAAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUC,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACrD;AAEM,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACD;AAED,QAAM,gBAAqC;AAAA,IAAA,QAC1CF;AAAAA,IAAA,WACAG,OAAA;AAAA,IAAA,QACAC,OAAA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAAA,QAC5CC,QAAA;AAAA,IACA,QAAQ,CAAC,eAAe,cAAc,mBAAkB;AAChD,aAAAC,eACN,eACA,gBAAgB,QAAQ,cACxB,kBAAkB,QAAQ,sBAAsB,QAAQ,cAAc;AAAA,IAExE;AAAA,IACA,QAAQ,CAAC,WAAW,iBAAgB;AACnC,aAAOC,QAAO,OAAA,WAAW,gBAAgB,QAAQ,YAAY;AAAA,IAC9D;AAAA,IAAA,QACAC,QAAA;AAAA,IAAA,YACAC,QAAA;AAAA,IAAA,oBACAC,QAAA;AAAA,IAAA,2BACAC,QAAA;AAAA,IAAA,qBACAC,QAAA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQC,6BAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,gBAAAA,gBAAgB,MAAMA,gBAAe,eAAA;AAC/C,YAAA,UAAUC,UAAAA,UAAU,MAAMA,UAAS,SAAA;AAAA,MACvC;AAAA,IACF;AAAA,EAAA;AAGM,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tcookie,\n\tcreateClient,\n\tpredicate,\n} from \"@prismicio/client\";\nimport {\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasText,\n\tdocumentToLinkField,\n} from \"@prismicio/helpers\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tpredicate,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, linkResolver, htmlSerializer) => {\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\tlinkResolver || options.linkResolver,\n\t\t\t\thtmlSerializer || options.richTextSerializer || options.htmlSerializer,\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, linkResolver) => {\n\t\t\treturn asLink(linkField, linkResolver || options.linkResolver);\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["options"],"mappings":";;;;;;;;;AA8Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAA;AACJ,MAAI,QAAQ,QAAQ;AACnB,aAAS,QAAQ;AAAA,EAAA,OACX;AACG,aAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUA,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACrD;AAEM,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACD;AAED,QAAM,gBAAqC;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAC5C;AAAA,IACA,QAAQ,CAAC,eAAe,cAAc,mBAAkB;AAChD,aAAA,OACN,eACA,gBAAgB,QAAQ,cACxB,kBAAkB,QAAQ,sBAAsB,QAAQ,cAAc;AAAA,IAExE;AAAA,IACA,QAAQ,CAAC,WAAW,iBAAgB;AACnC,aAAO,OAAO,WAAW,gBAAgB,QAAQ,YAAY;AAAA,IAC9D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQ,YAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,gBAAgB,MAAM,eAAe;AAC/C,YAAA,UAAU,UAAU,MAAM,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EAAA;AAGM,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectionSymbols.cjs","sources":["../../src/injectionSymbols.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\n\nimport type { PrismicPlugin } from \"./types\";\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n
|
|
1
|
+
{"version":3,"file":"injectionSymbols.cjs","sources":["../../src/injectionSymbols.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\n\nimport type { PrismicPlugin } from \"./types\";\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { usePrismic } from \"./usePrismic\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/**\n * `@prismicio/vue` plugin interface interface location used for\n * {@link usePrismic}.\n *\n * @internal\n */\nexport const prismicKey = Symbol(\"prismic\") as InjectionKey<PrismicPlugin>;\n"],"names":[],"mappings":";;AAgBa,MAAA,aAAa,OAAO,SAAS;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectionSymbols.js","sources":["../../src/injectionSymbols.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\n\nimport type { PrismicPlugin } from \"./types\";\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n
|
|
1
|
+
{"version":3,"file":"injectionSymbols.js","sources":["../../src/injectionSymbols.ts"],"sourcesContent":["import type { InjectionKey } from \"vue\";\n\nimport type { PrismicPlugin } from \"./types\";\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n// Imports for @link references:\nimport type { usePrismic } from \"./usePrismic\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/**\n * `@prismicio/vue` plugin interface interface location used for\n * {@link usePrismic}.\n *\n * @internal\n */\nexport const prismicKey = Symbol(\"prismic\") as InjectionKey<PrismicPlugin>;\n"],"names":[],"mappings":"AAgBa,MAAA,aAAa,OAAO,SAAS;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplyResolveComponent.cjs","sources":["../../../src/lib/simplyResolveComponent.ts"],"sourcesContent":["import {\n\tConcreteComponent,\n\tDefineComponent,\n\tRaw,\n\
|
|
1
|
+
{"version":3,"file":"simplyResolveComponent.cjs","sources":["../../../src/lib/simplyResolveComponent.ts"],"sourcesContent":["import {\n\tConcreteComponent,\n\tDefineComponent,\n\tRaw,\n\tVNode,\n\tresolveDynamicComponent,\n} from \"vue\";\n\n/**\n * A stricter version of {@link resolveDynamicComponent} that resolves only type\n * {@link VNode} for existing components or provided `string`.\n *\n * @param component - An HTML tag name, a component, or a functional component\n *\n * @returns Resolved component as a {@link VNode} or provided `string`.\n *\n * @internal\n */\nexport const simplyResolveComponent = (\n\tcomponent: string | ConcreteComponent | Raw<DefineComponent>,\n): string | VNode => {\n\treturn resolveDynamicComponent(component) as string | VNode;\n};\n"],"names":["resolveDynamicComponent"],"mappings":";;;AAkBa,MAAA,yBAAyB,CACrC,cACmB;AACnB,SAAOA,IAAAA,wBAAwB,SAAS;AACzC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplyResolveComponent.js","sources":["../../../src/lib/simplyResolveComponent.ts"],"sourcesContent":["import {\n\tConcreteComponent,\n\tDefineComponent,\n\tRaw,\n\
|
|
1
|
+
{"version":3,"file":"simplyResolveComponent.js","sources":["../../../src/lib/simplyResolveComponent.ts"],"sourcesContent":["import {\n\tConcreteComponent,\n\tDefineComponent,\n\tRaw,\n\tVNode,\n\tresolveDynamicComponent,\n} from \"vue\";\n\n/**\n * A stricter version of {@link resolveDynamicComponent} that resolves only type\n * {@link VNode} for existing components or provided `string`.\n *\n * @param component - An HTML tag name, a component, or a functional component\n *\n * @returns Resolved component as a {@link VNode} or provided `string`.\n *\n * @internal\n */\nexport const simplyResolveComponent = (\n\tcomponent: string | ConcreteComponent | Raw<DefineComponent>,\n): string | VNode => {\n\treturn resolveDynamicComponent(component) as string | VNode;\n};\n"],"names":[],"mappings":";AAkBa,MAAA,yBAAyB,CACrC,cACmB;AACnB,SAAO,wBAAwB,SAAS;AACzC;"}
|