crdx-components 1.0.0 → 1.0.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/crdx-components.mjs +1624 -0
- package/fesm2022/crdx-components.mjs.map +1 -0
- package/package.json +19 -14
- package/types/crdx-components.d.ts +749 -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,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
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
<figure class="shared-table">
|
|
2
|
-
<div
|
|
3
|
-
class="shared-table__container mdc-data-table"
|
|
4
|
-
[class.shared-table__container--no-paginator]="!shouldRenderPaginator()"
|
|
5
|
-
>
|
|
6
|
-
<!-- Header: scroll sincronizado con el cuerpo, sin barra visible -->
|
|
7
|
-
<div class="shared-table__header-wrap" #headerWrap>
|
|
8
|
-
<table
|
|
9
|
-
mat-table
|
|
10
|
-
[dataSource]="dataSource"
|
|
11
|
-
class="shared-table__mat-table shared-table__mat-table--header"
|
|
12
|
-
>
|
|
13
|
-
@for (column of columns(); track columnTrackBy($index, column)) {
|
|
14
|
-
<ng-container [matColumnDef]="columnId(column)">
|
|
15
|
-
<th
|
|
16
|
-
mat-header-cell
|
|
17
|
-
*matHeaderCellDef
|
|
18
|
-
[style.text-align]="resolveTextAlign(column)"
|
|
19
|
-
[style.width]="resolveWidth(column)"
|
|
20
|
-
>
|
|
21
|
-
{{ column.header }}
|
|
22
|
-
</th>
|
|
23
|
-
</ng-container>
|
|
24
|
-
}
|
|
25
|
-
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
26
|
-
</table>
|
|
27
|
-
</div>
|
|
28
|
-
<!-- Cuerpo: scroll horizontal aquí (barra debajo del header) -->
|
|
29
|
-
<div
|
|
30
|
-
class="shared-table__body-wrap"
|
|
31
|
-
[class.shared-table__body-wrap--loading]="loading()"
|
|
32
|
-
#bodyWrap
|
|
33
|
-
>
|
|
34
|
-
<table
|
|
35
|
-
mat-table
|
|
36
|
-
[dataSource]="dataSource"
|
|
37
|
-
class="shared-table__mat-table shared-table__mat-table--body"
|
|
38
|
-
>
|
|
39
|
-
@for (column of columns(); track columnTrackBy($index, column)) {
|
|
40
|
-
<ng-container [matColumnDef]="columnId(column)">
|
|
41
|
-
<td
|
|
42
|
-
mat-cell
|
|
43
|
-
*matCellDef="let row; let i = index"
|
|
44
|
-
[style.text-align]="resolveTextAlign(column)"
|
|
45
|
-
[style.width]="resolveWidth(column)"
|
|
46
|
-
>
|
|
47
|
-
@if (cellTemplates[column.key]) {
|
|
48
|
-
<ng-container
|
|
49
|
-
[ngTemplateOutlet]="cellTemplates[column.key]"
|
|
50
|
-
[ngTemplateOutletContext]="{
|
|
51
|
-
$implicit: row,
|
|
52
|
-
index: i,
|
|
53
|
-
column: column,
|
|
54
|
-
}"
|
|
55
|
-
></ng-container>
|
|
56
|
-
} @else {
|
|
57
|
-
{{ getCellValue(column, row, i) }}
|
|
58
|
-
}
|
|
59
|
-
</td>
|
|
60
|
-
</ng-container>
|
|
61
|
-
}
|
|
62
|
-
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
|
63
|
-
<tr mat-no-data-row>
|
|
64
|
-
<td
|
|
65
|
-
class="shared-table__empty"
|
|
66
|
-
[attr.colspan]="displayedColumns.length || 1"
|
|
67
|
-
>
|
|
68
|
-
|
|
69
|
-
<span>loading: {{ loading() }}</span>
|
|
70
|
-
@if (!loading()) {
|
|
71
|
-
{{ emptyState() }}
|
|
72
|
-
}
|
|
73
|
-
</td>
|
|
74
|
-
</tr>
|
|
75
|
-
</table>
|
|
76
|
-
@if (loading()) {
|
|
77
|
-
<div class="shared-table__loading-overlay">
|
|
78
|
-
<mat-spinner
|
|
79
|
-
class="shared-table__loading-spinner"
|
|
80
|
-
[diameter]="48"
|
|
81
|
-
[strokeWidth]="4"
|
|
82
|
-
></mat-spinner>
|
|
83
|
-
</div>
|
|
84
|
-
}
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
@if (shouldRenderPaginator()) {
|
|
89
|
-
<mat-paginator
|
|
90
|
-
class="shared-table__paginator"
|
|
91
|
-
[length]="totalElements() ?? data().length"
|
|
92
|
-
[pageSize]="pageSize()"
|
|
93
|
-
[pageSizeOptions]="pageSizeOptions()"
|
|
94
|
-
></mat-paginator>
|
|
95
|
-
}
|
|
96
|
-
</figure>
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import {
|
|
3
|
-
AfterContentInit,
|
|
4
|
-
AfterViewInit,
|
|
5
|
-
Component,
|
|
6
|
-
ContentChildren,
|
|
7
|
-
DestroyRef,
|
|
8
|
-
ElementRef,
|
|
9
|
-
EventEmitter,
|
|
10
|
-
effect,
|
|
11
|
-
input,
|
|
12
|
-
OnDestroy,
|
|
13
|
-
Output,
|
|
14
|
-
QueryList,
|
|
15
|
-
ViewChild,
|
|
16
|
-
inject,
|
|
17
|
-
} from '@angular/core';
|
|
18
|
-
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
|
19
|
-
import { MatPaginator, MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
|
20
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
21
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
22
|
-
import { SharedTableCellTemplateDirective } from './shared-table-cell-template.directive';
|
|
23
|
-
|
|
24
|
-
export interface TablePageEvent {
|
|
25
|
-
pageIndex: number;
|
|
26
|
-
pageSize: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface SharedTableColumn<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
30
|
-
key: string;
|
|
31
|
-
header: string;
|
|
32
|
-
align?: 'start' | 'center' | 'end';
|
|
33
|
-
width?: string;
|
|
34
|
-
cell?: (row: T, index: number) => unknown;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Component({
|
|
38
|
-
selector: 'lib-shared-table, shared-table',
|
|
39
|
-
standalone: true,
|
|
40
|
-
imports: [CommonModule, MatTableModule, MatPaginatorModule, MatProgressSpinnerModule],
|
|
41
|
-
templateUrl: './shared-table.component.html',
|
|
42
|
-
styleUrl: './shared-table.component.css'
|
|
43
|
-
})
|
|
44
|
-
export class SharedTableComponent<T extends Record<string, unknown> = Record<string, unknown>>
|
|
45
|
-
implements AfterContentInit, AfterViewInit, OnDestroy {
|
|
46
|
-
readonly columns = input.required<ReadonlyArray<SharedTableColumn<T>>>();
|
|
47
|
-
readonly data = input.required<ReadonlyArray<T>>();
|
|
48
|
-
readonly caption = input<string | undefined>();
|
|
49
|
-
readonly emptyState = input('Sin registros disponibles');
|
|
50
|
-
readonly loading = input(false);
|
|
51
|
-
readonly showPaginator = input(true);
|
|
52
|
-
readonly pageSize = input(10);
|
|
53
|
-
readonly pageSizeOptions = input<ReadonlyArray<number>>([5, 10, 20]);
|
|
54
|
-
readonly enableRowClick = input(false);
|
|
55
|
-
readonly totalElements = input<number | undefined>();
|
|
56
|
-
@Output() rowClick = new EventEmitter<T>();
|
|
57
|
-
@Output() pageChange = new EventEmitter<TablePageEvent>();
|
|
58
|
-
@ContentChildren(SharedTableCellTemplateDirective, { descendants: true })
|
|
59
|
-
cellTemplatesQuery!: QueryList<SharedTableCellTemplateDirective>;
|
|
60
|
-
cellTemplates: Record<string, SharedTableCellTemplateDirective['template']> = {};
|
|
61
|
-
private removeScrollSync: (() => void) | null = null;
|
|
62
|
-
private _paginator?: MatPaginator;
|
|
63
|
-
private readonly destroyRef = inject(DestroyRef);
|
|
64
|
-
|
|
65
|
-
readonly dataSource = new MatTableDataSource<T>();
|
|
66
|
-
displayedColumns: string[] = [];
|
|
67
|
-
|
|
68
|
-
constructor() {
|
|
69
|
-
effect(() => {
|
|
70
|
-
const columns = this.columns();
|
|
71
|
-
this.displayedColumns = columns.map((column) => String(column.key));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
effect(() => {
|
|
75
|
-
const rows = this.data();
|
|
76
|
-
this.dataSource.data = rows.slice();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@ViewChild(MatPaginator) set paginator(paginator: MatPaginator | undefined) {
|
|
81
|
-
this._paginator = paginator;
|
|
82
|
-
// En modo server-side (totalElements definido) NO conectamos al dataSource
|
|
83
|
-
// para que Material no intente paginar los datos localmente
|
|
84
|
-
if (this.totalElements() === undefined) {
|
|
85
|
-
this.dataSource.paginator = paginator ?? null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@ViewChild('headerWrap') headerWrapRef?: ElementRef<HTMLDivElement>;
|
|
90
|
-
@ViewChild('bodyWrap') bodyWrapRef?: ElementRef<HTMLDivElement>;
|
|
91
|
-
|
|
92
|
-
ngAfterViewInit(): void {
|
|
93
|
-
const header = this.headerWrapRef?.nativeElement;
|
|
94
|
-
const body = this.bodyWrapRef?.nativeElement;
|
|
95
|
-
if (header && body) {
|
|
96
|
-
const onScroll = () => { header.scrollLeft = body.scrollLeft; };
|
|
97
|
-
body.addEventListener('scroll', onScroll);
|
|
98
|
-
this.removeScrollSync = () => body.removeEventListener('scroll', onScroll);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Modo server-side: escuchar eventos del paginator y emitirlos hacia arriba
|
|
102
|
-
if (this._paginator && this.totalElements() !== undefined) {
|
|
103
|
-
this._paginator.page.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event: PageEvent) => {
|
|
104
|
-
this.pageChange.emit({ pageIndex: event.pageIndex, pageSize: event.pageSize });
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
ngAfterContentInit(): void {
|
|
110
|
-
const rebuildTemplateMap = () => {
|
|
111
|
-
const map: Record<string, SharedTableCellTemplateDirective['template']> = {};
|
|
112
|
-
this.cellTemplatesQuery.forEach((entry) => {
|
|
113
|
-
if (entry.key) {
|
|
114
|
-
map[entry.key] = entry.template;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
this.cellTemplates = map;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
rebuildTemplateMap();
|
|
121
|
-
this.cellTemplatesQuery.changes
|
|
122
|
-
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
123
|
-
.subscribe(() => rebuildTemplateMap());
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
ngOnDestroy(): void {
|
|
127
|
-
this.removeScrollSync?.();
|
|
128
|
-
this.removeScrollSync = null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getCellValue(column: SharedTableColumn<T>, row: T, index: number): unknown {
|
|
132
|
-
if (column.cell) {
|
|
133
|
-
return column.cell(row, index);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const key = column.key as keyof T;
|
|
137
|
-
const fallbackKey = column.key as keyof typeof row;
|
|
138
|
-
return (row?.[key] ?? row?.[fallbackKey]) ?? '';
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
columnId(column: SharedTableColumn<T>): string {
|
|
142
|
-
return String(column.key);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
columnTrackBy = (_: number, column: SharedTableColumn<T>) => column.key;
|
|
146
|
-
|
|
147
|
-
resolveTextAlign(column: SharedTableColumn<T>): 'start' | 'center' | 'end' {
|
|
148
|
-
return column.align ?? 'start';
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
resolveWidth(column: SharedTableColumn<T>): string | null {
|
|
152
|
-
return column.width ?? null;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
shouldRenderPaginator(): boolean {
|
|
156
|
-
return this.showPaginator();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
onRowClick(event: MouseEvent, row: T): void {
|
|
160
|
-
if (!this.enableRowClick()) return;
|
|
161
|
-
|
|
162
|
-
const el = event.target as HTMLElement | null;
|
|
163
|
-
// Evita abrir el side modal si el click fue sobre un elemento interactivo (acciones dentro de la fila)
|
|
164
|
-
if (el?.closest('button, a, input, textarea, select, [role="button"], mat-icon, mat-slide-toggle, mat-checkbox')) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.rowClick.emit(row);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export { SharedTableCellTemplateDirective } from './shared-table-cell-template.directive';
|