@ssgoi/solid 6.5.0 → 6.6.4

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/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@ssgoi/solid",
3
- "version": "6.5.0",
3
+ "version": "6.6.4",
4
4
  "description": "Solid.js bindings for SSGOI - Native app-like page transitions for Solid applications",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "files": [
8
+ "src/lib",
8
9
  "dist",
10
+ "!src/**/*.test.*",
11
+ "!src/**/*.spec.*",
9
12
  "!dist/**/*.test.*",
10
13
  "!dist/**/*.spec.*"
11
14
  ],
@@ -14,18 +17,21 @@
14
17
  "types": "./dist/index.d.ts",
15
18
  "exports": {
16
19
  ".": {
20
+ "solid": "./src/lib/index.ts",
17
21
  "types": "./dist/index.d.ts",
18
22
  "import": "./dist/index.js",
19
23
  "require": "./dist/index.cjs",
20
24
  "default": "./dist/index.js"
21
25
  },
22
26
  "./types": {
27
+ "solid": "./src/lib/types.ts",
23
28
  "types": "./dist/types.d.ts",
24
29
  "import": "./dist/types.js",
25
30
  "require": "./dist/types.cjs",
26
31
  "default": "./dist/types.js"
27
32
  },
28
33
  "./view-transitions": {
34
+ "solid": "./src/lib/view-transitions.ts",
29
35
  "types": "./dist/view-transitions.d.ts",
30
36
  "import": "./dist/view-transitions.js",
31
37
  "require": "./dist/view-transitions.cjs",
@@ -33,7 +39,7 @@
33
39
  }
34
40
  },
35
41
  "dependencies": {
36
- "@ssgoi/core": "^6.5.0"
42
+ "@ssgoi/core": "^6.6.4"
37
43
  },
38
44
  "devDependencies": {
39
45
  "@eslint/js": "^9.30.1",
@@ -0,0 +1,14 @@
1
+ import { createContext, useContext } from "solid-js";
2
+ import type { SsgoiContext } from "./types";
3
+
4
+ const SsgoiContextInstance = createContext<SsgoiContext | null>(null);
5
+
6
+ export const SsgoiProvider = SsgoiContextInstance.Provider;
7
+
8
+ export const useSsgoi = () => {
9
+ const context = useContext(SsgoiContextInstance);
10
+ if (!context) {
11
+ throw new Error("useSsgoi must be used within SsgoiProvider");
12
+ }
13
+ return context;
14
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export { Ssgoi } from "./ssgoi";
3
+ /** @deprecated Set `data-ssgoi-transition` directly on an element inside `<Ssgoi>` instead. */
4
+ export { SsgoiTransition } from "./ssgoi-transition";
5
+ export * from "@ssgoi/core";
@@ -0,0 +1,34 @@
1
+ import { splitProps, type JSX, type ValidComponent } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
3
+ import { useSsgoi } from "./context";
4
+
5
+ type SsgoiTransitionProps<T extends ValidComponent = "div"> = {
6
+ children: JSX.Element;
7
+ id: string;
8
+ as?: T;
9
+ class?: string;
10
+ };
11
+
12
+ /**
13
+ * @deprecated Set `data-ssgoi-transition` directly on the page boundary
14
+ * element inside `<Ssgoi>` instead.
15
+ */
16
+ export const SsgoiTransition = <T extends ValidComponent = "div">(
17
+ props: SsgoiTransitionProps<T>,
18
+ ) => {
19
+ const [local, rest] = splitProps(props, ["children", "id", "as", "class"]);
20
+ const ssgoi = useSsgoi();
21
+ const component = (local.as || "div") as ValidComponent;
22
+
23
+ return (
24
+ <Dynamic
25
+ component={component}
26
+ ref={ssgoi.refFor(local.id)}
27
+ data-ssgoi-transition={local.id}
28
+ class={local.class}
29
+ {...(rest as object)}
30
+ >
31
+ {local.children}
32
+ </Dynamic>
33
+ );
34
+ };
@@ -0,0 +1,35 @@
1
+ import { createEffect, createMemo, onCleanup, type JSX } from "solid-js";
2
+ import type { SsgoiConfig, SsgoiContext } from "./types";
3
+ import { SsgoiProvider } from "./context";
4
+ import {
5
+ createSggoiTransitionContext,
6
+ observeSsgoiTransitions,
7
+ } from "@ssgoi/core/internal";
8
+ import type { HostAnimation } from "@ssgoi/core/internal";
9
+
10
+ interface SsgoiProps {
11
+ config: SsgoiConfig;
12
+ host?: HostAnimation;
13
+ children: JSX.Element;
14
+ }
15
+
16
+ export const Ssgoi = (props: SsgoiProps) => {
17
+ let root!: HTMLDivElement;
18
+ const contextValue = createMemo<SsgoiContext>(() =>
19
+ createSggoiTransitionContext(props.config, { host: props.host }),
20
+ );
21
+
22
+ createEffect(() => {
23
+ if (!root) return;
24
+ const cleanup = observeSsgoiTransitions(root, contextValue());
25
+ onCleanup(cleanup);
26
+ });
27
+
28
+ return (
29
+ <SsgoiProvider value={contextValue()}>
30
+ <div ref={root} data-ssgoi-root="" style={{ display: "contents" }}>
31
+ {props.children}
32
+ </div>
33
+ </SsgoiProvider>
34
+ );
35
+ };
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core/types";
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core";