@prismicio/svelte 1.5.0 → 1.6.0-alpha.0
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/PrismicEmbed.svelte.d.ts +2 -0
- package/dist/PrismicImage.svelte.d.ts +9 -7
- package/dist/PrismicLink.svelte +4 -6
- package/dist/PrismicLink.svelte.d.ts +6 -4
- package/dist/PrismicRichText/DefaultComponent.svelte +1 -2
- package/dist/PrismicRichText/DefaultComponent.svelte.d.ts +2 -0
- package/dist/PrismicRichText/PrismicRichText.svelte +2 -3
- package/dist/PrismicRichText/PrismicRichText.svelte.d.ts +4 -3
- package/dist/PrismicRichText/Serialize.svelte.d.ts +5 -4
- package/dist/PrismicTable/DefaultComponent.svelte.d.ts +2 -0
- package/dist/PrismicTable/PrismicTable.svelte.d.ts +4 -7
- package/dist/PrismicText.svelte.d.ts +4 -2
- package/dist/SliceZone/SliceZone.svelte +1 -0
- package/dist/SliceZone/SliceZone.svelte.d.ts +13 -39
- package/dist/SliceZone/TodoComponent.svelte.d.ts +2 -0
- package/dist/kit/PrismicPreview.svelte +1 -2
- package/dist/kit/PrismicPreview.svelte.d.ts +4 -2
- package/dist/types.d.ts +81 -24
- package/package.json +21 -22
- package/src/PrismicRichText/PrismicRichText.svelte +1 -1
- package/src/PrismicRichText/Serialize.svelte +1 -1
- package/src/SliceZone/SliceZone.svelte +3 -1
- package/src/types.ts +46 -32
|
@@ -10,6 +10,8 @@ declare const __propDef: {
|
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
11
11
|
};
|
|
12
12
|
slots: {};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
13
15
|
};
|
|
14
16
|
export type PrismicEmbedProps = typeof __propDef.props;
|
|
15
17
|
export type PrismicEmbedEvents = typeof __propDef.events;
|
|
@@ -3,7 +3,7 @@ import { asImageWidthSrcSet, asImagePixelDensitySrcSet, type ImageFieldImage } f
|
|
|
3
3
|
import type { ImgixURLParams } from "imgix-url-builder";
|
|
4
4
|
import type { HTMLImgAttributes } from "svelte/elements";
|
|
5
5
|
declare const __propDef: {
|
|
6
|
-
props: Omit<HTMLImgAttributes, "src" | "srcset" | "alt"> & {
|
|
6
|
+
props: Omit<HTMLImgAttributes, "src" | "srcset" | "alt"> & ({
|
|
7
7
|
/**
|
|
8
8
|
* The Prismic image field or thumbnail to render.
|
|
9
9
|
*/
|
|
@@ -13,14 +13,14 @@ declare const __propDef: {
|
|
|
13
13
|
*
|
|
14
14
|
* See: https://docs.imgix.com/apis/rendering
|
|
15
15
|
*/
|
|
16
|
-
imgixParams?: ImgixURLParams
|
|
16
|
+
imgixParams?: ImgixURLParams;
|
|
17
17
|
/**
|
|
18
18
|
* Declare an image as decorative by providing `alt=""`.
|
|
19
19
|
*
|
|
20
20
|
* See:
|
|
21
21
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
22
22
|
*/
|
|
23
|
-
alt?: ""
|
|
23
|
+
alt?: "";
|
|
24
24
|
/**
|
|
25
25
|
* Declare an image as decorative only if the Image field does not have
|
|
26
26
|
* alternative text by providing `fallbackAlt=""`.
|
|
@@ -28,7 +28,7 @@ declare const __propDef: {
|
|
|
28
28
|
* See:
|
|
29
29
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
30
30
|
*/
|
|
31
|
-
fallbackAlt?: ""
|
|
31
|
+
fallbackAlt?: "";
|
|
32
32
|
} & ({
|
|
33
33
|
/**
|
|
34
34
|
* Widths used to build a `srcset` value for the Image field.
|
|
@@ -42,7 +42,7 @@ declare const __propDef: {
|
|
|
42
42
|
* `"thumbnails"` as the `widths` prop.
|
|
43
43
|
*/
|
|
44
44
|
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "defaults";
|
|
45
|
-
pixelDensities?:
|
|
45
|
+
pixelDensities?: never;
|
|
46
46
|
} | {
|
|
47
47
|
/**
|
|
48
48
|
* Pixel densities used to build a `srcset` value for the Image field.
|
|
@@ -51,12 +51,14 @@ declare const __propDef: {
|
|
|
51
51
|
* pixel densities will be used: 1, 2, 3.
|
|
52
52
|
*/
|
|
53
53
|
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
54
|
-
widths?:
|
|
55
|
-
});
|
|
54
|
+
widths?: never;
|
|
55
|
+
}));
|
|
56
56
|
events: {
|
|
57
57
|
[evt: string]: CustomEvent<any>;
|
|
58
58
|
};
|
|
59
59
|
slots: {};
|
|
60
|
+
exports?: {} | undefined;
|
|
61
|
+
bindings?: string | undefined;
|
|
60
62
|
};
|
|
61
63
|
export type PrismicImageProps = typeof __propDef.props;
|
|
62
64
|
export type PrismicImageEvents = typeof __propDef.events;
|
package/dist/PrismicLink.svelte
CHANGED
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
export let field = void 0;
|
|
5
5
|
export let document = void 0;
|
|
6
6
|
export let rel = void 0;
|
|
7
|
-
$:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
$:
|
|
12
|
-
resolvedRel = typeof rel === "string" ? rel : linkAttrs.rel;
|
|
7
|
+
$: linkAttrs = asLinkAttrs(field ?? document, {
|
|
8
|
+
rel: typeof rel === "function" ? rel : void 0
|
|
9
|
+
});
|
|
10
|
+
$: resolvedRel = typeof rel === "string" ? rel : linkAttrs.rel;
|
|
13
11
|
</script>
|
|
14
12
|
|
|
15
13
|
<!--
|
|
@@ -2,7 +2,7 @@ import { SvelteComponent } from "svelte";
|
|
|
2
2
|
import { type AsLinkAttrsConfig, type LinkField, type PrismicDocument } from "@prismicio/client";
|
|
3
3
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
4
4
|
declare const __propDef: {
|
|
5
|
-
props: Omit<HTMLAnchorAttributes, "rel" | "href"> & {
|
|
5
|
+
props: Omit<HTMLAnchorAttributes, "rel" | "href"> & ({
|
|
6
6
|
/**
|
|
7
7
|
* The `rel` attribute for the link. By default, `"noreferrer"` is provided
|
|
8
8
|
* if the link's URL is external. This prop can be provided a function to
|
|
@@ -15,14 +15,14 @@ declare const __propDef: {
|
|
|
15
15
|
* field.
|
|
16
16
|
*/
|
|
17
17
|
field: LinkField;
|
|
18
|
-
document?:
|
|
18
|
+
document?: never;
|
|
19
19
|
} | {
|
|
20
20
|
/**
|
|
21
21
|
* A Prismic document.
|
|
22
22
|
*/
|
|
23
23
|
document: PrismicDocument;
|
|
24
|
-
field?:
|
|
25
|
-
});
|
|
24
|
+
field?: never;
|
|
25
|
+
}));
|
|
26
26
|
events: {
|
|
27
27
|
click: MouseEvent;
|
|
28
28
|
} & {
|
|
@@ -31,6 +31,8 @@ declare const __propDef: {
|
|
|
31
31
|
slots: {
|
|
32
32
|
default: {};
|
|
33
33
|
};
|
|
34
|
+
exports?: {} | undefined;
|
|
35
|
+
bindings?: string | undefined;
|
|
34
36
|
};
|
|
35
37
|
export type PrismicLinkProps = typeof __propDef.props;
|
|
36
38
|
export type PrismicLinkEvents = typeof __propDef.events;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import PrismicImage from "../PrismicImage.svelte";
|
|
3
3
|
import PrismicLink from "../PrismicLink.svelte";
|
|
4
4
|
export let node;
|
|
5
|
-
$:
|
|
6
|
-
dir = "direction" in node && node.direction === "rtl" ? "rtl" : void 0;
|
|
5
|
+
$: dir = "direction" in node && node.direction === "rtl" ? "rtl" : void 0;
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
8
|
{#if node.type === "heading1"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
<script>import { asTree } from "@prismicio/richtext";
|
|
1
|
+
<script>import { asTree } from "@prismicio/client/richtext";
|
|
2
2
|
import Serialize from "./Serialize.svelte";
|
|
3
3
|
export let field;
|
|
4
4
|
export let components = {};
|
|
5
|
-
$:
|
|
6
|
-
children = asTree(field).children;
|
|
5
|
+
$: children = asTree(field).children;
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
8
|
<!--
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { RichTextField } from "@prismicio/client";
|
|
3
|
+
import type { SvelteRichTextSerializer } from "../types";
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
/**
|
|
@@ -7,14 +8,14 @@ declare const __propDef: {
|
|
|
7
8
|
*/ field: RichTextField;
|
|
8
9
|
/**
|
|
9
10
|
* An object that maps a rich text block type to a Svelte component.
|
|
10
|
-
*/ components?:
|
|
11
|
-
node: import("@prismicio/client").RTAnyNode;
|
|
12
|
-
}>, any, any>>> | undefined;
|
|
11
|
+
*/ components?: SvelteRichTextSerializer;
|
|
13
12
|
};
|
|
14
13
|
events: {
|
|
15
14
|
[evt: string]: CustomEvent<any>;
|
|
16
15
|
};
|
|
17
16
|
slots: {};
|
|
17
|
+
exports?: {} | undefined;
|
|
18
|
+
bindings?: string | undefined;
|
|
18
19
|
};
|
|
19
20
|
export type PrismicRichTextProps = typeof __propDef.props;
|
|
20
21
|
export type PrismicRichTextEvents = typeof __propDef.events;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { asTree } from "@prismicio/richtext";
|
|
2
|
+
import type { asTree } from "@prismicio/client/richtext";
|
|
3
|
+
import type { SvelteRichTextSerializer } from "../types";
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
|
-
components?:
|
|
6
|
-
node: import("@prismicio/client/*").RTAnyNode;
|
|
7
|
-
}>, any, any>>> | undefined;
|
|
6
|
+
components?: SvelteRichTextSerializer;
|
|
8
7
|
children: ReturnType<typeof asTree>["children"];
|
|
9
8
|
};
|
|
10
9
|
events: {
|
|
11
10
|
[evt: string]: CustomEvent<any>;
|
|
12
11
|
};
|
|
13
12
|
slots: {};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
14
15
|
};
|
|
15
16
|
export type SerializeProps = typeof __propDef.props;
|
|
16
17
|
export type SerializeEvents = typeof __propDef.events;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import { type TableField } from "@prismicio/client";
|
|
3
3
|
import { type ComponentType } from "svelte";
|
|
4
|
-
import type { TableComponents } from "../types";
|
|
4
|
+
import type { SvelteRichTextSerializer, TableComponents } from "../types";
|
|
5
5
|
declare const __propDef: {
|
|
6
6
|
props: {
|
|
7
7
|
/**
|
|
@@ -9,12 +9,7 @@ declare const __propDef: {
|
|
|
9
9
|
*/ field: TableField;
|
|
10
10
|
/**
|
|
11
11
|
* An object that maps a rich text block type to a Svelte component.
|
|
12
|
-
*/ components?:
|
|
13
|
-
/**
|
|
14
|
-
* An object that maps a rich text block type to a Svelte component.
|
|
15
|
-
*/
|
|
16
|
-
node: import("@prismicio/client").RTAnyNode;
|
|
17
|
-
}>, any, any>>>) | undefined;
|
|
12
|
+
*/ components?: TableComponents & SvelteRichTextSerializer;
|
|
18
13
|
/**
|
|
19
14
|
* The component rendered when the field is empty. If a fallback is not given,
|
|
20
15
|
* `null` will be rendered.
|
|
@@ -24,6 +19,8 @@ declare const __propDef: {
|
|
|
24
19
|
[evt: string]: CustomEvent<any>;
|
|
25
20
|
};
|
|
26
21
|
slots: {};
|
|
22
|
+
exports?: {} | undefined;
|
|
23
|
+
bindings?: string | undefined;
|
|
27
24
|
};
|
|
28
25
|
export type PrismicTableProps = typeof __propDef.props;
|
|
29
26
|
export type PrismicTableEvents = typeof __propDef.events;
|
|
@@ -4,13 +4,15 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
field: RichTextField;
|
|
7
|
-
separator?: string | undefined;
|
|
8
|
-
fallback?: string | undefined;
|
|
7
|
+
separator?: string | undefined | undefined;
|
|
8
|
+
fallback?: string | undefined | undefined;
|
|
9
9
|
};
|
|
10
10
|
events: {
|
|
11
11
|
[evt: string]: CustomEvent<any>;
|
|
12
12
|
};
|
|
13
13
|
slots: {};
|
|
14
|
+
exports?: undefined;
|
|
15
|
+
bindings?: undefined;
|
|
14
16
|
};
|
|
15
17
|
export type PrismicTextProps = typeof __propDef.props;
|
|
16
18
|
export type PrismicTextEvents = typeof __propDef.events;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { ComponentCompat } from "../types";
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
/**
|
|
@@ -15,8 +16,8 @@ declare const __propDef: {
|
|
|
15
16
|
*
|
|
16
17
|
* @internal
|
|
17
18
|
*/
|
|
18
|
-
__mapped?: true
|
|
19
|
-
})[]
|
|
19
|
+
__mapped?: true;
|
|
20
|
+
})[];
|
|
20
21
|
/**
|
|
21
22
|
* An object that maps Slice components to their corresponding API IDs.
|
|
22
23
|
*
|
|
@@ -31,36 +32,7 @@ declare const __propDef: {
|
|
|
31
32
|
* hero_image: HeroImage,
|
|
32
33
|
* };
|
|
33
34
|
* ```
|
|
34
|
-
*/ components?: Record<string,
|
|
35
|
-
slice?: (({
|
|
36
|
-
slice_type: string;
|
|
37
|
-
} | {
|
|
38
|
-
type: string;
|
|
39
|
-
}) & {
|
|
40
|
-
/**
|
|
41
|
-
* If `true`, this Slice has been modified from its original value using a
|
|
42
|
-
* mapper and `@prismicio/client`'s `mapSliceZone()`.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
__mapped?: true | undefined;
|
|
47
|
-
}) | undefined;
|
|
48
|
-
slices?: (({
|
|
49
|
-
slice_type: string;
|
|
50
|
-
} | {
|
|
51
|
-
type: string;
|
|
52
|
-
}) & {
|
|
53
|
-
/**
|
|
54
|
-
* If `true`, this Slice has been modified from its original value using a
|
|
55
|
-
* mapper and `@prismicio/client`'s `mapSliceZone()`.
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
__mapped?: true | undefined;
|
|
60
|
-
})[] | undefined;
|
|
61
|
-
context?: unknown;
|
|
62
|
-
index?: number | undefined;
|
|
63
|
-
}, any, any>> | undefined;
|
|
35
|
+
*/ components?: Record<string, ComponentCompat<any>>;
|
|
64
36
|
/**
|
|
65
37
|
* Arbitrary data passed to all Slice components as a `context` prop.
|
|
66
38
|
*/ context?: any;
|
|
@@ -68,7 +40,7 @@ declare const __propDef: {
|
|
|
68
40
|
* The Svelte component rendered if a component mapping from the `components`
|
|
69
41
|
* prop cannot be found.
|
|
70
42
|
*/ defaultComponent?: (new (...args: any[]) => SvelteComponent<{
|
|
71
|
-
slice?: (
|
|
43
|
+
slice?: ({
|
|
72
44
|
slice_type: string;
|
|
73
45
|
} | {
|
|
74
46
|
type: string;
|
|
@@ -79,8 +51,8 @@ declare const __propDef: {
|
|
|
79
51
|
*
|
|
80
52
|
* @internal
|
|
81
53
|
*/
|
|
82
|
-
__mapped?: true
|
|
83
|
-
}
|
|
54
|
+
__mapped?: true;
|
|
55
|
+
};
|
|
84
56
|
slices?: (({
|
|
85
57
|
slice_type: string;
|
|
86
58
|
} | {
|
|
@@ -92,16 +64,18 @@ declare const __propDef: {
|
|
|
92
64
|
*
|
|
93
65
|
* @internal
|
|
94
66
|
*/
|
|
95
|
-
__mapped?: true
|
|
96
|
-
})[]
|
|
67
|
+
__mapped?: true;
|
|
68
|
+
})[];
|
|
97
69
|
context?: unknown;
|
|
98
|
-
index?: number
|
|
99
|
-
}
|
|
70
|
+
index?: number;
|
|
71
|
+
}>) | undefined;
|
|
100
72
|
};
|
|
101
73
|
events: {
|
|
102
74
|
[evt: string]: CustomEvent<any>;
|
|
103
75
|
};
|
|
104
76
|
slots: {};
|
|
77
|
+
exports?: {} | undefined;
|
|
78
|
+
bindings?: string | undefined;
|
|
105
79
|
};
|
|
106
80
|
export type SliceZoneProps = typeof __propDef.props;
|
|
107
81
|
export type SliceZoneEvents = typeof __propDef.events;
|
|
@@ -11,6 +11,8 @@ declare const __propDef: {
|
|
|
11
11
|
[evt: string]: CustomEvent<any>;
|
|
12
12
|
};
|
|
13
13
|
slots: {};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
14
16
|
};
|
|
15
17
|
export type TodoComponentProps = typeof __propDef.props;
|
|
16
18
|
export type TodoComponentEvents = typeof __propDef.events;
|
|
@@ -4,8 +4,7 @@ import { beforeNavigate, goto, invalidateAll } from "$app/navigation";
|
|
|
4
4
|
export let repositoryName;
|
|
5
5
|
export let routePrefix = "preview";
|
|
6
6
|
export let routePrefixName = routePrefix;
|
|
7
|
-
$:
|
|
8
|
-
toolbarSrc = getToolbarSrc(repositoryName);
|
|
7
|
+
$: toolbarSrc = getToolbarSrc(repositoryName);
|
|
9
8
|
let endingPreview = false;
|
|
10
9
|
onMount(() => {
|
|
11
10
|
const controller = new AbortController();
|
|
@@ -7,19 +7,21 @@ declare const __propDef: {
|
|
|
7
7
|
*/ repositoryName: string;
|
|
8
8
|
/**
|
|
9
9
|
* The route parameter prefixed during preview sessions.
|
|
10
|
-
*/ routePrefix?: string
|
|
10
|
+
*/ routePrefix?: string;
|
|
11
11
|
/**
|
|
12
12
|
* The name of the preview-specific route parameter prefixed during preview
|
|
13
13
|
* sessions.
|
|
14
14
|
*
|
|
15
15
|
* Only set this value if the route parameter's name differs from the
|
|
16
16
|
* parameter's value.
|
|
17
|
-
*/ routePrefixName?: string
|
|
17
|
+
*/ routePrefixName?: string;
|
|
18
18
|
};
|
|
19
19
|
events: {
|
|
20
20
|
[evt: string]: CustomEvent<any>;
|
|
21
21
|
};
|
|
22
22
|
slots: {};
|
|
23
|
+
exports?: {} | undefined;
|
|
24
|
+
bindings?: string | undefined;
|
|
23
25
|
};
|
|
24
26
|
export type PrismicPreviewProps = typeof __propDef.props;
|
|
25
27
|
export type PrismicPreviewEvents = typeof __propDef.events;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,27 +1,84 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ComponentType, SvelteComponent } from "svelte";
|
|
3
|
-
export type SvelteRichTextSerializer =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import type * as prismic from "@prismicio/client";
|
|
2
|
+
import type { Component, ComponentType, SvelteComponent } from "svelte";
|
|
3
|
+
export type SvelteRichTextSerializer = {
|
|
4
|
+
heading1?: ComponentCompat<{
|
|
5
|
+
node: prismic.RTHeading1Node;
|
|
6
|
+
}>;
|
|
7
|
+
heading2?: ComponentCompat<{
|
|
8
|
+
node: prismic.RTHeading2Node;
|
|
9
|
+
}>;
|
|
10
|
+
heading3?: ComponentCompat<{
|
|
11
|
+
node: prismic.RTHeading3Node;
|
|
12
|
+
}>;
|
|
13
|
+
heading4?: ComponentCompat<{
|
|
14
|
+
node: prismic.RTHeading4Node;
|
|
15
|
+
}>;
|
|
16
|
+
heading5?: ComponentCompat<{
|
|
17
|
+
node: prismic.RTHeading5Node;
|
|
18
|
+
}>;
|
|
19
|
+
heading6?: ComponentCompat<{
|
|
20
|
+
node: prismic.RTHeading6Node;
|
|
21
|
+
}>;
|
|
22
|
+
paragraph?: ComponentCompat<{
|
|
23
|
+
node: prismic.RTParagraphNode;
|
|
24
|
+
}>;
|
|
25
|
+
preformatted?: ComponentCompat<{
|
|
26
|
+
node: prismic.RTPreformattedNode;
|
|
27
|
+
}>;
|
|
28
|
+
strong?: ComponentCompat<{
|
|
29
|
+
node: prismic.RTStrongNode;
|
|
30
|
+
}>;
|
|
31
|
+
em?: ComponentCompat<{
|
|
32
|
+
node: prismic.RTEmNode;
|
|
33
|
+
}>;
|
|
34
|
+
listItem?: ComponentCompat<{
|
|
35
|
+
node: prismic.RTListItemNode;
|
|
36
|
+
}>;
|
|
37
|
+
oListItem?: ComponentCompat<{
|
|
38
|
+
node: prismic.RTOListItemNode;
|
|
39
|
+
}>;
|
|
40
|
+
list?: ComponentCompat<{
|
|
41
|
+
node: prismic.RTListNode;
|
|
42
|
+
}>;
|
|
43
|
+
oList?: ComponentCompat<{
|
|
44
|
+
node: prismic.RTOListNode;
|
|
45
|
+
}>;
|
|
46
|
+
image?: ComponentCompat<{
|
|
47
|
+
node: prismic.RTImageNode;
|
|
48
|
+
}>;
|
|
49
|
+
embed?: ComponentCompat<{
|
|
50
|
+
node: prismic.RTEmbedNode;
|
|
51
|
+
}>;
|
|
52
|
+
hyperlink?: ComponentCompat<{
|
|
53
|
+
node: prismic.RTLinkNode;
|
|
54
|
+
}>;
|
|
55
|
+
label?: ComponentCompat<{
|
|
56
|
+
node: prismic.RTLabelNode;
|
|
57
|
+
}>;
|
|
58
|
+
span?: ComponentCompat<{
|
|
59
|
+
node: prismic.RTSpanNode;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
7
62
|
export type TableComponents = {
|
|
8
|
-
table?:
|
|
9
|
-
table: TableField<"filled">;
|
|
10
|
-
}
|
|
11
|
-
thead?:
|
|
12
|
-
head: TableFieldHead;
|
|
13
|
-
}
|
|
14
|
-
tbody?:
|
|
15
|
-
body: TableFieldBody;
|
|
16
|
-
}
|
|
17
|
-
tr?:
|
|
18
|
-
row: TableFieldHeadRow | TableFieldBodyRow;
|
|
19
|
-
}
|
|
20
|
-
th?:
|
|
21
|
-
table: TableFieldHeaderCell;
|
|
22
|
-
}
|
|
23
|
-
td?:
|
|
24
|
-
table: TableFieldDataCell;
|
|
25
|
-
}
|
|
63
|
+
table?: ComponentTypeCompat<{
|
|
64
|
+
table: prismic.TableField<"filled">;
|
|
65
|
+
}>;
|
|
66
|
+
thead?: ComponentTypeCompat<{
|
|
67
|
+
head: prismic.TableFieldHead;
|
|
68
|
+
}>;
|
|
69
|
+
tbody?: ComponentTypeCompat<{
|
|
70
|
+
body: prismic.TableFieldBody;
|
|
71
|
+
}>;
|
|
72
|
+
tr?: ComponentTypeCompat<{
|
|
73
|
+
row: prismic.TableFieldHeadRow | prismic.TableFieldBodyRow;
|
|
74
|
+
}>;
|
|
75
|
+
th?: ComponentTypeCompat<{
|
|
76
|
+
table: prismic.TableFieldHeaderCell;
|
|
77
|
+
}>;
|
|
78
|
+
td?: ComponentTypeCompat<{
|
|
79
|
+
table: prismic.TableFieldDataCell;
|
|
80
|
+
}>;
|
|
26
81
|
};
|
|
82
|
+
type ComponentTypeCompat<Props extends Record<string, any> = any> = Component<Props> | ComponentType<SvelteComponent<Props>>;
|
|
83
|
+
export type ComponentCompat<Props extends Record<string, any> = any> = Component<Props> | (new (...args: any[]) => SvelteComponent<Partial<Props>>);
|
|
27
84
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-alpha.0",
|
|
4
4
|
"description": "Svelte components to present Prismic content.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -61,40 +61,39 @@
|
|
|
61
61
|
"unit:watch": "vitest watch"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@prismicio/
|
|
64
|
+
"@prismicio/client": "^7.17.2",
|
|
65
65
|
"esm-env": "^1.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@prismicio/client": "^7.17.0",
|
|
69
68
|
"@prismicio/mock": "^0.7.1",
|
|
70
|
-
"@size-limit/preset-small-lib": "^11.0
|
|
71
|
-
"@sveltejs/kit": "^2.
|
|
72
|
-
"@sveltejs/package": "^2.
|
|
73
|
-
"@sveltejs/vite-plugin-svelte": "^3.
|
|
74
|
-
"@testing-library/svelte": "^4.
|
|
69
|
+
"@size-limit/preset-small-lib": "^11.2.0",
|
|
70
|
+
"@sveltejs/kit": "^2.21.0",
|
|
71
|
+
"@sveltejs/package": "^2.3.11",
|
|
72
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
73
|
+
"@testing-library/svelte": "^4.2.3",
|
|
75
74
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
77
|
-
"@typescript-eslint/parser": "^6.
|
|
78
|
-
"@vitest/coverage-v8": "^1.
|
|
79
|
-
"eslint": "^8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
76
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
77
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
78
|
+
"eslint": "^8.57.1",
|
|
80
79
|
"eslint-config-prettier": "^9.1.0",
|
|
81
|
-
"eslint-plugin-prettier": "^5.0
|
|
82
|
-
"eslint-plugin-svelte": "^2.
|
|
80
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
81
|
+
"eslint-plugin-svelte": "^2.46.1",
|
|
83
82
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
84
83
|
"happy-dom": "^12.10.3",
|
|
85
|
-
"prettier": "^3.
|
|
86
|
-
"prettier-plugin-jsdoc": "^1.
|
|
87
|
-
"prettier-plugin-svelte": "^3.
|
|
88
|
-
"size-limit": "^11.0
|
|
84
|
+
"prettier": "^3.5.3",
|
|
85
|
+
"prettier-plugin-jsdoc": "^1.3.2",
|
|
86
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
87
|
+
"size-limit": "^11.2.0",
|
|
89
88
|
"standard-version": "^9.5.0",
|
|
90
|
-
"svelte": "^4.2.
|
|
91
|
-
"typescript": "^5.
|
|
92
|
-
"vitest": "^1.
|
|
89
|
+
"svelte": "^4.2.19",
|
|
90
|
+
"typescript": "^5.8.3",
|
|
91
|
+
"vitest": "^1.6.1"
|
|
93
92
|
},
|
|
94
93
|
"peerDependencies": {
|
|
95
94
|
"@prismicio/client": ">=7",
|
|
96
95
|
"@sveltejs/kit": ">=1",
|
|
97
|
-
"svelte": ">=4
|
|
96
|
+
"svelte": ">=4"
|
|
98
97
|
},
|
|
99
98
|
"peerDependenciesMeta": {
|
|
100
99
|
"@sveltejs/kit": {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import TodoComponent from "./TodoComponent.svelte";
|
|
3
3
|
|
|
4
|
+
import { ComponentCompat } from "../types";
|
|
5
|
+
|
|
4
6
|
import type * as prismic from "@prismicio/client";
|
|
5
7
|
import type { SvelteComponent } from "svelte";
|
|
6
8
|
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
* };
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
|
-
export let components:
|
|
87
|
+
export let components: Record<string, ComponentCompat<any>> = {};
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
90
|
* Arbitrary data passed to all Slice components as a `context` prop.
|
package/src/types.ts
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
RichTextNodeType,
|
|
4
|
-
TableField,
|
|
5
|
-
TableFieldBody,
|
|
6
|
-
TableFieldBodyRow,
|
|
7
|
-
TableFieldDataCell,
|
|
8
|
-
TableFieldHead,
|
|
9
|
-
TableFieldHeadRow,
|
|
10
|
-
TableFieldHeaderCell,
|
|
11
|
-
} from "@prismicio/client";
|
|
12
|
-
import type { ComponentType, SvelteComponent } from "svelte";
|
|
1
|
+
import type * as prismic from "@prismicio/client";
|
|
2
|
+
import type { Component, ComponentType, SvelteComponent } from "svelte";
|
|
13
3
|
|
|
14
|
-
export type SvelteRichTextSerializer =
|
|
15
|
-
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
>;
|
|
4
|
+
export type SvelteRichTextSerializer = {
|
|
5
|
+
heading1?: ComponentCompat<{ node: prismic.RTHeading1Node }>;
|
|
6
|
+
heading2?: ComponentCompat<{ node: prismic.RTHeading2Node }>;
|
|
7
|
+
heading3?: ComponentCompat<{ node: prismic.RTHeading3Node }>;
|
|
8
|
+
heading4?: ComponentCompat<{ node: prismic.RTHeading4Node }>;
|
|
9
|
+
heading5?: ComponentCompat<{ node: prismic.RTHeading5Node }>;
|
|
10
|
+
heading6?: ComponentCompat<{ node: prismic.RTHeading6Node }>;
|
|
11
|
+
paragraph?: ComponentCompat<{ node: prismic.RTParagraphNode }>;
|
|
12
|
+
preformatted?: ComponentCompat<{ node: prismic.RTPreformattedNode }>;
|
|
13
|
+
strong?: ComponentCompat<{ node: prismic.RTStrongNode }>;
|
|
14
|
+
em?: ComponentCompat<{ node: prismic.RTEmNode }>;
|
|
15
|
+
listItem?: ComponentCompat<{ node: prismic.RTListItemNode }>;
|
|
16
|
+
oListItem?: ComponentCompat<{ node: prismic.RTOListItemNode }>;
|
|
17
|
+
list?: ComponentCompat<{ node: prismic.RTListNode }>;
|
|
18
|
+
oList?: ComponentCompat<{ node: prismic.RTOListNode }>;
|
|
19
|
+
image?: ComponentCompat<{ node: prismic.RTImageNode }>;
|
|
20
|
+
embed?: ComponentCompat<{ node: prismic.RTEmbedNode }>;
|
|
21
|
+
hyperlink?: ComponentCompat<{ node: prismic.RTLinkNode }>;
|
|
22
|
+
label?: ComponentCompat<{ node: prismic.RTLabelNode }>;
|
|
23
|
+
span?: ComponentCompat<{ node: prismic.RTSpanNode }>;
|
|
24
|
+
};
|
|
26
25
|
|
|
27
26
|
// Define the type for the components prop
|
|
28
27
|
export type TableComponents = {
|
|
29
|
-
table?:
|
|
30
|
-
thead?:
|
|
31
|
-
tbody?:
|
|
32
|
-
tr?:
|
|
33
|
-
|
|
34
|
-
>;
|
|
35
|
-
th?:
|
|
36
|
-
td?:
|
|
28
|
+
table?: ComponentTypeCompat<{ table: prismic.TableField<"filled"> }>;
|
|
29
|
+
thead?: ComponentTypeCompat<{ head: prismic.TableFieldHead }>;
|
|
30
|
+
tbody?: ComponentTypeCompat<{ body: prismic.TableFieldBody }>;
|
|
31
|
+
tr?: ComponentTypeCompat<{
|
|
32
|
+
row: prismic.TableFieldHeadRow | prismic.TableFieldBodyRow;
|
|
33
|
+
}>;
|
|
34
|
+
th?: ComponentTypeCompat<{ table: prismic.TableFieldHeaderCell }>;
|
|
35
|
+
td?: ComponentTypeCompat<{ table: prismic.TableFieldDataCell }>;
|
|
37
36
|
};
|
|
37
|
+
|
|
38
|
+
// Compatibility type helpers for better compatibility with Svelte 4 and 5.
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
type ComponentTypeCompat<Props extends Record<string, any> = any> =
|
|
42
|
+
| Component<Props>
|
|
43
|
+
| ComponentType<SvelteComponent<Props>>;
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
export type ComponentCompat<Props extends Record<string, any> = any> =
|
|
47
|
+
| Component<Props>
|
|
48
|
+
| (new (
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
...args: any[]
|
|
51
|
+
) => SvelteComponent<Partial<Props>>);
|