@prismicio/vue 5.3.0-pr.86.915aa0e → 5.3.0-pr.88.72388e2
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/PrismicImage.vue.d.cts +26 -54
- package/dist/PrismicImage.vue.d.cts.map +1 -1
- package/dist/PrismicLink.vue.d.cts +56 -48
- package/dist/PrismicLink.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +18 -41
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/types.d.cts +3 -3
- package/dist/PrismicRichText/types.d.cts.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue.d.cts +4 -4
- package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -1
- package/dist/PrismicTable/types.d.cts +1 -2
- package/dist/PrismicTable/types.d.cts.map +1 -1
- package/dist/PrismicText.vue.d.cts +1 -3
- package/dist/PrismicText.vue.d.cts.map +1 -1
- package/dist/SliceZone/SliceZone.vue.d.cts +3 -14
- package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/src/PrismicImage.cjs.map +1 -1
- package/dist/src/PrismicImage.js.map +1 -1
- package/dist/src/PrismicImage.vue.d.ts +30 -58
- package/dist/src/PrismicImage.vue.d.ts.map +1 -1
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicLink.cjs.map +1 -1
- package/dist/src/PrismicLink.js.map +1 -1
- package/dist/src/PrismicLink.vue.d.ts +60 -52
- package/dist/src/PrismicLink.vue.d.ts.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts +22 -45
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +39 -22
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js +39 -22
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs +6 -26
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js +6 -26
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.js.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs +7 -48
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js +7 -48
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/types.d.ts +3 -3
- package/dist/src/PrismicRichText/types.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts +6 -6
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +43 -15
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js +44 -16
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs +13 -10
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js +14 -11
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicTable/types.d.ts +1 -2
- package/dist/src/PrismicTable/types.d.ts.map +1 -1
- package/dist/src/PrismicText.cjs.map +1 -1
- package/dist/src/PrismicText.js.map +1 -1
- package/dist/src/PrismicText.vue.d.ts +3 -5
- package/dist/src/PrismicText.vue.d.ts.map +1 -1
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/SliceZone/SliceZone.cjs.map +1 -1
- package/dist/src/SliceZone/SliceZone.js.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue.d.ts +5 -16
- package/dist/src/SliceZone/SliceZone.vue.d.ts.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/types.cjs +9 -0
- package/dist/src/types.cjs.map +1 -0
- package/dist/src/types.d.ts +3 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +8 -0
- package/dist/src/types.js.map +1 -0
- package/dist/types.d.cts +3 -2
- package/dist/types.d.cts.map +1 -1
- package/package.json +1 -1
- package/src/PrismicImage.vue +8 -16
- package/src/PrismicLink.vue +12 -12
- package/src/PrismicRichText/PrismicRichText.vue +69 -49
- package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +38 -22
- package/src/PrismicRichText/PrismicRichTextSerialize.vue +5 -51
- package/src/PrismicRichText/types.ts +17 -13
- package/src/PrismicTable/PrismicTable.vue +44 -17
- package/src/PrismicTable/PrismicTableDefaultComponents.ts +14 -8
- package/src/PrismicTable/PrismicTableRow.vue +17 -24
- package/src/PrismicTable/types.ts +14 -11
- package/src/PrismicText.vue +1 -3
- package/src/SliceZone/SliceZone.vue +3 -14
- package/src/types.ts +31 -1
- package/src/lib/Wrapper.vue +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.cjs","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t
|
|
1
|
+
{"version":3,"file":"PrismicText.cjs","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\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\t/**\n\t * The separator used between blocks.\n\t *\n\t * @defaultValue `\" \"` (a whitespace)\n\t */\n\tseparator?: string\n}\n\nconst props = defineProps<PrismicTextProps>()\ndefineOptions({ name: \"PrismicText\" })\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}, {})\n}\n</script>\n\n<template>\n\t{{ asText(field) || fallback || \"\" }}\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.js","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t
|
|
1
|
+
{"version":3,"file":"PrismicText.js","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\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\t/**\n\t * The separator used between blocks.\n\t *\n\t * @defaultValue `\" \"` (a whitespace)\n\t */\n\tseparator?: string\n}\n\nconst props = defineProps<PrismicTextProps>()\ndefineOptions({ name: \"PrismicText\" })\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}, {})\n}\n</script>\n\n<template>\n\t{{ asText(field) || fallback || \"\" }}\n</template>\n"],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue14 from "vue";
|
|
2
2
|
import { RichTextField } from "@prismicio/client";
|
|
3
3
|
|
|
4
4
|
//#region src/PrismicText.vue.d.ts
|
|
@@ -6,9 +6,7 @@ import { RichTextField } from "@prismicio/client";
|
|
|
6
6
|
* Props for `<PrismicText />`.
|
|
7
7
|
*/
|
|
8
8
|
type PrismicTextProps = {
|
|
9
|
-
/**
|
|
10
|
-
* The Prismic rich text field to render.
|
|
11
|
-
*/
|
|
9
|
+
/** The Prismic rich text field to render. */
|
|
12
10
|
field: RichTextField | null | undefined;
|
|
13
11
|
/**
|
|
14
12
|
* The string value to be rendered when the field is empty. If a fallback is
|
|
@@ -22,7 +20,7 @@ type PrismicTextProps = {
|
|
|
22
20
|
*/
|
|
23
21
|
separator?: string;
|
|
24
22
|
};
|
|
25
|
-
declare const __VLS_export:
|
|
23
|
+
declare const __VLS_export: vue14.DefineComponent<PrismicTextProps, {}, {}, {}, {}, vue14.ComponentOptionsMixin, vue14.ComponentOptionsMixin, {}, string, vue14.PublicProps, Readonly<PrismicTextProps> & Readonly<{}>, {}, {}, {}, {}, string, vue14.ComponentProvideOptions, false, {}, any>;
|
|
26
24
|
declare const _default: typeof __VLS_export;
|
|
27
25
|
//#endregion
|
|
28
26
|
export { PrismicTextProps, _default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.vue.d.ts","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PrismicText.vue.d.ts","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":[],"mappings":";;;;;;;AA4DY,KAAA,gBAAA,GAAgB;EAqDtB;EAAY,KAAA,EAnDV,aAmDU,GAAA,IAAA,GAAA,SAAA;EAAA;;;;EAAA,QAAA,CAAA,EAAA,MAAA;EAAA;;;;AAAA;;;cAAZ,cAAY,KAAA,CAAA,gBAAA,kCAAA,KAAA,CAAA,qBAAA,EAAA,KAAA,CAAA,qBAAA,cAAA,KAAA,CAAA,WAAA,EAAA,SAAA,oBAAA,sCAAA,KAAA,CAAA,uBAAA;cAAA,iBAGU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t
|
|
1
|
+
{"version":3,"file":"PrismicText.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\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\t/**\n\t * The separator used between blocks.\n\t *\n\t * @defaultValue `\" \"` (a whitespace)\n\t */\n\tseparator?: string\n}\n\nconst props = defineProps<PrismicTextProps>()\ndefineOptions({ name: \"PrismicText\" })\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}, {})\n}\n</script>\n\n<template>\n\t{{ asText(field) || fallback || \"\" }}\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,QAAQ;AAGd,MAAI,YACH,4BAAkB;AACjB,OAAI,OAAO,MAAM,UAAU,SAC1B,OAAM,IAAI,MACT,oRAAoR,sBACnR,yDACA,GACF;KAEC,EAAE,CAAA;;kDAKF,0BAAM,CAAC,QAAA,MAAK,IAAK,QAAA,YAAQ,GAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t
|
|
1
|
+
{"version":3,"file":"PrismicText.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicText.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RichTextField } from \"@prismicio/client\"\nimport { asText } from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Props for `<PrismicText />`.\n */\nexport type PrismicTextProps = {\n\t/** The Prismic rich text field to render. */\n\tfield: RichTextField | null | undefined\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\t/**\n\t * The separator used between blocks.\n\t *\n\t * @defaultValue `\" \"` (a whitespace)\n\t */\n\tseparator?: string\n}\n\nconst props = defineProps<PrismicTextProps>()\ndefineOptions({ name: \"PrismicText\" })\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\t}, {})\n}\n</script>\n\n<template>\n\t{{ asText(field) || fallback || \"\" }}\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,QAAQ;AAGd,MAAI,IACH,mBAAkB;AACjB,OAAI,OAAO,MAAM,UAAU,SAC1B,OAAM,IAAI,MACT,oRAAoR,OACnR,yDACA,GACF;KAEC,EAAE,CAAA;;0BAKF,MAAA,OAAM,CAAC,QAAA,MAAK,IAAK,QAAA,YAAQ,GAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.cjs","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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
|
|
1
|
+
{"version":3,"file":"SliceZone.cjs","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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/** List of slice data from the slice zone. */\n\tslices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>\n\n\t/** A record mapping slice types to React components. */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst renderedSlices = computed(() => {\n\tif (!props.slices) return []\n\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is = props.components?.[type] || props.defaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<component\n\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t:is=\"renderedSlice.is\"\n\t\t:key=\"renderedSlice.key\"\n\t\tv-bind=\"renderedSlice.props\"\n\t/>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.js","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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
|
|
1
|
+
{"version":3,"file":"SliceZone.js","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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/** List of slice data from the slice zone. */\n\tslices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>\n\n\t/** A record mapping slice types to React components. */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst renderedSlices = computed(() => {\n\tif (!props.slices) return []\n\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is = props.components?.[type] || props.defaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<component\n\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t:is=\"renderedSlice.is\"\n\t\t:key=\"renderedSlice.key\"\n\t\tv-bind=\"renderedSlice.props\"\n\t/>\n</template>\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SliceComponentType, SliceLike, SliceZoneComponents, SliceZoneLike } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue19 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/SliceZone/SliceZone.vue.d.ts
|
|
5
5
|
|
|
@@ -9,31 +9,20 @@ import * as vue26 from "vue";
|
|
|
9
9
|
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
10
10
|
*/
|
|
11
11
|
type SliceZoneProps<TContext = unknown> = {
|
|
12
|
-
/**
|
|
13
|
-
* List of Slice data from the Slice Zone.
|
|
14
|
-
*/
|
|
12
|
+
/** List of slice data from the slice zone. */
|
|
15
13
|
slices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>;
|
|
16
|
-
/**
|
|
17
|
-
* A record mapping Slice types to Vue components.
|
|
18
|
-
*/
|
|
14
|
+
/** A record mapping slice types to React components. */
|
|
19
15
|
components?: SliceZoneComponents;
|
|
20
16
|
/**
|
|
21
17
|
* The Vue component rendered if a component mapping from the `components`
|
|
22
18
|
* prop cannot be found.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Components will be rendered using the {@link SliceComponentProps} interface.
|
|
26
|
-
*
|
|
27
|
-
* @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
|
|
28
19
|
*/
|
|
29
20
|
defaultComponent?: SliceComponentType<any, TContext>;
|
|
30
|
-
/**
|
|
31
|
-
* Arbitrary data made available to all Slice components.
|
|
32
|
-
*/
|
|
21
|
+
/** Arbitrary data made available to all slice components. */
|
|
33
22
|
context?: TContext;
|
|
34
23
|
};
|
|
35
24
|
type __VLS_Props = SliceZoneProps;
|
|
36
|
-
declare const __VLS_export:
|
|
25
|
+
declare const __VLS_export: vue19.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue19.ComponentOptionsMixin, vue19.ComponentOptionsMixin, {}, string, vue19.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, vue19.ComponentProvideOptions, false, {}, any>;
|
|
37
26
|
declare const _default: typeof __VLS_export;
|
|
38
27
|
//#endregion
|
|
39
28
|
export { SliceZoneProps, _default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.vue.d.ts","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"SliceZone.vue.d.ts","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":[],"mappings":";;;;;;;;AAsGA;;AAEoC,KAFxB,cAEwB,CAAA,WAAA,OAAA,CAAA,GAAA;EAAY;EAAvC,MAAA,EAAA,aAAA,CAAc,SAAd,GAAA,CAA2B,SAA3B,GAAuC,MAAvC,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,CAAA;EAGK;EAO8B,UAAA,CAAA,EAP9B,mBAO8B;EAAxB;;;AAInB;EA2EK,gBAEJ,CAAA,EAjFkB,kBAiFlB,CAAA,GAAA,EAjF0C,QAiF1C,CAAA;EAFgB;EAAA,OAAA,CAAA,EA5EP,QA4EO;CAAA;KAzEb,WAAA,GAAc,cAyED;cAAZ,YAAY,EAAA,KAAA,CAAA,eAAA,CAAA,WAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,KAAA,CAAA,qBAAA,EAAA,KAAA,CAAA,qBAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,WAAA,EAAA,QAAA,CAAA,WAAA,CAAA,GAAA,QAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,uBAAA,EAAA,KAAA,EAAA,CAAA,CAAA,EAAA,GAAA,CAAA;cAAA,QAAA,EAAA,OAGU,YAHV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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
|
|
1
|
+
{"version":3,"file":"SliceZone.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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/** List of slice data from the slice zone. */\n\tslices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>\n\n\t/** A record mapping slice types to React components. */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst renderedSlices = computed(() => {\n\tif (!props.slices) return []\n\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is = props.components?.[type] || props.defaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<component\n\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t:is=\"renderedSlice.is\"\n\t\t:key=\"renderedSlice.key\"\n\t\tv-bind=\"renderedSlice.props\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,QAAQ;EAGd,MAAM,yCAAgC;AACrC,OAAI,CAAC,MAAM,OAAQ,QAAO,EAAC;AAE3B,UAAO,MAAM,OAAO,KAAK,OAAO,UAAU;IACzC,MAAM,OACL,gBAAgB,QAAS,MAAM,aAAwB,MAAM;IAE9D,MAAM,MACL,QAAQ,SAAS,OAAO,MAAM,OAAO,WAClC,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;IAErC,MAAM,KAAK,MAAM,aAAa,SAAS,MAAM;AAE7C,QAAI,CAAC,GACJ,QAAO;KAAE,IAAI;KAAoB;KAAK,OAAO,EAAE,OAAO;KAAC;AAGxD,QAAI,MAAM,UAAU;KACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,YAAO;MAAE;MAAI;MAAK,OAAO;MAAY;;AAGtC,WAAO;KACN;KACA;KACA,OAAO;MACN;MACA;MACA,SAAS,MAAM;MACf,QAAQ,MAAM;MACd;KACF;KACA;IACD;;gEASE,cAAA,0BAJuB,eAAA,QAAjB,kBAAa;uFACf,cAAc,GAAE,sBAGpB,EAFA,KAAK,cAAc,0BACZ,cAAc,MAAK,EAAA,MAAA,GAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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
|
|
1
|
+
{"version":3,"file":"SliceZone.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/SliceZone/SliceZone.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from \"vue\"\n\nimport type {\n\tSliceComponentType,\n\tSliceLike,\n\tSliceZoneComponents,\n\tSliceZoneLike,\n} from \"./types\"\n\nimport { TODOSliceComponent } from \"./TODOSliceComponent\"\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/** List of slice data from the slice zone. */\n\tslices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>\n\n\t/** A record mapping slice types to React components. */\n\tcomponents?: SliceZoneComponents\n\n\t/**\n\t * The Vue component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext\n}\n\nconst props = defineProps<SliceZoneProps>()\ndefineOptions({ name: \"SliceZone\" })\n\nconst renderedSlices = computed(() => {\n\tif (!props.slices) return []\n\n\treturn props.slices.map((slice, index) => {\n\t\tconst type =\n\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type\n\n\t\tconst key =\n\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`\n\n\t\tconst is = props.components?.[type] || props.defaultComponent\n\n\t\tif (!is) {\n\t\t\treturn { is: TODOSliceComponent, key, props: { slice } }\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice\n\n\t\t\treturn { is, key, props: mappedProps }\n\t\t}\n\n\t\treturn {\n\t\t\tis,\n\t\t\tkey,\n\t\t\tprops: {\n\t\t\t\tslice,\n\t\t\t\tindex,\n\t\t\t\tcontext: props.context,\n\t\t\t\tslices: props.slices,\n\t\t\t},\n\t\t}\n\t})\n})\n</script>\n\n<template>\n\t<component\n\t\tv-for=\"renderedSlice in renderedSlices\"\n\t\t:is=\"renderedSlice.is\"\n\t\t:key=\"renderedSlice.key\"\n\t\tv-bind=\"renderedSlice.props\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,QAAQ;EAGd,MAAM,iBAAiB,eAAe;AACrC,OAAI,CAAC,MAAM,OAAQ,QAAO,EAAC;AAE3B,UAAO,MAAM,OAAO,KAAK,OAAO,UAAU;IACzC,MAAM,OACL,gBAAgB,QAAS,MAAM,aAAwB,MAAM;IAE9D,MAAM,MACL,QAAQ,SAAS,OAAO,MAAM,OAAO,WAClC,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;IAErC,MAAM,KAAK,MAAM,aAAa,SAAS,MAAM;AAE7C,QAAI,CAAC,GACJ,QAAO;KAAE,IAAI;KAAoB;KAAK,OAAO,EAAE,OAAO;KAAC;AAGxD,QAAI,MAAM,UAAU;KACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,YAAO;MAAE;MAAI;MAAK,OAAO;MAAY;;AAGtC,WAAO;KACN;KACA;KACA,OAAO;MACN;MACA;MACA,SAAS,MAAM;MACf,QAAQ,MAAM;MACd;KACF;KACA;IACD;;2BAIA,mBAKE,UAAA,MAAA,WAJuB,eAAA,QAAjB,kBAAa;wBADrB,YAKE,wBAHI,cAAc,GAAE,EAFtB,WAKE,EAFA,KAAK,cAAc,0BACZ,cAAc,MAAK,EAAA,MAAA,GAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/types.ts
|
|
3
|
+
const isVueComponent = (component) => {
|
|
4
|
+
return !!component && (typeof component === "function" || typeof component === "object" && ("render" in component && typeof component.render === "function" || "setup" in component && typeof component.setup === "function" || "__file" in component && !!component.__file || "__name" in component && !!component.__name || "props" in component && typeof component.props === "object"));
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.isVueComponent = isVueComponent;
|
|
9
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tRaw,\n\tdefineAsyncComponent,\n} from \"vue\"\n\nexport type ComponentOrTagName =\n\t| string\n\t| ConcreteComponent\n\t| Raw<DefineComponent>\n\nexport type VueComponent<TProps> =\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<TProps>\n\t| FunctionalComponent<TProps>\n\nexport const isVueComponent = <T>(\n\tcomponent: VueComponent<T> | unknown,\n): component is VueComponent<T> => {\n\treturn (\n\t\t!!component &&\n\t\t(typeof component === \"function\" ||\n\t\t\t(typeof component === \"object\" &&\n\t\t\t\t((\"render\" in component && typeof component.render === \"function\") ||\n\t\t\t\t\t(\"setup\" in component && typeof component.setup === \"function\") ||\n\t\t\t\t\t(\"__file\" in component && !!component.__file) ||\n\t\t\t\t\t(\"__name\" in component && !!component.__name) ||\n\t\t\t\t\t(\"props\" in component && typeof component.props === \"object\"))))\n\t)\n}\n"],"mappings":";;AAsBA,MAAa,kBACZ,cACkC;AAClC,QACC,CAAC,CAAC,cACD,OAAO,cAAc,cACpB,OAAO,cAAc,aACnB,YAAY,aAAa,OAAO,UAAU,WAAW,cACrD,WAAW,aAAa,OAAO,UAAU,UAAU,cACnD,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,WAAW,aAAa,OAAO,UAAU,UAAU"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ConcreteComponent, DefineComponent, Raw } from "vue";
|
|
1
|
+
import { ConcreteComponent, DefineComponent, FunctionalComponent, Raw, defineAsyncComponent } from "vue";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type ComponentOrTagName = string | ConcreteComponent | Raw<DefineComponent>;
|
|
5
|
+
type VueComponent<TProps> = DefineComponent<{}, {}, any> | ReturnType<typeof defineAsyncComponent> | DefineComponent<TProps> | FunctionalComponent<TProps>;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { ComponentOrTagName };
|
|
7
|
+
export { ComponentOrTagName, VueComponent };
|
|
7
8
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
const isVueComponent = (component) => {
|
|
3
|
+
return !!component && (typeof component === "function" || typeof component === "object" && ("render" in component && typeof component.render === "function" || "setup" in component && typeof component.setup === "function" || "__file" in component && !!component.__file || "__name" in component && !!component.__name || "props" in component && typeof component.props === "object"));
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isVueComponent };
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tRaw,\n\tdefineAsyncComponent,\n} from \"vue\"\n\nexport type ComponentOrTagName =\n\t| string\n\t| ConcreteComponent\n\t| Raw<DefineComponent>\n\nexport type VueComponent<TProps> =\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<TProps>\n\t| FunctionalComponent<TProps>\n\nexport const isVueComponent = <T>(\n\tcomponent: VueComponent<T> | unknown,\n): component is VueComponent<T> => {\n\treturn (\n\t\t!!component &&\n\t\t(typeof component === \"function\" ||\n\t\t\t(typeof component === \"object\" &&\n\t\t\t\t((\"render\" in component && typeof component.render === \"function\") ||\n\t\t\t\t\t(\"setup\" in component && typeof component.setup === \"function\") ||\n\t\t\t\t\t(\"__file\" in component && !!component.__file) ||\n\t\t\t\t\t(\"__name\" in component && !!component.__name) ||\n\t\t\t\t\t(\"props\" in component && typeof component.props === \"object\"))))\n\t)\n}\n"],"mappings":";AAsBA,MAAa,kBACZ,cACkC;AAClC,QACC,CAAC,CAAC,cACD,OAAO,cAAc,cACpB,OAAO,cAAc,aACnB,YAAY,aAAa,OAAO,UAAU,WAAW,cACrD,WAAW,aAAa,OAAO,UAAU,UAAU,cACnD,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,YAAY,aAAa,CAAC,CAAC,UAAU,UACrC,WAAW,aAAa,OAAO,UAAU,UAAU"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ConcreteComponent, DefineComponent, Raw } from "vue";
|
|
1
|
+
import { ConcreteComponent, DefineComponent, FunctionalComponent, Raw, defineAsyncComponent } from "vue";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
type ComponentOrTagName = string | ConcreteComponent | Raw<DefineComponent>;
|
|
5
|
+
type VueComponent<TProps> = DefineComponent<{}, {}, any> | ReturnType<typeof defineAsyncComponent> | DefineComponent<TProps> | FunctionalComponent<TProps>;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { ComponentOrTagName };
|
|
7
|
+
export { ComponentOrTagName, VueComponent };
|
|
7
8
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;KAQY,kBAAA,YAET,oBACA,IAAI;KAEK,uBAGT,+BAEA,kBAAkB,wBAClB,gBAAgB,UAChB,oBAAoB"}
|
package/package.json
CHANGED
package/src/PrismicImage.vue
CHANGED
|
@@ -14,9 +14,7 @@ import { devMsg } from "./lib/devMsg"
|
|
|
14
14
|
* Props for `<PrismicImage />`.
|
|
15
15
|
*/
|
|
16
16
|
export type PrismicImageProps = {
|
|
17
|
-
/**
|
|
18
|
-
* The Prismic image field or thumbnail to render.
|
|
19
|
-
*/
|
|
17
|
+
/** The Prismic image field or thumbnail to render. */
|
|
20
18
|
field: ImageField | ImageField<string>
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -61,29 +59,23 @@ export type PrismicImageProps = {
|
|
|
61
59
|
} & (
|
|
62
60
|
| {
|
|
63
61
|
/**
|
|
64
|
-
* Widths used to build a `srcset` value for the image
|
|
62
|
+
* Widths (in pixels) used to build a `srcset` value for the image
|
|
63
|
+
* field.
|
|
65
64
|
*
|
|
66
|
-
* If
|
|
67
|
-
*
|
|
68
|
-
* 3840.
|
|
65
|
+
* If omitted or set to `"defaults"`, the following widths will be used:
|
|
66
|
+
* 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
69
67
|
*
|
|
70
|
-
* If the image field contains responsive views, each responsive view
|
|
71
|
-
* be used as a width in the resulting `srcset` by passing
|
|
72
|
-
* as the `widths` prop.
|
|
68
|
+
* If the image field contains responsive views, each responsive view
|
|
69
|
+
* can be used as a width in the resulting `srcset` by passing
|
|
70
|
+
* `"thumbnails"` as the `widths` prop.
|
|
73
71
|
*/
|
|
74
72
|
widths?:
|
|
75
73
|
| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
|
|
76
74
|
| "thumbnails"
|
|
77
75
|
| "defaults"
|
|
78
|
-
/**
|
|
79
|
-
* Not used when the `widths` prop is used.
|
|
80
|
-
*/
|
|
81
76
|
pixelDensities?: never
|
|
82
77
|
}
|
|
83
78
|
| {
|
|
84
|
-
/**
|
|
85
|
-
* Not used when the `widths` prop is used.
|
|
86
|
-
*/
|
|
87
79
|
widths?: never
|
|
88
80
|
/**
|
|
89
81
|
* Pixel densities used to build a `srcset` value for the image field.
|
package/src/PrismicLink.vue
CHANGED
|
@@ -32,12 +32,13 @@ const defaultExternalRelAttribute = "noreferrer"
|
|
|
32
32
|
*/
|
|
33
33
|
export type PrismicLinkProps = {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
* resolver parameter with `@prismicio/client`.
|
|
35
|
+
* The link resolver used to resolve links.
|
|
37
36
|
*
|
|
38
|
-
* @
|
|
37
|
+
* @remarks
|
|
38
|
+
* If your app uses route resolvers when querying for your Prismic
|
|
39
|
+
* repository's content, a link resolver does not need to be provided.
|
|
39
40
|
*
|
|
40
|
-
* @see
|
|
41
|
+
* @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
|
|
41
42
|
*/
|
|
42
43
|
linkResolver?: LinkResolverFunction
|
|
43
44
|
|
|
@@ -49,30 +50,29 @@ export type PrismicLinkProps = {
|
|
|
49
50
|
rel?: string | AsLinkAttrsConfig["rel"]
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
|
-
* The
|
|
53
|
+
* The component rendered for internal URLs.
|
|
54
|
+
*
|
|
55
|
+
* If your app uses a client-side router that requires a special Link
|
|
56
|
+
* component, provide the Link component to this prop.
|
|
53
57
|
*
|
|
54
58
|
* @defaultValue `<RouterLink>`
|
|
55
59
|
*/
|
|
56
60
|
internalComponent?: ComponentOrTagName
|
|
57
61
|
|
|
58
62
|
/**
|
|
59
|
-
* The
|
|
63
|
+
* The component rendered for external URLs.
|
|
60
64
|
*
|
|
61
65
|
* @defaultValue `<a>`
|
|
62
66
|
*/
|
|
63
67
|
externalComponent?: ComponentOrTagName
|
|
64
68
|
} & (
|
|
65
69
|
| {
|
|
66
|
-
/**
|
|
67
|
-
* The Prismic link field to render.
|
|
68
|
-
*/
|
|
70
|
+
/** The Prismic link field to render. */
|
|
69
71
|
field: LinkField
|
|
70
72
|
document?: never
|
|
71
73
|
}
|
|
72
74
|
| {
|
|
73
|
-
/**
|
|
74
|
-
* The Prismic document to render as a link.
|
|
75
|
-
*/
|
|
75
|
+
/** The Prismic document to render as a link. */
|
|
76
76
|
document: PrismicDocument
|
|
77
77
|
field?: never
|
|
78
78
|
}
|
|
@@ -1,66 +1,59 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type {
|
|
3
|
+
LinkResolverFunction,
|
|
4
|
+
RichTextField,
|
|
5
|
+
RichTextNodeType,
|
|
5
6
|
} from "@prismicio/client"
|
|
6
7
|
import { asTree } from "@prismicio/client/richtext"
|
|
7
8
|
import type { PropType } from "vue"
|
|
8
9
|
import { computed } from "vue"
|
|
9
10
|
|
|
10
|
-
import type
|
|
11
|
-
import type {
|
|
11
|
+
import { type ComponentOrTagName, isVueComponent } from "../types"
|
|
12
|
+
import type {
|
|
13
|
+
InternalVueRichTextComponent,
|
|
14
|
+
VueRichTextSerializer,
|
|
15
|
+
VueShorthand,
|
|
16
|
+
} from "./types"
|
|
12
17
|
|
|
18
|
+
import PrismicRichTextDefaultComponent from "./PrismicRichTextDefaultComponent.vue"
|
|
13
19
|
import PrismicRichTextSerialize from "./PrismicRichTextSerialize.vue"
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* Props for `<PrismicRichText />`.
|
|
17
23
|
*/
|
|
18
24
|
export type PrismicRichTextProps = {
|
|
25
|
+
/** The Prismic rich text field to render. */
|
|
26
|
+
field: RichTextField | null | undefined
|
|
27
|
+
|
|
19
28
|
/**
|
|
20
|
-
* The
|
|
29
|
+
* The link resolver used to resolve links.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* If your app uses route resolvers when querying for your Prismic
|
|
33
|
+
* repository's content, a link resolver does not need to be provided.
|
|
34
|
+
*
|
|
35
|
+
* @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
|
|
21
36
|
*/
|
|
22
|
-
|
|
37
|
+
linkResolver?: LinkResolverFunction
|
|
23
38
|
|
|
24
39
|
/**
|
|
25
|
-
* An object that maps a rich text block type to a Vue component.
|
|
40
|
+
* An object that maps a rich text block type to a Vue component or a shorthand definition.
|
|
26
41
|
*
|
|
27
42
|
* @example
|
|
28
43
|
*
|
|
29
44
|
* ```javascript
|
|
30
45
|
* {
|
|
31
46
|
* heading1: Heading1,
|
|
47
|
+
* paragraph: { class: 'prose'},
|
|
48
|
+
* strong: { as: 'em', class: 'font-bold' },
|
|
32
49
|
* }
|
|
33
50
|
* ```
|
|
34
51
|
*/
|
|
35
52
|
components?: VueRichTextSerializer
|
|
36
53
|
|
|
37
|
-
/**
|
|
38
|
-
* A link resolver function used to resolve link when not using the route
|
|
39
|
-
* resolver parameter with `@prismicio/client`.
|
|
40
|
-
*
|
|
41
|
-
* @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.
|
|
42
|
-
*
|
|
43
|
-
* @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}
|
|
44
|
-
*/
|
|
45
|
-
linkResolver?: LinkResolverFunction
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The Vue component rendered for links when the URL is internal.
|
|
49
|
-
*
|
|
50
|
-
* @defaultValue `<RouterLink>`
|
|
51
|
-
*/
|
|
52
|
-
internalLinkComponent?: ComponentOrTagName
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The Vue component rendered for links when the URL is external.
|
|
56
|
-
*
|
|
57
|
-
* @defaultValue `<a>`
|
|
58
|
-
*/
|
|
59
|
-
externalLinkComponent?: ComponentOrTagName
|
|
60
|
-
|
|
61
54
|
/**
|
|
62
55
|
* The value to be rendered when the field is empty. If a fallback is not
|
|
63
|
-
* given, `null`
|
|
56
|
+
* given, `null` will be rendered.
|
|
64
57
|
*/
|
|
65
58
|
fallback?: ComponentOrTagName
|
|
66
59
|
}
|
|
@@ -71,21 +64,11 @@ const props = defineProps({
|
|
|
71
64
|
field: {
|
|
72
65
|
type: Array as unknown as PropType<PrismicRichTextProps["field"]>,
|
|
73
66
|
},
|
|
74
|
-
components: {
|
|
75
|
-
type: Object as PropType<PrismicRichTextProps["components"]>,
|
|
76
|
-
},
|
|
77
67
|
linkResolver: {
|
|
78
68
|
type: Function as PropType<PrismicRichTextProps["linkResolver"]>,
|
|
79
69
|
},
|
|
80
|
-
|
|
81
|
-
type:
|
|
82
|
-
PrismicRichTextProps["internalLinkComponent"]
|
|
83
|
-
>,
|
|
84
|
-
},
|
|
85
|
-
externalLinkComponent: {
|
|
86
|
-
type: [String, Object, Function] as PropType<
|
|
87
|
-
PrismicRichTextProps["externalLinkComponent"]
|
|
88
|
-
>,
|
|
70
|
+
components: {
|
|
71
|
+
type: Object as PropType<PrismicRichTextProps["components"]>,
|
|
89
72
|
},
|
|
90
73
|
fallback: {
|
|
91
74
|
type: [String, Object, Function] as PropType<
|
|
@@ -98,16 +81,53 @@ defineOptions({ name: "PrismicRichText" })
|
|
|
98
81
|
const children = computed(() => {
|
|
99
82
|
return asTree(props.field || []).children
|
|
100
83
|
})
|
|
84
|
+
|
|
85
|
+
function getInternalComponent(type: keyof typeof RichTextNodeType) {
|
|
86
|
+
const maybeComponentOrShorthand = props.components?.[type]
|
|
87
|
+
|
|
88
|
+
if (isVueComponent(maybeComponentOrShorthand)) {
|
|
89
|
+
return { is: maybeComponentOrShorthand }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
is: PrismicRichTextDefaultComponent,
|
|
94
|
+
props: {
|
|
95
|
+
linkResolver: props.linkResolver,
|
|
96
|
+
shorthand: maybeComponentOrShorthand as VueShorthand,
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const internalComponents = computed<InternalVueRichTextComponent>(() => {
|
|
102
|
+
return {
|
|
103
|
+
heading1: getInternalComponent("heading1"),
|
|
104
|
+
heading2: getInternalComponent("heading2"),
|
|
105
|
+
heading3: getInternalComponent("heading3"),
|
|
106
|
+
heading4: getInternalComponent("heading4"),
|
|
107
|
+
heading5: getInternalComponent("heading5"),
|
|
108
|
+
heading6: getInternalComponent("heading6"),
|
|
109
|
+
paragraph: getInternalComponent("paragraph"),
|
|
110
|
+
preformatted: getInternalComponent("preformatted"),
|
|
111
|
+
strong: getInternalComponent("strong"),
|
|
112
|
+
em: getInternalComponent("em"),
|
|
113
|
+
"list-item": getInternalComponent("listItem"),
|
|
114
|
+
"o-list-item": getInternalComponent("oListItem"),
|
|
115
|
+
"group-list-item": getInternalComponent("list"),
|
|
116
|
+
"group-o-list-item": getInternalComponent("oList"),
|
|
117
|
+
image: getInternalComponent("image"),
|
|
118
|
+
embed: getInternalComponent("embed"),
|
|
119
|
+
hyperlink: getInternalComponent("hyperlink"),
|
|
120
|
+
label: getInternalComponent("label"),
|
|
121
|
+
span: getInternalComponent("span"),
|
|
122
|
+
}
|
|
123
|
+
})
|
|
101
124
|
</script>
|
|
102
125
|
|
|
103
126
|
<template>
|
|
104
127
|
<PrismicRichTextSerialize
|
|
105
128
|
v-if="children.length"
|
|
106
129
|
:children="children"
|
|
107
|
-
:components="
|
|
108
|
-
:link-resolver="linkResolver"
|
|
109
|
-
:internal-link-component="internalLinkComponent"
|
|
110
|
-
:external-link-component="externalLinkComponent"
|
|
130
|
+
:internal-components="internalComponents"
|
|
111
131
|
/>
|
|
112
132
|
<component v-else-if="fallback" :is="fallback" />
|
|
113
133
|
</template>
|