@block-auth.io/angular 0.4.0 → 0.5.0
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 +9976 -0
- package/fesm2022/block-auth.io-angular.mjs.map +1 -0
- package/index.d.ts +1155 -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,222 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
effect,
|
|
6
|
-
input,
|
|
7
|
-
signal,
|
|
8
|
-
untracked,
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
import {
|
|
11
|
-
$extension,
|
|
12
|
-
$locale,
|
|
13
|
-
deepLinkFor,
|
|
14
|
-
makeQrDataUrl,
|
|
15
|
-
needsExtensionUnlock,
|
|
16
|
-
t as translate,
|
|
17
|
-
type TextKey,
|
|
18
|
-
} from '@block-auth.io/core';
|
|
19
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
20
|
-
import { injectStore } from '../../inject-store';
|
|
21
|
-
import { providersStyles } from '../../primitives/providersStyles';
|
|
22
|
-
import { ProgressbarComponent } from '../../primitives/progressbar.component';
|
|
23
|
-
import { ProvidersSectionComponent } from '../sections/providers-section.component';
|
|
24
|
-
import { LoginSectionComponent } from '../sections/login-section.component';
|
|
25
|
-
import { FooterSectionComponent } from '../sections/footer-section.component';
|
|
26
|
-
import type { WebTypeItem } from '../sections/internals/providers-filters.component';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Contenido de sign-up: el `<ba-progressbar>` de 3 pasos, la
|
|
30
|
-
* `<ba-providers-section>` (cabecera + filtros + grid), la
|
|
31
|
-
* `<ba-login-section>` (logo + CTA + descripción) y la `<ba-footer-section>`,
|
|
32
|
-
* en el grid responsive de dos columnas.
|
|
33
|
-
*/
|
|
34
|
-
const ENABLED_PROVIDERS = ['google', 'microsoft', 'blockauth'];
|
|
35
|
-
const WEB2 = ['google', 'microsoft'];
|
|
36
|
-
const FALLBACK_PROVIDERS = ['blockauth', 'google', 'microsoft'];
|
|
37
|
-
|
|
38
|
-
function applyFilters(providers: string[], { webType, search }: { webType: string; search: string }): string[] {
|
|
39
|
-
let result = providers;
|
|
40
|
-
if (webType === 'web2') result = result.filter((item) => WEB2.includes(item));
|
|
41
|
-
else if (webType === 'web3') result = result.filter((item) => !WEB2.includes(item));
|
|
42
|
-
if (search) {
|
|
43
|
-
const q = search.toLowerCase();
|
|
44
|
-
result = result.filter((item) => item.toLowerCase().includes(q));
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Component({
|
|
50
|
-
selector: 'ba-content-signup',
|
|
51
|
-
standalone: true,
|
|
52
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
53
|
-
imports: [ProgressbarComponent, ProvidersSectionComponent, LoginSectionComponent, FooterSectionComponent],
|
|
54
|
-
template: `
|
|
55
|
-
<div
|
|
56
|
-
data-testid="content-signup"
|
|
57
|
-
[attr.data-device]="device()"
|
|
58
|
-
[class]="
|
|
59
|
-
'bal-ba-glass-signup bas-grid bas-h-full ' +
|
|
60
|
-
(!isEditable()
|
|
61
|
-
? 'bas-w-full bas-grid-cols-1 bas-grid-rows-[52px_140px_228px_48px] sm1:bas-w-fit sm1:bas-grid-cols-[240px_384px] sm1:bas-grid-rows-[52px_auto_auto] lg:bas-grid-cols-[240px_640px]'
|
|
62
|
-
: 'bas-w-fit')
|
|
63
|
-
"
|
|
64
|
-
>
|
|
65
|
-
<ba-providers-section
|
|
66
|
-
[container]="container()"
|
|
67
|
-
[uiConfigProvidersInfo]="uiConfigProvidersInfo()"
|
|
68
|
-
[selectedService]="selectedService()"
|
|
69
|
-
(selectedServiceChange)="selectedService.set($event)"
|
|
70
|
-
[showedProviders]="showedProviders()"
|
|
71
|
-
(changeWebType)="onChangeWebType($event)"
|
|
72
|
-
(changeProviderSearch)="onChangeProviderSearch($event)"
|
|
73
|
-
[isEditable]="isEditable()"
|
|
74
|
-
[isEditing]="isEditing()"
|
|
75
|
-
[device]="device()"
|
|
76
|
-
/>
|
|
77
|
-
|
|
78
|
-
<section
|
|
79
|
-
[class]="
|
|
80
|
-
'bas-flex bas-items-center bas-justify-center ' + (!isEditable() ? 'bas-row-start-1 sm1:bas-row-start-auto' : '')
|
|
81
|
-
"
|
|
82
|
-
>
|
|
83
|
-
<span class="bal-ba-glass-stepper">
|
|
84
|
-
<ba-progressbar [step]="showImgLoader() ? 2 : 3" />
|
|
85
|
-
</span>
|
|
86
|
-
</section>
|
|
87
|
-
|
|
88
|
-
<ba-login-section
|
|
89
|
-
[imgQR]="imgQR() ?? ''"
|
|
90
|
-
[showImgLoader]="showImgLoader()"
|
|
91
|
-
[selectedService]="selectedService()"
|
|
92
|
-
[isServiceConnected]="isServiceConnected()"
|
|
93
|
-
[isEditable]="isEditable()"
|
|
94
|
-
[device]="device()"
|
|
95
|
-
[btnsConnectTxt]="btnsConnectTxt()"
|
|
96
|
-
[loginTxt]="loginTxt()"
|
|
97
|
-
[lastStepTxt]="lastStepTxt()"
|
|
98
|
-
/>
|
|
99
|
-
|
|
100
|
-
<ba-footer-section
|
|
101
|
-
[isEditable]="isEditable()"
|
|
102
|
-
[device]="device() === 'phone' ? 'phone' : 'desktop'"
|
|
103
|
-
[text1]="footerText1()"
|
|
104
|
-
[text2]="footerText2()"
|
|
105
|
-
[href]="footerHref()"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
`,
|
|
109
|
-
})
|
|
110
|
-
export class ContentSignupComponent {
|
|
111
|
-
container = input<HTMLElement | null>(null);
|
|
112
|
-
isEditable = input(false);
|
|
113
|
-
isEditing = input(false);
|
|
114
|
-
device = input<'desktop' | 'tablet' | 'phone'>('desktop');
|
|
115
|
-
|
|
116
|
-
private readonly client = injectBlockAuthClient();
|
|
117
|
-
private readonly ui = injectStore(this.client.state.$ui);
|
|
118
|
-
private readonly ws = injectStore(this.client.state.$ws);
|
|
119
|
-
private readonly ext = injectStore($extension);
|
|
120
|
-
private readonly locale = injectStore($locale);
|
|
121
|
-
private readonly t = (key: TextKey): string => translate(key, this.locale());
|
|
122
|
-
|
|
123
|
-
// Etiquetas localizadas del text-map del backend, con fallback al i18n del core.
|
|
124
|
-
private readonly content = computed(() => (this.ui() as Record<string, any>)?.uiConfig?.config?.content);
|
|
125
|
-
protected btnsConnectTxt = computed(() => this.content()?.btns?.connect?.[this.locale()] ?? '');
|
|
126
|
-
protected loginTxt = computed(() => this.content()?.login?.[this.locale()] ?? this.t('login'));
|
|
127
|
-
protected lastStepTxt = computed(() => this.content()?.lastStep?.[this.locale()] ?? this.t('lastStep'));
|
|
128
|
-
protected footerText1 = computed(() => this.content()?.footer?.first?.[this.locale()] ?? this.t('footerFirst'));
|
|
129
|
-
protected footerText2 = computed(() => this.content()?.footer?.second?.[this.locale()] ?? this.t('footerSecond'));
|
|
130
|
-
protected footerHref = computed(() => this.content()?.footer?.url ?? 'https://block-auth.io');
|
|
131
|
-
|
|
132
|
-
protected serviceName = computed(() => (this.ui() as Record<string, any>)?.serviceName);
|
|
133
|
-
// An extension account still waiting for its OTP is not connected yet.
|
|
134
|
-
protected isServiceConnected = computed(
|
|
135
|
-
() =>
|
|
136
|
-
!!(this.ui() as Record<string, any>)?.isServiceConnected &&
|
|
137
|
-
!needsExtensionUnlock(this.serviceName(), this.ws().did, this.ext().isLocked),
|
|
138
|
-
);
|
|
139
|
-
private readonly domain = computed(
|
|
140
|
-
() => (this.ui() as Record<string, any>)?.uiConfig?.domain as string | undefined,
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
protected uiConfigProvidersInfo = computed(() => {
|
|
144
|
-
const config = (this.ui() as Record<string, any>)?.uiConfig?.config;
|
|
145
|
-
if (!config) return undefined;
|
|
146
|
-
return {
|
|
147
|
-
providersColumns: Number(config.providersColumns) || undefined,
|
|
148
|
-
showProviderNameOnMobile: config.showProviderNameOnMobile,
|
|
149
|
-
enableSearch: config.enableSearch,
|
|
150
|
-
enableWebTypeFilter: config.enableWebTypeFilter,
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
private readonly allProviders = computed<string[]>(() => {
|
|
155
|
-
const config = (this.ui() as Record<string, any>)?.uiConfig?.config;
|
|
156
|
-
if (config) {
|
|
157
|
-
const enabled = Object.keys(config)
|
|
158
|
-
.filter(
|
|
159
|
-
(key) =>
|
|
160
|
-
ENABLED_PROVIDERS.includes(key) &&
|
|
161
|
-
providersStyles[key] &&
|
|
162
|
-
typeof config[key] === 'object' &&
|
|
163
|
-
config[key] !== null &&
|
|
164
|
-
'enabled' in config[key] &&
|
|
165
|
-
'orderIndex' in config[key],
|
|
166
|
-
)
|
|
167
|
-
.filter((key) => config[key].enabled)
|
|
168
|
-
.sort((a, b) => config[a].orderIndex - config[b].orderIndex);
|
|
169
|
-
if (enabled.length > 0) return enabled;
|
|
170
|
-
}
|
|
171
|
-
return FALLBACK_PROVIDERS;
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
protected selectedService = signal<string>(this.allProviders()[0] ?? 'blockauth');
|
|
175
|
-
protected showedProviders = signal<string[]>(this.allProviders());
|
|
176
|
-
protected imgQR = signal<string | null>(null);
|
|
177
|
-
// Estado de filtros no reactivo: mutarlo no dispara reactividad.
|
|
178
|
-
private filterState: { webType: string; search: string } = { webType: 'all', search: '' };
|
|
179
|
-
|
|
180
|
-
protected showImgLoader = computed(
|
|
181
|
-
() => !(this.isServiceConnected() && this.serviceName() === this.selectedService()),
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
constructor() {
|
|
185
|
-
// Efecto 1: re-deriva showedProviders/selectedService cuando cambia allProviders.
|
|
186
|
-
effect(() => {
|
|
187
|
-
const providers = this.allProviders();
|
|
188
|
-
this.showedProviders.set(applyFilters(providers, this.filterState));
|
|
189
|
-
const cur = untracked(() => this.selectedService());
|
|
190
|
-
this.selectedService.set(providers.includes(cur) ? cur : providers[0] ?? 'blockauth');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// Efecto 2: genera el QR para providers web3 (metamask/phantom), con guard
|
|
194
|
-
// de cancelación.
|
|
195
|
-
effect((onCleanup) => {
|
|
196
|
-
const svc = this.selectedService();
|
|
197
|
-
const dom = this.domain();
|
|
198
|
-
const isWeb3 = svc === 'metamask' || svc === 'phantom';
|
|
199
|
-
if (!isWeb3 || !dom) {
|
|
200
|
-
this.imgQR.set(null);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
let cancelled = false;
|
|
204
|
-
const deepLink = deepLinkFor(svc, dom);
|
|
205
|
-
makeQrDataUrl(deepLink).then((dataUrl) => {
|
|
206
|
-
if (!cancelled) this.imgQR.set(dataUrl);
|
|
207
|
-
});
|
|
208
|
-
onCleanup(() => {
|
|
209
|
-
cancelled = true;
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
onChangeWebType(webType: WebTypeItem): void {
|
|
215
|
-
this.filterState = { ...this.filterState, webType: webType.value };
|
|
216
|
-
this.showedProviders.set(applyFilters(this.allProviders(), this.filterState));
|
|
217
|
-
}
|
|
218
|
-
onChangeProviderSearch(value: string): void {
|
|
219
|
-
this.filterState = { ...this.filterState, search: value };
|
|
220
|
-
this.showedProviders.set(applyFilters(this.allProviders(), this.filterState));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
@@ -1,66 +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 { map } from 'nanostores';
|
|
5
|
-
import { ChangeAccountComponent } from './change-account.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
|
-
// Port de packages/react/src/components/dds/ChangeAccountComponent.test.tsx
|
|
18
|
-
// (mapa: packages/vue/.../ChangeAccountComponent.test.ts).
|
|
19
|
-
describe('ChangeAccountComponent', () => {
|
|
20
|
-
function makeClient() {
|
|
21
|
-
return {
|
|
22
|
-
web3: { signup: vi.fn() },
|
|
23
|
-
oauth: { signupGoogle: vi.fn(), signupMicrosoft: vi.fn() },
|
|
24
|
-
connectBlockAuth: vi.fn(),
|
|
25
|
-
state: { $ui: map({}), $ws: map({}), $wallet: map({}) },
|
|
26
|
-
} as any;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const renderFor = (serviceName: string) =>
|
|
30
|
-
render(ChangeAccountComponent, {
|
|
31
|
-
inputs: { serviceName, text: 'Change account' },
|
|
32
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('renderiza el texto "Change account" para el serviceName blockauth', async () => {
|
|
36
|
-
await renderFor('blockauth');
|
|
37
|
-
expect(screen.getByText('Change account')).toBeDefined();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
for (const svc of ['blockauth', 'google', 'microsoft', 'metamask', 'phantom']) {
|
|
41
|
-
it(`renderiza para el provider soportado "${svc}"`, async () => {
|
|
42
|
-
await renderFor(svc);
|
|
43
|
-
expect(screen.getByText('Change account')).toBeDefined();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
it('no renderiza ningun boton para un serviceName desconocido', async () => {
|
|
48
|
-
await renderFor('desconocido');
|
|
49
|
-
expect(screen.queryByText('Change account')).toBeNull();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('emite changeAccountClicked al pulsar la fila', async () => {
|
|
53
|
-
const onChange = vi.fn();
|
|
54
|
-
@Component({
|
|
55
|
-
standalone: true,
|
|
56
|
-
imports: [ChangeAccountComponent],
|
|
57
|
-
template: `<ba-change-account serviceName="blockauth" text="Change account" (changeAccountClicked)="f()" />`,
|
|
58
|
-
})
|
|
59
|
-
class Host {
|
|
60
|
-
f = onChange;
|
|
61
|
-
}
|
|
62
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(makeClient())] });
|
|
63
|
-
await fireEvent.click(screen.getByText('Change account'));
|
|
64
|
-
expect(onChange).toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
|
|
2
|
-
import { TbArrowsExchange2Component } from '../../icons';
|
|
3
|
-
import { BtnBlockAuthComponent } from '../btns/btn-block-auth.component';
|
|
4
|
-
import { BtnGmailComponent } from '../btns/btn-gmail.component';
|
|
5
|
-
import { BtnMicrosoftComponent } from '../btns/btn-microsoft.component';
|
|
6
|
-
import { BtnMetamaskComponent } from '../btns/btn-metamask.component';
|
|
7
|
-
import { BtnPhantomComponent } from '../btns/btn-phantom.component';
|
|
8
|
-
import { DropdownProfileItemComponent } from './dropdown-profile-item.component';
|
|
9
|
-
|
|
10
|
-
// Rama de 5 vías sobre `serviceName` (blockauth/google/microsoft/metamask/
|
|
11
|
-
// phantom): cada una envuelve un `<ba-dropdown-profile-item>` (con el icono de
|
|
12
|
-
// intercambio) dentro del botón del provider en modo `isDropdownProfile`, que
|
|
13
|
-
// re-dispara el flujo de conexión de ese provider.
|
|
14
|
-
//
|
|
15
|
-
// El click real de "cambiar cuenta" no lo dispara este output por sí solo: el
|
|
16
|
-
// `<button>` nativo de cada `Btn*` en modo `isDropdownProfile` tiene su propio
|
|
17
|
-
// `(click)` (que ejecuta el signin/connect real); el `dropdown-profile-item`
|
|
18
|
-
// anidado es un `<div>` hijo de ese botón, y al clicarlo el evento burbujea al
|
|
19
|
-
// botón exterior, disparando AMBOS handlers.
|
|
20
|
-
@Component({
|
|
21
|
-
selector: 'ba-change-account',
|
|
22
|
-
standalone: true,
|
|
23
|
-
// Igual que `ba-dropdown-profile-item`: host transparente al layout para que
|
|
24
|
-
// el <div bas-w-full> sea hijo directo del flex de la <ul> y llene el ancho
|
|
25
|
-
// (con `bas-items-center` en la ul, un host inline se encogería y centraría).
|
|
26
|
-
host: { style: 'display: contents' },
|
|
27
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
28
|
-
imports: [
|
|
29
|
-
BtnBlockAuthComponent,
|
|
30
|
-
BtnGmailComponent,
|
|
31
|
-
BtnMicrosoftComponent,
|
|
32
|
-
BtnMetamaskComponent,
|
|
33
|
-
BtnPhantomComponent,
|
|
34
|
-
DropdownProfileItemComponent,
|
|
35
|
-
],
|
|
36
|
-
template: `
|
|
37
|
-
<div class="bas-h-9 bas-w-full">
|
|
38
|
-
@switch (serviceName()) {
|
|
39
|
-
@case ('blockauth') {
|
|
40
|
-
<ba-btn-block-auth [text]="text()" [isDropdownProfile]="true">
|
|
41
|
-
<ba-dropdown-profile-item
|
|
42
|
-
id="ba-ddi-change-account-1"
|
|
43
|
-
[text]="text()"
|
|
44
|
-
[firstIcon]="exchangeIcon"
|
|
45
|
-
[isTopBorder]="isTopBorder()"
|
|
46
|
-
[disabled]="disabled()"
|
|
47
|
-
(clicked)="changeAccountClicked.emit()"
|
|
48
|
-
/>
|
|
49
|
-
</ba-btn-block-auth>
|
|
50
|
-
}
|
|
51
|
-
@case ('google') {
|
|
52
|
-
<ba-btn-gmail [text]="text()" [isDropdownProfile]="true">
|
|
53
|
-
<ba-dropdown-profile-item
|
|
54
|
-
id="ba-ddi-change-account-1"
|
|
55
|
-
[text]="text()"
|
|
56
|
-
[firstIcon]="exchangeIcon"
|
|
57
|
-
[isTopBorder]="isTopBorder()"
|
|
58
|
-
[disabled]="disabled()"
|
|
59
|
-
(clicked)="changeAccountClicked.emit()"
|
|
60
|
-
/>
|
|
61
|
-
</ba-btn-gmail>
|
|
62
|
-
}
|
|
63
|
-
@case ('microsoft') {
|
|
64
|
-
<ba-btn-microsoft [text]="text()" [isDropdownProfile]="true">
|
|
65
|
-
<ba-dropdown-profile-item
|
|
66
|
-
id="ba-ddi-change-account-1"
|
|
67
|
-
[text]="text()"
|
|
68
|
-
[firstIcon]="exchangeIcon"
|
|
69
|
-
[isTopBorder]="isTopBorder()"
|
|
70
|
-
[disabled]="disabled()"
|
|
71
|
-
(clicked)="changeAccountClicked.emit()"
|
|
72
|
-
/>
|
|
73
|
-
</ba-btn-microsoft>
|
|
74
|
-
}
|
|
75
|
-
@case ('metamask') {
|
|
76
|
-
<ba-btn-metamask [text]="text()" [isDropdownProfile]="true">
|
|
77
|
-
<ba-dropdown-profile-item
|
|
78
|
-
id="ba-ddi-change-account-1"
|
|
79
|
-
[text]="text()"
|
|
80
|
-
[firstIcon]="exchangeIcon"
|
|
81
|
-
[isTopBorder]="isTopBorder()"
|
|
82
|
-
[disabled]="disabled()"
|
|
83
|
-
(clicked)="changeAccountClicked.emit()"
|
|
84
|
-
/>
|
|
85
|
-
</ba-btn-metamask>
|
|
86
|
-
}
|
|
87
|
-
@case ('phantom') {
|
|
88
|
-
<ba-btn-phantom [text]="text()" [isDropdownProfile]="true">
|
|
89
|
-
<ba-dropdown-profile-item
|
|
90
|
-
id="ba-ddi-change-account-1"
|
|
91
|
-
[text]="text()"
|
|
92
|
-
[firstIcon]="exchangeIcon"
|
|
93
|
-
[isTopBorder]="isTopBorder()"
|
|
94
|
-
[disabled]="disabled()"
|
|
95
|
-
(clicked)="changeAccountClicked.emit()"
|
|
96
|
-
/>
|
|
97
|
-
</ba-btn-phantom>
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
</div>
|
|
101
|
-
`,
|
|
102
|
-
})
|
|
103
|
-
export class ChangeAccountComponent {
|
|
104
|
-
serviceName = input('');
|
|
105
|
-
text = input('');
|
|
106
|
-
disabled = input(false);
|
|
107
|
-
isTopBorder = input(false);
|
|
108
|
-
|
|
109
|
-
changeAccountClicked = output<void>();
|
|
110
|
-
|
|
111
|
-
protected readonly exchangeIcon = TbArrowsExchange2Component;
|
|
112
|
-
}
|
|
@@ -1,66 +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 { map } from 'nanostores';
|
|
5
|
-
import { DropdownProfileBtnComponent } from './dropdown-profile-btn.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
|
-
// Port de packages/react/src/components/dds/DropdownProfileBtn.test.tsx (mapa:
|
|
18
|
-
// packages/vue/.../DropdownProfileBtn.test.ts).
|
|
19
|
-
describe('DropdownProfileBtn', () => {
|
|
20
|
-
function makeClient(ws: Record<string, any> = {}) {
|
|
21
|
-
return { state: { $ui: map({}), $ws: map({ ...ws }) } } as any;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
it('renderiza el data-service del serviceName y emite clicked al pulsar', async () => {
|
|
25
|
-
const onClick = vi.fn();
|
|
26
|
-
@Component({
|
|
27
|
-
standalone: true,
|
|
28
|
-
imports: [DropdownProfileBtnComponent],
|
|
29
|
-
template: `<ba-dropdown-profile-btn serviceName="blockauth" (clicked)="f()" />`,
|
|
30
|
-
})
|
|
31
|
-
class Host {
|
|
32
|
-
f = onClick;
|
|
33
|
-
}
|
|
34
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(makeClient())] });
|
|
35
|
-
|
|
36
|
-
const btn = screen.getByTestId('dropdown-profile-btn');
|
|
37
|
-
expect(btn.getAttribute('data-service')).toBe('blockauth');
|
|
38
|
-
await fireEvent.click(btn);
|
|
39
|
-
expect(onClick).toHaveBeenCalled();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('copia el DID al clicar la fila del DID sin propagar el click al boton', async () => {
|
|
43
|
-
const writeText = vi.fn();
|
|
44
|
-
Object.assign(navigator, { clipboard: { writeText } });
|
|
45
|
-
const onClick = vi.fn();
|
|
46
|
-
@Component({
|
|
47
|
-
standalone: true,
|
|
48
|
-
imports: [DropdownProfileBtnComponent],
|
|
49
|
-
template: `<ba-dropdown-profile-btn serviceName="blockauth" (clicked)="f()" />`,
|
|
50
|
-
})
|
|
51
|
-
class Host {
|
|
52
|
-
f = onClick;
|
|
53
|
-
}
|
|
54
|
-
// Forzar un DID legible desde $ws (fallback cuando storage está vacío).
|
|
55
|
-
await render(Host, {
|
|
56
|
-
providers: [provideBlockAuthClientForTest(makeClient({ did: '0xabcdef1234567890' }))],
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const didRow = screen.getByText(/^did:/);
|
|
60
|
-
await fireEvent.click(didRow);
|
|
61
|
-
// Copia el DID completo, no la etiqueta acortada.
|
|
62
|
-
expect(writeText).toHaveBeenCalledWith('0xabcdef1234567890');
|
|
63
|
-
// stopPropagation: el click de copiar no debe emitir el click del botón.
|
|
64
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, input, output, signal } from '@angular/core';
|
|
2
|
-
import { utils } from '@block-auth.io/core';
|
|
3
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
4
|
-
import { injectStore } from '../../inject-store';
|
|
5
|
-
import { providersStyles } from '../../primitives/providersStyles';
|
|
6
|
-
import { DropdownArrowComponent } from '../../primitives/dropdown-arrow.component';
|
|
7
|
-
import { TbCopyComponent, TbCopyCheckFilledComponent } from '../../icons';
|
|
8
|
-
|
|
9
|
-
// El click-outside lo maneja el PADRE, que envuelve este componente en su
|
|
10
|
-
// propio `<div>` con una template ref; por eso aquí no hay prop de contenedor.
|
|
11
|
-
// Los `classNames` por tamaño salen de mapas indexados por `dropdownBtnSize`.
|
|
12
|
-
//
|
|
13
|
-
// `rawDid`/`rawAccount` se leen dentro de `computed()`s que dependen de `ui`/`ws`
|
|
14
|
-
// (relee storage vía `utils.browserBase` en cada recompute).
|
|
15
|
-
@Component({
|
|
16
|
-
selector: 'ba-dropdown-profile-btn',
|
|
17
|
-
standalone: true,
|
|
18
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
19
|
-
imports: [DropdownArrowComponent, TbCopyComponent, TbCopyCheckFilledComponent],
|
|
20
|
-
template: `
|
|
21
|
-
<div
|
|
22
|
-
data-testid="dropdown-profile-btn"
|
|
23
|
-
[attr.data-service]="serviceNameResolved()"
|
|
24
|
-
[class]="
|
|
25
|
-
'bal-ba-glass-profile bal-ba-transition-2 bas-group bas-relative bas-box-border bas-grid bas-h-full bas-w-full bas-cursor-pointer bas-flex-row bas-items-center bas-justify-between bas-gap-1 bas-overflow-hidden bas-rounded-lg bas-mx-auto ' +
|
|
26
|
-
dropdownBtnBgClassNames() + ' bas-border-2 bas-border-solid ' +
|
|
27
|
-
gridClassNames() + ' ' +
|
|
28
|
-
(dropdownBtnBorderClassNames() || 'bal-ba-glass-profile-rim')
|
|
29
|
-
"
|
|
30
|
-
[style.--bal-ba-provider]="style().colorBase"
|
|
31
|
-
[style.minHeight]="height() != null ? height() + 'px' : null"
|
|
32
|
-
[style.width]="widthStyle()"
|
|
33
|
-
(click)="clicked.emit()"
|
|
34
|
-
>
|
|
35
|
-
<span
|
|
36
|
-
[attr.data-status]="!isSignedFirstCheck() ? 'pending' : !isSigned() ? 'unsigned' : 'signed'"
|
|
37
|
-
[class]="
|
|
38
|
-
'bal-ba-glass-status-dot bas-absolute bas-right-2.5 bas-top-1.5 bas-h-2 bas-w-2 bas-rounded-full ' +
|
|
39
|
-
(!isSignedFirstCheck() ? 'bas-bg-gray-400' : !isSigned() ? 'bas-bg-red-400' : 'bas-bg-green-400')
|
|
40
|
-
"
|
|
41
|
-
></span>
|
|
42
|
-
<div class="bas-z-10 bas-flex bas-h-full bas-w-full bas-items-center bas-justify-center bas-rounded-md">
|
|
43
|
-
<img
|
|
44
|
-
[src]="style().imgSrc"
|
|
45
|
-
[alt]="serviceNameResolved() + ' icon'"
|
|
46
|
-
[class]="'bal-ba-transition-2 bal-ba-transform-base bal-ba-hover-scale-110 bas-rounded-md ' + imgSizesClassNames()"
|
|
47
|
-
[style.backgroundColor]="style().imgBgColor"
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
<div
|
|
51
|
-
[class]="'bal-ba-transition-2 bas-flex bas-h-full bas-w-full bas-flex-col bas-items-center bas-justify-center bas-font-semibold bas-min-w-0 ' + dropdownBtnTextColorClassNames()"
|
|
52
|
-
>
|
|
53
|
-
<div
|
|
54
|
-
[class]="
|
|
55
|
-
'bal-ba-transition-2 bas-flex bas-max-w-full bas-flex-row bas-items-center bas-justify-center bas-gap-1 bas-cursor-pointer ' +
|
|
56
|
-
(isDidCopied() ? 'bas-text-[#4d849b]' : 'hover:bas-opacity-50')
|
|
57
|
-
"
|
|
58
|
-
(click)="onCopyDid($event)"
|
|
59
|
-
>
|
|
60
|
-
<p class="bas-m-0 bas-truncate bas-text-sm">{{ did() }}</p>
|
|
61
|
-
@if (isDidCopied()) {
|
|
62
|
-
<ba-tb-copy-check-filled class="bal-ba-transition-2 bas-h-[18px] bas-w-[18px] bas-shrink-0" />
|
|
63
|
-
} @else {
|
|
64
|
-
<ba-tb-copy class="bal-ba-transition-2 bas-h-[18px] bas-w-[18px] bas-shrink-0" />
|
|
65
|
-
}
|
|
66
|
-
</div>
|
|
67
|
-
<!-- Solo texto, no copiable (la fila DID de arriba es la única acción de copiar) -->
|
|
68
|
-
@if (showAccountRow()) {
|
|
69
|
-
<div class="bal-ba-transition-2 bas-flex bas-max-w-full bas-flex-row bas-items-center bas-justify-center bas-gap-1">
|
|
70
|
-
<p class="bas-m-0 bas-truncate bas-text-xs">{{ accountSubtitle() }}</p>
|
|
71
|
-
</div>
|
|
72
|
-
}
|
|
73
|
-
</div>
|
|
74
|
-
<div [class]="arrowContainerClassNames()">
|
|
75
|
-
@if (isSigned()) {
|
|
76
|
-
<ba-dropdown-arrow
|
|
77
|
-
id="ba-ddp-btn-arrow"
|
|
78
|
-
[isOpen]="isProfileOpen()"
|
|
79
|
-
[color]="style().colorBase"
|
|
80
|
-
[sizeClassNames]="arrowSizesClassNames()"
|
|
81
|
-
/>
|
|
82
|
-
}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
`,
|
|
86
|
-
})
|
|
87
|
-
export class DropdownProfileBtnComponent {
|
|
88
|
-
serviceName = input<string | null>(null);
|
|
89
|
-
dropdownBtnBgClassNames = input('bas-bg-transparent');
|
|
90
|
-
dropdownBtnSize = input<'xs' | 'small' | 'base' | 'large'>('xs');
|
|
91
|
-
dropdownBtnBorderClassNames = input<string | undefined>(undefined);
|
|
92
|
-
dropdownBtnTextColorClassNames = input(
|
|
93
|
-
'bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]',
|
|
94
|
-
);
|
|
95
|
-
height = input<number | null>(null);
|
|
96
|
-
isProfileOpen = input(false);
|
|
97
|
-
|
|
98
|
-
clicked = output<void>();
|
|
99
|
-
|
|
100
|
-
private readonly client = injectBlockAuthClient();
|
|
101
|
-
private readonly ui = injectStore(this.client.state.$ui);
|
|
102
|
-
private readonly ws = injectStore(this.client.state.$ws);
|
|
103
|
-
|
|
104
|
-
private readonly gridClassNamesBySize: Record<string, string> = {
|
|
105
|
-
xs: 'bas-grid-cols-[46px_1fr_28px]',
|
|
106
|
-
small: 'bas-grid-cols-[46px_1fr_28px]',
|
|
107
|
-
base: 'bas-grid-cols-[56px_1fr_28px]',
|
|
108
|
-
large: 'bas-grid-cols-[56px_1fr_28px]',
|
|
109
|
-
};
|
|
110
|
-
private readonly widthBySize: Record<string, number> = { xs: 224, small: 224, base: 244, large: 244 };
|
|
111
|
-
private readonly imgSizesClassNamesBySize: Record<string, string> = {
|
|
112
|
-
xs: 'bas-h-9 bas-w-9',
|
|
113
|
-
small: 'bas-h-10 bas-w-10',
|
|
114
|
-
base: 'bas-h-12 bas-w-12',
|
|
115
|
-
large: 'bas-h-12 bas-w-12',
|
|
116
|
-
};
|
|
117
|
-
private readonly arrowSizesClassNamesBySize: Record<string, string> = {
|
|
118
|
-
xs: 'bas-h-3.5 bas-w-3.5',
|
|
119
|
-
small: 'bas-h-3.5 bas-w-3.5',
|
|
120
|
-
base: 'bas-h-4 bas-w-4',
|
|
121
|
-
large: 'bas-h-4 bas-w-4',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
protected readonly serviceNameResolved = computed(
|
|
125
|
-
() => this.serviceName() ?? this.ui().serviceName ?? 'blockauth',
|
|
126
|
-
);
|
|
127
|
-
protected readonly style = computed(
|
|
128
|
-
() => providersStyles[this.serviceNameResolved()] ?? providersStyles['blockauth'],
|
|
129
|
-
);
|
|
130
|
-
protected readonly isSignedFirstCheck = computed(() => this.ui().isSignedFirstCheck);
|
|
131
|
-
protected readonly isSigned = computed(() => this.ui().isSigned);
|
|
132
|
-
|
|
133
|
-
private short = (value: string, start: number, end: number): string =>
|
|
134
|
-
value.length > start + end ? `${value.slice(0, start)}…${value.slice(-end)}` : value;
|
|
135
|
-
|
|
136
|
-
private readonly rawDid = computed(() => {
|
|
137
|
-
const session = utils.browserBase.getSession();
|
|
138
|
-
const external = utils.browserBase.getExternalService();
|
|
139
|
-
return (this.serviceNameResolved() === 'blockauth' ? session.did : external.did) || this.ws().did || '';
|
|
140
|
-
});
|
|
141
|
-
protected readonly did = computed(() => this.short(this.rawDid(), 6, 4).replace('0x', 'did:'));
|
|
142
|
-
private readonly rawAccount = computed(() => utils.browserBase.getExternalService().account || '');
|
|
143
|
-
protected readonly accountSubtitle = computed(() =>
|
|
144
|
-
this.serviceNameResolved() === 'blockauth' ? '' : this.short(this.rawAccount(), 5, 8),
|
|
145
|
-
);
|
|
146
|
-
protected readonly showAccountRow = computed(
|
|
147
|
-
() => this.serviceNameResolved() !== 'blockauth' && !!this.rawAccount(),
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
protected readonly isDidCopied = signal(false);
|
|
151
|
-
|
|
152
|
-
protected readonly gridClassNames = computed(() => this.gridClassNamesBySize[this.dropdownBtnSize()]);
|
|
153
|
-
protected readonly imgSizesClassNames = computed(() => this.imgSizesClassNamesBySize[this.dropdownBtnSize()]);
|
|
154
|
-
protected readonly arrowSizesClassNames = computed(() => this.arrowSizesClassNamesBySize[this.dropdownBtnSize()]);
|
|
155
|
-
protected readonly widthStyle = computed(() => `min(100%, ${this.widthBySize[this.dropdownBtnSize()]}px)`);
|
|
156
|
-
protected readonly arrowContainerClassNames = computed(() => {
|
|
157
|
-
let classNames = 'bas-h-full bas-w-full bas-justify-center';
|
|
158
|
-
const size = this.dropdownBtnSize();
|
|
159
|
-
if (size === 'xs' || size === 'small') classNames += ' bas-pt-1.5';
|
|
160
|
-
return classNames;
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
onCopyDid(e: MouseEvent): void {
|
|
164
|
-
// Don't toggle the dropdown open/closed when the user only wants to copy.
|
|
165
|
-
e.stopPropagation();
|
|
166
|
-
const value = this.rawDid();
|
|
167
|
-
if (!value) return;
|
|
168
|
-
void navigator.clipboard?.writeText(value);
|
|
169
|
-
this.isDidCopied.set(true);
|
|
170
|
-
setTimeout(() => this.isDidCopied.set(false), 3000);
|
|
171
|
-
}
|
|
172
|
-
}
|