@ssgoi/react 0.0.6 → 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 l=(r={})=>{const{from:i=0,to:c=1,spring:a={stiffness:300,damping:30}}=r;return{in:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.opacity=t.toString()}}),out:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.opacity=t.toString()}})}},u=(r={})=>{const{from:i=0,to:c=1,spring:a={stiffness:300,damping:30}}=r;return{in:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.transform=`scale(${t})`}}),out:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.transform=`scale(${t})`}})}},y=(r={})=>{const{direction:i="left",distance:c=100,fade:a=!0,spring:o={stiffness:400,damping:35}}=r,s=t=>{const n=(1-t)*c;switch(i){case"left":return`translateX(${-n}px)`;case"right":return`translateX(${n}px)`;case"up":return`translateY(${-n}px)`;case"down":return`translateY(${n}px)`}};return{in:t=>({spring:o,tick:n=>{t.style.transform=s(n),a&&(t.style.opacity=n.toString())}}),out:t=>({spring:o,tick:n=>{t.style.transform=s(n),a&&(t.style.opacity=n.toString())}})}},p=(r={})=>{const{degrees:i=360,clockwise:c=!0,scale:a=!1,fade:o=!1,spring:s={stiffness:500,damping:25}}=r,t=c?i:-i;return{in:n=>({spring:s,tick:e=>{const f=[`rotate(${e*t}deg)`];a&&f.push(`scale(${e})`),n.style.transform=f.join(" "),o&&(n.style.opacity=e.toString())}}),out:n=>({spring:s,tick:e=>{const f=[`rotate(${e*t}deg)`];a&&f.push(`scale(${e})`),n.style.transform=f.join(" "),o&&(n.style.opacity=e.toString())}})}},d=(r={})=>{const{height:i=20,scale:c=!0,fade:a=!1,spring:o={stiffness:800,damping:15}}=r;return{in:s=>({spring:o,tick:t=>{const n=[],e=Math.sin(t*Math.PI)*i*(1-t);n.push(`translateY(${-e}px)`),c&&n.push(`scale(${.8+t*.2})`),s.style.transform=n.join(" "),a&&(s.style.opacity=t.toString())}}),out:s=>({spring:o,tick:t=>{const n=[],e=Math.sin(t*Math.PI)*i*(1-t);n.push(`translateY(${-e}px)`),c&&n.push(`scale(${.8+t*.2})`),s.style.transform=n.join(" "),a&&(s.style.opacity=t.toString())}})}},g=(r={})=>{const{amount:i=10,scale:c=!1,fade:a=!0,spring:o={stiffness:300,damping:30}}=r;return{in:s=>({spring:o,tick:t=>{const e=[`blur(${(1-t)*i}px)`];s.style.filter=e.join(" "),c&&(s.style.transform=`scale(${.8+t*.2})`),a&&(s.style.opacity=t.toString())}}),out:s=>({spring:o,tick:t=>{const e=[`blur(${(1-t)*i}px)`];s.style.filter=e.join(" "),c&&(s.style.transform=`scale(${.8+t*.2})`),a&&(s.style.opacity=t.toString())}})}},m=(r={})=>{const{spring:i={stiffness:1e3,damping:100}}=r;return{in:c=>({spring:i,tick:a=>{}}),out:c=>({spring:i,tick:a=>{}})}};exports.blur=g;exports.bounce=d;exports.fade=l;exports.none=m;exports.rotate=p;exports.scale=u;exports.slide=y;
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 = (r = {}) => {
2
- const {
3
- from: i = 0,
4
- to: c = 1,
5
- spring: a = { stiffness: 300, damping: 30 }
6
- } = r;
7
- return {
8
- in: (o) => ({
9
- spring: a,
10
- tick: (s) => {
11
- const t = i + (c - i) * s;
12
- o.style.opacity = t.toString();
13
- }
14
- }),
15
- out: (o) => ({
16
- spring: a,
17
- tick: (s) => {
18
- const t = i + (c - i) * s;
19
- o.style.opacity = t.toString();
20
- }
21
- })
22
- };
23
- }, u = (r = {}) => {
24
- const {
25
- from: i = 0,
26
- to: c = 1,
27
- spring: a = { stiffness: 300, damping: 30 }
28
- } = r;
29
- return {
30
- in: (o) => ({
31
- spring: a,
32
- tick: (s) => {
33
- const t = i + (c - i) * s;
34
- o.style.transform = `scale(${t})`;
35
- }
36
- }),
37
- out: (o) => ({
38
- spring: a,
39
- tick: (s) => {
40
- const t = i + (c - i) * s;
41
- o.style.transform = `scale(${t})`;
42
- }
43
- })
44
- };
45
- }, y = (r = {}) => {
46
- const {
47
- direction: i = "left",
48
- distance: c = 100,
49
- fade: a = !0,
50
- spring: o = { stiffness: 400, damping: 35 }
51
- } = r, s = (t) => {
52
- const n = (1 - t) * c;
53
- switch (i) {
54
- case "left":
55
- return `translateX(${-n}px)`;
56
- case "right":
57
- return `translateX(${n}px)`;
58
- case "up":
59
- return `translateY(${-n}px)`;
60
- case "down":
61
- return `translateY(${n}px)`;
62
- }
63
- };
64
- return {
65
- in: (t) => ({
66
- spring: o,
67
- tick: (n) => {
68
- t.style.transform = s(n), a && (t.style.opacity = n.toString());
69
- }
70
- }),
71
- out: (t) => ({
72
- spring: o,
73
- tick: (n) => {
74
- t.style.transform = s(n), a && (t.style.opacity = n.toString());
75
- }
76
- })
77
- };
78
- }, p = (r = {}) => {
79
- const {
80
- degrees: i = 360,
81
- clockwise: c = !0,
82
- scale: a = !1,
83
- fade: o = !1,
84
- spring: s = { stiffness: 500, damping: 25 }
85
- } = r, t = c ? i : -i;
86
- return {
87
- in: (n) => ({
88
- spring: s,
89
- tick: (e) => {
90
- const f = [`rotate(${e * t}deg)`];
91
- a && f.push(`scale(${e})`), n.style.transform = f.join(" "), o && (n.style.opacity = e.toString());
92
- }
93
- }),
94
- out: (n) => ({
95
- spring: s,
96
- tick: (e) => {
97
- const f = [`rotate(${e * t}deg)`];
98
- a && f.push(`scale(${e})`), n.style.transform = f.join(" "), o && (n.style.opacity = e.toString());
99
- }
100
- })
101
- };
102
- }, d = (r = {}) => {
103
- const {
104
- height: i = 20,
105
- scale: c = !0,
106
- fade: a = !1,
107
- spring: o = { stiffness: 800, damping: 15 }
108
- } = r;
109
- return {
110
- in: (s) => ({
111
- spring: o,
112
- tick: (t) => {
113
- const n = [], e = Math.sin(t * Math.PI) * i * (1 - t);
114
- n.push(`translateY(${-e}px)`), c && n.push(`scale(${0.8 + t * 0.2})`), s.style.transform = n.join(" "), a && (s.style.opacity = t.toString());
115
- }
116
- }),
117
- out: (s) => ({
118
- spring: o,
119
- tick: (t) => {
120
- const n = [], e = Math.sin(t * Math.PI) * i * (1 - t);
121
- n.push(`translateY(${-e}px)`), c && n.push(`scale(${0.8 + t * 0.2})`), s.style.transform = n.join(" "), a && (s.style.opacity = t.toString());
122
- }
123
- })
124
- };
125
- }, $ = (r = {}) => {
126
- const {
127
- amount: i = 10,
128
- scale: c = !1,
129
- fade: a = !0,
130
- spring: o = { stiffness: 300, damping: 30 }
131
- } = r;
132
- return {
133
- in: (s) => ({
134
- spring: o,
135
- tick: (t) => {
136
- const e = [`blur(${(1 - t) * i}px)`];
137
- s.style.filter = e.join(" "), c && (s.style.transform = `scale(${0.8 + t * 0.2})`), a && (s.style.opacity = t.toString());
138
- }
139
- }),
140
- out: (s) => ({
141
- spring: o,
142
- tick: (t) => {
143
- const e = [`blur(${(1 - t) * i}px)`];
144
- s.style.filter = e.join(" "), c && (s.style.transform = `scale(${0.8 + t * 0.2})`), a && (s.style.opacity = t.toString());
145
- }
146
- })
147
- };
148
- }, m = (r = {}) => {
149
- const {
150
- spring: i = { stiffness: 1e3, damping: 100 }
151
- } = r;
152
- return {
153
- in: (c) => ({
154
- spring: i,
155
- tick: (a) => {
156
- }
157
- }),
158
- out: (c) => ({
159
- spring: i,
160
- tick: (a) => {
161
- }
162
- })
163
- };
164
- };
165
- export {
166
- $ as blur,
167
- d as bounce,
168
- l as fade,
169
- m as none,
170
- p as rotate,
171
- u as scale,
172
- y as slide
173
- };
1
+ export * from "@ssgoi/core/transitions";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),P=(t={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??30};return{in:e=>({spring:n,tick:i=>{e.style.opacity=i.toString()}}),out:e=>({spring:n,tick:i=>{e.style.opacity=i.toString()},prepare:k.prepareOutgoing})}};function b(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function A(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}const C=(t={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??30},e=t.timeout??300;let i=null,s=null;return{in:async(a,h)=>{const o=a,c=Array.from(o.querySelectorAll("[data-hero-key]"));if(c.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(l=>{i?l(!0):(s=l,setTimeout(()=>{s=null,l(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const r=c.map(l=>{const y=l.getAttribute("data-hero-key");if(!y)return null;const d=b(i,y);if(!d)return null;const p=l,u=A(i,d),f=A(o,p),$=u.left-f.left-h.scrollOffset.x,w=u.top-f.top-h.scrollOffset.y,x=u.width/f.width,M=u.height/f.height,q=p.style.transform,O=p.style.position,T=p.style.transformOrigin;return{toEl:p,dx:$,dy:w,dw:x,dh:M,originalTransform:q,originalPosition:O,originalTransformOrigin:T}}).filter(Boolean);return i=null,r.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{r.forEach(({toEl:l})=>{l.style.position="relative",l.style.transformOrigin="top left"})},tick:l=>{r.forEach(({toEl:y,dx:d,dy:p,dw:u,dh:f})=>{y.style.transform=`translate(${(1-l)*d}px,${(1-l)*p}px) scale(${l+(1-l)*u}, ${l+(1-l)*f})`})},onEnd:()=>{r.forEach(({toEl:l,originalTransform:y,originalPosition:d,originalTransformOrigin:p})=>{l.style.transform=y,l.style.position=d,l.style.transformOrigin=p})}}},out:async a=>({onStart:()=>{i=a,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.style.opacity="0"}})}};function S(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}function E({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const a=n.left-t.left+(n.width-t.width)/2-i.x,h=n.top-t.top+(n.height-t.height)/2-i.y,o=n.width/t.width,c=n.height/t.height,g=Math.max(o,c),r=t.top/e.height*100,l=(e.width-(t.left+t.width))/e.width*100,y=(e.height-(t.top+t.height))/e.height*100,d=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,p=>{const u=1-p,f=r*u,$=l*u,w=y*u,x=d*u;s.style.clipPath=`inset(${f}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${a*u}px, ${h*u}px) scale(${1+(g-1)*u})`}}function D({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,a=n.top-t.top+(n.height-t.height)/2+e.y,h=n.width/t.width,o=n.height/t.height,c=Math.max(h,o);return g=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const r=1-g;i.style.transform=`translate(${s*r-e.x}px, ${a*r-e.y}px) scale(${1+(c-1)*r})`,i.style.opacity=`${1-r}`}}function H({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,a=n.top-t.top+(n.height-t.height)/2-e.y,h=n.width/t.width,o=n.height/t.height,c=Math.max(h,o);return g=>{const r=1-g,l=g;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*r}px, ${a*r}px) scale(${1+(c-1)*r})`,i.style.opacity=`${l}`}}function F({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const a=n.left-t.left+(n.width-t.width)/2+i.x,h=n.top-t.top+(n.height-t.height)/2+i.y,o=n.width/t.width,c=n.height/t.height,g=Math.min(o,c),r=t.top/e.height*100,l=(e.width-(t.left+t.width))/e.width*100,y=(e.height-(t.top+t.height))/e.height*100,d=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,p=>{const u=1-p,f=r*u,$=l*u,w=y*u,x=d*u;s.style.clipPath=`inset(${f}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${a*u-i.x}px, ${h*u-i.y}px) scale(${1+(g-1)*u})`}}function I(t,n,e){const i=t.querySelector("[data-pinterest-detail-key]"),s=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let a=null,h=null,o=!1;if(!i&&s){h=s;const l=h.getAttribute("data-pinterest-detail-key");if(!l)return null;a=t.querySelector(`[data-pinterest-gallery-key="${l}"]`),a&&(o=!0)}else if(i&&!s){h=i;const l=h.getAttribute("data-pinterest-detail-key");if(!l)return null;a=n.querySelector(`[data-pinterest-gallery-key="${l}"]`),a&&(o=!1)}if(!a||!h)return null;const c=S(o?t:n,a),g=S(o?n:t,h),r=n.getBoundingClientRect();return o?{inAnimation:E({detailRect:g,galleryRect:c,pageRect:r,scrollOffset:e},n),outAnimation:D({galleryRect:c,detailRect:g,scrollOffset:e},t)}:{inAnimation:H({galleryRect:c,detailRect:g,scrollOffset:e},n),outAnimation:F({detailRect:g,galleryRect:c,pageRect:r,scrollOffset:e},t)}}const L=(t={})=>{const n={stiffness:t.spring?.stiffness??50,damping:t.spring?.damping??10},e=t.timeout??300;let i=null,s=null,a=null;return{in:async(h,{scrollOffset:o})=>{const c=h;return!await new Promise(r=>{i?r(!0):(s=r,setTimeout(()=>{s=null,r(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(a=I(i,c,o),a?(i=null,{spring:n,tick:r=>{a&&a.inAnimation(r)}}):{spring:n,tick:()=>{}})},out:async h=>({spring:n,onStart:()=>{i=h,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.zIndex="-1"},tick:o=>{a&&a.outAnimation(o)}})}};function B(t){const n=t.getBoundingClientRect(),e=t.clientHeight,s=50*(window.innerHeight-n.top)/e;return Math.min(Math.max(s,0),100)}const X=(t={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??200};return{in:e=>{const i=B(e);return{spring:n,tick:s=>{e.style.clipPath=`circle(${s*100}% at 50% ${i}%)`}}},out:e=>{const i=B(e);return{spring:n,tick:s=>{e.style.clipPath=`circle(${s*100}% at 50% ${i}%)`,e.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=P;exports.hero=C;exports.pinterest=L;exports.ripple=X;
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,301 +1 @@
1
- import { p as k } from "../utils-DR41YsAh.js";
2
- const I = (t = {}) => {
3
- const n = {
4
- stiffness: t.spring?.stiffness ?? 300,
5
- damping: t.spring?.damping ?? 30
6
- };
7
- return {
8
- in: (e) => ({
9
- spring: n,
10
- tick: (i) => {
11
- e.style.opacity = i.toString();
12
- }
13
- }),
14
- out: (e) => ({
15
- spring: n,
16
- tick: (i) => {
17
- e.style.opacity = i.toString();
18
- },
19
- prepare: k
20
- })
21
- };
22
- };
23
- function E(t, n) {
24
- return t.querySelector(`[data-hero-key="${n}"]`);
25
- }
26
- function A(t, n) {
27
- const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
28
- return new DOMRect(
29
- i.left - e.left,
30
- i.top - e.top,
31
- i.width,
32
- i.height
33
- );
34
- }
35
- const L = (t = {}) => {
36
- const n = {
37
- stiffness: t.spring?.stiffness ?? 300,
38
- damping: t.spring?.damping ?? 30
39
- }, e = t.timeout ?? 300;
40
- let i = null, s = null;
41
- return {
42
- in: async (a, h) => {
43
- const o = a, c = Array.from(o.querySelectorAll("[data-hero-key]"));
44
- if (c.length === 0)
45
- return {
46
- spring: n,
47
- tick: () => {
48
- }
49
- // No hero elements, skip animation
50
- };
51
- if (!await new Promise((l) => {
52
- i ? l(!0) : (s = l, setTimeout(() => {
53
- s = null, l(!1);
54
- }, e));
55
- }) || !i)
56
- return i = null, {
57
- spring: n,
58
- tick: () => {
59
- }
60
- // No fromNode, skip animation
61
- };
62
- const r = c.map((l) => {
63
- const y = l.getAttribute("data-hero-key");
64
- if (!y) return null;
65
- const d = E(i, y);
66
- if (!d) return null;
67
- const p = l, u = A(i, d), f = A(o, p), $ = u.left - f.left - h.scrollOffset.x, w = u.top - f.top - h.scrollOffset.y, x = u.width / f.width, M = u.height / f.height, q = p.style.transform, T = p.style.position, C = p.style.transformOrigin;
68
- return {
69
- toEl: p,
70
- dx: $,
71
- dy: w,
72
- dw: x,
73
- dh: M,
74
- originalTransform: q,
75
- originalPosition: T,
76
- originalTransformOrigin: C
77
- };
78
- }).filter(Boolean);
79
- return i = null, r.length === 0 ? {
80
- spring: n,
81
- tick: () => {
82
- }
83
- // No matching hero elements
84
- } : {
85
- spring: n,
86
- prepare: () => {
87
- r.forEach(({ toEl: l }) => {
88
- l.style.position = "relative", l.style.transformOrigin = "top left";
89
- });
90
- },
91
- tick: (l) => {
92
- r.forEach(({ toEl: y, dx: d, dy: p, dw: u, dh: f }) => {
93
- y.style.transform = `translate(${(1 - l) * d}px,${(1 - l) * p}px) scale(${l + (1 - l) * u}, ${l + (1 - l) * f})`;
94
- });
95
- },
96
- onEnd: () => {
97
- r.forEach(
98
- ({
99
- toEl: l,
100
- originalTransform: y,
101
- originalPosition: d,
102
- originalTransformOrigin: p
103
- }) => {
104
- l.style.transform = y, l.style.position = d, l.style.transformOrigin = p;
105
- }
106
- );
107
- }
108
- };
109
- },
110
- out: async (a) => ({
111
- onStart: () => {
112
- i = a, s && (s(!0), s = null);
113
- },
114
- prepare: (h) => {
115
- k(h), h.style.opacity = "0";
116
- }
117
- })
118
- };
119
- };
120
- function S(t, n) {
121
- const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
122
- return new DOMRect(
123
- i.left - e.left,
124
- i.top - e.top,
125
- i.width,
126
- i.height
127
- );
128
- }
129
- function P({
130
- detailRect: t,
131
- galleryRect: n,
132
- pageRect: e,
133
- scrollOffset: i
134
- }, s) {
135
- const a = n.left - t.left + (n.width - t.width) / 2 - i.x, h = n.top - t.top + (n.height - t.height) / 2 - i.y, o = n.width / t.width, c = n.height / t.height, g = Math.max(o, c), r = t.top / e.height * 100, l = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, d = t.left / e.width * 100;
136
- return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (p) => {
137
- const u = 1 - p, f = r * u, $ = l * u, w = y * u, x = d * u;
138
- s.style.clipPath = `inset(${f}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${a * u}px, ${h * u}px) scale(${1 + (g - 1) * u})`;
139
- };
140
- }
141
- function D({
142
- galleryRect: t,
143
- detailRect: n,
144
- scrollOffset: e
145
- }, i) {
146
- const s = n.left - t.left + (n.width - t.width) / 2 + e.x, a = n.top - t.top + (n.height - t.height) / 2 + e.y, h = n.width / t.width, o = n.height / t.height, c = Math.max(h, o);
147
- return (g) => {
148
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
149
- const r = 1 - g;
150
- i.style.transform = `translate(${s * r - e.x}px, ${a * r - e.y}px) scale(${1 + (c - 1) * r})`, i.style.opacity = `${1 - r}`;
151
- };
152
- }
153
- function H({
154
- galleryRect: t,
155
- detailRect: n,
156
- scrollOffset: e
157
- }, i) {
158
- const s = n.left - t.left + (n.width - t.width) / 2 - e.x, a = n.top - t.top + (n.height - t.height) / 2 - e.y, h = n.width / t.width, o = n.height / t.height, c = Math.max(h, o);
159
- return (g) => {
160
- const r = 1 - g, l = g;
161
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${s * r}px, ${a * r}px) scale(${1 + (c - 1) * r})`, i.style.opacity = `${l}`;
162
- };
163
- }
164
- function b({
165
- detailRect: t,
166
- galleryRect: n,
167
- pageRect: e,
168
- scrollOffset: i
169
- }, s) {
170
- const a = n.left - t.left + (n.width - t.width) / 2 + i.x, h = n.top - t.top + (n.height - t.height) / 2 + i.y, o = n.width / t.width, c = n.height / t.height, g = Math.min(o, c), r = t.top / e.height * 100, l = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, d = t.left / e.width * 100;
171
- return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (p) => {
172
- const u = 1 - p, f = r * u, $ = l * u, w = y * u, x = d * u;
173
- s.style.clipPath = `inset(${f}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${a * u - i.x}px, ${h * u - i.y}px) scale(${1 + (g - 1) * u})`;
174
- };
175
- }
176
- function O(t, n, e) {
177
- const i = t.querySelector(
178
- "[data-pinterest-detail-key]"
179
- ), s = n.querySelector(
180
- "[data-pinterest-detail-key]"
181
- );
182
- if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || n.querySelectorAll("[data-pinterest-detail-key]").length > 1)
183
- return null;
184
- let a = null, h = null, o = !1;
185
- if (!i && s) {
186
- h = s;
187
- const l = h.getAttribute("data-pinterest-detail-key");
188
- if (!l) return null;
189
- a = t.querySelector(
190
- `[data-pinterest-gallery-key="${l}"]`
191
- ), a && (o = !0);
192
- } else if (i && !s) {
193
- h = i;
194
- const l = h.getAttribute("data-pinterest-detail-key");
195
- if (!l) return null;
196
- a = n.querySelector(
197
- `[data-pinterest-gallery-key="${l}"]`
198
- ), a && (o = !1);
199
- }
200
- if (!a || !h)
201
- return null;
202
- const c = S(o ? t : n, a), g = S(o ? n : t, h), r = n.getBoundingClientRect();
203
- return o ? {
204
- inAnimation: P(
205
- { detailRect: g, galleryRect: c, pageRect: r, scrollOffset: e },
206
- n
207
- ),
208
- outAnimation: D(
209
- { galleryRect: c, detailRect: g, scrollOffset: e },
210
- t
211
- )
212
- } : {
213
- inAnimation: H(
214
- { galleryRect: c, detailRect: g, scrollOffset: e },
215
- n
216
- ),
217
- outAnimation: b(
218
- { detailRect: g, galleryRect: c, pageRect: r, scrollOffset: e },
219
- t
220
- )
221
- };
222
- }
223
- const X = (t = {}) => {
224
- const n = {
225
- stiffness: t.spring?.stiffness ?? 50,
226
- damping: t.spring?.damping ?? 10
227
- }, e = t.timeout ?? 300;
228
- let i = null, s = null, a = null;
229
- return {
230
- in: async (h, { scrollOffset: o }) => {
231
- const c = h;
232
- return !await new Promise((r) => {
233
- i ? r(!0) : (s = r, setTimeout(() => {
234
- s = null, r(!1);
235
- }, e));
236
- }) || !i ? (i = null, {
237
- spring: n,
238
- tick: () => {
239
- }
240
- }) : (a = O(i, c, o), a ? (i = null, {
241
- spring: n,
242
- tick: (r) => {
243
- a && a.inAnimation(r);
244
- }
245
- }) : {
246
- spring: n,
247
- tick: () => {
248
- }
249
- });
250
- },
251
- out: async (h) => ({
252
- spring: n,
253
- onStart: () => {
254
- i = h, s && (s(!0), s = null);
255
- },
256
- prepare: (o) => {
257
- k(o), o.style.zIndex = "-1";
258
- },
259
- tick: (o) => {
260
- a && a.outAnimation(o);
261
- }
262
- })
263
- };
264
- };
265
- function B(t) {
266
- const n = t.getBoundingClientRect(), e = t.clientHeight, s = 50 * (window.innerHeight - n.top) / e;
267
- return Math.min(Math.max(s, 0), 100);
268
- }
269
- const Y = (t = {}) => {
270
- const n = {
271
- stiffness: t.spring?.stiffness ?? 300,
272
- damping: t.spring?.damping ?? 200
273
- };
274
- return {
275
- in: (e) => {
276
- const i = B(e);
277
- return {
278
- spring: n,
279
- tick: (s) => {
280
- e.style.clipPath = `circle(${s * 100}% at 50% ${i}%)`;
281
- }
282
- };
283
- },
284
- out: (e) => {
285
- const i = B(e);
286
- return {
287
- spring: n,
288
- tick: (s) => {
289
- e.style.clipPath = `circle(${s * 100}% at 50% ${i}%)`, e.style.zIndex = "100";
290
- },
291
- prepare: k
292
- };
293
- }
294
- };
295
- };
296
- export {
297
- I as fade,
298
- L as hero,
299
- X as pinterest,
300
- Y as ripple
301
- };
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.6",
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.getScrollingElement=r;exports.prepareOutgoing=n;
@@ -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 o = window.getComputedStyle(t), l = o.overflow + o.overflowY + o.overflowX;
7
- if (l.includes("auto") || l.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
- r as g,
15
- n as p
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>
@@ -1,14 +0,0 @@
1
- import { createContext, useContext } from "react";
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
- };