@prismicio/svelte 2.1.0 → 2.1.1-canary.0fd90e0

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.
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
2
  import {
3
- type ImageFieldImage,
4
3
  asImagePixelDensitySrcSet,
5
4
  asImageWidthSrcSet,
6
5
  isFilled,
7
6
  } from "@prismicio/client";
7
+ import type { ImageFieldImage } from "@prismicio/client";
8
8
  import type { ImgixURLParams } from "imgix-url-builder";
9
9
  import type { HTMLImgAttributes } from "svelte/elements";
10
10
 
@@ -1,4 +1,5 @@
1
- import { type ImageFieldImage, asImagePixelDensitySrcSet, asImageWidthSrcSet } from "@prismicio/client";
1
+ import { asImagePixelDensitySrcSet, asImageWidthSrcSet } from "@prismicio/client";
2
+ import type { ImageFieldImage } from "@prismicio/client";
2
3
  import type { ImgixURLParams } from "imgix-url-builder";
3
4
  import type { HTMLImgAttributes } from "svelte/elements";
4
5
  type Props = Omit<HTMLImgAttributes, "src" | "srcset" | "alt"> & {
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
- import {
3
- type AsLinkAttrsConfig,
4
- type LinkField,
5
- type PrismicDocument,
6
- asLinkAttrs,
2
+ import { asLinkAttrs } from "@prismicio/client";
3
+ import type {
4
+ AsLinkAttrsConfig,
5
+ LinkField,
6
+ PrismicDocument,
7
7
  } from "@prismicio/client";
8
8
  import type { HTMLAnchorAttributes } from "svelte/elements";
9
9
 
@@ -1,4 +1,4 @@
1
- import { type AsLinkAttrsConfig, type LinkField, type PrismicDocument } from "@prismicio/client";
1
+ import type { AsLinkAttrsConfig, LinkField, PrismicDocument } from "@prismicio/client";
2
2
  import type { HTMLAnchorAttributes } from "svelte/elements";
3
3
  type Props = Omit<HTMLAnchorAttributes, "rel" | "href"> & {
4
4
  /**
@@ -1,17 +1,17 @@
1
1
  <script lang="ts">
2
- import {
3
- type TableField,
2
+ import type {
3
+ TableField,
4
4
  TableFieldBody,
5
5
  TableFieldBodyRow,
6
6
  TableFieldDataCell,
7
7
  TableFieldHead,
8
8
  TableFieldHeadRow,
9
9
  TableFieldHeaderCell,
10
- isFilled,
11
10
  } from "@prismicio/client";
12
- import { type Component } from "svelte";
11
+ import { isFilled } from "@prismicio/client";
12
+ import type { Component } from "svelte";
13
13
 
14
- import { type RichTextComponents, type TableComponents } from "./types";
14
+ import type { RichTextComponents, TableComponents } from "./types";
15
15
 
16
16
  import PrismicRichText from "./PrismicRichText/PrismicRichText.svelte";
17
17
 
@@ -1,6 +1,6 @@
1
- import { type TableField } from "@prismicio/client";
2
- import { type Component } from "svelte";
3
- import { type RichTextComponents, type TableComponents } from "./types";
1
+ import type { TableField } from "@prismicio/client";
2
+ import type { Component } from "svelte";
3
+ import type { RichTextComponents, TableComponents } from "./types";
4
4
  type Props = {
5
5
  /**
6
6
  * The Prismic table field to render.
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import {
3
+ SimulatorManager,
4
+ StateEventType,
5
+ disableEventHandler,
6
+ getDefaultMessage,
7
+ getDefaultProps,
8
+ getDefaultSlices,
9
+ onClickHandler,
10
+ simulatorClass,
11
+ simulatorRootClass,
12
+ } from "@prismicio/simulator/kit";
13
+
14
+ const defaultProps = getDefaultProps();
15
+
16
+ export let zIndex = defaultProps.zIndex;
17
+ export let background = defaultProps.background;
18
+
19
+ let slices = getDefaultSlices();
20
+ let message = getDefaultMessage();
21
+
22
+ if (typeof window !== "undefined") {
23
+ const simulatorManager = new SimulatorManager();
24
+
25
+ simulatorManager.state.on(
26
+ StateEventType.Slices,
27
+ (newSlices) => {
28
+ slices = newSlices;
29
+ },
30
+ "simulator-slices",
31
+ );
32
+ simulatorManager.state.on(
33
+ StateEventType.Message,
34
+ (newMessage) => {
35
+ message = newMessage;
36
+ },
37
+ "simulator-message",
38
+ );
39
+
40
+ simulatorManager.init();
41
+ }
42
+ </script>
43
+
44
+ <div
45
+ class="{simulatorClass} {$$props.class}"
46
+ style="z-index: {zIndex}; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; overflow: auto; background: {background}"
47
+ >
48
+ {#if message}
49
+ <article>
50
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
51
+ {@html message}
52
+ </article>
53
+ {:else if slices.length}
54
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
55
+ <div
56
+ id="root"
57
+ class={simulatorRootClass}
58
+ on:click={onClickHandler}
59
+ on:submit={disableEventHandler}
60
+ on:keypress={disableEventHandler}
61
+ >
62
+ <slot {slices} />
63
+ </div>
64
+ {/if}
65
+ </div>
@@ -0,0 +1,35 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
15
+ default: any;
16
+ } ? Props extends Record<string, never> ? any : {
17
+ children?: any;
18
+ } : {});
19
+ declare const SliceSimulator: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
20
+ [x: string]: any;
21
+ zIndex?: number | undefined;
22
+ background?: string | undefined;
23
+ }, {
24
+ default: {
25
+ slices: import("@prismicio/client/*").SliceZone;
26
+ };
27
+ }>, {
28
+ [evt: string]: CustomEvent<any>;
29
+ }, {
30
+ default: {
31
+ slices: import("@prismicio/client/*").SliceZone;
32
+ };
33
+ }, {}, string>;
34
+ type SliceSimulator = InstanceType<typeof SliceSimulator>;
35
+ export default SliceSimulator;
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.sv
6
6
  export { default as PrismicTable } from "./PrismicTable.svelte";
7
7
  export { default as PrismicText } from "./PrismicText.svelte";
8
8
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
9
+ export { default as SliceSimulator } from "./SliceSimulator.svelte";
9
10
  /**
10
11
  * @deprecated Replaced with `RichTextComponents`
11
12
  */
package/dist/index.js CHANGED
@@ -5,3 +5,4 @@ export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.sv
5
5
  export { default as PrismicTable } from "./PrismicTable.svelte";
6
6
  export { default as PrismicText } from "./PrismicText.svelte";
7
7
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
8
+ export { default as SliceSimulator } from "./SliceSimulator.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/svelte",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-canary.0fd90e0",
4
4
  "description": "Svelte components to present Prismic content.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -55,28 +55,29 @@
55
55
  "test": "npm run lint && npm run types && npm run unit && npm run build"
56
56
  },
57
57
  "dependencies": {
58
+ "@prismicio/simulator": "^0.2.0",
58
59
  "esm-env": "^1.2.2"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@prismicio/client": "^7.21.0",
62
63
  "@prismicio/mock": "^0.7.1",
63
- "@sveltejs/kit": "^2.49.2",
64
+ "@sveltejs/kit": "^2.49.4",
64
65
  "@sveltejs/package": "^2.5.7",
65
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
66
- "@testing-library/svelte": "^5.2.9",
67
- "@trivago/prettier-plugin-sort-imports": "^6.0.0",
68
- "@types/node": "^25.0.3",
69
- "@vitest/coverage-v8": "^4.0.16",
70
- "globals": "^16.5.0",
71
- "happy-dom": "^20.0.11",
72
- "oxlint": "^1.33.0",
66
+ "@sveltejs/vite-plugin-svelte": "^6.2.4",
67
+ "@testing-library/svelte": "^5.3.1",
68
+ "@trivago/prettier-plugin-sort-imports": "^6.0.2",
69
+ "@types/node": "^25.0.8",
70
+ "@vitest/coverage-v8": "^4.0.17",
71
+ "globals": "^17.0.0",
72
+ "happy-dom": "^20.1.0",
73
+ "oxlint": "^1.39.0",
73
74
  "prettier": "^3.7.4",
74
75
  "prettier-plugin-jsdoc": "^1.8.0",
75
76
  "prettier-plugin-svelte": "^3.4.1",
76
77
  "standard-version": "^9.5.0",
77
- "svelte": "^5.46.0",
78
+ "svelte": "^5.46.3",
78
79
  "typescript": "^5.9.3",
79
- "vitest": "^4.0.16"
80
+ "vitest": "^4.0.17"
80
81
  },
81
82
  "peerDependencies": {
82
83
  "@prismicio/client": ">=7",
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
2
  import {
3
- type ImageFieldImage,
4
3
  asImagePixelDensitySrcSet,
5
4
  asImageWidthSrcSet,
6
5
  isFilled,
7
6
  } from "@prismicio/client";
7
+ import type { ImageFieldImage } from "@prismicio/client";
8
8
  import type { ImgixURLParams } from "imgix-url-builder";
9
9
  import type { HTMLImgAttributes } from "svelte/elements";
10
10
 
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
- import {
3
- type AsLinkAttrsConfig,
4
- type LinkField,
5
- type PrismicDocument,
6
- asLinkAttrs,
2
+ import { asLinkAttrs } from "@prismicio/client";
3
+ import type {
4
+ AsLinkAttrsConfig,
5
+ LinkField,
6
+ PrismicDocument,
7
7
  } from "@prismicio/client";
8
8
  import type { HTMLAnchorAttributes } from "svelte/elements";
9
9
 
@@ -1,17 +1,17 @@
1
1
  <script lang="ts">
2
- import {
3
- type TableField,
2
+ import type {
3
+ TableField,
4
4
  TableFieldBody,
5
5
  TableFieldBodyRow,
6
6
  TableFieldDataCell,
7
7
  TableFieldHead,
8
8
  TableFieldHeadRow,
9
9
  TableFieldHeaderCell,
10
- isFilled,
11
10
  } from "@prismicio/client";
12
- import { type Component } from "svelte";
11
+ import { isFilled } from "@prismicio/client";
12
+ import type { Component } from "svelte";
13
13
 
14
- import { type RichTextComponents, type TableComponents } from "./types";
14
+ import type { RichTextComponents, TableComponents } from "./types";
15
15
 
16
16
  import PrismicRichText from "./PrismicRichText/PrismicRichText.svelte";
17
17
 
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import {
3
+ SimulatorManager,
4
+ StateEventType,
5
+ disableEventHandler,
6
+ getDefaultMessage,
7
+ getDefaultProps,
8
+ getDefaultSlices,
9
+ onClickHandler,
10
+ simulatorClass,
11
+ simulatorRootClass,
12
+ } from "@prismicio/simulator/kit";
13
+
14
+ const defaultProps = getDefaultProps();
15
+
16
+ export let zIndex = defaultProps.zIndex;
17
+ export let background = defaultProps.background;
18
+
19
+ let slices = getDefaultSlices();
20
+ let message = getDefaultMessage();
21
+
22
+ if (typeof window !== "undefined") {
23
+ const simulatorManager = new SimulatorManager();
24
+
25
+ simulatorManager.state.on(
26
+ StateEventType.Slices,
27
+ (newSlices) => {
28
+ slices = newSlices;
29
+ },
30
+ "simulator-slices",
31
+ );
32
+ simulatorManager.state.on(
33
+ StateEventType.Message,
34
+ (newMessage) => {
35
+ message = newMessage;
36
+ },
37
+ "simulator-message",
38
+ );
39
+
40
+ simulatorManager.init();
41
+ }
42
+ </script>
43
+
44
+ <div
45
+ class="{simulatorClass} {$$props.class}"
46
+ style="z-index: {zIndex}; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; overflow: auto; background: {background}"
47
+ >
48
+ {#if message}
49
+ <article>
50
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
51
+ {@html message}
52
+ </article>
53
+ {:else if slices.length}
54
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
55
+ <div
56
+ id="root"
57
+ class={simulatorRootClass}
58
+ on:click={onClickHandler}
59
+ on:submit={disableEventHandler}
60
+ on:keypress={disableEventHandler}
61
+ >
62
+ <slot {slices} />
63
+ </div>
64
+ {/if}
65
+ </div>
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.sv
7
7
  export { default as PrismicTable } from "./PrismicTable.svelte";
8
8
  export { default as PrismicText } from "./PrismicText.svelte";
9
9
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
10
+ export { default as SliceSimulator } from "./SliceSimulator.svelte";
10
11
 
11
12
  /**
12
13
  * @deprecated Replaced with `RichTextComponents`