@block-auth.io/angular 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/block-auth.io-angular.mjs +9828 -0
- package/fesm2022/block-auth.io-angular.mjs.map +1 -0
- package/index.d.ts +1144 -0
- package/package.json +16 -37
- package/.turbo/turbo-build.log +0 -37
- package/.turbo/turbo-lint.log +0 -4
- package/.turbo/turbo-test.log +0 -1400
- package/.turbo/turbo-typecheck.log +0 -19
- package/CHANGELOG.md +0 -273
- package/ng-package.json +0 -6
- package/scripts/css-to-ts.mjs +0 -14
- package/src/lib/__tests__/integration.test.ts +0 -45
- package/src/lib/block-auth.service.test.ts +0 -69
- package/src/lib/block-auth.service.ts +0 -81
- package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
- package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
- package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
- package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
- package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
- package/src/lib/components/btns/btn-gmail.component.ts +0 -41
- package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
- package/src/lib/components/btns/btn-google-base.component.ts +0 -73
- package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
- package/src/lib/components/btns/btn-metamask.component.ts +0 -98
- package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
- package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
- package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
- package/src/lib/components/btns/btn-phantom.component.ts +0 -93
- package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
- package/src/lib/components/btns/btn-signin.component.ts +0 -108
- package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
- package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
- package/src/lib/components/btns/index.ts +0 -11
- package/src/lib/components/contents/content-signin.component.test.ts +0 -33
- package/src/lib/components/contents/content-signin.component.ts +0 -68
- package/src/lib/components/contents/content-signup.component.test.ts +0 -86
- package/src/lib/components/contents/content-signup.component.ts +0 -222
- package/src/lib/components/dds/change-account.component.test.ts +0 -66
- package/src/lib/components/dds/change-account.component.ts +0 -112
- package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
- package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
- package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
- package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
- package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
- package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
- package/src/lib/components/flow-block-auth.component.test.ts +0 -95
- package/src/lib/components/flow-block-auth.component.ts +0 -228
- package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
- package/src/lib/components/modals/modal-overlay.component.ts +0 -43
- package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
- package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
- package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
- package/src/lib/components/modals/modal-restore.component.ts +0 -104
- package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
- package/src/lib/components/modals/modal-signin.component.ts +0 -44
- package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
- package/src/lib/components/modals/modal-signup.component.ts +0 -40
- package/src/lib/components/sections/footer-section.component.test.ts +0 -19
- package/src/lib/components/sections/footer-section.component.ts +0 -49
- package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
- package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
- package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
- package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
- package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
- package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
- package/src/lib/components/sections/login-section.component.test.ts +0 -49
- package/src/lib/components/sections/login-section.component.ts +0 -119
- package/src/lib/components/sections/providers-section.component.test.ts +0 -22
- package/src/lib/components/sections/providers-section.component.ts +0 -187
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
- package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
- package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
- package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
- package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
- package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
- package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
- package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
- package/src/lib/components/txns/internals/txn.component.ts +0 -453
- package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
- package/src/lib/components/txns/txns-overview.component.ts +0 -461
- package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
- package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
- package/src/lib/icons/cg-profile.component.ts +0 -31
- package/src/lib/icons/check-icon.component.ts +0 -27
- package/src/lib/icons/ci-clock2.component.ts +0 -31
- package/src/lib/icons/fa-arrow-right.component.ts +0 -21
- package/src/lib/icons/fa-times.component.ts +0 -21
- package/src/lib/icons/fa-undo.component.ts +0 -21
- package/src/lib/icons/icons.test.ts +0 -25
- package/src/lib/icons/index.ts +0 -22
- package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
- package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
- package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
- package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
- package/src/lib/icons/pi-warning-fill.component.ts +0 -21
- package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
- package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
- package/src/lib/icons/tb-copy.component.ts +0 -34
- package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
- package/src/lib/inject-store.test.ts +0 -26
- package/src/lib/inject-store.ts +0 -16
- package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
- package/src/lib/primitives/arrow-icon.component.ts +0 -45
- package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
- package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
- package/src/lib/primitives/btn-base.component.test.ts +0 -38
- package/src/lib/primitives/btn-base.component.ts +0 -140
- package/src/lib/primitives/divider-base.component.test.ts +0 -12
- package/src/lib/primitives/divider-base.component.ts +0 -74
- package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
- package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
- package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
- package/src/lib/primitives/dropdown-base.component.ts +0 -329
- package/src/lib/primitives/helpers.ts +0 -151
- package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
- package/src/lib/primitives/horizontal-loader.component.ts +0 -46
- package/src/lib/primitives/icon-base.component.test.ts +0 -19
- package/src/lib/primitives/icon-base.component.ts +0 -58
- package/src/lib/primitives/img-loader.component.test.ts +0 -22
- package/src/lib/primitives/img-loader.component.ts +0 -121
- package/src/lib/primitives/index.ts +0 -29
- package/src/lib/primitives/input-base.component.test.ts +0 -20
- package/src/lib/primitives/input-base.component.ts +0 -210
- package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
- package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
- package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
- package/src/lib/primitives/oval-spinner.component.ts +0 -136
- package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
- package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
- package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
- package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
- package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
- package/src/lib/primitives/progressbar.component.test.ts +0 -34
- package/src/lib/primitives/progressbar.component.ts +0 -36
- package/src/lib/primitives/providersStyles.ts +0 -218
- package/src/lib/primitives/slider-base.component.ts +0 -56
- package/src/lib/provide-block-auth.test.ts +0 -43
- package/src/lib/provide-block-auth.ts +0 -43
- package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
- package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
- package/src/lib/teleport-body.directive.test.ts +0 -29
- package/src/lib/teleport-body.directive.ts +0 -21
- package/src/lib/testing.ts +0 -15
- package/src/lib/transitions.css +0 -19
- package/src/public-api.ts +0 -86
- package/src/vitest.setup.ts +0 -8
- package/tailwind.config.cjs +0 -6
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -9
- package/vite.config.mts +0 -44
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { render } from '@testing-library/angular';
|
|
3
|
-
import { HorizontalLoaderComponent } from './horizontal-loader.component';
|
|
4
|
-
describe('HorizontalLoaderComponent', () => {
|
|
5
|
-
it('renderiza los 3 puntos glass', async () => {
|
|
6
|
-
const { container } = await render(HorizontalLoaderComponent);
|
|
7
|
-
expect(container.querySelector('.bal-ba-glass-dots')).toBeTruthy();
|
|
8
|
-
expect(container.querySelectorAll('.bal-ba-glass-dot')).toHaveLength(3);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// Regresión: el host debe ser `display: contents` para que el <div> absoluto
|
|
12
|
-
// sea hijo directo del flex del botón (como en React). Sin esto el loader
|
|
13
|
-
// aparece descentrado dentro del botón en estado de carga.
|
|
14
|
-
it('el host es transparente al layout (display: contents)', async () => {
|
|
15
|
-
const { container } = await render(HorizontalLoaderComponent);
|
|
16
|
-
// testing-library monta el componente sobre su propio host (el `container`),
|
|
17
|
-
// donde Angular aplica el binding `host` del @Component.
|
|
18
|
-
expect(container.style.display).toBe('contents');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'ba-horizontal-loader',
|
|
5
|
-
standalone: true,
|
|
6
|
-
// El host debe ser transparente al layout para que el <div> absoluto sea hijo
|
|
7
|
-
// directo del flex del botón (como en React, donde HorizontalLoader renderiza
|
|
8
|
-
// el <div> directamente). Sin esto el host `<ba-horizontal-loader>` es un
|
|
9
|
-
// flex-item de ancho ~0 colocado por `justify-center`, y la posición estática
|
|
10
|
-
// del <div> `bas-absolute` (sin left/top) se corre al centro; con `bas-w-full`
|
|
11
|
-
// se desborda a la derecha y el loader aparece descentrado.
|
|
12
|
-
host: { style: 'display: contents' },
|
|
13
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
-
template: `
|
|
15
|
-
<div
|
|
16
|
-
[class]="
|
|
17
|
-
'bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-flex bas-h-full bas-w-full bas-items-center bas-justify-center ' +
|
|
18
|
-
classNames()
|
|
19
|
-
"
|
|
20
|
-
>
|
|
21
|
-
<div
|
|
22
|
-
class="bal-ba-glass-dots"
|
|
23
|
-
role="img"
|
|
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'"
|
|
29
|
-
>
|
|
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>
|
|
34
|
-
</div>
|
|
35
|
-
`,
|
|
36
|
-
})
|
|
37
|
-
export class HorizontalLoaderComponent {
|
|
38
|
-
loaderColor = input('#61a5c2');
|
|
39
|
-
loaderHeight = input(40);
|
|
40
|
-
loaderWidth = input(80);
|
|
41
|
-
classNames = input('bas-rounded-md');
|
|
42
|
-
|
|
43
|
-
dotSize = computed(() =>
|
|
44
|
-
Math.round(Math.min(this.loaderHeight() * 0.4, this.loaderWidth() / 5)),
|
|
45
|
-
);
|
|
46
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, screen } from '@testing-library/angular';
|
|
4
|
-
import { IconBaseComponent } from './icon-base.component';
|
|
5
|
-
|
|
6
|
-
describe('IconBaseComponent', () => {
|
|
7
|
-
it('renderiza el contenido proyectado cuando lo hay', async () => {
|
|
8
|
-
@Component({ standalone: true, imports: [IconBaseComponent], template: `<ba-icon-base><span data-testid="slot">x</span></ba-icon-base>` })
|
|
9
|
-
class Host {}
|
|
10
|
-
await render(Host);
|
|
11
|
-
expect(screen.getByTestId('slot')).toBeTruthy();
|
|
12
|
-
});
|
|
13
|
-
it('renderiza un <img> desde iconUrl cuando no hay contenido proyectado', async () => {
|
|
14
|
-
@Component({ standalone: true, imports: [IconBaseComponent], template: `<ba-icon-base iconUrl="https://x/y.png" />` })
|
|
15
|
-
class Host {}
|
|
16
|
-
const { container } = await render(Host);
|
|
17
|
-
expect(container.querySelector('img')?.getAttribute('src')).toBe('https://x/y.png');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AfterViewChecked,
|
|
3
|
-
ChangeDetectionStrategy,
|
|
4
|
-
Component,
|
|
5
|
-
ElementRef,
|
|
6
|
-
input,
|
|
7
|
-
signal,
|
|
8
|
-
viewChild,
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
|
|
11
|
-
// Renderiza el contenido proyectado
|
|
12
|
-
// (equivalente al slot `icon` de Vue / ReactNode `icon` de React) si hay
|
|
13
|
-
// contenido real, si no un <img> desde `iconUrl`, si no nada.
|
|
14
|
-
//
|
|
15
|
-
// Vue resuelve esto con `useSlots().default({}).length > 0` (comprobación en
|
|
16
|
-
// tiempo de render de si el slot forwardeado produjo vnodes reales). Angular
|
|
17
|
-
// no tiene un equivalente directo para <ng-content>, así que se envuelve la
|
|
18
|
-
// proyección en un <span #iconSlot> propio del template (no del content) y
|
|
19
|
-
// se comprueba en cada ciclo de content-check si ese wrapper terminó con
|
|
20
|
-
// nodos hijos reales — mismo resultado observable (fallback a `iconUrl` solo
|
|
21
|
-
// cuando no se proyectó nada).
|
|
22
|
-
@Component({
|
|
23
|
-
selector: 'ba-icon-base',
|
|
24
|
-
standalone: true,
|
|
25
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
-
template: `
|
|
27
|
-
<span #iconSlot style="display: contents"><ng-content /></span>
|
|
28
|
-
@if (!hasIconContent() && iconUrl()) {
|
|
29
|
-
<img
|
|
30
|
-
[src]="iconUrl()"
|
|
31
|
-
[width]="iconWidth()"
|
|
32
|
-
[height]="iconHeight()"
|
|
33
|
-
[class]="'bas-flex-shrink-0 bas-object-contain ' + iconClassNames()"
|
|
34
|
-
[style.width.px]="iconWidth()"
|
|
35
|
-
[style.height.px]="iconHeight()"
|
|
36
|
-
alt=""
|
|
37
|
-
/>
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
})
|
|
41
|
-
export class IconBaseComponent implements AfterViewChecked {
|
|
42
|
-
iconUrl = input<string | undefined>(undefined);
|
|
43
|
-
iconWidth = input(24);
|
|
44
|
-
iconHeight = input(24);
|
|
45
|
-
iconClassNames = input('bas-rounded-full');
|
|
46
|
-
|
|
47
|
-
// Signal query (no `@ViewChild` — los decoradores de campo clásicos no se
|
|
48
|
-
// soportan en el modo JIT del harness de test AnalogJS/Vitest).
|
|
49
|
-
private readonly iconSlot = viewChild<ElementRef<HTMLElement>>('iconSlot');
|
|
50
|
-
|
|
51
|
-
hasIconContent = signal(false);
|
|
52
|
-
|
|
53
|
-
ngAfterViewChecked(): void {
|
|
54
|
-
const el = this.iconSlot()?.nativeElement ?? null;
|
|
55
|
-
const hasContent = !!el && el.childNodes.length > 0;
|
|
56
|
-
if (hasContent !== this.hasIconContent()) this.hasIconContent.set(hasContent);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render } from '@testing-library/angular';
|
|
4
|
-
import { ImgLoaderComponent } from './img-loader.component';
|
|
5
|
-
describe('ImgLoaderComponent', () => {
|
|
6
|
-
it('renderiza la imagen con el imgSrc dado', async () => {
|
|
7
|
-
@Component({ standalone: true, imports: [ImgLoaderComponent], template: `<ba-img-loader imgSrc="https://x/y.png" imgAlt="a" />` })
|
|
8
|
-
class Host {}
|
|
9
|
-
const { container } = await render(Host);
|
|
10
|
-
expect(container.querySelector('img')?.getAttribute('src')).toBe('https://x/y.png');
|
|
11
|
-
});
|
|
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
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, input, signal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
// El anillo giratorio de framer-motion
|
|
4
|
-
// (`motion.span` con animate={{rotate:360}} infinito) pasa a ser una
|
|
5
|
-
// animación CSS local. La <img> hace fade-in cuando termina de cargar
|
|
6
|
-
// (`(load)`) aplicando las clases `bas-fade-enter-active`/`bas-fade-enter-from`
|
|
7
|
-
// de transitions.css (equivalente al `<Transition name="bas-fade">` +
|
|
8
|
-
// `v-show` del port Vue): se mantiene siempre montada (para que el navegador
|
|
9
|
-
// pueda disparar `load`) y se alterna la clase `-enter-from` según `loaded()`.
|
|
10
|
-
type ImgLoaderSize = 'small' | 'medium' | 'large' | 'big';
|
|
11
|
-
|
|
12
|
-
const SIZES_CONTAINER: Record<ImgLoaderSize, string> = {
|
|
13
|
-
small: 'bas-h-[82px] bas-w-[82px]',
|
|
14
|
-
medium: 'bas-h-[90px] bas-w-[90px]',
|
|
15
|
-
large: 'bas-h-[120px] bas-w-[120px]',
|
|
16
|
-
big: 'bas-h-[200px] bas-w-[200px]',
|
|
17
|
-
};
|
|
18
|
-
const SIZES_ICON_CONTAINER: Record<ImgLoaderSize, string> = {
|
|
19
|
-
small: 'bas-h-[72px] bas-w-[72px]',
|
|
20
|
-
medium: 'bas-h-20 bas-w-20',
|
|
21
|
-
large: 'bas-h-[108px] bas-w-[108px]',
|
|
22
|
-
big: 'bas-h-[180px] bas-w-[180px]',
|
|
23
|
-
};
|
|
24
|
-
const SIZES_ICON: Record<ImgLoaderSize, string> = {
|
|
25
|
-
small: 'bas-h-16 bas-w-16',
|
|
26
|
-
medium: 'bas-h-[80px] bas-w-[80px]',
|
|
27
|
-
large: 'bas-h-[100px] bas-w-[100px]',
|
|
28
|
-
big: 'bas-h-[166px] bas-w-[166px]',
|
|
29
|
-
};
|
|
30
|
-
const MOTION_SIZES: Record<ImgLoaderSize, string> = {
|
|
31
|
-
small: 'bas-h-[112px] bas-w-[112px]',
|
|
32
|
-
medium: 'bas-h-[124px] bas-w-[124px]',
|
|
33
|
-
large: 'bas-h-[164px] bas-w-[164px]',
|
|
34
|
-
big: 'bas-h-[272px] bas-w-[272px]',
|
|
35
|
-
};
|
|
36
|
-
const MOTION_SPAN_SIZES: Record<ImgLoaderSize, string> = {
|
|
37
|
-
small: 'bas-border-[22px]',
|
|
38
|
-
medium: 'bas-border-[24px]',
|
|
39
|
-
large: 'bas-border-[28px]',
|
|
40
|
-
big: 'bas-border-[46px]',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
@Component({
|
|
44
|
-
selector: 'ba-img-loader',
|
|
45
|
-
standalone: true,
|
|
46
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
47
|
-
template: `
|
|
48
|
-
<div
|
|
49
|
-
[class]="
|
|
50
|
-
'bal-ba-img-loader bas-relative bas-flex ' +
|
|
51
|
-
SIZES_CONTAINER[size()] +
|
|
52
|
-
' bas-items-center bas-justify-center bas-overflow-hidden bas-rounded-lg'
|
|
53
|
-
"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
[class]="
|
|
57
|
-
'bal-ba-img-loader-icon bas-z-10 bas-flex ' +
|
|
58
|
-
SIZES_ICON_CONTAINER[size()] +
|
|
59
|
-
' bas-items-center bas-justify-center bas-rounded-md bas-bg-white'
|
|
60
|
-
"
|
|
61
|
-
>
|
|
62
|
-
<img
|
|
63
|
-
[src]="imgSrc()"
|
|
64
|
-
[alt]="imgAlt()"
|
|
65
|
-
[class]="
|
|
66
|
-
'bal-ba-transform-base bal-ba-transition-2 bas-rounded-md ' +
|
|
67
|
-
SIZES_ICON[size()] +
|
|
68
|
-
' ' +
|
|
69
|
-
(scaleImgWhenHovered() ? 'bal-ba-hover-scale-110' : '') +
|
|
70
|
-
' bas-fade-enter-active ' +
|
|
71
|
-
(loaded() ? '' : 'bas-fade-enter-from')
|
|
72
|
-
"
|
|
73
|
-
[style.background-color]="imgBgColor()"
|
|
74
|
-
(load)="loaded.set(true)"
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
@if (showLoaderRing()) {
|
|
78
|
-
<div [class]="'bas-absolute ' + MOTION_SIZES[size()]">
|
|
79
|
-
<span
|
|
80
|
-
[id]="loaderId()"
|
|
81
|
-
[class]="
|
|
82
|
-
'bas-img-loader-ring bas-left-0 bas-top-0 bas-box-border bas-block bas-h-full bas-w-full bas-rounded-full bas-border-solid bas-border-transparent ' +
|
|
83
|
-
MOTION_SPAN_SIZES[size()]
|
|
84
|
-
"
|
|
85
|
-
[style.border-top-color]="loaderColor()"
|
|
86
|
-
></span>
|
|
87
|
-
</div>
|
|
88
|
-
}
|
|
89
|
-
</div>
|
|
90
|
-
`,
|
|
91
|
-
styles: [
|
|
92
|
-
`
|
|
93
|
-
@keyframes bas-img-loader-spin {
|
|
94
|
-
to {
|
|
95
|
-
transform: rotate(360deg);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
.bas-img-loader-ring {
|
|
99
|
-
animation: bas-img-loader-spin 1.25s linear infinite;
|
|
100
|
-
}
|
|
101
|
-
`,
|
|
102
|
-
],
|
|
103
|
-
})
|
|
104
|
-
export class ImgLoaderComponent {
|
|
105
|
-
readonly SIZES_CONTAINER = SIZES_CONTAINER;
|
|
106
|
-
readonly SIZES_ICON_CONTAINER = SIZES_ICON_CONTAINER;
|
|
107
|
-
readonly SIZES_ICON = SIZES_ICON;
|
|
108
|
-
readonly MOTION_SIZES = MOTION_SIZES;
|
|
109
|
-
readonly MOTION_SPAN_SIZES = MOTION_SPAN_SIZES;
|
|
110
|
-
|
|
111
|
-
loaderId = input('img-fm-loader');
|
|
112
|
-
imgSrc = input('');
|
|
113
|
-
imgAlt = input('');
|
|
114
|
-
imgBgColor = input('');
|
|
115
|
-
loaderColor = input('');
|
|
116
|
-
scaleImgWhenHovered = input(false);
|
|
117
|
-
size = input<ImgLoaderSize>('small');
|
|
118
|
-
showLoaderRing = input(true);
|
|
119
|
-
|
|
120
|
-
loaded = signal(false);
|
|
121
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Barrel de las primitivas de UI de @block-auth.io/angular.
|
|
2
|
-
// Excluidas (fuera de scope, igual que en el port Vue): Switcher.
|
|
3
|
-
export { ArrowIconComponent } from './arrow-icon.component';
|
|
4
|
-
export { BtnArrowDirComponent } from './btn-arrow-dir.component';
|
|
5
|
-
export { BtnBaseComponent } from './btn-base.component';
|
|
6
|
-
export { DividerBaseComponent } from './divider-base.component';
|
|
7
|
-
export { DropdownArrowComponent } from './dropdown-arrow.component';
|
|
8
|
-
export { DropdownBaseComponent, type DropdownItem, defaultItems } from './dropdown-base.component';
|
|
9
|
-
export { HorizontalLoaderComponent } from './horizontal-loader.component';
|
|
10
|
-
export { IconBaseComponent } from './icon-base.component';
|
|
11
|
-
export { ImgLoaderComponent } from './img-loader.component';
|
|
12
|
-
export { InputBaseComponent } from './input-base.component';
|
|
13
|
-
export { LifetimeSliderBaseComponent } from './lifetime-slider-base.component';
|
|
14
|
-
export { OvalSpinnerComponent } from './oval-spinner.component';
|
|
15
|
-
export { ProgressbarComponent } from './progressbar.component';
|
|
16
|
-
export { SliderBaseComponent } from './slider-base.component';
|
|
17
|
-
|
|
18
|
-
// pickers/* — port de packages/react/src/primitives/pickers.
|
|
19
|
-
export { DropdownPickerAnimatedBaseComponent } from './pickers/dropdown-picker-animated-base.component';
|
|
20
|
-
export { PickerButtonComponent } from './pickers/picker-button.component';
|
|
21
|
-
export { TimePickerComponent } from './pickers/time-picker.component';
|
|
22
|
-
export {
|
|
23
|
-
TimePickerDropdownSelectorComponent,
|
|
24
|
-
type TimeArrays,
|
|
25
|
-
} from './pickers/time-picker-dropdown-selector.component';
|
|
26
|
-
export { TimeUnitSelectorComponent } from './pickers/time-unit-selector.component';
|
|
27
|
-
|
|
28
|
-
export { providersStyles, type ProviderStyle } from './providersStyles';
|
|
29
|
-
export * from './helpers';
|
|
@@ -1,20 +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 { InputBaseComponent } from './input-base.component';
|
|
5
|
-
describe('InputBaseComponent', () => {
|
|
6
|
-
it('renderiza el label', async () => {
|
|
7
|
-
@Component({ standalone: true, imports: [InputBaseComponent], template: `<ba-input-base labelText="Correo" inputId="e" />` })
|
|
8
|
-
class Host {}
|
|
9
|
-
await render(Host);
|
|
10
|
-
expect(screen.getByText('Correo')).toBeTruthy();
|
|
11
|
-
});
|
|
12
|
-
it('emite changedInputValue en input cuando isInputValueManaged', async () => {
|
|
13
|
-
const onChange = vi.fn();
|
|
14
|
-
@Component({ standalone: true, imports: [InputBaseComponent], template: `<ba-input-base [isInputValueManaged]="true" inputTestId="in" (changedInputValue)="f($event)" />` })
|
|
15
|
-
class Host { f = onChange; }
|
|
16
|
-
await render(Host);
|
|
17
|
-
await fireEvent.input(screen.getByTestId('in'), { target: { value: 'hola' } });
|
|
18
|
-
expect(onChange).toHaveBeenCalledWith('hola');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
// `register` (react-hook-form) no tiene
|
|
4
|
-
// equivalente y se elimina; `onChangedInputValue` -> emit `changedInputValue`.
|
|
5
|
-
// `min`/`max`/`step` se dejan sin default (undefined) para no introducir un
|
|
6
|
-
// clamp que react nunca tuvo por defecto (misma decisión que InputBase.vue).
|
|
7
|
-
type InputSize = 'xxs' | 'xs' | 'small' | 'base' | 'medium';
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'ba-input-base',
|
|
11
|
-
standalone: true,
|
|
12
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
13
|
-
template: `
|
|
14
|
-
<div
|
|
15
|
-
[class]="
|
|
16
|
-
(enableError() ? displayClassNames() + ' ' + widthClassNames() + ' bas-items-center bas-gap-1.5' : '') +
|
|
17
|
-
' ' + outerHeightGrid() + ' ' + className()
|
|
18
|
-
"
|
|
19
|
-
>
|
|
20
|
-
@if ((enableError() || info()) && enableWhiteSpaces()) {
|
|
21
|
-
<p class="bal-ba-error-text-invisible bas-m-0 bas-h-[18px]">white space</p>
|
|
22
|
-
}
|
|
23
|
-
<div [class]="'bas-relative bas-min-w-0 ' + innerHeightGrid()">
|
|
24
|
-
@if (isTextArea()) {
|
|
25
|
-
<textarea
|
|
26
|
-
[id]="inputId()"
|
|
27
|
-
[class]="inputClassNames()"
|
|
28
|
-
placeholder=""
|
|
29
|
-
[disabled]="isDisabled()"
|
|
30
|
-
[readonly]="isReadOnly()"
|
|
31
|
-
autocomplete="off"
|
|
32
|
-
[value]="isInputValueManaged() ? inputValue() : ''"
|
|
33
|
-
(input)="isInputValueManaged() && onInput($event)"
|
|
34
|
-
></textarea>
|
|
35
|
-
} @else {
|
|
36
|
-
<input
|
|
37
|
-
[type]="type()"
|
|
38
|
-
[id]="inputId()"
|
|
39
|
-
[attr.data-testid]="inputTestId()"
|
|
40
|
-
[class]="inputClassNames()"
|
|
41
|
-
placeholder=""
|
|
42
|
-
[disabled]="isDisabled()"
|
|
43
|
-
[readonly]="isReadOnly()"
|
|
44
|
-
autocomplete="off"
|
|
45
|
-
[attr.min]="min()"
|
|
46
|
-
[attr.max]="max()"
|
|
47
|
-
[attr.step]="step()"
|
|
48
|
-
[value]="isInputValueManaged() ? inputValue() : ''"
|
|
49
|
-
(input)="isInputValueManaged() && onInput($event)"
|
|
50
|
-
/>
|
|
51
|
-
}
|
|
52
|
-
<label [for]="inputId()" [class]="floatingLabelClassNames()">
|
|
53
|
-
<p [class]="'bas-m-0 ' + (isDisabled() ? 'bas-cursor-not-allowed' : 'bas-cursor-text')">
|
|
54
|
-
{{ labelText() }}
|
|
55
|
-
</p>
|
|
56
|
-
</label>
|
|
57
|
-
</div>
|
|
58
|
-
@if (enableError() || info()) {
|
|
59
|
-
<p
|
|
60
|
-
[class]="
|
|
61
|
-
'bas-m-0 bas-h-[18px] ' +
|
|
62
|
-
(error() || info() ? 'bal-ba-error-text' : 'bal-ba-error-text-invisible') + ' ' +
|
|
63
|
-
(info() ? (blueStyles() ? 'bal-ba-info-text-blue-styles' : 'bal-ba-info-text') : '')
|
|
64
|
-
"
|
|
65
|
-
>
|
|
66
|
-
{{ error() ? errorMessage() : '' }}{{ info() ? infoMessage() : '' }}
|
|
67
|
-
</p>
|
|
68
|
-
}
|
|
69
|
-
</div>
|
|
70
|
-
`,
|
|
71
|
-
})
|
|
72
|
-
export class InputBaseComponent {
|
|
73
|
-
type = input('text');
|
|
74
|
-
inputId = input('floating_outlined');
|
|
75
|
-
isTextArea = input(false);
|
|
76
|
-
labelText = input('Floating outlined');
|
|
77
|
-
size = input<InputSize>('base');
|
|
78
|
-
isDisabled = input(false);
|
|
79
|
-
isReadOnly = input(false);
|
|
80
|
-
enableError = input(true);
|
|
81
|
-
enableWhiteSpaces = input(true);
|
|
82
|
-
error = input(false);
|
|
83
|
-
errorMessage = input('Error message');
|
|
84
|
-
info = input(false);
|
|
85
|
-
infoMessage = input('Info message');
|
|
86
|
-
isBgRedWhenError = input(false);
|
|
87
|
-
bgColor = input('bas-bg-transparent');
|
|
88
|
-
bgColorWhenError = input('bas-bg-red-50');
|
|
89
|
-
isInputValueManaged = input(false);
|
|
90
|
-
inputValue = input('');
|
|
91
|
-
floatingLabelTextStyles = input('bas-text-sm');
|
|
92
|
-
floatingLabelBgColor = input('bas-bg-white');
|
|
93
|
-
borderRadiusClassNames = input('bas-rounded-lg');
|
|
94
|
-
displayClassNames = input('bas-grid');
|
|
95
|
-
className = input('');
|
|
96
|
-
widthClassNames = input('bas-w-full');
|
|
97
|
-
blueStyles = input(false);
|
|
98
|
-
min = input<number | undefined>(undefined);
|
|
99
|
-
max = input<number | undefined>(undefined);
|
|
100
|
-
step = input<number | undefined>(undefined);
|
|
101
|
-
inputTestId = input<string | undefined>(undefined);
|
|
102
|
-
|
|
103
|
-
/** Equivalente al emit `changedInputValue` de InputBase.vue. */
|
|
104
|
-
changedInputValue = output<string>();
|
|
105
|
-
|
|
106
|
-
onInput(e: Event): void {
|
|
107
|
-
this.changedInputValue.emit((e.target as HTMLInputElement | HTMLTextAreaElement).value);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private heightGrid(enableError: boolean, enableWhiteSpaces: boolean): string {
|
|
111
|
-
if (!this.isTextArea()) {
|
|
112
|
-
return {
|
|
113
|
-
xxs: enableError
|
|
114
|
-
? enableWhiteSpaces ? 'bas-h-[82px] bas-grid-rows-[18px_34px_18px]' : 'bas-h-[58px] bas-grid-rows-[34px_18px]'
|
|
115
|
-
: 'bas-h-[34px]',
|
|
116
|
-
xs: enableError
|
|
117
|
-
? enableWhiteSpaces ? 'bas-h-[86px] bas-grid-rows-[18px_38px_18px]' : 'bas-h-[62px] bas-grid-rows-[38px_18px]'
|
|
118
|
-
: 'bas-h-[38px]',
|
|
119
|
-
small: enableError
|
|
120
|
-
? enableWhiteSpaces ? 'bas-h-[90px] bas-grid-rows-[18px_42px_18px]' : 'bas-h-[66px] bas-grid-rows-[42px_18px]'
|
|
121
|
-
: 'bas-h-[42px]',
|
|
122
|
-
base: enableError
|
|
123
|
-
? enableWhiteSpaces ? 'bas-h-[94px] bas-grid-rows-[18px_46px_18px]' : 'bas-h-[70px] bas-grid-rows-[46px_18px]'
|
|
124
|
-
: 'bas-h-[46px]',
|
|
125
|
-
medium: enableError
|
|
126
|
-
? enableWhiteSpaces ? 'bas-h-[102px] bas-grid-rows-[18px_54px_18px]' : 'bas-h-[78px] bas-grid-rows-[54px_18px]'
|
|
127
|
-
: 'bas-h-[54px]',
|
|
128
|
-
}[this.size()];
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
xxs: enableError
|
|
132
|
-
? enableWhiteSpaces ? 'bas-h-[96px] bas-grid-rows-[18px_48px_18px]' : 'bas-h-[72px] bas-grid-rows-[48px_18px]'
|
|
133
|
-
: 'bas-h-[48px]',
|
|
134
|
-
xs: enableError
|
|
135
|
-
? enableWhiteSpaces ? 'bas-h-[112px] bas-grid-rows-[18px_64px_18px]' : 'bas-h-[88px] bas-grid-rows-[64px_18px]'
|
|
136
|
-
: 'bas-h-[64px]',
|
|
137
|
-
small: enableError
|
|
138
|
-
? enableWhiteSpaces ? 'bas-h-[128px] bas-grid-rows-[18px_80px_18px]' : 'bas-h-[104px] bas-grid-rows-[80px_18px]'
|
|
139
|
-
: 'bas-h-[80px]',
|
|
140
|
-
base: enableError
|
|
141
|
-
? enableWhiteSpaces ? 'bas-h-[144px] bas-grid-rows-[18px_96px_18px]' : 'bas-h-[120px] bas-grid-rows-[96px_18px]'
|
|
142
|
-
: 'bas-h-[96px]',
|
|
143
|
-
medium: enableError
|
|
144
|
-
? enableWhiteSpaces ? 'bas-h-[160px] bas-grid-rows-[18px_112px_18px]' : 'bas-h-[136px] bas-grid-rows-[112px_18px]'
|
|
145
|
-
: 'bas-h-[112px]',
|
|
146
|
-
}[this.size()];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
outerHeightGrid = computed(() => this.heightGrid(this.enableError(), this.enableWhiteSpaces()));
|
|
150
|
-
innerHeightGrid = computed(() => this.heightGrid(false, false));
|
|
151
|
-
|
|
152
|
-
private inputHeightClassNames = computed(() => {
|
|
153
|
-
if (!this.isTextArea()) {
|
|
154
|
-
return {
|
|
155
|
-
xxs: 'bas-h-[34px] bas-pb-0.5 bas-pt-1.5',
|
|
156
|
-
xs: 'bas-h-[38px] bas-pb-0.5 bas-pt-2',
|
|
157
|
-
small: 'bas-h-[42px] bas-pb-1 bas-pt-2.5',
|
|
158
|
-
base: 'bas-h-[46px] bas-pb-1.5 bas-pt-3',
|
|
159
|
-
medium: 'bas-h-[54px] bas-pb-2.5 bas-pt-4',
|
|
160
|
-
}[this.size()];
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
xxs: 'bas-h-[48px] bas-pb-0.5 bas-pt-1.5',
|
|
164
|
-
xs: 'bas-h-[64px] bas-pb-0.5 bas-pt-2',
|
|
165
|
-
small: 'bas-h-[80px] bas-pb-1 bas-pt-2.5',
|
|
166
|
-
base: 'bas-h-[96px] bas-pb-1.5 bas-pt-3',
|
|
167
|
-
medium: 'bas-h-[112px] bas-pb-2.5 bas-pt-4',
|
|
168
|
-
}[this.size()];
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
inputClassNames = computed(
|
|
172
|
-
() => `bal-ba-floating-input-base bal-ba-floating-input-outlined
|
|
173
|
-
bas-peer bas-box-border bas-block bas-w-full bas-appearance-none bas-border-2
|
|
174
|
-
bal-ba-transition-150 bas-border-solid bas-px-2.5 bas-text-sm bal-ba-outline-none
|
|
175
|
-
bal-ba-shadow-base bal-ba-focus-shadow-none disabled:bas-cursor-not-allowed
|
|
176
|
-
disabled:bas-border-gray-200 disabled:bas-text-gray-500
|
|
177
|
-
${this.size() !== 'xxs' ? 'xsm1:bas-text-base' : ''} ${this.isTextArea() ? 'bal-ba-scroll-base bas-resize-none' : ''}
|
|
178
|
-
${this.borderRadiusClassNames()} ${this.inputHeightClassNames()} ${
|
|
179
|
-
!this.error()
|
|
180
|
-
? `focus:bas-border-[var(--bal-primary-100)] focus:hover:bas-border-[var(--bal-primary-300)] ${
|
|
181
|
-
this.blueStyles()
|
|
182
|
-
? 'bas-text-[#004e98] hover:bas-text-[#00296b] bas-border-[var(--bal-primary-100)] hover:bas-border-[var(--bal-primary-300)]'
|
|
183
|
-
: `bas-text-gray-800 hover:bas-text-gray-900 bas-border-gray-300 hover:bas-border-gray-400
|
|
184
|
-
focus:bas-text-[#004e98] focus:hover:bas-text-[#00296b]`
|
|
185
|
-
}`
|
|
186
|
-
: 'bas-border-red-500 bas-text-red-500 focus:bas-border-red-600'
|
|
187
|
-
} ${this.isBgRedWhenError() && this.error() ? this.bgColorWhenError() : this.bgColor()}`,
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
floatingLabelClassNames = computed(
|
|
191
|
-
() => `bal-ba-floating-label-base bal-ba-floating-label-outlined
|
|
192
|
-
bal-ba-transform-base bal-ba-transition-2 bas-absolute
|
|
193
|
-
bas-start-1 bas-z-10 bas-origin-[0] bas-cursor-text bas-px-2
|
|
194
|
-
peer-placeholder-shown:bas-top-1/2 peer-focus:bas-px-2
|
|
195
|
-
rtl:peer-focus:bas-left-auto ${
|
|
196
|
-
this.size() === 'small'
|
|
197
|
-
? 'bal-ba-floating-label-small-outlined bas-top-1 peer-focus:bas-top-1'
|
|
198
|
-
: 'bal-ba-floating-label-base-medium-outlined bas-top-2 peer-focus:bas-top-2'
|
|
199
|
-
} ${
|
|
200
|
-
this.isDisabled()
|
|
201
|
-
? 'bas-cursor-not-allowed bas-text-gray-400'
|
|
202
|
-
: !this.error()
|
|
203
|
-
? this.blueStyles()
|
|
204
|
-
? 'bas-text-[#004e98] peer-hover:bas-text-[#00296b]'
|
|
205
|
-
: `bas-text-gray-500 peer-hover:bas-text-gray-600
|
|
206
|
-
peer-focus:bas-text-[#004e98] peer-focus:hover:bas-text-[#00296b]`
|
|
207
|
-
: 'bas-text-red-500 peer-focus:bas-text-red-500'
|
|
208
|
-
} ${this.isBgRedWhenError() && this.error() ? this.bgColorWhenError() : this.floatingLabelBgColor()} ${this.floatingLabelTextStyles()}`,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/angular';
|
|
4
|
-
import { LifetimeSliderBaseComponent } from './lifetime-slider-base.component';
|
|
5
|
-
|
|
6
|
-
// Espejo de packages/vue/src/primitives/LifetimeSliderBase.test.ts. Cubre el
|
|
7
|
-
// árbol completo del port (LifetimeSliderBase -> TimePicker ->
|
|
8
|
-
// DropdownPickerAnimatedBase + TimePickerDropdownSelector + TimeUnitSelector +
|
|
9
|
-
// SliderBase), en particular la reconciliación de rangos y el commit en
|
|
10
|
-
// segundos de TimePickerDropdownSelector, que es la parte con más estado.
|
|
11
|
-
describe('LifetimeSliderBaseComponent', () => {
|
|
12
|
-
const TEMPLATE = `
|
|
13
|
-
<ba-lifetime-slider-base
|
|
14
|
-
id="lt"
|
|
15
|
-
[sliderValue]="sliderValue"
|
|
16
|
-
[min]="10"
|
|
17
|
-
[max]="29100"
|
|
18
|
-
[timeInputValue]="timeInputValue"
|
|
19
|
-
[isOpen]="isOpen"
|
|
20
|
-
(sliderValueChanged)="onSlider($event)"
|
|
21
|
-
(timeChanged)="onTime($event)"
|
|
22
|
-
(toggleTimerDropdown)="onToggle()"
|
|
23
|
-
/>
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
function makeHost(overrides: Partial<Record<string, unknown>> = {}) {
|
|
27
|
-
@Component({ standalone: true, imports: [LifetimeSliderBaseComponent], template: TEMPLATE })
|
|
28
|
-
class Host {
|
|
29
|
-
sliderValue = 3600;
|
|
30
|
-
timeInputValue = '01:00:00';
|
|
31
|
-
isOpen = false;
|
|
32
|
-
onSlider = vi.fn();
|
|
33
|
-
onTime = vi.fn();
|
|
34
|
-
onToggle = vi.fn();
|
|
35
|
-
constructor() {
|
|
36
|
-
Object.assign(this, overrides);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return Host;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
it('renderiza el slider (SliderBase) y el input del TimePicker con el valor HH:MM:SS', async () => {
|
|
43
|
-
const { container } = await render(makeHost());
|
|
44
|
-
const slider = container.querySelector('#lt-slider') as HTMLInputElement;
|
|
45
|
-
expect(slider).not.toBeNull();
|
|
46
|
-
expect(slider.type).toBe('range');
|
|
47
|
-
expect(slider.value).toBe('3600');
|
|
48
|
-
const timeInput = container.querySelector('#lt-time-picker-time-input') as HTMLInputElement;
|
|
49
|
-
expect(timeInput.value).toBe('01:00:00');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('emite toggleTimerDropdown al pulsar el botón del picker', async () => {
|
|
53
|
-
const onToggle = vi.fn();
|
|
54
|
-
const { container } = await render(makeHost({ onToggle }));
|
|
55
|
-
await fireEvent.click(container.querySelector('#lt-time-picker-btn') as HTMLButtonElement);
|
|
56
|
-
expect(onToggle).toHaveBeenCalledOnce();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('abierto: muestra las 3 columnas del picker (horas/minutos/segundos) y el botón Save', async () => {
|
|
60
|
-
const { container } = await render(makeHost({ isOpen: true }));
|
|
61
|
-
expect(container.querySelector('#lt-time-picker-hours-selector-container')).not.toBeNull();
|
|
62
|
-
expect(container.querySelector('#lt-time-picker-minutes-selector-container')).not.toBeNull();
|
|
63
|
-
expect(container.querySelector('#lt-time-picker-seconds-selector-container')).not.toBeNull();
|
|
64
|
-
expect(container.querySelector('#lt-time-picker-btn-save')).not.toBeNull();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('elegir una hora y guardar emite timeChanged en segundos', async () => {
|
|
68
|
-
const onTime = vi.fn();
|
|
69
|
-
const onToggle = vi.fn();
|
|
70
|
-
const { container } = await render(makeHost({ isOpen: true, onTime, onToggle }));
|
|
71
|
-
// Selecciona 02 horas (id `${id}-time-picker-hours-02`).
|
|
72
|
-
await fireEvent.click(container.querySelector('#lt-time-picker-hours-02') as HTMLElement);
|
|
73
|
-
const save = container.querySelector('#lt-time-picker-btn-save') as HTMLButtonElement;
|
|
74
|
-
expect(save.disabled).toBe(false); // cambió respecto del valor inicial
|
|
75
|
-
await fireEvent.click(save);
|
|
76
|
-
// 02:00:00 -> 7200s.
|
|
77
|
-
expect(onTime).toHaveBeenCalledWith(7200);
|
|
78
|
-
expect(onToggle).toHaveBeenCalledOnce();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('mover el slider emite sliderValueChanged en segundos', async () => {
|
|
82
|
-
const onSlider = vi.fn();
|
|
83
|
-
const { container } = await render(makeHost({ onSlider }));
|
|
84
|
-
const slider = container.querySelector('#lt-slider') as HTMLInputElement;
|
|
85
|
-
await fireEvent.input(slider, { target: { value: '7200' } });
|
|
86
|
-
expect(onSlider).toHaveBeenCalledWith(7200);
|
|
87
|
-
});
|
|
88
|
-
});
|