crdx-components 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/crdx-components.mjs +1960 -0
- package/fesm2022/crdx-components.mjs.map +1 -0
- package/package.json +28 -23
- package/src/lib/styles/index.scss +1 -0
- package/src/lib/styles/overrides/_index.scss +2 -4
- package/src/lib/styles/overrides/_mat-button-overrides.scss +0 -11
- package/src/lib/styles/overrides/_mat-checkbox-overrides.scss +2 -2
- package/src/lib/styles/overrides/_mat-radio-overrides.scss +40 -0
- package/types/crdx-components.d.ts +811 -0
- package/types/crdx-components.d.ts.map +1 -0
- package/.github/workflows/publish.yml +0 -38
- package/bun.lock +0 -491
- package/crdx-components-1.0.0.tgz +0 -0
- package/crdx-components-tokenized-components-1.0.1.tgz +0 -0
- package/ng-package.json +0 -12
- package/npm +0 -0
- package/src/index.ts +0 -45
- package/src/lib/components/breadcrumb/breadcrumb.component.css +0 -206
- package/src/lib/components/breadcrumb/breadcrumb.component.html +0 -15
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +0 -47
- package/src/lib/components/button/button.css +0 -371
- package/src/lib/components/button/button.html +0 -187
- package/src/lib/components/button/button.ts +0 -103
- package/src/lib/components/card/card.css +0 -285
- package/src/lib/components/card/card.html +0 -69
- package/src/lib/components/card/card.ts +0 -93
- package/src/lib/components/checkbox/checkbox-showcase.component.css +0 -42
- package/src/lib/components/checkbox/checkbox-showcase.component.html +0 -36
- package/src/lib/components/checkbox/checkbox-showcase.component.ts +0 -13
- package/src/lib/components/checkbox/checkbox.css +0 -10
- package/src/lib/components/checkbox/checkbox.html +0 -13
- package/src/lib/components/checkbox/checkbox.ts +0 -64
- package/src/lib/components/circular-progress-stepper/circular-progress-stepper.css +0 -89
- package/src/lib/components/circular-progress-stepper/circular-progress-stepper.html +0 -23
- package/src/lib/components/circular-progress-stepper/circular-progress-stepper.ts +0 -40
- package/src/lib/components/dialogs/alert-modal/alert-modal.css +0 -118
- package/src/lib/components/dialogs/alert-modal/alert-modal.html +0 -29
- package/src/lib/components/dialogs/alert-modal/alert-modal.ts +0 -28
- package/src/lib/components/dialogs/confirm-modal/confirm-modal.css +0 -219
- package/src/lib/components/dialogs/confirm-modal/confirm-modal.html +0 -60
- package/src/lib/components/dialogs/confirm-modal/confirm-modal.store.ts +0 -139
- package/src/lib/components/dialogs/confirm-modal/confirm-modal.ts +0 -63
- package/src/lib/components/dialogs/container-custom/container-custom.css +0 -11
- package/src/lib/components/dialogs/container-custom/container-custom.html +0 -3
- package/src/lib/components/dialogs/container-custom/container-custom.ts +0 -37
- package/src/lib/components/dialogs/container-custom/custom-modal.state.ts +0 -57
- package/src/lib/components/dialogs/error-modal/error-modal.css +0 -53
- package/src/lib/components/dialogs/error-modal/error-modal.html +0 -17
- package/src/lib/components/dialogs/error-modal/error-modal.ts +0 -20
- package/src/lib/components/dialogs/side-modal/side-modal.css +0 -80
- package/src/lib/components/dialogs/side-modal/side-modal.html +0 -30
- package/src/lib/components/dialogs/side-modal/side-modal.state.ts +0 -78
- package/src/lib/components/dialogs/side-modal/side-modal.ts +0 -50
- package/src/lib/components/divider/divider.css +0 -24
- package/src/lib/components/divider/divider.html +0 -7
- package/src/lib/components/divider/divider.ts +0 -13
- package/src/lib/components/footer-actions/footer/footer-flow.store.ts +0 -30
- package/src/lib/components/footer-actions/footer/footer.html +0 -14
- package/src/lib/components/footer-actions/footer/footer.ts +0 -50
- package/src/lib/components/footer-actions/modal-footer-actions/modal-footer-actions.css +0 -44
- package/src/lib/components/footer-actions/modal-footer-actions/modal-footer-actions.html +0 -7
- package/src/lib/components/footer-actions/modal-footer-actions/modal-footer-actions.ts +0 -12
- package/src/lib/components/footer-actions/page-footer-actions/page-footer-actions.css +0 -31
- package/src/lib/components/footer-actions/page-footer-actions/page-footer-actions.html +0 -7
- package/src/lib/components/footer-actions/page-footer-actions/page-footer-actions.ts +0 -12
- package/src/lib/components/form-field/select-field.css +0 -178
- package/src/lib/components/form-field/select-field.html +0 -94
- package/src/lib/components/form-field/select-field.ts +0 -324
- package/src/lib/components/form-field/text-field.css +0 -41
- package/src/lib/components/form-field/text-field.html +0 -38
- package/src/lib/components/form-field/text-field.ts +0 -102
- package/src/lib/components/header/header.css +0 -142
- package/src/lib/components/header/header.html +0 -36
- package/src/lib/components/header/header.ts +0 -101
- package/src/lib/components/icon-button/icon-button.css +0 -445
- package/src/lib/components/icon-button/icon-button.html +0 -15
- package/src/lib/components/icon-button/icon-button.ts +0 -49
- package/src/lib/components/list-item/list-item.css +0 -122
- package/src/lib/components/list-item/list-item.html +0 -79
- package/src/lib/components/list-item/list-item.ts +0 -104
- package/src/lib/components/menu/menu.css +0 -39
- package/src/lib/components/menu/menu.html +0 -57
- package/src/lib/components/menu/menu.ts +0 -159
- package/src/lib/components/shared-table/shared-table-cell-template.directive.ts +0 -25
- package/src/lib/components/shared-table/shared-table.component.css +0 -223
- package/src/lib/components/shared-table/shared-table.component.html +0 -96
- package/src/lib/components/shared-table/shared-table.component.ts +0 -172
- package/src/lib/components/sidebar/sidebar.css +0 -234
- package/src/lib/components/sidebar/sidebar.html +0 -67
- package/src/lib/components/sidebar/sidebar.ts +0 -92
- package/src/lib/components/slide-toggle/slide-toggle.css +0 -0
- package/src/lib/components/slide-toggle/slide-toggle.html +0 -3
- package/src/lib/components/slide-toggle/slide-toggle.ts +0 -18
- package/src/lib/components/spinner/spinner.css +0 -9
- package/src/lib/components/spinner/spinner.html +0 -9
- package/src/lib/components/spinner/spinner.ts +0 -17
- package/src/lib/components/tooltip/tooltip.css +0 -32
- package/src/lib/components/tooltip/tooltip.html +0 -3
- package/src/lib/components/tooltip/tooltip.ts +0 -31
- package/src/lib/icons/register-icons.ts +0 -101
- package/src/lib/lib-ui/lib-ui.html +0 -1
- package/src/lib/lib-ui/lib-ui.scss +0 -0
- package/src/lib/lib-ui/lib-ui.ts +0 -9
- package/tsconfig.json +0 -30
- package/tsconfig.lib.json +0 -20
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<div
|
|
2
|
-
class="ui-list-item__container"
|
|
3
|
-
[style.width]="width() ?? '100%'"
|
|
4
|
-
[style.min-width]="width() ?? null"
|
|
5
|
-
[style.--lib-list-item-background]="backgroundColor() ?? null"
|
|
6
|
-
>
|
|
7
|
-
@if (headerTemplate()) {
|
|
8
|
-
<div class="ui-list-item__header">
|
|
9
|
-
<ng-container [ngTemplateOutlet]="headerTemplate()!" />
|
|
10
|
-
</div>
|
|
11
|
-
}
|
|
12
|
-
<mat-list role="list">
|
|
13
|
-
@for (item of items(); track trackById($index, item)) {
|
|
14
|
-
<mat-list-item
|
|
15
|
-
role="listitem"
|
|
16
|
-
class="ui-list-option"
|
|
17
|
-
[class.ui-list-item--disabled]="item.disabled ?? false"
|
|
18
|
-
[class.ui-list-item--selected]="showCheckbox() && isItemSelected(item)"
|
|
19
|
-
[class.ui-list-item--with-divider]="showDividers()"
|
|
20
|
-
[disableRipple]="true"
|
|
21
|
-
(click)="onRowClick(item, $event)"
|
|
22
|
-
>
|
|
23
|
-
@if (itemTemplate()) {
|
|
24
|
-
<ng-container [ngTemplateOutlet]="itemTemplate()!" [ngTemplateOutletContext]="{ $implicit: item }" />
|
|
25
|
-
} @else {
|
|
26
|
-
<div class="ui-list-item" [class.ui-list-item--with-divider]="showDividers()">
|
|
27
|
-
<span class="ui-list-item__state-layer"></span>
|
|
28
|
-
|
|
29
|
-
@if (showCheckbox() && checkboxPosition() === 'leading') {
|
|
30
|
-
<span class="ui-list-item__leading ui-list-item__leading--checkbox">
|
|
31
|
-
<mat-checkbox
|
|
32
|
-
[checked]="isItemSelected(item)"
|
|
33
|
-
[disabled]="item.disabled ?? disabled()"
|
|
34
|
-
(change)="onCheckboxChange(item, $event.checked)"
|
|
35
|
-
(click)="$event.stopPropagation()"
|
|
36
|
-
/>
|
|
37
|
-
</span>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@if (showAvatar() && !showCheckbox()) {
|
|
41
|
-
<span class="ui-list-item__leading">
|
|
42
|
-
@if (item.avatarImage) {
|
|
43
|
-
<img
|
|
44
|
-
class="ui-list-item__avatar-image"
|
|
45
|
-
[src]="item.avatarImage"
|
|
46
|
-
[attr.alt]="item.avatarAlt || item.label"
|
|
47
|
-
loading="lazy"
|
|
48
|
-
/>
|
|
49
|
-
} @else {
|
|
50
|
-
<span class="ui-list-item__avatar-text" aria-hidden="true">
|
|
51
|
-
{{ avatarInitial(item) }}
|
|
52
|
-
</span>
|
|
53
|
-
}
|
|
54
|
-
</span>
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
<span class="ui-list-item__content">
|
|
58
|
-
<span class="ui-list-item__label">{{ item.label }}</span>
|
|
59
|
-
@if (item.description) {
|
|
60
|
-
<span class="ui-list-item__description">{{ item.description }}</span>
|
|
61
|
-
}
|
|
62
|
-
</span>
|
|
63
|
-
|
|
64
|
-
@if (showCheckbox() && checkboxPosition() === 'trailing') {
|
|
65
|
-
<span class="ui-list-item__trailing ui-list-item__trailing--checkbox">
|
|
66
|
-
<lib-checkbox
|
|
67
|
-
[checked]="isItemSelected(item)"
|
|
68
|
-
[disabled]="item.disabled ?? disabled()"
|
|
69
|
-
(checkedChange)="onCheckboxChange(item, $event)"
|
|
70
|
-
(click)="$event.stopPropagation()"
|
|
71
|
-
/>
|
|
72
|
-
</span>
|
|
73
|
-
}
|
|
74
|
-
</div>
|
|
75
|
-
}
|
|
76
|
-
</mat-list-item>
|
|
77
|
-
}
|
|
78
|
-
</mat-list>
|
|
79
|
-
</div>
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
contentChild,
|
|
6
|
-
input,
|
|
7
|
-
output,
|
|
8
|
-
TemplateRef,
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
11
|
-
import { MatListModule } from '@angular/material/list';
|
|
12
|
-
import { NgTemplateOutlet } from '@angular/common';
|
|
13
|
-
import { LibCheckboxComponent } from '../checkbox/checkbox';
|
|
14
|
-
|
|
15
|
-
export interface LibListItemData {
|
|
16
|
-
id: string;
|
|
17
|
-
label: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
avatarText?: string | null;
|
|
20
|
-
avatarImage?: string | null;
|
|
21
|
-
avatarAlt?: string;
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Component({
|
|
26
|
-
selector: 'lib-list-item',
|
|
27
|
-
standalone: true,
|
|
28
|
-
imports: [MatListModule, MatCheckboxModule, LibCheckboxComponent, NgTemplateOutlet],
|
|
29
|
-
templateUrl: './list-item.html',
|
|
30
|
-
styleUrl: './list-item.css',
|
|
31
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
32
|
-
})
|
|
33
|
-
export class LibListItemComponent {
|
|
34
|
-
items = input<LibListItemData[]>([]);
|
|
35
|
-
selectedIds = input<string[]>([]);
|
|
36
|
-
multiple = input(true);
|
|
37
|
-
disabled = input(false);
|
|
38
|
-
showCheckbox = input(true);
|
|
39
|
-
showAvatar = input(true);
|
|
40
|
-
showDividers = input(true);
|
|
41
|
-
/** Posición del checkbox: 'leading' (izquierda) o 'trailing' (derecha). Por defecto 'trailing' según diseño Figma. */
|
|
42
|
-
checkboxPosition = input<'leading' | 'trailing'>('trailing');
|
|
43
|
-
|
|
44
|
-
/** Ancho de la lista. Acepta valores CSS (ej: '18.8rem', '300px', '100%'). Si no se pasa, la lista ocupa el ancho disponible. */
|
|
45
|
-
width = input<string | undefined>(undefined);
|
|
46
|
-
/** Fondo personalizado de la lista/items. Si no se define, usa el fondo por defecto de tokens. */
|
|
47
|
-
backgroundColor = input<string | undefined>(undefined);
|
|
48
|
-
|
|
49
|
-
readonly selectionChange = output<string[]>();
|
|
50
|
-
readonly itemClick = output<LibListItemData>();
|
|
51
|
-
|
|
52
|
-
/** Template para proyectar contenido arriba de la lista (ej: checkbox, filtros) */
|
|
53
|
-
readonly headerTemplate = contentChild<TemplateRef<unknown>>('headerTemplate');
|
|
54
|
-
|
|
55
|
-
/** Template para proyectar el contenido personalizado de cada item. Usar: let-item para acceder al item */
|
|
56
|
-
readonly itemTemplate = contentChild<TemplateRef<{ $implicit: LibListItemData }>>('itemTemplate');
|
|
57
|
-
|
|
58
|
-
readonly selectedSet = computed(() => new Set(this.selectedIds()));
|
|
59
|
-
|
|
60
|
-
trackById(_index: number, item: LibListItemData): string {
|
|
61
|
-
return item.id;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
avatarInitial(item: LibListItemData): string {
|
|
65
|
-
const explicit = item.avatarText?.trim();
|
|
66
|
-
if (explicit) {
|
|
67
|
-
return explicit.slice(0, 2).toUpperCase();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const label = item.label?.trim();
|
|
71
|
-
return label ? label.charAt(0).toUpperCase() : '';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
isItemSelected(item: LibListItemData): boolean {
|
|
75
|
-
return this.selectedSet().has(item.id);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
onCheckboxChange(item: LibListItemData, selected: boolean): void {
|
|
79
|
-
const current = new Set(this.selectedIds());
|
|
80
|
-
if (this.multiple()) {
|
|
81
|
-
if (selected) {
|
|
82
|
-
current.add(item.id);
|
|
83
|
-
} else {
|
|
84
|
-
current.delete(item.id);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
this.selectionChange.emit(selected ? [item.id] : []);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
this.selectionChange.emit([...current]);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
onRowClick(item: LibListItemData, _event: Event): void {
|
|
94
|
-
if (this.showCheckbox() && !(item.disabled ?? this.disabled())) {
|
|
95
|
-
const isSelected = this.isItemSelected(item);
|
|
96
|
-
this.onCheckboxChange(item, !isSelected);
|
|
97
|
-
}
|
|
98
|
-
this.itemClick.emit(item);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
onItemClick(item: LibListItemData): void {
|
|
102
|
-
this.itemClick.emit(item);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
.lib-menu {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.lib-menu__trigger {
|
|
6
|
-
display: inline-flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
gap: 0.5rem;
|
|
10
|
-
min-width: 12rem;
|
|
11
|
-
padding-inline: 0.75rem;
|
|
12
|
-
text-transform: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.lib-menu__trigger-label {
|
|
16
|
-
font-size: 0.875rem;
|
|
17
|
-
color: rgba(0, 0, 0, 0.6);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.lib-menu__trigger-value {
|
|
21
|
-
flex: 1;
|
|
22
|
-
text-align: left;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.lib-menu__trigger-icon {
|
|
26
|
-
font-size: 20px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.lib-menu__filter {
|
|
30
|
-
padding: 0.5rem 1rem 0.25rem;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.lib-menu__filter-field {
|
|
34
|
-
width: 100%;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.lib-menu__panel {
|
|
38
|
-
max-width: 20rem;
|
|
39
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<div class="lib-menu">
|
|
2
|
-
<button
|
|
3
|
-
mat-button
|
|
4
|
-
class="lib-menu__trigger"
|
|
5
|
-
[matMenuTriggerFor]="menu"
|
|
6
|
-
[disabled]="disabled() || disabledByControl()"
|
|
7
|
-
type="button"
|
|
8
|
-
>
|
|
9
|
-
<span class="lib-menu__trigger-label">
|
|
10
|
-
{{ label() || '' }}
|
|
11
|
-
</span>
|
|
12
|
-
<span class="lib-menu__trigger-value">
|
|
13
|
-
{{ triggerLabel() }}
|
|
14
|
-
</span>
|
|
15
|
-
<mat-icon class="lib-menu__trigger-icon">
|
|
16
|
-
{{ panelOpen() ? 'keyboard_arrow_up' : 'keyboard_arrow_down' }}
|
|
17
|
-
</mat-icon>
|
|
18
|
-
</button>
|
|
19
|
-
|
|
20
|
-
<mat-menu
|
|
21
|
-
#menu="matMenu"
|
|
22
|
-
class="lib-menu__panel"
|
|
23
|
-
(menuOpened)="onMenuOpened()"
|
|
24
|
-
(menuClosed)="onMenuClosed()"
|
|
25
|
-
>
|
|
26
|
-
@if (filterable()) {
|
|
27
|
-
<div class="lib-menu__filter">
|
|
28
|
-
<mat-form-field appearance="outline" class="lib-menu__filter-field">
|
|
29
|
-
<mat-label>Buscar</mat-label>
|
|
30
|
-
<input
|
|
31
|
-
matInput
|
|
32
|
-
type="text"
|
|
33
|
-
(input)="onFilterInput($event)"
|
|
34
|
-
/>
|
|
35
|
-
</mat-form-field>
|
|
36
|
-
</div>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@for (opt of filteredOptions(); track opt.value) {
|
|
40
|
-
@if (isMultiple()) {
|
|
41
|
-
<button mat-menu-item (click)="onOptionClick(opt, $event)">
|
|
42
|
-
<mat-checkbox
|
|
43
|
-
[checked]="isSelected(opt.value)"
|
|
44
|
-
(click)="$event.stopPropagation()"
|
|
45
|
-
>
|
|
46
|
-
{{ opt.label }}
|
|
47
|
-
</mat-checkbox>
|
|
48
|
-
</button>
|
|
49
|
-
} @else {
|
|
50
|
-
<button mat-menu-item (click)="onOptionClick(opt, $event)">
|
|
51
|
-
<span>{{ opt.label }}</span>
|
|
52
|
-
</button>
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
</mat-menu>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
forwardRef,
|
|
6
|
-
input,
|
|
7
|
-
signal,
|
|
8
|
-
} from '@angular/core';
|
|
9
|
-
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
|
-
import { MatMenuModule } from '@angular/material/menu';
|
|
11
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
12
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
13
|
-
import { MatInputModule } from '@angular/material/input';
|
|
14
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
15
|
-
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
16
|
-
|
|
17
|
-
export interface LibMenuOption<T = string> {
|
|
18
|
-
value: T;
|
|
19
|
-
label: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type LibMenuMode = 'single' | 'multiple';
|
|
23
|
-
|
|
24
|
-
@Component({
|
|
25
|
-
selector: 'lib-menu',
|
|
26
|
-
standalone: true,
|
|
27
|
-
imports: [
|
|
28
|
-
MatMenuModule,
|
|
29
|
-
MatButtonModule,
|
|
30
|
-
MatFormFieldModule,
|
|
31
|
-
MatInputModule,
|
|
32
|
-
MatIconModule,
|
|
33
|
-
MatCheckboxModule,
|
|
34
|
-
],
|
|
35
|
-
templateUrl: './menu.html',
|
|
36
|
-
styleUrl: './menu.css',
|
|
37
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
38
|
-
providers: [
|
|
39
|
-
{
|
|
40
|
-
provide: NG_VALUE_ACCESSOR,
|
|
41
|
-
useExisting: forwardRef(() => LibMenuComponent),
|
|
42
|
-
multi: true,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
})
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Prefer `lib-select-field` for new implementations.
|
|
48
|
-
* Kept for compatibility while migrating existing screens.
|
|
49
|
-
*/
|
|
50
|
-
export class LibMenuComponent<T = string> implements ControlValueAccessor {
|
|
51
|
-
readonly label = input<string | null>(null);
|
|
52
|
-
readonly placeholder = input('Seleccionar');
|
|
53
|
-
readonly options = input<LibMenuOption<T>[]>([]);
|
|
54
|
-
readonly mode = input<LibMenuMode>('single');
|
|
55
|
-
readonly filterable = input(true);
|
|
56
|
-
readonly disabled = input(false);
|
|
57
|
-
|
|
58
|
-
readonly panelOpen = signal(false);
|
|
59
|
-
readonly filterTerm = signal('');
|
|
60
|
-
readonly disabledByControl = signal(false);
|
|
61
|
-
|
|
62
|
-
readonly valueSignal = signal<T | T[] | null>(null);
|
|
63
|
-
|
|
64
|
-
readonly isMultiple = computed(() => this.mode() === 'multiple');
|
|
65
|
-
|
|
66
|
-
readonly filteredOptions = computed(() => {
|
|
67
|
-
const opts = this.options();
|
|
68
|
-
const term = this.filterTerm().trim().toLowerCase();
|
|
69
|
-
if (!term) return opts;
|
|
70
|
-
return opts.filter((o) => o.label.toLowerCase().includes(term));
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
readonly triggerLabel = computed(() => {
|
|
74
|
-
const current = this.valueSignal();
|
|
75
|
-
const opts = this.options();
|
|
76
|
-
if (current == null) {
|
|
77
|
-
return this.placeholder();
|
|
78
|
-
}
|
|
79
|
-
if (Array.isArray(current)) {
|
|
80
|
-
if (!current.length) return this.placeholder();
|
|
81
|
-
const labels = current
|
|
82
|
-
.map((v) => opts.find((o) => o.value === v)?.label)
|
|
83
|
-
.filter((l): l is string => !!l);
|
|
84
|
-
if (!labels.length) return this.placeholder();
|
|
85
|
-
if (labels.length === 1) return labels[0];
|
|
86
|
-
const [first, ...rest] = labels;
|
|
87
|
-
return `${first} (+${rest.length})`;
|
|
88
|
-
}
|
|
89
|
-
const match = opts.find((o) => o.value === current);
|
|
90
|
-
return match?.label ?? this.placeholder();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
onMenuOpened(): void {
|
|
94
|
-
this.panelOpen.set(true);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
onMenuClosed(): void {
|
|
98
|
-
this.panelOpen.set(false);
|
|
99
|
-
this.filterTerm.set('');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
onFilterInput(event: Event): void {
|
|
103
|
-
const el = event.target as HTMLInputElement;
|
|
104
|
-
this.filterTerm.set(el?.value ?? '');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
onOptionClick(option: LibMenuOption<T>, event?: MouseEvent): void {
|
|
108
|
-
if (event) {
|
|
109
|
-
event.stopPropagation();
|
|
110
|
-
event.preventDefault();
|
|
111
|
-
}
|
|
112
|
-
if (this.isMultiple()) {
|
|
113
|
-
const current = this.valueSignal();
|
|
114
|
-
const asArray = Array.isArray(current) ? [...current] : [];
|
|
115
|
-
const index = asArray.findIndex((v) => v === option.value);
|
|
116
|
-
if (index >= 0) {
|
|
117
|
-
asArray.splice(index, 1);
|
|
118
|
-
} else {
|
|
119
|
-
asArray.push(option.value);
|
|
120
|
-
}
|
|
121
|
-
const next = asArray as T[];
|
|
122
|
-
this.valueSignal.set(next);
|
|
123
|
-
this.onChange(next);
|
|
124
|
-
} else {
|
|
125
|
-
const next = option.value;
|
|
126
|
-
this.valueSignal.set(next);
|
|
127
|
-
this.onChange(next);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
isSelected(value: T): boolean {
|
|
132
|
-
const current = this.valueSignal();
|
|
133
|
-
if (Array.isArray(current)) {
|
|
134
|
-
return current.includes(value);
|
|
135
|
-
}
|
|
136
|
-
return current === value;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// ControlValueAccessor
|
|
140
|
-
private onChange: (value: T | T[] | null) => void = () => {};
|
|
141
|
-
private onTouched: () => void = () => {};
|
|
142
|
-
|
|
143
|
-
writeValue(value: T | T[] | null): void {
|
|
144
|
-
this.valueSignal.set(value);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
registerOnChange(fn: (value: T | T[] | null) => void): void {
|
|
148
|
-
this.onChange = fn;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
registerOnTouched(fn: () => void): void {
|
|
152
|
-
this.onTouched = fn;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
setDisabledState(isDisabled: boolean): void {
|
|
156
|
-
this.disabledByControl.set(isDisabled);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Directive, Input, TemplateRef, inject } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Directive({
|
|
4
|
-
selector: 'ng-template[cellTemplate], ng-template[libCellTemplate]',
|
|
5
|
-
standalone: true,
|
|
6
|
-
})
|
|
7
|
-
export class SharedTableCellTemplateDirective {
|
|
8
|
-
readonly template = inject<TemplateRef<unknown>>(TemplateRef);
|
|
9
|
-
private legacyKey = '';
|
|
10
|
-
private modernKey = '';
|
|
11
|
-
|
|
12
|
-
@Input()
|
|
13
|
-
set cellTemplate(value: string | null | undefined) {
|
|
14
|
-
this.legacyKey = value ?? '';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@Input()
|
|
18
|
-
set libCellTemplate(value: string | null | undefined) {
|
|
19
|
-
this.modernKey = value ?? '';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get key(): string {
|
|
23
|
-
return this.modernKey || this.legacyKey;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
flex: 1 1 0;
|
|
5
|
-
min-height: 0;
|
|
6
|
-
width: 100%;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.shared-table {
|
|
10
|
-
width: 100%;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
margin: 0;
|
|
14
|
-
flex: 1 1 0;
|
|
15
|
-
min-height: 0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Paginador en el flujo (como en el ejemplo de Material): el scroll termina justo donde empieza el paginador */
|
|
19
|
-
.shared-table .mat-mdc-paginator {
|
|
20
|
-
flex-shrink: 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* Selector de número de páginas: contenedor al tamaño del contenido para que el gap sea 2.12rem */
|
|
24
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select {
|
|
25
|
-
width: fit-content !important;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
max-width: fit-content !important;
|
|
28
|
-
/* No crecer en el flex del paginador */
|
|
29
|
-
flex: 0 0 auto !important;
|
|
30
|
-
--mat-paginator-page-size-select-width: 100%;
|
|
31
|
-
--mat-paginator-page-size-select-touch-target-height: 100%;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field {
|
|
35
|
-
position: relative;
|
|
36
|
-
width: fit-content !important;
|
|
37
|
-
min-width: 0;
|
|
38
|
-
max-width: fit-content !important;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field,
|
|
42
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field-flex,
|
|
43
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field-subscript-wrapper,
|
|
44
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field-infix,
|
|
45
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-select-trigger,
|
|
46
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-select-value {
|
|
47
|
-
border: none !important;
|
|
48
|
-
border-bottom: none !important;
|
|
49
|
-
box-shadow: none !important;
|
|
50
|
-
padding-left: 0 !important;
|
|
51
|
-
padding-right: 0 !important;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* Solo selector de número de páginas: padding 0 en wrappers del text-field (Material) */
|
|
55
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-text-field-wrapper,
|
|
56
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-text-field,
|
|
57
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-text-field--outlined {
|
|
58
|
-
padding: 0 !important;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/* Contenedor del trigger como contexto de posicionamiento para que el touch target = mismo tamaño */
|
|
62
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field-flex {
|
|
63
|
-
position: relative;
|
|
64
|
-
width: fit-content !important;
|
|
65
|
-
min-width: 0;
|
|
66
|
-
max-width: fit-content !important;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* Evitar ancho fijo 180px del infix (Material) */
|
|
70
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-form-field-infix {
|
|
71
|
-
width: auto !important;
|
|
72
|
-
min-width: 0 !important;
|
|
73
|
-
flex: 0 0 auto !important;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/* Touch target solo del tamaño del selector (evitar 180px): topes máximos */
|
|
77
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-paginator-touch-target {
|
|
78
|
-
position: absolute !important;
|
|
79
|
-
inset: 0 !important;
|
|
80
|
-
width: 100% !important;
|
|
81
|
-
height: 100% !important;
|
|
82
|
-
max-width: 5rem !important;
|
|
83
|
-
max-height: 1.625rem !important;
|
|
84
|
-
box-sizing: border-box !important;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-select-value {
|
|
88
|
-
margin-right: 0 !important;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/* Trigger: min 2.0625rem x 1.625rem, se ensancha si el número es más largo */
|
|
92
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-select-trigger {
|
|
93
|
-
display: flex !important;
|
|
94
|
-
min-width: 2.0625rem !important;
|
|
95
|
-
width: max-content !important;
|
|
96
|
-
height: 1.625rem !important;
|
|
97
|
-
flex-direction: row !important;
|
|
98
|
-
align-items: center !important;
|
|
99
|
-
flex-shrink: 0;
|
|
100
|
-
gap: 0 !important;
|
|
101
|
-
border: none !important;
|
|
102
|
-
border-bottom: 0.0625rem solid var(--pallete-scheme-surface-outline-variant, #C3C7C9) !important;
|
|
103
|
-
box-shadow: none !important;
|
|
104
|
-
align-self: stretch;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mat-mdc-select-arrow-wrapper {
|
|
108
|
-
margin-left: 0 !important;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-notched-outline,
|
|
112
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-notched-outline__leading,
|
|
113
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-notched-outline__notch,
|
|
114
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-notched-outline__trailing,
|
|
115
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-notched-outline .mat-mdc-notch-piece {
|
|
116
|
-
border: none !important;
|
|
117
|
-
border-width: 0 !important;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
:host ::ng-deep .shared-table__paginator .mat-mdc-paginator-page-size-select .mdc-line-ripple {
|
|
121
|
-
display: none !important;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/* Tabla: ancho por contenido para que aparezca scroll horizontal con muchas columnas o pantalla estrecha */
|
|
125
|
-
.shared-table__mat-table {
|
|
126
|
-
width: max-content;
|
|
127
|
-
min-width: 100%;
|
|
128
|
-
table-layout: auto;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.shared-table__caption {
|
|
132
|
-
margin-bottom: 16px;
|
|
133
|
-
font-weight: 600;
|
|
134
|
-
font-size: 1.125rem;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.shared-table__empty {
|
|
138
|
-
text-align: center;
|
|
139
|
-
padding: 24px 16px;
|
|
140
|
-
color: #6b7280;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/* Contenedor: solo esquinas superiores redondeadas, sin borde inferior */
|
|
144
|
-
.shared-table__container {
|
|
145
|
-
--border-color: #E9E9E9;
|
|
146
|
-
--table-radius: 0.25rem;
|
|
147
|
-
flex: 1 1 0;
|
|
148
|
-
flex-grow: 1;
|
|
149
|
-
width: 100%;
|
|
150
|
-
display: flex;
|
|
151
|
-
flex-direction: column;
|
|
152
|
-
min-height: 0;
|
|
153
|
-
overflow: hidden;
|
|
154
|
-
border-radius: var(--table-radius) var(--table-radius) 0 0;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/* Sin paginador: cerrar "card" de tabla con borde y radio inferior */
|
|
158
|
-
.shared-table__container.shared-table__container--no-paginator {
|
|
159
|
-
border-radius: var(--table-radius) !important;
|
|
160
|
-
border-bottom: 1px solid var(--pallete-scheme-surface-outline-variant, #C3C7C9) !important;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.shared-table__container.shared-table__container--no-paginator .shared-table__body-wrap {
|
|
164
|
-
border-radius: 0 0 var(--table-radius) var(--table-radius);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/* Header: esquinas superiores redondeadas */
|
|
168
|
-
.shared-table__header-wrap {
|
|
169
|
-
flex-shrink: 0;
|
|
170
|
-
overflow-x: auto;
|
|
171
|
-
overflow-y: hidden;
|
|
172
|
-
scrollbar-width: none;
|
|
173
|
-
border-radius: var(--table-radius) var(--table-radius) 0 0;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.shared-table__header-wrap::-webkit-scrollbar {
|
|
177
|
-
display: none;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/* Cuerpo: sin radio en esquinas inferiores */
|
|
181
|
-
.shared-table__body-wrap {
|
|
182
|
-
flex: 1 1 0;
|
|
183
|
-
min-height: 0;
|
|
184
|
-
overflow: auto;
|
|
185
|
-
position: relative;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.shared-table__loading-overlay {
|
|
189
|
-
position: absolute;
|
|
190
|
-
top: 0;
|
|
191
|
-
left: 0;
|
|
192
|
-
right: 0;
|
|
193
|
-
bottom: 0;
|
|
194
|
-
background: rgba(255, 255, 255, 0.92);
|
|
195
|
-
display: flex;
|
|
196
|
-
align-items: center;
|
|
197
|
-
justify-content: center;
|
|
198
|
-
z-index: 9999;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
::ng-deep .shared-table__loading-spinner,
|
|
202
|
-
::ng-deep .shared-table__loading-spinner .mat-mdc-circular-progress,
|
|
203
|
-
::ng-deep .shared-table__loading-spinner .mdc-circular-progress,
|
|
204
|
-
::ng-deep .shared-table__loading-spinner circle {
|
|
205
|
-
position: relative;
|
|
206
|
-
z-index: 10000;
|
|
207
|
-
color: #d32f2f !important;
|
|
208
|
-
stroke: #d32f2f !important;
|
|
209
|
-
stroke-opacity: 1 !important;
|
|
210
|
-
opacity: 1 !important;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
::ng-deep .shared-table__loading-spinner .mdc-circular-progress__indicator,
|
|
214
|
-
::ng-deep .shared-table__loading-spinner .mdc-circular-progress__indeterminate-outer-circle,
|
|
215
|
-
::ng-deep .shared-table__loading-spinner .mdc-circular-progress__indeterminate-inner-circle {
|
|
216
|
-
stroke: #d32f2f !important;
|
|
217
|
-
stroke-width: 6 !important;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
::ng-deep .shared-table__loading-spinner {
|
|
221
|
-
--mdc-circular-progress-active-indicator-color: #d32f2f !important;
|
|
222
|
-
--mdc-circular-progress-track-color: rgba(0, 0, 0, 0.1) !important;
|
|
223
|
-
}
|