@ssgoi/react 0.0.7 → 2.0.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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/presets");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
@@ -0,0 +1 @@
1
+ export * from '@ssgoi/core/presets';
@@ -0,0 +1 @@
1
+ export * from "@ssgoi/core/presets";
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("@ssgoi/core"),s=require("./context.cjs"),r=({children:i,id:t})=>{const e=s.useSsgoi();return n.jsx("div",{ref:o.transition(e(t)),"data-ssgoi-transition":t,children:i})};exports.SsgoiTransition=r;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ import { transition as s } from "@ssgoi/core";
4
+ import { useSsgoi as n } from "./context.js";
5
+ const f = ({
6
+ children: t,
7
+ id: o
8
+ }) => {
9
+ const i = n();
10
+ return /* @__PURE__ */ r("div", { ref: s(i(o)), "data-ssgoi-transition": o, children: t });
11
+ };
12
+ export {
13
+ f as SsgoiTransition
14
+ };
package/dist/ssgoi.cjs ADDED
@@ -0,0 +1,2 @@
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"),c=({config:e,children:t})=>{const o=s.useMemo(()=>n.createSggoiTransitionContext(e),[e]);return r.jsx(i.SsgoiProvider,{value:o,children:t})};exports.Ssgoi=c;
package/dist/ssgoi.js ADDED
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as e } from "react/jsx-runtime";
3
+ import { useMemo as i } from "react";
4
+ import { SsgoiProvider as m } from "./context.js";
5
+ import { createSggoiTransitionContext as s } from "@ssgoi/core";
6
+ const x = ({ config: o, children: r }) => {
7
+ const t = i(
8
+ () => s(o),
9
+ [o]
10
+ );
11
+ return /* @__PURE__ */ e(m, { value: t, children: r });
12
+ };
13
+ export {
14
+ x as Ssgoi
15
+ };
@@ -1,2 +1 @@
1
- import { transition as _transition } from '@ssgoi/core';
2
- export declare const transition: typeof _transition;
1
+ export { transition } from '@ssgoi/core';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=(o={})=>{const{from:i=0,to:a=1,spring:e={stiffness:300,damping:30}}=o;return{in:r=>({spring:e,tick:n=>{const t=i+(a-i)*n;r.style.opacity=t.toString()}}),out:r=>({spring:e,tick:n=>{const t=i+(a-i)*n;r.style.opacity=t.toString()}})}},g=(o={})=>{const{from:i=0,to:a=1,spring:e={stiffness:300,damping:30}}=o;return{in:r=>({spring:e,tick:n=>{const t=i+(a-i)*n;r.style.transform=`scale(${t})`}}),out:r=>({spring:e,tick:n=>{const t=i+(a-i)*n;r.style.transform=`scale(${t})`}})}},f=(o={})=>{const{direction:i="left",distance:a=100,fade:e=!0,spring:r={stiffness:400,damping:35}}=o,n=t=>{const s=(1-t)*a;switch(i){case"left":return`translateX(${-s}px)`;case"right":return`translateX(${s}px)`;case"up":return`translateY(${-s}px)`;case"down":return`translateY(${s}px)`}};return{in:t=>({spring:r,tick:s=>{t.style.transform=n(s),e&&(t.style.opacity=s.toString())}}),out:t=>({spring:r,tick:s=>{t.style.transform=n(s),e&&(t.style.opacity=s.toString())}})}},u=(o={})=>{const{degrees:i=360,clockwise:a=!0,scale:e=!1,fade:r=!1,spring:n={stiffness:500,damping:25}}=o,t=a?i:-i;return{in:s=>({spring:n,tick:c=>{const l=[`rotate(${c*t}deg)`];e&&l.push(`scale(${c})`),s.style.transform=l.join(" "),r&&(s.style.opacity=c.toString())}}),out:s=>({spring:n,tick:c=>{const l=[`rotate(${c*t}deg)`];e&&l.push(`scale(${c})`),s.style.transform=l.join(" "),r&&(s.style.opacity=c.toString())}})}},y=(o={})=>{const{height:i=20,scale:a=!0,fade:e=!1,spring:r={stiffness:800,damping:15}}=o;return{in:n=>({spring:r,tick:t=>{const s=[],c=Math.sin(t*Math.PI)*i*(1-t);s.push(`translateY(${-c}px)`),a&&s.push(`scale(${.8+t*.2})`),n.style.transform=s.join(" "),e&&(n.style.opacity=t.toString())}}),out:n=>({spring:r,tick:t=>{const s=[],c=Math.sin(t*Math.PI)*i*(1-t);s.push(`translateY(${-c}px)`),a&&s.push(`scale(${.8+t*.2})`),n.style.transform=s.join(" "),e&&(n.style.opacity=t.toString())}})}},d=(o={})=>{const{amount:i=10,scale:a=!1,fade:e=!0,spring:r={stiffness:300,damping:30}}=o;return{in:n=>({spring:r,tick:t=>{const s=[`blur(${(1-t)*i}px)`];n.style.filter=s.join(" "),a&&(n.style.transform=`scale(${.8+t*.2})`),e&&(n.style.opacity=t.toString())}}),out:n=>({spring:r,tick:t=>{const s=[`blur(${(1-t)*i}px)`];n.style.filter=s.join(" "),a&&(n.style.transform=`scale(${.8+t*.2})`),e&&(n.style.opacity=t.toString())}})}},m=(o={})=>{const{spring:i={stiffness:1e3,damping:100}}=o;return{in:a=>({spring:i,tick:e=>{}}),out:a=>({spring:i,tick:e=>{}})}};exports.blur=d;exports.bounce=y;exports.fade=p;exports.none=m;exports.rotate=u;exports.scale=g;exports.slide=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/transitions");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
@@ -1,173 +1 @@
1
- const l = (o = {}) => {
2
- const {
3
- from: i = 0,
4
- to: a = 1,
5
- spring: r = { stiffness: 300, damping: 30 }
6
- } = o;
7
- return {
8
- in: (e) => ({
9
- spring: r,
10
- tick: (n) => {
11
- const t = i + (a - i) * n;
12
- e.style.opacity = t.toString();
13
- }
14
- }),
15
- out: (e) => ({
16
- spring: r,
17
- tick: (n) => {
18
- const t = i + (a - i) * n;
19
- e.style.opacity = t.toString();
20
- }
21
- })
22
- };
23
- }, g = (o = {}) => {
24
- const {
25
- from: i = 0,
26
- to: a = 1,
27
- spring: r = { stiffness: 300, damping: 30 }
28
- } = o;
29
- return {
30
- in: (e) => ({
31
- spring: r,
32
- tick: (n) => {
33
- const t = i + (a - i) * n;
34
- e.style.transform = `scale(${t})`;
35
- }
36
- }),
37
- out: (e) => ({
38
- spring: r,
39
- tick: (n) => {
40
- const t = i + (a - i) * n;
41
- e.style.transform = `scale(${t})`;
42
- }
43
- })
44
- };
45
- }, f = (o = {}) => {
46
- const {
47
- direction: i = "left",
48
- distance: a = 100,
49
- fade: r = !0,
50
- spring: e = { stiffness: 400, damping: 35 }
51
- } = o, n = (t) => {
52
- const s = (1 - t) * a;
53
- switch (i) {
54
- case "left":
55
- return `translateX(${-s}px)`;
56
- case "right":
57
- return `translateX(${s}px)`;
58
- case "up":
59
- return `translateY(${-s}px)`;
60
- case "down":
61
- return `translateY(${s}px)`;
62
- }
63
- };
64
- return {
65
- in: (t) => ({
66
- spring: e,
67
- tick: (s) => {
68
- t.style.transform = n(s), r && (t.style.opacity = s.toString());
69
- }
70
- }),
71
- out: (t) => ({
72
- spring: e,
73
- tick: (s) => {
74
- t.style.transform = n(s), r && (t.style.opacity = s.toString());
75
- }
76
- })
77
- };
78
- }, u = (o = {}) => {
79
- const {
80
- degrees: i = 360,
81
- clockwise: a = !0,
82
- scale: r = !1,
83
- fade: e = !1,
84
- spring: n = { stiffness: 500, damping: 25 }
85
- } = o, t = a ? i : -i;
86
- return {
87
- in: (s) => ({
88
- spring: n,
89
- tick: (c) => {
90
- const p = [`rotate(${c * t}deg)`];
91
- r && p.push(`scale(${c})`), s.style.transform = p.join(" "), e && (s.style.opacity = c.toString());
92
- }
93
- }),
94
- out: (s) => ({
95
- spring: n,
96
- tick: (c) => {
97
- const p = [`rotate(${c * t}deg)`];
98
- r && p.push(`scale(${c})`), s.style.transform = p.join(" "), e && (s.style.opacity = c.toString());
99
- }
100
- })
101
- };
102
- }, y = (o = {}) => {
103
- const {
104
- height: i = 20,
105
- scale: a = !0,
106
- fade: r = !1,
107
- spring: e = { stiffness: 800, damping: 15 }
108
- } = o;
109
- return {
110
- in: (n) => ({
111
- spring: e,
112
- tick: (t) => {
113
- const s = [], c = Math.sin(t * Math.PI) * i * (1 - t);
114
- s.push(`translateY(${-c}px)`), a && s.push(`scale(${0.8 + t * 0.2})`), n.style.transform = s.join(" "), r && (n.style.opacity = t.toString());
115
- }
116
- }),
117
- out: (n) => ({
118
- spring: e,
119
- tick: (t) => {
120
- const s = [], c = Math.sin(t * Math.PI) * i * (1 - t);
121
- s.push(`translateY(${-c}px)`), a && s.push(`scale(${0.8 + t * 0.2})`), n.style.transform = s.join(" "), r && (n.style.opacity = t.toString());
122
- }
123
- })
124
- };
125
- }, m = (o = {}) => {
126
- const {
127
- amount: i = 10,
128
- scale: a = !1,
129
- fade: r = !0,
130
- spring: e = { stiffness: 300, damping: 30 }
131
- } = o;
132
- return {
133
- in: (n) => ({
134
- spring: e,
135
- tick: (t) => {
136
- const s = [`blur(${(1 - t) * i}px)`];
137
- n.style.filter = s.join(" "), a && (n.style.transform = `scale(${0.8 + t * 0.2})`), r && (n.style.opacity = t.toString());
138
- }
139
- }),
140
- out: (n) => ({
141
- spring: e,
142
- tick: (t) => {
143
- const s = [`blur(${(1 - t) * i}px)`];
144
- n.style.filter = s.join(" "), a && (n.style.transform = `scale(${0.8 + t * 0.2})`), r && (n.style.opacity = t.toString());
145
- }
146
- })
147
- };
148
- }, d = (o = {}) => {
149
- const {
150
- spring: i = { stiffness: 1e3, damping: 100 }
151
- } = o;
152
- return {
153
- in: (a) => ({
154
- spring: i,
155
- tick: (r) => {
156
- }
157
- }),
158
- out: (a) => ({
159
- spring: i,
160
- tick: (r) => {
161
- }
162
- })
163
- };
164
- };
165
- export {
166
- m as blur,
167
- y as bounce,
168
- l as fade,
169
- d as none,
170
- u as rotate,
171
- g as scale,
172
- f as slide
173
- };
1
+ export * from "@ssgoi/core/transitions";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("../utils-DR41YsAh-CN_CfgYX.cjs"),P=(t={})=>{var e,n;const i={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((n=t.spring)==null?void 0:n.damping)??30};return{in:r=>({spring:i,tick:l=>{r.style.opacity=l.toString()}}),out:r=>({spring:i,tick:l=>{r.style.opacity=l.toString()},prepare:x.n})}};function E(t,e){return t.querySelector(`[data-hero-key="${e}"]`)}function R(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();return new DOMRect(i.left-n.left,i.top-n.top,i.width,i.height)}const B=(t={})=>{var e,n;const i={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((n=t.spring)==null?void 0:n.damping)??30},r=t.timeout??300;let l=null,s=null;return{in:async(a,g)=>{const h=a,p=Array.from(h.querySelectorAll("[data-hero-key]"));if(p.length===0)return{spring:i,tick:()=>{}};if(!await new Promise(c=>{l?c(!0):(s=c,setTimeout(()=>{s=null,c(!1)},r))})||!l)return l=null,{spring:i,tick:()=>{}};const f=p.map(c=>{const u=c.getAttribute("data-hero-key");if(!u)return null;const d=E(l,u);if(!d)return null;const o=c,y=R(l,d),m=R(h,o),w=y.left-m.left-g.scrollOffset.x,$=y.top-m.top-g.scrollOffset.y,A=y.width/m.width,S=y.height/m.height,v=o.style.transform,q=o.style.position,M=o.style.transformOrigin;return{toEl:o,dx:w,dy:$,dw:A,dh:S,originalTransform:v,originalPosition:q,originalTransformOrigin:M}}).filter(Boolean);return l=null,f.length===0?{spring:i,tick:()=>{}}:{spring:i,prepare:()=>{f.forEach(({toEl:c})=>{c.style.position="relative",c.style.transformOrigin="top left"})},tick:c=>{f.forEach(({toEl:u,dx:d,dy:o,dw:y,dh:m})=>{u.style.transform=`translate(${(1-c)*d}px,${(1-c)*o}px) scale(${c+(1-c)*y}, ${c+(1-c)*m})`})},onEnd:()=>{f.forEach(({toEl:c,originalTransform:u,originalPosition:d,originalTransformOrigin:o})=>{c.style.transform=u,c.style.position=d,c.style.transformOrigin=o})}}},out:async a=>({onStart:()=>{l=a,s&&(s(!0),s=null)},prepare:g=>{x.n(g),g.style.opacity="0"}})}};function O(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();return new DOMRect(i.left-n.left,i.top-n.top,i.width,i.height)}function T({detailRect:t,galleryRect:e,pageRect:n,scrollOffset:i},r){const l=e.left-t.left+(e.width-t.width)/2-i.x,s=e.top-t.top+(e.height-t.height)/2-i.y,a=e.width/t.width,g=e.height/t.height,h=Math.max(a,g),p=t.top/n.height*100,f=(n.width-(t.left+t.width))/n.width*100,c=(n.height-(t.top+t.height))/n.height*100,u=t.left/n.width*100;return r.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,d=>{const o=1-d,y=p*o,m=f*o,w=c*o,$=u*o;r.style.clipPath=`inset(${y}% ${m}% ${w}% ${$}%)`,r.style.transform=`translate(${l*o}px, ${s*o}px) scale(${1+(h-1)*o})`}}function C({galleryRect:t,detailRect:e,scrollOffset:n},i){const r=e.left-t.left+(e.width-t.width)/2+n.x,l=e.top-t.top+(e.height-t.height)/2+n.y,s=e.width/t.width,a=e.height/t.height,g=Math.max(s,a);return h=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const p=1-h;i.style.transform=`translate(${r*p-n.x}px, ${l*p-n.y}px) scale(${1+(g-1)*p})`,i.style.opacity=`${1-p}`}}function b({galleryRect:t,detailRect:e,scrollOffset:n},i){const r=e.left-t.left+(e.width-t.width)/2-n.x,l=e.top-t.top+(e.height-t.height)/2-n.y,s=e.width/t.width,a=e.height/t.height,g=Math.max(s,a);return h=>{const p=1-h,f=h;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${r*p}px, ${l*p}px) scale(${1+(g-1)*p})`,i.style.opacity=`${f}`}}function D({detailRect:t,galleryRect:e,pageRect:n,scrollOffset:i},r){const l=e.left-t.left+(e.width-t.width)/2+i.x,s=e.top-t.top+(e.height-t.height)/2+i.y,a=e.width/t.width,g=e.height/t.height,h=Math.min(a,g),p=t.top/n.height*100,f=(n.width-(t.left+t.width))/n.width*100,c=(n.height-(t.top+t.height))/n.height*100,u=t.left/n.width*100;return r.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,d=>{const o=1-d,y=p*o,m=f*o,w=c*o,$=u*o;r.style.clipPath=`inset(${y}% ${m}% ${w}% ${$}%)`,r.style.transform=`translate(${l*o-i.x}px, ${s*o-i.y}px) scale(${1+(h-1)*o})`}}function z(t,e,n){const i=t.querySelector("[data-pinterest-detail-key]"),r=e.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||e.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,s=null,a=!1;if(!i&&r){s=r;const f=s.getAttribute("data-pinterest-detail-key");if(!f)return null;l=t.querySelector(`[data-pinterest-gallery-key="${f}"]`),l&&(a=!0)}else if(i&&!r){s=i;const f=s.getAttribute("data-pinterest-detail-key");if(!f)return null;l=e.querySelector(`[data-pinterest-gallery-key="${f}"]`),l&&(a=!1)}if(!l||!s)return null;const g=O(a?t:e,l),h=O(a?e:t,s),p=e.getBoundingClientRect();return a?{inAnimation:T({detailRect:h,galleryRect:g,pageRect:p,scrollOffset:n},e),outAnimation:C({galleryRect:g,detailRect:h,scrollOffset:n},t)}:{inAnimation:b({galleryRect:g,detailRect:h,scrollOffset:n},e),outAnimation:D({detailRect:h,galleryRect:g,pageRect:p,scrollOffset:n},t)}}const H=(t={})=>{var e,n;const i={stiffness:((e=t.spring)==null?void 0:e.stiffness)??50,damping:((n=t.spring)==null?void 0:n.damping)??10},r=t.timeout??300;let l=null,s=null,a=null;return{in:async(g,{scrollOffset:h})=>{const p=g;return!await new Promise(f=>{l?f(!0):(s=f,setTimeout(()=>{s=null,f(!1)},r))})||!l?(l=null,{spring:i,tick:()=>{}}):(a=z(l,p,h),a?(l=null,{spring:i,tick:f=>{a&&a.inAnimation(f)}}):{spring:i,tick:()=>{}})},out:async g=>({spring:i,onStart:()=>{l=g,s&&(s(!0),s=null)},prepare:h=>{x.n(h),h.style.zIndex="-1"},tick:h=>{a&&a.outAnimation(h)}})}};function k(t){const e=t.getBoundingClientRect(),n=t.clientHeight,i=50*(window.innerHeight-e.top)/n;return Math.min(Math.max(i,0),100)}const I=(t={})=>{var e,n;const i={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((n=t.spring)==null?void 0:n.damping)??200};return{in:r=>{const l=k(r);return{spring:i,tick:s=>{r.style.clipPath=`circle(${s*100}% at 50% ${l}%)`}}},out:r=>{const l=k(r);return{spring:i,tick:s=>{r.style.clipPath=`circle(${s*100}% at 50% ${l}%)`,r.style.zIndex="100"},prepare:x.n}}}};exports.fade=P;exports.hero=B;exports.pinterest=H;exports.ripple=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/view-transitions");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
@@ -1,305 +1 @@
1
- import { n as x } from "../utils-DR41YsAh-mLT5vDuI.js";
2
- const D = (t = {}) => {
3
- var e, l;
4
- const i = {
5
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
6
- damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
7
- };
8
- return {
9
- in: (r) => ({
10
- spring: i,
11
- tick: (n) => {
12
- r.style.opacity = n.toString();
13
- }
14
- }),
15
- out: (r) => ({
16
- spring: i,
17
- tick: (n) => {
18
- r.style.opacity = n.toString();
19
- },
20
- prepare: x
21
- })
22
- };
23
- };
24
- function M(t, e) {
25
- return t.querySelector(`[data-hero-key="${e}"]`);
26
- }
27
- function R(t, e) {
28
- const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
29
- return new DOMRect(
30
- i.left - l.left,
31
- i.top - l.top,
32
- i.width,
33
- i.height
34
- );
35
- }
36
- const H = (t = {}) => {
37
- var e, l;
38
- const i = {
39
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
40
- damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
41
- }, r = t.timeout ?? 300;
42
- let n = null, s = null;
43
- return {
44
- in: async (a, g) => {
45
- const h = a, f = Array.from(h.querySelectorAll("[data-hero-key]"));
46
- if (f.length === 0)
47
- return {
48
- spring: i,
49
- tick: () => {
50
- }
51
- // No hero elements, skip animation
52
- };
53
- if (!await new Promise((c) => {
54
- n ? c(!0) : (s = c, setTimeout(() => {
55
- s = null, c(!1);
56
- }, r));
57
- }) || !n)
58
- return n = null, {
59
- spring: i,
60
- tick: () => {
61
- }
62
- // No fromNode, skip animation
63
- };
64
- const p = f.map((c) => {
65
- const u = c.getAttribute("data-hero-key");
66
- if (!u) return null;
67
- const d = M(n, u);
68
- if (!d) return null;
69
- const o = c, y = R(n, d), m = R(h, o), $ = y.left - m.left - g.scrollOffset.x, w = y.top - m.top - g.scrollOffset.y, A = y.width / m.width, v = y.height / m.height, S = o.style.transform, q = o.style.position, E = o.style.transformOrigin;
70
- return {
71
- toEl: o,
72
- dx: $,
73
- dy: w,
74
- dw: A,
75
- dh: v,
76
- originalTransform: S,
77
- originalPosition: q,
78
- originalTransformOrigin: E
79
- };
80
- }).filter(Boolean);
81
- return n = null, p.length === 0 ? {
82
- spring: i,
83
- tick: () => {
84
- }
85
- // No matching hero elements
86
- } : {
87
- spring: i,
88
- prepare: () => {
89
- p.forEach(({ toEl: c }) => {
90
- c.style.position = "relative", c.style.transformOrigin = "top left";
91
- });
92
- },
93
- tick: (c) => {
94
- p.forEach(({ toEl: u, dx: d, dy: o, dw: y, dh: m }) => {
95
- u.style.transform = `translate(${(1 - c) * d}px,${(1 - c) * o}px) scale(${c + (1 - c) * y}, ${c + (1 - c) * m})`;
96
- });
97
- },
98
- onEnd: () => {
99
- p.forEach(
100
- ({
101
- toEl: c,
102
- originalTransform: u,
103
- originalPosition: d,
104
- originalTransformOrigin: o
105
- }) => {
106
- c.style.transform = u, c.style.position = d, c.style.transformOrigin = o;
107
- }
108
- );
109
- }
110
- };
111
- },
112
- out: async (a) => ({
113
- onStart: () => {
114
- n = a, s && (s(!0), s = null);
115
- },
116
- prepare: (g) => {
117
- x(g), g.style.opacity = "0";
118
- }
119
- })
120
- };
121
- };
122
- function k(t, e) {
123
- const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
124
- return new DOMRect(
125
- i.left - l.left,
126
- i.top - l.top,
127
- i.width,
128
- i.height
129
- );
130
- }
131
- function P({
132
- detailRect: t,
133
- galleryRect: e,
134
- pageRect: l,
135
- scrollOffset: i
136
- }, r) {
137
- const n = e.left - t.left + (e.width - t.width) / 2 - i.x, s = e.top - t.top + (e.height - t.height) / 2 - i.y, a = e.width / t.width, g = e.height / t.height, h = Math.max(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
138
- return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
139
- const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
140
- r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o}px, ${s * o}px) scale(${1 + (h - 1) * o})`;
141
- };
142
- }
143
- function B({
144
- galleryRect: t,
145
- detailRect: e,
146
- scrollOffset: l
147
- }, i) {
148
- const r = e.left - t.left + (e.width - t.width) / 2 + l.x, n = e.top - t.top + (e.height - t.height) / 2 + l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
149
- return (h) => {
150
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
151
- const f = 1 - h;
152
- i.style.transform = `translate(${r * f - l.x}px, ${n * f - l.y}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${1 - f}`;
153
- };
154
- }
155
- function C({
156
- galleryRect: t,
157
- detailRect: e,
158
- scrollOffset: l
159
- }, i) {
160
- const r = e.left - t.left + (e.width - t.width) / 2 - l.x, n = e.top - t.top + (e.height - t.height) / 2 - l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
161
- return (h) => {
162
- const f = 1 - h, p = h;
163
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${r * f}px, ${n * f}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${p}`;
164
- };
165
- }
166
- function T({
167
- detailRect: t,
168
- galleryRect: e,
169
- pageRect: l,
170
- scrollOffset: i
171
- }, r) {
172
- const n = e.left - t.left + (e.width - t.width) / 2 + i.x, s = e.top - t.top + (e.height - t.height) / 2 + i.y, a = e.width / t.width, g = e.height / t.height, h = Math.min(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
173
- return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
174
- const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
175
- r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o - i.x}px, ${s * o - i.y}px) scale(${1 + (h - 1) * o})`;
176
- };
177
- }
178
- function b(t, e, l) {
179
- const i = t.querySelector(
180
- "[data-pinterest-detail-key]"
181
- ), r = e.querySelector(
182
- "[data-pinterest-detail-key]"
183
- );
184
- if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || e.querySelectorAll("[data-pinterest-detail-key]").length > 1)
185
- return null;
186
- let n = null, s = null, a = !1;
187
- if (!i && r) {
188
- s = r;
189
- const p = s.getAttribute("data-pinterest-detail-key");
190
- if (!p) return null;
191
- n = t.querySelector(
192
- `[data-pinterest-gallery-key="${p}"]`
193
- ), n && (a = !0);
194
- } else if (i && !r) {
195
- s = i;
196
- const p = s.getAttribute("data-pinterest-detail-key");
197
- if (!p) return null;
198
- n = e.querySelector(
199
- `[data-pinterest-gallery-key="${p}"]`
200
- ), n && (a = !1);
201
- }
202
- if (!n || !s)
203
- return null;
204
- const g = k(a ? t : e, n), h = k(a ? e : t, s), f = e.getBoundingClientRect();
205
- return a ? {
206
- inAnimation: P(
207
- { detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
208
- e
209
- ),
210
- outAnimation: B(
211
- { galleryRect: g, detailRect: h, scrollOffset: l },
212
- t
213
- )
214
- } : {
215
- inAnimation: C(
216
- { galleryRect: g, detailRect: h, scrollOffset: l },
217
- e
218
- ),
219
- outAnimation: T(
220
- { detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
221
- t
222
- )
223
- };
224
- }
225
- const I = (t = {}) => {
226
- var e, l;
227
- const i = {
228
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 50,
229
- damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 10
230
- }, r = t.timeout ?? 300;
231
- let n = null, s = null, a = null;
232
- return {
233
- in: async (g, { scrollOffset: h }) => {
234
- const f = g;
235
- return !await new Promise((p) => {
236
- n ? p(!0) : (s = p, setTimeout(() => {
237
- s = null, p(!1);
238
- }, r));
239
- }) || !n ? (n = null, {
240
- spring: i,
241
- tick: () => {
242
- }
243
- }) : (a = b(n, f, h), a ? (n = null, {
244
- spring: i,
245
- tick: (p) => {
246
- a && a.inAnimation(p);
247
- }
248
- }) : {
249
- spring: i,
250
- tick: () => {
251
- }
252
- });
253
- },
254
- out: async (g) => ({
255
- spring: i,
256
- onStart: () => {
257
- n = g, s && (s(!0), s = null);
258
- },
259
- prepare: (h) => {
260
- x(h), h.style.zIndex = "-1";
261
- },
262
- tick: (h) => {
263
- a && a.outAnimation(h);
264
- }
265
- })
266
- };
267
- };
268
- function O(t) {
269
- const e = t.getBoundingClientRect(), l = t.clientHeight, i = 50 * (window.innerHeight - e.top) / l;
270
- return Math.min(Math.max(i, 0), 100);
271
- }
272
- const F = (t = {}) => {
273
- var e, l;
274
- const i = {
275
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
276
- damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 200
277
- };
278
- return {
279
- in: (r) => {
280
- const n = O(r);
281
- return {
282
- spring: i,
283
- tick: (s) => {
284
- r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`;
285
- }
286
- };
287
- },
288
- out: (r) => {
289
- const n = O(r);
290
- return {
291
- spring: i,
292
- tick: (s) => {
293
- r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`, r.style.zIndex = "100";
294
- },
295
- prepare: x
296
- };
297
- }
298
- };
299
- };
300
- export {
301
- D as fade,
302
- H as hero,
303
- I as pinterest,
304
- F as ripple
305
- };
1
+ export * from "@ssgoi/core/view-transitions";
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@ssgoi/react",
3
- "version": "0.0.7",
3
+ "version": "2.0.0",
4
+ "description": "React bindings for SSGOI - Native app-like page transitions for React applications",
5
+ "private": false,
4
6
  "type": "module",
5
7
  "files": [
6
8
  "dist",
7
- "src"
9
+ "!dist/**/*.test.*",
10
+ "!dist/**/*.spec.*"
8
11
  ],
9
12
  "main": "./dist/index.cjs",
10
13
  "module": "./dist/index.js",
@@ -33,10 +36,16 @@
33
36
  "import": "./dist/types.js",
34
37
  "require": "./dist/types.cjs",
35
38
  "default": "./dist/types.js"
39
+ },
40
+ "./presets": {
41
+ "types": "./dist/presets/index.d.ts",
42
+ "import": "./dist/presets/index.js",
43
+ "require": "./dist/presets/index.cjs",
44
+ "default": "./dist/presets/index.js"
36
45
  }
37
46
  },
38
47
  "dependencies": {
39
- "@ssgoi/core": "0.0.1"
48
+ "@ssgoi/core": "2.0.0"
40
49
  },
41
50
  "peerDependencies": {
42
51
  "react": "^19.0.0",
@@ -51,14 +60,40 @@
51
60
  "eslint-plugin-react-hooks": "^5.2.0",
52
61
  "eslint-plugin-react-refresh": "^0.4.20",
53
62
  "globals": "^16.3.0",
63
+ "rollup-plugin-preserve-directives": "^0.4.0",
54
64
  "typescript": "~5.8.3",
55
65
  "typescript-eslint": "^8.35.1",
56
66
  "vite": "^7.0.4",
57
67
  "vite-plugin-dts": "^4.5.4"
58
68
  },
69
+ "keywords": [
70
+ "react",
71
+ "page-transition",
72
+ "animation",
73
+ "ssgoi",
74
+ "spring-physics"
75
+ ],
76
+ "author": "MeurSyphus <tmdeoans@snu.ac.kr>",
77
+ "license": "MIT",
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "git+https://github.com/meursyphus/ssgoi.git",
81
+ "directory": "packages/react"
82
+ },
83
+ "homepage": "https://ssgoi.dev",
84
+ "bugs": {
85
+ "url": "https://github.com/meursyphus/ssgoi/issues"
86
+ },
87
+ "publishConfig": {
88
+ "access": "public"
89
+ },
90
+ "engines": {
91
+ "node": ">=18.0.0"
92
+ },
59
93
  "scripts": {
60
94
  "dev": "vite build --watch",
61
95
  "build": "tsc -b && vite build",
96
+ "watch": "vite build --watch",
62
97
  "lint": "eslint .",
63
98
  "preview": "vite preview",
64
99
  "package": "vite build"
@@ -1 +0,0 @@
1
- "use strict";const n=e=>{e.style.position="absolute",e.style.width="100%",e.style.top="0",e.style.left="0"},r=e=>{let t=e.parentElement;for(;t&&t!==document.body;){const l=window.getComputedStyle(t),o=l.overflow+l.overflowY+l.overflowX;if(o.includes("auto")||o.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement};exports.n=n;exports.r=r;
@@ -1,16 +0,0 @@
1
- const n = (e) => {
2
- e.style.position = "absolute", e.style.width = "100%", e.style.top = "0", e.style.left = "0";
3
- }, r = (e) => {
4
- let t = e.parentElement;
5
- for (; t && t !== document.body; ) {
6
- const l = window.getComputedStyle(t), o = l.overflow + l.overflowY + l.overflowX;
7
- if (o.includes("auto") || o.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
8
- return t;
9
- t = t.parentElement;
10
- }
11
- return document.documentElement;
12
- };
13
- export {
14
- n,
15
- r
16
- };
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>