@block-auth.io/angular 0.4.0 → 0.4.1

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.
Files changed (153) hide show
  1. package/fesm2022/block-auth.io-angular.mjs +9828 -0
  2. package/fesm2022/block-auth.io-angular.mjs.map +1 -0
  3. package/index.d.ts +1144 -0
  4. package/package.json +16 -37
  5. package/.turbo/turbo-build.log +0 -37
  6. package/.turbo/turbo-lint.log +0 -4
  7. package/.turbo/turbo-test.log +0 -1400
  8. package/.turbo/turbo-typecheck.log +0 -19
  9. package/CHANGELOG.md +0 -273
  10. package/ng-package.json +0 -6
  11. package/scripts/css-to-ts.mjs +0 -14
  12. package/src/lib/__tests__/integration.test.ts +0 -45
  13. package/src/lib/block-auth.service.test.ts +0 -69
  14. package/src/lib/block-auth.service.ts +0 -81
  15. package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
  16. package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
  17. package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
  18. package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
  19. package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
  20. package/src/lib/components/btns/btn-gmail.component.ts +0 -41
  21. package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
  22. package/src/lib/components/btns/btn-google-base.component.ts +0 -73
  23. package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
  24. package/src/lib/components/btns/btn-metamask.component.ts +0 -98
  25. package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
  26. package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
  27. package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
  28. package/src/lib/components/btns/btn-phantom.component.ts +0 -93
  29. package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
  30. package/src/lib/components/btns/btn-signin.component.ts +0 -108
  31. package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
  32. package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
  33. package/src/lib/components/btns/index.ts +0 -11
  34. package/src/lib/components/contents/content-signin.component.test.ts +0 -33
  35. package/src/lib/components/contents/content-signin.component.ts +0 -68
  36. package/src/lib/components/contents/content-signup.component.test.ts +0 -86
  37. package/src/lib/components/contents/content-signup.component.ts +0 -222
  38. package/src/lib/components/dds/change-account.component.test.ts +0 -66
  39. package/src/lib/components/dds/change-account.component.ts +0 -112
  40. package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
  41. package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
  42. package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
  43. package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
  44. package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
  45. package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
  46. package/src/lib/components/flow-block-auth.component.test.ts +0 -95
  47. package/src/lib/components/flow-block-auth.component.ts +0 -228
  48. package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
  49. package/src/lib/components/modals/modal-overlay.component.ts +0 -43
  50. package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
  51. package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
  52. package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
  53. package/src/lib/components/modals/modal-restore.component.ts +0 -104
  54. package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
  55. package/src/lib/components/modals/modal-signin.component.ts +0 -44
  56. package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
  57. package/src/lib/components/modals/modal-signup.component.ts +0 -40
  58. package/src/lib/components/sections/footer-section.component.test.ts +0 -19
  59. package/src/lib/components/sections/footer-section.component.ts +0 -49
  60. package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
  61. package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
  62. package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
  63. package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
  64. package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
  65. package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
  66. package/src/lib/components/sections/login-section.component.test.ts +0 -49
  67. package/src/lib/components/sections/login-section.component.ts +0 -119
  68. package/src/lib/components/sections/providers-section.component.test.ts +0 -22
  69. package/src/lib/components/sections/providers-section.component.ts +0 -187
  70. package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
  71. package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
  72. package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
  73. package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
  74. package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
  75. package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
  76. package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
  77. package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
  78. package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
  79. package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
  80. package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
  81. package/src/lib/components/txns/internals/txn.component.ts +0 -453
  82. package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
  83. package/src/lib/components/txns/txns-overview.component.ts +0 -461
  84. package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
  85. package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
  86. package/src/lib/icons/cg-profile.component.ts +0 -31
  87. package/src/lib/icons/check-icon.component.ts +0 -27
  88. package/src/lib/icons/ci-clock2.component.ts +0 -31
  89. package/src/lib/icons/fa-arrow-right.component.ts +0 -21
  90. package/src/lib/icons/fa-times.component.ts +0 -21
  91. package/src/lib/icons/fa-undo.component.ts +0 -21
  92. package/src/lib/icons/icons.test.ts +0 -25
  93. package/src/lib/icons/index.ts +0 -22
  94. package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
  95. package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
  96. package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
  97. package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
  98. package/src/lib/icons/pi-warning-fill.component.ts +0 -21
  99. package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
  100. package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
  101. package/src/lib/icons/tb-copy.component.ts +0 -34
  102. package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
  103. package/src/lib/inject-store.test.ts +0 -26
  104. package/src/lib/inject-store.ts +0 -16
  105. package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
  106. package/src/lib/primitives/arrow-icon.component.ts +0 -45
  107. package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
  108. package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
  109. package/src/lib/primitives/btn-base.component.test.ts +0 -38
  110. package/src/lib/primitives/btn-base.component.ts +0 -140
  111. package/src/lib/primitives/divider-base.component.test.ts +0 -12
  112. package/src/lib/primitives/divider-base.component.ts +0 -74
  113. package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
  114. package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
  115. package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
  116. package/src/lib/primitives/dropdown-base.component.ts +0 -329
  117. package/src/lib/primitives/helpers.ts +0 -151
  118. package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
  119. package/src/lib/primitives/horizontal-loader.component.ts +0 -46
  120. package/src/lib/primitives/icon-base.component.test.ts +0 -19
  121. package/src/lib/primitives/icon-base.component.ts +0 -58
  122. package/src/lib/primitives/img-loader.component.test.ts +0 -22
  123. package/src/lib/primitives/img-loader.component.ts +0 -121
  124. package/src/lib/primitives/index.ts +0 -29
  125. package/src/lib/primitives/input-base.component.test.ts +0 -20
  126. package/src/lib/primitives/input-base.component.ts +0 -210
  127. package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
  128. package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
  129. package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
  130. package/src/lib/primitives/oval-spinner.component.ts +0 -136
  131. package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
  132. package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
  133. package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
  134. package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
  135. package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
  136. package/src/lib/primitives/progressbar.component.test.ts +0 -34
  137. package/src/lib/primitives/progressbar.component.ts +0 -36
  138. package/src/lib/primitives/providersStyles.ts +0 -218
  139. package/src/lib/primitives/slider-base.component.ts +0 -56
  140. package/src/lib/provide-block-auth.test.ts +0 -43
  141. package/src/lib/provide-block-auth.ts +0 -43
  142. package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
  143. package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
  144. package/src/lib/teleport-body.directive.test.ts +0 -29
  145. package/src/lib/teleport-body.directive.ts +0 -21
  146. package/src/lib/testing.ts +0 -15
  147. package/src/lib/transitions.css +0 -19
  148. package/src/public-api.ts +0 -86
  149. package/src/vitest.setup.ts +0 -8
  150. package/tailwind.config.cjs +0 -6
  151. package/tsconfig.json +0 -15
  152. package/tsconfig.lib.json +0 -9
  153. package/vite.config.mts +0 -44
@@ -1,119 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
2
- import { providersStyles } from '../../primitives/providersStyles';
3
- import { ImgLoaderComponent } from '../../primitives/img-loader.component';
4
- import { ArrowIconComponent } from '../../primitives/arrow-icon.component';
5
- import { SelectedButtonComponent } from './internals/selected-button.component';
6
- import { BtnSigninComponent } from '../btns/btn-signin.component';
7
- import { DropdownProfileComponent } from '../dds/dropdown-profile.component';
8
-
9
- /**
10
- * Columna derecha de la card de signup. Dos estados, según `showImgLoader`
11
- * (= no conectado al servicio seleccionado):
12
- * - NO conectado -> logo del provider (`<ba-img-loader>`) + botón de conexión
13
- * (`<ba-selected-button>`) + descripción.
14
- * - conectado -> el `<DropdownProfile>` de cuenta + separador "Completa el
15
- * último paso" + la fila `<ba-btn-signin>` "Iniciar sesión" flanqueada por
16
- * `<ba-arrow-icon>`.
17
- *
18
- * NOTA: `containerRef` existe en la interfaz react pero nunca se usa en el
19
- * cuerpo (prop muerta) — se omite, igual que en el port Vue.
20
- *
21
- * A10: el placeholder de A9 (rama conectada) ahora renderiza el
22
- * `<ba-dropdown-profile>` real.
23
- */
24
- @Component({
25
- selector: 'ba-login-section',
26
- standalone: true,
27
- // Hijo directo del grid de content-signup: el host debe ser transparente al
28
- // layout para que el contenido interno sea el grid item real (ver
29
- // providers-section para el detalle). Sin esto el layout del modal se solapa.
30
- host: { style: 'display: contents' },
31
- changeDetection: ChangeDetectionStrategy.OnPush,
32
- imports: [
33
- ImgLoaderComponent,
34
- ArrowIconComponent,
35
- SelectedButtonComponent,
36
- BtnSigninComponent,
37
- DropdownProfileComponent,
38
- ],
39
- template: `
40
- <section
41
- data-testid="login-section"
42
- [attr.data-service]="selectedService()"
43
- class="bas-relative bas-box-border bas-flex bas-h-[230px] bas-w-full bas-flex-col bas-items-center bas-justify-between bas-gap-2 bas-pt-4 bas-px-2 lg:bas-px-6"
44
- >
45
- @if (showImgLoader()) {
46
- <ba-img-loader
47
- loaderId="signup-provider-loader"
48
- [imgSrc]="isWeb3ProviderSelected() && imgQR() ? imgQR() : style().imgSrc"
49
- [imgAlt]="'Img of ' + selectedService() + ' provider'"
50
- [showLoaderRing]="false"
51
- [scaleImgWhenHovered]="!isWeb3ProviderSelected()"
52
- [size]="isWeb3ProviderSelected() ? 'medium' : 'small'"
53
- />
54
- } @else {
55
- <ba-dropdown-profile [isInsideModal]="true" dropdownBtnSize="small" />
56
- }
57
-
58
- <div class="bas-relative bas-box-border bas-flex bas-h-auto bas-w-full bas-flex-col bas-gap-4 bas-overflow-hidden bas-py-1">
59
- @if (showImgLoader()) {
60
- <!-- BOTON DE CONEXION DEL PROVIDER -->
61
- <div class="bas-flex bas-h-auto bas-w-auto bas-justify-center">
62
- <ba-selected-button
63
- [selectedService]="selectedService()"
64
- [btnsConnectTxt]="connectTxt()"
65
- [showImgLoader]="showImgLoader()"
66
- [isEditable]="isEditable()"
67
- />
68
- </div>
69
- <!-- DESCRIPCION -->
70
- <p [class]="'bas-m-0 bas-mx-auto bas-text-center bas-text-gray-900 ' + descriptionTextClassNames()">
71
- {{ titleTxt() }} {{ descriptionTxt() }}
72
- </p>
73
- } @else {
74
- <!-- CONECTADO: "Completa el último paso" + fila de Log In -->
75
- <div class="bas-flex bas-w-full bas-flex-col bas-items-center bas-gap-4 bas-pt-2">
76
- <div class="bas-flex bas-w-full bas-items-center bas-justify-center bas-gap-3">
77
- <span class="bal-ba-glass-divider bas-h-px bas-flex-1"></span>
78
- <p class="bas-m-0 bas-text-center bas-text-[var(--bal-primary-700)]">{{ lastStepTxt() }}</p>
79
- <span class="bal-ba-glass-divider bal-ba-glass-divider-end bas-h-px bas-flex-1"></span>
80
- </div>
81
- <div class="bas-flex bas-h-fit bas-w-full bas-flex-row bas-items-center bas-justify-center bas-gap-4">
82
- <ba-arrow-icon direction="right" />
83
- <ba-btn-signin [text]="loginTxt()" [isDisabled]="!isServiceConnected()" [isEditable]="isEditable()" />
84
- <ba-arrow-icon direction="left" />
85
- </div>
86
- </div>
87
- }
88
- </div>
89
- </section>
90
- `,
91
- })
92
- export class LoginSectionComponent {
93
- imgQR = input('');
94
- showImgLoader = input(true);
95
- selectedService = input('blockauth');
96
- isServiceConnected = input(false);
97
- isEditable = input(false);
98
- device = input<'desktop' | 'tablet' | 'phone'>('desktop');
99
- titleTxt = input('');
100
- descriptionTxt = input('Regístrate en segundos y olvídate de las contraseñas.');
101
- /** Etiqueta localizada del botón de conexión del provider. */
102
- btnsConnectTxt = input('');
103
- /** @deprecated usar `btnsConnectTxt`. */
104
- createAccountTxt = input('');
105
- /** Etiqueta localizada de "Log In" (estado conectado). */
106
- loginTxt = input('Iniciar sesión');
107
- /** Etiqueta localizada de "Completa el último paso" (estado conectado). */
108
- lastStepTxt = input('Completa el último paso');
109
-
110
- protected isWeb3ProviderSelected = computed(
111
- () => this.selectedService() === 'metamask' || this.selectedService() === 'phantom',
112
- );
113
- protected style = computed(() => providersStyles[this.selectedService()] ?? providersStyles['blockauth']);
114
- protected connectTxt = computed(() => this.btnsConnectTxt() || this.createAccountTxt());
115
- protected descriptionTextClassNames = computed(() => {
116
- if (!this.isEditable()) return 'bas-text-xs bas-font-light lg:bas-text-base lg:bas-font-thin';
117
- return this.device() === 'desktop' ? 'bas-text-base bas-font-thin' : 'bas-text-xs bas-font-light';
118
- });
119
- }
@@ -1,22 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { Component } from '@angular/core';
3
- import { render, screen } from '@testing-library/angular';
4
- import { ProvidersSectionComponent } from './providers-section.component';
5
-
6
- // Port de packages/react/src/components/sections/ProvidersSection.test.tsx.
7
- // Usa `$locale` del core (singleton) para i18n; sin dependencias del client.
8
- describe('ProvidersSection', () => {
9
- it('renderiza la seccion de proveedores', async () => {
10
- @Component({
11
- standalone: true,
12
- imports: [ProvidersSectionComponent],
13
- template: `<ba-providers-section [showedProviders]="providers" />`,
14
- })
15
- class HostComponent {
16
- providers = ['metamask', 'phantom'];
17
- }
18
- await render(HostComponent);
19
- expect(screen.getByTestId('providers-section')).toBeDefined();
20
- expect(screen.getByTestId('providers-buttons')).toBeDefined();
21
- });
22
- });
@@ -1,187 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- DestroyRef,
5
- PLATFORM_ID,
6
- computed,
7
- inject,
8
- input,
9
- output,
10
- signal,
11
- } from '@angular/core';
12
- import { isPlatformBrowser } from '@angular/common';
13
- import { $locale, t as translate, type TextKey } from '@block-auth.io/core';
14
- import { injectStore } from '../../inject-store';
15
- import {
16
- ProvidersFiltersComponent,
17
- makeWebTypeItems,
18
- type WebTypeItem,
19
- } from './internals/providers-filters.component';
20
- import { ProvidersButtonsComponent } from './internals/providers-buttons.component';
21
-
22
- /**
23
- * Columna izquierda de la card de signup: cabecera "Conectar con" (logo +
24
- * título), filtros de búsqueda/web-type y grid de proveedores. Estado local de
25
- * búsqueda/filtro cableado hacia abajo y expuesto al padre vía outputs
26
- * (`selectedServiceChange`/`changeWebType`/`changeProviderSearch`).
27
- *
28
- * `useMobile(660)` -> señal `isMobile` interna, SSR-safe (queda en `false`
29
- * hasta montar en cliente) y reactiva a `resize`. El efecto de medición de
30
- * scroll se internaliza en `<ba-providers-buttons>` (ver su cabecera). i18n vía
31
- * `$locale` del core (mismo patrón que BtnBlockAuth).
32
- */
33
- @Component({
34
- selector: 'ba-providers-section',
35
- standalone: true,
36
- // El elemento host es hijo directo del grid de content-signup, pero las clases
37
- // de posicionamiento (bas-row-start-2, sm1:bas-row-span-2, etc.) van en el
38
- // <section> interno. `display: contents` hace que ese <section> sea el grid
39
- // item real (como en React, donde el div raíz ES el hijo del grid). Sin esto
40
- // el host se auto-coloca y el layout del modal se solapa.
41
- host: { style: 'display: contents' },
42
- changeDetection: ChangeDetectionStrategy.OnPush,
43
- imports: [ProvidersFiltersComponent, ProvidersButtonsComponent],
44
- template: `
45
- @if (hasConfig()) {
46
- <section
47
- data-testid="providers-section"
48
- [class]="'bas-box-border bas-grid bas-items-center bas-justify-center ' + sectionContainerClassNames()"
49
- >
50
- <div class="bas-box-border bas-flex bas-h-[52px] bas-w-full bas-flex-row bas-items-center bas-justify-start bas-gap-2 bas-pl-2">
51
- <img src="https://dashboard.block-auth.io/img/blockauth_logo.png" width="34" height="34" alt="Block-Auth" />
52
- <h2 [class]="'bas-m-0 bas-text-2xl bas-font-normal bas-text-[#00509a] ' + h2ClassNames()">
53
- {{ titleTxt() ?? t('connectWith') }}
54
- </h2>
55
- </div>
56
-
57
- <ba-providers-filters
58
- [container]="container()"
59
- [uiConfigProvidersInfo]="info()"
60
- [searchProviderValue]="searchProviderValue()"
61
- (changeProviderSearch)="onChangeProviderSearchValue($event)"
62
- [openWebType]="openWebType()"
63
- (openWebTypeChange)="openWebType.set($event)"
64
- [selectedWebType]="selectedWebType()"
65
- [webTypesItems]="webTypesItems()"
66
- (changeWebType)="onChangeWebTypeItem($event)"
67
- [isEditable]="isEditable()"
68
- [isEditing]="isEditing()"
69
- [device]="device()"
70
- />
71
- <ba-providers-buttons
72
- [providersFiltersEnabled]="providersFiltersEnabled()"
73
- [isMobile]="isMobileLayout()"
74
- [uiConfigProvidersInfo]="info()"
75
- [showedProviders]="showedProviders()"
76
- [selectedService]="selectedService()"
77
- (selectedServiceChange)="selectedServiceChange.emit($event)"
78
- [isEditable]="isEditable()"
79
- [isEditing]="isEditing()"
80
- [device]="device() === 'phone' ? 'phone' : 'desktop'"
81
- />
82
- </section>
83
- }
84
- `,
85
- })
86
- export class ProvidersSectionComponent {
87
- container = input<HTMLElement | null>(null);
88
- // Acepta `undefined` (ContentSignup lo pasa así cuando no hay config). En
89
- // react un prop `undefined` recae en el default por parámetro; en Angular una
90
- // binding `undefined` PISA el default de `input()`, así que se recae al
91
- // default vía el `info()` computed.
92
- uiConfigProvidersInfo = input<
93
- | {
94
- providersColumns?: number;
95
- showProviderNameOnMobile?: boolean;
96
- enableSearch?: boolean;
97
- enableWebTypeFilter?: boolean;
98
- }
99
- | undefined
100
- >(undefined);
101
-
102
- private readonly DEFAULT_INFO = {
103
- providersColumns: 3,
104
- showProviderNameOnMobile: true,
105
- enableSearch: true,
106
- enableWebTypeFilter: true,
107
- };
108
- protected info = computed(() => this.uiConfigProvidersInfo() ?? this.DEFAULT_INFO);
109
- selectedService = input('');
110
- showedProviders = input<string[]>([]);
111
- isEditable = input(false);
112
- isEditing = input(false);
113
- device = input<'desktop' | 'tablet' | 'phone'>('desktop');
114
- titleTxt = input<string | undefined>(undefined);
115
-
116
- selectedServiceChange = output<string>();
117
- changeWebType = output<WebTypeItem>();
118
- changeProviderSearch = output<string>();
119
-
120
- private readonly locale = injectStore($locale);
121
- protected t = (key: TextKey): string => translate(key, this.locale());
122
-
123
- // Recalcula (vía `t`, que lee `$locale`) cuando cambia el idioma, igual que
124
- // el `useMemo(..., [locale])` de react.
125
- protected webTypesItems = computed(() => makeWebTypeItems(this.t));
126
- protected searchProviderValue = signal('');
127
- private readonly selectedWebTypeValue = signal('all');
128
- protected selectedWebType = computed(
129
- () => this.webTypesItems().find((item) => item.value === this.selectedWebTypeValue()) ?? this.webTypesItems()[0],
130
- );
131
- protected openWebType = signal(false);
132
-
133
- // useMobile(660): SSR-safe + reactivo a resize.
134
- private readonly platformId = inject(PLATFORM_ID);
135
- private readonly destroyRef = inject(DestroyRef);
136
- private readonly isMobile = signal(false);
137
-
138
- constructor() {
139
- if (isPlatformBrowser(this.platformId)) {
140
- const onResize = () => this.isMobile.set(window.innerWidth < 660);
141
- onResize();
142
- window.addEventListener('resize', onResize);
143
- this.destroyRef.onDestroy(() => window.removeEventListener('resize', onResize));
144
- }
145
- }
146
-
147
- protected hasConfig = computed(() => Object.keys(this.info()).length !== 0);
148
- protected providersFiltersEnabled = computed(
149
- () => !!this.info().enableSearch || !!this.info().enableWebTypeFilter,
150
- );
151
- protected isMobileLayout = computed(() => this.isMobile() || (this.isEditable() && this.device() === 'phone'));
152
-
153
- onChangeWebTypeItem(webType: WebTypeItem): void {
154
- this.selectedWebTypeValue.set(webType.value);
155
- this.changeWebType.emit(webType);
156
- }
157
- onChangeProviderSearchValue(value: string): void {
158
- this.searchProviderValue.set(value);
159
- this.changeProviderSearch.emit(value);
160
- }
161
-
162
- // ----------------- CLASSNAMES (port literal) -----------------
163
- protected useTallRows = computed(() => this.isMobileLayout() || this.providersFiltersEnabled());
164
- protected sectionContainerClassNames = computed(() => {
165
- if (!this.isEditable()) {
166
- return `bas-row-start-2 bas-h-[140px] bas-grid-cols-[auto_1fr] bas-grid-rows-[52px_76px]
167
- bas-gap-1 bas-pt-2 xsm1:bas-w-full sm1:bas-row-span-2 sm1:bas-row-start-auto
168
- sm1:bas-h-[282px] sm1:bas-w-60 sm1:bas-grid-cols-1 sm1:bas-gap-0 sm1:bas-pt-0
169
- ${this.useTallRows() ? 'sm1:bas-grid-rows-[52px_42px_188px]' : 'sm1:bas-grid-rows-[52px_0px_230px]'}`;
170
- }
171
- if (this.device() === 'phone') {
172
- return 'bas-row-start-2 bas-h-[140px] bas-grid-cols-[auto_1fr] bas-grid-rows-[52px_76px] bas-gap-1 bas-pt-2';
173
- }
174
- return `bas-row-span-2 bas-row-start-auto bas-h-[282px] bas-w-60 bas-grid-cols-1
175
- bas-gap-0 bas-pt-0 ${this.useTallRows() ? 'bas-grid-rows-[52px_42px_188px]' : 'bas-grid-rows-[52px_0px_230px]'}`;
176
- });
177
-
178
- protected bothFilters = computed(
179
- () => !!this.info().enableSearch && !!this.info().enableWebTypeFilter,
180
- );
181
- protected h2ClassNames = computed(() => {
182
- if (!this.isMobileLayout()) return '';
183
- if (this.isEditable()) return this.device() === 'phone' ? 'bas-hidden' : 'bas-block';
184
- if (this.providersFiltersEnabled()) return `bas-hidden ${this.bothFilters() ? 'xsm1:bas-block' : 'xsm:bas-block'}`;
185
- return '';
186
- });
187
- }
@@ -1,36 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import { render, screen } from '@testing-library/angular';
3
- import { setLocale } from '@block-auth.io/core';
4
- import { PermissionsRequiredModalComponent } from './permissions-required-modal.component';
5
-
6
- // Port de packages/react/src/components/txns/internals/PermissionsRequiredModal.test.tsx
7
- // (mapa: packages/vue/.../PermissionsRequiredModal.test.ts).
8
- describe('PermissionsRequiredModal', () => {
9
- afterEach(() => setLocale('en'));
10
-
11
- it('renderiza el modal de permisos requeridos', async () => {
12
- await render(PermissionsRequiredModalComponent);
13
- expect(screen.getByText('Temporal access to identity')).toBeDefined();
14
- expect(
15
- screen.getByText('Access to the list of authorised apps'),
16
- ).toBeDefined();
17
- expect(
18
- screen.getByText('Only this transaction will be signed'),
19
- ).toBeDefined();
20
- });
21
-
22
- it('usa el panel glass con filas e iconos animados', async () => {
23
- const { container } = await render(PermissionsRequiredModalComponent);
24
- const panel = container.querySelector('.bal-ba-glass-panel');
25
- expect(panel?.className).toContain('bal-ba-glass-pop');
26
- expect(panel?.className).toContain('bal-ba-glass-stagger');
27
- expect(container.querySelectorAll('.bal-ba-glass-row')).toHaveLength(3);
28
- expect(container.querySelectorAll('.bal-ba-glass-icon')).toHaveLength(3);
29
- });
30
-
31
- it('respeta el locale activo', async () => {
32
- setLocale('es');
33
- await render(PermissionsRequiredModalComponent);
34
- expect(screen.getByText('Acceso temporal a tu identidad')).toBeDefined();
35
- });
36
- });
@@ -1,43 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed } from '@angular/core';
2
- import { $locale, t as translate, type TextKey } from '@block-auth.io/core';
3
- import { injectStore } from '../../../inject-store';
4
-
5
- // Port literal de packages/react/src/components/txns/internals/PermissionsRequiredModal.tsx
6
- // (mapa: packages/vue/.../PermissionsRequiredModal.vue). Sin props/outputs.
7
- const iconClassNames = 'bal-ba-glass-icon bas-text-[#009F6B]';
8
-
9
- @Component({
10
- selector: 'ba-permissions-required-modal',
11
- standalone: true,
12
- changeDetection: ChangeDetectionStrategy.OnPush,
13
- template: `
14
- <div
15
- class="bal-ba-glass-panel bal-ba-glass-pop bal-ba-glass-stagger bas-box-border bas-grid bas-w-full bas-grid-rows-3 bas-gap-3 bas-py-4 bas-pl-3"
16
- >
17
- @for (permission of requiredPermissions(); track $index) {
18
- <div class="bal-ba-glass-row">
19
- <span [class]="iconClassNames" aria-hidden="true">{{
20
- permission.icon
21
- }}</span>
22
- <p
23
- class="bas-m-0 bas-text-start bas-text-base bas-text-[var(--bal-primary-800)]"
24
- >
25
- {{ permission.message }}
26
- </p>
27
- </div>
28
- }
29
- </div>
30
- `,
31
- })
32
- export class PermissionsRequiredModalComponent {
33
- protected readonly iconClassNames = iconClassNames;
34
-
35
- private readonly locale = injectStore($locale);
36
- protected t = (key: TextKey): string => translate(key, this.locale());
37
-
38
- protected readonly requiredPermissions = computed(() => [
39
- { message: this.t('permTemporalIdentity'), icon: '👤' },
40
- { message: this.t('permAuthorisedApps'), icon: '📝' },
41
- { message: this.t('permOnlyThisTxn'), icon: '🔄' },
42
- ]);
43
- }
@@ -1,119 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import { Component } from '@angular/core';
3
- import { render, screen, fireEvent } from '@testing-library/angular';
4
- import { setLocale } from '@block-auth.io/core';
5
- import { PhoneInputComponent } from './phone-input.component';
6
-
7
- const changes: string[] = [];
8
-
9
- @Component({
10
- standalone: true,
11
- imports: [PhoneInputComponent],
12
- template: `<ba-phone-input inputId="phone" [value]="value" (valueChange)="onChange($event)" />
13
- <button type="button" (click)="value = ''">reset</button>`,
14
- })
15
- class Host {
16
- value = '';
17
- onChange(next: string): void {
18
- this.value = next;
19
- changes.push(next);
20
- }
21
- }
22
-
23
- const renderHost = async (value: string) => {
24
- const result = await render(Host, { componentProperties: { value } });
25
- await result.fixture.whenStable();
26
- return result;
27
- };
28
-
29
- const countryButton = () => document.getElementById('phone-country') as HTMLButtonElement;
30
- const nationalInput = () => document.getElementById('phone') as HTMLInputElement;
31
- const search = () => document.getElementById('phone-country-search') as HTMLInputElement | null;
32
-
33
- describe('PhoneInputComponent', () => {
34
- afterEach(() => {
35
- changes.length = 0;
36
- setLocale('en');
37
- });
38
-
39
- it('muestra la bandera, el prefijo y el número nacional del valor', async () => {
40
- await renderHost('+34634343343');
41
- expect(countryButton().textContent).toContain('🇪🇸');
42
- expect(countryButton().textContent).toContain('+34');
43
- expect(countryButton().getAttribute('aria-label')).toBe('Country: Spain +34');
44
- expect(nationalInput().value).toBe('634 34 33 43');
45
- expect(nationalInput().type).toBe('tel');
46
- });
47
-
48
- it('acepta el formato antiguo y lo muestra separado', async () => {
49
- await renderHost('34_634343343_es');
50
- expect(countryButton().textContent).toContain('+34');
51
- expect(nationalInput().value).toBe('634 34 33 43');
52
- });
53
-
54
- it('envía el número en E.164 al escribir el número nacional', async () => {
55
- await renderHost('+34');
56
- await fireEvent.input(nationalInput(), { target: { value: '634 34 33 43' } });
57
- expect(changes[changes.length - 1]).toBe('+34634343343');
58
- expect(nationalInput().value).toBe('634 34 33 43');
59
- });
60
-
61
- it('busca y selecciona un país con el teclado y cierra con Escape', async () => {
62
- const { fixture } = await renderHost('+34634343343');
63
- await fireEvent.click(countryButton());
64
- await fixture.whenStable();
65
- expect(countryButton().getAttribute('aria-expanded')).toBe('true');
66
- expect(document.activeElement).toBe(search());
67
- expect(screen.getByRole('listbox')).toBeDefined();
68
- await fireEvent.input(search()!, { target: { value: 'fran' } });
69
- expect(screen.getAllByRole('option').map((option) => option.id)).toContain('phone-country-FR');
70
- await fireEvent.keyDown(search()!, { key: 'Escape' });
71
- expect(search()).toBeNull();
72
- expect(document.activeElement).toBe(countryButton());
73
-
74
- await fireEvent.click(countryButton());
75
- await fireEvent.input(search()!, { target: { value: '+33' } });
76
- expect(search()!.getAttribute('aria-activedescendant')).toBe('phone-country-FR');
77
- await fireEvent.keyDown(search()!, { key: 'Enter' });
78
- expect(search()).toBeNull();
79
- expect(countryButton().textContent).toContain('+33');
80
- expect(changes[changes.length - 1]).toBe('+33634343343');
81
- expect(document.activeElement).toBe(nationalInput());
82
- });
83
-
84
- it('mueve la opción activa con las flechas', async () => {
85
- await renderHost('+34634343343');
86
- await fireEvent.keyDown(countryButton(), { key: 'ArrowDown' });
87
- expect(search()!.getAttribute('aria-activedescendant')).toBe('phone-country-ES');
88
- const options = screen.getAllByRole('option');
89
- const index = options.findIndex((o) => o.id === 'phone-country-ES');
90
- await fireEvent.keyDown(search()!, { key: 'ArrowDown' });
91
- expect(search()!.getAttribute('aria-activedescendant')).toBe(options[index + 1].id);
92
- await fireEvent.keyDown(search()!, { key: 'ArrowUp' });
93
- await fireEvent.keyDown(search()!, { key: 'ArrowUp' });
94
- expect(search()!.getAttribute('aria-activedescendant')).toBe(options[index - 1].id);
95
- expect(document.getElementById('phone-country-ES')!.getAttribute('aria-selected')).toBe('true');
96
- });
97
-
98
- it('avisa si no hay países y usa el idioma activo', async () => {
99
- setLocale('es');
100
- await renderHost('+4915112345678');
101
- expect(countryButton().getAttribute('aria-label')).toBe('País: Alemania +49');
102
- await fireEvent.click(countryButton());
103
- expect(search()!.placeholder).toBe('Buscar país o prefijo');
104
- await fireEvent.input(search()!, { target: { value: 'zzzz' } });
105
- expect(screen.queryByRole('listbox')).toBeNull();
106
- expect(screen.getByText('No hay países que coincidan')).toBeDefined();
107
- });
108
-
109
- it('cierra la lista al pulsar fuera y conserva el país al vaciar', async () => {
110
- const { fixture } = await renderHost('+33612345678');
111
- await fireEvent.click(countryButton());
112
- await fireEvent.mouseDown(document.body);
113
- fixture.detectChanges();
114
- expect(search()).toBeNull();
115
- await fireEvent.click(screen.getByText('reset'));
116
- expect(nationalInput().value).toBe('');
117
- expect(countryButton().textContent).toContain('+33');
118
- });
119
- });