@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,12 +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 { DividerBaseComponent } from './divider-base.component';
5
- describe('DividerBaseComponent', () => {
6
- it('proyecta el contenido central cuando lo hay', async () => {
7
- @Component({ standalone: true, imports: [DividerBaseComponent], template: `<ba-divider-base><span data-testid="mid">or</span></ba-divider-base>` })
8
- class Host {}
9
- await render(Host);
10
- expect(screen.getByTestId('mid')).toBeTruthy();
11
- });
12
- });
@@ -1,74 +0,0 @@
1
- import {
2
- AfterViewChecked,
3
- ChangeDetectionStrategy,
4
- Component,
5
- ElementRef,
6
- input,
7
- signal,
8
- viewChild,
9
- } from '@angular/core';
10
-
11
- // `children` (ReactNode / slot por
12
- // defecto) pasa a ser `<ng-content />`; la presencia de contenido proyectado
13
- // se detecta igual que en IconBaseComponent (ver comentario allí).
14
- @Component({
15
- selector: 'ba-divider-base',
16
- standalone: true,
17
- changeDetection: ChangeDetectionStrategy.OnPush,
18
- template: `
19
- <div
20
- [class]="
21
- 'bas-group bas-relative bas-box-border bas-grid bas-w-full bas-items-center ' +
22
- classNames() +
23
- ' ' +
24
- zIndex() +
25
- ' ' +
26
- (hasChildren() ? 'bas-grid-cols-[1fr_auto_1fr]' : 'bas-grid-cols-[1fr_1fr]')
27
- "
28
- >
29
- <span
30
- [class]="
31
- 'bas-border-solid bas-w-full bas-border-x-0 bas-border-b-0 ' +
32
- borderSizeClassName() +
33
- ' ' +
34
- (dividerBorderColorClassNames() || 'bas-border-gray-300')
35
- "
36
- ></span>
37
- <span
38
- #childrenSlot
39
- [style.display]="hasChildren() ? 'contents' : 'none'"
40
- [class]="'bas-group ' + childrenContainerClassNames()"
41
- >
42
- <ng-content />
43
- </span>
44
- <span
45
- [class]="
46
- 'bas-border-solid bas-w-full bas-border-x-0 bas-border-b-0 ' +
47
- borderSizeClassName() +
48
- ' ' +
49
- (dividerBorderColorClassNames() || 'bas-border-gray-300')
50
- "
51
- ></span>
52
- </div>
53
- `,
54
- })
55
- export class DividerBaseComponent implements AfterViewChecked {
56
- classNames = input('');
57
- dividerBorderColorClassNames = input<string | undefined>(undefined);
58
- borderSizeClassName = input('bas-border-t');
59
- childrenContainerClassNames = input(`bas-flex bas-flex-row bas-items-center bas-text-sm
60
- bas-justify-center bas-gap-1 bas-bg-transparent bas-px-2 bas-text-gray-500`);
61
- zIndex = input('bas-z-50');
62
-
63
- // Signal query (no `@ViewChild` — los decoradores de campo clásicos no se
64
- // soportan en el modo JIT del harness de test AnalogJS/Vitest).
65
- private readonly childrenSlot = viewChild<ElementRef<HTMLElement>>('childrenSlot');
66
-
67
- hasChildren = signal(false);
68
-
69
- ngAfterViewChecked(): void {
70
- const el = this.childrenSlot()?.nativeElement ?? null;
71
- const has = !!el && el.childNodes.length > 0;
72
- if (has !== this.hasChildren()) this.hasChildren.set(has);
73
- }
74
- }
@@ -1,12 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { Component } from '@angular/core';
3
- import { render } from '@testing-library/angular';
4
- import { DropdownArrowComponent } from './dropdown-arrow.component';
5
- describe('DropdownArrowComponent', () => {
6
- it('aplica la clase abierta cuando isOpen', async () => {
7
- @Component({ standalone: true, imports: [DropdownArrowComponent], template: `<ba-dropdown-arrow [isOpen]="true" />` })
8
- class Host {}
9
- const { container } = await render(Host);
10
- expect(container.querySelector('.bas-dropdown-arrow-open')).toBeTruthy();
11
- });
12
- });
@@ -1,46 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
2
-
3
- // La rotación animada de
4
- // framer-motion (variants open/closed) pasa a `transition: transform` en los
5
- // `styles` del componente con la clase `bas-dropdown-arrow-open` condicional.
6
- @Component({
7
- selector: 'ba-dropdown-arrow',
8
- standalone: true,
9
- changeDetection: ChangeDetectionStrategy.OnPush,
10
- template: `
11
- <span
12
- [id]="id()"
13
- class="bas-dropdown-arrow bas-flex bas-h-full bas-w-full bas-items-center bas-justify-center"
14
- [class.bas-dropdown-arrow-open]="isOpen()"
15
- (click)="clicked.emit()"
16
- >
17
- <svg
18
- [class]="(disabled() ? 'bas-cursor-not-allowed' : 'bas-cursor-pointer') + ' ' + sizeClassNames()"
19
- viewBox="0 0 20 20"
20
- >
21
- <path d="M0 7 L 20 7 L 10 16" [attr.fill]="color()" />
22
- </svg>
23
- </span>
24
- `,
25
- styles: [
26
- `
27
- .bas-dropdown-arrow {
28
- transform: rotate(0deg);
29
- transition: transform 0.25s ease;
30
- }
31
- .bas-dropdown-arrow-open {
32
- transform: rotate(180deg);
33
- }
34
- `,
35
- ],
36
- })
37
- export class DropdownArrowComponent {
38
- id = input('animated-dropdown-id');
39
- isOpen = input(false);
40
- sizeClassNames = input('bas-h-4 bas-w-4');
41
- color = input('var(--bal-primary-700)');
42
- disabled = input(false);
43
-
44
- /** Equivalente al emit `click` de DropdownArrow.vue. */
45
- clicked = output<void>();
46
- }
@@ -1,49 +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 { DropdownBaseComponent } from './dropdown-base.component';
5
-
6
- describe('DropdownBaseComponent', () => {
7
- it('al pulsar el boton emite isOpenChange con el valor invertido', async () => {
8
- const onOpen = vi.fn();
9
- @Component({ standalone: true, imports: [DropdownBaseComponent], template: `<ba-dropdown-base [isOpen]="false" (isOpenChange)="f($event)" />` })
10
- class Host { f = onOpen; }
11
- await render(Host);
12
- await fireEvent.click(screen.getByRole('button'));
13
- expect(onOpen).toHaveBeenCalledWith(true);
14
- });
15
- it('con isOpen muestra la lista y al elegir un item emite changeSelectedItem', async () => {
16
- const onSel = vi.fn();
17
- @Component({ standalone: true, imports: [DropdownBaseComponent], template: `<ba-dropdown-base [isOpen]="true" (changeSelectedItem)="f($event)" />` })
18
- class Host { f = onSel; }
19
- await render(Host);
20
- await fireEvent.click(screen.getByText('Block-Auth'));
21
- expect(onSel).toHaveBeenCalled();
22
- expect(onSel.mock.calls[0][0]).toMatchObject({ value: 'blockauth' });
23
- });
24
- });
25
-
26
- // Click-outside con container (semantica portada de DropdownBase.tsx).
27
- describe('DropdownBaseComponent — click-outside', () => {
28
- it('sin container ningun click emite clickOutside', async () => {
29
- const onOut = vi.fn();
30
- @Component({ standalone: true, imports: [DropdownBaseComponent], template: `<ba-dropdown-base [isOpen]="true" (clickOutside)="f()" />` })
31
- class Host { f = onOut; }
32
- await render(Host);
33
- await fireEvent.click(document.body);
34
- expect(onOut).not.toHaveBeenCalled();
35
- });
36
- it('click dentro de container pero fuera del dropdown emite clickOutside', async () => {
37
- const onOut = vi.fn();
38
- const outer = document.createElement('div');
39
- document.body.appendChild(outer);
40
- const sibling = document.createElement('div');
41
- outer.appendChild(sibling);
42
- @Component({ standalone: true, imports: [DropdownBaseComponent], template: `<ba-dropdown-base [isOpen]="true" [container]="c" (clickOutside)="f()" />` })
43
- class Host { c = outer; f = onOut; }
44
- await render(Host);
45
- await fireEvent.click(sibling);
46
- expect(onOut).toHaveBeenCalled();
47
- document.body.removeChild(outer);
48
- });
49
- });
@@ -1,329 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- ElementRef,
5
- PLATFORM_ID,
6
- computed,
7
- effect,
8
- inject,
9
- input,
10
- output,
11
- viewChild,
12
- } from '@angular/core';
13
- import { isPlatformBrowser } from '@angular/common';
14
- import { DropdownArrowComponent } from './dropdown-arrow.component';
15
- import { CheckIconComponent } from '../icons';
16
-
17
- export interface DropdownItem {
18
- name: string;
19
- value: string;
20
- icon_url?: string;
21
- isOptionSelected?: boolean;
22
- [key: string]: unknown;
23
- }
24
-
25
- export const defaultItems: DropdownItem[] = [
26
- { name: 'Select', value: 'service_default', icon_url: 'https://picsum.photos/200/300', isOptionSelected: true },
27
- { name: 'Block-Auth', value: 'blockauth', icon_url: 'https://dashboard.block-auth.io/img/blockauth_logo.png', isOptionSelected: false },
28
- { name: 'Auditech', value: 'auditech', icon_url: 'https://auditech.es/wp-content/uploads/2020/05/Auditech-Iso-Mobile.png', isOptionSelected: false },
29
- { name: 'Microsoft', value: 'microsoft', icon_url: 'https://avatars.githubusercontent.com/u/6154722?s=200&v=4', isOptionSelected: false },
30
- ];
31
-
32
- // - `setIsOpen` (callback) -> emit `isOpenChange` (dos-vías idiomática Angular).
33
- // - `onChangeSelectedItem` -> emit `changeSelectedItem`.
34
- // - `callbackWhenClickOutside` -> emit `clickOutside`.
35
- // - `containerWithActiveClickOutsideRef` (React ref) -> input `container?: HTMLElement | null`.
36
- // Semántica 1:1 de DropdownBase.tsx (187-214): sin `container` no se añade
37
- // listener (click-outside desactivado); con `container` el listener va sobre
38
- // `container` (no `document`) solo cuando `isOpen`; "fuera" se calcula vs el
39
- // contenedor propio del dropdown; al cerrar (o destruir) se quita, EXCEPTO si
40
- // `isInsideModal` (leak deliberado del original). Se replica con `effect()`
41
- // sobre `isOpen()` (equivalente al useEffect(...,[isOpen]) de react).
42
- // - SSR: la lógica de click-outside solo corre en navegador (isPlatformBrowser).
43
- // - Animación open/close: `bas-pop` (transitions.css). El CheckIcon del item
44
- // seleccionado usa el icono compartido `ba-check-icon` (heroicons
45
- // CheckIcon 20/solid, Task A6).
46
- @Component({
47
- selector: 'ba-dropdown-base',
48
- standalone: true,
49
- changeDetection: ChangeDetectionStrategy.OnPush,
50
- imports: [DropdownArrowComponent, CheckIconComponent],
51
- template: `
52
- <div
53
- [class]="
54
- 'bas-box-border bas-group bas-relative bas-items-center ' + displayClassNames() + ' ' + classNames() + ' ' +
55
- getHeight(showTitle(), size()) + ' ' + (showTitle() ? containerGridRows() : '')
56
- "
57
- [style.width]="width()"
58
- [style.minWidth]="minWidth()"
59
- [style.maxWidth]="maxWidth()"
60
- >
61
- @if (showTitle()) {
62
- <p
63
- [class]="
64
- 'bal-ba-transition-2 bas-m-0 bas-h-[18px] bas-text-sm ' +
65
- (blueStyles()
66
- ? 'bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]'
67
- : 'bas-text-gray-700 group-hover:bas-text-gray-900')
68
- "
69
- >{{ title() }}</p>
70
- }
71
- @if (showFloatingLabel()) {
72
- <span
73
- [class]="
74
- 'bal-ba-transition-2 bas-group bas-absolute -bas-top-3 bas-left-2 bas-z-50 bas-flex bas-items-center bas-justify-center bas-px-1 bas-py-0.5 ' +
75
- floatingLabelBgColor() + ' ' +
76
- (blueStyles()
77
- ? 'bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]'
78
- : 'bas-text-gray-700 group-hover:bas-text-gray-900')
79
- "
80
- >
81
- <p [class]="'bal-ba-transition-2 bas-m-0 ' + (size() !== 'xxs' ? 'bas-text-xs' : 'bas-text-xxs')">
82
- {{ floatingLabelTxt() }}
83
- </p>
84
- </span>
85
- }
86
- <div #ddBaseContainer [class]="'bas-flex bas-w-full bas-flex-col bas-items-center bas-justify-start ' + getHeight(false, size())">
87
- <button
88
- [id]="btnId()"
89
- [disabled]="disabled()"
90
- [class]="
91
- 'bal-ba-transition-2 bal-ba-outline-none bas-relative bas-box-border bas-flex bas-w-full bas-cursor-pointer bas-flex-row bas-justify-between bas-gap-2 bas-border-2 bas-border-solid bas-bg-transparent bas-px-2 disabled:bas-cursor-not-allowed ' +
92
- getBtnHeight(size()) + ' ' + borderRadiusClassNames() + ' ' +
93
- (blueStyles() || isOpen()
94
- ? 'bas-border-[var(--bal-primary-100)] group-hover:bas-border-[var(--bal-primary-300)]'
95
- : 'bas-border-gray-300 group-hover:bas-border-gray-400')
96
- "
97
- (click)="onBtnClicked($event)"
98
- >
99
- <div class="bas-group bas-flex bas-h-full bas-w-full bas-flex-row bas-items-center bas-gap-1.5">
100
- @if (showStatusIndicator()) {
101
- <span [class]="'bas-h-2 bas-w-2 bas-rounded-full ' + (!isSelectedDefault() ? 'bas-bg-green-500' : 'bas-bg-sky-300')"></span>
102
- }
103
- @if (showImg() && selectedItem().icon_url) {
104
- <img [src]="selectedItem().icon_url" [alt]="'Image of ' + selectedItem()[titleKeyName()]" class="bas-h-5 bas-w-5 bas-flex-shrink-0" />
105
- }
106
- <p
107
- [class]="
108
- 'bal-ba-transition-2 bas-m-0 ' + (size() !== 'xxs' ? 'bas-text-base' : 'bas-text-sm') + ' ' +
109
- (isOpen() || blueStyles()
110
- ? (!isSelectedDefault()
111
- ? 'bas-text-[var(--bal-primary-800)] group-hover:bas-text-[var(--bal-primary-900)]'
112
- : 'bas-text-[var(--bal-primary-500)] group-hover:bas-text-[var(--bal-primary-600)]')
113
- : (!isSelectedDefault()
114
- ? 'bas-text-gray-800 group-hover:bas-text-gray-900'
115
- : 'bas-text-gray-500 group-hover:bas-text-gray-600'))
116
- "
117
- >{{ selectedItem()[titleKeyName()] }}</p>
118
- </div>
119
- <div class="bas-h-full bas-w-fit bas-justify-center">
120
- <ba-dropdown-arrow
121
- id="web-type-arrow"
122
- [isOpen]="isOpen()"
123
- sizeClassNames="bas-h-3 bas-w-3"
124
- [color]="blueStyles() || isOpen() ? 'var(--bal-primary-700)' : 'gray'"
125
- />
126
- </div>
127
- </button>
128
- @if (isOpen()) {
129
- <div
130
- class="ba-pop bal-ba-transition-2 bal-ba-shadow-base bal-ba-hover-shadow-md bas-absolute bas-top-full bas-z-50 bas-mt-1 bas-w-full bas-overflow-hidden bas-rounded-md bas-border bas-border-solid bas-border-[var(--bal-primary-100)] bas-bg-white hover:bas-border-[var(--bal-primary-300)]"
131
- [style.minHeight.px]="listMinHeight()"
132
- >
133
- <ul
134
- [class]="
135
- 'bal-ba-transition-2 bal-ba-scroll-base bas-m-0 bas-box-border bas-flex bas-h-full bas-w-full bas-flex-col bas-items-center bas-justify-start bas-p-0 bas-text-base bas-text-[var(--bal-primary-700)] hover:bas-text-[var(--bal-primary-900)] bas-overflow-y-auto'
136
- "
137
- [style.maxHeight.px]="listMinHeight()"
138
- >
139
- @for (item of items(); track item[keyName()]; let index = $index) {
140
- <li
141
- [id]="'dropdown-base-item-' + item[keyName()]"
142
- [class]="
143
- 'bal-ba-outline-none bas-group bas-box-border bas-flex bas-w-full bas-flex-row bas-items-center bas-justify-between bas-border-solid bas-border-[var(--bal-primary-90)] bas-px-2 bas-py-1 ' +
144
- getItemBorderStyles(index, items().length) + ' ' +
145
- (isItemDefault(item) ? 'bas-cursor-default' : 'bas-cursor-pointer') + ' ' +
146
- (isSelected(item) ? 'bas-bg-[#e7f2f7] hover:bas-bg-[#dbecf3]' : 'hover:bas-bg-[#f3f8fb]') + ' ' +
147
- (size() !== 'xxs' ? 'bas-min-h-[40px]' : 'bas-min-h-[34px]')
148
- "
149
- (click)="onItemClicked(item)"
150
- >
151
- <div class="bas-group bas-flex bas-h-full bas-w-fit bas-flex-row bas-items-center bas-gap-1.5">
152
- @if (showStatusIndicator()) {
153
- <span
154
- [class]="
155
- 'bas-h-2 bas-w-2 bas-rounded-full ' +
156
- (!isItemDefault(item) ? (isSelected(item) ? 'bas-bg-green-500' : 'bas-bg-slate-300') : 'bas-bg-sky-300')
157
- "
158
- ></span>
159
- }
160
- @if (showImg() && item.icon_url) {
161
- <img [src]="item.icon_url" [alt]="'Image of ' + item[titleKeyName()]" class="bas-h-5 bas-w-5 bas-flex-shrink-0" />
162
- }
163
- <p [class]="getOptionStyles(item, size())">{{ item[titleKeyName()] }}</p>
164
- </div>
165
- @if (showCheckWhenActive() && isSelected(item) && !isItemDefault(item)) {
166
- <span class="bal-ba-transition-2 bas-flex bas-items-center bas-text-[#004e98] group-hover:bas-text-[#00296b]">
167
- <ba-check-icon class="bas-h-4 bas-w-4" />
168
- </span>
169
- }
170
- </li>
171
- }
172
- </ul>
173
- </div>
174
- }
175
- </div>
176
- @if (showTitle()) {
177
- <p class="bal-ba-error-text-invisible bas-m-0 bas-h-[18px]">white space</p>
178
- }
179
- </div>
180
- `,
181
- styles: [
182
- `
183
- .ba-pop {
184
- animation: ba-pop-in 0.15s ease;
185
- transform-origin: top;
186
- }
187
- @keyframes ba-pop-in {
188
- from { opacity: 0; transform: scale(0.95); }
189
- to { opacity: 1; transform: scale(1); }
190
- }
191
- `,
192
- ],
193
- })
194
- export class DropdownBaseComponent {
195
- private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
196
- private readonly ddBaseContainer = viewChild<ElementRef<HTMLDivElement>>('ddBaseContainer');
197
-
198
- btnId = input('dropdown-base-button');
199
- isOpen = input(false);
200
- title = input('Select an item');
201
- showTitle = input(false);
202
- showFloatingLabel = input(false);
203
- floatingLabelTxt = input('Select an item');
204
- floatingLabelBgColor = input('bas-bg-white');
205
- size = input<'xxs' | 'xs' | 'tiny' | 'small' | 'base' | 'large'>('base');
206
- items = input<DropdownItem[]>(defaultItems);
207
- selectedItem = input<DropdownItem>(defaultItems[0]);
208
- keyName = input('value');
209
- titleKeyName = input('name');
210
- width = input<number | string>('100%');
211
- minWidth = input<number | string>(0);
212
- maxWidth = input<number | string>('100%');
213
- dropdownHeight = input<number | null>(null);
214
- classNames = input('');
215
- displayClassNames = input('bas-grid');
216
- borderRadiusClassNames = input('bas-rounded-lg');
217
- container = input<HTMLElement | null>(null);
218
- isInsideModal = input(false);
219
- showStatusIndicator = input(true);
220
- showImg = input(false);
221
- showCheckWhenActive = input(true);
222
- manageActiveWithIsOptionSelected = input(false);
223
- blueStyles = input(false);
224
- disabled = input(false);
225
-
226
- isOpenChange = output<boolean>();
227
- changeSelectedItem = output<DropdownItem>();
228
- clickOutside = output<void>();
229
-
230
- private readonly handleClickOutside = (e: Event): void => {
231
- const el = this.ddBaseContainer()?.nativeElement;
232
- if (!el) return;
233
- if (!el.contains(e.target as Node)) this.clickOutside.emit();
234
- };
235
-
236
- constructor() {
237
- // Port 1:1 del useEffect(...,[isOpen]) de DropdownBase.tsx (187-214),
238
- // solo en navegador (SSR-safe): añade el listener sobre `container` al
239
- // abrir; lo quita al cerrar/destruir salvo `isInsideModal`.
240
- effect((onCleanup) => {
241
- if (!this.isBrowser) return;
242
- const container = this.container();
243
- if (!container) return;
244
- const open = this.isOpen();
245
- const removeEventListeners = () => {
246
- if (this.isInsideModal()) return;
247
- container.removeEventListener('click', this.handleClickOutside);
248
- };
249
- if (open) container.addEventListener('click', this.handleClickOutside);
250
- else removeEventListeners();
251
- onCleanup(removeEventListeners);
252
- });
253
- }
254
-
255
- onBtnClicked(e: MouseEvent): void {
256
- e.preventDefault();
257
- this.isOpenChange.emit(!this.isOpen());
258
- }
259
-
260
- onItemClicked(item: DropdownItem): void {
261
- this.changeSelectedItem.emit(item);
262
- this.isOpenChange.emit(false);
263
- }
264
-
265
- isSelected = (item: DropdownItem): boolean =>
266
- this.manageActiveWithIsOptionSelected()
267
- ? !!item.isOptionSelected
268
- : this.selectedItem()[this.keyName()] === item[this.keyName()];
269
-
270
- isSelectedDefault = computed(() => `${this.selectedItem()[this.keyName()]}`.includes('default'));
271
- isItemDefault = (item: DropdownItem): boolean => `${item[this.keyName()]}`.includes('default');
272
-
273
- listMinHeight = computed(
274
- () => this.dropdownHeight() || this.items().length * (this.size() !== 'xxs' ? 40 : 34) + 2,
275
- );
276
-
277
- containerGridRows = computed(
278
- () =>
279
- ({
280
- xxs: 'bas-grid-rows-[18px_34px_18px]',
281
- xs: 'bas-grid-rows-[18px_36px_18px]',
282
- tiny: 'bas-grid-rows-[18px_38px_18px]',
283
- small: 'bas-grid-rows-[18px_42px_18px]',
284
- base: 'bas-grid-rows-[18px_46px_18px]',
285
- large: 'bas-grid-rows-[18px_54px_18px]',
286
- })[this.size()],
287
- );
288
-
289
- getHeight(showTitle: boolean, size: string): string {
290
- return {
291
- xxs: showTitle ? 'bas-h-[70px]' : 'bas-h-[34px]',
292
- xs: showTitle ? 'bas-h-[72px]' : 'bas-h-[36px]',
293
- tiny: showTitle ? 'bas-h-[74px]' : 'bas-h-[38px]',
294
- small: showTitle ? 'bas-h-[78px]' : 'bas-h-[42px]',
295
- base: showTitle ? 'bas-h-[82px]' : 'bas-h-[46px]',
296
- large: showTitle ? 'bas-h-[90px]' : 'bas-h-[54px]',
297
- }[size]!;
298
- }
299
-
300
- getBtnHeight(size: string): string {
301
- return {
302
- xxs: 'bas-min-h-[34px]',
303
- xs: 'bas-min-h-[36px]',
304
- tiny: 'bas-min-h-[38px]',
305
- small: 'bas-min-h-[42px]',
306
- base: 'bas-min-h-[46px]',
307
- large: 'bas-min-h-[54px]',
308
- }[size]!;
309
- }
310
-
311
- getOptionStyles(item: DropdownItem, size: string): string {
312
- const classes = 'bas-m-0 bas-block bal-ba-transition-2';
313
- if (`${item[this.keyName()]}`.includes('default')) return `${classes} bas-text-[#004e98] bas-text-sm`;
314
- return `${classes} ${size !== 'xxs' ? 'bas-text-base' : 'bas-text-sm'} ${
315
- this.isSelected(item)
316
- ? 'bas-font-medium bas-text-[#00296b] group-hover:bas-text-[#002055]'
317
- : 'bas-text-[#004e98] group-hover:bas-text-[#00296b]'
318
- }`;
319
- }
320
-
321
- getItemBorderStyles(index: number, itemsLength: number): string {
322
- let classNames = '';
323
- if (index < itemsLength - 1) classNames += ' bas-border-x-0 bas-border-b bas-border-t-0 ';
324
- else classNames += ' bas-border-0 ';
325
- if (index === 0) classNames += ' bas-rounded-t-lg ';
326
- else if (index === itemsLength - 1) classNames += ' bas-rounded-b-lg ';
327
- return classNames;
328
- }
329
- }
@@ -1,151 +0,0 @@
1
- // Port literal de packages/react/src/primitives/helpers.ts: helpers de UI
2
- // puros en TS, sin dependencias de React ni de framer-motion, por lo que se
3
- // copian tal cual (solo cambia el comentario de cabecera). Las variantes de
4
- // framer-motion (`dropdownContainerVariantsFromTopRight`, `liItemVariants`,
5
- // etc.) ya no las usa ningún primitivo Vue (DropdownBase anima con
6
- // `<Transition>` + CSS), pero se conservan por si algún componente futuro
7
- // las necesita como referencia/objeto de datos plano (no importan
8
- // framer-motion, son solo objetos JS).
9
- //
10
- // `imgUrlByService` ya vive en `@block-auth.io/core` utils — se reexporta
11
- // aquí para que los primitivos puedan importar todo desde un mismo sitio.
12
- import { utils } from '@block-auth.io/core';
13
-
14
- export const imgUrlByService = utils.imgUrlByService;
15
-
16
- /**
17
- * Variantes framer-motion usadas por el `DropdownBase` original (el dropdown
18
- * se revelaba desde la esquina superior derecha vía un círculo de
19
- * clip-path animado). Portado literalmente desde `helperUI.dropdownContainerVariantsFromTopRight`.
20
- * No se usa en el `DropdownBase.vue` (que anima con `<Transition name="bas-pop">`),
21
- * se conserva por paridad de API con el paquete react.
22
- */
23
- export function dropdownContainerVariantsFromTopRight(
24
- height = 1000,
25
- left: number | string = 'auto',
26
- ) {
27
- return {
28
- open: {
29
- clipPath: `circle(${height * 2 + 200}px at 100% 0%)`,
30
- left,
31
- transition: {
32
- type: 'spring',
33
- stiffness: 20,
34
- restDelta: 2,
35
- duration: 1,
36
- delayChildren: 0.3,
37
- staggerChildren: 0.05,
38
- },
39
- },
40
- closed: {
41
- clipPath: 'circle(0px at 100% 0%)',
42
- left,
43
- transition: {
44
- delay: 0,
45
- type: 'spring',
46
- stiffness: 400,
47
- damping: 40,
48
- },
49
- },
50
- };
51
- }
52
-
53
- /**
54
- * Variantes de stagger por item de la lista del dropdown. Portado
55
- * literalmente desde `helperUI.liItemVariants`. No usado en `DropdownBase.vue`.
56
- */
57
- export function liItemVariants(openOpacity = 1) {
58
- return {
59
- open: {
60
- opacity: openOpacity,
61
- y: 0,
62
- transition: { duration: 0.2 },
63
- },
64
- closed: { opacity: 0, y: 20, transition: { duration: 0.2 } },
65
- };
66
- }
67
-
68
- /* ------------------------------------------------------------------ *
69
- * Helpers de tiempo + variantes de dropdown de pickers — absorbidos del
70
- * `helperUI` original. Los usan `pickers/` y `LifetimeSliderBase`, ambos
71
- * fuera de alcance en esta tarea (excluidos por el plan), pero se conservan
72
- * (son TS puro, sin coste) por si un futuro port de esos componentes los
73
- * necesita.
74
- * ------------------------------------------------------------------ */
75
-
76
- /** Descompone segundos totales en `{ hours, minutes, seconds }`. */
77
- export function convertSecondsToTime(totalSeconds: number) {
78
- const hours = Math.floor(totalSeconds / 3600);
79
- const minutes = Math.floor((totalSeconds % 3600) / 60);
80
- const seconds = totalSeconds % 60;
81
- return { hours, minutes, seconds };
82
- }
83
-
84
- /** Rellena con cero un número menor a 10 (`5` → `"05"`). */
85
- export function formatNumberToString(num: number) {
86
- return num < 10 ? `0${num}` : `${num}`;
87
- }
88
-
89
- /** Parsea un string `HH:MM:SS` a segundos totales. */
90
- export function getSecFromTimeValue(timeValue: string) {
91
- const [h, m, s] = timeValue.split(':');
92
- return parseInt(h) * 3600 + parseInt(m) * 60 + parseInt(s);
93
- }
94
-
95
- /** Segundos totales → `HH:MM:SS` (port de `getTimeBySec`). */
96
- export function getTimeBySec(totalSeconds: number) {
97
- const { hours, minutes, seconds } = convertSecondsToTime(totalSeconds);
98
- return [hours, minutes, seconds].map(formatNumberToString).join(':');
99
- }
100
-
101
- /**
102
- * Revelado del dropdown del picker (hacia abajo) — círculo de clip-path
103
- * desde arriba al centro. Port literal de `dropdownContainerVariantsTopCenterCircle`.
104
- */
105
- export function dropdownContainerVariantsTopCenterCircle(height = 1000) {
106
- return {
107
- open: {
108
- clipPath: `circle(${height * 2 + 200}px at 50% 0%)`,
109
- top: 0,
110
- transition: {
111
- type: 'spring',
112
- stiffness: 20,
113
- restDelta: 2,
114
- duration: 1,
115
- delayChildren: 0.3,
116
- staggerChildren: 0.05,
117
- },
118
- },
119
- closed: {
120
- clipPath: 'circle(0px at 50% 0%)',
121
- top: '-100%',
122
- transition: { delay: 0, type: 'spring', stiffness: 400, damping: 40 },
123
- },
124
- };
125
- }
126
-
127
- /**
128
- * Revelado del dropdown del picker (hacia arriba) — círculo de clip-path
129
- * desde abajo al centro. Port literal de `dropdownContainerUpwardsVariants`.
130
- */
131
- export function dropdownContainerUpwardsVariants(top = -288, height = 1000) {
132
- return {
133
- open: {
134
- clipPath: `circle(${height * 2 + 200}px at 50% 100%)`,
135
- top,
136
- transition: {
137
- type: 'tween',
138
- stiffness: 20,
139
- restDelta: 2,
140
- duration: 2,
141
- delayChildren: 0.3,
142
- staggerChildren: 0.05,
143
- },
144
- },
145
- closed: {
146
- clipPath: 'circle(0px at 50% 100%)',
147
- top,
148
- transition: { delay: 0, type: 'tween', stiffness: 400, damping: 40 },
149
- },
150
- };
151
- }