@kuzntsv/uikit 1.0.25 → 1.0.27

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.
@@ -1,310 +1,294 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Injectable, signal, DestroyRef } from '@angular/core';
3
- import { HttpContextToken, HttpHeaders, HttpClient, HttpParams } from '@angular/common/http';
4
- import { Subject, tap, catchError, throwError } from 'rxjs';
5
- import { Router } from '@angular/router';
6
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
- import { MatSnackBar } from '@angular/material/snack-bar';
8
-
9
- const UIKIT_CONFIG = new InjectionToken('UIKIT_CONFIG');
10
-
11
- /**
12
- * Специальный маркер-роль в массиве ограничений,
13
- * который полностью скрывает элемент от обычных пользователей.
14
- */
15
- const HIDE_ROLE_MARKER = 'HIDE';
16
- /**
17
- * Системная роль Администратора, которая игнорирует любые ограничения прав.
18
- */
19
- const ADMIN_ROLE = 'ADMIN';
20
-
21
- // Токен, в который мы будем передавать строку-идентификатор нужного API
22
- // По умолчанию пустая строка означает "использовать дефолтное (основное) API"
23
- const API_NAME = new HttpContextToken(() => '');
24
- // Иногда внутри сервиса нужно сделать один специфический запрос (например, стянуть публичный JSON-файл конфигурации), не добавляя его глобально в publicUrls.
25
- // Используя подход с HttpContext, мы можем добавить в библиотеку маркер пропуска авторизации:
26
- // А в коде приложения вызывать так:
27
- // this.http.get('/assets/config.json', {
28
- // context: new HttpContext().set(BYPASS_AUTH, true)
29
- // });
1
+ import * as i0 from "@angular/core";
2
+ import { DestroyRef, Injectable, InjectionToken, inject, signal } from "@angular/core";
3
+ import { HttpClient, HttpContextToken, HttpHeaders, HttpParams } from "@angular/common/http";
4
+ import { Subject, catchError, tap, throwError } from "rxjs";
5
+ import { Router } from "@angular/router";
6
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
7
+ import { MatSnackBar } from "@angular/material/snack-bar";
8
+ const UIKIT_CONFIG = new InjectionToken("UIKIT_CONFIG");
9
+ const HIDE_ROLE_MARKER = "HIDE";
10
+ const ADMIN_ROLE = "ADMIN";
11
+ const API_NAME = new HttpContextToken(() => "");
30
12
  const BYPASS_AUTH = new HttpContextToken(() => false);
31
- // DI-токен, который переопределяем в appConfig
32
- const DEFAULT_TIMEOUT = new InjectionToken('DEFAULT_TIMEOUT', {
33
- providedIn: 'root',
34
- factory: () => 10000 // Запасной дефолт (10 сек), если в appConfig ничего не указали
13
+ const DEFAULT_TIMEOUT = new InjectionToken("DEFAULT_TIMEOUT", {
14
+ providedIn: "root",
15
+ factory: () => 1e4
35
16
  });
36
- // Если для каких-то тяжелых запросов (например, загрузка больших файлов или генерация отчетов)
37
- // вам нужно увеличить таймаут, вы можете передавать его значение прямо в запросе через HttpContext.
38
17
  const REQUEST_TIMEOUT = new HttpContextToken(() => inject(DEFAULT_TIMEOUT));
39
-
40
- ;
41
- const APP_ENVIRONMENT = new InjectionToken('ApplicationEnvironment');
42
-
43
- const UIKIT_NOTIFICATION_TOKEN = new InjectionToken('UikitNotificationToken');
44
-
45
- class AuthEventService {
46
- // Ошибки авторизации
47
- authErrorSource = new Subject();
48
- // Стрим для прослушивания ошибок авторизации (экспортируется наружу)
49
- authError$ = this.authErrorSource.asObservable();
50
- /** Вызывается в интерцепторе при 401 ошибке */
51
- notify401() {
52
- this.authErrorSource.next();
53
- }
54
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthEventService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
55
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthEventService, providedIn: 'root' });
56
- }
57
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthEventService, decorators: [{
58
- type: Injectable,
59
- args: [{ providedIn: 'root' }]
60
- }] });
61
-
62
- /**
63
- * Сущность пользователя из API
64
- */
65
- class User {
66
- id = 0;
67
- username = '';
68
- firstName = '';
69
- lastName = '';
70
- prof = '';
71
- depart = 0;
72
- area = '';
73
- tabnum = '';
74
- mail = '';
75
- phone = '';
76
- roles = '';
77
- rolesArray = [];
78
- roleList = [];
79
- idHuman = '';
80
- token = '';
81
- // Время действия токена
82
- expires_in = 0;
83
- }
84
- /**
85
- * Сервис для работы с объектом в local Storage
86
- */
87
- class UserService {
88
- user;
89
- config = inject(UIKIT_CONFIG);
90
- constructor() {
91
- const saved = localStorage.getItem(this.config.auth.userStorageKey);
92
- this.user = saved ? JSON.parse(saved) : new User();
93
- }
94
- get dept() {
95
- return this.user?.depart;
96
- }
97
- /** Получить данные о пользователе */
98
- get userData() {
99
- return this.user;
100
- }
101
- /** Изменить данные пользователя в localStorage */
102
- set userData(user) {
103
- this.user = user;
104
- localStorage.setItem(this.config.auth.userStorageKey, JSON.stringify(user));
105
- }
106
- /** Удаляет данные о пользователе из localStorage. */
107
- removeUser() {
108
- localStorage.removeItem(this.config.auth.userStorageKey);
109
- }
110
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: UserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
111
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: UserService, providedIn: 'root' });
112
- }
113
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: UserService, decorators: [{
114
- type: Injectable,
115
- args: [{
116
- providedIn: 'root'
117
- }]
118
- }], ctorParameters: () => [] });
119
-
120
- // interface RefreshResponse {
121
- // accessToken: string;
122
- // refreshToken: string;
123
- // }
124
- class AuthService {
125
- // Хранит роли пользователя
126
- _roles = signal([], ...(ngDevMode ? [{ debugName: "_roles" }] : /* istanbul ignore next */ []));
127
- // Состояние авторизации
128
- _loggedIn = signal(false, ...(ngDevMode ? [{ debugName: "_loggedIn" }] : /* istanbul ignore next */ []));
129
- roles = this._roles.asReadonly();
130
- loggedIn = this._loggedIn.asReadonly();
131
- // Заголовки для URL-encoded формы
132
- defaultOptions = {
133
- headers: new HttpHeaders().set('content-type', 'application/x-www-form-urlencoded'),
134
- };
135
- notificationService = inject(UIKIT_NOTIFICATION_TOKEN);
136
- userService = inject(UserService);
137
- eventService = inject(AuthEventService);
138
- destroyRef = inject(DestroyRef);
139
- http = inject(HttpClient);
140
- config = inject(UIKIT_CONFIG);
141
- // Внедряем роутер опционально, чтобы библиотека не падала, если роутера нет в приложении
142
- router = inject(Router, { optional: true });
143
- constructor() {
144
- const initialUser = this.userService.userData;
145
- if (initialUser?.token) {
146
- this._loggedIn.set(true);
147
- this._roles.set(initialUser.roleList ?? []);
148
- }
149
- // Слушаем шину событий: если интерцептор поймал 401, сбрасываем сессию
150
- this.eventService.authError$
151
- .pipe(takeUntilDestroyed(this.destroyRef))
152
- .subscribe(() => this.logout());
153
- }
154
- /**
155
- * Запрос авторизации
156
- * Возвращает Observable, позволяя компоненту реагировать на статус запроса.
157
- */
158
- login(username, password, idCas) {
159
- let params = new HttpParams()
160
- .set('username', username)
161
- .set('password', password); // HttpParams закодирует спецсимволы сам!
162
- if (idCas) {
163
- params = params.set('idcas', idCas.toString());
164
- }
165
- const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
166
- return this.http
167
- .post(url, params.toString(), this.defaultOptions)
168
- .pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
169
- console.log('Login error:', error);
170
- return throwError(() => error);
171
- }));
172
- }
173
- /** Aвторизация по пропуску */
174
- loginByPermit(permit, idCas) {
175
- let params = new HttpParams().set('permit', permit);
176
- if (idCas) {
177
- params = params.set('idcas', idCas.toString());
178
- }
179
- const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
180
- return this.http.post(url, params.toString(), this.defaultOptions).pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
181
- console.log('Permit login error:', error);
182
- return throwError(() => error);
183
- }));
184
- }
185
- logout() {
186
- // Убирает(удаляет) пользователя из локального хранилища когда он разлогинивается
187
- this.userService.removeUser();
188
- this._loggedIn.set(false);
189
- this._roles.set([]);
190
- // localStorage.removeItem(this.config.auth.userStorageKey);
191
- // localStorage.removeItem(this.config.auth.refreshTokenStorageKey);
192
- // ЛОГИКА СОХРАНЕНИЯ URL ПРИ РАЗЛОГИНЕ (Ваш улучшенный кусок кода)
193
- if (this.router) {
194
- const currentUrl = this.router.url;
195
- // Проверяем, не находимся ли мы уже на странице логина, чтобы избежать зацикливания
196
- if (currentUrl.includes(this.config.auth.loginRoute)) {
197
- return;
198
- }
199
- // Безопасное формирование query-параметров через Router
200
- this.router.navigate([this.config.auth.loginRoute], {
201
- queryParams: { returnUrl: encodeURIComponent(currentUrl) },
202
- });
203
- }
204
- }
205
- /** При успешной авторизации */
206
- successLoginAction(user) {
207
- this.userService.userData = user;
208
- this._loggedIn.set(true);
209
- this._roles.set(user.roleList ?? []);
210
- }
211
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
212
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthService, providedIn: 'root' });
213
- }
214
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AuthService, decorators: [{
215
- type: Injectable,
216
- args: [{ providedIn: 'root' }]
217
- }], ctorParameters: () => [] });
218
-
219
- /**
220
- * Проверяет, пересекаются ли два массива (есть ли хотя бы один общий элемент).
221
- */
18
+ const APP_ENVIRONMENT = new InjectionToken("ApplicationEnvironment");
19
+ const UIKIT_NOTIFICATION_TOKEN = new InjectionToken("UikitNotificationToken");
20
+ var AuthEventService = class AuthEventService {
21
+ authErrorSource = new Subject();
22
+ authError$ = this.authErrorSource.asObservable();
23
+ notify401() {
24
+ this.authErrorSource.next();
25
+ }
26
+ static ɵfac = i0.ɵɵngDeclareFactory({
27
+ minVersion: "12.0.0",
28
+ version: "22.2.2",
29
+ ngImport: i0,
30
+ type: AuthEventService,
31
+ deps: [],
32
+ target: i0.ɵɵFactoryTarget.Injectable
33
+ });
34
+ static ɵprov = i0.ɵɵngDeclareInjectable({
35
+ minVersion: "12.0.0",
36
+ version: "22.2.2",
37
+ ngImport: i0,
38
+ type: AuthEventService,
39
+ providedIn: "root"
40
+ });
41
+ };
42
+ i0.ɵɵngDeclareClassMetadata({
43
+ minVersion: "12.0.0",
44
+ version: "22.2.2",
45
+ ngImport: i0,
46
+ type: AuthEventService,
47
+ decorators: [{
48
+ type: Injectable,
49
+ args: [{ providedIn: "root" }]
50
+ }]
51
+ });
52
+ var User = class {
53
+ id = 0;
54
+ username = "";
55
+ firstName = "";
56
+ lastName = "";
57
+ prof = "";
58
+ depart = 0;
59
+ area = "";
60
+ tabnum = "";
61
+ mail = "";
62
+ phone = "";
63
+ roles = "";
64
+ rolesArray = [];
65
+ roleList = [];
66
+ idHuman = "";
67
+ token = "";
68
+ expires_in = 0;
69
+ };
70
+ var UserService = class UserService {
71
+ user;
72
+ config = inject(UIKIT_CONFIG);
73
+ constructor() {
74
+ const saved = localStorage.getItem(this.config.auth.userStorageKey);
75
+ this.user = saved ? JSON.parse(saved) : new User();
76
+ }
77
+ get dept() {
78
+ return this.user?.depart;
79
+ }
80
+ get userData() {
81
+ return this.user;
82
+ }
83
+ set userData(user) {
84
+ this.user = user;
85
+ localStorage.setItem(this.config.auth.userStorageKey, JSON.stringify(user));
86
+ }
87
+ removeUser() {
88
+ localStorage.removeItem(this.config.auth.userStorageKey);
89
+ }
90
+ static ɵfac = i0.ɵɵngDeclareFactory({
91
+ minVersion: "12.0.0",
92
+ version: "22.2.2",
93
+ ngImport: i0,
94
+ type: UserService,
95
+ deps: [],
96
+ target: i0.ɵɵFactoryTarget.Injectable
97
+ });
98
+ static ɵprov = i0.ɵɵngDeclareInjectable({
99
+ minVersion: "12.0.0",
100
+ version: "22.2.2",
101
+ ngImport: i0,
102
+ type: UserService,
103
+ providedIn: "root"
104
+ });
105
+ };
106
+ i0.ɵɵngDeclareClassMetadata({
107
+ minVersion: "12.0.0",
108
+ version: "22.2.2",
109
+ ngImport: i0,
110
+ type: UserService,
111
+ decorators: [{
112
+ type: Injectable,
113
+ args: [{ providedIn: "root" }]
114
+ }],
115
+ ctorParameters: () => []
116
+ });
117
+ var AuthService = class AuthService {
118
+ _roles = signal([], ...ngDevMode ? [{ debugName: "_roles" }] : /* istanbul ignore next */ []);
119
+ _loggedIn = signal(false, ...ngDevMode ? [{ debugName: "_loggedIn" }] : /* istanbul ignore next */ []);
120
+ roles = this._roles.asReadonly();
121
+ loggedIn = this._loggedIn.asReadonly();
122
+ defaultOptions = { headers: new HttpHeaders().set("content-type", "application/x-www-form-urlencoded") };
123
+ notificationService = inject(UIKIT_NOTIFICATION_TOKEN);
124
+ userService = inject(UserService);
125
+ eventService = inject(AuthEventService);
126
+ destroyRef = inject(DestroyRef);
127
+ http = inject(HttpClient);
128
+ config = inject(UIKIT_CONFIG);
129
+ router = inject(Router, { optional: true });
130
+ constructor() {
131
+ const initialUser = this.userService.userData;
132
+ if (initialUser?.token) {
133
+ this._loggedIn.set(true);
134
+ this._roles.set(initialUser.roleList ?? []);
135
+ }
136
+ this.eventService.authError$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.logout());
137
+ }
138
+ login(username, password, idCas) {
139
+ let params = new HttpParams().set("username", username).set("password", password);
140
+ if (idCas) params = params.set("idcas", idCas.toString());
141
+ const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
142
+ return this.http.post(url, params.toString(), this.defaultOptions).pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
143
+ console.log("Login error:", error);
144
+ return throwError(() => error);
145
+ }));
146
+ }
147
+ loginByPermit(permit, idCas) {
148
+ let params = new HttpParams().set("permit", permit);
149
+ if (idCas) params = params.set("idcas", idCas.toString());
150
+ const url = `${this.config.apiUrls.auth}${this.config.auth.tokenRoute}`;
151
+ return this.http.post(url, params.toString(), this.defaultOptions).pipe(tap((data) => this.successLoginAction(data)), catchError((error) => {
152
+ console.log("Permit login error:", error);
153
+ return throwError(() => error);
154
+ }));
155
+ }
156
+ logout() {
157
+ this.userService.removeUser();
158
+ this._loggedIn.set(false);
159
+ this._roles.set([]);
160
+ if (this.router) {
161
+ const currentUrl = this.router.url;
162
+ if (currentUrl.includes(this.config.auth.loginRoute)) return;
163
+ this.router.navigate([this.config.auth.loginRoute], { queryParams: { returnUrl: encodeURIComponent(currentUrl) } });
164
+ }
165
+ }
166
+ successLoginAction(user) {
167
+ this.userService.userData = user;
168
+ this._loggedIn.set(true);
169
+ this._roles.set(user.roleList ?? []);
170
+ }
171
+ static ɵfac = i0.ɵɵngDeclareFactory({
172
+ minVersion: "12.0.0",
173
+ version: "22.2.2",
174
+ ngImport: i0,
175
+ type: AuthService,
176
+ deps: [],
177
+ target: i0.ɵɵFactoryTarget.Injectable
178
+ });
179
+ static ɵprov = i0.ɵɵngDeclareInjectable({
180
+ minVersion: "12.0.0",
181
+ version: "22.2.2",
182
+ ngImport: i0,
183
+ type: AuthService,
184
+ providedIn: "root"
185
+ });
186
+ };
187
+ i0.ɵɵngDeclareClassMetadata({
188
+ minVersion: "12.0.0",
189
+ version: "22.2.2",
190
+ ngImport: i0,
191
+ type: AuthService,
192
+ decorators: [{
193
+ type: Injectable,
194
+ args: [{ providedIn: "root" }]
195
+ }],
196
+ ctorParameters: () => []
197
+ });
222
198
  function hasArrayIntersection(arrayA, arrayB) {
223
- if (!arrayA || !arrayB)
224
- return false;
225
- return arrayA.some(item => arrayB.includes(item));
226
- }
227
-
228
- /** Вычисление разрешений по ролям */
229
- class RoleService {
230
- authService = inject(AuthService);
231
- /**
232
- * Проверяет, заблокирован ли доступ к элементу на основе списка ограничений.
233
- * Возвращает true, если у пользователя есть запрещенная роль или передан маркер 'HIDE'.
234
- * Администратор (ADMIN) всегда игнорирует любые запреты и маркер 'HIDE'.
235
- */
236
- hasForbiddenRole(forbiddenRoles) {
237
- if (!forbiddenRoles || forbiddenRoles.length === 0)
238
- return false;
239
- const userRoles = this.authService.roles() ?? [];
240
- // Если пользователь ADMIN — он игнорирует списки запретов
241
- if (userRoles.includes(ADMIN_ROLE))
242
- return false;
243
- // Если в условиях зашит маркер 'HIDE' — скрываем элемент от обычного пользователя
244
- if (forbiddenRoles.includes(HIDE_ROLE_MARKER))
245
- return true;
246
- // В остальных случаях проверяем стандартное пересечение ролей
247
- return hasArrayIntersection(userRoles, forbiddenRoles);
248
- }
249
- /**
250
- * Проверяет, есть ли у пользователя хотя бы одна из разрешенных ролей.
251
- * ADMIN всегда возвращает true.
252
- */
253
- hasAnyRole(allowedRoles) {
254
- const userRoles = this.authService.roles() ?? [];
255
- if (userRoles.includes(ADMIN_ROLE))
256
- return true;
257
- return hasArrayIntersection(userRoles, allowedRoles);
258
- }
259
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
260
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, providedIn: 'root' });
261
- }
262
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: RoleService, decorators: [{
263
- type: Injectable,
264
- args: [{
265
- providedIn: 'root',
266
- }]
267
- }] });
268
-
269
- // Сервис для вывода сообщений(ошибки, успеха)
270
- class NotificationService {
271
- // eslint-disable-next-line no-magic-numbers
272
- duration = 5000;
273
- _snackBar = inject(MatSnackBar);
274
- openSnackBar(message, action, duration = this.duration) {
275
- this._snackBar.open(message, action, {
276
- duration,
277
- panelClass: ['red-snackbar'],
278
- });
279
- }
280
- success(message, duration = this.duration) {
281
- this.openSnackBar(message, 'Закрыть', duration);
282
- }
283
- info(message, duration = this.duration) {
284
- this.openSnackBar(message, 'Закрыть', duration);
285
- }
286
- helper(message, duration = this.duration) {
287
- this.openSnackBar(message, 'Закрыть', duration);
288
- }
289
- warning(message, duration = this.duration) {
290
- this.openSnackBar(message, 'Закрыть', duration);
291
- }
292
- error(message, duration = this.duration) {
293
- this.openSnackBar(message, 'Закрыть', duration);
294
- }
295
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
296
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: NotificationService, providedIn: 'root' });
199
+ if (!arrayA || !arrayB) return false;
200
+ return arrayA.some((item) => arrayB.includes(item));
297
201
  }
298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: NotificationService, decorators: [{
299
- type: Injectable,
300
- args: [{
301
- providedIn: 'root'
302
- }]
303
- }] });
304
-
305
- /**
306
- * Generated bundle index. Do not edit.
307
- */
308
-
202
+ var RoleService = class RoleService {
203
+ authService = inject(AuthService);
204
+ hasForbiddenRole(forbiddenRoles) {
205
+ if (!forbiddenRoles || forbiddenRoles.length === 0) return false;
206
+ const userRoles = this.authService.roles() ?? [];
207
+ if (userRoles.includes("ADMIN")) return false;
208
+ if (forbiddenRoles.includes("HIDE")) return true;
209
+ return hasArrayIntersection(userRoles, forbiddenRoles);
210
+ }
211
+ hasAnyRole(allowedRoles) {
212
+ const userRoles = this.authService.roles() ?? [];
213
+ if (userRoles.includes("ADMIN")) return true;
214
+ return hasArrayIntersection(userRoles, allowedRoles);
215
+ }
216
+ static ɵfac = i0.ɵɵngDeclareFactory({
217
+ minVersion: "12.0.0",
218
+ version: "22.2.2",
219
+ ngImport: i0,
220
+ type: RoleService,
221
+ deps: [],
222
+ target: i0.ɵɵFactoryTarget.Injectable
223
+ });
224
+ static ɵprov = i0.ɵɵngDeclareInjectable({
225
+ minVersion: "12.0.0",
226
+ version: "22.2.2",
227
+ ngImport: i0,
228
+ type: RoleService,
229
+ providedIn: "root"
230
+ });
231
+ };
232
+ i0.ɵɵngDeclareClassMetadata({
233
+ minVersion: "12.0.0",
234
+ version: "22.2.2",
235
+ ngImport: i0,
236
+ type: RoleService,
237
+ decorators: [{
238
+ type: Injectable,
239
+ args: [{ providedIn: "root" }]
240
+ }]
241
+ });
242
+ var NotificationService = class NotificationService {
243
+ duration = 5e3;
244
+ _snackBar = inject(MatSnackBar);
245
+ openSnackBar(message, action, duration = this.duration) {
246
+ this._snackBar.open(message, action, {
247
+ duration,
248
+ panelClass: ["red-snackbar"]
249
+ });
250
+ }
251
+ success(message, duration = this.duration) {
252
+ this.openSnackBar(message, "Закрыть", duration);
253
+ }
254
+ info(message, duration = this.duration) {
255
+ this.openSnackBar(message, "Закрыть", duration);
256
+ }
257
+ helper(message, duration = this.duration) {
258
+ this.openSnackBar(message, "Закрыть", duration);
259
+ }
260
+ warning(message, duration = this.duration) {
261
+ this.openSnackBar(message, "Закрыть", duration);
262
+ }
263
+ error(message, duration = this.duration) {
264
+ this.openSnackBar(message, "Закрыть", duration);
265
+ }
266
+ static ɵfac = i0.ɵɵngDeclareFactory({
267
+ minVersion: "12.0.0",
268
+ version: "22.2.2",
269
+ ngImport: i0,
270
+ type: NotificationService,
271
+ deps: [],
272
+ target: i0.ɵɵFactoryTarget.Injectable
273
+ });
274
+ static ɵprov = i0.ɵɵngDeclareInjectable({
275
+ minVersion: "12.0.0",
276
+ version: "22.2.2",
277
+ ngImport: i0,
278
+ type: NotificationService,
279
+ providedIn: "root"
280
+ });
281
+ };
282
+ i0.ɵɵngDeclareClassMetadata({
283
+ minVersion: "12.0.0",
284
+ version: "22.2.2",
285
+ ngImport: i0,
286
+ type: NotificationService,
287
+ decorators: [{
288
+ type: Injectable,
289
+ args: [{ providedIn: "root" }]
290
+ }]
291
+ });
309
292
  export { ADMIN_ROLE, API_NAME, APP_ENVIRONMENT, AuthEventService, AuthService, BYPASS_AUTH, DEFAULT_TIMEOUT, HIDE_ROLE_MARKER, NotificationService, REQUEST_TIMEOUT, RoleService, UIKIT_CONFIG, UIKIT_NOTIFICATION_TOKEN, User, UserService, hasArrayIntersection };
310
- //# sourceMappingURL=kuzntsv-uikit.mjs.map
293
+
294
+ //# sourceMappingURL=kuzntsv-uikit.mjs.map