@prismicio/svelte 1.0.3 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,8 +7,6 @@
7
7
  [![Conventional Commits][conventional-commits-src]][conventional-commits-href]
8
8
  [![License][license-src]][license-href]
9
9
 
10
- > ⚠  This project is in an experimental state. Use it at your own risk or stay tuned for the official release!
11
-
12
10
  [Svelte][svelte] components to present [Prismic][prismic] content.
13
11
 
14
12
  - 📝  Display content from Prismic like [Rich Text][prismic-rich-text] and [Link][prismic-link] fields;
@@ -24,6 +24,12 @@ $:
24
24
  ```
25
25
  -->
26
26
 
27
- <a {...linkAttrs} rel={resolvedRel} href={linkAttrs.href} {...$$restProps}>
27
+ <a
28
+ {...linkAttrs}
29
+ rel={resolvedRel}
30
+ href={linkAttrs.href}
31
+ on:click
32
+ {...$$restProps}
33
+ >
28
34
  <slot />
29
35
  </a>
@@ -24,6 +24,8 @@ declare const __propDef: {
24
24
  field?: undefined;
25
25
  });
26
26
  events: {
27
+ click: MouseEvent;
28
+ } & {
27
29
  [evt: string]: CustomEvent<any>;
28
30
  };
29
31
  slots: {
@@ -25,7 +25,12 @@ export let defaultComponent = void 0;
25
25
  {@const type = "slice_type" in slice ? slice.slice_type : slice.type}
26
26
  {@const Component = components[type] || defaultComponent}
27
27
  {#if Component}
28
- <svelte:component this={Component} {slice} {slices} {context} {index} />
28
+ {#if slice.__mapped}
29
+ {@const { __mapped, ...mappedProps } = slice}
30
+ <svelte:component this={Component} {...mappedProps} />
31
+ {:else}
32
+ <svelte:component this={Component} {slice} {slices} {context} {index} />
33
+ {/if}
29
34
  {:else}
30
35
  <TodoComponent {slice} />
31
36
  {/if}
@@ -4,10 +4,18 @@ declare const __propDef: {
4
4
  /**
5
5
  * An array of Prismic Slices, such as the `slices` property from a Prismic
6
6
  * document.
7
- */ slices?: ({
7
+ */ slices?: (({
8
8
  slice_type: string;
9
9
  } | {
10
10
  type: string;
11
+ }) & {
12
+ /**
13
+ * If `true`, this Slice has been modified from its original value using a
14
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
15
+ *
16
+ * @internal
17
+ */
18
+ __mapped?: true | undefined;
11
19
  })[] | undefined;
12
20
  /**
13
21
  * An object that maps Slice components to their corresponding API IDs.
@@ -24,15 +32,31 @@ declare const __propDef: {
24
32
  * };
25
33
  * ```
26
34
  */ components?: Record<string, new (...args: any[]) => SvelteComponent<{
27
- slice?: ({
35
+ slice?: (({
28
36
  slice_type: string;
29
37
  } | {
30
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;
31
47
  }) | undefined;
32
- slices?: ({
48
+ slices?: (({
33
49
  slice_type: string;
34
50
  } | {
35
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;
36
60
  })[] | undefined;
37
61
  context?: unknown;
38
62
  index?: number | undefined;
@@ -44,15 +68,31 @@ declare const __propDef: {
44
68
  * The Svelte component rendered if a component mapping from the `components`
45
69
  * prop cannot be found.
46
70
  */ defaultComponent?: (new (...args: any[]) => SvelteComponent<{
47
- slice?: ({
71
+ slice?: (({
48
72
  slice_type: string;
49
73
  } | {
50
74
  type: string;
75
+ }) & {
76
+ /**
77
+ * If `true`, this Slice has been modified from its original value using a
78
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
79
+ *
80
+ * @internal
81
+ */
82
+ __mapped?: true | undefined;
51
83
  }) | undefined;
52
- slices?: ({
84
+ slices?: (({
53
85
  slice_type: string;
54
86
  } | {
55
87
  type: string;
88
+ }) & {
89
+ /**
90
+ * If `true`, this Slice has been modified from its original value using a
91
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
92
+ *
93
+ * @internal
94
+ */
95
+ __mapped?: true | undefined;
56
96
  })[] | undefined;
57
97
  context?: unknown;
58
98
  index?: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/svelte",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "Svelte components to present Prismic content.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -65,7 +65,7 @@
65
65
  "esm-env": "^1.0.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@prismicio/client": "^7.2.0",
68
+ "@prismicio/client": "^7.4.0",
69
69
  "@prismicio/mock": "^0.3.1",
70
70
  "@size-limit/preset-small-lib": "^11.0.1",
71
71
  "@sveltejs/kit": "^2.0.0",
@@ -55,6 +55,12 @@
55
55
  ```
56
56
  -->
57
57
 
58
- <a {...linkAttrs} rel={resolvedRel} href={linkAttrs.href} {...$$restProps}>
58
+ <a
59
+ {...linkAttrs}
60
+ rel={resolvedRel}
61
+ href={linkAttrs.href}
62
+ on:click
63
+ {...$$restProps}
64
+ >
59
65
  <slot />
60
66
  </a>
@@ -48,9 +48,18 @@
48
48
  *
49
49
  * @typeParam SliceType - Type name of the Slice.
50
50
  */
51
- type SliceLike<SliceType extends string = string> =
51
+ type SliceLike<SliceType extends string = string> = (
52
52
  | SliceLikeRestV2<SliceType>
53
- | SliceLikeGraphQL<SliceType>;
53
+ | SliceLikeGraphQL<SliceType>
54
+ ) & {
55
+ /**
56
+ * If `true`, this Slice has been modified from its original value using a
57
+ * mapper and `@prismicio/client`'s `mapSliceZone()`.
58
+ *
59
+ * @internal
60
+ */
61
+ __mapped?: true;
62
+ };
54
63
 
55
64
  /**
56
65
  * An array of Prismic Slices, such as the `slices` property from a Prismic
@@ -108,7 +117,12 @@
108
117
  {@const type = "slice_type" in slice ? slice.slice_type : slice.type}
109
118
  {@const Component = components[type] || defaultComponent}
110
119
  {#if Component}
111
- <svelte:component this={Component} {slice} {slices} {context} {index} />
120
+ {#if slice.__mapped}
121
+ {@const { __mapped, ...mappedProps } = slice}
122
+ <svelte:component this={Component} {...mappedProps} />
123
+ {:else}
124
+ <svelte:component this={Component} {slice} {slices} {context} {index} />
125
+ {/if}
112
126
  {:else}
113
127
  <TodoComponent {slice} />
114
128
  {/if}