@ssgoi/angular 2.5.2
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 +178 -0
- package/fesm2022/ssgoi-angular-presets.mjs +6 -0
- package/fesm2022/ssgoi-angular-presets.mjs.map +1 -0
- package/fesm2022/ssgoi-angular-transitions.mjs +6 -0
- package/fesm2022/ssgoi-angular-transitions.mjs.map +1 -0
- package/fesm2022/ssgoi-angular-view-transitions.mjs +6 -0
- package/fesm2022/ssgoi-angular-view-transitions.mjs.map +1 -0
- package/fesm2022/ssgoi-angular.mjs +139 -0
- package/fesm2022/ssgoi-angular.mjs.map +1 -0
- package/index.d.ts +44 -0
- package/package.json +65 -0
- package/presets/index.d.ts +1 -0
- package/transitions/index.d.ts +1 -0
- package/view-transitions/index.d.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @ssgoi/angular
|
|
2
|
+
|
|
3
|
+
Angular bindings for SSGOI that give any Angular 20+ app native-feeling page and element transitions powered by the `@ssgoi/core` animation engine.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ssgoi/angular
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @ssgoi/angular
|
|
11
|
+
# or
|
|
12
|
+
yarn add @ssgoi/angular
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What You Get
|
|
16
|
+
|
|
17
|
+
- `Ssgoi` directive (selector: `[ssgoi]`) that bootstraps the core transition context on the client and gracefully no-ops during SSR.
|
|
18
|
+
- `SsgoiTransition` directive (selector: `[ssgoiTransition]`) that wires individual route containers into the transition system.
|
|
19
|
+
- `TransitionDirective` (selector: `[transition]`) for running element-level in/out animations with spring physics.
|
|
20
|
+
- `injectSsgoi()` helper and `SSGOI_CONTEXT` injection token for retrieving transition definitions anywhere in your component tree.
|
|
21
|
+
- Re-exported transition factories and presets under `@ssgoi/angular/view-transitions`, `@ssgoi/angular/transitions`, and `@ssgoi/angular/presets`.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Provide the transition context once
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Component, signal } from "@angular/core";
|
|
29
|
+
import { RouterOutlet } from "@angular/router";
|
|
30
|
+
import { Ssgoi, SsgoiConfig } from "@ssgoi/angular";
|
|
31
|
+
import { fade } from "@ssgoi/angular/view-transitions";
|
|
32
|
+
|
|
33
|
+
@Component({
|
|
34
|
+
selector: "app-root",
|
|
35
|
+
standalone: true,
|
|
36
|
+
imports: [RouterOutlet, Ssgoi],
|
|
37
|
+
template: `
|
|
38
|
+
<div
|
|
39
|
+
ssgoi
|
|
40
|
+
[config]="ssgoiConfig()"
|
|
41
|
+
style="position: relative; min-height: 100vh"
|
|
42
|
+
>
|
|
43
|
+
<router-outlet />
|
|
44
|
+
</div>
|
|
45
|
+
`,
|
|
46
|
+
})
|
|
47
|
+
export class AppComponent {
|
|
48
|
+
protected readonly ssgoiConfig = signal<SsgoiConfig>({
|
|
49
|
+
defaultTransition: fade(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Mark each routed view with `SsgoiTransition`
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { Component } from "@angular/core";
|
|
58
|
+
import { SsgoiTransition } from "@ssgoi/angular";
|
|
59
|
+
|
|
60
|
+
@Component({
|
|
61
|
+
selector: "app-home",
|
|
62
|
+
standalone: true,
|
|
63
|
+
imports: [SsgoiTransition],
|
|
64
|
+
template: `
|
|
65
|
+
<section [ssgoiTransition]="'/home'">
|
|
66
|
+
<h1>Home Page</h1>
|
|
67
|
+
</section>
|
|
68
|
+
`,
|
|
69
|
+
})
|
|
70
|
+
export class HomeComponent {}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The value you pass to `[ssgoiTransition]` should uniquely identify the view (commonly the route path).
|
|
74
|
+
|
|
75
|
+
### 3. (Optional) Add element-level transitions
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { Component } from "@angular/core";
|
|
79
|
+
import { TransitionDirective } from "@ssgoi/angular";
|
|
80
|
+
import { fadeIn, fadeOut } from "@ssgoi/angular/transitions";
|
|
81
|
+
|
|
82
|
+
@Component({
|
|
83
|
+
selector: "app-call-to-action",
|
|
84
|
+
standalone: true,
|
|
85
|
+
imports: [TransitionDirective],
|
|
86
|
+
template: `
|
|
87
|
+
<button
|
|
88
|
+
[transition]="{
|
|
89
|
+
key: 'cta',
|
|
90
|
+
in: fadeIn({ duration: 220 }),
|
|
91
|
+
out: fadeOut({ duration: 180 })
|
|
92
|
+
}"
|
|
93
|
+
>
|
|
94
|
+
Get Started
|
|
95
|
+
</button>
|
|
96
|
+
`,
|
|
97
|
+
})
|
|
98
|
+
export class CallToActionComponent {}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## How It Works
|
|
102
|
+
|
|
103
|
+
- `Ssgoi` wraps `createSggoiTransitionContext` from `@ssgoi/core` and injects it via `SSGOI_CONTEXT`. The directive guards against the server platform so SSR renders stay deterministic.
|
|
104
|
+
- `SsgoiTransition` reads that context with `injectSsgoi()`, sets `data-ssgoi-transition` on the host, and subscribes the element to the core transition runner.
|
|
105
|
+
- `TransitionDirective` lets any element opt into spring-driven enter/leave effects while sharing the same scheduling primitives as view transitions.
|
|
106
|
+
|
|
107
|
+
Because everything is driven by signals, Angular change detection stays minimal and the bundle remains fully tree-shakeable.
|
|
108
|
+
|
|
109
|
+
## API Reference
|
|
110
|
+
|
|
111
|
+
- `Ssgoi`
|
|
112
|
+
- `config: SsgoiConfig` (input, optional) – global transition configuration. Uses `{}` as default.
|
|
113
|
+
- `SsgoiTransition`
|
|
114
|
+
- `ssgoiTransition: string` (required input) – identifier for the target view/container.
|
|
115
|
+
- `TransitionDirective`
|
|
116
|
+
- `transition: TransitionDirectiveConfig` (required input) – accepts any config from `@ssgoi/core`, plus an optional `key` to coordinate enter/leave pairs.
|
|
117
|
+
- `injectSsgoi(): SsgoiContext` – returns a function that looks up transition definitions by id. During SSR it falls back to a no-op implementation so you can call it unconditionally.
|
|
118
|
+
|
|
119
|
+
## Available Transitions
|
|
120
|
+
|
|
121
|
+
View-level factories:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { fade, scroll, drill, hero, pinterest } from "@ssgoi/angular/view-transitions";
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Element-level factories:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import {
|
|
131
|
+
fadeIn,
|
|
132
|
+
fadeOut,
|
|
133
|
+
slideUp,
|
|
134
|
+
slideDown,
|
|
135
|
+
slideLeft,
|
|
136
|
+
slideRight,
|
|
137
|
+
scaleIn,
|
|
138
|
+
scaleOut,
|
|
139
|
+
bounce,
|
|
140
|
+
blur,
|
|
141
|
+
rotate,
|
|
142
|
+
} from "@ssgoi/angular/transitions";
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Presets that combine common configurations:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { marketingPreset, dashboardPreset } from "@ssgoi/angular/presets";
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Sample Configuration
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { fade, scroll } from "@ssgoi/angular/view-transitions";
|
|
155
|
+
import type { SsgoiConfig } from "@ssgoi/angular";
|
|
156
|
+
|
|
157
|
+
export const config: SsgoiConfig = {
|
|
158
|
+
defaultTransition: fade(),
|
|
159
|
+
transitions: [
|
|
160
|
+
{
|
|
161
|
+
from: "/home",
|
|
162
|
+
to: "/about",
|
|
163
|
+
transition: scroll({ direction: "up" }),
|
|
164
|
+
symmetric: true,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT © MeurSyphus
|
|
173
|
+
|
|
174
|
+
## Links
|
|
175
|
+
|
|
176
|
+
- [Documentation](https://ssgoi.dev)
|
|
177
|
+
- [GitHub](https://github.com/meursyphus/ssgoi)
|
|
178
|
+
- [Issues](https://github.com/meursyphus/ssgoi/issues)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssgoi-angular-presets.mjs","sources":["../../src/lib/presets/ssgoi-angular-presets.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssgoi-angular-transitions.mjs","sources":["../../src/lib/transitions/ssgoi-angular-transitions.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssgoi-angular-view-transitions.mjs","sources":["../../src/lib/view-transitions/ssgoi-angular-view-transitions.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, PLATFORM_ID, input, forwardRef, Directive, ElementRef } from '@angular/core';
|
|
3
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
4
|
+
import { createSggoiTransitionContext, transition } from '@ssgoi/core';
|
|
5
|
+
export { transition } from '@ssgoi/core';
|
|
6
|
+
|
|
7
|
+
const SSGOI_CONTEXT = new InjectionToken("ssgoi-context");
|
|
8
|
+
function injectSsgoi() {
|
|
9
|
+
const context = inject(SSGOI_CONTEXT, { optional: true });
|
|
10
|
+
if (!context) {
|
|
11
|
+
// During SSR or when not wrapped in <ssgoi>, return a no-op context
|
|
12
|
+
// This prevents errors during server-side rendering
|
|
13
|
+
return () => ({
|
|
14
|
+
key: "",
|
|
15
|
+
in: async () => ({}),
|
|
16
|
+
out: async () => ({}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createSsgoiContext(component) {
|
|
23
|
+
const platformId = inject(PLATFORM_ID);
|
|
24
|
+
// Only create context in browser environment
|
|
25
|
+
if (!isPlatformBrowser(platformId)) {
|
|
26
|
+
// Return a no-op context for SSR
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return createSggoiTransitionContext(component.config());
|
|
30
|
+
}
|
|
31
|
+
class Ssgoi {
|
|
32
|
+
config = input({}, ...(ngDevMode ? [{ debugName: "config" }] : []));
|
|
33
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Ssgoi, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
34
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: Ssgoi, isStandalone: true, selector: "[ssgoi]", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
35
|
+
{
|
|
36
|
+
provide: SSGOI_CONTEXT,
|
|
37
|
+
useFactory: createSsgoiContext,
|
|
38
|
+
deps: [forwardRef(() => Ssgoi)],
|
|
39
|
+
},
|
|
40
|
+
], ngImport: i0 });
|
|
41
|
+
}
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: Ssgoi, decorators: [{
|
|
43
|
+
type: Directive,
|
|
44
|
+
args: [{
|
|
45
|
+
selector: "[ssgoi]",
|
|
46
|
+
standalone: true,
|
|
47
|
+
providers: [
|
|
48
|
+
{
|
|
49
|
+
provide: SSGOI_CONTEXT,
|
|
50
|
+
useFactory: createSsgoiContext,
|
|
51
|
+
deps: [forwardRef(() => Ssgoi)],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}]
|
|
55
|
+
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }] } });
|
|
56
|
+
|
|
57
|
+
class SsgoiTransition {
|
|
58
|
+
// The directive attribute value becomes the transition ID
|
|
59
|
+
ssgoiTransition = input.required(...(ngDevMode ? [{ debugName: "ssgoiTransition" }] : []));
|
|
60
|
+
getTransition = injectSsgoi();
|
|
61
|
+
el = inject((ElementRef));
|
|
62
|
+
platformId = inject(PLATFORM_ID);
|
|
63
|
+
cleanup;
|
|
64
|
+
ngOnInit() {
|
|
65
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Set data attribute on host element
|
|
69
|
+
this.el.nativeElement.setAttribute("data-ssgoi-transition", this.ssgoiTransition());
|
|
70
|
+
}
|
|
71
|
+
ngAfterViewInit() {
|
|
72
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Use the host element itself as the transition target
|
|
76
|
+
const targetElement = this.el.nativeElement;
|
|
77
|
+
const transitionConfig = this.getTransition(this.ssgoiTransition());
|
|
78
|
+
const cleanupResult = transition(transitionConfig)(targetElement);
|
|
79
|
+
if (cleanupResult) {
|
|
80
|
+
this.cleanup = cleanupResult;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
ngOnDestroy() {
|
|
84
|
+
this.cleanup?.();
|
|
85
|
+
}
|
|
86
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SsgoiTransition, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
87
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: SsgoiTransition, isStandalone: true, selector: "[ssgoiTransition]", inputs: { ssgoiTransition: { classPropertyName: "ssgoiTransition", publicName: "ssgoiTransition", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
88
|
+
}
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SsgoiTransition, decorators: [{
|
|
90
|
+
type: Directive,
|
|
91
|
+
args: [{
|
|
92
|
+
selector: "[ssgoiTransition]",
|
|
93
|
+
standalone: true,
|
|
94
|
+
}]
|
|
95
|
+
}], propDecorators: { ssgoiTransition: [{ type: i0.Input, args: [{ isSignal: true, alias: "ssgoiTransition", required: true }] }] } });
|
|
96
|
+
|
|
97
|
+
class TransitionDirective {
|
|
98
|
+
transition = input.required(...(ngDevMode ? [{ debugName: "transition" }] : []));
|
|
99
|
+
el = inject((ElementRef));
|
|
100
|
+
platformId = inject(PLATFORM_ID);
|
|
101
|
+
cleanup;
|
|
102
|
+
ngOnInit() {
|
|
103
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const config = this.transition();
|
|
107
|
+
const cleanupResult = transition({
|
|
108
|
+
key: config.key,
|
|
109
|
+
in: config.in,
|
|
110
|
+
out: config.out,
|
|
111
|
+
ref: this.el.nativeElement,
|
|
112
|
+
})(this.el.nativeElement);
|
|
113
|
+
if (cleanupResult) {
|
|
114
|
+
this.cleanup = cleanupResult;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
ngOnDestroy() {
|
|
118
|
+
this.cleanup?.();
|
|
119
|
+
}
|
|
120
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TransitionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
121
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: TransitionDirective, isStandalone: true, selector: "[transition]", inputs: { transition: { classPropertyName: "transition", publicName: "transition", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
122
|
+
}
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TransitionDirective, decorators: [{
|
|
124
|
+
type: Directive,
|
|
125
|
+
args: [{
|
|
126
|
+
selector: "[transition]",
|
|
127
|
+
}]
|
|
128
|
+
}], propDecorators: { transition: [{ type: i0.Input, args: [{ isSignal: true, alias: "transition", required: true }] }] } });
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* Public API Surface of @ssgoi/angular
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Generated bundle index. Do not edit.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
export { SSGOI_CONTEXT, Ssgoi, SsgoiTransition, TransitionDirective, injectSsgoi };
|
|
139
|
+
//# sourceMappingURL=ssgoi-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssgoi-angular.mjs","sources":["../../src/lib/context.ts","../../src/lib/ssgoi.directive.ts","../../src/lib/ssgoi-transition.directive.ts","../../src/lib/transition.directive.ts","../../src/public-api.ts","../../src/ssgoi-angular.ts"],"sourcesContent":["import { InjectionToken, inject } from \"@angular/core\";\nimport type { SsgoiContext } from \"@ssgoi/core\";\n\nexport const SSGOI_CONTEXT = new InjectionToken<SsgoiContext | undefined>(\n \"ssgoi-context\",\n);\n\nexport function injectSsgoi(): SsgoiContext {\n const context = inject(SSGOI_CONTEXT, { optional: true });\n\n if (!context) {\n // During SSR or when not wrapped in <ssgoi>, return a no-op context\n // This prevents errors during server-side rendering\n return () => ({\n key: \"\",\n in: async () => ({}),\n out: async () => ({}),\n });\n }\n\n return context;\n}\n","import {\n Directive,\n input,\n forwardRef,\n PLATFORM_ID,\n inject,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { createSggoiTransitionContext } from \"@ssgoi/core\";\nimport type { SsgoiConfig, SsgoiContext } from \"@ssgoi/core\";\nimport { SSGOI_CONTEXT } from \"./context\";\n\nfunction createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {\n const platformId = inject(PLATFORM_ID);\n\n // Only create context in browser environment\n if (!isPlatformBrowser(platformId)) {\n // Return a no-op context for SSR\n return undefined;\n }\n return createSggoiTransitionContext(component.config());\n}\n\n@Directive({\n selector: \"[ssgoi]\",\n standalone: true,\n providers: [\n {\n provide: SSGOI_CONTEXT,\n useFactory: createSsgoiContext,\n deps: [forwardRef(() => Ssgoi)],\n },\n ],\n})\nexport class Ssgoi {\n readonly config = input<SsgoiConfig>({});\n}\n","import {\n Directive,\n input,\n OnInit,\n OnDestroy,\n AfterViewInit,\n ElementRef,\n inject,\n PLATFORM_ID,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { transition } from \"@ssgoi/core\";\nimport { injectSsgoi } from \"./context\";\n\n@Directive({\n selector: \"[ssgoiTransition]\",\n standalone: true,\n})\nexport class SsgoiTransition implements OnInit, OnDestroy, AfterViewInit {\n // The directive attribute value becomes the transition ID\n readonly ssgoiTransition = input.required<string>();\n\n private readonly getTransition = injectSsgoi();\n private readonly el = inject(ElementRef<HTMLElement>);\n private readonly platformId = inject(PLATFORM_ID);\n private cleanup?: () => void;\n\n ngOnInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n // Set data attribute on host element\n this.el.nativeElement.setAttribute(\n \"data-ssgoi-transition\",\n this.ssgoiTransition(),\n );\n }\n\n ngAfterViewInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n // Use the host element itself as the transition target\n const targetElement = this.el.nativeElement;\n\n const transitionConfig = this.getTransition(this.ssgoiTransition());\n const cleanupResult = transition(transitionConfig)(targetElement);\n\n if (cleanupResult) {\n this.cleanup = cleanupResult;\n }\n }\n\n ngOnDestroy(): void {\n this.cleanup?.();\n }\n}\n","import {\n Directive,\n ElementRef,\n input,\n OnInit,\n OnDestroy,\n inject,\n PLATFORM_ID,\n} from \"@angular/core\";\nimport { isPlatformBrowser } from \"@angular/common\";\nimport { transition as coreTransition } from \"@ssgoi/core\";\nimport type {\n Transition as CoreTransitionConfig,\n TransitionKey as CoreTransitionKey,\n} from \"@ssgoi/core\";\n\nexport type TransitionDirectiveConfig = CoreTransitionConfig & {\n key?: CoreTransitionKey;\n};\n\n@Directive({\n selector: \"[transition]\",\n})\nexport class TransitionDirective implements OnInit, OnDestroy {\n transition = input.required<TransitionDirectiveConfig>();\n\n private readonly el = inject(ElementRef<HTMLElement>);\n private readonly platformId = inject(PLATFORM_ID);\n private cleanup?: () => void;\n\n ngOnInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n const config = this.transition();\n const cleanupResult = coreTransition({\n key: config.key,\n in: config.in,\n out: config.out,\n ref: this.el.nativeElement,\n })(this.el.nativeElement);\n\n if (cleanupResult) {\n this.cleanup = cleanupResult;\n }\n }\n\n ngOnDestroy(): void {\n this.cleanup?.();\n }\n}\n","/*\n * Public API Surface of @ssgoi/angular\n */\n\nexport * from \"./lib/index\";\nexport * from \"./lib/types\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["coreTransition"],"mappings":";;;;;;MAGa,aAAa,GAAG,IAAI,cAAc,CAC7C,eAAe;SAGD,WAAW,GAAA;AACzB,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAEzD,IAAI,CAAC,OAAO,EAAE;;;QAGZ,OAAO,OAAO;AACZ,YAAA,GAAG,EAAE,EAAE;AACP,YAAA,EAAE,EAAE,aAAa,EAAE,CAAC;AACpB,YAAA,GAAG,EAAE,aAAa,EAAE,CAAC;AACtB,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,OAAO;AAChB;;ACTA,SAAS,kBAAkB,CAAC,SAAgB,EAAA;AAC1C,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;;AAGtC,IAAA,IAAI,CAAC,iBAAiB,C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;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAH/B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACzB,iBAAA;;;ACtBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, OnDestroy, AfterViewInit, InjectionToken } from '@angular/core';
|
|
3
|
+
import { SsgoiConfig, Transition, TransitionKey, SsgoiContext } from '@ssgoi/core';
|
|
4
|
+
export * from '@ssgoi/core';
|
|
5
|
+
export { transition } from '@ssgoi/core';
|
|
6
|
+
|
|
7
|
+
declare class Ssgoi {
|
|
8
|
+
readonly config: i0.InputSignal<SsgoiConfig>;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Ssgoi, never>;
|
|
10
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Ssgoi, "[ssgoi]", never, { "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class SsgoiTransition implements OnInit, OnDestroy, AfterViewInit {
|
|
14
|
+
readonly ssgoiTransition: i0.InputSignal<string>;
|
|
15
|
+
private readonly getTransition;
|
|
16
|
+
private readonly el;
|
|
17
|
+
private readonly platformId;
|
|
18
|
+
private cleanup?;
|
|
19
|
+
ngOnInit(): void;
|
|
20
|
+
ngAfterViewInit(): void;
|
|
21
|
+
ngOnDestroy(): void;
|
|
22
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SsgoiTransition, never>;
|
|
23
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<SsgoiTransition, "[ssgoiTransition]", never, { "ssgoiTransition": { "alias": "ssgoiTransition"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type TransitionDirectiveConfig = Transition & {
|
|
27
|
+
key?: TransitionKey;
|
|
28
|
+
};
|
|
29
|
+
declare class TransitionDirective implements OnInit, OnDestroy {
|
|
30
|
+
transition: i0.InputSignal<TransitionDirectiveConfig>;
|
|
31
|
+
private readonly el;
|
|
32
|
+
private readonly platformId;
|
|
33
|
+
private cleanup?;
|
|
34
|
+
ngOnInit(): void;
|
|
35
|
+
ngOnDestroy(): void;
|
|
36
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TransitionDirective, never>;
|
|
37
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<TransitionDirective, "[transition]", never, { "transition": { "alias": "transition"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const SSGOI_CONTEXT: InjectionToken<SsgoiContext>;
|
|
41
|
+
declare function injectSsgoi(): SsgoiContext;
|
|
42
|
+
|
|
43
|
+
export { SSGOI_CONTEXT, Ssgoi, SsgoiTransition, TransitionDirective, injectSsgoi };
|
|
44
|
+
export type { TransitionDirectiveConfig };
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ssgoi/angular",
|
|
3
|
+
"version": "2.5.2",
|
|
4
|
+
"description": "Angular bindings for SSGOI - Native app-like page transitions for Angular applications",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@ssgoi/core": "^2.5.2",
|
|
10
|
+
"tslib": "^2.3.0"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"@angular/common": "^20.0.0",
|
|
14
|
+
"@angular/core": "^20.0.0"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"angular",
|
|
18
|
+
"page-transition",
|
|
19
|
+
"animation",
|
|
20
|
+
"ssgoi",
|
|
21
|
+
"spring-physics",
|
|
22
|
+
"standalone"
|
|
23
|
+
],
|
|
24
|
+
"author": "MeurSyphus <tmdeoans@snu.ac.kr>",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/meursyphus/ssgoi.git",
|
|
29
|
+
"directory": "packages/angular"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://ssgoi.dev",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/meursyphus/ssgoi/issues"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": {
|
|
43
|
+
"default": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./index.d.ts",
|
|
47
|
+
"default": "./fesm2022/ssgoi-angular.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./presets": {
|
|
50
|
+
"types": "./presets/index.d.ts",
|
|
51
|
+
"default": "./fesm2022/ssgoi-angular-presets.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./transitions": {
|
|
54
|
+
"types": "./transitions/index.d.ts",
|
|
55
|
+
"default": "./fesm2022/ssgoi-angular-transitions.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./view-transitions": {
|
|
58
|
+
"types": "./view-transitions/index.d.ts",
|
|
59
|
+
"default": "./fesm2022/ssgoi-angular-view-transitions.mjs"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"sideEffects": false,
|
|
63
|
+
"module": "fesm2022/ssgoi-angular.mjs",
|
|
64
|
+
"typings": "index.d.ts"
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/presets';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/transitions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/view-transitions';
|