@kuzntsv/uikit 1.0.98 → 1.0.99

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,21 +1,21 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { ChangeDetectionStrategy, Component, Directive, ElementRef, Injectable, InjectionToken, Injector, NgZone, Pipe, Service, computed, debounced, effect, inject, input, linkedSignal, makeEnvironmentProviders, model, output, signal, untracked, viewChild } from "@angular/core";
3
3
  import { Router, RouterLink } from "@angular/router";
4
- import { API_NAME, AuthService, HIDE_ROLE_MARKER, LoaderService, NotificationService, RoleService, SignalSelectionModel, UIKIT_NOTIFICATION_TOKEN, formatZodError } from "@kuzntsv/uikit";
4
+ import { API_NAME, AuthService, HIDE_ROLE_MARKER, LoaderService, NotificationService, RoleService, SKIP_LOADER, SKIP_NOTIFICATION, SignalSelectionModel, UIKIT_NOTIFICATION_TOKEN, formatZodError } from "@kuzntsv/uikit";
5
5
  import { ReplaySubject, Subject, Subscription, filter, forkJoin, lastValueFrom, map, of, switchMap, take, tap } from "rxjs";
6
6
  import { MatAnchor, MatButton, MatIconButton } from "@angular/material/button";
7
7
  import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from "@angular/material/card";
8
8
  import { MatError, MatFormField, MatHint, MatLabel, MatSuffix } from "@angular/material/form-field";
9
9
  import { MatIcon } from "@angular/material/icon";
10
10
  import { MatInput } from "@angular/material/input";
11
- import { FormField, FormRoot, debounce, disabled, form, validateStandardSchema } from "@angular/forms/signals";
11
+ import { FormField, FormRoot, debounce, disabled, form, validateHttp, validateStandardSchema } from "@angular/forms/signals";
12
12
  import z, { z as z$1 } from "zod";
13
13
  import { MatDivider } from "@angular/material/divider";
14
14
  import { MatMenu, MatMenuContent, MatMenuItem, MatMenuTrigger } from "@angular/material/menu";
15
15
  import { MatToolbar } from "@angular/material/toolbar";
16
16
  import * as i4 from "@angular/material/tooltip";
17
17
  import { MatTooltip, MatTooltipModule } from "@angular/material/tooltip";
18
- import { HttpClient, HttpContext, HttpParams, httpResource } from "@angular/common/http";
18
+ import { HttpClient, HttpContext, HttpErrorResponse, HttpParams, httpResource } from "@angular/common/http";
19
19
  import { DomSanitizer } from "@angular/platform-browser";
20
20
  import { catchError, map as map$1 } from "rxjs/operators";
21
21
  import { MAT_DIALOG_DATA, MatDialog, MatDialogActions, MatDialogClose, MatDialogConfig, MatDialogContent, MatDialogRef, MatDialogTitle } from "@angular/material/dialog";
@@ -5289,6 +5289,70 @@ i0.ɵɵngDeclareClassMetadata({
5289
5289
  }]
5290
5290
  }
5291
5291
  });
5292
- export { Action, AvatarService, BaseEditClass, BaseFilterClass, BaseNavBarMenuClass, BasePageClass, BaseSchema, BaseServiceClass, BaseSignalEditClass, BaseSignalFilterClass, BaseSignalPageClass, BaseSignalServiceClass, BaseToolbarComponent, ChipInputAutocompleteComponent, CustomDateAdapter, DateRangeInputComponent, DialogAction, DialogComponent, DisableIfRoleDirective, EmptyComponent, EntityAction, ExportService, HideIfForbiddenRoleDirective, LOGGER_CONFIG, LocalStorageService, LoggerService, LoginPageComponent, MY_NATIVE_FORMATS, NavBarComponent, NotFoundComponent, PageStateSchema, SafePipe, SecureImageService, SelectAutocompleteWithVsComponent, SelectWithGroupComponent, SetValueDirective, SortDirectionSchema, SortStateSchema, SseService, TableComponent, TableStateSchema, TimePipe, TruncatePipe, authGuard, dateRangeFormSchema, dateRangeSchema, provideLogger, redirectGuard, roleGuard, secUserSchema };
5292
+ function uniqueCodeValidator(field, formSchema, options) {
5293
+ validateHttp(field, {
5294
+ debounce: 500,
5295
+ request: ({ value }) => {
5296
+ const code = value();
5297
+ if (code === null || code === void 0) return void 0;
5298
+ const divider = options.useEquals ? "=" : "/";
5299
+ return {
5300
+ url: `${options.endpoint}${divider}${encodeURIComponent(code)}`,
5301
+ method: "GET",
5302
+ options: { context: new HttpContext().set(SKIP_NOTIFICATION, true).set(SKIP_LOADER, true) }
5303
+ };
5304
+ },
5305
+ onSuccess: (foundEntity, { value, valueOf }) => {
5306
+ if (!foundEntity) return null;
5307
+ const currentId = valueOf(formSchema.id);
5308
+ const currentCode = value() || 0;
5309
+ return currentId === foundEntity.id || currentId !== foundEntity.id && currentCode !== foundEntity.code ? null : {
5310
+ kind: "uniqueCode",
5311
+ message: options.errorMessage
5312
+ };
5313
+ },
5314
+ onError: (error) => {
5315
+ if (error instanceof HttpErrorResponse && error.status === 404) return null;
5316
+ console.error(`Ошибка валидации кода на ${options.endpoint}:`, error);
5317
+ return {
5318
+ kind: "serverError",
5319
+ message: "Не удалось проверить код на сервере"
5320
+ };
5321
+ }
5322
+ });
5323
+ }
5324
+ function uniqueNameValidator(field, formSchema, options) {
5325
+ validateHttp(field, {
5326
+ debounce: 500,
5327
+ request: ({ value }) => {
5328
+ const name = (value() || "").trim();
5329
+ if (!name) return void 0;
5330
+ const divider = options.useEquals ? "=" : "/";
5331
+ return {
5332
+ url: `${options.endpoint}${divider}${encodeURIComponent(name)}`,
5333
+ method: "GET",
5334
+ options: { context: new HttpContext().set(SKIP_NOTIFICATION, true).set(SKIP_LOADER, true) }
5335
+ };
5336
+ },
5337
+ onSuccess: (foundEntity, { value, valueOf }) => {
5338
+ if (!foundEntity) return null;
5339
+ const currentId = valueOf(formSchema.id);
5340
+ const currentName = (value() || "").trim();
5341
+ return currentId === foundEntity.id || currentId !== foundEntity.id && currentName.toUpperCase() !== foundEntity.name.toUpperCase() ? null : {
5342
+ kind: "uniqueName",
5343
+ message: options.errorMessage
5344
+ };
5345
+ },
5346
+ onError: (error) => {
5347
+ if (error instanceof HttpErrorResponse && error.status === 404) return null;
5348
+ console.error(`Ошибка валидации имени на ${options.endpoint}:`, error);
5349
+ return {
5350
+ kind: "serverError",
5351
+ message: "Не удалось проверить имя на сервере"
5352
+ };
5353
+ }
5354
+ });
5355
+ }
5356
+ export { Action, AvatarService, BaseEditClass, BaseFilterClass, BaseNavBarMenuClass, BasePageClass, BaseSchema, BaseServiceClass, BaseSignalEditClass, BaseSignalFilterClass, BaseSignalPageClass, BaseSignalServiceClass, BaseToolbarComponent, ChipInputAutocompleteComponent, CustomDateAdapter, DateRangeInputComponent, DialogAction, DialogComponent, DisableIfRoleDirective, EmptyComponent, EntityAction, ExportService, HideIfForbiddenRoleDirective, LOGGER_CONFIG, LocalStorageService, LoggerService, LoginPageComponent, MY_NATIVE_FORMATS, NavBarComponent, NotFoundComponent, PageStateSchema, SafePipe, SecureImageService, SelectAutocompleteWithVsComponent, SelectWithGroupComponent, SetValueDirective, SortDirectionSchema, SortStateSchema, SseService, TableComponent, TableStateSchema, TimePipe, TruncatePipe, authGuard, dateRangeFormSchema, dateRangeSchema, provideLogger, redirectGuard, roleGuard, secUserSchema, uniqueCodeValidator, uniqueNameValidator };
5293
5357
 
5294
5358
  //# sourceMappingURL=kuzntsv-uikit-ui.mjs.map