grav-svelte 0.0.53 → 0.0.55
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/dist/CRUD/CrudWrapper.svelte +17 -3
- package/dist/CRUD/CrudWrapper.svelte.d.ts +1 -0
- package/dist/CRUD/PaginationCRUD.css +106 -0
- package/dist/CRUD/PaginationCRUD.svelte +17 -28
- package/dist/CRUD/PaginationCRUD.svelte.d.ts +0 -2
- package/dist/generics.d.ts +5 -1
- package/dist/generics.js +6 -2
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
export let Titulo_Crud: string;
|
|
23
23
|
export let dragEnabled: boolean = false;
|
|
24
24
|
export let orderField: string = "inOrden";
|
|
25
|
+
export let minHeightScreen: boolean = false;
|
|
25
26
|
|
|
26
27
|
// Event handlers from parent
|
|
27
28
|
export let onFilter: (filters: FiltrosI[]) => void;
|
|
@@ -67,14 +68,23 @@
|
|
|
67
68
|
onFilter(Filtros);
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
function generateFileName(title: string): string {
|
|
72
|
+
const today = new Date();
|
|
73
|
+
const dateStr = today.toISOString().split('T')[0]; // YYYY-MM-DD
|
|
74
|
+
const cleanTitle = title.replace(/[^a-zA-Z0-9\s]/g, ''); // Remove special chars
|
|
75
|
+
return `${cleanTitle} - ${dateStr}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
function handleExport(type: "excel" | "pdf") {
|
|
71
79
|
const table = document.querySelector("table");
|
|
72
80
|
if (!table) return;
|
|
73
81
|
|
|
82
|
+
const fileName = generateFileName(Titulo_Crud);
|
|
83
|
+
|
|
74
84
|
if (type === "excel") {
|
|
75
|
-
html_table_to_excel("xlsx",
|
|
85
|
+
html_table_to_excel("xlsx", fileName, table);
|
|
76
86
|
} else {
|
|
77
|
-
createPDF(table);
|
|
87
|
+
createPDF(table, fileName);
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
|
|
@@ -89,7 +99,7 @@
|
|
|
89
99
|
}
|
|
90
100
|
</script>
|
|
91
101
|
|
|
92
|
-
<div class="crud-wrapper">
|
|
102
|
+
<div class="crud-wrapper" class:min-height-screen={minHeightScreen}>
|
|
93
103
|
<CrudFilters
|
|
94
104
|
bind:PageSize
|
|
95
105
|
bind:Filtros
|
|
@@ -138,6 +148,10 @@
|
|
|
138
148
|
|
|
139
149
|
<style>
|
|
140
150
|
.crud-wrapper {
|
|
151
|
+
min-height: auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.crud-wrapper.min-height-screen {
|
|
141
155
|
min-height: 100vh;
|
|
142
156
|
}
|
|
143
157
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* Pagination CRUD Styles */
|
|
2
|
+
.pagination-container {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: 0.75rem;
|
|
7
|
+
padding-bottom: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.pagination-button {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
padding: 0.5rem;
|
|
13
|
+
border-radius: var(--grav-crud-button-border-radius, 0.5rem);
|
|
14
|
+
border-width: var(--grav-crud-button-border-width, 1.5px);
|
|
15
|
+
border-style: solid;
|
|
16
|
+
font-family: var(--grav-crud-button-font-family, 'mundial', sans-serif);
|
|
17
|
+
font-size: var(--grav-crud-button-font-size, 0.875rem);
|
|
18
|
+
font-weight: var(--grav-crud-button-font-weight, 500);
|
|
19
|
+
line-height: var(--grav-crud-button-line-height, 1.5);
|
|
20
|
+
transition: all 0.2s ease;
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.pagination-button:disabled {
|
|
25
|
+
opacity: 0.5;
|
|
26
|
+
cursor: not-allowed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.pagination-button-nav {
|
|
30
|
+
border-color: var(--grav-crud-color-neutral);
|
|
31
|
+
color: var(--grav-crud-color-neutral);
|
|
32
|
+
background-color: transparent;
|
|
33
|
+
font-size: var(--grav-crud-header-font-size, 0.75rem);
|
|
34
|
+
font-weight: var(--grav-crud-header-font-weight, 600);
|
|
35
|
+
text-transform: uppercase;
|
|
36
|
+
letter-spacing: 0.05em;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pagination-button-nav:hover:not(:disabled) {
|
|
40
|
+
background-color: var(--grav-crud-color-neutral);
|
|
41
|
+
color: var(--grav-crud-color-button);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.pagination-button-nav.first {
|
|
45
|
+
margin-right: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.pagination-button-nav.last {
|
|
49
|
+
margin-left: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.pagination-button-page {
|
|
53
|
+
padding: 0.25rem;
|
|
54
|
+
width: 2rem;
|
|
55
|
+
text-align: center;
|
|
56
|
+
border-bottom-width: 2px;
|
|
57
|
+
border-bottom-style: solid;
|
|
58
|
+
border-bottom-color: transparent;
|
|
59
|
+
margin-right: 0.25rem;
|
|
60
|
+
border-radius: 0;
|
|
61
|
+
border-left: none;
|
|
62
|
+
border-right: none;
|
|
63
|
+
border-top: none;
|
|
64
|
+
color: var(--grav-crud-color-neutral);
|
|
65
|
+
background-color: transparent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.pagination-button-page:hover {
|
|
69
|
+
background-color: var(--grav-crud-color-light);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pagination-button-page.active {
|
|
73
|
+
border-bottom-color: var(--grav-crud-color-neutral);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.pagination-button-arrow {
|
|
77
|
+
border: none;
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
color: var(--grav-crud-color-neutral);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.pagination-button-arrow:hover:not(:disabled) {
|
|
83
|
+
background-color: var(--grav-crud-color-light);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.pagination-ellipsis {
|
|
87
|
+
padding: 0 0.5rem;
|
|
88
|
+
color: var(--grav-crud-color-neutral);
|
|
89
|
+
font-family: var(--grav-crud-button-font-family, 'mundial', sans-serif);
|
|
90
|
+
font-size: var(--grav-crud-button-font-size, 0.875rem);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.pagination-info-container {
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
margin: 0.5rem 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.pagination-info {
|
|
101
|
+
font-family: var(--grav-crud-cell-font-family, 'mundial', sans-serif);
|
|
102
|
+
font-size: var(--grav-crud-cell-font-size, 0.875rem);
|
|
103
|
+
font-weight: var(--grav-crud-cell-font-weight, 400);
|
|
104
|
+
line-height: var(--grav-crud-cell-line-height, 1.5);
|
|
105
|
+
color: var(--grav-crud-color-neutral);
|
|
106
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import "./PaginationCRUD.css";
|
|
4
|
+
import "../typography.css";
|
|
3
5
|
const dispatch = createEventDispatcher();
|
|
4
6
|
|
|
5
7
|
export let perPage;
|
|
6
8
|
export let totalRows;
|
|
7
9
|
export let currentPage = 1;
|
|
8
|
-
export let theme = "black";
|
|
9
10
|
|
|
10
11
|
$: totalPages = Math.ceil(totalRows / perPage);
|
|
11
12
|
$: start = (currentPage - 1) * perPage;
|
|
@@ -25,24 +26,24 @@
|
|
|
25
26
|
</script>
|
|
26
27
|
|
|
27
28
|
{#if totalRows && totalRows > perPage}
|
|
28
|
-
<div class="
|
|
29
|
+
<div class="pagination-container">
|
|
29
30
|
<button
|
|
30
31
|
on:click={() => handlePageChange(1)}
|
|
31
32
|
disabled={currentPage === 1}
|
|
32
|
-
class="
|
|
33
|
+
class="pagination-button pagination-button-nav first"
|
|
33
34
|
aria-label="Go to first page"
|
|
34
35
|
>
|
|
35
|
-
<i class="fas fa-chevron-left"
|
|
36
|
-
<i class="fas fa-chevron-left"
|
|
36
|
+
<i class="fas fa-chevron-left"></i>
|
|
37
|
+
<i class="fas fa-chevron-left"></i>
|
|
37
38
|
</button>
|
|
38
39
|
|
|
39
40
|
<button
|
|
40
41
|
on:click={() => handlePageChange(currentPage - 1)}
|
|
41
42
|
disabled={currentPage === 1}
|
|
42
|
-
class="
|
|
43
|
+
class="pagination-button pagination-button-arrow"
|
|
43
44
|
aria-label="Go to previous page"
|
|
44
45
|
>
|
|
45
|
-
<i class="fas fa-chevron-left"
|
|
46
|
+
<i class="fas fa-chevron-left"></i>
|
|
46
47
|
</button>
|
|
47
48
|
|
|
48
49
|
{#each Array(totalPages) as _, i}
|
|
@@ -50,53 +51,41 @@
|
|
|
50
51
|
{#if shouldShowPage(pageNum)}
|
|
51
52
|
<button
|
|
52
53
|
on:click={() => handlePageChange(pageNum)}
|
|
53
|
-
class="
|
|
54
|
-
currentPage
|
|
55
|
-
? 'border-black'
|
|
56
|
-
: ''}"
|
|
54
|
+
class="pagination-button pagination-button-page {pageNum === currentPage ? 'active' : ''}"
|
|
57
55
|
aria-label="Go to page {pageNum}"
|
|
58
56
|
aria-current={pageNum === currentPage ? "page" : undefined}
|
|
59
57
|
>
|
|
60
58
|
{pageNum}
|
|
61
59
|
</button>
|
|
62
60
|
{:else if shouldShowPage(i) && !shouldShowPage(i + 1)}
|
|
63
|
-
<span class="
|
|
61
|
+
<span class="pagination-ellipsis">...</span>
|
|
64
62
|
{/if}
|
|
65
63
|
{/each}
|
|
66
64
|
|
|
67
65
|
<button
|
|
68
66
|
on:click={() => handlePageChange(currentPage + 1)}
|
|
69
67
|
disabled={currentPage === totalPages}
|
|
70
|
-
class="
|
|
68
|
+
class="pagination-button pagination-button-arrow"
|
|
71
69
|
aria-label="Go to next page"
|
|
72
70
|
>
|
|
73
|
-
<i class="fas fa-chevron-right"
|
|
71
|
+
<i class="fas fa-chevron-right"></i>
|
|
74
72
|
</button>
|
|
75
73
|
|
|
76
74
|
<button
|
|
77
75
|
on:click={() => handlePageChange(totalPages)}
|
|
78
76
|
disabled={currentPage === totalPages}
|
|
79
|
-
class="
|
|
77
|
+
class="pagination-button pagination-button-nav last"
|
|
80
78
|
aria-label="Go to last page"
|
|
81
79
|
>
|
|
82
|
-
<i class="fas fa-chevron-right"
|
|
83
|
-
<i class="fas fa-chevron-right"
|
|
80
|
+
<i class="fas fa-chevron-right"></i>
|
|
81
|
+
<i class="fas fa-chevron-right"></i>
|
|
84
82
|
</button>
|
|
85
83
|
</div>
|
|
86
84
|
{/if}
|
|
87
85
|
|
|
88
|
-
<div
|
|
89
|
-
class="
|
|
90
|
-
? 'texto-pagination'
|
|
91
|
-
: 'text-white'}"
|
|
92
|
-
>
|
|
93
|
-
<p class="text-sm">
|
|
86
|
+
<div class="pagination-info-container">
|
|
87
|
+
<p class="pagination-info">
|
|
94
88
|
Mostrando: {start + 1} - {end + 1} de {totalRows} registros
|
|
95
89
|
</p>
|
|
96
90
|
</div>
|
|
97
91
|
|
|
98
|
-
<style>
|
|
99
|
-
.texto-pagination {
|
|
100
|
-
color: var(--grav-crud-color-neutral);
|
|
101
|
-
}
|
|
102
|
-
</style>
|
|
@@ -5,7 +5,6 @@ export default class PaginationCrud extends SvelteComponentTyped<{
|
|
|
5
5
|
perPage: any;
|
|
6
6
|
totalRows: any;
|
|
7
7
|
currentPage?: number | undefined;
|
|
8
|
-
theme?: string | undefined;
|
|
9
8
|
}, {
|
|
10
9
|
pageChange: CustomEvent<any>;
|
|
11
10
|
} & {
|
|
@@ -21,7 +20,6 @@ declare const __propDef: {
|
|
|
21
20
|
perPage: any;
|
|
22
21
|
totalRows: any;
|
|
23
22
|
currentPage?: number | undefined;
|
|
24
|
-
theme?: string | undefined;
|
|
25
23
|
};
|
|
26
24
|
events: {
|
|
27
25
|
pageChange: CustomEvent<any>;
|
package/dist/generics.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export function html_table_to_excel(type: any, nombreArchivo: any, tablaExport: any): void;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @param {HTMLElement} tablaExport
|
|
4
|
+
* @param {string} nombreArchivo
|
|
5
|
+
*/
|
|
6
|
+
export function createPDF(tablaExport: HTMLElement, nombreArchivo?: string): void;
|
package/dist/generics.js
CHANGED
|
@@ -27,7 +27,11 @@ function html_table_to_excel(type, nombreArchivo, tablaExport) {
|
|
|
27
27
|
XLSX.writeFile(workbook, `${nombreArchivo}.${type}`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @param {HTMLElement} tablaExport
|
|
32
|
+
* @param {string} nombreArchivo
|
|
33
|
+
*/
|
|
34
|
+
function createPDF(tablaExport, nombreArchivo = "PDF") {
|
|
31
35
|
// Crear un nuevo contenido solo con los datos limpios
|
|
32
36
|
let cleanTable = "<table>";
|
|
33
37
|
|
|
@@ -55,7 +59,7 @@ function createPDF(tablaExport) {
|
|
|
55
59
|
|
|
56
60
|
// Crear una nueva ventana para el contenido limpio
|
|
57
61
|
const win = window.open("", "", "height=700,width=700");
|
|
58
|
-
win.document.write(
|
|
62
|
+
win.document.write(`<html><head><title>${nombreArchivo}</title>`);
|
|
59
63
|
win.document.write(style); // Agregar estilos
|
|
60
64
|
win.document.write("</head><body>");
|
|
61
65
|
win.document.write(cleanTable); // Insertar la tabla limpia
|