@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.
- package/fesm2022/block-auth.io-angular.mjs +9828 -0
- package/fesm2022/block-auth.io-angular.mjs.map +1 -0
- package/index.d.ts +1144 -0
- package/package.json +16 -37
- package/.turbo/turbo-build.log +0 -37
- package/.turbo/turbo-lint.log +0 -4
- package/.turbo/turbo-test.log +0 -1400
- package/.turbo/turbo-typecheck.log +0 -19
- package/CHANGELOG.md +0 -273
- package/ng-package.json +0 -6
- package/scripts/css-to-ts.mjs +0 -14
- package/src/lib/__tests__/integration.test.ts +0 -45
- package/src/lib/block-auth.service.test.ts +0 -69
- package/src/lib/block-auth.service.ts +0 -81
- package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
- package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
- package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
- package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
- package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
- package/src/lib/components/btns/btn-gmail.component.ts +0 -41
- package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
- package/src/lib/components/btns/btn-google-base.component.ts +0 -73
- package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
- package/src/lib/components/btns/btn-metamask.component.ts +0 -98
- package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
- package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
- package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
- package/src/lib/components/btns/btn-phantom.component.ts +0 -93
- package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
- package/src/lib/components/btns/btn-signin.component.ts +0 -108
- package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
- package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
- package/src/lib/components/btns/index.ts +0 -11
- package/src/lib/components/contents/content-signin.component.test.ts +0 -33
- package/src/lib/components/contents/content-signin.component.ts +0 -68
- package/src/lib/components/contents/content-signup.component.test.ts +0 -86
- package/src/lib/components/contents/content-signup.component.ts +0 -222
- package/src/lib/components/dds/change-account.component.test.ts +0 -66
- package/src/lib/components/dds/change-account.component.ts +0 -112
- package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
- package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
- package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
- package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
- package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
- package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
- package/src/lib/components/flow-block-auth.component.test.ts +0 -95
- package/src/lib/components/flow-block-auth.component.ts +0 -228
- package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
- package/src/lib/components/modals/modal-overlay.component.ts +0 -43
- package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
- package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
- package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
- package/src/lib/components/modals/modal-restore.component.ts +0 -104
- package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
- package/src/lib/components/modals/modal-signin.component.ts +0 -44
- package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
- package/src/lib/components/modals/modal-signup.component.ts +0 -40
- package/src/lib/components/sections/footer-section.component.test.ts +0 -19
- package/src/lib/components/sections/footer-section.component.ts +0 -49
- package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
- package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
- package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
- package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
- package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
- package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
- package/src/lib/components/sections/login-section.component.test.ts +0 -49
- package/src/lib/components/sections/login-section.component.ts +0 -119
- package/src/lib/components/sections/providers-section.component.test.ts +0 -22
- package/src/lib/components/sections/providers-section.component.ts +0 -187
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
- package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
- package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
- package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
- package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
- package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
- package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
- package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
- package/src/lib/components/txns/internals/txn.component.ts +0 -453
- package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
- package/src/lib/components/txns/txns-overview.component.ts +0 -461
- package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
- package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
- package/src/lib/icons/cg-profile.component.ts +0 -31
- package/src/lib/icons/check-icon.component.ts +0 -27
- package/src/lib/icons/ci-clock2.component.ts +0 -31
- package/src/lib/icons/fa-arrow-right.component.ts +0 -21
- package/src/lib/icons/fa-times.component.ts +0 -21
- package/src/lib/icons/fa-undo.component.ts +0 -21
- package/src/lib/icons/icons.test.ts +0 -25
- package/src/lib/icons/index.ts +0 -22
- package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
- package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
- package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
- package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
- package/src/lib/icons/pi-warning-fill.component.ts +0 -21
- package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
- package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
- package/src/lib/icons/tb-copy.component.ts +0 -34
- package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
- package/src/lib/inject-store.test.ts +0 -26
- package/src/lib/inject-store.ts +0 -16
- package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
- package/src/lib/primitives/arrow-icon.component.ts +0 -45
- package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
- package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
- package/src/lib/primitives/btn-base.component.test.ts +0 -38
- package/src/lib/primitives/btn-base.component.ts +0 -140
- package/src/lib/primitives/divider-base.component.test.ts +0 -12
- package/src/lib/primitives/divider-base.component.ts +0 -74
- package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
- package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
- package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
- package/src/lib/primitives/dropdown-base.component.ts +0 -329
- package/src/lib/primitives/helpers.ts +0 -151
- package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
- package/src/lib/primitives/horizontal-loader.component.ts +0 -46
- package/src/lib/primitives/icon-base.component.test.ts +0 -19
- package/src/lib/primitives/icon-base.component.ts +0 -58
- package/src/lib/primitives/img-loader.component.test.ts +0 -22
- package/src/lib/primitives/img-loader.component.ts +0 -121
- package/src/lib/primitives/index.ts +0 -29
- package/src/lib/primitives/input-base.component.test.ts +0 -20
- package/src/lib/primitives/input-base.component.ts +0 -210
- package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
- package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
- package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
- package/src/lib/primitives/oval-spinner.component.ts +0 -136
- package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
- package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
- package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
- package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
- package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
- package/src/lib/primitives/progressbar.component.test.ts +0 -34
- package/src/lib/primitives/progressbar.component.ts +0 -36
- package/src/lib/primitives/providersStyles.ts +0 -218
- package/src/lib/primitives/slider-base.component.ts +0 -56
- package/src/lib/provide-block-auth.test.ts +0 -43
- package/src/lib/provide-block-auth.ts +0 -43
- package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
- package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
- package/src/lib/teleport-body.directive.test.ts +0 -29
- package/src/lib/teleport-body.directive.ts +0 -21
- package/src/lib/testing.ts +0 -15
- package/src/lib/transitions.css +0 -19
- package/src/public-api.ts +0 -86
- package/src/vitest.setup.ts +0 -8
- package/tailwind.config.cjs +0 -6
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -9
- package/vite.config.mts +0 -44
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core';
|
|
2
|
-
import { ModalOverlayComponent } from './modal-overlay.component';
|
|
3
|
-
import { BtnBaseComponent } from '../../primitives/btn-base.component';
|
|
4
|
-
import { FaTimesComponent, FaUndoComponent } from '../../icons';
|
|
5
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
6
|
-
import { injectStore } from '../../inject-store';
|
|
7
|
-
|
|
8
|
-
const TEXTS = {
|
|
9
|
-
title: 'Do you want to restore your account?',
|
|
10
|
-
message: 'By continuing you will be able to return to your usual operations.',
|
|
11
|
-
yes: 'Restore',
|
|
12
|
-
no: 'No',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Modal de restauración de cuenta fino, dirigido por el core. Visibilidad por
|
|
17
|
-
* `openModals().includes('restore')`; el cierre delega en `closeModal()`.
|
|
18
|
-
* Confirmar cierra el modal y luego `await client.restore()` (el core resuelve
|
|
19
|
-
* la dirección de borrado/DID, emite `sdk:restore` y espera el desenlace). Los
|
|
20
|
-
* botones se deshabilitan mientras la restauración está en curso.
|
|
21
|
-
*
|
|
22
|
-
* Se inyecta el client directamente (no via BlockAuthService) porque `restore()`
|
|
23
|
-
* no está expuesto en el facade.
|
|
24
|
-
*/
|
|
25
|
-
@Component({
|
|
26
|
-
selector: 'ba-modal-restore',
|
|
27
|
-
standalone: true,
|
|
28
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
29
|
-
imports: [ModalOverlayComponent, BtnBaseComponent, FaTimesComponent, FaUndoComponent],
|
|
30
|
-
template: `
|
|
31
|
-
<ba-modal-overlay
|
|
32
|
-
testId="modal-restore"
|
|
33
|
-
[open]="open()"
|
|
34
|
-
containerClassName="bas-flex bas-h-full bas-items-end bas-justify-center md:bas-items-center"
|
|
35
|
-
panelClassName="bas-overflow-hidden bas-bg-white bas-rounded-2xl bas-w-[90%] sm:bas-max-w-[540px]"
|
|
36
|
-
(closed)="onNoClicked()"
|
|
37
|
-
>
|
|
38
|
-
<div 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 sm:bas-py-10 bas-text-center">
|
|
39
|
-
<h3 class="bas-text-lg bas-font-bold bas-text-[--bal-primary-900] sm:bas-text-2xl">{{ TEXTS.title }}</h3>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="bas-flex bas-flex-col bas-gap-8 bas-p-8 sm:bas-gap-10 sm:bas-p-12">
|
|
42
|
-
<div class="bas-flex bas-flex-col bas-gap-4 bas-text-center">
|
|
43
|
-
<p class="bas-text-base bas-text-[--bal-primary-800] sm:bas-text-lg">{{ TEXTS.message }}</p>
|
|
44
|
-
</div>
|
|
45
|
-
<div class="bas-flex bas-w-full bas-flex-col-reverse bas-gap-4 sm:bas-flex-row">
|
|
46
|
-
<ba-btn-base
|
|
47
|
-
btnId="btn-no-restore-account"
|
|
48
|
-
[text]="TEXTS.no"
|
|
49
|
-
size="small"
|
|
50
|
-
bgClassNames="bas-bg-blue-900"
|
|
51
|
-
ringClassNames="bal-ba-hover-ring-blue-600 bal-ba-focus-ring-blue-600"
|
|
52
|
-
textClassNames="bas-text-white bas-font-semibold bas-uppercase bas-tracking-wider"
|
|
53
|
-
classNames="bas-w-full bas-justify-center bas-shadow-md"
|
|
54
|
-
paddingClassNames="bas-py-3"
|
|
55
|
-
[isIcon]="true"
|
|
56
|
-
[disabled]="!open() || isRestoring()"
|
|
57
|
-
(action)="onNoClicked()"
|
|
58
|
-
>
|
|
59
|
-
<ba-fa-times slot="icon" class="bas-mr-2 bas-text-white" />
|
|
60
|
-
</ba-btn-base>
|
|
61
|
-
<ba-btn-base
|
|
62
|
-
btnId="btn-yes-restore-account"
|
|
63
|
-
[text]="TEXTS.yes"
|
|
64
|
-
size="small"
|
|
65
|
-
bgClassNames="bas-bg-green-600 hover:bas-bg-green-700"
|
|
66
|
-
ringClassNames="bal-ba-hover-ring-green-600 bal-ba-focus-ring-green-600"
|
|
67
|
-
textClassNames="bas-text-white bas-font-semibold bas-tracking-wider bas-uppercase"
|
|
68
|
-
classNames="bas-w-full bas-justify-center bas-shadow-lg"
|
|
69
|
-
paddingClassNames="bas-py-3"
|
|
70
|
-
[isIcon]="true"
|
|
71
|
-
[disabled]="!open() || isRestoring()"
|
|
72
|
-
(action)="onYesClicked()"
|
|
73
|
-
>
|
|
74
|
-
<ba-fa-undo slot="icon" class="bas-mr-2 bas-text-white" />
|
|
75
|
-
</ba-btn-base>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
</ba-modal-overlay>
|
|
79
|
-
`,
|
|
80
|
-
})
|
|
81
|
-
export class ModalRestoreComponent {
|
|
82
|
-
protected readonly TEXTS = TEXTS;
|
|
83
|
-
|
|
84
|
-
private readonly client = injectBlockAuthClient();
|
|
85
|
-
private readonly openModals = injectStore(this.client.state.$openModals);
|
|
86
|
-
readonly open = computed(() => this.openModals().includes('restore'));
|
|
87
|
-
readonly isRestoring = signal(false);
|
|
88
|
-
|
|
89
|
-
onNoClicked(): void {
|
|
90
|
-
if (this.isRestoring()) return;
|
|
91
|
-
this.client.closeModal();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async onYesClicked(): Promise<void> {
|
|
95
|
-
if (this.isRestoring()) return;
|
|
96
|
-
this.isRestoring.set(true);
|
|
97
|
-
this.client.closeModal();
|
|
98
|
-
try {
|
|
99
|
-
await this.client.restore();
|
|
100
|
-
} finally {
|
|
101
|
-
this.isRestoring.set(false);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
3
|
-
import { atom, map } from 'nanostores';
|
|
4
|
-
import type { ModalName } from '@block-auth.io/core';
|
|
5
|
-
import { ModalSigninComponent } from './modal-signin.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
|
-
// Fake client con stores nanostores-backed: BlockAuthService lee $ws/$ui/$wallet/
|
|
18
|
-
// $openModals, así que los cuatro deben existir. `openModal`/`closeModal`/
|
|
19
|
-
// `cancelTxns` son spies (BlockAuthService captura closeModal/openModal por
|
|
20
|
-
// referencia en construcción, por eso se fijan antes de render).
|
|
21
|
-
function makeClient() {
|
|
22
|
-
const $openModals = atom<ModalName[]>([]);
|
|
23
|
-
const openModal = vi.fn((m: ModalName) => $openModals.set([...$openModals.get(), m]));
|
|
24
|
-
const closeModal = vi.fn(() => $openModals.set([]));
|
|
25
|
-
const cancelTxns = vi.fn();
|
|
26
|
-
const client = {
|
|
27
|
-
state: { $ws: map({}), $ui: map({}), $wallet: map({}), $openModals },
|
|
28
|
-
openModal, closeModal, cancelTxns,
|
|
29
|
-
} as any;
|
|
30
|
-
return { client, $openModals, openModal, closeModal, cancelTxns };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Port de packages/react/src/components/modals/ModalSignin.test.tsx.
|
|
34
|
-
describe('ModalSignin', () => {
|
|
35
|
-
it('no renderiza cuando el modal está cerrado', async () => {
|
|
36
|
-
const { client } = makeClient();
|
|
37
|
-
await render(ModalSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
38
|
-
expect(screen.queryByTestId('modal-signin')).toBeNull();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renderiza el modal signin (teleportado a body) cuando está abierto', async () => {
|
|
42
|
-
const { client } = makeClient();
|
|
43
|
-
client.openModal('signin');
|
|
44
|
-
await render(ModalSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
45
|
-
const overlay = screen.getByTestId('modal-signin');
|
|
46
|
-
expect(overlay).toBeDefined();
|
|
47
|
-
expect(overlay.parentElement).toBe(document.body);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('al cerrar (backdrop) llama cancelTxns() y luego closeModal(), en ese orden', async () => {
|
|
51
|
-
const { client } = makeClient();
|
|
52
|
-
const callOrder: string[] = [];
|
|
53
|
-
client.cancelTxns = vi.fn(() => callOrder.push('cancelTxns'));
|
|
54
|
-
client.closeModal = vi.fn(() => callOrder.push('closeModal'));
|
|
55
|
-
client.openModal('signin');
|
|
56
|
-
|
|
57
|
-
await render(ModalSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
58
|
-
const backdrop = screen.getByTestId('modal-signin').querySelector('[aria-hidden="true"]');
|
|
59
|
-
expect(backdrop).not.toBeNull();
|
|
60
|
-
await fireEvent.click(backdrop!);
|
|
61
|
-
|
|
62
|
-
expect(client.cancelTxns).toHaveBeenCalledOnce();
|
|
63
|
-
expect(client.closeModal).toHaveBeenCalledOnce();
|
|
64
|
-
expect(callOrder).toEqual(['cancelTxns', 'closeModal']);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
|
2
|
-
import { ModalOverlayComponent } from './modal-overlay.component';
|
|
3
|
-
import { ContentSigninComponent } from '../contents/content-signin.component';
|
|
4
|
-
import { BlockAuthService } from '../../block-auth.service';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Modal de sign-in fino, dirigido por el core. La visibilidad se deriva de
|
|
8
|
-
* `openModals().includes('signin')` y el cierre llama a `cancelTxns()` y luego
|
|
9
|
-
* a `closeModal()`. El ORDEN importa (idéntico al `.tsx`): `cancelTxns()`
|
|
10
|
-
* primero (emite `user:txns:update { state:'cancelled' }` sobre el socket) y
|
|
11
|
-
* `closeModal()` después (cierra localmente).
|
|
12
|
-
*
|
|
13
|
-
* El contenido real es `<ba-content-signin [closeTxns]="handleClose" />`
|
|
14
|
-
* (port de A9), que muestra el overview de transacciones / spinner de firma.
|
|
15
|
-
*/
|
|
16
|
-
@Component({
|
|
17
|
-
selector: 'ba-modal-signin',
|
|
18
|
-
standalone: true,
|
|
19
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
-
imports: [ModalOverlayComponent, ContentSigninComponent],
|
|
21
|
-
template: `
|
|
22
|
-
<ba-modal-overlay
|
|
23
|
-
testId="modal-signin"
|
|
24
|
-
[open]="open()"
|
|
25
|
-
panelClassName="bal-ba-glass-card xmd:bas-top-24 bas-w-full xsm1:bas-w-[380px] bas-text-left bas-h-[600px] bas-rounded-tl-[18px] bas-rounded-tr-[18px] xmd:bas-rounded-br-[18px] xmd:bas-rounded-bl-[18px]"
|
|
26
|
-
(closed)="handleClose()"
|
|
27
|
-
>
|
|
28
|
-
<div class="bas-flex bas-h-full bas-w-full bas-items-center bas-justify-center">
|
|
29
|
-
<div class="bas-relative bas-h-full bas-w-full">
|
|
30
|
-
<ba-content-signin [closeTxns]="handleClose" />
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</ba-modal-overlay>
|
|
34
|
-
`,
|
|
35
|
-
})
|
|
36
|
-
export class ModalSigninComponent {
|
|
37
|
-
private readonly ba = inject(BlockAuthService);
|
|
38
|
-
readonly open = computed(() => this.ba.openModals().includes('signin'));
|
|
39
|
-
|
|
40
|
-
readonly handleClose = (): void => {
|
|
41
|
-
this.ba.cancelTxns();
|
|
42
|
-
this.ba.closeModal();
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
3
|
-
import { atom, map } from 'nanostores';
|
|
4
|
-
import type { ModalName } from '@block-auth.io/core';
|
|
5
|
-
import { ModalSignupComponent } from './modal-signup.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
|
-
function makeClient() {
|
|
18
|
-
const $openModals = atom<ModalName[]>([]);
|
|
19
|
-
const openModal = vi.fn((m: ModalName) => $openModals.set([...$openModals.get(), m]));
|
|
20
|
-
const closeModal = vi.fn(() => $openModals.set([]));
|
|
21
|
-
const client = {
|
|
22
|
-
state: { $ws: map({}), $ui: map({}), $wallet: map({}), $openModals },
|
|
23
|
-
openModal, closeModal,
|
|
24
|
-
} as any;
|
|
25
|
-
return { client, $openModals, openModal, closeModal };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Port de packages/react/src/components/modals/ModalSignup.test.tsx.
|
|
29
|
-
describe('ModalSignup', () => {
|
|
30
|
-
it('no renderiza cuando el modal está cerrado', async () => {
|
|
31
|
-
const { client } = makeClient();
|
|
32
|
-
await render(ModalSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
33
|
-
expect(screen.queryByTestId('modal-signup')).toBeNull();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('renderiza el modal signup (teleportado a body) cuando está abierto', async () => {
|
|
37
|
-
const { client } = makeClient();
|
|
38
|
-
client.openModal('signup');
|
|
39
|
-
await render(ModalSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
40
|
-
const overlay = screen.getByTestId('modal-signup');
|
|
41
|
-
expect(overlay).toBeDefined();
|
|
42
|
-
expect(overlay.parentElement).toBe(document.body);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('al hacer click en el backdrop llama client.closeModal()', async () => {
|
|
46
|
-
const { client, closeModal } = makeClient();
|
|
47
|
-
client.openModal('signup');
|
|
48
|
-
await render(ModalSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
49
|
-
|
|
50
|
-
const backdrop = screen.getByTestId('modal-signup').querySelector('[aria-hidden="true"]');
|
|
51
|
-
expect(backdrop).not.toBeNull();
|
|
52
|
-
await fireEvent.click(backdrop!);
|
|
53
|
-
|
|
54
|
-
expect(closeModal).toHaveBeenCalledOnce();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
|
2
|
-
import { ModalOverlayComponent } from './modal-overlay.component';
|
|
3
|
-
import { ContentSignupComponent } from '../contents/content-signup.component';
|
|
4
|
-
import { BlockAuthService } from '../../block-auth.service';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Modal de sign-up fino, dirigido por el core. La visibilidad se deriva de
|
|
8
|
-
* `openModals().includes('signup')` y el cierre delega en `closeModal()`.
|
|
9
|
-
*
|
|
10
|
-
* El contenido real es `<ba-content-signup [isEditable]="false"
|
|
11
|
-
* [isEditing]="false" />` (port de A9).
|
|
12
|
-
* TODO: restaurar el estado de carga `<OvalSpinner>` cuando la lib de
|
|
13
|
-
* componentes esté cableada en este paquete (igual que en el `.tsx`).
|
|
14
|
-
*/
|
|
15
|
-
@Component({
|
|
16
|
-
selector: 'ba-modal-signup',
|
|
17
|
-
standalone: true,
|
|
18
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
19
|
-
imports: [ModalOverlayComponent, ContentSignupComponent],
|
|
20
|
-
template: `
|
|
21
|
-
<ba-modal-overlay
|
|
22
|
-
testId="modal-signup"
|
|
23
|
-
[open]="open()"
|
|
24
|
-
panelClassName="bal-ba-glass-card xmd:bas-top-24 xmd:bas-m-1 bas-min-w-fit bas-text-left xmd:bas-my-8 sm1:bas-h-[364px] bas-w-full xmd:bas-w-fit lg:bas-h-[376px] bas-h-[508px] bas-rounded-tl-[18px] bas-rounded-tr-[18px] xmd:bas-rounded-br-[18px] xmd:bas-rounded-bl-[18px]"
|
|
25
|
-
(closed)="onClose()"
|
|
26
|
-
>
|
|
27
|
-
<div class="bas-box-border bas-h-full bas-w-full bas-px-4 bas-pb-4 bas-pt-6 sm1:bas-pt-5 xmd:bas-pb-3.5 lg:bas-px-6 lg:bas-pb-5 lg:bas-pt-[26px]">
|
|
28
|
-
<ba-content-signup [isEditable]="false" [isEditing]="false" />
|
|
29
|
-
</div>
|
|
30
|
-
</ba-modal-overlay>
|
|
31
|
-
`,
|
|
32
|
-
})
|
|
33
|
-
export class ModalSignupComponent {
|
|
34
|
-
private readonly ba = inject(BlockAuthService);
|
|
35
|
-
readonly open = computed(() => this.ba.openModals().includes('signup'));
|
|
36
|
-
|
|
37
|
-
onClose(): void {
|
|
38
|
-
this.ba.closeModal();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,19 +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 { FooterSectionComponent } from './footer-section.component';
|
|
5
|
-
|
|
6
|
-
// Port de packages/react/src/components/sections/FooterSection.test.tsx.
|
|
7
|
-
describe('FooterSection', () => {
|
|
8
|
-
it('renderiza el footer con el enlace', async () => {
|
|
9
|
-
@Component({
|
|
10
|
-
standalone: true,
|
|
11
|
-
imports: [FooterSectionComponent],
|
|
12
|
-
template: `<ba-footer-section text1="Powered by" text2="Block-Auth" href="https://block-auth.io" />`,
|
|
13
|
-
})
|
|
14
|
-
class HostComponent {}
|
|
15
|
-
await render(HostComponent);
|
|
16
|
-
const link = screen.getByText('Block-Auth');
|
|
17
|
-
expect(link.getAttribute('href')).toBe('https://block-auth.io');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Port literal de packages/react/src/components/sections/FooterSection.tsx
|
|
5
|
-
* (mapa: packages/vue/.../sections/FooterSection.vue). Footer presentacional
|
|
6
|
-
* puro, sin core logic ni stores.
|
|
7
|
-
*/
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'ba-footer-section',
|
|
10
|
-
standalone: true,
|
|
11
|
-
// Hijo directo del grid de content-signup: el host debe ser transparente al
|
|
12
|
-
// layout para que el <footer> interno sea el grid item real (ver
|
|
13
|
-
// providers-section para el detalle). Sin esto el layout del modal se solapa.
|
|
14
|
-
host: { style: 'display: contents' },
|
|
15
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
-
template: `
|
|
17
|
-
<footer
|
|
18
|
-
data-testid="footer-section"
|
|
19
|
-
[class]="
|
|
20
|
-
'bas-group bas-box-border bas-flex bas-h-12 bas-items-end bas-justify-start bas-py-1 bas-text-left bas-text-gray-500 ' +
|
|
21
|
-
getFooterClassNames(isEditable(), device())
|
|
22
|
-
"
|
|
23
|
-
>
|
|
24
|
-
<p class="bas-ba-transition-2 bas-m-0 bas-text-left bas-text-gray-500 group-hover:bas-text-slate-600">
|
|
25
|
-
{{ text1() }}
|
|
26
|
-
<a
|
|
27
|
-
[href]="href()"
|
|
28
|
-
target="_blank"
|
|
29
|
-
rel="noreferrer"
|
|
30
|
-
class="bal-ba-transition-2 bas-font-semibold bas-leading-6 bas-text-[var(--bal-primary-900)] group-hover:bas-text-[var(--bal-primary-600)]"
|
|
31
|
-
>{{ text2() }}</a
|
|
32
|
-
>
|
|
33
|
-
</p>
|
|
34
|
-
</footer>
|
|
35
|
-
`,
|
|
36
|
-
})
|
|
37
|
-
export class FooterSectionComponent {
|
|
38
|
-
isEditable = input(false);
|
|
39
|
-
device = input<'desktop' | 'phone'>('desktop');
|
|
40
|
-
text1 = input('');
|
|
41
|
-
text2 = input('');
|
|
42
|
-
href = input('');
|
|
43
|
-
|
|
44
|
-
getFooterClassNames(editable: boolean, dev: string): string {
|
|
45
|
-
if (!editable) return 'bas-text-xxs xsm:bas-text-xs xsm1:bas-text-sm sm1:bas-col-span-2';
|
|
46
|
-
if (dev === 'phone') return 'bas-text-xs';
|
|
47
|
-
return 'bas-text-sm bas-col-span-2';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
4
|
-
import { ProvidersButtonsComponent } from './providers-buttons.component';
|
|
5
|
-
|
|
6
|
-
// Port de packages/react/src/components/sections/internals/ProvidersButtons.test.tsx.
|
|
7
|
-
// ProvidersButtons no inyecta el client (renderiza <ba-btn-base-provider>, que
|
|
8
|
-
// tampoco lo hace), así que no requiere provideBlockAuthClientForTest.
|
|
9
|
-
describe('ProvidersButtons', () => {
|
|
10
|
-
it('renderiza un boton por proveedor y propaga la seleccion', async () => {
|
|
11
|
-
const onSelected = vi.fn();
|
|
12
|
-
@Component({
|
|
13
|
-
standalone: true,
|
|
14
|
-
imports: [ProvidersButtonsComponent],
|
|
15
|
-
template: `<ba-providers-buttons [showedProviders]="providers" (selectedServiceChange)="onSelected($event)" />`,
|
|
16
|
-
})
|
|
17
|
-
class HostComponent {
|
|
18
|
-
providers = ['metamask', 'phantom'];
|
|
19
|
-
onSelected = onSelected;
|
|
20
|
-
}
|
|
21
|
-
await render(HostComponent);
|
|
22
|
-
const buttons = screen.getAllByRole('button');
|
|
23
|
-
expect(buttons.length).toBe(2);
|
|
24
|
-
await fireEvent.click(buttons[0]);
|
|
25
|
-
expect(onSelected).toHaveBeenCalledWith('metamask');
|
|
26
|
-
});
|
|
27
|
-
});
|