innoboxrr-vue-datatable 1.3.3 → 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/README.md +198 -198
- package/index.js +3 -3
- package/package.json +59 -25
- package/src/DataTable.vue +426 -384
- package/src/components/DataTableComponent.vue +183 -171
- package/src/components/DisabledLinkComponent.vue +39 -49
- package/src/components/IconLinkComponent.vue +65 -79
- package/src/components/IconRouteComponent.vue +71 -85
- package/src/components/NavDropdownComponent.vue +55 -62
- package/src/components/PaginationComponent.vue +79 -110
- package/src/components/SelectPaginationComponent.vue +110 -142
package/README.md
CHANGED
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
# InnoboxRR Vue DataTable
|
|
3
|
-
|
|
4
|
-
**InnoboxRR Vue DataTable** es un paquete avanzado para manejar tablas de datos en aplicaciones Vue 3, con soporte para filtros, ordenación, paginación, personalización de columnas y componentes dinámicos. Este README incluye instrucciones detalladas para configurar tanto el entorno Vue como los archivos de configuración necesarios.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Índice
|
|
9
|
-
|
|
10
|
-
1. [Instalación](#instalación)
|
|
11
|
-
2. [Configuración en Vue](#configuración-en-vue)
|
|
12
|
-
3. [Archivo de Configuración](#archivo-de-configuración)
|
|
13
|
-
4. [Uso de DataTable](#uso-de-datatable)
|
|
14
|
-
5. [Personalización](#personalización)
|
|
15
|
-
6. [CRUD y Políticas](#crud-y-políticas)
|
|
16
|
-
7. [Ejemplo Completo](#ejemplo-completo)
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Instalación
|
|
21
|
-
|
|
22
|
-
### Paso 1: Instalar el paquete
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install innoboxrr-vue-datatable innoboxrr-http-request
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Configuración en Vue
|
|
31
|
-
|
|
32
|
-
1. **Registrar el paquete:**
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
// main.js
|
|
36
|
-
import { createApp } from 'vue';
|
|
37
|
-
import App from './App.vue';
|
|
38
|
-
import DataTable from 'innoboxrr-vue-datatable';
|
|
39
|
-
|
|
40
|
-
const app = createApp(App);
|
|
41
|
-
app.component('DataTable', DataTable);
|
|
42
|
-
app.mount('#app');
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
2. **Registrar los componentes globales necesarios:**
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
// main.js
|
|
49
|
-
import ClipboardInput from './components/ClipboardInput.vue';
|
|
50
|
-
|
|
51
|
-
app.component('ClipboardInput', ClipboardInput);
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Archivo de Configuración
|
|
57
|
-
|
|
58
|
-
Crea un archivo de configuración, por ejemplo, `dataTableConfig.js`, para centralizar la lógica asociada a tus tablas y modelos.
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
import makeHttpRequest from 'innoboxrr-http-request';
|
|
62
|
-
import ClipboardInput from '@components/ClipboardInput.vue';
|
|
63
|
-
|
|
64
|
-
export const API_ROUTE_PREFIX = 'api.example.';
|
|
65
|
-
export const CSRF_TOKEN = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
|
66
|
-
|
|
67
|
-
export let filters = {};
|
|
68
|
-
|
|
69
|
-
export const strings = {
|
|
70
|
-
crudActions: {
|
|
71
|
-
create: { name: 'Create', icon: 'fa-plus' },
|
|
72
|
-
export: { name: 'Export', icon: 'fa-download' },
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const setFilters = (newFilters = {}) => {
|
|
77
|
-
filters = { ...filters, ...newFilters };
|
|
78
|
-
return filters;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const getFilters = () => filters;
|
|
82
|
-
|
|
83
|
-
export const crudActions = () => [
|
|
84
|
-
{
|
|
85
|
-
id: 'create',
|
|
86
|
-
name: strings.crudActions.create.name,
|
|
87
|
-
callback: 'createModel',
|
|
88
|
-
icon: strings.crudActions.create.icon,
|
|
89
|
-
route: true,
|
|
90
|
-
params: { to: { name: 'CreateExample', params: {} } },
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
export const dataTableComponents = () => ({
|
|
95
|
-
ClipboardInput,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
export const dataTableHead = () => [
|
|
99
|
-
{ id: 'id', value: 'ID', sortable: true },
|
|
100
|
-
{ id: 'name', value: 'Name', sortable: true },
|
|
101
|
-
{ id: 'description', value: 'Description', sortable: false },
|
|
102
|
-
{ id: 'link', value: 'Link', component: 'ClipboardInput', parser: (value) => ({ value }) },
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
export const dataTableSort = () => ({
|
|
106
|
-
id: 'asc',
|
|
107
|
-
name: 'asc',
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
export const indexModel = (filters = {}) =>
|
|
111
|
-
makeHttpRequest('get', route(API_ROUTE_PREFIX + 'index'), { _token: CSRF_TOKEN, ...filters });
|
|
112
|
-
|
|
113
|
-
export const createModel = (data) =>
|
|
114
|
-
makeHttpRequest('post', route(API_ROUTE_PREFIX + 'create'), { _token: CSRF_TOKEN, ...data });
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Uso de DataTable
|
|
120
|
-
|
|
121
|
-
```vue
|
|
122
|
-
<template>
|
|
123
|
-
<data-table
|
|
124
|
-
title="Example Table"
|
|
125
|
-
:data-url="dataUrl"
|
|
126
|
-
data-method="get"
|
|
127
|
-
:model="model"
|
|
128
|
-
:external-filters="externalFilters"
|
|
129
|
-
:form-filters="formFilters"
|
|
130
|
-
:extra-params="extraParams"
|
|
131
|
-
:hide-columns="hideColumns"
|
|
132
|
-
:has-actions="true"
|
|
133
|
-
:has-filter="true"
|
|
134
|
-
>
|
|
135
|
-
<template v-slot:filterForm>
|
|
136
|
-
<filter-form @submit="updateFormFilters" />
|
|
137
|
-
</template>
|
|
138
|
-
</data-table>
|
|
139
|
-
</template>
|
|
140
|
-
|
|
141
|
-
<script>
|
|
142
|
-
import DataTable from 'innoboxrr-vue-datatable';
|
|
143
|
-
import FilterForm from './FilterForm.vue';
|
|
144
|
-
import * as model from './dataTableConfig';
|
|
145
|
-
|
|
146
|
-
export default {
|
|
147
|
-
components: { DataTable, FilterForm },
|
|
148
|
-
data() {
|
|
149
|
-
return {
|
|
150
|
-
dataUrl: '/api/example',
|
|
151
|
-
model,
|
|
152
|
-
externalFilters: {},
|
|
153
|
-
formFilters: {},
|
|
154
|
-
extraParams: {},
|
|
155
|
-
hideColumns: [],
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
methods: {
|
|
159
|
-
updateFormFilters(filters) {
|
|
160
|
-
this.formFilters = filters;
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
</script>
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Personalización
|
|
170
|
-
|
|
171
|
-
1. **Cabezeras de tabla (dataTableHead):**
|
|
172
|
-
Define las columnas de la tabla en el archivo de configuración.
|
|
173
|
-
|
|
174
|
-
2. **Filtros externos e internos:**
|
|
175
|
-
Usa `formFilters` para los filtros internos y `externalFilters` para filtros definidos fuera del componente.
|
|
176
|
-
|
|
177
|
-
3. **Componentes personalizados:**
|
|
178
|
-
Registra componentes como `ClipboardInput` para columnas dinámicas.
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## CRUD y Políticas
|
|
183
|
-
|
|
184
|
-
1. **Definir acciones CRUD (crudActions):**
|
|
185
|
-
Asigna iconos, nombres y rutas a las acciones.
|
|
186
|
-
|
|
187
|
-
2. **Petición de datos:**
|
|
188
|
-
Usa funciones como `indexModel` y `createModel` para interactuar con el backend.
|
|
189
|
-
|
|
190
|
-
3. **Políticas:**
|
|
191
|
-
Integra validaciones de acceso por políticas usando rutas predefinidas.
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## Ejemplo Completo
|
|
196
|
-
|
|
197
|
-
Revisa la sección de ejemplos en los apartados anteriores.
|
|
198
|
-
Para más información, consulta la [documentación oficial del paquete](https://github.com/innoboxrr/vue-datatable).
|
|
1
|
+
|
|
2
|
+
# InnoboxRR Vue DataTable
|
|
3
|
+
|
|
4
|
+
**InnoboxRR Vue DataTable** es un paquete avanzado para manejar tablas de datos en aplicaciones Vue 3, con soporte para filtros, ordenación, paginación, personalización de columnas y componentes dinámicos. Este README incluye instrucciones detalladas para configurar tanto el entorno Vue como los archivos de configuración necesarios.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Índice
|
|
9
|
+
|
|
10
|
+
1. [Instalación](#instalación)
|
|
11
|
+
2. [Configuración en Vue](#configuración-en-vue)
|
|
12
|
+
3. [Archivo de Configuración](#archivo-de-configuración)
|
|
13
|
+
4. [Uso de DataTable](#uso-de-datatable)
|
|
14
|
+
5. [Personalización](#personalización)
|
|
15
|
+
6. [CRUD y Políticas](#crud-y-políticas)
|
|
16
|
+
7. [Ejemplo Completo](#ejemplo-completo)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Instalación
|
|
21
|
+
|
|
22
|
+
### Paso 1: Instalar el paquete
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install innoboxrr-vue-datatable innoboxrr-http-request
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Configuración en Vue
|
|
31
|
+
|
|
32
|
+
1. **Registrar el paquete:**
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// main.js
|
|
36
|
+
import { createApp } from 'vue';
|
|
37
|
+
import App from './App.vue';
|
|
38
|
+
import DataTable from 'innoboxrr-vue-datatable';
|
|
39
|
+
|
|
40
|
+
const app = createApp(App);
|
|
41
|
+
app.component('DataTable', DataTable);
|
|
42
|
+
app.mount('#app');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. **Registrar los componentes globales necesarios:**
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
// main.js
|
|
49
|
+
import ClipboardInput from './components/ClipboardInput.vue';
|
|
50
|
+
|
|
51
|
+
app.component('ClipboardInput', ClipboardInput);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Archivo de Configuración
|
|
57
|
+
|
|
58
|
+
Crea un archivo de configuración, por ejemplo, `dataTableConfig.js`, para centralizar la lógica asociada a tus tablas y modelos.
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import makeHttpRequest from 'innoboxrr-http-request';
|
|
62
|
+
import ClipboardInput from '@components/ClipboardInput.vue';
|
|
63
|
+
|
|
64
|
+
export const API_ROUTE_PREFIX = 'api.example.';
|
|
65
|
+
export const CSRF_TOKEN = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
|
66
|
+
|
|
67
|
+
export let filters = {};
|
|
68
|
+
|
|
69
|
+
export const strings = {
|
|
70
|
+
crudActions: {
|
|
71
|
+
create: { name: 'Create', icon: 'fa-plus' },
|
|
72
|
+
export: { name: 'Export', icon: 'fa-download' },
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const setFilters = (newFilters = {}) => {
|
|
77
|
+
filters = { ...filters, ...newFilters };
|
|
78
|
+
return filters;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const getFilters = () => filters;
|
|
82
|
+
|
|
83
|
+
export const crudActions = () => [
|
|
84
|
+
{
|
|
85
|
+
id: 'create',
|
|
86
|
+
name: strings.crudActions.create.name,
|
|
87
|
+
callback: 'createModel',
|
|
88
|
+
icon: strings.crudActions.create.icon,
|
|
89
|
+
route: true,
|
|
90
|
+
params: { to: { name: 'CreateExample', params: {} } },
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
export const dataTableComponents = () => ({
|
|
95
|
+
ClipboardInput,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const dataTableHead = () => [
|
|
99
|
+
{ id: 'id', value: 'ID', sortable: true },
|
|
100
|
+
{ id: 'name', value: 'Name', sortable: true },
|
|
101
|
+
{ id: 'description', value: 'Description', sortable: false },
|
|
102
|
+
{ id: 'link', value: 'Link', component: 'ClipboardInput', parser: (value) => ({ value }) },
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
export const dataTableSort = () => ({
|
|
106
|
+
id: 'asc',
|
|
107
|
+
name: 'asc',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const indexModel = (filters = {}) =>
|
|
111
|
+
makeHttpRequest('get', route(API_ROUTE_PREFIX + 'index'), { _token: CSRF_TOKEN, ...filters });
|
|
112
|
+
|
|
113
|
+
export const createModel = (data) =>
|
|
114
|
+
makeHttpRequest('post', route(API_ROUTE_PREFIX + 'create'), { _token: CSRF_TOKEN, ...data });
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Uso de DataTable
|
|
120
|
+
|
|
121
|
+
```vue
|
|
122
|
+
<template>
|
|
123
|
+
<data-table
|
|
124
|
+
title="Example Table"
|
|
125
|
+
:data-url="dataUrl"
|
|
126
|
+
data-method="get"
|
|
127
|
+
:model="model"
|
|
128
|
+
:external-filters="externalFilters"
|
|
129
|
+
:form-filters="formFilters"
|
|
130
|
+
:extra-params="extraParams"
|
|
131
|
+
:hide-columns="hideColumns"
|
|
132
|
+
:has-actions="true"
|
|
133
|
+
:has-filter="true"
|
|
134
|
+
>
|
|
135
|
+
<template v-slot:filterForm>
|
|
136
|
+
<filter-form @submit="updateFormFilters" />
|
|
137
|
+
</template>
|
|
138
|
+
</data-table>
|
|
139
|
+
</template>
|
|
140
|
+
|
|
141
|
+
<script>
|
|
142
|
+
import DataTable from 'innoboxrr-vue-datatable';
|
|
143
|
+
import FilterForm from './FilterForm.vue';
|
|
144
|
+
import * as model from './dataTableConfig';
|
|
145
|
+
|
|
146
|
+
export default {
|
|
147
|
+
components: { DataTable, FilterForm },
|
|
148
|
+
data() {
|
|
149
|
+
return {
|
|
150
|
+
dataUrl: '/api/example',
|
|
151
|
+
model,
|
|
152
|
+
externalFilters: {},
|
|
153
|
+
formFilters: {},
|
|
154
|
+
extraParams: {},
|
|
155
|
+
hideColumns: [],
|
|
156
|
+
};
|
|
157
|
+
},
|
|
158
|
+
methods: {
|
|
159
|
+
updateFormFilters(filters) {
|
|
160
|
+
this.formFilters = filters;
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Personalización
|
|
170
|
+
|
|
171
|
+
1. **Cabezeras de tabla (dataTableHead):**
|
|
172
|
+
Define las columnas de la tabla en el archivo de configuración.
|
|
173
|
+
|
|
174
|
+
2. **Filtros externos e internos:**
|
|
175
|
+
Usa `formFilters` para los filtros internos y `externalFilters` para filtros definidos fuera del componente.
|
|
176
|
+
|
|
177
|
+
3. **Componentes personalizados:**
|
|
178
|
+
Registra componentes como `ClipboardInput` para columnas dinámicas.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## CRUD y Políticas
|
|
183
|
+
|
|
184
|
+
1. **Definir acciones CRUD (crudActions):**
|
|
185
|
+
Asigna iconos, nombres y rutas a las acciones.
|
|
186
|
+
|
|
187
|
+
2. **Petición de datos:**
|
|
188
|
+
Usa funciones como `indexModel` y `createModel` para interactuar con el backend.
|
|
189
|
+
|
|
190
|
+
3. **Políticas:**
|
|
191
|
+
Integra validaciones de acceso por políticas usando rutas predefinidas.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Ejemplo Completo
|
|
196
|
+
|
|
197
|
+
Revisa la sección de ejemplos en los apartados anteriores.
|
|
198
|
+
Para más información, consulta la [documentación oficial del paquete](https://github.com/innoboxrr/vue-datatable).
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import DataTable from './src/DataTable.vue';
|
|
2
|
-
|
|
3
|
-
export default DataTable;
|
|
1
|
+
import DataTable from './src/DataTable.vue';
|
|
2
|
+
|
|
3
|
+
export default DataTable;
|
package/package.json
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "innoboxrr-vue-datatable",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Datatable para vue3",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "innoboxrr-vue-datatable",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Datatable para vue3",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "vitest run",
|
|
8
|
+
"test:watch": "vitest"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/innoboxrr/vue-datatable.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"vue3",
|
|
16
|
+
"datatable",
|
|
17
|
+
"table",
|
|
18
|
+
"crud"
|
|
19
|
+
],
|
|
20
|
+
"author": "Homero Raul Vargas Cruz",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/innoboxrr/vue-datatable/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/innoboxrr/vue-datatable#readme",
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./index.js",
|
|
32
|
+
"./src/*": "./src/*"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"index.js",
|
|
36
|
+
"src"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"*.css",
|
|
40
|
+
"*.vue"
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"innoboxrr-form-core": "^2.0.0",
|
|
44
|
+
"vue": "^3.5.0",
|
|
45
|
+
"vue-router": "^4.5.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"axios": "^1.7.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
52
|
+
"@vue/test-utils": "^2.4.6",
|
|
53
|
+
"jsdom": "^25.0.0",
|
|
54
|
+
"vite": "^7.1.0",
|
|
55
|
+
"vitest": "^3.0.0",
|
|
56
|
+
"vue": "^3.5.0",
|
|
57
|
+
"vue-router": "^4.5.0"
|
|
58
|
+
}
|
|
59
|
+
}
|