b2b-tools 0.0.3 → 0.1.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 (39) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +120 -25
  3. package/ng-package.json +7 -0
  4. package/package.json +13 -24
  5. package/src/lib/b2b-tools.spec.ts +23 -0
  6. package/src/lib/b2b-tools.ts +15 -0
  7. package/src/lib/components/advanced-card/advanced-card.css +265 -0
  8. package/src/lib/components/advanced-card/advanced-card.html +117 -0
  9. package/src/lib/components/advanced-card/advanced-card.ts +75 -0
  10. package/src/lib/components/advanced-card/index.ts +2 -0
  11. package/src/lib/components/advanced-card/types/card.types.ts +37 -0
  12. package/src/lib/components/advanced-card/types/index.ts +1 -0
  13. package/src/lib/components/advanced-table/advanced-table.component.css +81 -0
  14. package/src/lib/components/advanced-table/advanced-table.component.html +56 -0
  15. package/src/lib/components/advanced-table/advanced-table.component.ts +469 -0
  16. package/src/lib/components/advanced-table/index.ts +2 -0
  17. package/src/lib/components/advanced-table/parts/table-grid/table-grid.component.css +274 -0
  18. package/src/lib/components/advanced-table/parts/table-grid/table-grid.component.html +168 -0
  19. package/src/lib/components/advanced-table/parts/table-grid/table-grid.component.ts +224 -0
  20. package/src/lib/components/advanced-table/parts/table-modal-image/table-modal-image.component.css +49 -0
  21. package/src/lib/components/advanced-table/parts/table-modal-image/table-modal-image.component.html +14 -0
  22. package/src/lib/components/advanced-table/parts/table-modal-image/table-modal-image.component.ts +22 -0
  23. package/src/lib/components/advanced-table/parts/table-pagination/table-pagination.component.css +147 -0
  24. package/src/lib/components/advanced-table/parts/table-pagination/table-pagination.component.html +95 -0
  25. package/src/lib/components/advanced-table/parts/table-pagination/table-pagination.component.ts +61 -0
  26. package/src/lib/components/advanced-table/parts/table-toolbar/table-toolbar.component.css +32 -0
  27. package/src/lib/components/advanced-table/parts/table-toolbar/table-toolbar.component.html +17 -0
  28. package/src/lib/components/advanced-table/parts/table-toolbar/table-toolbar.component.ts +30 -0
  29. package/src/lib/components/advanced-table/types/index.ts +2 -0
  30. package/src/lib/components/advanced-table/types/table.types.ts +101 -0
  31. package/src/lib/components/advanced-table/types/time-zone.types.ts +91 -0
  32. package/src/lib/components/index.ts +2 -0
  33. package/src/public-api.ts +4 -0
  34. package/tsconfig.lib.json +17 -0
  35. package/tsconfig.lib.prod.json +11 -0
  36. package/tsconfig.spec.json +15 -0
  37. package/fesm2022/b2b-tools.mjs +0 -761
  38. package/fesm2022/b2b-tools.mjs.map +0 -1
  39. package/types/b2b-tools.d.ts +0 -431
@@ -0,0 +1,75 @@
1
+ import { Component, computed, effect, HostListener, input, output, signal } from '@angular/core';
2
+ import { AdvancedAction, AdvancedCardConfig, AdvancedTone } from './types';
3
+
4
+ @Component({
5
+ selector: 'advanced-card',
6
+ imports: [],
7
+ templateUrl: './advanced-card.html',
8
+ styleUrl: './advanced-card.css',
9
+ })
10
+ export class AdvancedCard {
11
+ // Inputs (signals)
12
+ config = input.required<AdvancedCardConfig>();
13
+
14
+ // Controls (Fase 1)
15
+ fullWidthOnExpand = input(true);
16
+ stickyHeader = input(true);
17
+ closeOnEsc = input(true);
18
+
19
+ // Outputs
20
+ expandedChange = output<boolean>();
21
+ action = output<{ actionId: string; cardId: string }>();
22
+
23
+ // State (signals)
24
+ readonly expanded = signal(false);
25
+
26
+ // Computeds
27
+ readonly cardId = computed(() => this.config().id);
28
+ readonly hasHighlights = computed(() => (this.config().highlights?.length ?? 0) > 0);
29
+ readonly hasSummaryBlocks = computed(() => (this.config().summaryBlocks?.length ?? 0) > 0);
30
+
31
+ constructor() {
32
+ effect(() => {
33
+ // Notifica al exterior
34
+ this.expandedChange.emit(this.expanded());
35
+ });
36
+ }
37
+
38
+ toggleExpand(): void {
39
+ this.expanded.update((v) => !v);
40
+ }
41
+
42
+ expand(): void {
43
+ if (!this.expanded()) this.expanded.set(true);
44
+ }
45
+
46
+ collapse(): void {
47
+ if (this.expanded()) this.expanded.set(false);
48
+ }
49
+
50
+ onActionClick(a: AdvancedAction): void {
51
+ if (a.disabled) return;
52
+ this.action.emit({ actionId: a.id, cardId: this.cardId() });
53
+ }
54
+
55
+ badgeClass(tone: AdvancedTone | undefined): string {
56
+ switch (tone) {
57
+ case 'success':
58
+ return 'badge badge--success';
59
+ case 'warning':
60
+ return 'badge badge--warning';
61
+ case 'danger':
62
+ return 'badge badge--danger';
63
+ case 'primary':
64
+ return 'badge badge--primary';
65
+ default:
66
+ return 'badge badge--neutral';
67
+ }
68
+ }
69
+
70
+ @HostListener('document:keydown', ['$event'])
71
+ onKeydown(ev: KeyboardEvent): void {
72
+ if (!this.closeOnEsc()) return;
73
+ if (ev.key === 'Escape') this.collapse();
74
+ }
75
+ }
@@ -0,0 +1,2 @@
1
+ export * from './advanced-card';
2
+ export * from './types';
@@ -0,0 +1,37 @@
1
+ export type AdvancedTone = 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
2
+
3
+ export interface AdvancedBadge {
4
+ label: string;
5
+ tone?: AdvancedTone;
6
+ }
7
+
8
+ export interface AdvancedHighlight {
9
+ label: string;
10
+ value: string;
11
+ hint?: string;
12
+ }
13
+
14
+ export interface AdvancedAction {
15
+ id: string;
16
+ label: string;
17
+ tone?: 'primary' | 'secondary' | 'danger';
18
+ disabled?: boolean;
19
+ }
20
+
21
+ export interface AdvancedCardConfig {
22
+ id: string;
23
+ title: string;
24
+ subtitle?: string;
25
+ badge?: AdvancedBadge;
26
+
27
+ highlights?: AdvancedHighlight[]; // compact key info
28
+ summaryBlocks?: AdvancedSummaryBlock[]; // expanded top row blocks
29
+
30
+ primaryCta?: { label: string }; // compact CTA
31
+ actions?: AdvancedAction[]; // expanded header actions
32
+ }
33
+
34
+ export interface AdvancedSummaryBlock {
35
+ title: string;
36
+ rows: { label: string; value: string }[];
37
+ }
@@ -0,0 +1 @@
1
+ export * from './card.types';
@@ -0,0 +1,81 @@
1
+ :host {
2
+ display: block;
3
+ font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
4
+
5
+ --black: #171717;
6
+ --black-light: #343434;
7
+ --black-dark: #000000;
8
+ --black-navy: #191a21;
9
+
10
+ --xs-dark-gray: #5A5A5A;
11
+ --dark-gray: #9E9E9E;
12
+ --medium-gray: #D5D5D5;
13
+ --gray: #F8F8F8;
14
+ --light-gray: #C6C6C6;
15
+ --xs-light-gray: #DFDFDF;
16
+ --gray-white: #F5F4F4;
17
+ --xxs-light-gray: #F2F2F2;
18
+ --soft-white: #EEEEEE;
19
+
20
+ --green-success: #208B6A;
21
+
22
+ --blue: #3360fa;
23
+ --blue-info: #7390EC;
24
+
25
+ --orange: #F77C00;
26
+ --yellow-warning: #FFBC57;
27
+
28
+ --red: #E60018;
29
+
30
+ --white: #FFFFFF;
31
+
32
+ --disabled: #C6C6C6;
33
+ --disabled-text: #9E9E9E;
34
+
35
+ --radius-sm: 4px;
36
+ --radius-md: 6px;
37
+ --border: 1px solid var(--xs-light-gray);
38
+ --focus-ring: 0 0 0 3px rgba(51, 96, 250, 0.18);
39
+ }
40
+
41
+ .dt-container {
42
+ border: var(--border);
43
+ border-radius: var(--radius-md);
44
+ background: var(--white);
45
+ overflow: hidden;
46
+ }
47
+
48
+ .dt-toolbar {
49
+ display: flex;
50
+ justify-content: space-between;
51
+ align-items: center;
52
+ gap: 12px;
53
+ /* padding: 12px; */
54
+ border-bottom: var(--border);
55
+ background: var(--xxs-light-gray);
56
+ }
57
+
58
+ .dt-empty {
59
+ padding: 18px 12px;
60
+ color: var(--xs-dark-gray);
61
+ }
62
+
63
+ @media (max-width: 900px) {
64
+ .dt-toolbar {
65
+ flex-wrap: wrap;
66
+ align-items: flex-start;
67
+ row-gap: 10px;
68
+ padding: 10px 12px;
69
+ }
70
+
71
+ .dt-toolbar > b2b-table-toolbar {
72
+ flex: 1 1 100%;
73
+ }
74
+
75
+ .dt-toolbar > b2b-table-pagination {
76
+ flex: 1 1 100%;
77
+ display: flex;
78
+ justify-content: center;
79
+ }
80
+ }
81
+
@@ -0,0 +1,56 @@
1
+ <div class="dt-container">
2
+ <div class="dt-toolbar">
3
+ <!-- Search and Clean -->
4
+ <table-toolbar
5
+ [enabled]="config().globalSearch ?? true"
6
+ [query]="globalQuery()"
7
+ placeholder="Buscar..."
8
+ [showClear]="true"
9
+ (queryChange)="setGlobalQuery($event)"
10
+ (clear)="clearFilters()"
11
+ />
12
+
13
+ <!-- Pagination -->
14
+ @if (config().pagination?.enabled) {
15
+ <table-pagination
16
+ [page]="page()"
17
+ [pageSize]="pageSize()"
18
+ [pageCount]="pageCount()"
19
+ [totalCount]="totalCount()"
20
+ [pagerItems]="pagerItems()"
21
+ [pageSizeOptions]="config().pagination!.pageSizeOptions ?? [10, 25, 50]"
22
+ (pageChange)="goToPage($event)"
23
+ (pageSizeChange)="onPageSizeChange($event)"
24
+ />
25
+ }
26
+ </div>
27
+
28
+ <div class="dt-grid">
29
+ <!-- Data Table -->
30
+ <table-grid
31
+ [config]="config()"
32
+ [columns]="visibleColumns()"
33
+ [rows]="pagedData()"
34
+ [gridTemplateColumns]="gridTemplateColumns()"
35
+ [columnQueries]="columnQueries()"
36
+ [sortState]="sortState()"
37
+ [selectedIdsSet]="selectedIdsSet()"
38
+ (headerSort)="onHeaderClickSort($event)"
39
+ (columnQueryChange)="setColumnQuery($event.key, $event.value)"
40
+ (rowClick)="onRowClick($event)"
41
+ (toggleRow)="toggleRowSelection($event)"
42
+ (toggleAllOnPage)="toggleSelectAllOnPage()"
43
+ (openImage)="openImageModal($event.src, $event.alt)"
44
+ (actionClick)="actionClick.emit($event)"
45
+ (bodyScroll)="onBodyScroll($event)"
46
+ />
47
+ </div>
48
+
49
+ <!-- Image Modal -->
50
+ <table-modal-image
51
+ [open]="modalOpen()"
52
+ [src]="modalImageSrc()"
53
+ [alt]="modalImageAlt()"
54
+ (close)="closeModal()"
55
+ />
56
+ </div>