@formriff/onboarding-angular 0.0.0-stage → 0.1.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/LICENSE +22 -0
- package/README.md +143 -2
- package/fesm2022/formriff-onboarding-angular.mjs +150 -0
- package/fesm2022/formriff-onboarding-angular.mjs.map +1 -0
- package/package.json +38 -3
- package/types/formriff-onboarding-angular.d.ts +57 -0
- package/types/formriff-onboarding-angular.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Onboarding Kit contributors
|
|
4
|
+
Copyright (c) 2026 Zero
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formriff/onboarding-angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standalone Angular **21.2.26+ (21.x)** bindings for `@formriff/onboarding`. Built as an ESM-only
|
|
4
|
+
Angular Package Format library with partial compilation. Requires Angular common,
|
|
5
|
+
core, router, and RxJS 7.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @formriff/onboarding-angular @formriff/onboarding
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Keep Angular packages on matching versions. Import the default renderer stylesheet
|
|
14
|
+
once, in a global stylesheet:
|
|
15
|
+
|
|
16
|
+
```css
|
|
17
|
+
@import '@formriff/onboarding/styles.css';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Alternatively add `@formriff/onboarding/styles.css` to Angular CLI's global `styles`
|
|
21
|
+
array. The adapter does not import CSS or access browser globals on the server.
|
|
22
|
+
|
|
23
|
+
## Standalone application and Angular Router
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { inject } from '@angular/core';
|
|
27
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
28
|
+
import { provideRouter, Router } from '@angular/router';
|
|
29
|
+
import { createAngularRouter, provideOnboarding } from '@formriff/onboarding-angular';
|
|
30
|
+
import { localStorageAdapter } from '@formriff/onboarding';
|
|
31
|
+
import { AppComponent } from './app.component';
|
|
32
|
+
import { routes } from './app.routes';
|
|
33
|
+
|
|
34
|
+
bootstrapApplication(AppComponent, {
|
|
35
|
+
providers: [
|
|
36
|
+
provideRouter(routes),
|
|
37
|
+
provideOnboarding(() => ({
|
|
38
|
+
router: createAngularRouter(inject(Router)),
|
|
39
|
+
storage: localStorageAdapter('my-app'),
|
|
40
|
+
tours: [
|
|
41
|
+
{
|
|
42
|
+
id: 'onboarding',
|
|
43
|
+
steps: [
|
|
44
|
+
{
|
|
45
|
+
id: 'welcome',
|
|
46
|
+
route: '/',
|
|
47
|
+
target: '[data-onboarding="welcome"]',
|
|
48
|
+
title: 'Welcome',
|
|
49
|
+
content: 'Your workspace starts here.',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'settings',
|
|
53
|
+
route: '/settings',
|
|
54
|
+
target: '[data-onboarding="settings"]',
|
|
55
|
+
title: 'Settings',
|
|
56
|
+
content: 'Adjust your preferences.',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
})),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`provideOnboarding(options)` also accepts a plain `OnboardingOptions` object.
|
|
67
|
+
The factory form runs in Angular's injection context. Provide it once at application
|
|
68
|
+
scope: its environment initializer creates and mounts the kit in the browser;
|
|
69
|
+
destroying that injector unsubscribes, unmounts, and destroys it. SSR creates the
|
|
70
|
+
state container but does not mount; the service's `start()` is a no-op on the server.
|
|
71
|
+
Start tours in browser interactions rather than server constructors. Direct calls
|
|
72
|
+
to `kit.start()` bypass this guard (core's `start()` can auto-mount).
|
|
73
|
+
|
|
74
|
+
`createAngularRouter(router)` uses Angular navigation, not browser history patches.
|
|
75
|
+
It reports successful `NavigationEnd` events, strips query strings/fragments from
|
|
76
|
+
`getPath()`, rejects cancelled navigations, and returns an unsubscribe function.
|
|
77
|
+
Use pathname-only step routes such as `/settings`.
|
|
78
|
+
|
|
79
|
+
## Targets and service
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { Component, inject } from '@angular/core';
|
|
83
|
+
import { OnboardingService, OnboardingStepDirective } from '@formriff/onboarding-angular';
|
|
84
|
+
|
|
85
|
+
@Component({
|
|
86
|
+
selector: 'app-welcome',
|
|
87
|
+
standalone: true,
|
|
88
|
+
imports: [OnboardingStepDirective],
|
|
89
|
+
template: `
|
|
90
|
+
<h1 onboardingStep="welcome">Your workspace</h1>
|
|
91
|
+
<button type="button" (click)="onboarding.start('onboarding')">Start onboarding</button>
|
|
92
|
+
<p aria-live="polite">{{ onboarding.state().status }}</p>
|
|
93
|
+
`,
|
|
94
|
+
})
|
|
95
|
+
export class WelcomeComponent {
|
|
96
|
+
readonly onboarding = inject(OnboardingService);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`[onboardingStep]` writes `data-onboarding`; it does not register a step. Changing or
|
|
101
|
+
clearing its input updates or removes the attribute. A literal `data-onboarding`
|
|
102
|
+
attribute works equally well.
|
|
103
|
+
|
|
104
|
+
`OnboardingService` exposes:
|
|
105
|
+
|
|
106
|
+
- `state`: readonly Angular signal of the core `OnboardingState`.
|
|
107
|
+
- `kit`: the underlying core instance.
|
|
108
|
+
- `start(id, { resume? })`, `next()`, `prev()` (async).
|
|
109
|
+
- `skip()`, `reset(id?)`, `trigger(name)`, `on(type, listener)` (returns unsubscribe).
|
|
110
|
+
|
|
111
|
+
State may be `idle`, `waiting`, or `navigating` with no renderable target. Render a
|
|
112
|
+
step only when `status === 'running'`; `step` and `target` are nullable. Core defaults
|
|
113
|
+
to its accessible renderer. A custom core renderer function is passed through
|
|
114
|
+
unchanged and receives `{ state, kit, labels }`; return cleanup for each render.
|
|
115
|
+
|
|
116
|
+
## Angular ng-template renderer
|
|
117
|
+
|
|
118
|
+
Set `renderer: 'none'` in the provider and import `OnboardingOutletComponent` in your
|
|
119
|
+
standalone component. This disables the core DOM renderer; the outlet reacts to the
|
|
120
|
+
service signal and renders only a running, non-null step.
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<onboarding-outlet>
|
|
124
|
+
<ng-template let-state let-kit="kit">
|
|
125
|
+
<aside role="region" aria-labelledby="tour-title" aria-live="polite">
|
|
126
|
+
<h2 id="tour-title">{{ state.step?.title }}</h2>
|
|
127
|
+
<p>{{ state.step?.content }}</p>
|
|
128
|
+
<p>Step {{ state.stepIndex + 1 }} of {{ state.totalSteps }}</p>
|
|
129
|
+
<button type="button" (click)="kit.skip()">Skip</button>
|
|
130
|
+
<button type="button" [disabled]="state.stepIndex === 0" (click)="kit.prev()">Back</button>
|
|
131
|
+
<button type="button" (click)="kit.next()">
|
|
132
|
+
{{ state.stepIndex + 1 === state.totalSteps ? 'Done' : 'Next' }}
|
|
133
|
+
</button>
|
|
134
|
+
</aside>
|
|
135
|
+
</ng-template>
|
|
136
|
+
</onboarding-outlet>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The template's implicit value and `state` are the current state; `kit` is the core
|
|
140
|
+
instance. Alternatively use `OnboardingService.state()` directly in your own template.
|
|
141
|
+
The outlet supplies no overlay, positioning, labels, focus management, or focus trap.
|
|
142
|
+
You own those concerns, including accessible dialog behavior if you build a modal.
|
|
143
|
+
Core still handles Escape and arrow keys for headless onboardings; avoid duplicating
|
|
144
|
+
those listeners.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, NgZone, PLATFORM_ID, signal, DestroyRef, Injectable, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, Input, Directive, TemplateRef, ContentChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { NavigationEnd } from '@angular/router';
|
|
5
|
+
import { createOnboarding } from '@formriff/onboarding';
|
|
6
|
+
|
|
7
|
+
// Keep the small public surface in one entry file: ng-packagr 18 emits .mjs
|
|
8
|
+
// runtime files, while extensionless declaration re-exports fail Node ESM checks.
|
|
9
|
+
const ONBOARDING_OPTIONS = new InjectionToken('Onboarding Kit options');
|
|
10
|
+
/** One kit per environment injector. Provide it once in the application configuration. */
|
|
11
|
+
class OnboardingService {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.zone = inject(NgZone);
|
|
14
|
+
this.platformId = inject(PLATFORM_ID);
|
|
15
|
+
this.kit = createOnboarding(inject(ONBOARDING_OPTIONS));
|
|
16
|
+
this.currentState = signal(this.kit.getState(), ...(ngDevMode ? [{ debugName: "currentState" }] : /* istanbul ignore next */ []));
|
|
17
|
+
this.state = this.currentState.asReadonly();
|
|
18
|
+
this.start = (tourId, options) => isPlatformBrowser(this.platformId) ? this.kit.start(tourId, options) : Promise.resolve();
|
|
19
|
+
this.next = () => this.kit.next();
|
|
20
|
+
this.prev = () => this.kit.prev();
|
|
21
|
+
this.skip = () => this.kit.skip();
|
|
22
|
+
this.reset = (tourId) => this.kit.reset(tourId);
|
|
23
|
+
this.trigger = (name) => this.kit.trigger(name);
|
|
24
|
+
this.on = (type, listener) => this.kit.on(type, listener);
|
|
25
|
+
const unsubscribe = this.kit.subscribe((state) => {
|
|
26
|
+
this.zone.run(() => this.currentState.set(state));
|
|
27
|
+
});
|
|
28
|
+
inject(DestroyRef).onDestroy(() => {
|
|
29
|
+
unsubscribe();
|
|
30
|
+
this.unmount?.();
|
|
31
|
+
this.unmount = undefined;
|
|
32
|
+
this.kit.destroy();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** Called automatically by provideOnboarding. No DOM work is done on the server. */
|
|
36
|
+
mount() {
|
|
37
|
+
if (isPlatformBrowser(this.platformId) && !this.unmount) {
|
|
38
|
+
this.unmount = this.kit.mount();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
42
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingService }); }
|
|
43
|
+
}
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingService, decorators: [{
|
|
45
|
+
type: Injectable
|
|
46
|
+
}], ctorParameters: () => [] });
|
|
47
|
+
/** A factory may use inject(), for example to obtain Angular's Router. */
|
|
48
|
+
function provideOnboarding(options) {
|
|
49
|
+
return makeEnvironmentProviders([
|
|
50
|
+
{
|
|
51
|
+
provide: ONBOARDING_OPTIONS,
|
|
52
|
+
useFactory: typeof options === 'function' ? options : () => options,
|
|
53
|
+
},
|
|
54
|
+
OnboardingService,
|
|
55
|
+
{
|
|
56
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
57
|
+
multi: true,
|
|
58
|
+
useValue: () => inject(OnboardingService).mount(),
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
/** Exposes a stable data-onboarding target without registering or mutating a tour. */
|
|
63
|
+
class OnboardingStepDirective {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.onboardingStep = '';
|
|
66
|
+
}
|
|
67
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingStepDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
68
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.26", type: OnboardingStepDirective, isStandalone: true, selector: "[onboardingStep]", inputs: { onboardingStep: "onboardingStep" }, host: { properties: { "attr.data-onboarding": "onboardingStep || null" } }, ngImport: i0 }); }
|
|
69
|
+
}
|
|
70
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingStepDirective, decorators: [{
|
|
71
|
+
type: Directive,
|
|
72
|
+
args: [{
|
|
73
|
+
selector: '[onboardingStep]',
|
|
74
|
+
standalone: true,
|
|
75
|
+
host: { '[attr.data-onboarding]': 'onboardingStep || null' },
|
|
76
|
+
}]
|
|
77
|
+
}], propDecorators: { onboardingStep: [{
|
|
78
|
+
type: Input
|
|
79
|
+
}] } });
|
|
80
|
+
/**
|
|
81
|
+
* Reactive template rendering for renderer: 'none'. Positioning, focus management,
|
|
82
|
+
* accessible markup, and styles are intentionally owned by the supplied template.
|
|
83
|
+
*/
|
|
84
|
+
class OnboardingOutletComponent {
|
|
85
|
+
constructor() {
|
|
86
|
+
this.onboarding = inject(OnboardingService);
|
|
87
|
+
}
|
|
88
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
89
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.26", type: OnboardingOutletComponent, isStandalone: true, selector: "onboarding-outlet", queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0, template: `
|
|
90
|
+
@if (onboarding.state().status === 'running' && onboarding.state().step && template) {
|
|
91
|
+
<ng-container
|
|
92
|
+
[ngTemplateOutlet]="template"
|
|
93
|
+
[ngTemplateOutletContext]="{
|
|
94
|
+
$implicit: onboarding.state(),
|
|
95
|
+
state: onboarding.state(),
|
|
96
|
+
kit: onboarding.kit,
|
|
97
|
+
}"
|
|
98
|
+
/>
|
|
99
|
+
}
|
|
100
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
101
|
+
}
|
|
102
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: OnboardingOutletComponent, decorators: [{
|
|
103
|
+
type: Component,
|
|
104
|
+
args: [{
|
|
105
|
+
selector: 'onboarding-outlet',
|
|
106
|
+
standalone: true,
|
|
107
|
+
imports: [NgTemplateOutlet],
|
|
108
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
109
|
+
template: `
|
|
110
|
+
@if (onboarding.state().status === 'running' && onboarding.state().step && template) {
|
|
111
|
+
<ng-container
|
|
112
|
+
[ngTemplateOutlet]="template"
|
|
113
|
+
[ngTemplateOutletContext]="{
|
|
114
|
+
$implicit: onboarding.state(),
|
|
115
|
+
state: onboarding.state(),
|
|
116
|
+
kit: onboarding.kit,
|
|
117
|
+
}"
|
|
118
|
+
/>
|
|
119
|
+
}
|
|
120
|
+
`,
|
|
121
|
+
}]
|
|
122
|
+
}], propDecorators: { template: [{
|
|
123
|
+
type: ContentChild,
|
|
124
|
+
args: [TemplateRef]
|
|
125
|
+
}] } });
|
|
126
|
+
/** Adapts successful Angular navigations; query strings/fragments are not route paths. */
|
|
127
|
+
function createAngularRouter(router) {
|
|
128
|
+
return {
|
|
129
|
+
getPath: () => router.url.split(/[?#]/, 1)[0] || '/',
|
|
130
|
+
async navigate(path) {
|
|
131
|
+
if (!(await router.navigateByUrl(path))) {
|
|
132
|
+
throw new Error(`Onboarding navigation to "${path}" was cancelled.`);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
subscribe(listener) {
|
|
136
|
+
const subscription = router.events.subscribe((event) => {
|
|
137
|
+
if (event instanceof NavigationEnd)
|
|
138
|
+
listener();
|
|
139
|
+
});
|
|
140
|
+
return () => subscription.unsubscribe();
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Generated bundle index. Do not edit.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
export { OnboardingOutletComponent, OnboardingService, OnboardingStepDirective, createAngularRouter, provideOnboarding };
|
|
150
|
+
//# sourceMappingURL=formriff-onboarding-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formriff-onboarding-angular.mjs","sources":["../../src/index.ts","../../src/formriff-onboarding-angular.ts"],"sourcesContent":["import { NgTemplateOutlet, isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n ContentChild,\n DestroyRef,\n Directive,\n ENVIRONMENT_INITIALIZER,\n Injectable,\n InjectionToken,\n Input,\n NgZone,\n PLATFORM_ID,\n TemplateRef,\n inject,\n makeEnvironmentProviders,\n signal,\n type EnvironmentProviders,\n} from '@angular/core';\nimport { NavigationEnd, type Router } from '@angular/router';\nimport {\n createOnboarding,\n type RouterAdapter,\n type OnboardingEvent,\n type OnboardingEventType,\n type Onboarding,\n type OnboardingOptions,\n type OnboardingState,\n} from '@formriff/onboarding';\n\n// Keep the small public surface in one entry file: ng-packagr 18 emits .mjs\n// runtime files, while extensionless declaration re-exports fail Node ESM checks.\nconst ONBOARDING_OPTIONS = new InjectionToken<OnboardingOptions>('Onboarding Kit options');\n\n/** One kit per environment injector. Provide it once in the application configuration. */\n@Injectable()\nexport class OnboardingService {\n private readonly zone = inject(NgZone);\n private readonly platformId = inject(PLATFORM_ID);\n readonly kit = createOnboarding(inject(ONBOARDING_OPTIONS));\n private readonly currentState = signal(this.kit.getState());\n readonly state = this.currentState.asReadonly();\n private unmount?: () => void;\n\n constructor() {\n const unsubscribe = this.kit.subscribe((state) => {\n this.zone.run(() => this.currentState.set(state));\n });\n\n inject(DestroyRef).onDestroy(() => {\n unsubscribe();\n this.unmount?.();\n this.unmount = undefined;\n this.kit.destroy();\n });\n }\n\n /** Called automatically by provideOnboarding. No DOM work is done on the server. */\n mount(): void {\n if (isPlatformBrowser(this.platformId) && !this.unmount) {\n this.unmount = this.kit.mount();\n }\n }\n\n readonly start = (tourId: string, options?: { resume?: boolean }) =>\n isPlatformBrowser(this.platformId) ? this.kit.start(tourId, options) : Promise.resolve();\n readonly next = () => this.kit.next();\n readonly prev = () => this.kit.prev();\n readonly skip = () => this.kit.skip();\n readonly reset = (tourId?: string) => this.kit.reset(tourId);\n readonly trigger = (name: string) => this.kit.trigger(name);\n readonly on = (type: OnboardingEventType, listener: (event: OnboardingEvent) => void) =>\n this.kit.on(type, listener);\n}\n\n/** A factory may use inject(), for example to obtain Angular's Router. */\nexport function provideOnboarding(\n options: OnboardingOptions | (() => OnboardingOptions),\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: ONBOARDING_OPTIONS,\n useFactory: typeof options === 'function' ? options : () => options,\n },\n OnboardingService,\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => inject(OnboardingService).mount(),\n },\n ]);\n}\n\n/** Exposes a stable data-onboarding target without registering or mutating a tour. */\n@Directive({\n selector: '[onboardingStep]',\n standalone: true,\n host: { '[attr.data-onboarding]': 'onboardingStep || null' },\n})\nexport class OnboardingStepDirective {\n @Input() onboardingStep = '';\n}\n\nexport interface OnboardingTemplateContext {\n $implicit: OnboardingState;\n state: OnboardingState;\n kit: Onboarding;\n}\n\n/**\n * Reactive template rendering for renderer: 'none'. Positioning, focus management,\n * accessible markup, and styles are intentionally owned by the supplied template.\n */\n@Component({\n selector: 'onboarding-outlet',\n standalone: true,\n imports: [NgTemplateOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n @if (onboarding.state().status === 'running' && onboarding.state().step && template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{\n $implicit: onboarding.state(),\n state: onboarding.state(),\n kit: onboarding.kit,\n }\"\n />\n }\n `,\n})\nexport class OnboardingOutletComponent {\n readonly onboarding = inject(OnboardingService);\n @ContentChild(TemplateRef) template?: TemplateRef<OnboardingTemplateContext>;\n}\n\n/** Adapts successful Angular navigations; query strings/fragments are not route paths. */\nexport function createAngularRouter(router: Router): RouterAdapter {\n return {\n getPath: () => router.url.split(/[?#]/, 1)[0] || '/',\n async navigate(path) {\n if (!(await router.navigateByUrl(path))) {\n throw new Error(`Onboarding navigation to \"${path}\" was cancelled.`);\n }\n },\n subscribe(listener) {\n const subscription = router.events.subscribe((event) => {\n if (event instanceof NavigationEnd) listener();\n });\n return () => subscription.unsubscribe();\n },\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AA8BA;AACA;AACA,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAo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zC,CAAC;KACF;AACH;;ACxJA;;AAEG;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formriff/onboarding-angular",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Standalone Angular adapters for Onboarding Kit",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/FormRiff/onboarding-kit.git",
|
|
9
|
+
"directory": "packages/angular"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/FormRiff/onboarding-kit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/FormRiff/onboarding-kit/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@formriff/onboarding": "^0.1.2",
|
|
22
|
+
"tslib": "^2.8.1"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@angular/common": ">=21.2.26 <22",
|
|
26
|
+
"@angular/core": ">=21.2.26 <22",
|
|
27
|
+
"@angular/router": ">=21.2.26 <22",
|
|
28
|
+
"rxjs": "^7.8.2"
|
|
29
|
+
},
|
|
30
|
+
"module": "fesm2022/formriff-onboarding-angular.mjs",
|
|
31
|
+
"typings": "types/formriff-onboarding-angular.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
"./package.json": {
|
|
34
|
+
"default": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./types/formriff-onboarding-angular.d.ts",
|
|
38
|
+
"default": "./fesm2022/formriff-onboarding-angular.mjs"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
6
41
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { TemplateRef, EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { Onboarding, OnboardingState, OnboardingEventType, OnboardingEvent, RouterAdapter, OnboardingOptions } from '@formriff/onboarding';
|
|
5
|
+
|
|
6
|
+
/** One kit per environment injector. Provide it once in the application configuration. */
|
|
7
|
+
declare class OnboardingService {
|
|
8
|
+
private readonly zone;
|
|
9
|
+
private readonly platformId;
|
|
10
|
+
readonly kit: Onboarding;
|
|
11
|
+
private readonly currentState;
|
|
12
|
+
readonly state: i0.Signal<OnboardingState>;
|
|
13
|
+
private unmount?;
|
|
14
|
+
constructor();
|
|
15
|
+
/** Called automatically by provideOnboarding. No DOM work is done on the server. */
|
|
16
|
+
mount(): void;
|
|
17
|
+
readonly start: (tourId: string, options?: {
|
|
18
|
+
resume?: boolean;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
readonly next: () => Promise<void>;
|
|
21
|
+
readonly prev: () => Promise<void>;
|
|
22
|
+
readonly skip: () => void;
|
|
23
|
+
readonly reset: (tourId?: string) => void;
|
|
24
|
+
readonly trigger: (name: string) => void;
|
|
25
|
+
readonly on: (type: OnboardingEventType, listener: (event: OnboardingEvent) => void) => () => void;
|
|
26
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OnboardingService, never>;
|
|
27
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<OnboardingService>;
|
|
28
|
+
}
|
|
29
|
+
/** A factory may use inject(), for example to obtain Angular's Router. */
|
|
30
|
+
declare function provideOnboarding(options: OnboardingOptions | (() => OnboardingOptions)): EnvironmentProviders;
|
|
31
|
+
/** Exposes a stable data-onboarding target without registering or mutating a tour. */
|
|
32
|
+
declare class OnboardingStepDirective {
|
|
33
|
+
onboardingStep: string;
|
|
34
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OnboardingStepDirective, never>;
|
|
35
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<OnboardingStepDirective, "[onboardingStep]", never, { "onboardingStep": { "alias": "onboardingStep"; "required": false; }; }, {}, never, never, true, never>;
|
|
36
|
+
}
|
|
37
|
+
interface OnboardingTemplateContext {
|
|
38
|
+
$implicit: OnboardingState;
|
|
39
|
+
state: OnboardingState;
|
|
40
|
+
kit: Onboarding;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reactive template rendering for renderer: 'none'. Positioning, focus management,
|
|
44
|
+
* accessible markup, and styles are intentionally owned by the supplied template.
|
|
45
|
+
*/
|
|
46
|
+
declare class OnboardingOutletComponent {
|
|
47
|
+
readonly onboarding: OnboardingService;
|
|
48
|
+
template?: TemplateRef<OnboardingTemplateContext>;
|
|
49
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OnboardingOutletComponent, never>;
|
|
50
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<OnboardingOutletComponent, "onboarding-outlet", never, {}, {}, ["template"], never, true, never>;
|
|
51
|
+
}
|
|
52
|
+
/** Adapts successful Angular navigations; query strings/fragments are not route paths. */
|
|
53
|
+
declare function createAngularRouter(router: Router): RouterAdapter;
|
|
54
|
+
|
|
55
|
+
export { OnboardingOutletComponent, OnboardingService, OnboardingStepDirective, createAngularRouter, provideOnboarding };
|
|
56
|
+
export type { OnboardingTemplateContext };
|
|
57
|
+
//# sourceMappingURL=formriff-onboarding-angular.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formriff-onboarding-angular.d.ts","sources":["../../src/index.ts"],"mappings":";;;;;AAkCA;AACA,cACa,iBAAiB;AAC5B;AACA;kBACY,UAAA;AACZ;oBACcA,EAAA,CAAA,MAAA,CAAA,eAAA;;;;AAiBd;AAMA;;UAAgE,OAAA;yBAEnD,OAAA;yBACA,OAAA;;AAEb;AACA;AACA,wBAAqB,mBAAmB,oBAAoB,eAAe;yCAnChE,iBAAiB;6CAAjB,iBAAiB;AAqC7B;AAED;AACA,iBAAgB,iBAAiB,UACtB,iBAAiB,UAAU,iBAAiB,IACpD,oBAAoB;AAevB;AACA,cAKa,uBAAuB;AACzB;yCADE,uBAAuB;2CAAvB,uBAAuB;AAEnC;UAEgB,yBAAyB;eAC7B,eAAe;WACnB,eAAe;SACjB,UAAU;AAChB;AAED;;;AAGG;AACH,cAkBa,yBAAyB;yBACjB,iBAAA;AACQ,eAAW,WAAW,CAAC,yBAAyB;yCAFhE,yBAAyB;2CAAzB,yBAAyB;AAGrC;AAED;AACA,iBAAgB,mBAAmB,SAAS,MAAM,GAAG,aAAa;;","names":["_angular_core"]}
|