@block-auth.io/angular 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/fesm2022/block-auth.io-angular.mjs +9828 -0
  2. package/fesm2022/block-auth.io-angular.mjs.map +1 -0
  3. package/index.d.ts +1144 -0
  4. package/package.json +16 -37
  5. package/.turbo/turbo-build.log +0 -37
  6. package/.turbo/turbo-lint.log +0 -4
  7. package/.turbo/turbo-test.log +0 -1400
  8. package/.turbo/turbo-typecheck.log +0 -19
  9. package/CHANGELOG.md +0 -273
  10. package/ng-package.json +0 -6
  11. package/scripts/css-to-ts.mjs +0 -14
  12. package/src/lib/__tests__/integration.test.ts +0 -45
  13. package/src/lib/block-auth.service.test.ts +0 -69
  14. package/src/lib/block-auth.service.ts +0 -81
  15. package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
  16. package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
  17. package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
  18. package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
  19. package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
  20. package/src/lib/components/btns/btn-gmail.component.ts +0 -41
  21. package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
  22. package/src/lib/components/btns/btn-google-base.component.ts +0 -73
  23. package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
  24. package/src/lib/components/btns/btn-metamask.component.ts +0 -98
  25. package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
  26. package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
  27. package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
  28. package/src/lib/components/btns/btn-phantom.component.ts +0 -93
  29. package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
  30. package/src/lib/components/btns/btn-signin.component.ts +0 -108
  31. package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
  32. package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
  33. package/src/lib/components/btns/index.ts +0 -11
  34. package/src/lib/components/contents/content-signin.component.test.ts +0 -33
  35. package/src/lib/components/contents/content-signin.component.ts +0 -68
  36. package/src/lib/components/contents/content-signup.component.test.ts +0 -86
  37. package/src/lib/components/contents/content-signup.component.ts +0 -222
  38. package/src/lib/components/dds/change-account.component.test.ts +0 -66
  39. package/src/lib/components/dds/change-account.component.ts +0 -112
  40. package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
  41. package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
  42. package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
  43. package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
  44. package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
  45. package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
  46. package/src/lib/components/flow-block-auth.component.test.ts +0 -95
  47. package/src/lib/components/flow-block-auth.component.ts +0 -228
  48. package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
  49. package/src/lib/components/modals/modal-overlay.component.ts +0 -43
  50. package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
  51. package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
  52. package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
  53. package/src/lib/components/modals/modal-restore.component.ts +0 -104
  54. package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
  55. package/src/lib/components/modals/modal-signin.component.ts +0 -44
  56. package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
  57. package/src/lib/components/modals/modal-signup.component.ts +0 -40
  58. package/src/lib/components/sections/footer-section.component.test.ts +0 -19
  59. package/src/lib/components/sections/footer-section.component.ts +0 -49
  60. package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
  61. package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
  62. package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
  63. package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
  64. package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
  65. package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
  66. package/src/lib/components/sections/login-section.component.test.ts +0 -49
  67. package/src/lib/components/sections/login-section.component.ts +0 -119
  68. package/src/lib/components/sections/providers-section.component.test.ts +0 -22
  69. package/src/lib/components/sections/providers-section.component.ts +0 -187
  70. package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
  71. package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
  72. package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
  73. package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
  74. package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
  75. package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
  76. package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
  77. package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
  78. package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
  79. package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
  80. package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
  81. package/src/lib/components/txns/internals/txn.component.ts +0 -453
  82. package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
  83. package/src/lib/components/txns/txns-overview.component.ts +0 -461
  84. package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
  85. package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
  86. package/src/lib/icons/cg-profile.component.ts +0 -31
  87. package/src/lib/icons/check-icon.component.ts +0 -27
  88. package/src/lib/icons/ci-clock2.component.ts +0 -31
  89. package/src/lib/icons/fa-arrow-right.component.ts +0 -21
  90. package/src/lib/icons/fa-times.component.ts +0 -21
  91. package/src/lib/icons/fa-undo.component.ts +0 -21
  92. package/src/lib/icons/icons.test.ts +0 -25
  93. package/src/lib/icons/index.ts +0 -22
  94. package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
  95. package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
  96. package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
  97. package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
  98. package/src/lib/icons/pi-warning-fill.component.ts +0 -21
  99. package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
  100. package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
  101. package/src/lib/icons/tb-copy.component.ts +0 -34
  102. package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
  103. package/src/lib/inject-store.test.ts +0 -26
  104. package/src/lib/inject-store.ts +0 -16
  105. package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
  106. package/src/lib/primitives/arrow-icon.component.ts +0 -45
  107. package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
  108. package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
  109. package/src/lib/primitives/btn-base.component.test.ts +0 -38
  110. package/src/lib/primitives/btn-base.component.ts +0 -140
  111. package/src/lib/primitives/divider-base.component.test.ts +0 -12
  112. package/src/lib/primitives/divider-base.component.ts +0 -74
  113. package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
  114. package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
  115. package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
  116. package/src/lib/primitives/dropdown-base.component.ts +0 -329
  117. package/src/lib/primitives/helpers.ts +0 -151
  118. package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
  119. package/src/lib/primitives/horizontal-loader.component.ts +0 -46
  120. package/src/lib/primitives/icon-base.component.test.ts +0 -19
  121. package/src/lib/primitives/icon-base.component.ts +0 -58
  122. package/src/lib/primitives/img-loader.component.test.ts +0 -22
  123. package/src/lib/primitives/img-loader.component.ts +0 -121
  124. package/src/lib/primitives/index.ts +0 -29
  125. package/src/lib/primitives/input-base.component.test.ts +0 -20
  126. package/src/lib/primitives/input-base.component.ts +0 -210
  127. package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
  128. package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
  129. package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
  130. package/src/lib/primitives/oval-spinner.component.ts +0 -136
  131. package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
  132. package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
  133. package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
  134. package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
  135. package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
  136. package/src/lib/primitives/progressbar.component.test.ts +0 -34
  137. package/src/lib/primitives/progressbar.component.ts +0 -36
  138. package/src/lib/primitives/providersStyles.ts +0 -218
  139. package/src/lib/primitives/slider-base.component.ts +0 -56
  140. package/src/lib/provide-block-auth.test.ts +0 -43
  141. package/src/lib/provide-block-auth.ts +0 -43
  142. package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
  143. package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
  144. package/src/lib/teleport-body.directive.test.ts +0 -29
  145. package/src/lib/teleport-body.directive.ts +0 -21
  146. package/src/lib/testing.ts +0 -15
  147. package/src/lib/transitions.css +0 -19
  148. package/src/public-api.ts +0 -86
  149. package/src/vitest.setup.ts +0 -8
  150. package/tailwind.config.cjs +0 -6
  151. package/tsconfig.json +0 -15
  152. package/tsconfig.lib.json +0 -9
  153. package/vite.config.mts +0 -44
@@ -1,430 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- DestroyRef,
5
- ElementRef,
6
- afterNextRender,
7
- computed,
8
- effect,
9
- inject,
10
- input,
11
- output,
12
- signal,
13
- viewChild,
14
- } from '@angular/core';
15
- import { $locale, t as translate, type TextKey, type TxnDataParam } from '@block-auth.io/core';
16
- import { injectStore } from '../../../inject-store';
17
- import { PhoneInputComponent } from './phone-input.component';
18
- import {
19
- PARAM_ERROR_KEYS,
20
- PARAM_INPUT_TYPE,
21
- PARAM_LABEL_KEYS,
22
- getSolicitedFields,
23
- getSolicitedHintKey,
24
- getSolicitedParams,
25
- isSolicitedDataComplete,
26
- isSolicitedHintSuccess,
27
- type SolicitedField,
28
- } from '@block-auth.io/core';
29
-
30
- // `handleParamChange`/`onValidationChange` (callback props en react) -> outputs
31
- // `paramChange`/`validationChange`: notificaciones puras de "algo cambió en la
32
- // UI de este componente" (a diferencia de `closeTxns`/`addError` en Txn, que
33
- // son funciones orquestadas imperativamente por el padre). `paramChange` emite
34
- // `{ slug, value }` (un output Angular emite un único valor; se agrupa el par).
35
- //
36
- // El `useEffect(() => onValidationChange(allRequiredFilled), [allRequiredFilled])`
37
- // de react -> `effect()` de Angular: emite el valor inicial tras el primer CD
38
- // (igual que el efecto de react corre tras el primer render) y en cada cambio.
39
- export interface ParamChange {
40
- slug: string;
41
- value: string;
42
- }
43
-
44
- export interface ShareChange {
45
- slug: string;
46
- shared: boolean;
47
- }
48
-
49
- interface SolicitedFieldView extends SolicitedField {
50
- isRequired: boolean;
51
- isPending: boolean;
52
- label: string;
53
- inputId: string;
54
- inputType: string;
55
- error: string | null;
56
- hint: string | null;
57
- isHintSuccess: boolean;
58
- showDecision: boolean;
59
- describedBy: string | null;
60
- isPhone: boolean;
61
- }
62
-
63
- @Component({
64
- selector: 'ba-solicited-data-modal',
65
- standalone: true,
66
- imports: [PhoneInputComponent],
67
- changeDetection: ChangeDetectionStrategy.OnPush,
68
- template: `
69
- <div
70
- class="bal-ba-glass-panel bal-ba-glass-pop bal-ba-glass-modal bas-box-border bas-w-full bas-max-w-[334px] bas-gap-4 bas-p-4"
71
- >
72
- @if (closable()) {
73
- <div class="bal-ba-glass-modal-head">
74
- <button
75
- type="button"
76
- id="solicited-data-close"
77
- [attr.aria-label]="t('close')"
78
- class="bal-ba-glass-close"
79
- (click)="closed.emit()"
80
- >
81
- <svg
82
- viewBox="0 0 10 10"
83
- fill="none"
84
- stroke="currentColor"
85
- stroke-width="1.6"
86
- stroke-linecap="round"
87
- aria-hidden="true"
88
- >
89
- <path d="M2 2l6 6M8 2 2 8" />
90
- </svg>
91
- </button>
92
- </div>
93
- }
94
- <div
95
- #scroll
96
- [class]="'bal-ba-glass-scroll' + (isScrollable() ? ' bal-ba-glass-scroll-overflow' : '')"
97
- >
98
- <div class="bal-ba-glass-stagger bas-flex bas-flex-col bas-gap-3">
99
- @for (field of fields(); track field.slug) {
100
- <div
101
- [class]="'bal-ba-glass-field' + (field.isPending ? ' bal-ba-glass-field-pending' : '')"
102
- >
103
- <div class="bal-ba-glass-field-head">
104
- <label [for]="field.inputId" class="bal-ba-glass-label">
105
- <span>{{ field.label }}</span>
106
- @if (field.isRequired) {
107
- <span class="bal-ba-glass-label-required">{{ requiredLabelTxtResolved() }}</span>
108
- } @else {
109
- <span class="bal-ba-glass-label-optional">{{ optionalLabelTxtResolved() }}</span>
110
- }
111
- </label>
112
- @if (withConsent()) {
113
- <button
114
- type="button"
115
- role="switch"
116
- [id]="'solicited-data-share-' + field.slug"
117
- [attr.aria-checked]="field.isShared ? 'true' : 'false'"
118
- [disabled]="field.isEmpty"
119
- [attr.aria-label]="t('shareData') + ' ' + field.label"
120
- class="bal-ba-glass-switch"
121
- (click)="onShare(field)"
122
- >
123
- <span aria-hidden="true">{{ t('shareData') }}</span>
124
- <span class="bal-ba-glass-switch-track" aria-hidden="true">
125
- <span class="bal-ba-glass-switch-thumb"></span>
126
- </span>
127
- </button>
128
- }
129
- </div>
130
- @if (field.isPhone) {
131
- <ba-phone-input
132
- #phoneInput
133
- [inputId]="field.inputId"
134
- [value]="field.inputValue"
135
- [invalid]="!!field.error"
136
- [describedBy]="field.describedBy"
137
- (valueChange)="paramChange.emit({ slug: field.slug, value: $event })"
138
- (blurred)="onBlur(field.slug)"
139
- >
140
- @if (field.inputValue) {
141
- <button
142
- type="button"
143
- [attr.aria-label]="t('clearField') + ' ' + field.label"
144
- class="bal-ba-glass-input-clear"
145
- (click)="onClear(field.slug, phoneInput)"
146
- >
147
- <svg
148
- viewBox="0 0 10 10"
149
- fill="none"
150
- stroke="currentColor"
151
- stroke-width="1.8"
152
- stroke-linecap="round"
153
- aria-hidden="true"
154
- >
155
- <path d="M2 2l6 6M8 2 2 8" />
156
- </svg>
157
- </button>
158
- }
159
- </ba-phone-input>
160
- } @else {
161
- <div class="bal-ba-glass-input-wrap">
162
- <input
163
- #fieldInput
164
- [id]="field.inputId"
165
- [type]="field.inputType"
166
- [value]="field.inputValue"
167
- [attr.aria-invalid]="field.error ? 'true' : 'false'"
168
- [attr.aria-describedby]="field.describedBy"
169
- class="bal-ba-glass-input"
170
- (input)="onInput(field.slug, $event)"
171
- (blur)="onBlur(field.slug)"
172
- />
173
- @if (field.inputValue) {
174
- <button
175
- type="button"
176
- [attr.aria-label]="t('clearField') + ' ' + field.label"
177
- class="bal-ba-glass-input-clear"
178
- (click)="onClear(field.slug, fieldInput)"
179
- >
180
- <svg
181
- viewBox="0 0 10 10"
182
- fill="none"
183
- stroke="currentColor"
184
- stroke-width="1.8"
185
- stroke-linecap="round"
186
- aria-hidden="true"
187
- >
188
- <path d="M2 2l6 6M8 2 2 8" />
189
- </svg>
190
- </button>
191
- }
192
- </div>
193
- }
194
- @if (field.error) {
195
- <p [id]="field.inputId + '-error'" class="bal-ba-glass-error">
196
- {{ field.error }}
197
- </p>
198
- } @if (field.showDecision) {
199
- <div class="bal-ba-glass-decision">
200
- @if (field.hint) {
201
- <p
202
- [id]="field.inputId + '-hint'"
203
- [class]="
204
- 'bal-ba-glass-hint' +
205
- (field.isHintSuccess ? ' bal-ba-glass-hint-success' : '')
206
- "
207
- >
208
- {{ field.hint }}
209
- </p>
210
- }
211
- <div class="bal-ba-glass-decision-actions">
212
- <button
213
- type="button"
214
- [id]="'solicited-data-undo-' + field.slug"
215
- class="bal-ba-glass-chip-btn"
216
- (click)="undoParam.emit(field.slug)"
217
- >
218
- {{ t('undoChange') }}
219
- </button>
220
- @if (!field.isSaved) {
221
- <button
222
- type="button"
223
- [id]="'solicited-data-save-' + field.slug"
224
- [disabled]="!field.isValid && !field.isEmpty"
225
- class="bal-ba-glass-chip-btn bal-ba-glass-chip-btn-primary"
226
- (click)="saveParam.emit(field.slug)"
227
- >
228
- {{ t('saveData') }}
229
- </button>
230
- }
231
- </div>
232
- </div>
233
- } @else { @if (field.hint) {
234
- <p
235
- [id]="field.inputId + '-hint'"
236
- [class]="
237
- 'bal-ba-glass-hint' +
238
- (field.isHintSuccess ? ' bal-ba-glass-hint-success' : '')
239
- "
240
- >
241
- {{ field.hint }}
242
- </p>
243
- } }
244
- </div>
245
- }
246
- </div>
247
- </div>
248
- @if (!allRequiredFilled()) {
249
- <p id="solicited-data-notice" class="bal-ba-glass-notice bal-ba-glass-rise">
250
- <svg
251
- viewBox="0 0 16 16"
252
- fill="none"
253
- stroke="currentColor"
254
- stroke-width="1.5"
255
- stroke-linecap="round"
256
- aria-hidden="true"
257
- class="bal-ba-glass-notice-icon"
258
- >
259
- <circle cx="8" cy="8" r="6.25" />
260
- <path d="M8 7.25v3.5M8 5.1v.01" />
261
- </svg>
262
- <span>{{ fillRequiredTxtResolved() }}</span>
263
- </p>
264
- } @if (errorTxt()) {
265
- <p role="alert" class="bal-ba-glass-notice bal-ba-glass-notice-error bal-ba-glass-rise">
266
- {{ errorTxt() }}
267
- </p>
268
- } @if (closable() || acceptable()) {
269
- <div class="bal-ba-glass-actions">
270
- @if (closable()) {
271
- <button
272
- type="button"
273
- id="solicited-data-cancel"
274
- class="bal-ba-glass-action bal-ba-glass-action-primary bal-ba-glass-action-secondary"
275
- (click)="closed.emit()"
276
- >
277
- {{ cancelTxt() ?? t('cancelData') }}
278
- </button>
279
- } @if (acceptable()) {
280
- <button
281
- type="button"
282
- id="solicited-data-accept"
283
- class="bal-ba-glass-action bal-ba-glass-action-primary"
284
- [disabled]="!allRequiredFilled()"
285
- (click)="accepted.emit()"
286
- >
287
- {{ acceptTxt() ?? t('acceptData') }}
288
- </button>
289
- }
290
- </div>
291
- }
292
- </div>
293
- `,
294
- })
295
- export class SolicitedDataModalComponent {
296
- requiredParams = input<string[]>([]);
297
- optionalParams = input<string[]>([]);
298
- params = input<TxnDataParam[] | null>();
299
- userParamValues = input<Record<string, string>>({});
300
- sharedParams = input<Record<string, boolean>>({});
301
- savedParams = input<Record<string, string>>({});
302
- requiredLabelTxt = input<string>();
303
- optionalLabelTxt = input<string>();
304
- fillRequiredTxt = input<string>();
305
- errorTxt = input<string>();
306
- closable = input(false);
307
- acceptable = input(false);
308
- acceptTxt = input<string>();
309
- cancelTxt = input<string>();
310
-
311
- paramChange = output<ParamChange>();
312
- shareChange = output<ShareChange>();
313
- saveParam = output<string>();
314
- undoParam = output<string>();
315
- validationChange = output<boolean>();
316
- closed = output<void>();
317
- accepted = output<void>();
318
-
319
- private readonly locale = injectStore($locale);
320
- protected t = (key: TextKey): string => translate(key, this.locale());
321
-
322
- protected readonly requiredLabelTxtResolved = computed(
323
- () => this.requiredLabelTxt() ?? this.t('required')
324
- );
325
- protected readonly optionalLabelTxtResolved = computed(
326
- () => this.optionalLabelTxt() ?? this.t('optional')
327
- );
328
- protected readonly withConsent = computed(() => !!this.params());
329
- protected readonly fillRequiredTxtResolved = computed(
330
- () =>
331
- this.fillRequiredTxt() ??
332
- this.t(this.withConsent() ? 'completeRequiredData' : 'fillRequiredFields')
333
- );
334
-
335
- private readonly touched = signal<Record<string, boolean>>({});
336
- private readonly scroll = viewChild.required<ElementRef<HTMLDivElement>>('scroll');
337
- protected readonly isScrollable = signal(false);
338
-
339
- private readonly solicitedFields = computed(() =>
340
- getSolicitedFields(
341
- getSolicitedParams({
342
- params: this.params(),
343
- requiredParams: this.requiredParams(),
344
- optionalParams: this.optionalParams(),
345
- }),
346
- {
347
- values: this.userParamValues(),
348
- shared: this.sharedParams(),
349
- saved: this.savedParams(),
350
- },
351
- this.withConsent()
352
- )
353
- );
354
-
355
- protected readonly allRequiredFilled = computed(() =>
356
- isSolicitedDataComplete(this.solicitedFields())
357
- );
358
-
359
- protected readonly fields = computed<SolicitedFieldView[]>(() =>
360
- this.solicitedFields().map((field) => {
361
- const labelKey = PARAM_LABEL_KEYS[field.slug];
362
- const label = labelKey ? this.t(labelKey) : field.slug;
363
- const inputId = `solicited-data-${field.slug}`;
364
- const errorKey = PARAM_ERROR_KEYS[field.slug];
365
- const error =
366
- this.touched()[field.slug] &&
367
- field.inputValue.trim() &&
368
- !field.isValid &&
369
- errorKey
370
- ? this.t(errorKey)
371
- : null;
372
- const showDecision = this.withConsent() && field.isChanged;
373
- const hintKey = getSolicitedHintKey(field, this.withConsent());
374
- const hint = hintKey ? this.t(hintKey) : null;
375
- return {
376
- ...field,
377
- isRequired: field.mode === 'required',
378
- isPending: field.mode === 'required' && !field.isComplete,
379
- label,
380
- inputId,
381
- inputType: PARAM_INPUT_TYPE[field.slug] || 'text',
382
- isPhone: PARAM_INPUT_TYPE[field.slug] === 'tel',
383
- error,
384
- hint,
385
- isHintSuccess: isSolicitedHintSuccess(field),
386
- showDecision,
387
- describedBy: error ? `${inputId}-error` : hint ? `${inputId}-hint` : null,
388
- };
389
- })
390
- );
391
-
392
- constructor() {
393
- effect(() => {
394
- this.validationChange.emit(this.allRequiredFilled());
395
- });
396
-
397
- const destroyRef = inject(DestroyRef);
398
- afterNextRender(() => {
399
- const el = this.scroll().nativeElement;
400
- const update = () => this.isScrollable.set(el.scrollHeight > el.clientHeight + 1);
401
- update();
402
- if (typeof ResizeObserver === 'undefined') return;
403
- const observer = new ResizeObserver(update);
404
- observer.observe(el);
405
- if (el.firstElementChild) observer.observe(el.firstElementChild);
406
- destroyRef.onDestroy(() => observer.disconnect());
407
- });
408
- }
409
-
410
- onBlur(slug: string): void {
411
- this.touched.update((prev) => ({ ...prev, [slug]: true }));
412
- }
413
-
414
- onShare(field: SolicitedField): void {
415
- if (field.isEmpty) return;
416
- this.shareChange.emit({ slug: field.slug, shared: !field.isShared });
417
- }
418
-
419
- onClear(slug: string, inputEl: { focus: () => void }): void {
420
- this.paramChange.emit({ slug, value: '' });
421
- inputEl.focus();
422
- }
423
-
424
- onInput(slug: string, event: Event): void {
425
- this.paramChange.emit({
426
- slug,
427
- value: (event.target as HTMLInputElement).value,
428
- });
429
- }
430
- }
@@ -1,127 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { Component } from '@angular/core';
3
- import { render, screen, fireEvent } from '@testing-library/angular';
4
- import { setLocale } from '@block-auth.io/core';
5
- import { TxnErrorComponent } from './txn-error.component';
6
- import { provideBlockAuthClientForTest } from '../../../testing';
7
-
8
- vi.mock('@wagmi/core', () => ({
9
- createConfig: vi.fn(() => ({ connectors: [] })),
10
- connect: vi.fn(),
11
- disconnect: vi.fn(),
12
- getAccount: vi.fn(() => ({})),
13
- signMessage: vi.fn(),
14
- watchAccount: vi.fn(() => () => undefined),
15
- http: vi.fn(),
16
- }));
17
- vi.mock('@wagmi/connectors', () => ({
18
- injected: vi.fn(() => ({ id: 'injected' })),
19
- walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
20
- }));
21
-
22
- // Port de packages/react/src/components/txns/internals/TxnError.test.tsx +
23
- // TxnActions.behavior.test.tsx (REPORT -> client.txns.report). Mapa: Vue.
24
- describe('TxnError', () => {
25
- function makeClient(report = vi.fn()) {
26
- return { txns: { report } } as any;
27
- }
28
-
29
- afterEach(() => setLocale('en'));
30
-
31
- it('renderiza el panel de error de txn', async () => {
32
- await render(TxnErrorComponent, {
33
- inputs: { errorMessageTxt: 'No transactions found' },
34
- providers: [provideBlockAuthClientForTest(makeClient())],
35
- });
36
- expect(screen.getByText('No transactions found')).toBeDefined();
37
- expect(screen.getByText('REPORT')).toBeDefined();
38
- });
39
-
40
- it('respeta el locale activo cuando no se pasan textos custom', async () => {
41
- setLocale('es');
42
- await render(TxnErrorComponent, {
43
- inputs: { errorMessageTxt: 'No transactions found' },
44
- providers: [provideBlockAuthClientForTest(makeClient())],
45
- });
46
- expect(screen.getByText('REPORTAR')).toBeDefined();
47
- });
48
-
49
- it('REPORT llama a client.txns.report(slug)', async () => {
50
- const report = vi.fn();
51
- await render(TxnErrorComponent, {
52
- inputs: {
53
- errorMessageTxt: 'No transactions found',
54
- errorMessageSlug: 'no_transactions_found',
55
- },
56
- providers: [provideBlockAuthClientForTest(makeClient(report))],
57
- });
58
- await fireEvent.click(screen.getByText('REPORT'));
59
- expect(report).toHaveBeenCalledWith('no_transactions_found');
60
- });
61
-
62
- describe('countdown tras REPORT', () => {
63
- beforeEach(() => {
64
- vi.useFakeTimers();
65
- });
66
- afterEach(() => {
67
- vi.useRealTimers();
68
- });
69
-
70
- it('muestra "Thanks for reporting" y cuenta hasta cerrar via closeTxns', async () => {
71
- const closeTxns = vi.fn();
72
- @Component({
73
- standalone: true,
74
- imports: [TxnErrorComponent],
75
- template: `<ba-txn-error
76
- errorMessageTxt="No transactions found"
77
- [closeTxns]="c"
78
- />`,
79
- })
80
- class Host {
81
- c = closeTxns;
82
- }
83
- const { fixture } = await render(Host, {
84
- providers: [provideBlockAuthClientForTest(makeClient())],
85
- });
86
-
87
- await fireEvent.click(screen.getByText('REPORT'));
88
- await vi.advanceTimersByTimeAsync(1500);
89
- fixture.detectChanges();
90
- expect(screen.getByText('Thanks for reporting the error!')).toBeDefined();
91
-
92
- // 10s countdown, ticking every second; closeTxns fires when it hits 0.
93
- await vi.advanceTimersByTimeAsync(9000);
94
- expect(closeTxns).not.toHaveBeenCalled();
95
- await vi.advanceTimersByTimeAsync(1000);
96
- expect(closeTxns).toHaveBeenCalledOnce();
97
- });
98
-
99
- it('con isCountdown=false no arranca el countdown ni cierra solo', async () => {
100
- const closeTxns = vi.fn();
101
- @Component({
102
- standalone: true,
103
- imports: [TxnErrorComponent],
104
- template: `<ba-txn-error
105
- errorMessageTxt="No transactions found"
106
- [closeTxns]="c"
107
- [isCountdown]="false"
108
- />`,
109
- })
110
- class Host {
111
- c = closeTxns;
112
- }
113
- const { fixture } = await render(Host, {
114
- providers: [provideBlockAuthClientForTest(makeClient())],
115
- });
116
-
117
- await fireEvent.click(screen.getByText('REPORT'));
118
- await vi.advanceTimersByTimeAsync(1500);
119
- await vi.advanceTimersByTimeAsync(20000);
120
- fixture.detectChanges();
121
- expect(closeTxns).not.toHaveBeenCalled();
122
-
123
- await fireEvent.click(screen.getByText('Close'));
124
- expect(closeTxns).toHaveBeenCalledOnce();
125
- });
126
- });
127
- });
@@ -1,144 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- DestroyRef,
5
- computed,
6
- inject,
7
- input,
8
- signal,
9
- } from '@angular/core';
10
- import { $locale, t as translate, type TextKey } from '@block-auth.io/core';
11
- import { injectStore } from '../../../inject-store';
12
- import { injectBlockAuthClient } from '../../../provide-block-auth';
13
-
14
- // `closeTxns` se mantiene como INPUT DE FUNCIÓN (no output): react lo invoca
15
- // imperativamente tanto desde el botón "Close" como desde dentro del
16
- // setInterval del countdown — no es un evento de UI disparado por una
17
- // interacción directa de este componente, sino una función que este orquesta
18
- // a su propio ritmo (misma convención que Txn/TxnsOverview para este prop).
19
- //
20
- // Deviación deliberada (consistente con el port Vue): se limpian el
21
- // timeout/interval pendientes vía `DestroyRef` para no mutar signals de un
22
- // componente ya destruido en tests con temporizadores reales/fake.
23
- @Component({
24
- selector: 'ba-txn-error',
25
- standalone: true,
26
- changeDetection: ChangeDetectionStrategy.OnPush,
27
- template: `
28
- <div
29
- class="bas-box-border bas-flex bas-h-full bas-max-w-full bas-flex-col bas-items-center bas-gap-8 bas-px-4 bas-pt-6 bas-text-center bas-text-xl bas-font-medium bas-text-[var(--bal-primary-800)]"
30
- >
31
- <div class="bas-h-20 bas-w-20 bas-text-red-700" aria-hidden="true">⚠</div>
32
- <div
33
- class="bal-ba-transition-2 bal-ba-shadow-base bal-ba-hover-shadow-lg bas-box-border bas-flex bas-w-full bas-cursor-default bas-items-center bas-justify-center bas-rounded-md bas-border-2 bas-border-solid bas-border-red-600 bas-bg-red-50 bas-px-2 bas-py-4 bas-text-2xl bas-text-[var(--bal-primary-600)] hover:bas-border-red-800 hover:bas-bg-red-100 hover:bas-text-[var(--bal-primary-900)]"
34
- >
35
- <p class="bas-m-0">{{ errorMessageTxt() }}</p>
36
- </div>
37
- <div
38
- class="bas-box-border bas-flex bas-w-full bas-flex-col bas-items-center bas-justify-center bas-gap-1 bas-px-1"
39
- >
40
- <div class="bas-h-16 bas-w-full">
41
- @if (!reportSent()) {
42
- <p class="bas-m-0">{{ helpUsTxtResolved() }}</p>
43
- } @else {
44
- <p class="bas-m-0">{{ thanksForReportTxtResolved() }}</p>
45
- }
46
- </div>
47
- @if (!reportSent()) {
48
- <button
49
- type="button"
50
- id="btn-txn-report-error"
51
- [disabled]="sendingReport()"
52
- class="bal-ba-hover-ring-red-500 bal-ba-focus-ring-red-500 bas-mt-2 bas-w-[220px] bas-justify-center bas-bg-red-500 hover:bas-bg-red-600 bas-px-4 bas-text-center bas-text-xl bas-font-medium bas-text-[var(--bal-primary-10)]"
53
- (click)="onReportErrorClicked()"
54
- >
55
- {{ sendingReport() ? '…' : reportTxtResolved() }}
56
- </button>
57
- } @else {
58
- <button
59
- type="button"
60
- id="btn-txn-error-report"
61
- class="bal-ba-hover-ring-primary-300 bal-ba-focus-ring-primary-300 bas-mt-2 bas-w-[220px] bas-justify-center bas-rounded-md bas-border-2 bas-border-solid bas-border-[var(--bal-primary-300)] bas-bg-transparent bas-px-4 bas-text-center bas-text-xl bas-font-medium bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]"
62
- (click)="close()"
63
- >
64
- {{ textCloseTxtResolved() }}
65
- </button>
66
- }
67
- </div>
68
- @if (reportSent() && isCountdown()) {
69
- <div class="bas-flex bas-flex-row bas-items-end bas-gap-2">
70
- <p class="bas-m-0">{{ modalWillCloseInTxtResolved() }}</p>
71
- <p class="bas-m-0">{{ countDown() }}</p>
72
- </div>
73
- }
74
- </div>
75
- `,
76
- })
77
- export class TxnErrorComponent {
78
- errorMessageSlug = input('unknown');
79
- errorMessageTxt = input('unknown');
80
- closeTxns = input<() => void>(() => {});
81
- helpUsTxt = input<string>();
82
- thanksForReportTxt = input<string>();
83
- reportTxt = input<string>();
84
- textCloseTxt = input<string>();
85
- modalWillCloseInTxt = input<string>();
86
- isCountdown = input(true);
87
-
88
- private readonly client = injectBlockAuthClient();
89
- private readonly locale = injectStore($locale);
90
- protected t = (key: TextKey): string => translate(key, this.locale());
91
-
92
- protected readonly helpUsTxtResolved = computed(
93
- () => this.helpUsTxt() ?? this.t('helpUsReport'),
94
- );
95
- protected readonly thanksForReportTxtResolved = computed(
96
- () => this.thanksForReportTxt() ?? this.t('thanksForReport'),
97
- );
98
- protected readonly reportTxtResolved = computed(
99
- () => this.reportTxt() ?? this.t('report'),
100
- );
101
- protected readonly textCloseTxtResolved = computed(
102
- () => this.textCloseTxt() ?? this.t('close'),
103
- );
104
- protected readonly modalWillCloseInTxtResolved = computed(
105
- () => this.modalWillCloseInTxt() ?? this.t('modalWillCloseIn'),
106
- );
107
-
108
- protected readonly sendingReport = signal(false);
109
- protected readonly reportSent = signal(false);
110
- protected readonly countDown = signal(10);
111
-
112
- private reportTimeout: ReturnType<typeof setTimeout> | undefined;
113
- private countdownInterval: ReturnType<typeof setInterval> | undefined;
114
-
115
- constructor() {
116
- inject(DestroyRef).onDestroy(() => {
117
- if (this.reportTimeout) clearTimeout(this.reportTimeout);
118
- if (this.countdownInterval) clearInterval(this.countdownInterval);
119
- });
120
- }
121
-
122
- close(): void {
123
- this.closeTxns()();
124
- }
125
-
126
- onReportErrorClicked(): void {
127
- this.sendingReport.set(true);
128
- this.client.txns.report(this.errorMessageSlug());
129
- this.reportTimeout = setTimeout(() => {
130
- this.sendingReport.set(false);
131
- this.reportSent.set(true);
132
- if (!this.isCountdown()) return;
133
- this.countdownInterval = setInterval(() => {
134
- if (this.countDown() === 1) {
135
- this.closeTxns()();
136
- clearInterval(this.countdownInterval);
137
- this.countDown.set(0);
138
- return;
139
- }
140
- this.countDown.update((v) => v - 1);
141
- }, 1000);
142
- }, 1500);
143
- }
144
- }