nexabase-report 0.1.0 → 0.1.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/README.md +68 -2
- package/dist/{html2canvas-BXLDsEU4.js → html2canvas-Dmt1hL9C.js} +2 -2
- package/dist/{html2canvas-CSJ68r_Q.js → html2canvas-MMn8dUQK.js} +1 -1
- package/dist/{html2pdf-DwP6YZUu.js → html2pdf-BumfBzwC.js} +3 -3
- package/dist/{index-BJcVIdAR.js → index-j9lAJl17.js} +24973 -24106
- package/dist/{index.es-CLzdqdqQ.js → index.es-BQC8FNVO.js} +2 -2
- package/dist/{jspdf.es.min-CDx0J4wI.js → jspdf.es.min-DIevzj7_.js} +2 -2
- package/dist/nexabase-report.es.js +1 -1
- package/dist/nexabase-report.umd.js +170 -170
- package/dist/style.css +376 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,12 @@ npm install nexabase-report
|
|
|
12
12
|
|
|
13
13
|
El Viewer se expone como Custom Element: `<nexa-viewer />`.
|
|
14
14
|
|
|
15
|
+
## Flujo real (NexaBase): cargar JSON exportado + pasar data
|
|
16
|
+
|
|
17
|
+
1. Exporta el reporte desde NexaBase y guarda el JSON en tu app (por ejemplo en `public/report.json`).
|
|
18
|
+
2. Carga ese JSON por `fetch()` y asígnalo a `definition`.
|
|
19
|
+
3. Pasa tus datos del sistema en `data`.
|
|
20
|
+
|
|
15
21
|
### 1) Vue 3
|
|
16
22
|
|
|
17
23
|
```ts
|
|
@@ -22,6 +28,23 @@ registerNexaReport();
|
|
|
22
28
|
```
|
|
23
29
|
|
|
24
30
|
```vue
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { onMounted, ref } from 'vue';
|
|
33
|
+
|
|
34
|
+
const definition = ref<any>(null);
|
|
35
|
+
const data = ref<any[]>([]);
|
|
36
|
+
|
|
37
|
+
onMounted(async () => {
|
|
38
|
+
const res = await fetch('/report.json');
|
|
39
|
+
definition.value = await res.json();
|
|
40
|
+
|
|
41
|
+
data.value = [
|
|
42
|
+
{ nombre: 'Producto A', precio: 100, cantidad: 2 },
|
|
43
|
+
{ nombre: 'Producto B', precio: 50, cantidad: 5 },
|
|
44
|
+
];
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
25
48
|
<template>
|
|
26
49
|
<nexa-viewer
|
|
27
50
|
:definition="definition"
|
|
@@ -36,14 +59,29 @@ registerNexaReport();
|
|
|
36
59
|
### 2) React
|
|
37
60
|
|
|
38
61
|
```tsx
|
|
39
|
-
import { useEffect, useRef } from 'react';
|
|
62
|
+
import { useEffect, useRef, useState } from 'react';
|
|
40
63
|
import { registerNexaReport } from 'nexabase-report';
|
|
41
64
|
import 'nexabase-report/style.css';
|
|
42
65
|
|
|
43
66
|
registerNexaReport();
|
|
44
67
|
|
|
45
|
-
export function ReportViewer(
|
|
68
|
+
export function ReportViewer() {
|
|
46
69
|
const ref = useRef<any>(null);
|
|
70
|
+
const [definition, setDefinition] = useState<any>(null);
|
|
71
|
+
const [data, setData] = useState<any[]>([]);
|
|
72
|
+
const [parameters] = useState<any>({ fechaDesde: '2026-01-01' });
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
(async () => {
|
|
76
|
+
const res = await fetch('/report.json');
|
|
77
|
+
setDefinition(await res.json());
|
|
78
|
+
setData([
|
|
79
|
+
{ nombre: 'Producto A', precio: 100, cantidad: 2 },
|
|
80
|
+
{ nombre: 'Producto B', precio: 50, cantidad: 5 },
|
|
81
|
+
]);
|
|
82
|
+
})();
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
47
85
|
useEffect(() => {
|
|
48
86
|
if (!ref.current) return;
|
|
49
87
|
ref.current.definition = definition;
|
|
@@ -55,6 +93,34 @@ export function ReportViewer({ definition, data, parameters }: any) {
|
|
|
55
93
|
}
|
|
56
94
|
```
|
|
57
95
|
|
|
96
|
+
### 3) Angular
|
|
97
|
+
|
|
98
|
+
En Angular, pon el JSON exportado en `src/assets/report.json` y cárgalo con `HttpClient` o `fetch()`.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
|
|
102
|
+
|
|
103
|
+
@Component({
|
|
104
|
+
selector: 'app-root',
|
|
105
|
+
template: '<nexa-viewer #viewer></nexa-viewer>',
|
|
106
|
+
})
|
|
107
|
+
export class AppComponent implements AfterViewInit {
|
|
108
|
+
@ViewChild('viewer', { static: true }) viewerRef!: ElementRef<any>;
|
|
109
|
+
|
|
110
|
+
async ngAfterViewInit() {
|
|
111
|
+
const v = this.viewerRef.nativeElement;
|
|
112
|
+
const res = await fetch('/assets/report.json');
|
|
113
|
+
v.definition = await res.json();
|
|
114
|
+
v.data = [
|
|
115
|
+
{ nombre: 'Producto A', precio: 100, cantidad: 2 },
|
|
116
|
+
{ nombre: 'Producto B', precio: 50, cantidad: 5 },
|
|
117
|
+
];
|
|
118
|
+
v.minimal = true;
|
|
119
|
+
v.skipParamsDialog = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
58
124
|
### 3) HTML puro (CDN / UMD)
|
|
59
125
|
|
|
60
126
|
```html
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as c } from "./index-
|
|
2
|
-
import { r as f } from "./html2canvas-
|
|
1
|
+
import { a as c } from "./index-j9lAJl17.js";
|
|
2
|
+
import { r as f } from "./html2canvas-MMn8dUQK.js";
|
|
3
3
|
function l(r, n) {
|
|
4
4
|
for (var o = 0; o < n.length; o++) {
|
|
5
5
|
const e = n[o];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as De, a as Ke, c as Te } from "./index-
|
|
2
|
-
import { j as Ge } from "./jspdf.es.min-
|
|
3
|
-
import { r as Be } from "./html2canvas-
|
|
1
|
+
import { g as De, a as Ke, c as Te } from "./index-j9lAJl17.js";
|
|
2
|
+
import { j as Ge } from "./jspdf.es.min-DIevzj7_.js";
|
|
3
|
+
import { r as Be } from "./html2canvas-MMn8dUQK.js";
|
|
4
4
|
function Ue(ge, we) {
|
|
5
5
|
for (var me = 0; me < we.length; me++) {
|
|
6
6
|
const ce = we[me];
|