@bootkit/ng0 0.0.0-alpha.5 → 0.0.0-alpha.50
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 +2 -2
- package/common/index.d.ts +288 -28
- package/components/accordion/index.d.ts +20 -10
- package/components/button/index.d.ts +7 -10
- package/components/card/index.d.ts +2 -6
- package/components/code/index.d.ts +2 -4
- package/components/collapse/index.d.ts +4 -41
- package/components/confirmation/index.d.ts +14 -16
- package/components/dropdown/index.d.ts +156 -0
- package/components/form-field/index.d.ts +24 -41
- package/components/list/index.d.ts +260 -0
- package/components/modal/index.d.ts +33 -11
- package/components/nav/index.d.ts +34 -32
- package/components/offcanvas/index.d.ts +13 -5
- package/components/pagination/index.d.ts +39 -13
- package/components/popover/index.d.ts +6 -6
- package/components/select/index.d.ts +160 -0
- package/components/sidenav/index.d.ts +122 -0
- package/components/stepper/index.d.ts +3 -4
- package/components/table/index.d.ts +203 -73
- package/components/toast/index.d.ts +14 -8
- package/components/tooltip/index.d.ts +36 -22
- package/components/vertical-menu/index.d.ts +79 -42
- package/data/index.d.ts +98 -38
- package/date/index.d.ts +34 -0
- package/fesm2022/bootkit-ng0-common.mjs +289 -12
- package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-accordion.mjs +38 -33
- package/fesm2022/bootkit-ng0-components-accordion.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-button.mjs +21 -29
- package/fesm2022/bootkit-ng0-components-button.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-card.mjs +18 -26
- package/fesm2022/bootkit-ng0-components-card.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-code.mjs +16 -20
- package/fesm2022/bootkit-ng0-components-code.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-collapse.mjs +20 -132
- package/fesm2022/bootkit-ng0-components-collapse.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-confirmation.mjs +24 -34
- package/fesm2022/bootkit-ng0-components-confirmation.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-dropdown.mjs +308 -0
- package/fesm2022/bootkit-ng0-components-dropdown.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-form-field.mjs +62 -84
- package/fesm2022/bootkit-ng0-components-form-field.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-list.mjs +564 -0
- package/fesm2022/bootkit-ng0-components-list.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-modal.mjs +48 -29
- package/fesm2022/bootkit-ng0-components-modal.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-nav.mjs +60 -68
- package/fesm2022/bootkit-ng0-components-nav.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs +20 -13
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-overlay.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-pagination.mjs +61 -26
- package/fesm2022/bootkit-ng0-components-pagination.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-popover.mjs +12 -12
- package/fesm2022/bootkit-ng0-components-popover.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-select.mjs +448 -0
- package/fesm2022/bootkit-ng0-components-select.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs +296 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-stepper.mjs +15 -42
- package/fesm2022/bootkit-ng0-components-stepper.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-table.mjs +304 -167
- package/fesm2022/bootkit-ng0-components-table.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-toast.mjs +62 -84
- package/fesm2022/bootkit-ng0-components-toast.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-tooltip.mjs +87 -74
- package/fesm2022/bootkit-ng0-components-tooltip.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs +171 -114
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-data.mjs +152 -39
- package/fesm2022/bootkit-ng0-data.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-date.mjs +50 -0
- package/fesm2022/bootkit-ng0-date.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-file.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-form.mjs +575 -264
- package/fesm2022/bootkit-ng0-form.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-http.mjs +61 -34
- package/fesm2022/bootkit-ng0-http.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-layouts-layout1.mjs +317 -0
- package/fesm2022/bootkit-ng0-layouts-layout1.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-localization-locales.mjs +103 -0
- package/fesm2022/bootkit-ng0-localization-locales.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-localization.mjs +431 -105
- package/fesm2022/bootkit-ng0-localization.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-platform-browser.mjs +179 -0
- package/fesm2022/bootkit-ng0-platform-browser.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-routing.mjs +80 -0
- package/fesm2022/bootkit-ng0-routing.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-script.mjs +3 -3
- package/fesm2022/bootkit-ng0-script.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-security.mjs +175 -40
- package/fesm2022/bootkit-ng0-security.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-utils.mjs +122 -0
- package/fesm2022/bootkit-ng0-utils.mjs.map +1 -0
- package/fesm2022/bootkit-ng0.mjs +2 -2
- package/fesm2022/bootkit-ng0.mjs.map +1 -1
- package/form/index.d.ts +153 -56
- package/http/index.d.ts +45 -14
- package/index.d.ts +2 -2
- package/layouts/layout1/index.d.ts +201 -0
- package/localization/index.d.ts +231 -42
- package/localization/locales/index.d.ts +7 -0
- package/package.json +57 -17
- package/platform/browser/index.d.ts +88 -0
- package/routing/index.d.ts +124 -0
- package/security/index.d.ts +76 -11
- package/utils/index.d.ts +63 -0
|
@@ -1,81 +1,134 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, Injectable, input, effect, Directive, NgModule } from '@angular/core';
|
|
2
|
+
import { signal, Injectable, inject, TemplateRef, ViewContainerRef, input, effect, Directive, NgModule } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
/** User */
|
|
5
5
|
class User {
|
|
6
|
-
claims;
|
|
6
|
+
claims = signal([], ...(ngDevMode ? [{ debugName: "claims" }] : []));
|
|
7
7
|
constructor(claims) {
|
|
8
|
-
this.claims
|
|
8
|
+
this.claims.set(claims);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
addClaim(claim) {
|
|
11
|
+
let currentClaims = this.claims();
|
|
12
|
+
if (currentClaims.includes(claim)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
this.claims.set([...currentClaims, claim]);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
removeClaim(claim) {
|
|
19
|
+
let currentClaims = this.claims();
|
|
20
|
+
if (!currentClaims.includes(claim)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
this.claims.set(currentClaims.filter(x => x !== claim));
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
hasAllClaims(claims) {
|
|
27
|
+
return claims.every(x => this.claims().some(y => x === y));
|
|
12
28
|
}
|
|
13
29
|
hasAnyClaim(claims) {
|
|
14
|
-
return claims.length == 0 || claims.some(x => this.claims.some(y => x === y));
|
|
30
|
+
return claims.length == 0 || claims.some(x => this.claims().some(y => x === y));
|
|
15
31
|
}
|
|
16
32
|
hasClaim(claim) {
|
|
17
33
|
var type = typeof claim;
|
|
18
34
|
if (type === 'string') {
|
|
19
|
-
return this.claims.some(x => x === claim);
|
|
35
|
+
return this.claims().some(x => x === claim);
|
|
20
36
|
}
|
|
21
37
|
if (type === 'object') {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
38
|
+
const claimObject = claim;
|
|
39
|
+
if (claimObject?.any && claimObject?.all) {
|
|
24
40
|
throw Error('Setting "any" and "all" at the same time is not valid.');
|
|
25
41
|
}
|
|
26
|
-
if (Array.isArray(
|
|
27
|
-
return this.hasAnyClaim(
|
|
42
|
+
if (Array.isArray(claimObject?.any)) {
|
|
43
|
+
return this.hasAnyClaim(claimObject.any);
|
|
28
44
|
}
|
|
29
|
-
if (Array.isArray(
|
|
30
|
-
return this.
|
|
45
|
+
if (Array.isArray(claimObject?.all)) {
|
|
46
|
+
return this.hasAllClaims(claimObject.all);
|
|
31
47
|
}
|
|
32
48
|
}
|
|
33
|
-
throw Error(
|
|
49
|
+
throw Error(`Invalid claim to check: ${JSON.stringify(claim)}`);
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Service to manage the current user state.
|
|
55
|
+
*/
|
|
37
56
|
class UserStore {
|
|
38
|
-
user = signal(undefined);
|
|
39
|
-
|
|
57
|
+
user = signal(undefined, ...(ngDevMode ? [{ debugName: "user" }] : []));
|
|
58
|
+
/**
|
|
59
|
+
* Check if the given condition is met by the current user.
|
|
60
|
+
* If there is no user, only 'false' condition is met.
|
|
61
|
+
* If there is a user, 'true' conditions and claims will be checked.
|
|
62
|
+
* @param condition The user condition to check
|
|
63
|
+
* @returns Whether the condition is met
|
|
64
|
+
*/
|
|
65
|
+
checkCondition(condition) {
|
|
66
|
+
let user = this.user();
|
|
67
|
+
if (user) {
|
|
68
|
+
if (condition === true) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
else if (condition === false) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return user.hasClaim(condition);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return condition === false;
|
|
80
|
+
}
|
|
40
81
|
}
|
|
41
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
42
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.
|
|
82
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: UserStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
83
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: UserStore, providedIn: 'root' });
|
|
43
84
|
}
|
|
44
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
85
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: UserStore, decorators: [{
|
|
45
86
|
type: Injectable,
|
|
46
87
|
args: [{ providedIn: 'root' }]
|
|
47
|
-
}]
|
|
88
|
+
}] });
|
|
48
89
|
|
|
49
|
-
|
|
50
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated use *ng0User instead
|
|
92
|
+
*/
|
|
93
|
+
class ClaimDirective {
|
|
51
94
|
_viewCreated = false;
|
|
52
|
-
|
|
95
|
+
_templateRef = inject((TemplateRef));
|
|
96
|
+
_viewContainer = inject(ViewContainerRef);
|
|
97
|
+
_userStore = inject(UserStore);
|
|
98
|
+
/**
|
|
99
|
+
* Claim to check
|
|
100
|
+
*/
|
|
101
|
+
claim = input('', ...(ngDevMode ? [{ debugName: "claim", alias: 'ng0Claim' }] : [{ alias: 'ng0Claim' }]));
|
|
102
|
+
constructor() {
|
|
53
103
|
effect(() => {
|
|
54
104
|
let claim = this.claim();
|
|
55
|
-
let user =
|
|
105
|
+
let user = this._userStore.user();
|
|
56
106
|
let show = !user ? false : (claim == undefined ? true : user.hasClaim(claim));
|
|
57
107
|
if (show && !this._viewCreated) {
|
|
58
|
-
|
|
108
|
+
this._viewContainer.createEmbeddedView(this._templateRef);
|
|
59
109
|
this._viewCreated = true;
|
|
60
110
|
}
|
|
61
111
|
else if (!show && this._viewCreated) {
|
|
62
|
-
|
|
112
|
+
this._viewContainer.clear();
|
|
63
113
|
this._viewCreated = false;
|
|
64
114
|
}
|
|
65
115
|
});
|
|
66
116
|
}
|
|
67
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
68
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.
|
|
117
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: ClaimDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
118
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.11", type: ClaimDirective, isStandalone: true, selector: "[ng0Claim]", inputs: { claim: { classPropertyName: "claim", publicName: "ng0Claim", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ng0Claim"], ngImport: i0 });
|
|
69
119
|
}
|
|
70
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
120
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: ClaimDirective, decorators: [{
|
|
71
121
|
type: Directive,
|
|
72
122
|
args: [{
|
|
73
123
|
selector: '[ng0Claim]',
|
|
74
124
|
exportAs: 'ng0Claim',
|
|
75
125
|
standalone: true
|
|
76
126
|
}]
|
|
77
|
-
}], ctorParameters: () => [
|
|
127
|
+
}], ctorParameters: () => [], propDecorators: { claim: [{ type: i0.Input, args: [{ isSignal: true, alias: "ng0Claim", required: false }] }] } });
|
|
78
128
|
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated use *ng0User directive instead
|
|
131
|
+
*/
|
|
79
132
|
class GuestUserDirective {
|
|
80
133
|
_created = false;
|
|
81
134
|
constructor(templateRef, viewContainer, userStore) {
|
|
@@ -91,10 +144,10 @@ class GuestUserDirective {
|
|
|
91
144
|
}
|
|
92
145
|
});
|
|
93
146
|
}
|
|
94
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
95
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.
|
|
147
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: GuestUserDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: UserStore }], target: i0.ɵɵFactoryTarget.Directive });
|
|
148
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.11", type: GuestUserDirective, isStandalone: true, selector: "[ng0GuestUser]", exportAs: ["ng0GuestUser"], ngImport: i0 });
|
|
96
149
|
}
|
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: GuestUserDirective, decorators: [{
|
|
98
151
|
type: Directive,
|
|
99
152
|
args: [{
|
|
100
153
|
selector: '[ng0GuestUser]',
|
|
@@ -104,17 +157,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
104
157
|
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: UserStore }] });
|
|
105
158
|
|
|
106
159
|
const items = [
|
|
107
|
-
|
|
160
|
+
ClaimDirective,
|
|
108
161
|
GuestUserDirective
|
|
109
162
|
];
|
|
110
163
|
class SecurityModule {
|
|
111
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
112
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.
|
|
113
|
-
GuestUserDirective], exports: [
|
|
164
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: SecurityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
165
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.11", ngImport: i0, type: SecurityModule, imports: [ClaimDirective,
|
|
166
|
+
GuestUserDirective], exports: [ClaimDirective,
|
|
114
167
|
GuestUserDirective] });
|
|
115
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.
|
|
168
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: SecurityModule });
|
|
116
169
|
}
|
|
117
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: SecurityModule, decorators: [{
|
|
118
171
|
type: NgModule,
|
|
119
172
|
args: [{
|
|
120
173
|
imports: items,
|
|
@@ -122,11 +175,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
122
175
|
}]
|
|
123
176
|
}] });
|
|
124
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Directive to conditionally display content based on user claims or conditions.
|
|
180
|
+
* If there is no condition provided, the content is always shown.
|
|
181
|
+
* If a condition is provided, it checks against the current user.
|
|
182
|
+
* @example
|
|
183
|
+
* ```html
|
|
184
|
+
* <ng-container *ng0User="true">
|
|
185
|
+
* This content is shown only if there is a logged-in user, regardless of claims.
|
|
186
|
+
* </ng-container>
|
|
187
|
+
* <ng-container *ng0User="false">
|
|
188
|
+
* This content is shown only if there is no logged-in user.
|
|
189
|
+
* </ng-container>
|
|
190
|
+
* <ng-container *ng0User="'admin'">
|
|
191
|
+
* This content is shown only if the user has the 'admin' claim.
|
|
192
|
+
* </ng-container>
|
|
193
|
+
* <ng-container *ng0User="{ all: ['read', 'write'] }">
|
|
194
|
+
* This content is shown only if the user has both 'read' and 'write' claims.
|
|
195
|
+
* </ng-container>
|
|
196
|
+
* <ng-container *ng0User="{ any: ['editor', 'contributor'] }">
|
|
197
|
+
* This content is shown if the user has either 'editor' or 'contributor' claims.
|
|
198
|
+
* </ng-container>
|
|
199
|
+
* <ng-container *ng0User="null">
|
|
200
|
+
* This content is always shown, regardless of user state.
|
|
201
|
+
* </ng-container>
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
class UserDirective {
|
|
205
|
+
_viewCreated = false;
|
|
206
|
+
_templateRef = inject((TemplateRef));
|
|
207
|
+
_viewContainer = inject(ViewContainerRef);
|
|
208
|
+
_userStore = inject(UserStore);
|
|
209
|
+
/**
|
|
210
|
+
* Show condition to check
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
condition = input('', ...(ngDevMode ? [{ debugName: "condition", alias: 'ng0User' }] : [{ alias: 'ng0User' }]));
|
|
214
|
+
constructor() {
|
|
215
|
+
effect(() => {
|
|
216
|
+
let condition = this.condition();
|
|
217
|
+
let user = this._userStore.user();
|
|
218
|
+
let show;
|
|
219
|
+
if (condition === null || condition === undefined) {
|
|
220
|
+
show = true;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (user) {
|
|
224
|
+
if (condition === true) {
|
|
225
|
+
show = true;
|
|
226
|
+
}
|
|
227
|
+
else if (condition === false) {
|
|
228
|
+
show = false;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
show = user.hasClaim(condition);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
show = condition === false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (show && !this._viewCreated) {
|
|
239
|
+
this._viewContainer.createEmbeddedView(this._templateRef);
|
|
240
|
+
this._viewCreated = true;
|
|
241
|
+
}
|
|
242
|
+
else if (!show && this._viewCreated) {
|
|
243
|
+
this._viewContainer.clear();
|
|
244
|
+
this._viewCreated = false;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: UserDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
249
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.11", type: UserDirective, isStandalone: true, selector: "[ng0User]", inputs: { condition: { classPropertyName: "condition", publicName: "ng0User", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ng0User"], ngImport: i0 });
|
|
250
|
+
}
|
|
251
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: UserDirective, decorators: [{
|
|
252
|
+
type: Directive,
|
|
253
|
+
args: [{
|
|
254
|
+
selector: '[ng0User]',
|
|
255
|
+
exportAs: 'ng0User',
|
|
256
|
+
standalone: true
|
|
257
|
+
}]
|
|
258
|
+
}], ctorParameters: () => [], propDecorators: { condition: [{ type: i0.Input, args: [{ isSignal: true, alias: "ng0User", required: false }] }] } });
|
|
259
|
+
|
|
125
260
|
// export * from './types';
|
|
126
261
|
|
|
127
262
|
/**
|
|
128
263
|
* Generated bundle index. Do not edit.
|
|
129
264
|
*/
|
|
130
265
|
|
|
131
|
-
export { GuestUserDirective, SecurityModule, User, UserDirective, UserStore };
|
|
266
|
+
export { ClaimDirective, GuestUserDirective, SecurityModule, User, UserDirective, UserStore };
|
|
132
267
|
//# sourceMappingURL=bootkit-ng0-security.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootkit-ng0-security.mjs","sources":["../../../projects/ng0/security/user.ts","../../../projects/ng0/security/user-store.ts","../../../projects/ng0/security/claim.directive.ts","../../../projects/ng0/security/guest-user.directive.ts","../../../projects/ng0/security/security.module.ts","../../../projects/ng0/security/public-api.ts","../../../projects/ng0/security/bootkit-ng0-security.ts"],"sourcesContent":["import { ClaimLike, ClaimObject } from '@bootkit/ng0/common';\r\n\r\n/** User */\r\nexport class User {\r\n constructor(public readonly claims: string[]) {\r\n }\r\n\r\n public hasClaims(claims: string[]): boolean {\r\n return claims.every(x => this.claims.some(y => x === y));\r\n }\r\n\r\n public hasAnyClaim(claims: string[]): boolean {\r\n return claims.length == 0 || claims.some(x => this.claims.some(y => x === y));\r\n }\r\n\r\n public hasClaim(claim: ClaimLike): boolean {\r\n var type = typeof claim;\r\n if (type === 'string') {\r\n return this.claims.some(x => x === claim);\r\n }\r\n\r\n if (type === 'object') {\r\n const co = claim as ClaimObject;\r\n if (co?.any && co?.all) {\r\n throw Error('Setting \"any\" and \"all\" at the same time is not valid.');\r\n }\r\n\r\n if (Array.isArray(co?.any)) {\r\n return this.hasAnyClaim(co.any);\r\n }\r\n if (Array.isArray(co?.all)) {\r\n return this.hasClaims(co.all);\r\n }\r\n }\r\n\r\n throw Error('Invalid claim');\r\n }\r\n}\r\n","import { User } from './user';\r\nimport { Injectable, signal } from '@angular/core';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class UserStore<U extends User = User> {\r\n public readonly user = signal<U | null | undefined>(undefined);\r\n\r\n constructor() {\r\n }\r\n}","import { Directive, TemplateRef, ViewContainerRef, input, effect } from '@angular/core';\r\n\r\nimport { UserStore } from './user-store';\r\nimport { ClaimLike } from '@bootkit/ng0/common';\r\n\r\n@Directive({\r\n selector: '[ng0Claim]',\r\n exportAs: 'ng0Claim',\r\n standalone: true\r\n})\r\nexport class UserDirective {\r\n public claim = input<ClaimLike | null | undefined>(undefined, { alias: 'ng0Claim' });\r\n private _viewCreated = false;\r\n\r\n constructor(\r\n templateRef: TemplateRef<any>,\r\n viewContainer: ViewContainerRef,\r\n userStore: UserStore,\r\n ) {\r\n effect(() => {\r\n let claim = this.claim();\r\n let user = userStore.user();\r\n let show = !user ? false : (claim == undefined ? true : user.hasClaim(claim))\r\n\r\n if (show && !this._viewCreated) {\r\n viewContainer.createEmbeddedView(templateRef);\r\n this._viewCreated = true;\r\n } else if (!show && this._viewCreated) {\r\n viewContainer.clear();\r\n this._viewCreated = false;\r\n }\r\n })\r\n }\r\n}\r\n","import { Directive, TemplateRef, ViewContainerRef, effect } from '@angular/core';\r\nimport { UserStore } from './user-store';\r\n\r\n@Directive({\r\n selector: '[ng0GuestUser]',\r\n exportAs: 'ng0GuestUser',\r\n standalone: true\r\n})\r\nexport class GuestUserDirective {\r\n private _created = false;\r\n\r\n constructor(\r\n templateRef: TemplateRef<any>,\r\n viewContainer: ViewContainerRef,\r\n userStore: UserStore,\r\n ) {\r\n effect(() => {\r\n let show = userStore.user() == undefined\r\n\r\n if (show && !this._created) {\r\n viewContainer.createEmbeddedView(templateRef);\r\n this._created = true;\r\n } else if (!show && this._created) {\r\n viewContainer.clear();\r\n this._created = false;\r\n }\r\n })\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { UserDirective } from './claim.directive';\r\nimport { GuestUserDirective } from './guest-user.directive';\r\n\r\nconst items = [\r\n UserDirective,\r\n GuestUserDirective\r\n]\r\n\r\n@NgModule({\r\n imports: items,\r\n exports: items\r\n})\r\nexport class SecurityModule { }\r\n","// export * from './types';\r\nexport * from './user';\r\nexport * from './user-store';\r\nexport * from './claim.directive';\r\nexport * from './guest-user.directive';\r\nexport * from './security.module';\r\n ","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.UserStore"],"mappings":";;;AAEA;MACa,IAAI,CAAA;AACe,IAAA,MAAA;AAA5B,IAAA,WAAA,CAA4B,MAAgB,EAAA;QAAhB,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B,IAAA,SAAS,CAAC,MAAgB,EAAA;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;AAGrD,IAAA,WAAW,CAAC,MAAgB,EAAA;AAC/B,QAAA,OAAO,MAAM,CAA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AAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACHD,MAAM,KAAK,GAAG;IACV,aAAa;IACb;CACH;MAMY,cAAc,CAAA;uGAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;AAAd,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,YARvB,aAAa;AACb,YAAA,kBAAkB,aADlB,aAAa;YACb,kBAAkB,CAAA,EAAA,CAAA;wGAOT,cAAc,EAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,OAAO,EAAE;AACZ,iBAAA;;;ACZD;;ACAA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"bootkit-ng0-security.mjs","sources":["../../../projects/ng0/security/user.ts","../../../projects/ng0/security/user-store.ts","../../../projects/ng0/security/claim.directive.ts","../../../projects/ng0/security/guest-user.directive.ts","../../../projects/ng0/security/security.module.ts","../../../projects/ng0/security/user.directive.ts","../../../projects/ng0/security/public-api.ts","../../../projects/ng0/security/bootkit-ng0-security.ts"],"sourcesContent":["import { signal } from '@angular/core';\nimport { ClaimLike, ClaimObject } from '@bootkit/ng0/common';\n\n/** User */\nexport class User {\n public readonly claims = signal<string[]>([]);\n\n constructor(claims: string[]) {\n this.claims.set(claims);\n }\n\n public addClaim(claim: string): boolean {\n let currentClaims = this.claims();\n if (currentClaims.includes(claim)) {\n return false;\n }\n this.claims.set([...currentClaims, claim]);\n return true;\n }\n\n public removeClaim(claim: string): boolean {\n let currentClaims = this.claims();\n if (!currentClaims.includes(claim)) {\n return false;\n }\n this.claims.set(currentClaims.filter(x => x !== claim));\n return true;\n }\n\n public hasAllClaims(claims: string[]): boolean {\n return claims.every(x => this.claims().some(y => x === y));\n }\n\n public hasAnyClaim(claims: string[]): boolean {\n return claims.length == 0 || claims.some(x => this.claims().some(y => x === y));\n }\n\n public hasClaim(claim: ClaimLike): boolean {\n var type = typeof claim;\n if (type === 'string') {\n return this.claims().some(x => x === claim);\n }\n\n if (type === 'object') {\n const claimObject = claim as ClaimObject;\n if (claimObject?.any && claimObject?.all) {\n throw Error('Setting \"any\" and \"all\" at the same time is not valid.');\n }\n\n if (Array.isArray(claimObject?.any)) {\n return this.hasAnyClaim(claimObject.any);\n }\n if (Array.isArray(claimObject?.all)) {\n return this.hasAllClaims(claimObject.all);\n }\n }\n\n throw Error(`Invalid claim to check: ${JSON.stringify(claim)}`);\n }\n}\n","import { Injectable, signal } from '@angular/core';\nimport { User } from './user';\nimport { UserCondition } from '@bootkit/ng0/common';\n\n/**\n * Service to manage the current user state.\n */\n@Injectable({ providedIn: 'root' })\nexport class UserStore<U extends User = User> {\n public readonly user = signal<U | null | undefined>(undefined);\n\n /**\n * Check if the given condition is met by the current user.\n * If there is no user, only 'false' condition is met.\n * If there is a user, 'true' conditions and claims will be checked.\n * @param condition The user condition to check\n * @returns Whether the condition is met\n */\n checkCondition(condition: UserCondition): boolean {\n let user = this.user();\n\n if (user) {\n if (condition === true) {\n return true;\n } else if (condition === false) {\n return false;\n } else {\n return user.hasClaim(condition);\n }\n } else {\n return condition === false;\n }\n }\n}","import { Directive, TemplateRef, ViewContainerRef, input, effect, inject } from '@angular/core';\nimport { UserStore } from './user-store';\nimport { ClaimLike } from '@bootkit/ng0/common';\n\n/**\n * @deprecated use *ng0User instead\n */\n@Directive({\n selector: '[ng0Claim]',\n exportAs: 'ng0Claim',\n standalone: true\n})\nexport class ClaimDirective {\n private _viewCreated = false;\n private _templateRef = inject(TemplateRef<any>);\n private _viewContainer = inject(ViewContainerRef);\n private _userStore = inject(UserStore);\n\n /**\n * Claim to check\n */\n public readonly claim = input<ClaimLike | null | undefined>('', { alias: 'ng0Claim' });\n\n constructor() {\n effect(() => {\n let claim = this.claim();\n let user = this._userStore.user();\n let show = !user ? false : (claim == undefined ? true : user.hasClaim(claim))\n\n if (show && !this._viewCreated) {\n this._viewContainer.createEmbeddedView(this._templateRef);\n this._viewCreated = true;\n } else if (!show && this._viewCreated) {\n this._viewContainer.clear();\n this._viewCreated = false;\n }\n })\n }\n}\n","import { Directive, TemplateRef, ViewContainerRef, effect } from '@angular/core';\nimport { UserStore } from './user-store';\n\n/**\n * @deprecated use *ng0User directive instead\n */\n@Directive({\n selector: '[ng0GuestUser]',\n exportAs: 'ng0GuestUser',\n standalone: true\n})\nexport class GuestUserDirective {\n private _created = false;\n\n constructor(\n templateRef: TemplateRef<any>,\n viewContainer: ViewContainerRef,\n userStore: UserStore,\n ) {\n effect(() => {\n let show = userStore.user() == undefined\n\n if (show && !this._created) {\n viewContainer.createEmbeddedView(templateRef);\n this._created = true;\n } else if (!show && this._created) {\n viewContainer.clear();\n this._created = false;\n }\n })\n }\n}\n","import { NgModule } from '@angular/core';\nimport { ClaimDirective } from './claim.directive';\nimport { GuestUserDirective } from './guest-user.directive';\n\nconst items = [\n ClaimDirective,\n GuestUserDirective\n]\n\n@NgModule({\n imports: items,\n exports: items\n})\nexport class SecurityModule { }\n","import { Directive, TemplateRef, ViewContainerRef, input, effect, inject } from '@angular/core';\nimport { UserStore } from './user-store';\nimport { UserCondition } from '@bootkit/ng0/common';\nimport { User } from './user';\n\n/**\n * Directive to conditionally display content based on user claims or conditions.\n * If there is no condition provided, the content is always shown.\n * If a condition is provided, it checks against the current user.\n * @example\n * ```html\n * <ng-container *ng0User=\"true\">\n * This content is shown only if there is a logged-in user, regardless of claims.\n * </ng-container>\n * <ng-container *ng0User=\"false\">\n * This content is shown only if there is no logged-in user.\n * </ng-container>\n * <ng-container *ng0User=\"'admin'\">\n * This content is shown only if the user has the 'admin' claim.\n * </ng-container>\n * <ng-container *ng0User=\"{ all: ['read', 'write'] }\">\n * This content is shown only if the user has both 'read' and 'write' claims.\n * </ng-container>\n * <ng-container *ng0User=\"{ any: ['editor', 'contributor'] }\">\n * This content is shown if the user has either 'editor' or 'contributor' claims.\n * </ng-container>\n * <ng-container *ng0User=\"null\">\n * This content is always shown, regardless of user state.\n * </ng-container>\n * ```\n */\n@Directive({\n selector: '[ng0User]',\n exportAs: 'ng0User',\n standalone: true\n})\nexport class UserDirective {\n private _viewCreated = false;\n private readonly _templateRef = inject(TemplateRef<any>);\n private readonly _viewContainer = inject(ViewContainerRef);\n private readonly _userStore = inject<UserStore<User>>(UserStore);\n\n /**\n * Show condition to check\n * \n */\n public readonly condition = input<UserCondition | null | undefined>('', { alias: 'ng0User' });\n\n constructor() {\n effect(() => {\n let condition = this.condition();\n let user = this._userStore.user();\n let show: boolean;\n\n if (condition === null || condition === undefined) {\n show = true;\n } else {\n if (user) {\n if (condition === true) {\n show = true;\n } else if (condition === false) {\n show = false;\n } else {\n show = user.hasClaim(condition);\n }\n } else {\n show = condition === false;\n }\n }\n\n if (show && !this._viewCreated) {\n this._viewContainer.createEmbeddedView(this._templateRef);\n this._viewCreated = true;\n } else if (!show && this._viewCreated) {\n this._viewContainer.clear();\n this._viewCreated = false;\n }\n })\n }\n}\n","// export * from './types';\nexport * from './user';\nexport * from './user-store';\nexport * from './claim.directive';\nexport * from './guest-user.directive';\nexport * from './security.module';\nexport * from './user.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.UserStore"],"mappings":";;;AAGA;MACa,IAAI,CAAA;AACG,IAAA,MAAM,GAAG,MAAM,CAAW,EAAE,kDAAC;AAE7C,IAAA,WAAA,CAAY,MAAgB,EAAA;AACxB,QAAA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AA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;4FAAb,aAAa,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,SAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;4FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBALzB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,WAAW;AACrB,oBAAA,QAAQ,EAAE,SAAS;AACnB,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACnCD;;ACAA;;AAEG;;;;"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, inject, RendererFactory2, Injectable } from '@angular/core';
|
|
3
|
+
import { interval, animationFrameScheduler, map, takeWhile } from 'rxjs';
|
|
4
|
+
import { DOCUMENT } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A counter that animates a numeric value from a start to an end value over a specified duration using an easing function.
|
|
8
|
+
*/
|
|
9
|
+
class Counter {
|
|
10
|
+
from;
|
|
11
|
+
to;
|
|
12
|
+
duration;
|
|
13
|
+
_subscription;
|
|
14
|
+
value = signal(0, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
15
|
+
running = signal(false, ...(ngDevMode ? [{ debugName: "running" }] : []));
|
|
16
|
+
easing;
|
|
17
|
+
constructor(from, to, duration = 1000, easing, currentValue) {
|
|
18
|
+
this.from = from;
|
|
19
|
+
this.to = to;
|
|
20
|
+
this.duration = duration;
|
|
21
|
+
if (to < from || duration <= 0) {
|
|
22
|
+
throw new Error('Invalid params');
|
|
23
|
+
}
|
|
24
|
+
this.easing = easing ?? easingFunctions.linear;
|
|
25
|
+
this.value.set(currentValue != null ? currentValue : this.from);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resets the counter and starts it.
|
|
29
|
+
* This method should be called in a browser environment.
|
|
30
|
+
* @returns void
|
|
31
|
+
*/
|
|
32
|
+
start() {
|
|
33
|
+
if (this.running())
|
|
34
|
+
return;
|
|
35
|
+
this.value.set(this.from);
|
|
36
|
+
this.running.set(true);
|
|
37
|
+
const startTime = performance.now();
|
|
38
|
+
const from = this.from;
|
|
39
|
+
const change = this.to - this.from;
|
|
40
|
+
this._subscription = interval(0, animationFrameScheduler)
|
|
41
|
+
.pipe(map(() => performance.now() - startTime), takeWhile(time => time <= this.duration, true), map(elapsed => {
|
|
42
|
+
const t = Math.min(1, elapsed / this.duration);
|
|
43
|
+
return from + change * this.easing(t);
|
|
44
|
+
}))
|
|
45
|
+
.subscribe({
|
|
46
|
+
next: val => this.value.set(val),
|
|
47
|
+
complete: () => {
|
|
48
|
+
this.running.set(false);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stops the counter animation.
|
|
54
|
+
*/
|
|
55
|
+
stop() {
|
|
56
|
+
this._subscription?.unsubscribe();
|
|
57
|
+
this.running.set(false);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A collection of common easing functions for animations.
|
|
62
|
+
*/
|
|
63
|
+
const easingFunctions = {
|
|
64
|
+
linear: (t) => t,
|
|
65
|
+
easeIn: (t) => t * t,
|
|
66
|
+
easeOut: (t) => t * (2 - t),
|
|
67
|
+
easeInOut: (t) => t < 0.5 ? (2 * t * t) : (-1 + (4 - 2 * t) * t),
|
|
68
|
+
smooth: (t) => t * t * (3 - 2 * t),
|
|
69
|
+
// smoother: (t: number) => t * t * t * (t * (6 - 15 * t) + 10)
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
class StyleManager {
|
|
73
|
+
_rendererFactory = inject(RendererFactory2);
|
|
74
|
+
_document = inject(DOCUMENT);
|
|
75
|
+
_renderer = this._rendererFactory.createRenderer(null, null);
|
|
76
|
+
_loadedStyles = new Map();
|
|
77
|
+
/**
|
|
78
|
+
* Loads a CSS
|
|
79
|
+
* @param url
|
|
80
|
+
* @returns Promise<HTMLLinkElement>
|
|
81
|
+
*/
|
|
82
|
+
load(url) {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
if (this._loadedStyles.has(url)) {
|
|
85
|
+
return resolve(this._loadedStyles.get(url));
|
|
86
|
+
}
|
|
87
|
+
const elm = this._renderer.createElement('link');
|
|
88
|
+
elm.rel = 'stylesheet';
|
|
89
|
+
elm.href = url;
|
|
90
|
+
elm.onload = (res) => {
|
|
91
|
+
this._loadedStyles.set(url, elm);
|
|
92
|
+
return resolve(elm);
|
|
93
|
+
};
|
|
94
|
+
this._document.head.append(elm);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Unloads a CSS from the DOM
|
|
99
|
+
* @param url
|
|
100
|
+
* @returns void
|
|
101
|
+
*/
|
|
102
|
+
unload(url) {
|
|
103
|
+
this._document.head.childNodes.forEach(x => {
|
|
104
|
+
// if(x.nodeName)
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: StyleManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
108
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: StyleManager, providedIn: 'root' });
|
|
109
|
+
}
|
|
110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.11", ngImport: i0, type: StyleManager, decorators: [{
|
|
111
|
+
type: Injectable,
|
|
112
|
+
args: [{
|
|
113
|
+
providedIn: 'root'
|
|
114
|
+
}]
|
|
115
|
+
}] });
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Generated bundle index. Do not edit.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
export { Counter, StyleManager, easingFunctions };
|
|
122
|
+
//# sourceMappingURL=bootkit-ng0-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootkit-ng0-utils.mjs","sources":["../../../projects/ng0/utils/counter.ts","../../../projects/ng0/utils/style-manager.ts","../../../projects/ng0/utils/bootkit-ng0-utils.ts"],"sourcesContent":["\nimport { signal } from '@angular/core';\nimport { animationFrameScheduler, interval, map, Subscription, takeWhile } from 'rxjs';\n\n/**\n * Easing function type definition.\n */\nexport type EasingFn = (t: number) => number;\n\n/**\n * A counter that animates a numeric value from a start to an end value over a specified duration using an easing function.\n */\nexport class Counter {\n private _subscription?: Subscription;\n public readonly value = signal(0);\n public readonly running = signal(false);\n public readonly easing: EasingFn;\n\n constructor(\n public readonly from: number,\n public readonly to: number,\n public readonly duration = 1000,\n easing?: EasingFn,\n currentValue?: number) {\n\n if (to < from || duration <= 0) {\n throw new Error('Invalid params');\n }\n\n this.easing = easing ?? easingFunctions.linear;\n this.value.set(currentValue != null ? currentValue : this.from);\n }\n\n /**\n * Resets the counter and starts it.\n * This method should be called in a browser environment.\n * @returns void\n */\n public start() {\n if (this.running()) return;\n\n this.value.set(this.from);\n this.running.set(true);\n\n const startTime = performance.now();\n const from = this.from;\n const change = this.to - this.from;\n\n this._subscription = interval(0, animationFrameScheduler)\n .pipe(\n map(() => performance.now() - startTime),\n takeWhile(time => time <= this.duration, true),\n map(elapsed => {\n const t = Math.min(1, elapsed / this.duration);\n return from + change * this.easing(t);\n })\n )\n .subscribe({\n next: val => this.value.set(val),\n complete: () => {\n this.running.set(false)\n }\n });\n }\n\n /**\n * Stops the counter animation.\n */\n public stop() {\n this._subscription?.unsubscribe();\n this.running.set(false);\n }\n}\n\n/**\n * A collection of common easing functions for animations.\n */\nexport const easingFunctions = {\n linear: (t: number) => t,\n easeIn: (t: number) => t * t,\n easeOut: (t: number) => t * (2 - t),\n easeInOut: (t: number) => t < 0.5 ? (2 * t * t) : (-1 + (4 - 2 * t) * t),\n smooth: (t: number) => t * t * (3 - 2 * t),\n // smoother: (t: number) => t * t * t * (t * (6 - 15 * t) + 10)\n};","import { Injectable, RendererFactory2, inject } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class StyleManager {\n private readonly _rendererFactory = inject(RendererFactory2);\n private readonly _document: Document = inject(DOCUMENT);\n private readonly _renderer = this._rendererFactory.createRenderer(null, null);\n private readonly _loadedStyles = new Map<string, HTMLLinkElement>();\n\n /**\n * Loads a CSS\n * @param url \n * @returns Promise<HTMLLinkElement>\n */\n public load(url: string): Promise<HTMLLinkElement> {\n return new Promise<HTMLLinkElement>((resolve, reject) => {\n\n if (this._loadedStyles.has(url)) {\n return resolve(this._loadedStyles.get(url)!);\n }\n\n const elm = this._renderer.createElement('link');\n elm.rel = 'stylesheet';\n elm.href = url;\n\n elm.onload = (res: any) => {\n this._loadedStyles.set(url, elm);\n return resolve(elm);\n }\n\n this._document.head.append(elm);\n });\n }\n\n /**\n * Unloads a CSS from the DOM\n * @param url \n * @returns void\n */\n public unload(url: string): void {\n this._document.head.childNodes.forEach(x => {\n // if(x.nodeName)\n });\n }\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AASA;;AAEG;MACU,OAAO,CAAA;AAOA,IAAA,IAAA;AACA,IAAA,EAAA;AACA,IAAA,QAAA;AARV,IAAA,aAAa;AACL,IAAA,KAAK,GAAG,MAAM,CAAC,CAAC,iDAAC;AACjB,IAAA,OAAO,GAAG,MAAM,CAAC,KAAK,mDAAC;AACvB,IAAA,MAAM;IAEtB,WAAA,CACkB,IAAY,EACZ,EAAU,EACV,WAAW,IAAI,E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GED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const libName = 'bootkit/ng0';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Public API Surface of bootkit
|
|
@@ -8,5 +8,5 @@ const LibName = 'bootkit/angular-pro';
|
|
|
8
8
|
* Generated bundle index. Do not edit.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { libName };
|
|
12
12
|
//# sourceMappingURL=bootkit-ng0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootkit-ng0.mjs","sources":["../../../projects/ng0/src/lib/index.ts","../../../projects/ng0/src/public-api.ts","../../../projects/ng0/src/bootkit-ng0.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"file":"bootkit-ng0.mjs","sources":["../../../projects/ng0/src/lib/index.ts","../../../projects/ng0/src/public-api.ts","../../../projects/ng0/src/bootkit-ng0.ts"],"sourcesContent":["export const libName = 'bootkit/ng0';","/*\n * Public API Surface of bootkit\n */\n\nexport * from './lib';\n \n \n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAO,MAAM,OAAO,GAAG;;ACAvB;;AAEG;;ACFH;;AAEG;;;;"}
|