@prismicio/vue 4.2.3 → 4.3.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 +7 -7
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +10 -8
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs +8 -3
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +14 -8
- package/dist/components/PrismicLink.js +8 -3
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +8 -8
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +8 -8
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +14 -12
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/composables.cjs.map +1 -1
- package/dist/composables.d.ts +38 -74
- 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/__PRODUCTION__.cjs.map +1 -1
- package/dist/lib/__PRODUCTION__.js.map +1 -1
- package/dist/lib/getSlots.cjs +6 -4
- package/dist/lib/getSlots.cjs.map +1 -1
- package/dist/lib/getSlots.d.ts +2 -2
- package/dist/lib/getSlots.js +6 -4
- package/dist/lib/getSlots.js.map +1 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/simplyResolveComponent.cjs.map +1 -1
- package/dist/lib/simplyResolveComponent.d.ts +1 -1
- package/dist/lib/simplyResolveComponent.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/usePrismic.cjs.map +1 -1
- package/dist/usePrismic.d.ts +5 -5
- package/dist/usePrismic.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.d.ts +4 -3
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +28 -29
- package/src/components/PrismicEmbed.ts +16 -17
- package/src/components/PrismicImage.ts +57 -59
- package/src/components/PrismicLink.ts +78 -67
- package/src/components/PrismicRichText.ts +64 -63
- package/src/components/PrismicText.ts +30 -32
- package/src/components/SliceZone.ts +94 -96
- package/src/components/index.ts +12 -16
- package/src/composables.ts +41 -23
- package/src/createPrismic.ts +40 -34
- package/src/globalExtensions.ts +2 -2
- package/src/index.ts +10 -10
- package/src/injectionSymbols.ts +4 -4
- package/src/lib/__PRODUCTION__.ts +2 -2
- package/src/lib/getSlots.ts +17 -8
- package/src/lib/isInternalURL.ts +4 -4
- package/src/lib/simplyResolveComponent.ts +4 -9
- package/src/types.ts +61 -52
- package/src/usePrismic.ts +9 -9
- package/src/useStatefulPrismicClientMethod.ts +42 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tRichTextField,\n\
|
|
1
|
+
{"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import type {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tRichTextField,\n} from \"@prismicio/client\"\nimport { asHTML, isFilled } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n} from \"vue\"\nimport {\n\tcomputed,\n\tdefineComponent,\n\th,\n\tinject,\n\tnextTick,\n\tonBeforeUnmount,\n\tref,\n\tunref,\n\twatch,\n} from \"vue\"\nimport { routerKey } from \"vue-router\"\n\nimport { isInternalURL } from \"../lib/isInternalURL\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../types\"\n\nimport { usePrismic } from \"../usePrismic\"\n\n/**\n * The default component rendered to wrap the HTML output.\n */\nconst defaultWrapper = \"div\"\n\n/**\n * Props for `<PrismicRichText />`.\n */\nexport type PrismicRichTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * A link resolver function used to resolve link when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\tserializer?: HTMLFunctionSerializer | HTMLMapSerializer\n\n\t/**\n\t * An HTML serializer to customize the way rich text fields are rendered.\n\t *\n\t * @deprecated Use `serializer` instead.\n\t *\n\t * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}\n\t */\n\thtmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>\n\n\t/**\n\t * The HTML value to be rendered when the field is empty. If a fallback is not\n\t * given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string\n}\n\n/**\n * Options for {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextOptions = VueUseOptions<\n\tOmit<PrismicRichTextProps, \"wrapper\">\n>\n\n/**\n * Return type of {@link usePrismicRichText}.\n */\nexport type UsePrismicRichTextReturnType = {\n\t/**\n\t * Serialized rich text field as HTML.\n\t */\n\thtml: ComputedRef<string>\n}\n\n/**\n * A low level composable that returns a serialized rich text field as HTML.\n *\n * @param props - {@link UsePrismicRichTextOptions}\n *\n * @returns - Serialized rich text field as HTML\n * {@link UsePrismicRichTextReturnType}\n */\nexport const usePrismicRichText = (\n\tprops: UsePrismicRichTextOptions,\n): UsePrismicRichTextReturnType => {\n\tconst { options } = usePrismic()\n\n\tconst html = computed(() => {\n\t\tconst field = unref(props.field)\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\"\n\t\t}\n\n\t\tconst linkResolver = unref(props.linkResolver) ?? options.linkResolver\n\t\tconst serializer =\n\t\t\tunref(props.serializer) ??\n\t\t\tunref(props.htmlSerializer) ??\n\t\t\toptions.richTextSerializer ??\n\t\t\toptions.htmlSerializer\n\n\t\treturn asHTML(unref(field), linkResolver, serializer)\n\t})\n\n\treturn {\n\t\thtml,\n\t}\n}\n\n/**\n * `<PrismicRichText />` implementation.\n *\n * @internal\n */\nexport const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicRichText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tlinkResolver: {\n\t\t\ttype: Function as PropType<LinkResolverFunction>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tserializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\thtmlSerializer: {\n\t\t\ttype: [Function, Object] as PropType<\n\t\t\t\tHTMLFunctionSerializer | HTMLMapSerializer\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { html } = usePrismicRichText(props)\n\n\t\tconst root = ref<HTMLElement | Comment | Component | null>(null)\n\n\t\tconst maybeRouter = inject(routerKey, null)\n\t\tif (maybeRouter) {\n\t\t\ttype InternalLink = {\n\t\t\t\telement: HTMLAnchorElement\n\t\t\t\tlistener: EventListener\n\t\t\t}\n\t\t\tlet links: InternalLink[] = []\n\n\t\t\tconst navigate: EventListener = function (\n\t\t\t\tthis: { href: string },\n\t\t\t\tevent: Event,\n\t\t\t) {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tmaybeRouter.push(this.href)\n\t\t\t}\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tconst node: HTMLElement | Comment | null =\n\t\t\t\t\troot.value && \"$el\" in root.value ? root.value.$el : root.value\n\t\t\t\tif (node && \"querySelectorAll\" in node) {\n\t\t\t\t\t// Get all internal link tags and add listeners on them\n\t\t\t\t\tlinks = Array.from(node.querySelectorAll(\"a\"))\n\t\t\t\t\t\t.map((element) => {\n\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\")\n\n\t\t\t\t\t\t\tif (href && isInternalURL(href)) {\n\t\t\t\t\t\t\t\tconst listener = navigate.bind({ href })\n\t\t\t\t\t\t\t\telement.addEventListener(\"click\", listener)\n\n\t\t\t\t\t\t\t\treturn { element, listener }\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((link): link is InternalLink => link as boolean)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tlinks.forEach(({ element, listener }) =>\n\t\t\t\t\telement.removeEventListener(\"click\", listener),\n\t\t\t\t)\n\t\t\t\tlinks = []\n\t\t\t}\n\n\t\t\twatch(\n\t\t\t\thtml,\n\t\t\t\t() => {\n\t\t\t\t\tremoveListeners()\n\t\t\t\t\tnextTick(addListeners)\n\t\t\t\t},\n\t\t\t\t{ immediate: true },\n\t\t\t)\n\n\t\t\tonBeforeUnmount(() => {\n\t\t\t\tremoveListeners()\n\t\t\t})\n\t\t}\n\n\t\treturn () => {\n\t\t\treturn h(simplyResolveComponent(props.wrapper || defaultWrapper), {\n\t\t\t\tinnerHTML: html.value,\n\t\t\t\tref: root,\n\t\t\t})\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as HTML.\n *\n * @see Component props {@link PrismicRichTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicRichText = PrismicRichTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicRichTextProps\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAyCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,QAAO,IAAK;AAEd,QAAA,OAAO,SAAS,MAAK;AACpB,UAAA,QAAQ,MAAM,MAAM,KAAK;AAE/B,QAAI,CAAC,SAAS,SAAS,KAAK,GAAG;AACvB,aAAA,MAAM,MAAM,QAAQ,KAAK;AAAA,IAAA;AAGjC,UAAM,eAA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sBAAsB,MAAM;AAE/B,kBAAA,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,EAC3C,IAAI,CAAC,YAAW;AACV,kBAAA,OAAO,QAAQ,aAAa,MAAM;AAEpC,gBAAA,QAAQ,cAAc,IAAI,GAAG;AAChC,oBAAM,WAAW,SAAS,KAAK,EAAE,MAAM;AAC/B,sBAAA,iBAAiB,SAAS,QAAQ;AAEnC,qBAAA,EAAE,SAAS;mBACZ;AACC,qBAAA;AAAA,YAAA;AAAA,UAER,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,QAAA;AAAA,MAE1D;AAEA,YAAM,kBAAkB,MAAK;AACtB,cAAA,QAAQ,CAAC,EAAE,SAAS,eACzB,QAAQ,oBAAoB,SAAS,QAAQ,CAAC;AAE/C,gBAAQ;MACT;AAEA,YACC,MACA,MAAK;;AAEJ,iBAAS,YAAY;AAAA,MAAA,GAEtB,EAAE,WAAW,MAAM;AAGpB,sBAAgB,MAAK;;OAEpB;AAAA,IAAA;AAGF,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,WAAW,KAAK;AAAA,QAChB,KAAK;AAAA,MAAA,CACL;AAAA,IACF;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,kBAAkB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { RichTextField
|
|
1
|
+
{"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import type { RichTextField } from \"@prismicio/client\"\nimport { asText, isFilled } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n} from \"vue\"\nimport { computed, defineComponent, h, unref } from \"vue\"\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../types\"\n\n/**\n * The default component rendered to wrap the text output.\n */\nconst defaultWrapper = \"div\"\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic rich text or title field to render.\n\t */\n\tfield: RichTextField | null | undefined\n\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue `\" \"` (a space)\n\t */\n\tseparator?: string\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output.\n\t *\n\t * @defaultValue `\"div\"`\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>\n\n\t/**\n\t * The string value to be rendered when the field is empty. If a fallback is\n\t * not given, `\"\"` (nothing) will be rendered.\n\t */\n\tfallback?: string\n}\n\n/**\n * Options for {@link usePrismicText}.\n */\nexport type UsePrismicTextOptions = VueUseOptions<\n\tOmit<PrismicTextProps, \"wrapper\">\n>\n\n/**\n * Return type of {@link usePrismicText}.\n */\nexport type UsePrismicTextReturnType = {\n\t/**\n\t * Serialized rich text field as plain text.\n\t */\n\ttext: ComputedRef<string>\n}\n\n/**\n * A low level composable that returns a serialized rich text field as plain\n * text.\n *\n * @param props - {@link UsePrismicTextOptions}\n *\n * @returns - Serialized rich text field as plain text\n * {@link UsePrismicTextReturnType}\n */\nexport const usePrismicText = (\n\tprops: UsePrismicTextOptions,\n): UsePrismicTextReturnType => {\n\tconst text = computed(() => {\n\t\tconst field = unref(props.field)\n\n\t\tif (!isFilled.richText(field)) {\n\t\t\treturn unref(props.fallback) ?? \"\"\n\t\t}\n\n\t\treturn asText(unref(field), unref(props.separator))\n\t})\n\n\treturn {\n\t\ttext,\n\t}\n}\n\n/**\n * `<PrismicText />` implementation.\n *\n * @internal\n */\nexport const PrismicTextImpl = /*#__PURE__*/ defineComponent({\n\tname: \"PrismicText\",\n\tprops: {\n\t\tfield: {\n\t\t\ttype: Array as unknown as PropType<RichTextField | null | undefined>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tseparator: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: String as PropType<string>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\tconst { text } = usePrismicText(props)\n\n\t\treturn () => {\n\t\t\tconst parent = simplyResolveComponent(props.wrapper || defaultWrapper)\n\n\t\t\t// This works but is absurd\n\t\t\t// if (typeof parent === \"string\") {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// } else {\n\t\t\t// \treturn h(parent, null, { default: () => text.value });\n\t\t\t// }\n\n\t\t\treturn h(parent as VNode, null, {\n\t\t\t\tdefault: () => text.value,\n\t\t\t})\n\t\t}\n\t},\n})\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic rich text field as plain text.\n *\n * @see Component props {@link PrismicTextProps}\n * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}\n */\nexport const PrismicText = PrismicTextImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tPrismicTextProps\n\t}\n}\n"],"names":["computed","unref","isFilled","asText","defineComponent","simplyResolveComponent","h"],"mappings":";;;;;AAsBA,MAAM,iBAAiB;AA0DV,MAAA,iBAAiB,CAC7B,UAC6B;AACvB,QAAA,OAAOA,IAAAA,SAAS,MAAK;AACpB,UAAA,QAAQC,IAAAA,MAAM,MAAM,KAAK;AAE/B,QAAI,CAACC,OAAA,SAAS,SAAS,KAAK,GAAG;AACvB,aAAAD,UAAM,MAAM,QAAQ,KAAK;AAAA,IAAA;AAGjC,WAAOE,OAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAGA,IAAAA,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA;AAEF;AAOO,MAAM,kBAAgDG,oBAAAA,gBAAA;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IAAA;AAAA,EAEX;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,eAAe,KAAK;AAErC,WAAO,MAAK;AACX,YAAM,SAASC,uBAAA,uBAAuB,MAAM,WAAW,cAAc;AAS9D,aAAAC,IAAA,EAAE,QAAiB,MAAM;AAAA,QAC/B,SAAS,MAAM,KAAK;AAAA,MAAA,CACpB;AAAA,IACF;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,cAAc;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RichTextField } from "@prismicio/client";
|
|
2
|
-
import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNode, VNodeProps } from "vue";
|
|
3
|
-
import { VueUseOptions } from "../types";
|
|
1
|
+
import type { RichTextField } from "@prismicio/client";
|
|
2
|
+
import type { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNode, VNodeProps } from "vue";
|
|
3
|
+
import type { VueUseOptions } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `<PrismicText />`.
|
|
6
6
|
*/
|
|
@@ -56,7 +56,7 @@ export declare const usePrismicText: (props: UsePrismicTextOptions) => UsePrismi
|
|
|
56
56
|
*
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
|
-
export declare const PrismicTextImpl: DefineComponent<{
|
|
59
|
+
export declare const PrismicTextImpl: DefineComponent<import("vue").ExtractPropTypes<{
|
|
60
60
|
field: {
|
|
61
61
|
type: PropType<RichTextField | null | undefined>;
|
|
62
62
|
default: undefined;
|
|
@@ -77,9 +77,9 @@ export declare const PrismicTextImpl: DefineComponent<{
|
|
|
77
77
|
default: undefined;
|
|
78
78
|
required: false;
|
|
79
79
|
};
|
|
80
|
-
}
|
|
80
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
81
81
|
[key: string]: any;
|
|
82
|
-
}>,
|
|
82
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
83
83
|
field: {
|
|
84
84
|
type: PropType<RichTextField | null | undefined>;
|
|
85
85
|
default: undefined;
|
|
@@ -100,12 +100,12 @@ export declare const PrismicTextImpl: DefineComponent<{
|
|
|
100
100
|
default: undefined;
|
|
101
101
|
required: false;
|
|
102
102
|
};
|
|
103
|
-
}
|
|
103
|
+
}>> & Readonly<{}>, {
|
|
104
104
|
wrapper: string | ConcreteComponent | Raw<DefineComponent>;
|
|
105
105
|
field: RichTextField | null | undefined;
|
|
106
106
|
separator: string;
|
|
107
107
|
fallback: string;
|
|
108
|
-
}, {}>;
|
|
108
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
109
109
|
/**
|
|
110
110
|
* Component to render a Prismic rich text field as plain text.
|
|
111
111
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.js","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { RichTextField
|
|
1
|
+
{"version":3,"file":"PrismicText.js","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import type { RichTextField } from \"@prismicio/client\"\nimport { asText, isFilled } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n} from \"vue\"\nimport { computed, defineComponent, h, unref } from \"vue\"\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\n\nimport type { VueUseOptions } from \"../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":";;;AAsBA,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,IAAA;AAGjC,WAAO,OAAO,MAAM,KAAK,GAAG,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA;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,IAAA;AAAA,EAEX;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,IACF;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\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/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\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 V2, use the `Slice` export from\n * `@prismicio/client` 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\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` 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\tTSlice extends SliceLike = SliceLike,\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<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\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.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\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// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\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<{\n\t\t\tslice: SliceLike;\n\t }>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"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\n *\n * ```javascript\n * // Defining a slice components\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// TODO: Remove in v5 when the `resolver` prop is removed.\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<\n\t\t\t\tSliceZoneLike<SliceLike & Record<string, unknown>>\n\t\t\t>,\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\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t);\n\t\t\t}\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 =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : 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\n\t\t\t\t// TODO: Remove `resolver` in v5 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 && typeof slice.id === \"string\"\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\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t);\n\t\t\t\t}\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":";;;;;;AAwMa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,MAAM,UAAU;AACnB,kBAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAE9B,mBAAAE,IAAA,EAAEG,8CAAuB,SAA8B,GAAG;AAAA,cAChE;AAAA,cACA,GAAG;AAAA,YAAA,CACH;AAAA,UACF;AAEO,iBAAAH,IAAA,EAAEG,8CAAuB,SAA8B,GAAG;AAAA,YAChE;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS,MAAM;AAAA,YACf,QAAQ,MAAM;AAAA,UAAA,CACd;AAAA,QAAA,OACK;AACN,iBAAOH,IAAAA,EACNG,uBAAAA,uBAAuB,kBAAuC,GAC9D,EAAE,KAAK,OAAO;AAAA,QAEhB;AAAA,MAAA,CACA;AAAA,IAAA,CACD;AAED,WAAO,MAAK;AACX,UAAI,MAAM,SAAS;AACZ,cAAA,SAASA,uBAAAA,uBAAuB,MAAM,OAAO;AAE/C,YAAA,OAAO,WAAW,UAAU;AAC/B,iBAAOH,IAAE,EAAA,QAAQ,MAAM,eAAe,KAAK;AAAA,QAAA,OACrC;AACC,iBAAAA,IAAA,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,eAAe,OAAO;AAAA,QAC/D;AAAA,MAAA,OACM;AACN,eAAO,eAAe;AAAA,MACvB;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,YAAY;;;;;;"}
|
|
1
|
+
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import type { Slice } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tdefineAsyncComponent,\n} from \"vue\"\nimport { computed, defineComponent, h, markRaw, watchEffect } from \"vue\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\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\t? TSlice[\"type\"]\n\t\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/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\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 V2, use the `Slice` export from\n * `@prismicio/client` 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\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true\n}\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` 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\tTSlice extends SliceLike = SliceLike,\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<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\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.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * }\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\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 *\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-empty-object-type, @typescript-eslint/no-explicit-any\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\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<{\n\t\t\tslice: SliceLike\n\t\t}>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"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\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 *\n * @example\n *\n * ```javascript\n * // Defining a slice components\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\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// TODO: Remove in v5 when the `resolver` prop is removed.\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<\n\t\t\t\tSliceZoneLike<SliceLike & Record<string, unknown>>\n\t\t\t>,\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\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t)\n\t\t\t}\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 =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : 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\toptions.components?.sliceZoneDefaultComponent\n\n\t\t\t\t// TODO: Remove `resolver` in v5 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 && typeof slice.id === \"string\"\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\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t)\n\t\t\t\t}\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":";;;;;;AAqMa,MAAA,yBAAyB,CAMrC,eAC2D;AAAA,EAC3D,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,QAAQ;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,SAAS;AAAA,IACR,MAAM;AAAA,IAGN,UAAU;AAAA,EAAA;AAEX;AA4BM,MAAM,qBAAqBA,eAAA,iBAC7B,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,OACK;AACN,iBAAOH,IAAAA,EACNG,uBAAAA,uBAAuB,kBAAuC,GAC9D,EAAE,KAAK,OAAO;AAAA,QAAA;AAAA,MAEhB,CACA;AAAA,IAAA,CACD;AAED,WAAO,MAAK;AACX,UAAI,MAAM,SAAS;AACZ,cAAA,SAASA,uBAAAA,uBAAuB,MAAM,OAAO;AAE/C,YAAA,OAAO,WAAW,UAAU;AAC/B,iBAAOH,IAAE,EAAA,QAAQ,MAAM,eAAe,KAAK;AAAA,QAAA,OACrC;AACC,iBAAAA,IAAAA,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,eAAe,OAAO;AAAA,QAAA;AAAA,MAC/D,OACM;AACN,eAAO,eAAe;AAAA,MAAA;AAAA,IAExB;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,YAAY;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Slice } from "@prismicio/client";
|
|
2
|
-
import { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, DefineComponent, FunctionalComponent, PropType, Raw, VNodeProps, defineAsyncComponent } from "vue";
|
|
1
|
+
import type { Slice } from "@prismicio/client";
|
|
2
|
+
import type { AllowedComponentProps, ComponentCustomProps, ConcreteComponent, DefineComponent, FunctionalComponent, PropType, Raw, VNodeProps, defineAsyncComponent } from "vue";
|
|
3
3
|
/**
|
|
4
4
|
* Returns the type of a `SliceLike` type.
|
|
5
5
|
*
|
|
@@ -116,27 +116,28 @@ export type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, T
|
|
|
116
116
|
*
|
|
117
117
|
* ```javascript
|
|
118
118
|
* // Defining a new slice component
|
|
119
|
-
* import { getSliceComponentProps } from "@prismicio/vue"
|
|
119
|
+
* import { getSliceComponentProps } from "@prismicio/vue"
|
|
120
120
|
*
|
|
121
121
|
* export default {
|
|
122
122
|
* props: getSliceComponentProps(),
|
|
123
|
-
* }
|
|
123
|
+
* }
|
|
124
124
|
* ```
|
|
125
125
|
*
|
|
126
126
|
* @example
|
|
127
127
|
*
|
|
128
128
|
* ```javascript
|
|
129
129
|
* // Defining a new slice component with visual hint
|
|
130
|
-
* import { getSliceComponentProps } from "@prismicio/vue"
|
|
130
|
+
* import { getSliceComponentProps } from "@prismicio/vue"
|
|
131
131
|
*
|
|
132
132
|
* export default {
|
|
133
133
|
* props: getSliceComponentProps(["slice", "index", "slices", "context"]),
|
|
134
|
-
* }
|
|
134
|
+
* }
|
|
135
135
|
* ```
|
|
136
136
|
*
|
|
137
137
|
* @typeParam TSlice - The Slice type
|
|
138
138
|
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
139
139
|
* available to all Slice components
|
|
140
|
+
*
|
|
140
141
|
* @param propsHint - An optional array of prop names used for the sole purpose
|
|
141
142
|
* of having a visual hint of which props are made available to the slice,
|
|
142
143
|
* this parameters doesn't have any effect
|
|
@@ -158,7 +159,7 @@ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknow
|
|
|
158
159
|
* This is also the default Vue component rendered when a component mapping
|
|
159
160
|
* cannot be found in `<SliceZone />`.
|
|
160
161
|
*/
|
|
161
|
-
export declare const TODOSliceComponent: import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any,
|
|
162
|
+
export declare const TODOSliceComponent: import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | {
|
|
162
163
|
new (...args: any[]): any;
|
|
163
164
|
__isFragment?: never;
|
|
164
165
|
__isTeleport?: never;
|
|
@@ -183,6 +184,7 @@ export type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext =
|
|
|
183
184
|
* @remarks
|
|
184
185
|
* This is essentially an helper function to ensure {@link markRaw} is correctly
|
|
185
186
|
* applied on each components, improving performances.
|
|
187
|
+
*
|
|
186
188
|
* @example
|
|
187
189
|
*
|
|
188
190
|
* ```javascript
|
|
@@ -290,7 +292,7 @@ export type SliceZoneProps<TContext = unknown> = {
|
|
|
290
292
|
*
|
|
291
293
|
* @internal
|
|
292
294
|
*/
|
|
293
|
-
export declare const SliceZoneImpl: DefineComponent<{
|
|
295
|
+
export declare const SliceZoneImpl: DefineComponent<import("vue").ExtractPropTypes<{
|
|
294
296
|
slices: {
|
|
295
297
|
type: PropType<SliceZoneLike<SliceLike & Record<string, unknown>>>;
|
|
296
298
|
required: true;
|
|
@@ -320,11 +322,11 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
320
322
|
default: undefined;
|
|
321
323
|
required: false;
|
|
322
324
|
};
|
|
323
|
-
}
|
|
325
|
+
}>, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
324
326
|
[key: string]: any;
|
|
325
327
|
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
326
328
|
[key: string]: any;
|
|
327
|
-
}>[]),
|
|
329
|
+
}>[]), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
328
330
|
slices: {
|
|
329
331
|
type: PropType<SliceZoneLike<SliceLike & Record<string, unknown>>>;
|
|
330
332
|
required: true;
|
|
@@ -354,13 +356,13 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
354
356
|
default: undefined;
|
|
355
357
|
required: false;
|
|
356
358
|
};
|
|
357
|
-
}
|
|
359
|
+
}>> & Readonly<{}>, {
|
|
358
360
|
context: any;
|
|
359
361
|
components: SliceZoneComponents<SliceLike<string>, unknown>;
|
|
360
362
|
resolver: SliceZoneResolver<any, unknown>;
|
|
361
363
|
defaultComponent: SliceComponentType<any, unknown>;
|
|
362
364
|
wrapper: string | ConcreteComponent | Raw<DefineComponent>;
|
|
363
|
-
}, {}>;
|
|
365
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
364
366
|
/**
|
|
365
367
|
* Component to render a Prismic Slice Zone.
|
|
366
368
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\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/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\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 V2, use the `Slice` export from\n * `@prismicio/client` 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\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` 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\tTSlice extends SliceLike = SliceLike,\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<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\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.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\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// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\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<{\n\t\t\tslice: SliceLike;\n\t }>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"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\n *\n * ```javascript\n * // Defining a slice components\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// TODO: Remove in v5 when the `resolver` prop is removed.\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<\n\t\t\t\tSliceZoneLike<SliceLike & Record<string, unknown>>\n\t\t\t>,\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\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t);\n\t\t\t}\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 =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : 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\n\t\t\t\t// TODO: Remove `resolver` in v5 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 && typeof slice.id === \"string\"\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\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t);\n\t\t\t\t}\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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AC;AAErC,YAAI,WAAW;AACd,cAAI,MAAM,UAAU;AACnB,kBAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAE9B,mBAAA,EAAE,uBAAuB,SAA8B,GAAG;AAAA,cAChE;AAAA,cACA,GAAG;AAAA,YAAA,CACH;AAAA,UACF;AAEO,iBAAA,EAAE,uBAAuB,SAA8B,GAAG;AAAA,YAChE;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS,MAAM;AAAA,YACf,QAAQ,MAAM;AAAA,UAAA,CACd;AAAA,QAAA,OACK;AACN,iBAAO,EACN,uBAAuB,kBAAuC,GAC9D,EAAE,KAAK,OAAO;AAAA,QAEhB;AAAA,MAAA,CACA;AAAA,IAAA,CACD;AAED,WAAO,MAAK;AACX,UAAI,MAAM,SAAS;AACZ,cAAA,SAAS,uBAAuB,MAAM,OAAO;AAE/C,YAAA,OAAO,WAAW,UAAU;AAC/B,iBAAO,EAAE,QAAQ,MAAM,eAAe,KAAK;AAAA,QAAA,OACrC;AACC,iBAAA,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,eAAe,OAAO;AAAA,QAC/D;AAAA,MAAA,OACM;AACN,eAAO,eAAe;AAAA,MACvB;AAAA,IAAA;AAAA,EAEF;AACA,CAAA;AAUM,MAAM,YAAY;"}
|
|
1
|
+
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import type { Slice } from \"@prismicio/client\"\nimport type {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tdefineAsyncComponent,\n} from \"vue\"\nimport { computed, defineComponent, h, markRaw, watchEffect } from \"vue\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\"\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\t? TSlice[\"type\"]\n\t\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/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\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 V2, use the `Slice` export from\n * `@prismicio/client` 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\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true\n}\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` 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\tTSlice extends SliceLike = SliceLike,\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<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\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.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\"\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * }\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\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 *\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-empty-object-type, @typescript-eslint/no-explicit-any\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\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<{\n\t\t\tslice: SliceLike\n\t\t}>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"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\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 *\n * @example\n *\n * ```javascript\n * // Defining a slice components\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\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// TODO: Remove in v5 when the `resolver` prop is removed.\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<\n\t\t\t\tSliceZoneLike<SliceLike & Record<string, unknown>>\n\t\t\t>,\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\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t)\n\t\t\t}\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 =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : 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\toptions.components?.sliceZoneDefaultComponent\n\n\t\t\t\t// TODO: Remove `resolver` in v5 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 && typeof slice.id === \"string\"\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\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t)\n\t\t\t\t}\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":";;;;AAqMa,MAAA,yBAAyB,CAMrC,eAC2D;AAAA,EAC3D,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,OAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,QAAQ;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACV;AAAA,EACD,SAAS;AAAA,IACR,MAAM;AAAA,IAGN,UAAU;AAAA,EAAA;AAEX;AA4BM,MAAM,qBAAqB,iBAC7B,MAAM,OAGuB,gCAAA;AAAA,EAC/B,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,U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B,MAAM,OAAO;AAE/C,YAAA,OAAO,WAAW,UAAU;AAC/B,iBAAO,EAAE,QAAQ,MAAM,eAAe,KAAK;AAAA,QAAA,OACrC;AACC,iBAAA,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,eAAe,OAAO;AAAA,QAAA;AAAA,MAC/D,OACM;AACN,eAAO,eAAe;AAAA,MAAA;AAAA,IAExB;AAAA,EAAA;AAED,CAAA;AAUM,MAAM,YAAY;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PrismicEmbedImpl, PrismicEmbed } from "./PrismicEmbed";
|
|
2
2
|
export type { PrismicEmbedProps } from "./PrismicEmbed";
|
|
3
|
-
export { usePrismicImage, PrismicImageImpl, PrismicImage
|
|
3
|
+
export { usePrismicImage, PrismicImageImpl, PrismicImage } from "./PrismicImage";
|
|
4
4
|
export type { UsePrismicImageOptions, PrismicImageProps } from "./PrismicImage";
|
|
5
5
|
export { usePrismicLink, PrismicLinkImpl, PrismicLink } from "./PrismicLink";
|
|
6
6
|
export type { UsePrismicLinkOptions, PrismicLinkProps } from "./PrismicLink";
|
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// Imports for @link references:\nimport type { Client } from \"@prismicio/client\";\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport { PrismicDocument, Query } from \"@prismicio/client\";\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(\"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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 type { PrismicDocument, Query } from \"@prismicio/client\"\n\nimport type {\n\tClientComposableReturnType,\n\tClientMethodParameters,\n\tComposableOnlyParameters,\n} from \"./useStatefulPrismicClientMethod\"\nimport { useStatefulPrismicClientMethod } 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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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":";;;AA+BO,MAAM,sBAAsB,IAC/B,SAIHA,+BAAA,+BAA+B,OAAO,IAAI;AAkBpC,MAAM,0BAA0B,IACnC,SAIHA,+BAAA,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,yBAAyB,IAClC,SAKHA,+BAAA,+BAA+B,WAAW,IAAI;AAmBxC,MAAM,2BAA2B,IACpC,SAKHA,+BAAA,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,8BAA8B,IACvC,SAMHA,+BAAA,+BAA+B,eAAe,IAAI;AAoB5C,MAAM,0BAA0B,IACnC,SAMHA,+BAAA,+BAA+B,YAAY,IAAI;AAoBzC,MAAM,4BAA4B,IACrC,SAMHA,+BAAA,+BAA+B,aAAa,IAAI;AAoB1C,MAAM,+BAA+B,IACxC,SAOHA,+BAAA,+BAA+B,gBAAgB,IAAI;AAmB7C,MAAM,2BAA2B,IACpC,SA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