@prismicio/vue 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/components/PrismicEmbed.cjs.map +1 -1
  2. package/dist/components/PrismicEmbed.d.ts +57 -63
  3. package/dist/components/PrismicEmbed.js.map +1 -1
  4. package/dist/components/PrismicImage.cjs.map +1 -1
  5. package/dist/components/PrismicImage.d.ts +161 -161
  6. package/dist/components/PrismicImage.js.map +1 -1
  7. package/dist/components/PrismicLink.cjs.map +1 -1
  8. package/dist/components/PrismicLink.d.ts +190 -190
  9. package/dist/components/PrismicLink.js.map +1 -1
  10. package/dist/components/PrismicRichText.cjs.map +1 -1
  11. package/dist/components/PrismicRichText.d.ts +159 -159
  12. package/dist/components/PrismicRichText.js.map +1 -1
  13. package/dist/components/PrismicText.cjs.map +1 -1
  14. package/dist/components/PrismicText.d.ts +117 -117
  15. package/dist/components/PrismicText.js.map +1 -1
  16. package/dist/components/SliceZone.cjs +26 -18
  17. package/dist/components/SliceZone.cjs.map +1 -1
  18. package/dist/components/SliceZone.d.ts +373 -371
  19. package/dist/components/SliceZone.js +26 -18
  20. package/dist/components/SliceZone.js.map +1 -1
  21. package/dist/components/index.d.ts +12 -12
  22. package/dist/composables.d.ts +384 -384
  23. package/dist/createPrismic.cjs.map +1 -1
  24. package/dist/createPrismic.d.ts +12 -12
  25. package/dist/createPrismic.js.map +1 -1
  26. package/dist/globalExtensions.d.ts +11 -11
  27. package/dist/index.d.ts +10 -10
  28. package/dist/injectionSymbols.d.ts +9 -9
  29. package/dist/lib/__PRODUCTION__.cjs.map +1 -1
  30. package/dist/lib/__PRODUCTION__.d.ts +7 -7
  31. package/dist/lib/__PRODUCTION__.js.map +1 -1
  32. package/dist/lib/getSlots.cjs.map +1 -1
  33. package/dist/lib/getSlots.d.ts +14 -14
  34. package/dist/lib/getSlots.js.map +1 -1
  35. package/dist/lib/isInternalURL.d.ts +8 -8
  36. package/dist/lib/simplyResolveComponent.d.ts +12 -12
  37. package/dist/types.d.ts +384 -384
  38. package/dist/usePrismic.d.ts +22 -22
  39. package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
  40. package/dist/useStatefulPrismicClientMethod.d.ts +64 -64
  41. package/dist/useStatefulPrismicClientMethod.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/components/SliceZone.ts +44 -43
@@ -1,159 +1,159 @@
1
- import { HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction, RichTextField } from "@prismicio/client";
2
- import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
3
- import { VueUseOptions } from "../types";
4
- /**
5
- * Props for `<PrismicRichText />`.
6
- */
7
- export declare type PrismicRichTextProps = {
8
- /**
9
- * The Prismic rich text or title field to render.
10
- */
11
- field: RichTextField | null | undefined;
12
- /**
13
- * A link resolver function used to resolve link when not using the route
14
- * resolver parameter with `@prismicio/client`.
15
- *
16
- * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
17
- *
18
- * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
19
- */
20
- linkResolver?: LinkResolverFunction;
21
- /**
22
- * An HTML serializer to customize the way rich text fields are rendered.
23
- *
24
- * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.
25
- *
26
- * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
27
- */
28
- serializer?: HTMLFunctionSerializer | HTMLMapSerializer;
29
- /**
30
- * An HTML serializer to customize the way rich text fields are rendered.
31
- *
32
- * @deprecated Use `serializer` instead.
33
- *
34
- * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.
35
- *
36
- * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
37
- */
38
- htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
39
- /**
40
- * An HTML tag name, a component, or a functional component used to wrap the
41
- * output.
42
- *
43
- * @defaultValue `"div"`
44
- */
45
- wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
46
- /**
47
- * The HTML value to be rendered when the field is empty. If a fallback is not
48
- * given, `""` (nothing) will be rendered.
49
- */
50
- fallback?: string;
51
- };
52
- /**
53
- * Options for {@link usePrismicRichText}.
54
- */
55
- export declare type UsePrismicRichTextOptions = VueUseOptions<Omit<PrismicRichTextProps, "wrapper">>;
56
- /**
57
- * Return type of {@link usePrismicRichText}.
58
- */
59
- export declare type UsePrismicRichTextReturnType = {
60
- /**
61
- * Serialized rich text field as HTML.
62
- */
63
- html: ComputedRef<string>;
64
- };
65
- /**
66
- * A low level composable that returns a serialized rich text field as HTML.
67
- *
68
- * @param props - {@link UsePrismicRichTextOptions}
69
- *
70
- * @returns - Serialized rich text field as HTML
71
- * {@link UsePrismicRichTextReturnType}
72
- */
73
- export declare const usePrismicRichText: (props: UsePrismicRichTextOptions) => UsePrismicRichTextReturnType;
74
- /**
75
- * `<PrismicRichText />` implementation.
76
- *
77
- * @internal
78
- */
79
- export declare const PrismicRichTextImpl: DefineComponent<{
80
- field: {
81
- type: PropType<[] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined>;
82
- default: undefined;
83
- required: false;
84
- };
85
- linkResolver: {
86
- type: PropType<LinkResolverFunction<string | null | undefined>>;
87
- default: undefined;
88
- required: false;
89
- };
90
- serializer: {
91
- type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
92
- default: undefined;
93
- required: false;
94
- };
95
- htmlSerializer: {
96
- type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
97
- default: undefined;
98
- required: false;
99
- };
100
- wrapper: {
101
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>>;
102
- default: undefined;
103
- required: false;
104
- };
105
- fallback: {
106
- type: PropType<string>;
107
- default: undefined;
108
- required: false;
109
- };
110
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
111
- [key: string]: any;
112
- }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
113
- field: {
114
- type: PropType<[] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined>;
115
- default: undefined;
116
- required: false;
117
- };
118
- linkResolver: {
119
- type: PropType<LinkResolverFunction<string | null | undefined>>;
120
- default: undefined;
121
- required: false;
122
- };
123
- serializer: {
124
- type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
125
- default: undefined;
126
- required: false;
127
- };
128
- htmlSerializer: {
129
- type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
130
- default: undefined;
131
- required: false;
132
- };
133
- wrapper: {
134
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>>;
135
- default: undefined;
136
- required: false;
137
- };
138
- fallback: {
139
- type: PropType<string>;
140
- default: undefined;
141
- required: false;
142
- };
143
- }>>, {
144
- wrapper: string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>;
145
- field: [] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined;
146
- linkResolver: LinkResolverFunction<string | null | undefined>;
147
- fallback: string;
148
- serializer: import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer;
149
- htmlSerializer: import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer;
150
- }, {}>;
151
- /**
152
- * Component to render a Prismic rich text field as HTML.
153
- *
154
- * @see Component props {@link PrismicRichTextProps}
155
- * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
156
- */
157
- export declare const PrismicRichText: new () => {
158
- $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicRichTextProps;
159
- };
1
+ import { HTMLFunctionSerializer, HTMLMapSerializer, LinkResolverFunction, RichTextField } from "@prismicio/client";
2
+ import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNodeProps } from "vue";
3
+ import { VueUseOptions } from "../types";
4
+ /**
5
+ * Props for `<PrismicRichText />`.
6
+ */
7
+ export type PrismicRichTextProps = {
8
+ /**
9
+ * The Prismic rich text or title field to render.
10
+ */
11
+ field: RichTextField | null | undefined;
12
+ /**
13
+ * A link resolver function used to resolve link when not using the route
14
+ * resolver parameter with `@prismicio/client`.
15
+ *
16
+ * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
17
+ *
18
+ * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
19
+ */
20
+ linkResolver?: LinkResolverFunction;
21
+ /**
22
+ * An HTML serializer to customize the way rich text fields are rendered.
23
+ *
24
+ * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.
25
+ *
26
+ * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
27
+ */
28
+ serializer?: HTMLFunctionSerializer | HTMLMapSerializer;
29
+ /**
30
+ * An HTML serializer to customize the way rich text fields are rendered.
31
+ *
32
+ * @deprecated Use `serializer` instead.
33
+ *
34
+ * @defaultValue The HTML serializer provided to `@prismicio/vue` plugin if configured.
35
+ *
36
+ * @see HTML serializer documentation {@link https://prismic.io/docs/core-concepts/html-serializer}
37
+ */
38
+ htmlSerializer?: HTMLFunctionSerializer | HTMLMapSerializer;
39
+ /**
40
+ * An HTML tag name, a component, or a functional component used to wrap the
41
+ * output.
42
+ *
43
+ * @defaultValue `"div"`
44
+ */
45
+ wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
46
+ /**
47
+ * The HTML value to be rendered when the field is empty. If a fallback is not
48
+ * given, `""` (nothing) will be rendered.
49
+ */
50
+ fallback?: string;
51
+ };
52
+ /**
53
+ * Options for {@link usePrismicRichText}.
54
+ */
55
+ export type UsePrismicRichTextOptions = VueUseOptions<Omit<PrismicRichTextProps, "wrapper">>;
56
+ /**
57
+ * Return type of {@link usePrismicRichText}.
58
+ */
59
+ export type UsePrismicRichTextReturnType = {
60
+ /**
61
+ * Serialized rich text field as HTML.
62
+ */
63
+ html: ComputedRef<string>;
64
+ };
65
+ /**
66
+ * A low level composable that returns a serialized rich text field as HTML.
67
+ *
68
+ * @param props - {@link UsePrismicRichTextOptions}
69
+ *
70
+ * @returns - Serialized rich text field as HTML
71
+ * {@link UsePrismicRichTextReturnType}
72
+ */
73
+ export declare const usePrismicRichText: (props: UsePrismicRichTextOptions) => UsePrismicRichTextReturnType;
74
+ /**
75
+ * `<PrismicRichText />` implementation.
76
+ *
77
+ * @internal
78
+ */
79
+ export declare const PrismicRichTextImpl: DefineComponent<{
80
+ field: {
81
+ type: PropType<RichTextField | null | undefined>;
82
+ default: undefined;
83
+ required: false;
84
+ };
85
+ linkResolver: {
86
+ type: PropType<LinkResolverFunction>;
87
+ default: undefined;
88
+ required: false;
89
+ };
90
+ serializer: {
91
+ type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
92
+ default: undefined;
93
+ required: false;
94
+ };
95
+ htmlSerializer: {
96
+ type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
97
+ default: undefined;
98
+ required: false;
99
+ };
100
+ wrapper: {
101
+ type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
102
+ default: undefined;
103
+ required: false;
104
+ };
105
+ fallback: {
106
+ type: PropType<string>;
107
+ default: undefined;
108
+ required: false;
109
+ };
110
+ }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
111
+ [key: string]: any;
112
+ }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
113
+ field: {
114
+ type: PropType<RichTextField | null | undefined>;
115
+ default: undefined;
116
+ required: false;
117
+ };
118
+ linkResolver: {
119
+ type: PropType<LinkResolverFunction>;
120
+ default: undefined;
121
+ required: false;
122
+ };
123
+ serializer: {
124
+ type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
125
+ default: undefined;
126
+ required: false;
127
+ };
128
+ htmlSerializer: {
129
+ type: PropType<import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer>;
130
+ default: undefined;
131
+ required: false;
132
+ };
133
+ wrapper: {
134
+ type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
135
+ default: undefined;
136
+ required: false;
137
+ };
138
+ fallback: {
139
+ type: PropType<string>;
140
+ default: undefined;
141
+ required: false;
142
+ };
143
+ }>>, {
144
+ wrapper: string | ConcreteComponent | Raw<DefineComponent>;
145
+ field: RichTextField | null | undefined;
146
+ linkResolver: LinkResolverFunction;
147
+ fallback: string;
148
+ serializer: import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer;
149
+ htmlSerializer: import("@prismicio/client").HTMLRichTextFunctionSerializer | import("@prismicio/client").HTMLRichTextMapSerializer;
150
+ }, {}>;
151
+ /**
152
+ * Component to render a Prismic rich text field as HTML.
153
+ *
154
+ * @see Component props {@link PrismicRichTextProps}
155
+ * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
156
+ */
157
+ export declare const PrismicRichText: new () => {
158
+ $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicRichTextProps;
159
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tRichTextField,\n\tasHTML,\n\tisFilled,\n} from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\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 { 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":";;;;;;AAwCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,YAAY;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,IAChC;AAED,UAAM,eAAe,MAAM,MAAM,YAAY,KAAK,QAAQ;AACpD,UAAA,aACL,MAAM,MAAM,UAAU,KACtB,MAAM,MAAM,cAAc,KAC1B,QAAQ,sBACR,QAAQ;AAET,WAAO,OAAO,MAAM,KAAK,GAAG,cAAc,UAAU;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,sBAAoD,gCAAA;AAAA,EAChE,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACX,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,mBAAmB,KAAK;AAEnC,UAAA,OAAO,IAA8C,IAAI;AAEzD,UAAA,cAAc,OAAO,WAAW,IAAI;AAC1C,QAAI,aAAa;AAKhB,UAAI,QAAwB,CAAA;AAEtB,YAAA,WAA0B,SAE/B,OAAY;AAEZ,cAAM,eAAc;AACR,oBAAA,KAAK,KAAK,IAAI;AAAA,MAAA;AAG3B,YAAM,eAAe,MAAK;AACnB,cAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,YAAA,QAAQ,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,KAAM,CAAA;AAC/B,sBAAA,iBAAiB,SAAS,QAAQ;AAEnC,qBAAA,EAAE,SAAS;mBACZ;AACC,qBAAA;AAAA,YACP;AAAA,UACD,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,QACxD;AAAA,MAAA;AAGF,YAAM,kBAAkB,MAAK;AACtB,cAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ,CAAC;AAE/C,gBAAQ,CAAA;AAAA;AAGT,YACC,MACA,MAAK;;AAEJ,iBAAS,YAAY;AAAA,MAAA,GAEtB,EAAE,WAAW,KAAA,CAAM;AAGpB,sBAAgB,MAAK;;OAEpB;AAAA,IACD;AAED,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,WAAW,KAAK;AAAA,QAChB,KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,kBAAkB;"}
1
+ {"version":3,"file":"PrismicRichText.js","sources":["../../../src/components/PrismicRichText.ts"],"sourcesContent":["import {\n\tHTMLFunctionSerializer,\n\tHTMLMapSerializer,\n\tLinkResolverFunction,\n\tRichTextField,\n\tasHTML,\n\tisFilled,\n} from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponent,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\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 { 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":";;;;;;AAwCA,MAAM,iBAAiB;AAiFV,MAAA,qBAAqB,CACjC,UACiC;AAC3B,QAAA,EAAE,YAAY;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,IACjC;AAEA,UAAM,eAAe,MAAM,MAAM,YAAY,KAAK,QAAQ;AACpD,UAAA,aACL,MAAM,MAAM,UAAU,KACtB,MAAM,MAAM,cAAc,KAC1B,QAAQ,sBACR,QAAQ;AAET,WAAO,OAAO,MAAM,KAAK,GAAG,cAAc,UAAU;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;AAOO,MAAM,sBAAoD,gCAAA;AAAA,EAChE,MAAM;AAAA,EACN,OAAO;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,cAAc;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,YAAY;AAAA,MACX,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM,CAAC,UAAU,MAAM;AAAA,MAGvB,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,SAAS;AAAA,MACR,MAAM,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAG/B,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,IACD,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACV;AAAA,EACD;AAAA,EACD,MAAM,OAAK;AACV,UAAM,EAAE,KAAA,IAAS,mBAAmB,KAAK;AAEnC,UAAA,OAAO,IAA8C,IAAI;AAEzD,UAAA,cAAc,OAAO,WAAW,IAAI;AAC1C,QAAI,aAAa;AAKhB,UAAI,QAAwB,CAAA;AAEtB,YAAA,WAA0B,SAE/B,OAAY;AAEZ,cAAM,eAAc;AACR,oBAAA,KAAK,KAAK,IAAI;AAAA,MAAA;AAG3B,YAAM,eAAe,MAAK;AACnB,cAAA,OACL,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;AACvD,YAAA,QAAQ,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,KAAM,CAAA;AAC/B,sBAAA,iBAAiB,SAAS,QAAQ;AAEnC,qBAAA,EAAE,SAAS;mBACZ;AACC,qBAAA;AAAA,YACR;AAAA,UACA,CAAA,EACA,OAAO,CAAC,SAA+B,IAAe;AAAA,QACzD;AAAA,MAAA;AAGD,YAAM,kBAAkB,MAAK;AACtB,cAAA,QAAQ,CAAC,EAAE,SAAS,SAAA,MACzB,QAAQ,oBAAoB,SAAS,QAAQ,CAAC;AAE/C,gBAAQ,CAAA;AAAA;AAGT,YACC,MACA,MAAK;;AAEJ,iBAAS,YAAY;AAAA,MAAA,GAEtB,EAAE,WAAW,KAAA,CAAM;AAGpB,sBAAgB,MAAK;;OAEpB;AAAA,IACF;AAEA,WAAO,MAAK;AACX,aAAO,EAAE,uBAAuB,MAAM,WAAW,cAAc,GAAG;AAAA,QACjE,WAAW,KAAK;AAAA,QAChB,KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,kBAAkB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { RichTextField, asText, isFilled } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\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":";;;;;AAwBA,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,IAChC;AAED,WAAOE,OAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAGA,IAAAA,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;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,IACV;AAAA,EACD;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,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
1
+ {"version":3,"file":"PrismicText.cjs","sources":["../../../src/components/PrismicText.ts"],"sourcesContent":["import { RichTextField, asText, isFilled } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tComputedRef,\n\tConcreteComponent,\n\tDefineComponent,\n\tPropType,\n\tRaw,\n\tVNode,\n\tVNodeProps,\n\tcomputed,\n\tdefineComponent,\n\th,\n\tunref,\n} from \"vue\";\n\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { VueUseOptions } from \"../types\";\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":";;;;;AAwBA,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,IACjC;AAEA,WAAOE,OAAAA,OAAOF,IAAAA,MAAM,KAAK,GAAGA,IAAAA,MAAM,MAAM,SAAS,CAAC;AAAA,EAAA,CAClD;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;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,IACV;AAAA,EACD;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,IAAA;AAAA,EAEH;AACA,CAAA;AAUM,MAAM,cAAc;;;;"}
@@ -1,117 +1,117 @@
1
- import { RichTextField } from "@prismicio/client";
2
- import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNode, VNodeProps } from "vue";
3
- import { VueUseOptions } from "../types";
4
- /**
5
- * Props for `<PrismicText />`.
6
- */
7
- export declare type PrismicTextProps = {
8
- /**
9
- * The Prismic rich text or title field to render.
10
- */
11
- field: RichTextField | null | undefined;
12
- /**
13
- * Separator used to join each element.
14
- *
15
- * @defaultValue `" "` (a space)
16
- */
17
- separator?: string;
18
- /**
19
- * An HTML tag name, a component, or a functional component used to wrap the
20
- * output.
21
- *
22
- * @defaultValue `"div"`
23
- */
24
- wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
25
- /**
26
- * The string value to be rendered when the field is empty. If a fallback is
27
- * not given, `""` (nothing) will be rendered.
28
- */
29
- fallback?: string;
30
- };
31
- /**
32
- * Options for {@link usePrismicText}.
33
- */
34
- export declare type UsePrismicTextOptions = VueUseOptions<Omit<PrismicTextProps, "wrapper">>;
35
- /**
36
- * Return type of {@link usePrismicText}.
37
- */
38
- export declare type UsePrismicTextReturnType = {
39
- /**
40
- * Serialized rich text field as plain text.
41
- */
42
- text: ComputedRef<string>;
43
- };
44
- /**
45
- * A low level composable that returns a serialized rich text field as plain
46
- * text.
47
- *
48
- * @param props - {@link UsePrismicTextOptions}
49
- *
50
- * @returns - Serialized rich text field as plain text
51
- * {@link UsePrismicTextReturnType}
52
- */
53
- export declare const usePrismicText: (props: UsePrismicTextOptions) => UsePrismicTextReturnType;
54
- /**
55
- * `<PrismicText />` implementation.
56
- *
57
- * @internal
58
- */
59
- export declare const PrismicTextImpl: DefineComponent<{
60
- field: {
61
- type: PropType<[] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined>;
62
- default: undefined;
63
- required: false;
64
- };
65
- separator: {
66
- type: PropType<string>;
67
- default: undefined;
68
- required: false;
69
- };
70
- wrapper: {
71
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>>;
72
- default: undefined;
73
- required: false;
74
- };
75
- fallback: {
76
- type: PropType<string>;
77
- default: undefined;
78
- required: false;
79
- };
80
- }, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
81
- [key: string]: any;
82
- }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
83
- field: {
84
- type: PropType<[] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined>;
85
- default: undefined;
86
- required: false;
87
- };
88
- separator: {
89
- type: PropType<string>;
90
- default: undefined;
91
- required: false;
92
- };
93
- wrapper: {
94
- type: PropType<string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>>;
95
- default: undefined;
96
- required: false;
97
- };
98
- fallback: {
99
- type: PropType<string>;
100
- default: undefined;
101
- required: false;
102
- };
103
- }>>, {
104
- wrapper: string | ConcreteComponent<{}, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | Raw<DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>>;
105
- field: [] | [import("@prismicio/client").RTNode, ...import("@prismicio/client").RTNode[]] | null | undefined;
106
- separator: string;
107
- fallback: string;
108
- }, {}>;
109
- /**
110
- * Component to render a Prismic rich text field as plain text.
111
- *
112
- * @see Component props {@link PrismicTextProps}
113
- * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
114
- */
115
- export declare const PrismicText: new () => {
116
- $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicTextProps;
117
- };
1
+ import { RichTextField } from "@prismicio/client";
2
+ import { AllowedComponentProps, ComponentCustomProps, ComputedRef, ConcreteComponent, DefineComponent, PropType, Raw, VNode, VNodeProps } from "vue";
3
+ import { VueUseOptions } from "../types";
4
+ /**
5
+ * Props for `<PrismicText />`.
6
+ */
7
+ export type PrismicTextProps = {
8
+ /**
9
+ * The Prismic rich text or title field to render.
10
+ */
11
+ field: RichTextField | null | undefined;
12
+ /**
13
+ * Separator used to join each element.
14
+ *
15
+ * @defaultValue `" "` (a space)
16
+ */
17
+ separator?: string;
18
+ /**
19
+ * An HTML tag name, a component, or a functional component used to wrap the
20
+ * output.
21
+ *
22
+ * @defaultValue `"div"`
23
+ */
24
+ wrapper?: string | ConcreteComponent | Raw<DefineComponent>;
25
+ /**
26
+ * The string value to be rendered when the field is empty. If a fallback is
27
+ * not given, `""` (nothing) will be rendered.
28
+ */
29
+ fallback?: string;
30
+ };
31
+ /**
32
+ * Options for {@link usePrismicText}.
33
+ */
34
+ export type UsePrismicTextOptions = VueUseOptions<Omit<PrismicTextProps, "wrapper">>;
35
+ /**
36
+ * Return type of {@link usePrismicText}.
37
+ */
38
+ export type UsePrismicTextReturnType = {
39
+ /**
40
+ * Serialized rich text field as plain text.
41
+ */
42
+ text: ComputedRef<string>;
43
+ };
44
+ /**
45
+ * A low level composable that returns a serialized rich text field as plain
46
+ * text.
47
+ *
48
+ * @param props - {@link UsePrismicTextOptions}
49
+ *
50
+ * @returns - Serialized rich text field as plain text
51
+ * {@link UsePrismicTextReturnType}
52
+ */
53
+ export declare const usePrismicText: (props: UsePrismicTextOptions) => UsePrismicTextReturnType;
54
+ /**
55
+ * `<PrismicText />` implementation.
56
+ *
57
+ * @internal
58
+ */
59
+ export declare const PrismicTextImpl: DefineComponent<{
60
+ field: {
61
+ type: PropType<RichTextField | null | undefined>;
62
+ default: undefined;
63
+ required: false;
64
+ };
65
+ separator: {
66
+ type: PropType<string>;
67
+ default: undefined;
68
+ required: false;
69
+ };
70
+ wrapper: {
71
+ type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
72
+ default: undefined;
73
+ required: false;
74
+ };
75
+ fallback: {
76
+ type: PropType<string>;
77
+ default: undefined;
78
+ required: false;
79
+ };
80
+ }, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
81
+ [key: string]: any;
82
+ }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
83
+ field: {
84
+ type: PropType<RichTextField | null | undefined>;
85
+ default: undefined;
86
+ required: false;
87
+ };
88
+ separator: {
89
+ type: PropType<string>;
90
+ default: undefined;
91
+ required: false;
92
+ };
93
+ wrapper: {
94
+ type: PropType<string | ConcreteComponent | Raw<DefineComponent>>;
95
+ default: undefined;
96
+ required: false;
97
+ };
98
+ fallback: {
99
+ type: PropType<string>;
100
+ default: undefined;
101
+ required: false;
102
+ };
103
+ }>>, {
104
+ wrapper: string | ConcreteComponent | Raw<DefineComponent>;
105
+ field: RichTextField | null | undefined;
106
+ separator: string;
107
+ fallback: string;
108
+ }, {}>;
109
+ /**
110
+ * Component to render a Prismic rich text field as plain text.
111
+ *
112
+ * @see Component props {@link PrismicTextProps}
113
+ * @see Templating rich text and title fields {@link https://prismic.io/docs/technologies/vue-template-content#rich-text-and-titles}
114
+ */
115
+ export declare const PrismicText: new () => {
116
+ $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & PrismicTextProps;
117
+ };