@ssgoi/react 3.1.0 → 3.2.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/dist/core/dist/types.cjs +1 -1
- package/dist/core/dist/types.js +47 -44
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- 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.cjs +2 -0
- package/dist/react/src/lib/transition.js +14 -0
- package/dist/transition.d.ts +23 -1
- package/package.json +2 -6
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,74 +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
|
-
async function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
prepare:
|
|
29
|
-
wait:
|
|
30
|
-
onStart:
|
|
31
|
-
onEnd:
|
|
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,
|
|
32
32
|
springs: [
|
|
33
33
|
{
|
|
34
|
-
spring:
|
|
35
|
-
tick:
|
|
36
|
-
css:
|
|
34
|
+
spring: e.spring,
|
|
35
|
+
tick: e.tick,
|
|
36
|
+
css: e.css
|
|
37
37
|
}
|
|
38
38
|
],
|
|
39
39
|
schedule: "parallel"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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 };
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
}), { schedule: u, ...r } = n;
|
|
62
|
+
), { schedule: h, ...o } = n;
|
|
60
63
|
return {
|
|
61
|
-
...
|
|
62
|
-
springs:
|
|
64
|
+
...o,
|
|
65
|
+
springs: a
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
74
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transition as n } from "
|
|
1
|
+
import { transition as n } from "./react/src/lib/transition.js";
|
|
2
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
3
|
import { Ssgoi as f } from "./react/src/lib/ssgoi.js";
|
|
4
4
|
import { SsgoiTransition as d } from "./react/src/lib/ssgoi-transition.js";
|
|
@@ -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
|
};
|
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.1
|
|
3
|
+
"version": "3.2.1",
|
|
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,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ssgoi/core": "^3.
|
|
49
|
-
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"react": "^19.0.0",
|
|
52
|
-
"react-dom": "^19.0.0"
|
|
48
|
+
"@ssgoi/core": "^3.2.0"
|
|
53
49
|
},
|
|
54
50
|
"devDependencies": {
|
|
55
51
|
"@eslint/js": "^9.30.1",
|