@ssgoi/react 3.0.0 → 3.2.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/core/dist/types.cjs +1 -1
- package/dist/core/dist/types.js +47 -43
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -10
- package/dist/react/src/lib/ssgoi-transition.cjs +1 -1
- package/dist/react/src/lib/ssgoi-transition.js +1 -1
- package/dist/react/src/lib/ssgoi.cjs +1 -1
- package/dist/react/src/lib/ssgoi.js +7 -3
- package/dist/react/src/lib/transition-scope.cjs +2 -0
- package/dist/react/src/lib/transition-scope.js +9 -0
- package/dist/react/src/lib/transition.cjs +2 -0
- package/dist/react/src/lib/transition.js +14 -0
- package/dist/transition-scope.d.ts +28 -0
- package/dist/transition.d.ts +23 -1
- package/package.json +4 -4
package/dist/core/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function h(e){return("tick"in e||"css"in e)&&!("springs"in e)}function s(e){return"springs"in e}function o(e){return"css"in e&&typeof e.css=="function"}function a(e){return"tick"in e&&typeof e.tick=="function"}function c(e){if(o(e)&&a(e))throw new Error("SingleSpringConfig cannot have both 'tick' and 'css' defined. Use one or the other.")}function l(e){if(e.tick&&e.css)throw new Error("SpringItem cannot have both 'tick' and 'css' defined. Use one or the other.")}async function m(e){const n=await e;return s(n)?(n.springs.forEach(l),n):(c(n),{prepare:n.prepare,wait:n.wait,onStart:n.onStart,onEnd:n.onEnd,springs:[{spring:n.spring,tick:n.tick,css:n.css}],schedule:"parallel"})}function S(e,n){const u=e.schedule??"parallel",f=e.springs.map(r=>{let t;switch(u){case"parallel":t=0;break;case"sequential":t=1;break;case"stagger":t=Math.max(0,Math.min(1,r.offset??0));break;default:t=0}const{css:i,offset:w,...g}=r,d=i?typeof i=="function"?n?{element:n,style:i}:void 0:{element:i.element,style:i.style}:void 0;return{...g,css:d,normalizedOffset:t}}),{schedule:k,...p}=e;return{...p,springs:f}}exports.isCssAnimation=o;exports.isMultiSpring=s;exports.isSingleSpring=h;exports.isTickAnimation=a;exports.normalizeMultiSpringSchedule=S;exports.normalizeToMultiSpring=m;exports.validateAnimationMode=c;exports.validateSpringItem=l;
|
package/dist/core/dist/types.js
CHANGED
|
@@ -1,73 +1,77 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(n) {
|
|
2
2
|
return ("tick" in n || "css" in n) && !("springs" in n);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function f(n) {
|
|
5
5
|
return "springs" in n;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function p(n) {
|
|
8
8
|
return "css" in n && typeof n.css == "function";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function u(n) {
|
|
11
11
|
return "tick" in n && typeof n.tick == "function";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
13
|
+
function g(n) {
|
|
14
|
+
if (p(n) && u(n))
|
|
15
15
|
throw new Error(
|
|
16
16
|
"SingleSpringConfig cannot have both 'tick' and 'css' defined. Use one or the other."
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function d(n) {
|
|
20
20
|
if (n.tick && n.css)
|
|
21
21
|
throw new Error(
|
|
22
22
|
"SpringItem cannot have both 'tick' and 'css' defined. Use one or the other."
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
async function S(n) {
|
|
26
|
+
const e = await n;
|
|
27
|
+
return f(e) ? (e.springs.forEach(d), e) : (g(e), {
|
|
28
|
+
prepare: e.prepare,
|
|
29
|
+
wait: e.wait,
|
|
30
|
+
onStart: e.onStart,
|
|
31
|
+
onEnd: e.onEnd,
|
|
31
32
|
springs: [
|
|
32
33
|
{
|
|
33
|
-
spring:
|
|
34
|
-
tick:
|
|
35
|
-
css:
|
|
34
|
+
spring: e.spring,
|
|
35
|
+
tick: e.tick,
|
|
36
|
+
css: e.css
|
|
36
37
|
}
|
|
37
38
|
],
|
|
38
39
|
schedule: "parallel"
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
const r = n.schedule ?? "parallel",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
function w(n, e) {
|
|
43
|
+
const r = n.schedule ?? "parallel", a = n.springs.map(
|
|
44
|
+
(s) => {
|
|
45
|
+
let t;
|
|
46
|
+
switch (r) {
|
|
47
|
+
case "parallel":
|
|
48
|
+
t = 0;
|
|
49
|
+
break;
|
|
50
|
+
case "sequential":
|
|
51
|
+
t = 1;
|
|
52
|
+
break;
|
|
53
|
+
case "stagger":
|
|
54
|
+
t = Math.max(0, Math.min(1, s.offset ?? 0));
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
t = 0;
|
|
58
|
+
}
|
|
59
|
+
const { css: i, offset: m, ...c } = s, l = i ? typeof i == "function" ? e ? { element: e, style: i } : void 0 : { element: i.element, style: i.style } : void 0;
|
|
60
|
+
return { ...c, css: l, normalizedOffset: t };
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
}), { schedule: u, ...a } = n;
|
|
62
|
+
), { schedule: h, ...o } = n;
|
|
59
63
|
return {
|
|
60
|
-
...
|
|
61
|
-
springs:
|
|
64
|
+
...o,
|
|
65
|
+
springs: a
|
|
62
66
|
};
|
|
63
67
|
}
|
|
64
68
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
p as isCssAnimation,
|
|
70
|
+
f as isMultiSpring,
|
|
71
|
+
k as isSingleSpring,
|
|
72
|
+
u as isTickAnimation,
|
|
73
|
+
w as normalizeMultiSpringSchedule,
|
|
74
|
+
S as normalizeToMultiSpring,
|
|
75
|
+
g as validateAnimationMode,
|
|
76
|
+
d as validateSpringItem
|
|
73
77
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./react/src/lib/transition.cjs"),i=require("./core/dist/types.cjs"),t=require("./react/src/lib/ssgoi.cjs"),o=require("./react/src/lib/ssgoi-transition.cjs"),e=require("./react/src/lib/transition-scope.cjs");exports.transition=n.transition;exports.isCssAnimation=i.isCssAnimation;exports.isMultiSpring=i.isMultiSpring;exports.isSingleSpring=i.isSingleSpring;exports.isTickAnimation=i.isTickAnimation;exports.normalizeMultiSpringSchedule=i.normalizeMultiSpringSchedule;exports.normalizeToMultiSpring=i.normalizeToMultiSpring;exports.validateAnimationMode=i.validateAnimationMode;exports.validateSpringItem=i.validateSpringItem;exports.Ssgoi=t.Ssgoi;exports.SsgoiTransition=o.SsgoiTransition;exports.TransitionScope=e.TransitionScope;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { transition as n } from "
|
|
2
|
-
import { isCssAnimation as t, isMultiSpring as e, isSingleSpring as a, isTickAnimation as m, normalizeMultiSpringSchedule as
|
|
3
|
-
import { Ssgoi as
|
|
4
|
-
import { SsgoiTransition as
|
|
1
|
+
import { transition as n } from "./react/src/lib/transition.js";
|
|
2
|
+
import { isCssAnimation as t, isMultiSpring as e, isSingleSpring as a, isTickAnimation as m, normalizeMultiSpringSchedule as p, normalizeToMultiSpring as s, validateAnimationMode as S, validateSpringItem as l } from "./core/dist/types.js";
|
|
3
|
+
import { Ssgoi as f } from "./react/src/lib/ssgoi.js";
|
|
4
|
+
import { SsgoiTransition as d } from "./react/src/lib/ssgoi-transition.js";
|
|
5
|
+
import { TransitionScope as M } from "./react/src/lib/transition-scope.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
f as Ssgoi,
|
|
8
|
+
d as SsgoiTransition,
|
|
9
|
+
M as TransitionScope,
|
|
8
10
|
t as isCssAnimation,
|
|
9
11
|
e as isMultiSpring,
|
|
10
12
|
a as isSingleSpring,
|
|
11
13
|
m as isTickAnimation,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
p as normalizeMultiSpringSchedule,
|
|
15
|
+
s as normalizeToMultiSpring,
|
|
14
16
|
n as transition,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
S as validateAnimationMode,
|
|
18
|
+
l as validateSpringItem
|
|
17
19
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),c=require("./transition.cjs"),u=require("./context.cjs"),g=({children:n,id:t,as:i,className:o,...s})=>{const e=u.useSsgoi(),r=i||"div";return a.jsx(r,{ref:c.transition(e(t)),"data-ssgoi-transition":t,className:o,...s,children:n})};exports.SsgoiTransition=g;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),i=require("./context.cjs"),n=require("@ssgoi/core"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),i=require("./context.cjs"),n=require("@ssgoi/core"),u=({config:e,children:t})=>{const o=s.useMemo(()=>n.createSggoiTransitionContext(e,{outFirst:!1}),[e]);return r.jsx(i.SsgoiProvider,{value:o,children:t})};exports.Ssgoi=u;
|
|
@@ -3,13 +3,17 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
3
3
|
import { useMemo as i } from "react";
|
|
4
4
|
import { SsgoiProvider as m } from "./context.js";
|
|
5
5
|
import { createSggoiTransitionContext as s } from "@ssgoi/core";
|
|
6
|
-
const
|
|
6
|
+
const f = ({ config: o, children: r }) => {
|
|
7
7
|
const t = i(
|
|
8
|
-
() => s(o
|
|
8
|
+
() => s(o, {
|
|
9
|
+
// React uses MutationObserver for unmount detection,
|
|
10
|
+
// so OUT and IN can arrive in any order
|
|
11
|
+
outFirst: !1
|
|
12
|
+
}),
|
|
9
13
|
[o]
|
|
10
14
|
);
|
|
11
15
|
return /* @__PURE__ */ e(m, { value: t, children: r });
|
|
12
16
|
};
|
|
13
17
|
export {
|
|
14
|
-
|
|
18
|
+
f as Ssgoi
|
|
15
19
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("@ssgoi/core");function r({children:e}){return t.jsx("div",{ref:n.createTransitionScope(),style:{display:"contents"},children:e})}exports.TransitionScope=r;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { createTransitionScope as t } from "@ssgoi/core";
|
|
4
|
+
function n({ children: o }) {
|
|
5
|
+
return /* @__PURE__ */ r("div", { ref: t(), style: { display: "contents" }, children: o });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
n as TransitionScope
|
|
9
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type TransitionScopeProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* TransitionScope creates a boundary for local-scoped transitions.
|
|
7
|
+
*
|
|
8
|
+
* Child elements with `scope: 'local'` will:
|
|
9
|
+
* - Skip IN animation when mounted simultaneously with the scope
|
|
10
|
+
* - Skip OUT animation when unmounted simultaneously with the scope
|
|
11
|
+
*
|
|
12
|
+
* This is useful for:
|
|
13
|
+
* - Page transitions where child elements shouldn't animate individually
|
|
14
|
+
* - Modal/dialog content that appears/disappears with the container
|
|
15
|
+
* - List items that shouldn't animate when the entire list mounts/unmounts
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <TransitionScope>
|
|
20
|
+
* <div ref={transition(fadeIn(), { scope: 'local' })}>
|
|
21
|
+
* This will only animate when added/removed independently,
|
|
22
|
+
* not when the entire scope mounts/unmounts.
|
|
23
|
+
* </div>
|
|
24
|
+
* </TransitionScope>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function TransitionScope({ children }: TransitionScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
package/dist/transition.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { Transition, TransitionKey, TransitionScope } from '@ssgoi/core';
|
|
2
|
+
type TransitionOptions = Transition<undefined> & {
|
|
3
|
+
key?: TransitionKey;
|
|
4
|
+
scope?: TransitionScope;
|
|
5
|
+
ref?: object;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* React ref callback for element transitions
|
|
9
|
+
*
|
|
10
|
+
* OUT transition is automatically triggered by MutationObserver
|
|
11
|
+
* when the element is removed from the DOM - works with React 18+
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <div ref={transition({
|
|
16
|
+
* key: 'fade',
|
|
17
|
+
* in: (el) => ({ tick: (p) => el.style.opacity = String(p) }),
|
|
18
|
+
* out: (el) => ({ tick: (p) => el.style.opacity = String(p) }),
|
|
19
|
+
* })} />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const transition: (options: TransitionOptions) => (element: HTMLElement | null) => void;
|
|
23
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "React bindings for SSGOI - Native app-like page transitions for React applications",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ssgoi/core": "^3.
|
|
48
|
+
"@ssgoi/core": "^3.2.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"react": "^
|
|
52
|
-
"react-dom": "^
|
|
51
|
+
"react": "^18.0.0",
|
|
52
|
+
"react-dom": "^18.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@eslint/js": "^9.30.1",
|