@ssgoi/vue 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.
package/README.md CHANGED
@@ -115,8 +115,8 @@ Animate specific elements during mount/unmount:
115
115
  <template>
116
116
  <div v-transition="{
117
117
  key: 'card',
118
- in: fadeIn(),
119
- out: slideUp()
118
+ in: fade(),
119
+ out: slide({ direction: 'up' })
120
120
  }">
121
121
  <h2>Animated Card</h2>
122
122
  </div>
@@ -124,7 +124,7 @@ Animate specific elements during mount/unmount:
124
124
 
125
125
  <script setup>
126
126
  import { vTransition as vTransitionDirective } from '@ssgoi/vue';
127
- import { fadeIn, slideUp } from '@ssgoi/vue/transitions';
127
+ import { fade, slide } from '@ssgoi/vue/transitions';
128
128
 
129
129
  // Local directive registration
130
130
  const vTransition = vTransitionDirective;
@@ -157,7 +157,7 @@ app.mount('#app');
157
157
  <script setup>
158
158
  import { ref, onMounted, onUnmounted } from 'vue';
159
159
  import { transition } from '@ssgoi/vue';
160
- import { fadeIn, slideUp } from '@ssgoi/vue/transitions';
160
+ import { fade, slide } from '@ssgoi/vue/transitions';
161
161
 
162
162
  const cardRef = ref();
163
163
  let cleanup;
@@ -165,8 +165,8 @@ let cleanup;
165
165
  onMounted(() => {
166
166
  cleanup = transition({
167
167
  key: 'card',
168
- in: fadeIn(),
169
- out: slideUp()
168
+ in: fade(),
169
+ out: slide({ direction: 'up' })
170
170
  })(cardRef.value);
171
171
  });
172
172
 
@@ -256,8 +256,8 @@ Apply transitions to individual elements.
256
256
  ```vue
257
257
  <div v-transition="{
258
258
  key: 'unique-key',
259
- in: fadeIn(),
260
- out: fadeOut()
259
+ in: fade(),
260
+ out: fade()
261
261
  }">
262
262
  Content
263
263
  </div>
@@ -271,8 +271,8 @@ Apply transitions programmatically.
271
271
  ```javascript
272
272
  const cleanup = transition({
273
273
  key: 'unique-key',
274
- in: fadeIn(),
275
- out: fadeOut()
274
+ in: fade(),
275
+ out: fade()
276
276
  })(element);
277
277
  ```
278
278
 
@@ -286,12 +286,12 @@ const cleanup = transition({
286
286
  - `pinterest()` - Pinterest-style expand effect
287
287
 
288
288
  ### Element Transitions (`@ssgoi/vue/transitions`)
289
- - `fadeIn()` / `fadeOut()`
290
- - `slideUp()` / `slideDown()` / `slideLeft()` / `slideRight()`
291
- - `scaleIn()` / `scaleOut()`
292
- - `bounce()`
293
- - `blur()`
294
- - `rotate()`
289
+ - `fade()` - Fade in/out effect
290
+ - `slide({ direction })` - Slide animation with direction: 'up', 'down', 'left', 'right'
291
+ - `scale()` - Scale in/out effect
292
+ - `bounce()` - Bounce animation
293
+ - `blur()` - Blur effect
294
+ - `rotate()` - Rotation animation
295
295
 
296
296
  ## Spring Physics Configuration
297
297
 
@@ -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 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;
@@ -1,73 +1,77 @@
1
- function f(n) {
1
+ function k(n) {
2
2
  return ("tick" in n || "css" in n) && !("springs" in n);
3
3
  }
4
- function e(n) {
4
+ function f(n) {
5
5
  return "springs" in n;
6
6
  }
7
- function o(n) {
7
+ function p(n) {
8
8
  return "css" in n && typeof n.css == "function";
9
9
  }
10
- function c(n) {
10
+ function u(n) {
11
11
  return "tick" in n && typeof n.tick == "function";
12
12
  }
13
- function l(n) {
14
- if (o(n) && c(n))
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 p(n) {
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 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 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: n.spring,
34
- tick: n.tick,
35
- css: n.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 h(n) {
42
- const r = n.schedule ?? "parallel", s = n.springs.map((t) => {
43
- let i;
44
- switch (r) {
45
- case "parallel":
46
- i = 0;
47
- break;
48
- case "sequential":
49
- i = 1;
50
- break;
51
- case "stagger":
52
- i = Math.max(0, Math.min(1, t.offset ?? 0));
53
- break;
54
- default:
55
- i = 0;
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
- return { ...t, normalizedOffset: i };
58
- }), { schedule: u, ...a } = n;
62
+ ), { schedule: h, ...o } = n;
59
63
  return {
60
- ...a,
61
- springs: s
64
+ ...o,
65
+ springs: a
62
66
  };
63
67
  }
64
68
  export {
65
- o as isCssAnimation,
66
- e as isMultiSpring,
67
- f as isSingleSpring,
68
- c as isTickAnimation,
69
- h as normalizeMultiSpringSchedule,
70
- g as normalizeToMultiSpring,
71
- l as validateAnimationMode,
72
- p as validateSpringItem
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("./vue/src/lib/transition.cjs"),i=require("./core/dist/types.cjs"),t=require("./vue/src/lib/ssgoi.vue.cjs"),e=require("./vue/src/lib/ssgoi-transition.vue.cjs");exports.transition=n.transition;exports.vTransition=n.vTransition;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.default;exports.SsgoiTransition=e.default;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./vue/src/lib/transition.cjs"),i=require("./core/dist/types.cjs"),e=require("./vue/src/lib/ssgoi.vue.cjs"),n=require("./vue/src/lib/ssgoi-transition.vue.cjs"),r=require("./vue/src/lib/transition-scope.vue.cjs");exports.transition=t.transition;exports.vTransition=t.vTransition;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.default;exports.SsgoiTransition=n.default;exports.TransitionScope=r.default;
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { transition, vTransition } from './transition';
2
2
  export * from './types';
3
3
  export { default as Ssgoi } from './ssgoi.vue';
4
4
  export { default as SsgoiTransition } from './ssgoi-transition.vue';
5
+ export { default as TransitionScope } from './transition-scope.vue';
package/dist/index.js CHANGED
@@ -1,18 +1,20 @@
1
- import { transition as o, vTransition as t } from "./vue/src/lib/transition.js";
2
- import { isCssAnimation as a, isMultiSpring as e, isSingleSpring as s, isTickAnimation as l, normalizeMultiSpringSchedule as m, normalizeToMultiSpring as p, validateAnimationMode as S, validateSpringItem as g } from "./core/dist/types.js";
3
- import { default as f } from "./vue/src/lib/ssgoi.vue.js";
1
+ import { transition as n, vTransition as t } from "./vue/src/lib/transition.js";
2
+ import { isCssAnimation as a, isMultiSpring as e, isSingleSpring as s, isTickAnimation as l, normalizeMultiSpringSchedule as m, normalizeToMultiSpring as p, validateAnimationMode as S, validateSpringItem as f } from "./core/dist/types.js";
3
+ import { default as d } from "./vue/src/lib/ssgoi.vue.js";
4
4
  import { default as x } from "./vue/src/lib/ssgoi-transition.vue.js";
5
+ import { default as M } from "./vue/src/lib/transition-scope.vue.js";
5
6
  export {
6
- f as Ssgoi,
7
+ d as Ssgoi,
7
8
  x as SsgoiTransition,
9
+ M as TransitionScope,
8
10
  a as isCssAnimation,
9
11
  e as isMultiSpring,
10
12
  s as isSingleSpring,
11
13
  l as isTickAnimation,
12
14
  m as normalizeMultiSpringSchedule,
13
15
  p as normalizeToMultiSpring,
14
- o as transition,
16
+ n as transition,
15
17
  t as vTransition,
16
18
  S as validateAnimationMode,
17
- g as validateSpringItem
19
+ f as validateSpringItem
18
20
  };
@@ -0,0 +1,21 @@
1
+ declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
3
+ slots: {
4
+ default?(_: {}): any;
5
+ };
6
+ refs: {
7
+ scopeRef: HTMLDivElement;
8
+ };
9
+ rootEl: HTMLDivElement;
10
+ };
11
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
12
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
13
+ scopeRef: HTMLDivElement;
14
+ }, HTMLDivElement>;
15
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
+ export default _default;
17
+ type __VLS_WithTemplateSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -1,6 +1,9 @@
1
- import { transition as _transition, Transition, TransitionKey } from '@ssgoi/core';
1
+ import { transition as _transition, Transition, TransitionKey, TransitionScope } from '@ssgoi/core';
2
2
  import { Directive } from 'vue';
3
3
  export declare const transition: typeof _transition;
4
- export declare const vTransition: Directive<HTMLElement, (Transition & {
5
- key?: TransitionKey;
6
- }) | undefined>;
4
+ type TransitionConfig = Transition & {
5
+ key: TransitionKey;
6
+ scope?: TransitionScope;
7
+ };
8
+ export declare const vTransition: Directive<HTMLElement, TransitionConfig | undefined>;
9
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("./context.cjs"),s=require("@ssgoi/core"),u=e.defineComponent({__name:"ssgoi",props:{config:{}},setup(t){const o=t,n=e.computed(()=>s.createSggoiTransitionContext(o.config));return e.watchEffect(()=>{c.provideSsgoi(n.value)}),(r,i)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(r.$slots,"default")]))}});exports.default=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("./context.cjs"),s=require("@ssgoi/core"),u=e.defineComponent({__name:"ssgoi",props:{config:{}},setup(t){const o=t,n=e.computed(()=>s.createSggoiTransitionContext(o.config,{outFirst:!1}));return e.watchEffect(()=>{c.provideSsgoi(n.value)}),(r,i)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(r.$slots,"default")]))}});exports.default=u;
@@ -1,4 +1,4 @@
1
- import { defineComponent as r, computed as c, watchEffect as i, createElementBlock as s, openBlock as p, renderSlot as a } from "vue";
1
+ import { defineComponent as r, computed as c, watchEffect as s, createElementBlock as i, openBlock as a, renderSlot as p } from "vue";
2
2
  import { provideSsgoi as f } from "./context.js";
3
3
  import { createSggoiTransitionContext as l } from "@ssgoi/core";
4
4
  const _ = /* @__PURE__ */ r({
@@ -7,11 +7,17 @@ const _ = /* @__PURE__ */ r({
7
7
  config: {}
8
8
  },
9
9
  setup(o) {
10
- const e = o, t = c(() => l(e.config));
11
- return i(() => {
10
+ const e = o, t = c(
11
+ () => l(e.config, {
12
+ // Vue directive uses unmounted hook for cleanup,
13
+ // so OUT and IN can arrive in any order
14
+ outFirst: !1
15
+ })
16
+ );
17
+ return s(() => {
12
18
  f(t.value);
13
- }), (n, m) => (p(), s("div", null, [
14
- a(n.$slots, "default")
19
+ }), (n, m) => (a(), i("div", null, [
20
+ p(n.$slots, "default")
15
21
  ]));
16
22
  }
17
23
  });
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@ssgoi/core"),s=e.defineComponent({__name:"transition-scope",setup(c){const t=e.ref(null);let n;return e.onMounted(()=>{t.value&&(n=r.createTransitionScope()(t.value))}),e.onUnmounted(()=>{n?.()}),(o,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"scopeRef",ref:t,style:{display:"contents"}},[e.renderSlot(o.$slots,"default")],512))}});exports.default=s;
@@ -0,0 +1,23 @@
1
+ import { defineComponent as t, ref as r, onMounted as s, onUnmounted as c, createElementBlock as l, openBlock as a, renderSlot as p } from "vue";
2
+ import { createTransitionScope as f } from "@ssgoi/core";
3
+ const _ = /* @__PURE__ */ t({
4
+ __name: "transition-scope",
5
+ setup(i) {
6
+ const e = r(null);
7
+ let o;
8
+ return s(() => {
9
+ e.value && (o = f()(e.value));
10
+ }), c(() => {
11
+ o?.();
12
+ }), (n, u) => (a(), l("div", {
13
+ ref_key: "scopeRef",
14
+ ref: e,
15
+ style: { display: "contents" }
16
+ }, [
17
+ p(n.$slots, "default")
18
+ ], 512));
19
+ }
20
+ });
21
+ export {
22
+ _ as default
23
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./transition-scope.vue.cjs");exports.default=e.default;
@@ -0,0 +1,4 @@
1
+ import f from "./transition-scope.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@ssgoi/core"),e=s.transition,r={mounted(n,t){if(!t.value){console.warn("[SSGOI] v-transition directive requires a configuration object");return}const o=t.value;setTimeout(()=>{const i=e({key:o.key,in:o.in,out:o.out,ref:n})(n);n._ssgoiCleanup=i},0)},unmounted(n){const t=n._ssgoiCleanup;t&&(t(),delete n._ssgoiCleanup)}};exports.transition=e;exports.vTransition=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@ssgoi/core"),o=s.transition,r={mounted(n,t){if(!t.value){console.warn("[SSGOI] v-transition directive requires a configuration object");return}const e=t.value,i=o(e)(n);n._ssgoiCleanup=i},unmounted(n){const t=n._ssgoiCleanup;t&&(t(),delete n._ssgoiCleanup)}};exports.transition=o;exports.vTransition=r;
@@ -1,29 +1,21 @@
1
- import { transition as e } from "@ssgoi/core";
2
- const s = e, r = {
3
- mounted(n, t) {
4
- if (!t.value) {
1
+ import { transition as s } from "@ssgoi/core";
2
+ const e = s, r = {
3
+ mounted(n, o) {
4
+ if (!o.value) {
5
5
  console.warn(
6
6
  "[SSGOI] v-transition directive requires a configuration object"
7
7
  );
8
8
  return;
9
9
  }
10
- const o = t.value;
11
- setTimeout(() => {
12
- const i = s({
13
- key: o.key,
14
- in: o.in,
15
- out: o.out,
16
- ref: n
17
- })(n);
18
- n._ssgoiCleanup = i;
19
- }, 0);
10
+ const t = o.value, i = e(t)(n);
11
+ n._ssgoiCleanup = i;
20
12
  },
21
13
  unmounted(n) {
22
- const t = n._ssgoiCleanup;
23
- t && (t(), delete n._ssgoiCleanup);
14
+ const o = n._ssgoiCleanup;
15
+ o && (o(), delete n._ssgoiCleanup);
24
16
  }
25
17
  };
26
18
  export {
27
- s as transition,
19
+ e as transition,
28
20
  r as vTransition
29
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/vue",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Vue bindings for SSGOI - Native app-like page transitions for Vue 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.4.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "vue": "^3.5.0"