@ssgoi/react 3.0.0 → 3.1.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(n){return("tick"in n||"css"in n)&&!("springs"in n)}function r(n){return"springs"in n}function s(n){return"css"in n&&typeof n.css=="function"}function e(n){return"tick"in n&&typeof n.tick=="function"}function o(n){if(s(n)&&e(n))throw new Error("SingleSpringConfig cannot have both 'tick' and 'css' defined. Use one or the other.")}function a(n){if(n.tick&&n.css)throw new Error("SpringItem cannot have both 'tick' and 'css' defined. Use one or the other.")}function f(n){return r(n)?(n.springs.forEach(a),n):(o(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 g(n){const c=n.schedule??"parallel",l=n.springs.map(t=>{let i;switch(c){case"parallel":i=0;break;case"sequential":i=1;break;case"stagger":i=Math.max(0,Math.min(1,t.offset??0));break;default:i=0}return{...t,normalizedOffset:i}}),{schedule:d,...u}=n;return{...u,springs:l}}exports.isCssAnimation=s;exports.isMultiSpring=r;exports.isSingleSpring=p;exports.isTickAnimation=e;exports.normalizeMultiSpringSchedule=g;exports.normalizeToMultiSpring=f;exports.validateAnimationMode=o;exports.validateSpringItem=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(n){return("tick"in n||"css"in n)&&!("springs"in n)}function r(n){return"springs"in n}function s(n){return"css"in n&&typeof n.css=="function"}function a(n){return"tick"in n&&typeof n.tick=="function"}function o(n){if(s(n)&&a(n))throw new Error("SingleSpringConfig cannot have both 'tick' and 'css' defined. Use one or the other.")}function c(n){if(n.tick&&n.css)throw new Error("SpringItem cannot have both 'tick' and 'css' defined. Use one or the other.")}async function f(n){const i=await n;return r(i)?(i.springs.forEach(c),i):(o(i),{prepare:i.prepare,wait:i.wait,onStart:i.onStart,onEnd:i.onEnd,springs:[{spring:i.spring,tick:i.tick,css:i.css}],schedule:"parallel"})}function g(n){const i=n.schedule??"parallel",l=n.springs.map(t=>{let e;switch(i){case"parallel":e=0;break;case"sequential":e=1;break;case"stagger":e=Math.max(0,Math.min(1,t.offset??0));break;default:e=0}return{...t,normalizedOffset:e}}),{schedule:d,...u}=n;return{...u,springs:l}}exports.isCssAnimation=s;exports.isMultiSpring=r;exports.isSingleSpring=p;exports.isTickAnimation=a;exports.normalizeMultiSpringSchedule=g;exports.normalizeToMultiSpring=f;exports.validateAnimationMode=o;exports.validateSpringItem=c;
@@ -1,7 +1,7 @@
1
1
  function f(n) {
2
2
  return ("tick" in n || "css" in n) && !("springs" in n);
3
3
  }
4
- function e(n) {
4
+ function a(n) {
5
5
  return "springs" in n;
6
6
  }
7
7
  function o(n) {
@@ -22,48 +22,49 @@ function p(n) {
22
22
  "SpringItem cannot have both 'tick' and 'css' defined. Use one or the other."
23
23
  );
24
24
  }
25
- function g(n) {
26
- return e(n) ? (n.springs.forEach(p), n) : (l(n), {
27
- prepare: n.prepare,
28
- wait: n.wait,
29
- onStart: n.onStart,
30
- onEnd: n.onEnd,
25
+ async function g(n) {
26
+ const i = await n;
27
+ return a(i) ? (i.springs.forEach(p), i) : (l(i), {
28
+ prepare: i.prepare,
29
+ wait: i.wait,
30
+ onStart: i.onStart,
31
+ onEnd: i.onEnd,
31
32
  springs: [
32
33
  {
33
- spring: n.spring,
34
- tick: n.tick,
35
- css: n.css
34
+ spring: i.spring,
35
+ tick: i.tick,
36
+ css: i.css
36
37
  }
37
38
  ],
38
39
  schedule: "parallel"
39
40
  });
40
41
  }
41
42
  function h(n) {
42
- const r = n.schedule ?? "parallel", s = n.springs.map((t) => {
43
- let i;
44
- switch (r) {
43
+ const i = n.schedule ?? "parallel", s = n.springs.map((e) => {
44
+ let t;
45
+ switch (i) {
45
46
  case "parallel":
46
- i = 0;
47
+ t = 0;
47
48
  break;
48
49
  case "sequential":
49
- i = 1;
50
+ t = 1;
50
51
  break;
51
52
  case "stagger":
52
- i = Math.max(0, Math.min(1, t.offset ?? 0));
53
+ t = Math.max(0, Math.min(1, e.offset ?? 0));
53
54
  break;
54
55
  default:
55
- i = 0;
56
+ t = 0;
56
57
  }
57
- return { ...t, normalizedOffset: i };
58
- }), { schedule: u, ...a } = n;
58
+ return { ...e, normalizedOffset: t };
59
+ }), { schedule: u, ...r } = n;
59
60
  return {
60
- ...a,
61
+ ...r,
61
62
  springs: s
62
63
  };
63
64
  }
64
65
  export {
65
66
  o as isCssAnimation,
66
- e as isMultiSpring,
67
+ a as isMultiSpring,
67
68
  f as isSingleSpring,
68
69
  c as isTickAnimation,
69
70
  h as normalizeMultiSpringSchedule,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@ssgoi/core"),i=require("./core/dist/types.cjs"),e=require("./react/src/lib/ssgoi.cjs"),t=require("./react/src/lib/ssgoi-transition.cjs");Object.defineProperty(exports,"transition",{enumerable:!0,get:()=>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=e.Ssgoi;exports.SsgoiTransition=t.SsgoiTransition;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@ssgoi/core"),i=require("./core/dist/types.cjs"),e=require("./react/src/lib/ssgoi.cjs"),t=require("./react/src/lib/ssgoi-transition.cjs"),o=require("./react/src/lib/transition-scope.cjs");Object.defineProperty(exports,"transition",{enumerable:!0,get:()=>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=e.Ssgoi;exports.SsgoiTransition=t.SsgoiTransition;exports.TransitionScope=o.TransitionScope;
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { transition } from './transition';
2
2
  export * from './types';
3
3
  export { Ssgoi } from './ssgoi';
4
4
  export { SsgoiTransition } from './ssgoi-transition';
5
+ export { TransitionScope } from './transition-scope';
package/dist/index.js CHANGED
@@ -1,17 +1,19 @@
1
1
  import { transition as n } from "@ssgoi/core";
2
- import { isCssAnimation as t, isMultiSpring as e, isSingleSpring as a, isTickAnimation as m, normalizeMultiSpringSchedule as s, normalizeToMultiSpring as l, validateAnimationMode as p, validateSpringItem as S } from "./core/dist/types.js";
3
- import { Ssgoi as d } from "./react/src/lib/ssgoi.js";
4
- import { SsgoiTransition as u } from "./react/src/lib/ssgoi-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
- d as Ssgoi,
7
- u as SsgoiTransition,
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
- s as normalizeMultiSpringSchedule,
13
- l as normalizeToMultiSpring,
14
+ p as normalizeMultiSpringSchedule,
15
+ s as normalizeToMultiSpring,
14
16
  n as transition,
15
- p as validateAnimationMode,
16
- S as validateSpringItem
17
+ S as validateAnimationMode,
18
+ l as validateSpringItem
17
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/react",
3
- "version": "3.0.0",
3
+ "version": "3.1.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,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@ssgoi/core": "^3.0.0"
48
+ "@ssgoi/core": "^3.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^19.0.0",