@prismicio/vue 5.3.0-canary.5d9ea4c → 5.3.0-canary.87748cc
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 +30 -58
- package/dist/PrismicImage.vue.d.cts.map +1 -1
- package/dist/PrismicLink.vue.d.cts +65 -137
- package/dist/PrismicLink.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +25 -53
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -1
- package/dist/PrismicRichText/types.d.cts +18 -5
- package/dist/PrismicRichText/types.d.cts.map +1 -1
- package/dist/PrismicTable/PrismicTable.vue.d.cts +10 -10
- package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -1
- package/dist/PrismicTable/types.d.cts +8 -8
- package/dist/PrismicTable/types.d.cts.map +1 -1
- package/dist/PrismicText.vue.d.cts +3 -13
- package/dist/PrismicText.vue.d.cts.map +1 -1
- package/dist/SliceZone/SliceZone.vue.d.cts +5 -24
- package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -1
- package/dist/index.cjs +3 -10
- package/dist/index.d.cts +9 -13
- package/dist/index.d.ts +11 -15
- package/dist/index.js +3 -6
- 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 +26 -54
- package/dist/src/PrismicImage.vue.d.ts.map +1 -1
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs +2 -4
- 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 +2 -4
- 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 +61 -133
- package/dist/src/PrismicLink.vue.d.ts.map +1 -1
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs +3 -6
- 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 +3 -6
- 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 +25 -53
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -1
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +41 -57
- 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 +42 -58
- 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 +53 -33
- 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 +54 -34
- 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 +9 -29
- 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 +10 -30
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicRichText/types.d.ts +18 -5
- 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 +13 -13
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -1
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +47 -19
- 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 +48 -20
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs +36 -18
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs.map +1 -1
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js +36 -18
- 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 +8 -8
- 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 +1 -11
- package/dist/src/PrismicText.vue.d.ts.map +1 -1
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs +1 -12
- 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 +3 -14
- 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 -24
- package/dist/src/SliceZone/SliceZone.vue.d.ts.map +1 -1
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs +5 -17
- 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 +6 -18
- 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 -352
- 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 -352
- package/dist/types.d.cts.map +1 -1
- package/package.json +6 -5
- package/src/PrismicImage.vue +10 -27
- package/src/PrismicLink.vue +18 -43
- package/src/PrismicRichText/PrismicRichText.vue +68 -118
- package/src/PrismicRichText/PrismicRichTextDefaultComponent.vue +61 -19
- package/src/PrismicRichText/PrismicRichTextSerialize.vue +5 -30
- package/src/PrismicRichText/types.ts +33 -14
- package/src/PrismicTable/PrismicTable.vue +50 -23
- package/src/PrismicTable/PrismicTableDefaultComponents.ts +45 -20
- package/src/PrismicTable/PrismicTableRow.vue +17 -24
- package/src/PrismicTable/types.ts +28 -15
- package/src/PrismicText.vue +3 -18
- package/src/SliceZone/SliceZone.vue +12 -41
- package/src/index.ts +13 -21
- package/src/types.ts +30 -438
- package/dist/PrismicEmbed.vue.d.cts +0 -25
- package/dist/PrismicEmbed.vue.d.cts.map +0 -1
- package/dist/createPrismic.d.cts +0 -29
- package/dist/createPrismic.d.cts.map +0 -1
- package/dist/src/PrismicEmbed.cjs +0 -8
- package/dist/src/PrismicEmbed.cjs.map +0 -1
- package/dist/src/PrismicEmbed.js +0 -8
- package/dist/src/PrismicEmbed.js.map +0 -1
- package/dist/src/PrismicEmbed.vue.d.ts +0 -25
- package/dist/src/PrismicEmbed.vue.d.ts.map +0 -1
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.cjs +0 -42
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.cjs.map +0 -1
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.js +0 -42
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.cjs +0 -8
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.cjs.map +0 -1
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.js +0 -8
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.js.map +0 -1
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.cjs +0 -92
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +0 -1
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.js +0 -92
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/src/createPrismic.cjs +0 -85
- package/dist/src/createPrismic.cjs.map +0 -1
- package/dist/src/createPrismic.d.ts +0 -29
- package/dist/src/createPrismic.d.ts.map +0 -1
- package/dist/src/createPrismic.js +0 -85
- package/dist/src/createPrismic.js.map +0 -1
- package/dist/src/lib/Wrapper.cjs +0 -8
- package/dist/src/lib/Wrapper.cjs.map +0 -1
- package/dist/src/lib/Wrapper.js +0 -8
- package/dist/src/lib/Wrapper.js.map +0 -1
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.cjs +0 -22
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.cjs.map +0 -1
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.js +0 -22
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/src/usePrismic.cjs +0 -38
- package/dist/src/usePrismic.cjs.map +0 -1
- package/dist/src/usePrismic.d.ts +0 -36
- package/dist/src/usePrismic.d.ts.map +0 -1
- package/dist/src/usePrismic.js +0 -37
- package/dist/src/usePrismic.js.map +0 -1
- package/dist/usePrismic.d.cts +0 -36
- package/dist/usePrismic.d.cts.map +0 -1
- package/src/PrismicEmbed.vue +0 -42
- package/src/PrismicRichText/DeprecatedPrismicRichText.vue +0 -146
- package/src/createPrismic.ts +0 -154
- package/src/lib/Wrapper.vue +0 -22
- package/src/usePrismic.ts +0 -36
|
@@ -1,44 +1,69 @@
|
|
|
1
1
|
import { defineComponent, h } from "vue"
|
|
2
|
+
import type { PropType } from "vue"
|
|
2
3
|
|
|
3
|
-
import type {
|
|
4
|
+
import type { DefaultVueTableComponents } from "./types"
|
|
4
5
|
|
|
5
6
|
import * as getTableComponentProps from "./getTableComponentProps"
|
|
6
7
|
|
|
7
|
-
export const defaultTableComponents:
|
|
8
|
+
export const defaultTableComponents: DefaultVueTableComponents = {
|
|
8
9
|
table: defineComponent({
|
|
9
|
-
props:
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
props: {
|
|
11
|
+
...getTableComponentProps.table(),
|
|
12
|
+
as: { type: String as PropType<string | undefined> },
|
|
13
|
+
},
|
|
14
|
+
setup(props, { attrs, slots }) {
|
|
15
|
+
return () =>
|
|
16
|
+
h(props.as ?? "table", attrs, slots.default ? slots.default() : [])
|
|
12
17
|
},
|
|
13
18
|
}),
|
|
14
19
|
thead: defineComponent({
|
|
15
|
-
props:
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
props: {
|
|
21
|
+
...getTableComponentProps.thead(),
|
|
22
|
+
as: { type: String as PropType<string | undefined> },
|
|
23
|
+
},
|
|
24
|
+
setup(props, { attrs, slots }) {
|
|
25
|
+
return () =>
|
|
26
|
+
h(props.as ?? "thead", attrs, slots.default ? slots.default() : [])
|
|
18
27
|
},
|
|
19
28
|
}),
|
|
20
29
|
tbody: defineComponent({
|
|
21
|
-
props:
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
props: {
|
|
31
|
+
...getTableComponentProps.tbody(),
|
|
32
|
+
as: { type: String as PropType<string | undefined> },
|
|
33
|
+
},
|
|
34
|
+
setup(props, { attrs, slots }) {
|
|
35
|
+
return () =>
|
|
36
|
+
h(props.as ?? "tbody", attrs, slots.default ? slots.default() : [])
|
|
24
37
|
},
|
|
25
38
|
}),
|
|
26
39
|
tr: defineComponent({
|
|
27
|
-
props:
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
props: {
|
|
41
|
+
...getTableComponentProps.tr(),
|
|
42
|
+
as: { type: String as PropType<string | undefined> },
|
|
43
|
+
},
|
|
44
|
+
setup(props, { attrs, slots }) {
|
|
45
|
+
return () =>
|
|
46
|
+
h(props.as ?? "tr", attrs, slots.default ? slots.default() : [])
|
|
30
47
|
},
|
|
31
48
|
}),
|
|
32
49
|
th: defineComponent({
|
|
33
|
-
props:
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
props: {
|
|
51
|
+
...getTableComponentProps.th(),
|
|
52
|
+
as: { type: String as PropType<string | undefined> },
|
|
53
|
+
},
|
|
54
|
+
setup(props, { attrs, slots }) {
|
|
55
|
+
return () =>
|
|
56
|
+
h(props.as ?? "th", attrs, slots.default ? slots.default() : [])
|
|
36
57
|
},
|
|
37
58
|
}),
|
|
38
59
|
td: defineComponent({
|
|
39
|
-
props:
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
props: {
|
|
61
|
+
...getTableComponentProps.td(),
|
|
62
|
+
as: { type: String as PropType<string | undefined> },
|
|
63
|
+
},
|
|
64
|
+
setup(props, { attrs, slots }) {
|
|
65
|
+
return () =>
|
|
66
|
+
h(props.as ?? "td", attrs, slots.default ? slots.default() : [])
|
|
42
67
|
},
|
|
43
68
|
}),
|
|
44
69
|
}
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { TableFieldBodyRow, TableFieldHeadRow } from "@prismicio/client"
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { InternalVueTableComponents } from "./types"
|
|
5
5
|
|
|
6
6
|
import type { VueRichTextSerializer } from "../PrismicRichText"
|
|
7
7
|
import PrismicRichText from "../PrismicRichText/PrismicRichText.vue"
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Props for `<PrismicRowTable />`.
|
|
11
|
-
*/
|
|
12
9
|
export type PrismicTableRowProps = {
|
|
13
|
-
/**
|
|
14
|
-
* The Prismic table row to render.
|
|
15
|
-
*/
|
|
16
10
|
row: TableFieldHeadRow | TableFieldBodyRow
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* An object that maps a table block type to a Vue component.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* ```javascript
|
|
24
|
-
* {
|
|
25
|
-
* tr: TableRow,
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
components: VueTableComponents & VueRichTextSerializer
|
|
11
|
+
internalTableComponents: InternalVueTableComponents
|
|
12
|
+
components?: VueRichTextSerializer
|
|
30
13
|
}
|
|
31
14
|
|
|
32
15
|
const props = defineProps<PrismicTableRowProps>()
|
|
@@ -34,17 +17,27 @@ defineOptions({ name: "PrismicTableRow" })
|
|
|
34
17
|
</script>
|
|
35
18
|
|
|
36
19
|
<template>
|
|
37
|
-
<component
|
|
20
|
+
<component
|
|
21
|
+
:is="internalTableComponents.tr.is"
|
|
22
|
+
:row="row"
|
|
23
|
+
v-bind="internalTableComponents.tr.shorthand"
|
|
24
|
+
>
|
|
38
25
|
<template v-for="cell in row.cells" :key="cell.key">
|
|
39
26
|
<component
|
|
40
27
|
v-if="cell.type === 'header'"
|
|
41
|
-
:is="
|
|
28
|
+
:is="internalTableComponents.th.is"
|
|
42
29
|
:cell="cell"
|
|
30
|
+
v-bind="internalTableComponents.th.shorthand"
|
|
43
31
|
>
|
|
44
32
|
<PrismicRichText :field="cell.content" :components="components" />
|
|
45
33
|
</component>
|
|
46
|
-
<component
|
|
47
|
-
|
|
34
|
+
<component
|
|
35
|
+
v-else
|
|
36
|
+
:is="internalTableComponents.td.is"
|
|
37
|
+
:cell="cell"
|
|
38
|
+
v-bind="internalTableComponents.td.shorthand"
|
|
39
|
+
>
|
|
40
|
+
<PrismicRichText :field="cell.content" :components="components" />
|
|
48
41
|
</component>
|
|
49
42
|
</template>
|
|
50
43
|
</component>
|
|
@@ -7,11 +7,9 @@ import type {
|
|
|
7
7
|
TableFieldHeadRow,
|
|
8
8
|
TableFieldHeaderCell,
|
|
9
9
|
} from "@prismicio/client"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
defineAsyncComponent,
|
|
14
|
-
} from "vue"
|
|
10
|
+
|
|
11
|
+
import type { VueShorthand } from "../PrismicRichText/types"
|
|
12
|
+
import type { VueComponent } from "../types"
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* A map of Table block types to Vue Components. It is used to render table
|
|
@@ -20,15 +18,30 @@ import type {
|
|
|
20
18
|
* @see Templating Table fields from Prismic {@link https://prismic.io/docs/table}
|
|
21
19
|
*/
|
|
22
20
|
export type VueTableComponents = {
|
|
23
|
-
table?: VueComponent<{ table: TableField<"filled"> }>
|
|
24
|
-
thead?: VueComponent<{ head: TableFieldHead }>
|
|
25
|
-
tbody?: VueComponent<{ body: TableFieldBody }>
|
|
26
|
-
tr?:
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
table?: VueComponent<{ table: TableField<"filled"> }> | VueShorthand
|
|
22
|
+
thead?: VueComponent<{ head: TableFieldHead }> | VueShorthand
|
|
23
|
+
tbody?: VueComponent<{ body: TableFieldBody }> | VueShorthand
|
|
24
|
+
tr?:
|
|
25
|
+
| VueComponent<{ row: TableFieldBodyRow | TableFieldHeadRow }>
|
|
26
|
+
| VueShorthand
|
|
27
|
+
th?: VueComponent<{ cell: TableFieldHeaderCell }> | VueShorthand
|
|
28
|
+
td?: VueComponent<{ cell: TableFieldDataCell }> | VueShorthand
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
export type DefaultVueTableComponents = {
|
|
32
|
+
table: VueComponent<{ table: TableField<"filled">; as?: string }>
|
|
33
|
+
thead: VueComponent<{ head: TableFieldHead; as?: string }>
|
|
34
|
+
tbody: VueComponent<{ body: TableFieldBody; as?: string }>
|
|
35
|
+
tr: VueComponent<{ row: TableFieldBodyRow | TableFieldHeadRow; as?: string }>
|
|
36
|
+
th: VueComponent<{ cell: TableFieldHeaderCell; as?: string }>
|
|
37
|
+
td: VueComponent<{ cell: TableFieldDataCell; as?: string }>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type InternalVueTableComponents = {
|
|
41
|
+
table: { is: VueTableComponents["table"]; shorthand?: VueShorthand }
|
|
42
|
+
thead: { is: VueTableComponents["thead"]; shorthand?: VueShorthand }
|
|
43
|
+
tbody: { is: VueTableComponents["tbody"]; shorthand?: VueShorthand }
|
|
44
|
+
tr: { is: VueTableComponents["tr"]; shorthand?: VueShorthand }
|
|
45
|
+
th: { is: VueTableComponents["th"]; shorthand?: VueShorthand }
|
|
46
|
+
td: { is: VueTableComponents["td"]; shorthand?: VueShorthand }
|
|
47
|
+
}
|
package/src/PrismicText.vue
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { RichTextField } from "@prismicio/client"
|
|
3
|
-
import { asText
|
|
3
|
+
import { asText } from "@prismicio/client"
|
|
4
4
|
import { DEV } from "esm-env"
|
|
5
5
|
import { watchEffect } from "vue"
|
|
6
6
|
|
|
7
|
-
import Wrapper from "./lib/Wrapper.vue"
|
|
8
7
|
import { devMsg } from "./lib/devMsg"
|
|
9
8
|
|
|
10
|
-
import type { ComponentOrTagName } from "./types"
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Props for `<PrismicText />`.
|
|
14
11
|
*/
|
|
15
12
|
export type PrismicTextProps = {
|
|
16
|
-
/**
|
|
17
|
-
* The Prismic rich text field to render.
|
|
18
|
-
*/
|
|
13
|
+
/** The Prismic rich text field to render. */
|
|
19
14
|
field: RichTextField | null | undefined
|
|
20
15
|
|
|
21
16
|
/**
|
|
@@ -30,14 +25,6 @@ export type PrismicTextProps = {
|
|
|
30
25
|
* @defaultValue `" "` (a whitespace)
|
|
31
26
|
*/
|
|
32
27
|
separator?: string
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* An HTML tag name or a component used to wrap the output. `<PrismicText />`
|
|
36
|
-
* is not wrapped by default.
|
|
37
|
-
*
|
|
38
|
-
* @defaultValue `"template"` (no wrapper)
|
|
39
|
-
*/
|
|
40
|
-
wrapper?: ComponentOrTagName
|
|
41
28
|
}
|
|
42
29
|
|
|
43
30
|
const props = defineProps<PrismicTextProps>()
|
|
@@ -57,7 +44,5 @@ if (DEV) {
|
|
|
57
44
|
</script>
|
|
58
45
|
|
|
59
46
|
<template>
|
|
60
|
-
|
|
61
|
-
{{ asText(field) || fallback }}
|
|
62
|
-
</Wrapper>
|
|
47
|
+
{{ asText(field) || fallback || "" }}
|
|
63
48
|
</template>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from "vue"
|
|
3
3
|
|
|
4
|
-
import Wrapper from "../lib/Wrapper.vue"
|
|
5
|
-
|
|
6
|
-
import type { ComponentOrTagName } from "../types"
|
|
7
4
|
import type {
|
|
8
5
|
SliceComponentType,
|
|
9
6
|
SliceLike,
|
|
@@ -11,8 +8,6 @@ import type {
|
|
|
11
8
|
SliceZoneLike,
|
|
12
9
|
} from "./types"
|
|
13
10
|
|
|
14
|
-
import { usePrismic } from "../usePrismic"
|
|
15
|
-
|
|
16
11
|
import { TODOSliceComponent } from "./TODOSliceComponent"
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -21,48 +16,29 @@ import { TODOSliceComponent } from "./TODOSliceComponent"
|
|
|
21
16
|
* @typeParam TContext - Arbitrary data made available to all Slice components
|
|
22
17
|
*/
|
|
23
18
|
export type SliceZoneProps<TContext = unknown> = {
|
|
24
|
-
/**
|
|
25
|
-
* List of Slice data from the Slice Zone.
|
|
26
|
-
*/
|
|
19
|
+
/** List of slice data from the slice zone. */
|
|
27
20
|
slices: SliceZoneLike<SliceLike | (SliceLike & Record<string, unknown>)>
|
|
28
21
|
|
|
29
|
-
/**
|
|
30
|
-
* A record mapping Slice types to Vue components.
|
|
31
|
-
*/
|
|
22
|
+
/** A record mapping slice types to React components. */
|
|
32
23
|
components?: SliceZoneComponents
|
|
33
24
|
|
|
34
25
|
/**
|
|
35
26
|
* The Vue component rendered if a component mapping from the `components`
|
|
36
27
|
* prop cannot be found.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* Components will be rendered using the {@link SliceComponentProps} interface.
|
|
40
|
-
*
|
|
41
|
-
* @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
|
|
42
28
|
*/
|
|
43
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
30
|
defaultComponent?: SliceComponentType<any, TContext>
|
|
45
31
|
|
|
46
|
-
/**
|
|
47
|
-
* Arbitrary data made available to all Slice components.
|
|
48
|
-
*/
|
|
32
|
+
/** Arbitrary data made available to all slice components. */
|
|
49
33
|
context?: TContext
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* An HTML tag name or a component used to wrap the output. `<SliceZone />` is
|
|
53
|
-
* not wrapped by default.
|
|
54
|
-
*
|
|
55
|
-
* @defaultValue `"template"` (no wrapper)
|
|
56
|
-
*/
|
|
57
|
-
wrapper?: ComponentOrTagName
|
|
58
34
|
}
|
|
59
35
|
|
|
60
36
|
const props = defineProps<SliceZoneProps>()
|
|
61
37
|
defineOptions({ name: "SliceZone" })
|
|
62
38
|
|
|
63
|
-
const { options } = usePrismic()
|
|
64
|
-
|
|
65
39
|
const renderedSlices = computed(() => {
|
|
40
|
+
if (!props.slices) return []
|
|
41
|
+
|
|
66
42
|
return props.slices.map((slice, index) => {
|
|
67
43
|
const type =
|
|
68
44
|
"slice_type" in slice ? (slice.slice_type as string) : slice.type
|
|
@@ -72,10 +48,7 @@ const renderedSlices = computed(() => {
|
|
|
72
48
|
? slice.id
|
|
73
49
|
: `${index}-${JSON.stringify(slice)}`
|
|
74
50
|
|
|
75
|
-
const is =
|
|
76
|
-
props.components?.[type] ||
|
|
77
|
-
props.defaultComponent ||
|
|
78
|
-
options.components?.sliceZoneDefaultComponent
|
|
51
|
+
const is = props.components?.[type] || props.defaultComponent
|
|
79
52
|
|
|
80
53
|
if (!is) {
|
|
81
54
|
return { is: TODOSliceComponent, key, props: { slice } }
|
|
@@ -102,12 +75,10 @@ const renderedSlices = computed(() => {
|
|
|
102
75
|
</script>
|
|
103
76
|
|
|
104
77
|
<template>
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/>
|
|
112
|
-
</Wrapper>
|
|
78
|
+
<component
|
|
79
|
+
v-for="renderedSlice in renderedSlices"
|
|
80
|
+
:is="renderedSlice.is"
|
|
81
|
+
:key="renderedSlice.key"
|
|
82
|
+
v-bind="renderedSlice.props"
|
|
83
|
+
/>
|
|
113
84
|
</template>
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.vue"
|
|
2
|
-
export { default as PrismicTable } from "./PrismicTable/PrismicTable.vue"
|
|
3
|
-
export { default as SliceZone } from "./SliceZone/SliceZone.vue"
|
|
4
|
-
|
|
5
|
-
export { default as PrismicEmbed } from "./PrismicEmbed.vue"
|
|
6
|
-
export { default as PrismicImage } from "./PrismicImage.vue"
|
|
7
|
-
export { default as PrismicLink } from "./PrismicLink.vue"
|
|
8
|
-
export { default as PrismicText } from "./PrismicText.vue"
|
|
9
|
-
|
|
10
|
-
export type { SliceZoneProps } from "./SliceZone/SliceZone.vue"
|
|
11
2
|
export type { PrismicRichTextProps } from "./PrismicRichText/PrismicRichText.vue"
|
|
12
|
-
export type { PrismicTableProps } from "./PrismicTable/PrismicTable.vue"
|
|
13
|
-
|
|
14
|
-
export type { PrismicEmbedProps } from "./PrismicEmbed.vue"
|
|
15
|
-
export type { PrismicImageProps } from "./PrismicImage.vue"
|
|
16
|
-
export type { PrismicLinkProps } from "./PrismicLink.vue"
|
|
17
|
-
export type { PrismicTextProps } from "./PrismicText.vue"
|
|
18
|
-
|
|
19
3
|
export { getRichTextComponentProps } from "./PrismicRichText"
|
|
20
4
|
export type {
|
|
21
5
|
VueRichTextSerializer,
|
|
22
6
|
RichTextComponentProps,
|
|
23
7
|
} from "./PrismicRichText"
|
|
24
8
|
|
|
9
|
+
export { default as PrismicTable } from "./PrismicTable/PrismicTable.vue"
|
|
10
|
+
export type { PrismicTableProps } from "./PrismicTable/PrismicTable.vue"
|
|
25
11
|
export { getTableComponentProps } from "./PrismicTable"
|
|
26
12
|
|
|
13
|
+
export { default as PrismicImage } from "./PrismicImage.vue"
|
|
14
|
+
export type { PrismicImageProps } from "./PrismicImage.vue"
|
|
15
|
+
|
|
16
|
+
export { default as PrismicLink } from "./PrismicLink.vue"
|
|
17
|
+
export type { PrismicLinkProps } from "./PrismicLink.vue"
|
|
18
|
+
|
|
19
|
+
export { default as PrismicText } from "./PrismicText.vue"
|
|
20
|
+
export type { PrismicTextProps } from "./PrismicText.vue"
|
|
21
|
+
|
|
22
|
+
export { default as SliceZone } from "./SliceZone/SliceZone.vue"
|
|
23
|
+
export type { SliceZoneProps } from "./SliceZone/SliceZone.vue"
|
|
27
24
|
export {
|
|
28
25
|
TODOSliceComponent,
|
|
29
26
|
defineSliceZoneComponents,
|
|
@@ -38,8 +35,3 @@ export type {
|
|
|
38
35
|
SliceZoneComponents,
|
|
39
36
|
SliceZoneLike,
|
|
40
37
|
} from "./SliceZone"
|
|
41
|
-
|
|
42
|
-
export type { PrismicPluginOptions, PrismicPlugin } from "./types"
|
|
43
|
-
|
|
44
|
-
export { createPrismic } from "./createPrismic"
|
|
45
|
-
export { usePrismic, prismicKey } from "./usePrismic"
|