@block-auth.io/angular 0.3.2 → 0.4.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.
Files changed (32) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +701 -1302
  4. package/.turbo/turbo-typecheck.log +4 -4
  5. package/CHANGELOG.md +28 -0
  6. package/package.json +3 -3
  7. package/src/lib/components/btns/btn-base-provider.component.test.ts +14 -0
  8. package/src/lib/components/btns/btn-base-provider.component.ts +7 -1
  9. package/src/lib/components/contents/content-signup.component.ts +5 -17
  10. package/src/lib/components/dds/dropdown-profile-btn.component.ts +5 -3
  11. package/src/lib/components/flow-block-auth.component.test.ts +2 -0
  12. package/src/lib/components/flow-block-auth.component.ts +10 -8
  13. package/src/lib/components/modals/modal-signin.component.ts +2 -2
  14. package/src/lib/components/modals/modal-signup.component.ts +1 -1
  15. package/src/lib/components/sections/internals/providers-buttons.component.ts +1 -11
  16. package/src/lib/components/sections/login-section.component.ts +4 -5
  17. package/src/lib/components/txns/internals/permissions-required-modal.component.ts +1 -1
  18. package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +39 -0
  19. package/src/lib/components/txns/internals/solicited-data-modal.component.ts +25 -10
  20. package/src/lib/components/txns/internals/txn.component.test.ts +13 -0
  21. package/src/lib/components/txns/internals/txn.component.ts +15 -23
  22. package/src/lib/components/txns/txns-overview.component.ts +49 -12
  23. package/src/lib/primitives/horizontal-loader.component.test.ts +3 -2
  24. package/src/lib/primitives/horizontal-loader.component.ts +15 -39
  25. package/src/lib/primitives/img-loader.component.test.ts +10 -0
  26. package/src/lib/primitives/img-loader.component.ts +5 -2
  27. package/src/lib/primitives/oval-spinner.component.test.ts +10 -2
  28. package/src/lib/primitives/oval-spinner.component.ts +35 -57
  29. package/src/lib/primitives/progressbar.component.test.ts +27 -11
  30. package/src/lib/primitives/progressbar.component.ts +24 -81
  31. package/src/lib/primitives/providersStyles.ts +0 -50
  32. package/src/lib/transitions.css +0 -4
@@ -86,7 +86,10 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
86
86
  template: `
87
87
  <div
88
88
  data-testid="txns-overview"
89
- class="bas-flex bas-box-border bas-relative bas-h-full bas-w-full bas-gap-6 bas-flex-col bas-items-center bas-p-6 bas-font-medium bas-justify-center"
89
+ [class]="
90
+ 'bas-relative bas-box-border bas-flex bas-h-full bas-w-full bas-flex-col bas-font-medium ' +
91
+ (hasHeader() ? '' : 'bas-items-center bas-justify-center bas-gap-6 bas-p-6')
92
+ "
90
93
  >
91
94
  @if (isEmpty() && isSigning() && !isOtpRequired()) {
92
95
  <ba-txn-error
@@ -104,9 +107,12 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
104
107
  />
105
108
  } @else if (!isEmpty() || isOtpRequired()) {
106
109
  <!-- No txn yet when the session expired before it was created. -->
107
- @if (!isEmpty()) {
110
+ @if (hasHeader()) {
111
+ <header
112
+ class="bal-ba-glass-card-header bas-box-border bas-flex bas-w-full bas-shrink-0 bas-justify-center bas-px-6 bas-pb-9 bas-pt-5"
113
+ >
108
114
  <div
109
- class="bal-ba-glass-rise bas-flex bas-flex-col bas-items-center bas-gap-3"
115
+ class="bal-ba-glass-rise bas-flex bas-flex-col bas-items-center bas-gap-2"
110
116
  >
111
117
  <img
112
118
  [src]="
@@ -127,6 +133,16 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
127
133
  {{ accountShort(did()) }}
128
134
  </p>
129
135
  </div>
136
+ </header>
137
+ }
138
+ <div
139
+ [class]="
140
+ hasHeader()
141
+ ? 'bal-ba-glass-card-body -bas-mt-4 bas-box-border bas-flex bas-min-h-0 bas-w-full bas-flex-1 bas-flex-col bas-items-center bas-gap-5 bas-overflow-y-auto bal-ba-scroll-base bas-px-6 bas-pb-6 bas-pt-5'
142
+ : 'bas-contents'
143
+ "
144
+ >
145
+ @if (hasHeader()) {
130
146
  <ba-txn-type
131
147
  [txnType]="preParams().txnType || t('login')"
132
148
  [txnsLength]="txns().length"
@@ -166,8 +182,9 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
166
182
  }
167
183
  </div>
168
184
  } @else {
169
- <div class="bas-h-[334px] bas-w-full bas-max-w-[330px]">
185
+ <div class="bas-flex bas-w-full bas-max-w-[330px] bas-flex-1">
170
186
  <ba-txn
187
+ class="bas-w-full"
171
188
  [hasSolicitedData]="hasSolicitedData()"
172
189
  [allRequiredFilled]="allRequiredFilled()"
173
190
  [solicitedDataPending]="solicitedDataPending()"
@@ -178,24 +195,30 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
178
195
  [revokedParams]="acceptParams().revokedParams"
179
196
  [addError]="addError"
180
197
  (permissionsRequiredClicked)="showPermissions.set(true)"
181
- (solicitedDataClicked)="showSolicitedData.set(true)"
198
+ (solicitedDataClicked)="openSolicitedData()"
182
199
  />
183
200
  </div>
184
- } } @if (showPermissions()) {
201
+ }
202
+ </div>
203
+ } @if (showPermissions()) {
185
204
  <div
186
205
  class="bal-ba-glass-backdrop bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
187
206
  (click)="showPermissions.set(false)"
188
207
  ></div>
189
- <div class="bas-absolute bas-top-44 bas-z-40">
190
- <ba-permissions-required-modal />
208
+ <div
209
+ class="bas-pointer-events-none bas-absolute bas-inset-x-0 bas-top-44 bas-z-40 bas-box-border bas-flex bas-justify-center bas-px-4"
210
+ >
211
+ <div class="bas-pointer-events-auto bas-w-full bas-max-w-[334px]">
212
+ <ba-permissions-required-modal />
213
+ </div>
191
214
  </div>
192
215
  } @if (showSolicitedData()) {
193
216
  <div
194
217
  class="bal-ba-glass-backdrop bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
195
- (click)="showSolicitedData.set(false)"
218
+ (click)="cancelSolicitedData()"
196
219
  ></div>
197
220
  <ba-solicited-data-modal
198
- class="bal-ba-glass-modal-slot bas-absolute bas-inset-y-6 bas-z-40"
221
+ class="bal-ba-glass-modal-slot bas-absolute bas-inset-x-0 bas-inset-y-6 bas-z-40 bas-box-border bas-flex bas-justify-center bas-px-4"
199
222
  [requiredParams]="requiredParams()"
200
223
  [optionalParams]="optionalParams()"
201
224
  [params]="txnData()?.params"
@@ -209,7 +232,7 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
209
232
  (shareChange)="handleShareChange($event)"
210
233
  (saveParam)="handleSaveParam($event)"
211
234
  (undoParam)="handleUndoParam($event)"
212
- (closed)="showSolicitedData.set(false)"
235
+ (closed)="cancelSolicitedData()"
213
236
  (accepted)="showSolicitedData.set(false)"
214
237
  />
215
238
  }
@@ -234,6 +257,7 @@ export class TxnsOverviewComponent {
234
257
  protected readonly solicitedForm = signal<SolicitedDataForm>(
235
258
  EMPTY_SOLICITED_DATA_FORM,
236
259
  );
260
+ private solicitedSnapshot: SolicitedDataForm = EMPTY_SOLICITED_DATA_FORM;
237
261
  protected readonly txnData = signal<TxnDataRequest | null>(null);
238
262
  private readonly isLoadingTxnData = signal(false);
239
263
  private readonly txnDataReload = signal(0);
@@ -249,6 +273,9 @@ export class TxnsOverviewComponent {
249
273
  protected readonly acceptTxnError = computed(() => this.ui().acceptTxnError);
250
274
  protected readonly openExtensionOnTxn = openExtensionOnTxn;
251
275
  protected readonly isEmpty = computed(() => this.txns().length === 0);
276
+ protected readonly hasHeader = computed(
277
+ () => !this.isEmpty() && !this.error().value,
278
+ );
252
279
  protected readonly errorText = computed(() =>
253
280
  this.t(
254
281
  TXN_ERROR_TEXT_KEYS[this.error().messageSlug] ??
@@ -362,7 +389,7 @@ export class TxnsOverviewComponent {
362
389
  effect(() => {
363
390
  if (!this.acceptTxnError()) return;
364
391
  untracked(() => {
365
- this.showSolicitedData.set(true);
392
+ this.openSolicitedData();
366
393
  this.txnDataReload.update((n) => n + 1);
367
394
  });
368
395
  });
@@ -411,6 +438,16 @@ export class TxnsOverviewComponent {
411
438
  this.updateParam(slug, undoSolicitedValue);
412
439
  }
413
440
 
441
+ openSolicitedData(): void {
442
+ this.solicitedSnapshot = this.solicitedForm();
443
+ this.showSolicitedData.set(true);
444
+ }
445
+
446
+ cancelSolicitedData(): void {
447
+ this.solicitedForm.set(this.solicitedSnapshot);
448
+ this.showSolicitedData.set(false);
449
+ }
450
+
414
451
  onPrevTxnClicked(): void {
415
452
  const len = this.txns().length;
416
453
  if (len === 0) return;
@@ -2,9 +2,10 @@ import { describe, it, expect } from 'vitest';
2
2
  import { render } from '@testing-library/angular';
3
3
  import { HorizontalLoaderComponent } from './horizontal-loader.component';
4
4
  describe('HorizontalLoaderComponent', () => {
5
- it('renderiza un svg', async () => {
5
+ it('renderiza los 3 puntos glass', async () => {
6
6
  const { container } = await render(HorizontalLoaderComponent);
7
- expect(container.querySelector('svg')).toBeTruthy();
7
+ expect(container.querySelector('.bal-ba-glass-dots')).toBeTruthy();
8
+ expect(container.querySelectorAll('.bal-ba-glass-dot')).toHaveLength(3);
8
9
  });
9
10
 
10
11
  // Regresión: el host debe ser `display: contents` para que el <div> absoluto
@@ -1,8 +1,5 @@
1
- import { ChangeDetectionStrategy, Component, input } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
2
2
 
3
- // Sin react-loader-spinner:
4
- // se dibujan 3 puntos SVG con una animación de opacidad escalonada
5
- // (definida en `styles`), reproduciendo el look del `ThreeDots` original.
6
3
  @Component({
7
4
  selector: 'ba-horizontal-loader',
8
5
  standalone: true,
@@ -21,50 +18,29 @@ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
21
18
  classNames()
22
19
  "
23
20
  >
24
- <svg
25
- class="bas-three-dots"
26
- [attr.height]="loaderHeight()"
27
- [attr.width]="loaderWidth()"
28
- viewBox="0 0 80 40"
21
+ <div
22
+ class="bal-ba-glass-dots"
29
23
  role="img"
30
24
  aria-label="three-dots-loading"
25
+ [style.width.px]="loaderWidth()"
26
+ [style.height.px]="loaderHeight()"
27
+ [style.--bal-glass-dot-color]="loaderColor()"
28
+ [style.--bal-glass-dot-size]="dotSize() + 'px'"
31
29
  >
32
- <circle class="bas-dot bas-dot-1" cx="15" cy="20" r="9" [attr.fill]="loaderColor()" />
33
- <circle class="bas-dot bas-dot-2" cx="40" cy="20" r="9" [attr.fill]="loaderColor()" />
34
- <circle class="bas-dot bas-dot-3" cx="65" cy="20" r="9" [attr.fill]="loaderColor()" />
35
- </svg>
30
+ <span class="bal-ba-glass-dot"></span>
31
+ <span class="bal-ba-glass-dot"></span>
32
+ <span class="bal-ba-glass-dot"></span>
33
+ </div>
36
34
  </div>
37
35
  `,
38
- styles: [
39
- `
40
- @keyframes bas-three-dots-fade {
41
- 0%,
42
- 80%,
43
- 100% {
44
- opacity: 0.25;
45
- }
46
- 40% {
47
- opacity: 1;
48
- }
49
- }
50
- .bas-dot {
51
- animation: bas-three-dots-fade 1.2s ease-in-out infinite;
52
- }
53
- .bas-dot-1 {
54
- animation-delay: -0.32s;
55
- }
56
- .bas-dot-2 {
57
- animation-delay: -0.16s;
58
- }
59
- .bas-dot-3 {
60
- animation-delay: 0s;
61
- }
62
- `,
63
- ],
64
36
  })
65
37
  export class HorizontalLoaderComponent {
66
38
  loaderColor = input('#61a5c2');
67
39
  loaderHeight = input(40);
68
40
  loaderWidth = input(80);
69
41
  classNames = input('bas-rounded-md');
42
+
43
+ dotSize = computed(() =>
44
+ Math.round(Math.min(this.loaderHeight() * 0.4, this.loaderWidth() / 5)),
45
+ );
70
46
  }
@@ -10,3 +10,13 @@ describe('ImgLoaderComponent', () => {
10
10
  expect(container.querySelector('img')?.getAttribute('src')).toBe('https://x/y.png');
11
11
  });
12
12
  });
13
+
14
+ describe('ImgLoaderComponent sin anillo', () => {
15
+ it('no monta el anillo giratorio cuando showLoaderRing es false', async () => {
16
+ const { container } = await render(ImgLoaderComponent, {
17
+ componentInputs: { showLoaderRing: false },
18
+ });
19
+ expect(container.querySelector('.bas-img-loader-ring')).toBeNull();
20
+ expect(container.querySelector('.bal-ba-img-loader')).not.toBeNull();
21
+ });
22
+ });
@@ -47,14 +47,14 @@ const MOTION_SPAN_SIZES: Record<ImgLoaderSize, string> = {
47
47
  template: `
48
48
  <div
49
49
  [class]="
50
- 'bas-relative bas-flex ' +
50
+ 'bal-ba-img-loader bas-relative bas-flex ' +
51
51
  SIZES_CONTAINER[size()] +
52
52
  ' bas-items-center bas-justify-center bas-overflow-hidden bas-rounded-lg'
53
53
  "
54
54
  >
55
55
  <div
56
56
  [class]="
57
- 'bas-z-10 bas-flex ' +
57
+ 'bal-ba-img-loader-icon bas-z-10 bas-flex ' +
58
58
  SIZES_ICON_CONTAINER[size()] +
59
59
  ' bas-items-center bas-justify-center bas-rounded-md bas-bg-white'
60
60
  "
@@ -74,6 +74,7 @@ const MOTION_SPAN_SIZES: Record<ImgLoaderSize, string> = {
74
74
  (load)="loaded.set(true)"
75
75
  />
76
76
  </div>
77
+ @if (showLoaderRing()) {
77
78
  <div [class]="'bas-absolute ' + MOTION_SIZES[size()]">
78
79
  <span
79
80
  [id]="loaderId()"
@@ -84,6 +85,7 @@ const MOTION_SPAN_SIZES: Record<ImgLoaderSize, string> = {
84
85
  [style.border-top-color]="loaderColor()"
85
86
  ></span>
86
87
  </div>
88
+ }
87
89
  </div>
88
90
  `,
89
91
  styles: [
@@ -113,6 +115,7 @@ export class ImgLoaderComponent {
113
115
  loaderColor = input('');
114
116
  scaleImgWhenHovered = input(false);
115
117
  size = input<ImgLoaderSize>('small');
118
+ showLoaderRing = input(true);
116
119
 
117
120
  loaded = signal(false);
118
121
  }
@@ -2,8 +2,16 @@ import { describe, it, expect } from 'vitest';
2
2
  import { render } from '@testing-library/angular';
3
3
  import { OvalSpinnerComponent } from './oval-spinner.component';
4
4
  describe('OvalSpinnerComponent', () => {
5
- it('renderiza un svg con la clase de spin', async () => {
5
+ it('renderiza el glass loader', async () => {
6
6
  const { container } = await render(OvalSpinnerComponent);
7
- expect(container.querySelector('.bas-oval-spin')).toBeTruthy();
7
+ expect(container.querySelector('.bal-ba-glass-loader-panel')).toBeTruthy();
8
+ expect(container.querySelector('#loader-image')).toBeNull();
9
+ });
10
+
11
+ it('muestra el logo dentro del cristal cuando showLogo', async () => {
12
+ const { container } = await render(OvalSpinnerComponent, {
13
+ componentInputs: { showLogo: true },
14
+ });
15
+ expect(container.querySelector('.bal-ba-glass-loader-logo #loader-image')).toBeTruthy();
8
16
  });
9
17
  });
@@ -1,11 +1,5 @@
1
1
  import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
2
2
 
3
- // Sin react-loader-spinner (`<Oval>`)
4
- // ni `animate.css`: el anillo animado se dibuja con un <svg> propio (pista +
5
- // arco giratorio con la clase `bas-oval-spin` de transitions.css) y el
6
- // fade-in de entrada se resuelve con una animación CSS local equivalente a
7
- // `animate__fadeIn`. `icon` (ReactNode / slot `icon`) pasa a ser
8
- // `<ng-content select="[slot=icon]" />`.
9
3
  const BLOCKAUTH_LOGO = 'https://dashboard.block-auth.io/img/blockauth_logo.png';
10
4
 
11
5
  type OvalSize = 'xs' | 'small' | 'medium' | 'large';
@@ -40,46 +34,35 @@ type OvalPosition =
40
34
  <div
41
35
  [class]="'bas-relative bas-flex bas-items-center bas-justify-center ' + positionClassNames()"
42
36
  >
43
- <svg
44
- class="bas-oval-fadein"
45
- [attr.width]="ovalSize()"
46
- [attr.height]="ovalSize()"
37
+ <div
38
+ class="bal-ba-glass-loader"
47
39
  role="img"
48
40
  aria-label="oval-loading"
49
- [attr.viewBox]="'0 0 ' + ovalSize() + ' ' + ovalSize()"
41
+ [style.width.px]="ovalSize()"
42
+ [style.height.px]="ovalSize()"
43
+ [style.--bal-glass-loader-size]="ovalSize() + 'px'"
50
44
  >
51
- <circle
52
- [attr.cx]="ovalSize() / 2"
53
- [attr.cy]="ovalSize() / 2"
54
- [attr.r]="radius()"
55
- fill="none"
56
- stroke="#93C5FD"
57
- [attr.stroke-width]="strokeWidth"
58
- />
59
- <circle
60
- class="bas-oval-spin"
61
- [attr.cx]="ovalSize() / 2"
62
- [attr.cy]="ovalSize() / 2"
63
- [attr.r]="radius()"
64
- fill="none"
65
- stroke="#00509A"
66
- [attr.stroke-width]="strokeWidth"
67
- [attr.stroke-dasharray]="circumference() * 0.25 + ' ' + circumference()"
68
- stroke-linecap="round"
69
- style="transform-origin: 50% 50%"
70
- />
71
- </svg>
72
- <div [class]="showLogo() ? 'bas-absolute ' + (customLogoSize() || imageSize()) : 'bas-hidden'">
73
- @if (!isIcon()) {
74
- <img
75
- id="loader-image"
76
- [src]="imageLogoSrc()"
77
- class="bas-aspect-square bas-h-full bas-w-full bas-rounded-full"
78
- [alt]="imageAlt()"
79
- />
80
- } @else {
81
- <ng-content select="[slot=icon]" />
82
- }
45
+ <span class="bal-ba-glass-loader-ground" aria-hidden="true"></span>
46
+ <span class="bal-ba-glass-loader-halo" aria-hidden="true"></span>
47
+ <div class="bal-ba-glass-loader-body">
48
+ <span class="bal-ba-glass-loader-panel" aria-hidden="true"></span>
49
+ <span class="bal-ba-glass-loader-arc" aria-hidden="true"></span>
50
+ <span class="bal-ba-glass-loader-spec" aria-hidden="true"></span>
51
+ <span class="bal-ba-glass-loader-sheen" aria-hidden="true"></span>
52
+ @if (showLogo()) {
53
+ <div
54
+ [class]="'bal-ba-glass-loader-logo ' + (customLogoSize() ?? '')"
55
+ [style.width]="customLogoSize() ? null : logoScale()"
56
+ [style.height]="customLogoSize() ? null : logoScale()"
57
+ >
58
+ @if (!isIcon()) {
59
+ <img id="loader-image" [src]="imageLogoSrc()" [alt]="imageAlt()" />
60
+ } @else {
61
+ <ng-content select="[slot=icon]" />
62
+ }
63
+ </div>
64
+ }
65
+ </div>
83
66
  </div>
84
67
  </div>
85
68
  </div>
@@ -114,14 +97,12 @@ export class OvalSpinnerComponent {
114
97
  imageLogoSrc = input(BLOCKAUTH_LOGO);
115
98
  zIndex = input('bas-z-50');
116
99
 
117
- readonly strokeWidth = 2;
118
-
119
100
  ovalSize = computed(() => {
120
101
  if (this.customSize()) return this.customSize()!;
121
- if (this.size() === 'xs') return 48;
122
- if (this.size() === 'small') return 64;
123
- if (this.size() === 'medium') return 80;
124
- return 112; // large
102
+ if (this.size() === 'xs') return 56;
103
+ if (this.size() === 'small') return 76;
104
+ if (this.size() === 'medium') return 104;
105
+ return 132; // large
125
106
  });
126
107
 
127
108
  positionClasses = computed(
@@ -139,20 +120,17 @@ export class OvalSpinnerComponent {
139
120
  })[this.position()],
140
121
  );
141
122
 
142
- imageSize = computed(
123
+ logoScale = computed(
143
124
  () =>
144
125
  ({
145
- xs: 'bas-h-10 bas-w-10',
146
- small: 'bas-h-12 bas-w-12',
147
- medium: 'bas-h-16 bas-w-16',
148
- large: 'bas-h-20 bas-w-20',
126
+ xs: '57%',
127
+ small: '62%',
128
+ medium: '67%',
129
+ large: '72%',
149
130
  })[this.logoSize()],
150
131
  );
151
132
 
152
133
  imageAlt = computed(() =>
153
134
  this.imageLogoSrc() === BLOCKAUTH_LOGO ? 'Block-Auth Logo' : 'Image inside loader',
154
135
  );
155
-
156
- radius = computed(() => this.ovalSize() / 2 - this.strokeWidth);
157
- circumference = computed(() => 2 * Math.PI * this.radius());
158
136
  }
@@ -1,18 +1,34 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { Component } from '@angular/core';
3
2
  import { render, screen } from '@testing-library/angular';
4
3
  import { ProgressbarComponent } from './progressbar.component';
4
+
5
+ const nodeStates = () =>
6
+ Array.from(screen.getByTestId('progressbar').querySelectorAll('.bal-ba-stepper-node')).map((node) =>
7
+ node.getAttribute('data-state'),
8
+ );
9
+
5
10
  describe('ProgressbarComponent', () => {
6
- it('percent 100 cuando step3', async () => {
7
- @Component({ standalone: true, imports: [ProgressbarComponent], template: `<ba-progressbar [step3]="true" />` })
8
- class Host {}
9
- await render(Host);
10
- expect(screen.getByTestId('progressbar-fill').getAttribute('data-percent')).toBe('100');
11
+ it.each([
12
+ [1, ['active', 'pending', 'pending']],
13
+ [2, ['done', 'active', 'pending']],
14
+ [3, ['done', 'done', 'active']],
15
+ ] as const)('paso %i pinta cada nodo según el paso', async (step, states) => {
16
+ await render(ProgressbarComponent, { inputs: { step } });
17
+ const bar = screen.getByTestId('progressbar');
18
+ expect(bar.getAttribute('data-step')).toBe(String(step));
19
+ expect(bar.getAttribute('aria-valuenow')).toBe(String(step));
20
+ expect(nodeStates()).toEqual(states);
11
21
  });
12
- it('percent 15 cuando step1', async () => {
13
- @Component({ standalone: true, imports: [ProgressbarComponent], template: `<ba-progressbar [step1]="true" />` })
14
- class Host {}
15
- await render(Host);
16
- expect(screen.getByTestId('progressbar-fill').getAttribute('data-percent')).toBe('15');
22
+
23
+ it('al volver del paso 3 al 2 no deja restos del paso 3', async () => {
24
+ const { rerender } = await render(ProgressbarComponent, { inputs: { step: 3 } });
25
+ await rerender({ inputs: { step: 2 }, partialUpdate: true });
26
+ expect(screen.getByTestId('progressbar').getAttribute('data-step')).toBe('2');
27
+ expect(nodeStates()).toEqual(['done', 'active', 'pending']);
28
+ });
29
+
30
+ it('un solo indicador de paso activo', async () => {
31
+ await render(ProgressbarComponent, { inputs: { step: 2 } });
32
+ expect(screen.getByTestId('progressbar').querySelectorAll('.bal-ba-stepper-indicator')).toHaveLength(1);
17
33
  });
18
34
  });
@@ -1,93 +1,36 @@
1
- import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
2
+
3
+ export type ProgressbarStep = 1 | 2 | 3;
2
4
 
3
- // El original orquesta 12
4
- // AnimationControls de framer-motion; siguiendo el port Vue, esa coreografía
5
- // se sustituye por un único porcentaje derivado de los mismos props (`percent`)
6
- // que revela una capa coloreada superpuesta a la de fondo mediante `clip-path`,
7
- // animado con `transition` CSS. El subrayado decorativo no se reproduce.
8
- //
9
- // `activeUnderlineWhenFillStep1`/`activeUnderlineWhenFillToStep2` se aceptan
10
- // por paridad de API pero no afectan a `percent` (solo controlaban el
11
- // subrayado). Prioridad de `percent`: gana el flag del paso más avanzado
12
- // (misma elección deliberada documentada en Progressbar.vue).
13
5
  @Component({
14
6
  selector: 'ba-progressbar',
15
7
  standalone: true,
16
8
  changeDetection: ChangeDetectionStrategy.OnPush,
17
9
  template: `
18
- <div class="bas-relative bas-flex bas-h-[54px] bas-w-60 bas-flex-row bas-items-center bas-justify-between">
19
- <!-- Fondo apagado (siempre visible) -->
20
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
21
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#acd4e4" stroke-width="5" fill="transparent" />
22
- </svg>
23
- <svg width="82" height="8" style="position: absolute; left: 26px; z-index: 0" xmlns="http://www.w3.org/2000/svg">
24
- <path fill="#c4e0ec" d="M0 0h90v10H0Z" />
25
- </svg>
26
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
27
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#acd4e4" stroke-width="5" fill="transparent" />
28
- </svg>
29
- <svg width="82" height="8" style="position: absolute; left: 130px; z-index: 0" xmlns="http://www.w3.org/2000/svg">
30
- <path fill="#c4e0ec" d="M0 0h90v10H0Z" />
31
- </svg>
32
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
33
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#acd4e4" stroke-width="5" fill="transparent" />
34
- </svg>
35
-
36
- <!-- Capa coloreada, revelada según percent -->
37
- <div
38
- class="bas-absolute bas-flex bas-h-full bas-w-full bas-flex-row bas-items-center bas-justify-between bas-progress-fill"
39
- [style.clip-path]="'inset(0 ' + (100 - percent()) + '% 0 0)'"
40
- data-testid="progressbar-fill"
41
- [attr.data-percent]="percent()"
42
- >
43
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
44
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#1961a4" stroke-width="5" fill="transparent" />
45
- <circle r="5" cx="15" cy="15" fill="#1961a4" />
46
- </svg>
47
- <svg width="84" height="8" style="position: absolute; left: 26px; z-index: 0" xmlns="http://www.w3.org/2000/svg">
48
- <path fill="#1961a4" d="M0 0h90v10H0Z" />
49
- </svg>
50
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
51
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#1961a4" stroke-width="5" fill="transparent" />
52
- <circle r="5" cx="15" cy="15" fill="#1961a4" />
53
- </svg>
54
- <svg width="84" height="8" style="position: absolute; left: 130px; z-index: 0" xmlns="http://www.w3.org/2000/svg">
55
- <path fill="#1961a4" d="M0 0h90v10H0Z" />
56
- </svg>
57
- <svg height="30" width="30" style="z-index: 1" xmlns="http://www.w3.org/2000/svg">
58
- <path d="M4,15a11,11 0 1,0 22,0a11,11 0 1,0 -22,0" stroke="#1961a4" stroke-width="5" fill="transparent" />
59
- <circle r="5" cx="15" cy="15" fill="#1961a4" />
60
- </svg>
61
- </div>
10
+ <div
11
+ class="bal-ba-stepper"
12
+ [attr.data-step]="step()"
13
+ data-testid="progressbar"
14
+ role="progressbar"
15
+ aria-valuemin="1"
16
+ aria-valuemax="3"
17
+ [attr.aria-valuenow]="step()"
18
+ >
19
+ <span class="bal-ba-stepper-track">
20
+ <span class="bal-ba-stepper-fill"></span>
21
+ </span>
22
+ @for (node of steps; track node) {
23
+ <span
24
+ class="bal-ba-stepper-node"
25
+ [attr.data-state]="node < step() ? 'done' : node === step() ? 'active' : 'pending'"
26
+ ></span>
27
+ }
28
+ <span class="bal-ba-stepper-indicator"></span>
62
29
  </div>
63
30
  `,
64
- styles: [
65
- `
66
- .bas-progress-fill {
67
- transition: clip-path 0.6s ease;
68
- }
69
- `,
70
- ],
71
31
  })
72
32
  export class ProgressbarComponent {
73
- step1 = input(false);
74
- step2 = input(false);
75
- step3 = input(false);
76
- goBackToStep1 = input(false);
77
- goBackToStep2 = input(false);
78
- fillStep1 = input(false);
79
- activeUnderlineWhenFillStep1 = input(false);
80
- fillToStep2 = input(false);
81
- activeUnderlineWhenFillToStep2 = input(false);
33
+ step = input.required<ProgressbarStep>();
82
34
 
83
- percent = computed(() => {
84
- if (this.step3()) return 100;
85
- if (this.step2()) return 50;
86
- if (this.step1()) return 15;
87
- if (this.goBackToStep2()) return 50;
88
- if (this.goBackToStep1()) return 15;
89
- if (this.fillToStep2()) return 50;
90
- if (this.fillStep1()) return 15;
91
- return 0;
92
- });
35
+ protected readonly steps: ProgressbarStep[] = [1, 2, 3];
93
36
  }