ng-table-pg
Version:
A powerful and flexible responsive table component for Angular applications with drag-drop, filtering, pagination, and advanced responsive features
862 lines (712 loc) • 14.4 kB
CSS
/* Tailwind CSS Base Styles for ng-table-pg */
/* Solo las clases que realmente usamos en la librería */
/* Layout */
.space-y-4 > * + * {
margin-top: 1rem;
}
.space-y-6 > * + * {
margin-top: 1.5rem;
}
.space-x-2 > * + * {
margin-left: 0.5rem;
}
.flex {
display: flex;
}
.justify-between {
justify-content: space-between;
}
.items-center {
align-items: center;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
}
.flex-grow {
flex-grow: 1;
}
.gap-2 {
gap: 0.5rem;
}
/* CORRECCIONES PRINCIPALES - Responsive Table Styles */
.table-container {
position: relative;
border-radius: 0.5rem;
border: 1px solid rgb(229 231 235);
background: white;
width: 100%;
max-width: 100%;
box-sizing: border-box;
/* CRÍTICO: Contenedor debe tener overflow controlado */
overflow: hidden;
/* Altura fija para evitar desbordamiento de página */
height: auto;
max-height: 70vh; /* Máximo 70% de la altura de viewport */
}
.table-container.responsive {
/* CRÍTICO: Scroll horizontal SOLO en el contenedor de tabla */
overflow-x: auto;
overflow-y: auto; /* Scroll vertical también controlado */
-webkit-overflow-scrolling: touch;
scrollbar-width: thin;
scrollbar-color: rgb(156 163 175) rgb(243 244 246);
/* Asegurar que el scroll sea visible */
scrollbar-gutter: stable;
}
/* Scrollbar personalizada mejorada */
.table-container.responsive::-webkit-scrollbar {
height: 12px;
width: 12px;
}
.table-container.responsive::-webkit-scrollbar-track {
background: rgb(243 244 246);
border-radius: 6px;
margin: 2px;
}
.table-container.responsive::-webkit-scrollbar-thumb {
background: rgb(156 163 175);
border-radius: 6px;
border: 2px solid rgb(243 244 246);
}
.table-container.responsive::-webkit-scrollbar-thumb:hover {
background: rgb(107 114 128);
}
.table-container.responsive::-webkit-scrollbar-corner {
background: rgb(243 244 246);
}
/* Contenedor con altura máxima controlada */
.table-container.with-max-height {
max-height: var(--table-max-height, 500px);
overflow-y: auto;
}
/* Scroll Indicators mejorados */
.scroll-indicator {
position: absolute;
top: 0;
bottom: 0;
width: 30px;
pointer-events: none;
z-index: 15;
transition: opacity 0.3s ease;
}
.scroll-indicator.left {
left: 0;
background: linear-gradient(
to right,
rgba(255, 255, 255, 0.95),
rgba(255, 255, 255, 0.7),
transparent
);
border-top-left-radius: 0.5rem;
border-bottom-left-radius: 0.5rem;
}
.scroll-indicator.right {
right: 0;
background: linear-gradient(
to left,
rgba(255, 255, 255, 0.95),
rgba(255, 255, 255, 0.7),
transparent
);
border-top-right-radius: 0.5rem;
border-bottom-right-radius: 0.5rem;
}
.scroll-indicator.hidden {
opacity: 0;
}
/* Responsive Table mejorada */
.responsive-table {
width: 100%;
min-width: var(--table-min-width, 900px);
border-collapse: collapse;
table-layout: fixed; /* Cambiado a fixed para mejor control */
margin: 0;
border-spacing: 0;
/* Asegurar que la tabla no cause overflow en la página */
max-width: none;
}
.responsive-table.compact {
font-size: 0.875rem;
min-width: var(--table-min-width, 700px);
}
.responsive-table.compact th,
.responsive-table.compact td {
padding: 0.5rem 0.75rem;
}
/* Celdas optimizadas para no causar overflow */
.responsive-table th,
.responsive-table td {
vertical-align: middle;
padding: 0.75rem 1rem;
border-bottom: 1px solid rgb(229 231 235);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
/* Ancho flexible pero controlado */
min-width: 100px;
max-width: 250px;
}
/* Sticky Header mejorado */
.sticky-header {
position: sticky;
top: 0;
z-index: 25;
background: rgba(249, 250, 251, 0.95);
backdrop-filter: blur(10px);
border-bottom: 2px solid rgb(229 231 235);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.sticky-header th {
background: rgba(249, 250, 251, 0.95);
backdrop-filter: blur(10px);
}
/* Column Responsiveness */
.col-priority-1 {
/* Siempre visible */
}
.col-priority-2 {
/* Ocultar en pantallas muy pequeñas */
}
.col-priority-3 {
/* Ocultar en pantallas pequeñas */
}
/* Responsive con scroll horizontal - mantener todas las columnas */
.table-container.responsive {
overflow-x: auto ;
overflow-y: hidden ;
-webkit-overflow-scrolling: touch ;
}
.responsive-table {
table-layout: fixed ;
min-width: max-content ;
width: auto ;
}
/* Asegurar que las columnas mantengan su ancho */
.responsive-table th,
.responsive-table td {
white-space: nowrap ;
overflow: hidden ;
text-overflow: ellipsis ;
min-width: 100px ;
}
/* Forzar scroll horizontal en pantallas pequeñas */
@media (max-width: 768px) {
.table-container.responsive {
overflow-x: scroll ;
}
.responsive-table {
min-width: 1200px ;
}
}
/* Improved Cell Content */
.cell-content {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: block;
}
.cell-content.expandable {
white-space: normal;
word-wrap: break-word;
max-width: none;
line-height: 1.4;
}
.cell-content.truncate {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
white-space: normal;
line-height: 1.3;
}
/* PAGINACIÓN MEJORADA - Coherente con el diseño */
.pagination-container {
padding: 1rem 1.5rem;
border-top: 1px solid rgb(229 231 235);
background: rgb(249 250 251);
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 1rem;
min-height: 70px;
/* Asegurar que no se desborde */
width: 100%;
box-sizing: border-box;
border-bottom-left-radius: 0.5rem;
border-bottom-right-radius: 0.5rem;
}
/* Estilos del selector de elementos por página */
.pagination-container select {
height: 36px;
min-width: 70px;
padding: 0.5rem;
border: 1px solid rgb(209 213 219);
border-radius: 0.375rem;
background: white;
font-size: 0.875rem;
color: rgb(55 65 81);
cursor: pointer;
transition: all 0.2s ease;
}
.pagination-container select:hover {
border-color: rgb(156 163 175);
}
.pagination-container select:focus {
outline: none;
border-color: rgb(59 130 246);
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* Botones de paginación mejorados */
.pagination-button {
height: 36px;
width: 36px;
padding: 0;
border: 1px solid rgb(209 213 219);
border-radius: 0.375rem;
background: white;
color: rgb(55 65 81);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.875rem;
font-weight: 500;
}
.pagination-button:hover:not(:disabled) {
background: rgb(243 244 246);
border-color: rgb(156 163 175);
}
.pagination-button:disabled {
opacity: 0.5;
cursor: not-allowed;
background: rgb(249 250 251);
}
.pagination-button.active {
background: rgb(59 130 246);
border-color: rgb(59 130 246);
color: white;
}
.pagination-button.active:hover {
background: rgb(37 99 235);
border-color: rgb(37 99 235);
}
/* Texto de información de paginación */
.pagination-info {
font-size: 0.875rem;
color: rgb(75 85 99);
display: flex;
align-items: center;
gap: 0.5rem;
white-space: nowrap;
}
/* Mobile Optimizations mejoradas */
@media (max-width: 768px) {
.table-container {
margin: 0;
border-radius: 0.5rem;
border: 1px solid rgb(229 231 235);
max-height: 60vh; /* Reducido para móviles */
}
.responsive-table {
min-width: 600px;
}
.pagination-container {
flex-direction: column;
align-items: stretch;
text-align: center;
gap: 0.75rem;
padding: 1rem;
}
.pagination-info {
justify-content: center;
order: -1;
}
.mobile-stack {
display: block;
}
.mobile-stack tr {
display: block;
border: 1px solid rgb(229 231 235);
border-radius: 0.5rem;
margin-bottom: 0.5rem;
background: white;
overflow: visible;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.mobile-stack td {
display: block;
text-align: left;
border: none;
padding: 0.75rem 1rem;
white-space: normal;
word-wrap: break-word;
border-bottom: 1px solid rgb(243 244 246);
}
.mobile-stack td:last-child {
border-bottom: none;
}
.mobile-stack td:before {
content: attr(data-label);
font-weight: 600;
color: rgb(55 65 81);
display: block;
margin-bottom: 0.25rem;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.mobile-stack th {
display: none;
}
}
/* Utility Classes */
.mr-4 {
margin-right: 1rem;
}
.ml-1 {
margin-left: 0.25rem;
}
.ml-2 {
margin-left: 0.5rem;
}
.mb-1 {
margin-bottom: 0.25rem;
}
.mb-4 {
margin-bottom: 1rem;
}
.pl-3 {
padding-left: 0.75rem;
}
.pl-8 {
padding-left: 2rem;
}
.pr-4 {
padding-right: 1rem;
}
.pr-10 {
padding-right: 2.5rem;
}
.px-4 {
padding-left: 1rem;
padding-right: 1rem;
}
.px-6 {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.py-3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}
.py-4 {
padding-top: 1rem;
padding-bottom: 1rem;
}
.p-4 {
padding: 1rem;
}
.left-2 {
left: 0.5rem;
}
.top-2\.5 {
top: 0.625rem;
}
.w-full {
width: 100%;
}
.w-4 {
width: 1rem;
}
.w-5 {
width: 1.25rem;
}
.w-6 {
width: 1.5rem;
}
.w-8 {
width: 2rem;
}
.w-10 {
width: 2.5rem;
}
.w-12 {
width: 3rem;
}
.w-16 {
width: 4rem;
}
.w-20 {
width: 5rem;
}
.w-24 {
width: 6rem;
}
.w-32 {
width: 8rem;
}
.w-36 {
width: 9rem;
}
.w-40 {
width: 10rem;
}
.w-56 {
width: 14rem;
}
.w-2\/3 {
width: 66.666667%;
}
.h-4 {
height: 1rem;
}
.h-5 {
height: 1.25rem;
}
.h-6 {
height: 1.5rem;
}
.h-8 {
height: 2rem;
}
.h-10 {
height: 2.5rem;
}
.min-w-full {
min-width: 100%;
}
.bg-white {
background-color: rgb(255 255 255);
}
.bg-gray-50 {
background-color: rgb(249 250 251);
}
.bg-gray-200 {
background-color: rgb(229 231 235);
}
.text-gray-400 {
color: rgb(156 163 175);
}
.text-gray-500 {
color: rgb(107 114 128);
}
.text-gray-700 {
color: rgb(55 65 81);
}
.hover\:bg-gray-50:hover {
background-color: rgb(249 250 251);
}
.border {
border-width: 1px;
}
.border-t {
border-top-width: 1px;
}
.border-1 {
border-width: 1px;
}
.border-gray-200 {
border-color: rgb(229 231 235);
}
.border-gray-300 {
border-color: rgb(209 213 219);
}
.divide-y > * + * {
border-top-width: 1px;
}
.divide-gray-200 > * + * {
border-color: rgb(229 231 235);
}
.rounded {
border-radius: 0.25rem;
}
.rounded-md {
border-radius: 0.375rem;
}
.rounded-lg {
border-radius: 0.5rem;
}
.rounded-full {
border-radius: 9999px;
}
.overflow-hidden {
overflow: hidden;
}
.overflow-x-auto {
overflow-x: auto;
}
.text-left {
text-align: left;
}
.text-xs {
font-size: 0.75rem;
line-height: 1rem;
}
.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
}
.text-base {
font-size: 1rem;
line-height: 1.5rem;
}
.font-medium {
font-weight: 500;
}
.uppercase {
text-transform: uppercase;
}
.tracking-wider {
letter-spacing: 0.05em;
}
.titlecase {
text-transform: capitalize;
}
.cursor-pointer {
cursor: pointer;
}
.block {
display: block;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
.shadow {
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.focus\:outline-none:focus {
outline: 2px solid transparent;
outline-offset: 2px;
}
.focus\:ring-indigo-500:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity));
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0
var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0
calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow),
var(--tw-shadow, 0 0 #0000);
}
.focus\:border-indigo-500:focus {
--tw-border-opacity: 1;
border-color: rgb(99 102 241 / var(--tw-border-opacity));
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.skeleton {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: loading 1.5s infinite;
}
@keyframes loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.drop-target:hover {
background-color: #f3f4f6;
}
.cdk-drag-preview {
box-sizing: border-box;
border-radius: 4px;
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.cdk-drag-placeholder {
opacity: 0;
}
.cdk-drag-animating {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
tr.cdk-drag {
background: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.pagination-drop-zone {
min-height: 40px;
display: flex;
align-items: center;
justify-content: center;
border: 2px dashed transparent;
transition: all 0.3s ease;
}
.pagination-drop-zone.active-drop-target {
border-color: #3b82f6;
background-color: #eff6ff;
}
.pagination-drop-zone.active-drop-target button:not(:disabled) {
background-color: #3b82f6;
color: white;
}
.pagination-drop-zone.active-drop-target::after {
content: "Soltar aquí para mover a esta página";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #3b82f6;
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
}
.pagination-drop-zone button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.drop-zone {
position: relative;
}
.drop-zone::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(59, 130, 246, 0.1);
border: 2px dashed #3b82f6;
border-radius: 4px;
opacity: 0;
transition: opacity 0.2s ease;
}
.drop-zone:hover::after {
opacity: 1;
}