@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,228 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, inject, input, output } from '@angular/core';
2
- import { setIsSigningLoader } from '@block-auth.io/core';
3
- import { BlockAuthService } from '../block-auth.service';
4
- import { BtnBaseComponent } from '../primitives/btn-base.component';
5
- import { BlockAuthRuntimeDirective } from '../runtime/block-auth-runtime.directive';
6
- import {
7
- DropdownProfileComponent,
8
- type DropdownProfileAdditionalItem,
9
- } from './dds/dropdown-profile.component';
10
- import { ModalSigninComponent } from './modals/modal-signin.component';
11
- import { ModalSignupComponent } from './modals/modal-signup.component';
12
- import { ModalRestoreComponent } from './modals/modal-restore.component';
13
- import { ModalRestorationExpiredComponent } from './modals/modal-restoration-expired.component';
14
-
15
- @Component({
16
- selector: 'ba-flow-block-auth',
17
- standalone: true,
18
- changeDetection: ChangeDetectionStrategy.OnPush,
19
- imports: [
20
- BtnBaseComponent,
21
- BlockAuthRuntimeDirective,
22
- DropdownProfileComponent,
23
- ModalSigninComponent,
24
- ModalSignupComponent,
25
- ModalRestoreComponent,
26
- ModalRestorationExpiredComponent,
27
- ],
28
- template: `
29
- <div
30
- data-testid="flow-blockauth"
31
- [class]="
32
- 'bas-flex bas-w-full bas-items-center bas-justify-center ' +
33
- (showDDP() ? 'bas-h-fit bas-flex-col bas-gap-2.5' : ' bas-h-[52px]')
34
- "
35
- >
36
- @if (initializeSdk()) {
37
- <ng-container
38
- baRuntime
39
- (success)="success.emit($event)"
40
- (errored)="errored.emit()"
41
- (loggedOut)="loggedOut.emit()"
42
- />
43
- }
44
-
45
- @if (!ui().isSigned || !ui().isSignedFirstCheck) {
46
- <ba-btn-base
47
- btnId="btn-flow-blockauth"
48
- type="button-outlined"
49
- size="base"
50
- [disabled]="isLoading()"
51
- [isLoader]="isLoading()"
52
- loaderColor="#ffffff"
53
- [isIcon]="ws().ready"
54
- [text]="buttonText() || label()"
55
- [bgClassNames]="bgClassNames()"
56
- [textClassNames]="btnTextClassNames()"
57
- [classNames]="'bas-justify-center ' + btnClassNames()"
58
- [isFocusOutlinedEnabled]="false"
59
- (action)="onFlowBAClicked()"
60
- >
61
- @if (ws().ready && ui().isSdkSignedIn) {
62
- <img
63
- slot="icon"
64
- src="https://dashboard.block-auth.io/img/blockauth_logo.png"
65
- width="26"
66
- height="26"
67
- alt="BlockAuth"
68
- />
69
- } @else if (ws().ready) {
70
- <svg
71
- slot="icon"
72
- class="bas-h-6 bas-w-6 bas-text-white"
73
- viewBox="0 0 24 24"
74
- fill="currentColor"
75
- aria-hidden="true"
76
- >
77
- <path
78
- d="M12 2 1 21h22L12 2Zm0 6c.55 0 1 .45 1 1v5a1 1 0 1 1-2 0V9c0-.55.45-1 1-1Zm0 9.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5Z"
79
- />
80
- </svg>
81
- }
82
- </ba-btn-base>
83
- }
84
-
85
- @if (showDDP()) {
86
- <ba-dropdown-profile
87
- [onLogout]="onLogoutForwarder"
88
- [isInsideModal]="isInsideModal()"
89
- [container]="container()"
90
- [dropdownBtnSize]="dropdownBtnSize()"
91
- [dropdownBtnBgClassNames]="dropdownBtnBgClassNames()"
92
- [dropdownBtnTextColorClassNames]="dropdownBtnTextColorClassNames()"
93
- [dropdownBtnBorderClassNames]="dropdownBtnBorderClassNames()"
94
- [dropdownHeight]="dropdownHeight()"
95
- [additionalDropdownItems]="additionalDropdownItems()"
96
- />
97
- }
98
-
99
- <!-- Orden fijo: signin (modal de txn) se renderiza por encima de signup;
100
- la card de signup queda detrás. Cada modal se auto-oculta según el
101
- stack openModals del core. -->
102
- <ba-modal-signup />
103
- <ba-modal-restore />
104
- <ba-modal-restoration-expired />
105
- <ba-modal-signin />
106
- </div>
107
- `,
108
- })
109
- export class FlowBlockAuthComponent {
110
- showDropdownWhenConnected = input(true);
111
- isInsideModal = input(false);
112
- /** Modal container that scopes the dropdown's click-outside listener when `isInsideModal`. */
113
- container = input<HTMLElement | null>(null);
114
- btnClassNames = input('bas-w-full bas-justify-center');
115
- btnTextClassNames = input('bas-font-semibold bas-leading-6 bas-text-base bas-text-white');
116
- dropdownBtnSize = input<'xs' | 'small' | 'base' | 'large'>('small');
117
- dropdownBtnBgClassNames = input('bas-bg-transparent');
118
- dropdownBtnTextColorClassNames = input(
119
- 'bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]',
120
- );
121
- dropdownBtnBorderClassNames = input<string | undefined>(undefined);
122
- dropdownHeight = input<number | null>(null);
123
- initializeSdk = input(true);
124
- additionalDropdownItems = input<DropdownProfileAdditionalItem[] | null>(null);
125
- /** Status-button label override. */
126
- buttonText = input('');
127
-
128
- success = output<string | undefined>();
129
- errored = output<void>();
130
- loggedOut = output<void>();
131
-
132
- private readonly ba = inject(BlockAuthService);
133
- protected readonly ws = this.ba.ws;
134
- protected readonly ui = this.ba.ui;
135
- private readonly locale = this.ba.locale;
136
-
137
- private readonly isUiConfig = computed(
138
- () => this.ui().uiConfig != null && Object.keys(this.ui().uiConfig as object).length > 0,
139
- );
140
- // Copia localizada del backend (`app()` -> uiConfig.config.content.btns):
141
- // { reviewApi, signUp, logIn, restore } cada una keyed por locale (en/es).
142
- private readonly btnsTexts = computed(
143
- () =>
144
- (
145
- this.ui().uiConfig as
146
- | { config?: { content?: { btns?: Record<string, Record<string, string>> } } }
147
- | null
148
- )?.config?.content?.btns,
149
- );
150
-
151
- protected readonly showDDP = computed(
152
- () =>
153
- this.ws().ready &&
154
- this.ui().isSdkSignedIn &&
155
- this.ui().isServiceConnected &&
156
- this.showDropdownWhenConnected() &&
157
- this.ui().isSignedFirstCheck,
158
- );
159
-
160
- // Azul mientras arranca, transparente una vez firmado en el SDK, naranja en
161
- // on-deletion, rojo si la api key es inválida.
162
- protected readonly bgClassNames = computed(
163
- () =>
164
- 'bal-ba-glass-status-btn ' +
165
- (!(this.ws().ready && this.isUiConfig())
166
- ? 'bal-ba-glass-tone-boot'
167
- : this.ui().isSdkSignedIn
168
- ? 'bal-ba-glass-tone-ready'
169
- : this.ui().isOnDeletion
170
- ? 'bal-ba-glass-tone-deletion'
171
- : 'bal-ba-glass-tone-error'),
172
- );
173
-
174
- protected readonly isLoading = computed(
175
- () => !(this.ws().ready && this.isUiConfig() && this.ui().isSignedFirstCheck),
176
- );
177
-
178
- // Label localizado desde el mapa de texto del backend; `buttonText` sigue
179
- // pudiendo sobreescribirlo.
180
- private readonly restoreDefault: Record<string, string> = {
181
- es: 'Restaurar cuenta',
182
- en: 'Restore account',
183
- };
184
- protected readonly label = computed<string>(() => {
185
- if (this.isLoading()) return '';
186
- if (!this.ui().isSdkSignedIn) return this.btnsTexts()?.reviewApi?.[this.locale()] ?? '';
187
- if (this.ui().isOnDeletion) {
188
- return (
189
- this.btnsTexts()?.restore?.[this.locale()] ??
190
- this.restoreDefault[this.locale()] ??
191
- this.restoreDefault['en']
192
- );
193
- }
194
- if (!this.ui().isServiceConnected && !this.ui().isSigned) {
195
- return this.btnsTexts()?.signUp?.[this.locale()] ?? '';
196
- }
197
- if (this.ui().isServiceConnected && !this.ui().isSigned) {
198
- return this.btnsTexts()?.logIn?.[this.locale()] ?? '';
199
- }
200
- return '';
201
- });
202
-
203
- /** Reenvía el logout manual del dropdown al output `loggedOut`. */
204
- protected readonly onLogoutForwarder = (): void => this.loggedOut.emit();
205
-
206
- onFlowBAClicked(): void {
207
- if (!(this.ui().isSdkSignedIn && this.ws().ready)) return;
208
- if (this.ui().isOnDeletion) {
209
- this.ba.openModal('restore');
210
- return;
211
- }
212
- if (!this.ui().isServiceConnected && !this.ui().isSigned) {
213
- this.ba.openModal('signup');
214
- return;
215
- }
216
- if (this.ui().isServiceConnected && !this.ui().isSigned) {
217
- // LOG-IN branch: emit the signin transaction, then open the signin modal
218
- // and flag the signing loader. The runtime clears the loader once
219
- // `user:txns` reports no pending txns.
220
- this.ba.requestSignin();
221
- const known = ['google', 'metamask', 'phantom', 'microsoft', 'blockauth'];
222
- if (known.includes(this.ui().serviceName ?? '')) {
223
- this.ba.openModal('signin');
224
- setIsSigningLoader(true);
225
- }
226
- }
227
- }
228
- }
@@ -1,81 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { Component, input } from '@angular/core';
3
- import { render, screen, fireEvent } from '@testing-library/angular';
4
- import { ModalOverlayComponent } from './modal-overlay.component';
5
-
6
- // Port de packages/react/src/components/modals/ModalOverlay.tsx (mapa:
7
- // packages/vue/src/components/modals/ModalOverlay.test.ts): verifica el
8
- // contrato de portal + backdrop-click + slot que comparten los 4 modales.
9
- // Los signal inputs no se pueden fijar por `componentInputs` de forma fiable,
10
- // así que se usa un host component con binding de template.
11
- @Component({
12
- selector: 'ba-overlay-host',
13
- standalone: true,
14
- imports: [ModalOverlayComponent],
15
- template: `
16
- <ba-modal-overlay [open]="open()" testId="modal-x" (closed)="onClose()">
17
- <div data-testid="panel-content">hola</div>
18
- </ba-modal-overlay>
19
- `,
20
- })
21
- class OverlayHostComponent {
22
- open = input(false);
23
- onClose = (): void => undefined;
24
- }
25
-
26
- describe('ModalOverlay', () => {
27
- it('no renderiza nada cuando open es false', async () => {
28
- await render(OverlayHostComponent);
29
- expect(screen.queryByTestId('modal-x')).toBeNull();
30
- });
31
-
32
- it('se monta en document.body (portal) y renderiza el slot cuando open es true', async () => {
33
- @Component({
34
- selector: 'ba-overlay-host-open',
35
- standalone: true,
36
- imports: [ModalOverlayComponent],
37
- template: `
38
- <ba-modal-overlay [open]="true" testId="modal-x">
39
- <div data-testid="panel-content">hola</div>
40
- </ba-modal-overlay>
41
- `,
42
- })
43
- class HostOpen {}
44
- await render(HostOpen);
45
- const overlay = screen.getByTestId('modal-x');
46
- expect(overlay).toBeDefined();
47
- expect(overlay.parentElement).toBe(document.body);
48
- expect(screen.getByTestId('panel-content').textContent).toBe('hola');
49
- });
50
-
51
- it('el panel tiene role="dialog" y aria-modal="true"', async () => {
52
- @Component({
53
- selector: 'ba-overlay-host-dialog',
54
- standalone: true,
55
- imports: [ModalOverlayComponent],
56
- template: `<ba-modal-overlay [open]="true" testId="modal-x" />`,
57
- })
58
- class HostDialog {}
59
- await render(HostDialog);
60
- const dialog = screen.getByRole('dialog');
61
- expect(dialog.getAttribute('aria-modal')).toBe('true');
62
- });
63
-
64
- it('al hacer click en el backdrop emite closed', async () => {
65
- const onClose = vi.fn();
66
- @Component({
67
- selector: 'ba-overlay-host-close',
68
- standalone: true,
69
- imports: [ModalOverlayComponent],
70
- template: `<ba-modal-overlay [open]="true" testId="modal-x" (closed)="onClose()" />`,
71
- })
72
- class HostClose {
73
- onClose = onClose;
74
- }
75
- await render(HostClose);
76
- const backdrop = screen.getByTestId('modal-x').querySelector('[aria-hidden="true"]');
77
- expect(backdrop).not.toBeNull();
78
- await fireEvent.click(backdrop!);
79
- expect(onClose).toHaveBeenCalledOnce();
80
- });
81
- });
@@ -1,43 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
2
- import { TeleportBodyDirective } from '../../teleport-body.directive';
3
-
4
- // Overlay mínimo usado por los 4 modales. La fuente React usaba `<ModalBase>` de
5
- // `@block-auth.io/blockauth-lib-react` (un Dialog headless-ui con transiciones
6
- // + portal); esa lib aún no es dependencia de este paquete, así que este es un
7
- // stand-in ligero que preserva las clases `bas-` del panel original y el
8
- // contrato open/close. La visibilidad la maneja el estado core `$openModals`
9
- // en cada modal llamador.
10
- //
11
- // Se monta en `document.body` vía `baTeleportBody` (equivalente a
12
- // createPortal(..., document.body) / <Teleport to="body">): las apps host
13
- // montan `FlowBlockAuth` dentro de contenedores transformados/animados que de
14
- // otro modo atraparían el overlay `fixed` dentro de ese ancestro.
15
- @Component({
16
- selector: 'ba-modal-overlay',
17
- standalone: true,
18
- changeDetection: ChangeDetectionStrategy.OnPush,
19
- imports: [TeleportBodyDirective],
20
- template: `
21
- @if (open()) {
22
- <div
23
- baTeleportBody
24
- [attr.data-testid]="testId()"
25
- [class]="'bas-fixed bas-inset-0 bas-z-50 bas-bg-black/40 ' + containerClassName()"
26
- >
27
- <div class="bas-absolute bas-inset-0" aria-hidden="true" (click)="closed.emit()"></div>
28
- <div [class]="'bas-relative ' + panelClassName()" role="dialog" aria-modal="true">
29
- <ng-content />
30
- </div>
31
- </div>
32
- }
33
- `,
34
- })
35
- export class ModalOverlayComponent {
36
- open = input.required<boolean>();
37
- panelClassName = input('');
38
- containerClassName = input(
39
- 'bas-flex bas-min-h-full bas-items-end xmd:bas-items-baseline xmd:bas-justify-center',
40
- );
41
- testId = input<string | undefined>(undefined);
42
- closed = output<void>();
43
- }
@@ -1,71 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent } from '@testing-library/angular';
3
- import { atom } from 'nanostores';
4
- import type { ModalName } from '@block-auth.io/core';
5
- import { ModalRestorationExpiredComponent } from './modal-restoration-expired.component';
6
- import { provideBlockAuthClientForTest } from '../../testing';
7
-
8
- vi.mock('@wagmi/core', () => ({
9
- createConfig: vi.fn(() => ({ connectors: [] })),
10
- connect: vi.fn(), disconnect: vi.fn(), getAccount: vi.fn(() => ({})),
11
- signMessage: vi.fn(), watchAccount: vi.fn(() => () => undefined), http: vi.fn(),
12
- }));
13
- vi.mock('@wagmi/connectors', () => ({
14
- injected: vi.fn(() => ({ id: 'injected' })), walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
15
- }));
16
-
17
- // ModalRestorationExpired inyecta el client directamente (BlockAuthService no
18
- // expone finalizeRestorationExpired()), así que el fake sólo necesita
19
- // state.$openModals + los métodos.
20
- function makeClient() {
21
- const $openModals = atom<ModalName[]>([]);
22
- const openModal = (m: ModalName) => $openModals.set([...$openModals.get(), m]);
23
- const closeModal = vi.fn(() => $openModals.set([]));
24
- const finalizeRestorationExpired = vi.fn();
25
- const client = { state: { $openModals }, openModal, closeModal, finalizeRestorationExpired } as any;
26
- return { client, $openModals, openModal, closeModal, finalizeRestorationExpired };
27
- }
28
-
29
- // Port de packages/react/src/components/modals/ModalRestorationExpired.test.tsx.
30
- describe('ModalRestorationExpired', () => {
31
- it('no renderiza cuando el modal está cerrado', async () => {
32
- const { client } = makeClient();
33
- await render(ModalRestorationExpiredComponent, { providers: [provideBlockAuthClientForTest(client)] });
34
- expect(screen.queryByTestId('modal-restoration-expired')).toBeNull();
35
- });
36
-
37
- it('renderiza el contenido cuando el modal restorationExpired está abierto', async () => {
38
- const { client } = makeClient();
39
- client.openModal('restorationExpired');
40
- await render(ModalRestorationExpiredComponent, { providers: [provideBlockAuthClientForTest(client)] });
41
- expect(screen.getByTestId('modal-restoration-expired')).toBeDefined();
42
- expect(screen.getByText('Restoration Period Expired')).toBeDefined();
43
- });
44
-
45
- it('al hacer click en "Continue" llama finalizeRestorationExpired() y luego closeModal()', async () => {
46
- const { client } = makeClient();
47
- const callOrder: string[] = [];
48
- client.finalizeRestorationExpired = vi.fn(() => callOrder.push('finalize'));
49
- client.closeModal = vi.fn(() => callOrder.push('closeModal'));
50
- client.openModal('restorationExpired');
51
-
52
- await render(ModalRestorationExpiredComponent, { providers: [provideBlockAuthClientForTest(client)] });
53
- await fireEvent.click(screen.getByRole('button', { name: /continue/i }));
54
-
55
- expect(client.finalizeRestorationExpired).toHaveBeenCalledOnce();
56
- expect(client.closeModal).toHaveBeenCalledOnce();
57
- expect(callOrder).toEqual(['finalize', 'closeModal']);
58
- });
59
-
60
- it('al hacer click en el backdrop también llama finalizeRestorationExpired() y closeModal()', async () => {
61
- const { client, finalizeRestorationExpired, closeModal } = makeClient();
62
- client.openModal('restorationExpired');
63
-
64
- await render(ModalRestorationExpiredComponent, { providers: [provideBlockAuthClientForTest(client)] });
65
- const backdrop = screen.getByTestId('modal-restoration-expired').querySelector('[aria-hidden="true"]');
66
- await fireEvent.click(backdrop!);
67
-
68
- expect(finalizeRestorationExpired).toHaveBeenCalledOnce();
69
- expect(closeModal).toHaveBeenCalledOnce();
70
- });
71
- });
@@ -1,83 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed } from '@angular/core';
2
- import { ModalOverlayComponent } from './modal-overlay.component';
3
- import { BtnBaseComponent } from '../../primitives/btn-base.component';
4
- import { PiWarningFillComponent, FaArrowRightComponent } from '../../icons';
5
- import { injectBlockAuthClient } from '../../provide-block-auth';
6
- import { injectStore } from '../../inject-store';
7
-
8
- const TEXTS = {
9
- title: 'Restoration Period Expired',
10
- message:
11
- 'Account permanently deleted, please complete the registration again to use Blockauth again',
12
- button: 'Continue',
13
- };
14
-
15
- /**
16
- * Modal de restauración expirada fino, dirigido por el core. Visibilidad por
17
- * `openModals().includes('restorationExpired')`. Confirmar (o backdrop) ejecuta
18
- * `finalizeRestorationExpired()` (limpia el storage de auth restante y resetea
19
- * los flags de borrado/firma) y luego `closeModal()`.
20
- *
21
- * El `text` de React era un ReactNode (label + icono); igual que en el port Vue
22
- * se usa el slot de contenido por defecto de `<ba-btn-base>` (`isIcon=false`)
23
- * para renderizar la etiqueta + la flecha, en vez de la prop `text`.
24
- *
25
- * Se inyecta el client directamente (no via BlockAuthService) porque
26
- * `finalizeRestorationExpired()` no está expuesto en el facade.
27
- */
28
- @Component({
29
- selector: 'ba-modal-restoration-expired',
30
- standalone: true,
31
- changeDetection: ChangeDetectionStrategy.OnPush,
32
- imports: [ModalOverlayComponent, BtnBaseComponent, PiWarningFillComponent, FaArrowRightComponent],
33
- template: `
34
- <ba-modal-overlay
35
- testId="modal-restoration-expired"
36
- [open]="open()"
37
- containerClassName="bas-flex bas-h-full bas-items-end bas-justify-center md:bas-items-center"
38
- panelClassName="bas-overflow-hidden bas-bg-white bas-rounded-2xl bas-w-[90%] sm:bas-max-w-[540px]"
39
- (closed)="onOkClicked()"
40
- >
41
- <header class="bas-w-full bas-border-b-2 bas-border-solid bas-border-[--bal-primary-100] bas-bg-[--bg-200] bas-py-6 bas-px-8 bas-text-center sm:bas-py-10">
42
- <h3 class="bas-text-lg bas-font-bold bas-text-[--bal-primary-900] sm:bas-text-2xl">{{ TEXTS.title }}</h3>
43
- </header>
44
- <main class="bas-flex bas-flex-col bas-gap-8 bas-p-8 sm:bas-gap-10 sm:bas-p-12">
45
- <div class="bas-flex bas-flex-col bas-items-center bas-gap-6 bas-text-center">
46
- <ba-pi-warning-fill class="bas-h-12 bas-w-12 bas-text-black sm:bas-h-20 sm:bas-w-20" />
47
- <article class="bas-text-sm bas-font-medium bas-leading-relaxed bas-text-black sm:bas-text-base">{{ TEXTS.message }}</article>
48
- </div>
49
- <footer class="bas-flex bas-w-full bas-justify-center">
50
- <ba-btn-base
51
- btnId="btn-ok-restoration-expired"
52
- size="small"
53
- bgClassNames="bas-bg-blue-900"
54
- ringClassNames="bal-ba-hover-ring-blue-600 bal-ba-focus-ring-blue-600"
55
- textClassNames="bas-text-white bas-font-semibold"
56
- classNames="bas-w-full bas-justify-center bas-shadow-md"
57
- paddingClassNames="bas-py-3"
58
- [isIcon]="false"
59
- [disabled]="!open()"
60
- (action)="onOkClicked()"
61
- >
62
- <div class="bas-flex bas-items-center bas-gap-2">
63
- <span class="bas-uppercase bas-tracking-wider">{{ TEXTS.button }}</span>
64
- <ba-fa-arrow-right class="bas-text-white" />
65
- </div>
66
- </ba-btn-base>
67
- </footer>
68
- </main>
69
- </ba-modal-overlay>
70
- `,
71
- })
72
- export class ModalRestorationExpiredComponent {
73
- protected readonly TEXTS = TEXTS;
74
-
75
- private readonly client = injectBlockAuthClient();
76
- private readonly openModals = injectStore(this.client.state.$openModals);
77
- readonly open = computed(() => this.openModals().includes('restorationExpired'));
78
-
79
- onOkClicked(): void {
80
- this.client.finalizeRestorationExpired();
81
- this.client.closeModal();
82
- }
83
- }
@@ -1,74 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent } from '@testing-library/angular';
3
- import { atom } from 'nanostores';
4
- import type { ModalName, RestoreResult } from '@block-auth.io/core';
5
- import { ModalRestoreComponent } from './modal-restore.component';
6
- import { provideBlockAuthClientForTest } from '../../testing';
7
-
8
- vi.mock('@wagmi/core', () => ({
9
- createConfig: vi.fn(() => ({ connectors: [] })),
10
- connect: vi.fn(), disconnect: vi.fn(), getAccount: vi.fn(() => ({})),
11
- signMessage: vi.fn(), watchAccount: vi.fn(() => () => undefined), http: vi.fn(),
12
- }));
13
- vi.mock('@wagmi/connectors', () => ({
14
- injected: vi.fn(() => ({ id: 'injected' })), walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
15
- }));
16
-
17
- // ModalRestore inyecta el client directamente (BlockAuthService no expone
18
- // restore()), así que el fake sólo necesita state.$openModals + los métodos.
19
- function makeClient() {
20
- const $openModals = atom<ModalName[]>([]);
21
- const openModal = (m: ModalName) => $openModals.set([...$openModals.get(), m]);
22
- const closeModal = vi.fn(() => $openModals.set([]));
23
- const restore = vi.fn((): Promise<RestoreResult> => Promise.resolve({ success: true }));
24
- const client = { state: { $openModals }, openModal, closeModal, restore } as any;
25
- return { client, $openModals, openModal, closeModal, restore };
26
- }
27
-
28
- // Port de packages/react/src/components/modals/ModalRestore.test.tsx.
29
- describe('ModalRestore', () => {
30
- it('no renderiza cuando el modal está cerrado', async () => {
31
- const { client } = makeClient();
32
- await render(ModalRestoreComponent, { providers: [provideBlockAuthClientForTest(client)] });
33
- expect(screen.queryByTestId('modal-restore')).toBeNull();
34
- });
35
-
36
- it('renderiza el contenido cuando el modal restore está abierto', async () => {
37
- const { client } = makeClient();
38
- client.openModal('restore');
39
- await render(ModalRestoreComponent, { providers: [provideBlockAuthClientForTest(client)] });
40
- expect(screen.getByTestId('modal-restore')).toBeDefined();
41
- expect(screen.getByText('Do you want to restore your account?')).toBeDefined();
42
- });
43
-
44
- it('click en "No" llama solo client.closeModal(), sin invocar restore()', async () => {
45
- const { client, closeModal, restore } = makeClient();
46
- client.openModal('restore');
47
- await render(ModalRestoreComponent, { providers: [provideBlockAuthClientForTest(client)] });
48
- await fireEvent.click(screen.getByRole('button', { name: /no/i }));
49
-
50
- expect(closeModal).toHaveBeenCalledOnce();
51
- expect(restore).not.toHaveBeenCalled();
52
- });
53
-
54
- it('click en "Restore" llama closeModal() antes de await restore(), en ese orden', async () => {
55
- const { client } = makeClient();
56
- const callOrder: string[] = [];
57
- client.closeModal = vi.fn(() => callOrder.push('closeModal'));
58
- let resolveRestore: (result: RestoreResult) => void;
59
- client.restore = vi.fn(() => {
60
- callOrder.push('restore');
61
- return new Promise<RestoreResult>((resolve) => { resolveRestore = resolve; });
62
- });
63
- client.openModal('restore');
64
-
65
- await render(ModalRestoreComponent, { providers: [provideBlockAuthClientForTest(client)] });
66
- await fireEvent.click(screen.getByRole('button', { name: /restore/i }));
67
-
68
- expect(client.closeModal).toHaveBeenCalledOnce();
69
- expect(client.restore).toHaveBeenCalledOnce();
70
- expect(callOrder).toEqual(['closeModal', 'restore']);
71
-
72
- resolveRestore!({ success: true });
73
- });
74
- });