@block-auth.io/angular 0.1.2 → 0.2.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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +836 -389
- package/.turbo/turbo-typecheck.log +4 -4
- package/CHANGELOG.md +13 -0
- package/package.json +2 -2
- package/src/lib/components/dds/dropdown-profile-btn.component.ts +13 -28
- package/src/lib/components/dds/dropdown-profile.component.test.ts +14 -2
- package/src/lib/components/dds/dropdown-profile.component.ts +25 -19
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @block-auth.io/angular@0.
|
|
2
|
+
> @block-auth.io/angular@0.2.0 pretypecheck /home/vlad/Escritorio/blockauth-code/blockauth-sdk/packages/angular
|
|
3
3
|
> pnpm build:css
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @block-auth.io/angular@0.
|
|
6
|
+
> @block-auth.io/angular@0.2.0 build:css /home/vlad/Escritorio/blockauth-code/blockauth-sdk/packages/angular
|
|
7
7
|
> tailwindcss -i ../ui-styles/src/input.css -c ./tailwind.config.cjs -o ./src/styles.generated.css --minify && node scripts/css-to-ts.mjs
|
|
8
8
|
|
|
9
9
|
Browserslist: caniuse-lite is outdated. Please run:
|
|
@@ -12,8 +12,8 @@ Browserslist: caniuse-lite is outdated. Please run:
|
|
|
12
12
|
|
|
13
13
|
Rebuilding...
|
|
14
14
|
|
|
15
|
-
Done in
|
|
15
|
+
Done in 1016ms.
|
|
16
16
|
|
|
17
|
-
> @block-auth.io/angular@0.
|
|
17
|
+
> @block-auth.io/angular@0.2.0 typecheck /home/vlad/Escritorio/blockauth-code/blockauth-sdk/packages/angular
|
|
18
18
|
> tsc -p tsconfig.lib.json --noEmit
|
|
19
19
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @block-auth.io/angular
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @block-auth.io/core@0.4.2
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Conditionally render DropdownProfile actions based on authentication state
|
|
15
|
+
|
|
3
16
|
## 0.1.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@block-auth.io/angular",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"nanostores": "^0.10.0",
|
|
6
6
|
"tslib": "^2.6.0",
|
|
7
|
-
"@block-auth.io/core": "0.4.
|
|
7
|
+
"@block-auth.io/core": "0.4.2",
|
|
8
8
|
"@block-auth.io/ui-styles": "0.4.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
@@ -62,30 +62,22 @@ import { TbCopyComponent, TbCopyCheckFilledComponent } from '../../icons';
|
|
|
62
62
|
<ba-tb-copy class="bal-ba-transition-2 bas-h-[18px] bas-w-[18px] bas-shrink-0" />
|
|
63
63
|
}
|
|
64
64
|
</div>
|
|
65
|
+
<!-- Solo texto, no copiable (la fila DID de arriba es la única acción de copiar) -->
|
|
65
66
|
@if (showAccountRow()) {
|
|
66
|
-
<div
|
|
67
|
-
[class]="
|
|
68
|
-
'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 ' +
|
|
69
|
-
(isAccountCopied() ? 'bas-text-[#4d849b]' : 'hover:bas-opacity-50')
|
|
70
|
-
"
|
|
71
|
-
(click)="onCopyAccount($event)"
|
|
72
|
-
>
|
|
67
|
+
<div class="bal-ba-transition-2 bas-flex bas-max-w-full bas-flex-row bas-items-center bas-justify-center bas-gap-1">
|
|
73
68
|
<p class="bas-m-0 bas-truncate bas-text-xs">{{ accountSubtitle() }}</p>
|
|
74
|
-
@if (isAccountCopied()) {
|
|
75
|
-
<ba-tb-copy-check-filled class="bal-ba-transition-2 bas-h-4 bas-w-4 bas-shrink-0" />
|
|
76
|
-
} @else {
|
|
77
|
-
<ba-tb-copy class="bal-ba-transition-2 bas-h-4 bas-w-4 bas-shrink-0" />
|
|
78
|
-
}
|
|
79
69
|
</div>
|
|
80
70
|
}
|
|
81
71
|
</div>
|
|
82
72
|
<div [class]="arrowContainerClassNames()">
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
@if (isSigned()) {
|
|
74
|
+
<ba-dropdown-arrow
|
|
75
|
+
id="ba-ddp-btn-arrow"
|
|
76
|
+
[isOpen]="isProfileOpen()"
|
|
77
|
+
[color]="style().colorBase"
|
|
78
|
+
[sizeClassNames]="arrowSizesClassNames()"
|
|
79
|
+
/>
|
|
80
|
+
}
|
|
89
81
|
</div>
|
|
90
82
|
</div>
|
|
91
83
|
`,
|
|
@@ -154,7 +146,6 @@ export class DropdownProfileBtnComponent {
|
|
|
154
146
|
);
|
|
155
147
|
|
|
156
148
|
protected readonly isDidCopied = signal(false);
|
|
157
|
-
protected readonly isAccountCopied = signal(false);
|
|
158
149
|
|
|
159
150
|
protected readonly gridClassNames = computed(() => this.gridClassNamesBySize[this.dropdownBtnSize()]);
|
|
160
151
|
protected readonly imgSizesClassNames = computed(() => this.imgSizesClassNamesBySize[this.dropdownBtnSize()]);
|
|
@@ -168,18 +159,12 @@ export class DropdownProfileBtnComponent {
|
|
|
168
159
|
});
|
|
169
160
|
|
|
170
161
|
onCopyDid(e: MouseEvent): void {
|
|
171
|
-
this.copy(this.rawDid(), this.isDidCopied, e);
|
|
172
|
-
}
|
|
173
|
-
onCopyAccount(e: MouseEvent): void {
|
|
174
|
-
this.copy(this.rawAccount(), this.isAccountCopied, e);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private copy(value: string, copiedSignal: { set: (v: boolean) => void }, e: MouseEvent): void {
|
|
178
162
|
// Don't toggle the dropdown open/closed when the user only wants to copy.
|
|
179
163
|
e.stopPropagation();
|
|
164
|
+
const value = this.rawDid();
|
|
180
165
|
if (!value) return;
|
|
181
166
|
void navigator.clipboard?.writeText(value);
|
|
182
|
-
|
|
183
|
-
setTimeout(() =>
|
|
167
|
+
this.isDidCopied.set(true);
|
|
168
|
+
setTimeout(() => this.isDidCopied.set(false), 3000);
|
|
184
169
|
}
|
|
185
170
|
}
|
|
@@ -18,13 +18,15 @@ vi.mock('@wagmi/connectors', () => ({
|
|
|
18
18
|
// packages/vue/.../DropdownProfile.test.ts). Client falso con `logout` spy y
|
|
19
19
|
// stores nanostores; serviceName 'blockauth' para textos en inglés.
|
|
20
20
|
describe('DropdownProfile', () => {
|
|
21
|
-
|
|
21
|
+
// isSigned: true — el item list (My profile/Change account/Disconnect)
|
|
22
|
+
// solo se muestra autenticado (ver dropdown-profile.component.ts).
|
|
23
|
+
function makeClient(logout = vi.fn(async () => {}), uiOverrides: Record<string, unknown> = {}) {
|
|
22
24
|
return {
|
|
23
25
|
logout,
|
|
24
26
|
web3: { signup: vi.fn() },
|
|
25
27
|
oauth: { signupGoogle: vi.fn(), signupMicrosoft: vi.fn() },
|
|
26
28
|
connectBlockAuth: vi.fn(),
|
|
27
|
-
state: { $ui: map({ serviceName: 'blockauth' }), $ws: map({}) },
|
|
29
|
+
state: { $ui: map({ serviceName: 'blockauth', isSigned: true, ...uiOverrides }), $ws: map({}) },
|
|
28
30
|
} as any;
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -95,4 +97,14 @@ describe('DropdownProfile', () => {
|
|
|
95
97
|
});
|
|
96
98
|
expect(screen.getByTestId('dropdown-profile').className).toContain('bas-w-fit');
|
|
97
99
|
});
|
|
100
|
+
|
|
101
|
+
it('sin firmar (conectado pero no autenticado) solo permite copiar el DID', async () => {
|
|
102
|
+
await render(DropdownProfileComponent, {
|
|
103
|
+
providers: [provideBlockAuthClientForTest(makeClient(vi.fn(), { isSigned: false }))],
|
|
104
|
+
});
|
|
105
|
+
await fireEvent.click(screen.getByTestId('dropdown-profile-btn'));
|
|
106
|
+
expect(screen.queryByText('My profile')).toBeNull();
|
|
107
|
+
expect(screen.queryByText('Change account')).toBeNull();
|
|
108
|
+
expect(screen.queryByText('Disconnect')).toBeNull();
|
|
109
|
+
});
|
|
98
110
|
});
|
|
@@ -88,22 +88,23 @@ export interface DropdownProfileAdditionalItem {
|
|
|
88
88
|
(clicked)="item.onClick()"
|
|
89
89
|
/>
|
|
90
90
|
}
|
|
91
|
-
<!-- CHANGE ACCOUNT -->
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
<!-- CHANGE ACCOUNT + DISCONNECT — hidden until the login transaction is signed -->
|
|
92
|
+
@if (isSigned()) {
|
|
93
|
+
<ba-change-account
|
|
94
|
+
[serviceName]="serviceName()"
|
|
95
|
+
[text]="localized(btnsTexts().changeAccount, 'Change account')"
|
|
96
|
+
[disabled]="disabled()"
|
|
97
|
+
[isTopBorder]="isWeb3Service() || itemsToShow().length > 0"
|
|
98
|
+
(changeAccountClicked)="onChangeAccountClicked()"
|
|
99
|
+
/>
|
|
100
|
+
<ba-dropdown-profile-item
|
|
101
|
+
id="ba-dd8-disconnect-0"
|
|
102
|
+
[text]="localized(btnsTexts().disconnect, 'Disconnect')"
|
|
103
|
+
[firstIcon]="disconnectIcon"
|
|
104
|
+
[isTopBorder]="true"
|
|
105
|
+
(clicked)="onDisconnectClicked()"
|
|
106
|
+
/>
|
|
107
|
+
}
|
|
107
108
|
</ul>
|
|
108
109
|
</div>
|
|
109
110
|
}
|
|
@@ -153,6 +154,7 @@ export class DropdownProfileComponent {
|
|
|
153
154
|
private animTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
154
155
|
|
|
155
156
|
protected readonly serviceName = computed(() => this.ui().serviceName ?? 'blockauth');
|
|
157
|
+
protected readonly isSigned = computed(() => this.ui().isSigned);
|
|
156
158
|
|
|
157
159
|
private readonly uiConfigContent = computed(
|
|
158
160
|
() =>
|
|
@@ -191,12 +193,15 @@ export class DropdownProfileComponent {
|
|
|
191
193
|
},
|
|
192
194
|
]);
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
// Not fully authenticated yet (connected but transaction unsigned): only the
|
|
197
|
+
// "Copy DID" row in `DropdownProfileBtnComponent` is a valid action, so the
|
|
198
|
+
// item list (My profile / Change account / Disconnect) stays empty.
|
|
199
|
+
protected readonly itemsToShow = computed(() =>
|
|
200
|
+
this.isSigned() ? this.additionalDropdownItems() ?? this.defaultAdditionalDropdownItems() : [],
|
|
196
201
|
);
|
|
197
202
|
private readonly web2Services = ['google', 'microsoft'];
|
|
198
203
|
protected readonly isWeb3Service = computed(() => !this.web2Services.includes(this.serviceName()));
|
|
199
|
-
protected readonly totalDropdownItems = computed(() => 2 + this.itemsToShow().length);
|
|
204
|
+
protected readonly totalDropdownItems = computed(() => (this.isSigned() ? 2 + this.itemsToShow().length : 0));
|
|
200
205
|
|
|
201
206
|
private readonly heightBySize: Record<string, number> = { xs: 46, small: 52, base: 58, large: 64 };
|
|
202
207
|
|
|
@@ -217,6 +222,7 @@ export class DropdownProfileComponent {
|
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
onProfileClicked(): void {
|
|
225
|
+
if (!this.isSigned()) return;
|
|
220
226
|
this.isAnimationCompleted.set(false);
|
|
221
227
|
const next = !this.isProfileOpen();
|
|
222
228
|
this.isProfileOpen.set(next);
|