@edsis/angular 22.1.0 → 22.1.3

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,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, inject, signal, computed, makeEnvironmentProviders, provideAppInitializer, Service, Component, DestroyRef, Injector, viewChild, ElementRef, effect, afterNextRender, input } from '@angular/core';
2
+ import { InjectionToken, Service, inject, signal, computed, makeEnvironmentProviders, provideAppInitializer, Component, DestroyRef, Injector, viewChild, ElementRef, effect, afterNextRender, input, untracked } from '@angular/core';
3
3
  import { HttpClient, HttpErrorResponse, HttpContextToken, HttpContext, provideHttpClient, withFetch, withInterceptors } from '@angular/common/http';
4
4
  import { provideApiConfiguration } from '@edsis/sdk/shared';
5
5
  import { Router, RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
6
6
  import { setNativeNotificationBadge, RuntimeContextService, NativeHostService } from '@edsis/angular/services/runtime';
7
- import { firstValueFrom, throwError, from, timeout, startWith, finalize } from 'rxjs';
7
+ import { firstValueFrom, throwError, from, timeout, finalize } from 'rxjs';
8
8
  import { catchError, switchMap } from 'rxjs/operators';
9
9
  import { DOCUMENT, Location } from '@angular/common';
10
10
  import { LayoutService, LayoutComponent, DesktopAppBarComponent, LayoutFluidComponent } from '@edsis/theme/layout';
@@ -15,8 +15,7 @@ import { AspectRatioComponent } from '@edsis/component/aspect-ratio';
15
15
  import { ButtonComponent } from '@edsis/component/button';
16
16
  import { CardActionComponent, CardComponent, CardContentComponent, CardDescriptionComponent, CardFooterComponent, CardHeaderComponent, CardTitleComponent } from '@edsis/component/card';
17
17
  import { SpinnerComponent } from '@edsis/component/spinner';
18
- import * as i1 from '@angular/forms';
19
- import { FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
18
+ import { form, required, email, maxLength, submit, FormField } from '@angular/forms/signals';
20
19
  import { InputGroupAddonComponent, InputGroupButtonComponent, InputGroupComponent, InputGroupInputComponent } from '@edsis/component/input-group';
21
20
  import { LabelComponent } from '@edsis/component/label';
22
21
  import { SeparatorComponent } from '@edsis/component/separator';
@@ -253,11 +252,12 @@ class TauriNativeGoogleAuthAdapter {
253
252
  const { invoke } = await import('@tauri-apps/api/core');
254
253
  await invoke('plugin:edsis-google-auth|sign_out');
255
254
  }
256
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: TauriNativeGoogleAuthAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
257
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: TauriNativeGoogleAuthAdapter });
255
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: TauriNativeGoogleAuthAdapter, deps: [], target: i0.ɵɵFactoryTarget.Service });
256
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: TauriNativeGoogleAuthAdapter, autoProvided: false });
258
257
  }
259
258
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: TauriNativeGoogleAuthAdapter, decorators: [{
260
- type: Injectable
259
+ type: Service,
260
+ args: [{ autoProvided: false }]
261
261
  }] });
262
262
  function isNativeGoogleSignInResult(value) {
263
263
  if (typeof value !== 'object' || value === null || Array.isArray(value)) {
@@ -422,12 +422,11 @@ class AuthService {
422
422
  // sign-out failure must not restore or persist the application session.
423
423
  }
424
424
  }
425
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
426
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthService, providedIn: 'root' });
425
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Service });
426
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: AuthService });
427
427
  }
428
428
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthService, decorators: [{
429
- type: Injectable,
430
- args: [{ providedIn: 'root' }]
429
+ type: Service
431
430
  }] });
432
431
 
433
432
  const EDSIS_SKIP_AUTH = new HttpContextToken(() => false);
@@ -543,11 +542,12 @@ class AuthHealthService {
543
542
  this.inFlight = false;
544
543
  }
545
544
  }
546
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthHealthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
547
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthHealthService });
545
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthHealthService, deps: [], target: i0.ɵɵFactoryTarget.Service });
546
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: AuthHealthService, autoProvided: false });
548
547
  }
549
548
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthHealthService, decorators: [{
550
- type: Injectable
549
+ type: Service,
550
+ args: [{ autoProvided: false }]
551
551
  }] });
552
552
 
553
553
  class NativeGoogleAuthService {
@@ -613,11 +613,12 @@ class NativeGoogleAuthService {
613
613
  idToken = '';
614
614
  }
615
615
  }
616
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: NativeGoogleAuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
617
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: NativeGoogleAuthService });
616
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: NativeGoogleAuthService, deps: [], target: i0.ɵɵFactoryTarget.Service });
617
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: NativeGoogleAuthService, autoProvided: false });
618
618
  }
619
619
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: NativeGoogleAuthService, decorators: [{
620
- type: Injectable
620
+ type: Service,
621
+ args: [{ autoProvided: false }]
621
622
  }] });
622
623
  function toNativePlatform(platform) {
623
624
  return platform === 'ios' || platform === 'android' ? platform : null;
@@ -1386,7 +1387,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
1386
1387
  class AuthLoginPage {
1387
1388
  documentRef = inject(DOCUMENT);
1388
1389
  destroyRef = inject(DestroyRef);
1389
- formBuilder = inject(FormBuilder);
1390
1390
  injector = inject(Injector);
1391
1391
  authMagicLinkService = inject(AuthMagicLinkService);
1392
1392
  authConfig = inject(EDSIS_AUTH_CONFIG);
@@ -1415,24 +1415,22 @@ class AuthLoginPage {
1415
1415
  ? this.messages.google.nativeSignInInProgress
1416
1416
  : this.messages.google.googleRedirecting, /* @ts-ignore */
1417
1417
  ...(ngDevMode ? [{ debugName: "googleProgressMessage" }] : /* istanbul ignore next */ []));
1418
- form = this.formBuilder.nonNullable.group({
1419
- email: ['', [Validators.required, Validators.email, Validators.maxLength(255)]],
1418
+ loginModel = signal({ email: '' }, /* @ts-ignore */
1419
+ ...(ngDevMode ? [{ debugName: "loginModel" }] : /* istanbul ignore next */ []));
1420
+ form = form(this.loginModel, (path) => {
1421
+ required(path.email);
1422
+ email(path.email);
1423
+ maxLength(path.email, 255);
1420
1424
  });
1421
- isSubmitting = signal(false, /* @ts-ignore */
1422
- ...(ngDevMode ? [{ debugName: "isSubmitting" }] : /* istanbul ignore next */ []));
1423
1425
  responseMessage = signal(null, /* @ts-ignore */
1424
1426
  ...(ngDevMode ? [{ debugName: "responseMessage" }] : /* istanbul ignore next */ []));
1425
1427
  errorMessage = signal(null, /* @ts-ignore */
1426
1428
  ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
1427
- emailControl = this.form.controls.email;
1428
1429
  emailFeedbackId = 'email-feedback';
1429
1430
  healthBannerId = 'auth-health-banner';
1430
1431
  // `button[Button]` adalah komponen, jadi tanpa `read` query template-ref ini
1431
1432
  // mengembalikan instance ButtonComponent — bukan elemen button-nya.
1432
1433
  retryButton = viewChild('healthRetryButton', { ...(ngDevMode ? { debugName: "retryButton" } : /* istanbul ignore next */ {}), read: ElementRef });
1433
- emailControlState = toSignal(this.emailControl.events.pipe(startWith(null)), {
1434
- initialValue: null,
1435
- });
1436
1434
  constructor() {
1437
1435
  // On-load health check: non-blocking, no-op saat healthCheck.enabled=false.
1438
1436
  void this.health.check();
@@ -1444,19 +1442,15 @@ class AuthLoginPage {
1444
1442
  });
1445
1443
  }
1446
1444
  hasInlineError = computed(() => {
1447
- this.emailControlState();
1448
- return this.emailControl.invalid && (this.emailControl.dirty || this.emailControl.touched);
1445
+ const emailState = this.form.email();
1446
+ return emailState.invalid() && (emailState.dirty() || emailState.touched());
1449
1447
  }, /* @ts-ignore */
1450
1448
  ...(ngDevMode ? [{ debugName: "hasInlineError" }] : /* istanbul ignore next */ []));
1451
1449
  inlineErrorMessage = computed(() => {
1452
- // Depend on the control events directly: `hasInlineError` stays `true`
1453
- // while the error kind changes (e.g. format → required), and a memoized
1454
- // boolean alone would leave a stale message on screen.
1455
- this.emailControlState();
1456
1450
  if (!this.hasInlineError()) {
1457
1451
  return null;
1458
1452
  }
1459
- return this.emailControl.hasError('required')
1453
+ return this.form.email().getError('required')
1460
1454
  ? this.messages.login.emailRequired
1461
1455
  : this.messages.login.emailInvalid;
1462
1456
  }, /* @ts-ignore */
@@ -1567,34 +1561,29 @@ class AuthLoginPage {
1567
1561
  this.documentRef.defaultView?.location.assign(url);
1568
1562
  }
1569
1563
  async submit() {
1570
- if (this.form.invalid) {
1571
- this.form.markAllAsTouched();
1572
- return;
1573
- }
1574
- // Pre-submit re-check: backend bisa mati setelah halaman dimuat.
1575
- if (!(await this.health.check())) {
1576
- return;
1577
- }
1578
- this.isSubmitting.set(true);
1579
- this.responseMessage.set(null);
1580
- this.errorMessage.set(null);
1581
- const email = this.emailControl.getRawValue().trim().toLowerCase();
1582
- this.emailControl.setValue(email);
1583
- this.authMagicLinkService
1584
- .requestMagicLoginLink({
1585
- body: {
1586
- email,
1587
- frontend_url: new URL(this.authConfig.appUrl).origin,
1588
- },
1589
- })
1590
- .pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.isSubmitting.set(false)))
1591
- .subscribe({
1592
- next: (response) => {
1564
+ await submit(this.form, async () => {
1565
+ // Pre-submit re-check: backend bisa mati setelah halaman dimuat.
1566
+ if (!(await this.health.check())) {
1567
+ return;
1568
+ }
1569
+ this.responseMessage.set(null);
1570
+ this.errorMessage.set(null);
1571
+ const email = this.form.email().value().trim().toLowerCase();
1572
+ this.form.email().value.set(email);
1573
+ try {
1574
+ const response = await firstValueFrom(this.authMagicLinkService
1575
+ .requestMagicLoginLink({
1576
+ body: {
1577
+ email,
1578
+ frontend_url: new URL(this.authConfig.appUrl).origin,
1579
+ },
1580
+ })
1581
+ .pipe(takeUntilDestroyed(this.destroyRef)));
1593
1582
  this.responseMessage.set(getResponseMessage(response, this.messages.login.magicLinkSent));
1594
- },
1595
- error: (error) => {
1583
+ }
1584
+ catch (error) {
1596
1585
  this.errorMessage.set(getErrorMessage(error, this.messages.login.magicLinkFailed));
1597
- },
1586
+ }
1598
1587
  });
1599
1588
  }
1600
1589
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthLoginPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -1655,7 +1644,7 @@ class AuthLoginPage {
1655
1644
  </div>
1656
1645
  }
1657
1646
 
1658
- <form class="space-y-6" [formGroup]="form" (ngSubmit)="submit()">
1647
+ <form class="space-y-6" (submit)="submit(); $event.preventDefault()">
1659
1648
  <div class="space-y-3">
1660
1649
  <label Label for="email" class="sr-only">Alamat email</label>
1661
1650
  <InputGroup [class]="emailFieldClasses()">
@@ -1687,7 +1676,7 @@ class AuthLoginPage {
1687
1676
  autocomplete="email"
1688
1677
  [attr.aria-describedby]="feedbackMessage() ? emailFeedbackId : null"
1689
1678
  [attr.aria-invalid]="fieldTone() === 'error' ? 'true' : null"
1690
- formControlName="email"
1679
+ [formField]="form.email"
1691
1680
  [placeholder]="messages.login.emailPlaceholder"
1692
1681
  />
1693
1682
 
@@ -1697,12 +1686,15 @@ class AuthLoginPage {
1697
1686
  variant="default"
1698
1687
  size="sm"
1699
1688
  [disabled]="
1700
- form.invalid || isSubmitting() || health.isChecking() || health.isUnhealthy()
1689
+ form().invalid() ||
1690
+ form().submitting() ||
1691
+ health.isChecking() ||
1692
+ health.isUnhealthy()
1701
1693
  "
1702
1694
  [attr.aria-describedby]="health.isUnhealthy() ? healthBannerId : null"
1703
1695
  class="order-30 h-12! min-w-24 rounded-none px-5 text-sm font-medium"
1704
1696
  >
1705
- {{ isSubmitting() ? messages.login.submitting : messages.login.submit }}
1697
+ {{ form().submitting() ? messages.login.submitting : messages.login.submit }}
1706
1698
  </button>
1707
1699
  </InputGroup>
1708
1700
 
@@ -1844,14 +1836,14 @@ class AuthLoginPage {
1844
1836
  </form>
1845
1837
  </CardContent>
1846
1838
  </Card>
1847
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: AspectRatioComponent, selector: "AspectRatio", inputs: ["ratio", "class"] }, { kind: "component", type: ButtonComponent, selector: "button[Button], a[Button]", inputs: ["variant", "size", "class"] }, { kind: "component", type: CardActionComponent, selector: "CardAction", inputs: ["class"] }, { kind: "component", type: CardComponent, selector: "Card", inputs: ["size", "class"] }, { kind: "component", type: CardContentComponent, selector: "CardContent", inputs: ["class"] }, { kind: "component", type: CardDescriptionComponent, selector: "CardDescription, p[CardDescription]", inputs: ["class"] }, { kind: "component", type: CardHeaderComponent, selector: "CardHeader", inputs: ["class"] }, { kind: "component", type: CardTitleComponent, selector: "CardTitle, h3[CardTitle]", inputs: ["class"] }, { kind: "component", type: InputGroupAddonComponent, selector: "InputGroupAddon", inputs: ["align", "class"] }, { kind: "component", type: InputGroupButtonComponent, selector: "button[InputGroupButton], a[InputGroupButton]", inputs: ["variant", "size", "class"] }, { kind: "component", type: InputGroupComponent, selector: "InputGroup", inputs: ["class"] }, { kind: "component", type: InputGroupInputComponent, selector: "input[InputGroupInput]", inputs: ["class"] }, { kind: "component", type: LabelComponent, selector: "Label, label[Label]", inputs: ["for", "class"] }, { kind: "component", type: SeparatorComponent, selector: "Separator", inputs: ["orientation", "decorative", "class"] }] });
1839
+ `, isInline: true, dependencies: [{ kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "component", type: AspectRatioComponent, selector: "AspectRatio", inputs: ["ratio", "class"] }, { kind: "component", type: ButtonComponent, selector: "button[Button], a[Button]", inputs: ["variant", "size", "class"] }, { kind: "component", type: CardActionComponent, selector: "CardAction", inputs: ["class"] }, { kind: "component", type: CardComponent, selector: "Card", inputs: ["size", "class"] }, { kind: "component", type: CardContentComponent, selector: "CardContent", inputs: ["class"] }, { kind: "component", type: CardDescriptionComponent, selector: "CardDescription, p[CardDescription]", inputs: ["class"] }, { kind: "component", type: CardHeaderComponent, selector: "CardHeader", inputs: ["class"] }, { kind: "component", type: CardTitleComponent, selector: "CardTitle, h3[CardTitle]", inputs: ["class"] }, { kind: "component", type: InputGroupAddonComponent, selector: "InputGroupAddon", inputs: ["align", "class"] }, { kind: "component", type: InputGroupButtonComponent, selector: "button[InputGroupButton], a[InputGroupButton]", inputs: ["variant", "size", "class"] }, { kind: "component", type: InputGroupComponent, selector: "InputGroup", inputs: ["class"] }, { kind: "component", type: InputGroupInputComponent, selector: "input[InputGroupInput]", inputs: ["class"] }, { kind: "component", type: LabelComponent, selector: "Label, label[Label]", inputs: ["for", "class"] }, { kind: "component", type: SeparatorComponent, selector: "Separator", inputs: ["orientation", "decorative", "class"] }] });
1848
1840
  }
1849
1841
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AuthLoginPage, decorators: [{
1850
1842
  type: Component,
1851
1843
  args: [{
1852
1844
  selector: 'edsis-auth-login-page',
1853
1845
  imports: [
1854
- ReactiveFormsModule,
1846
+ FormField,
1855
1847
  AspectRatioComponent,
1856
1848
  ButtonComponent,
1857
1849
  CardActionComponent,
@@ -1927,7 +1919,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
1927
1919
  </div>
1928
1920
  }
1929
1921
 
1930
- <form class="space-y-6" [formGroup]="form" (ngSubmit)="submit()">
1922
+ <form class="space-y-6" (submit)="submit(); $event.preventDefault()">
1931
1923
  <div class="space-y-3">
1932
1924
  <label Label for="email" class="sr-only">Alamat email</label>
1933
1925
  <InputGroup [class]="emailFieldClasses()">
@@ -1959,7 +1951,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
1959
1951
  autocomplete="email"
1960
1952
  [attr.aria-describedby]="feedbackMessage() ? emailFeedbackId : null"
1961
1953
  [attr.aria-invalid]="fieldTone() === 'error' ? 'true' : null"
1962
- formControlName="email"
1954
+ [formField]="form.email"
1963
1955
  [placeholder]="messages.login.emailPlaceholder"
1964
1956
  />
1965
1957
 
@@ -1969,12 +1961,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
1969
1961
  variant="default"
1970
1962
  size="sm"
1971
1963
  [disabled]="
1972
- form.invalid || isSubmitting() || health.isChecking() || health.isUnhealthy()
1964
+ form().invalid() ||
1965
+ form().submitting() ||
1966
+ health.isChecking() ||
1967
+ health.isUnhealthy()
1973
1968
  "
1974
1969
  [attr.aria-describedby]="health.isUnhealthy() ? healthBannerId : null"
1975
1970
  class="order-30 h-12! min-w-24 rounded-none px-5 text-sm font-medium"
1976
1971
  >
1977
- {{ isSubmitting() ? messages.login.submitting : messages.login.submit }}
1972
+ {{ form().submitting() ? messages.login.submitting : messages.login.submit }}
1978
1973
  </button>
1979
1974
  </InputGroup>
1980
1975
 
@@ -2355,7 +2350,7 @@ class AuthVerifyPage {
2355
2350
  this.clearTokenFromAddressBar();
2356
2351
  this.state.set('pending');
2357
2352
  this.message.set(this.messages.verify.pending);
2358
- this.verify(token);
2353
+ untracked(() => this.verify(token));
2359
2354
  });
2360
2355
  }
2361
2356
  clearTokenFromAddressBar() {