stimulsoft-dashboards-js-react 2025.2.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/viewer.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import * as React from 'react'
2
+ import { Stimulsoft } from './stimulsoft.reports'
3
+ export { Stimulsoft };
4
+
5
+ interface ViewerProperties {
6
+ report?: Stimulsoft.Report.StiReport;
7
+ visible?: boolean,
8
+ options?: Stimulsoft.Viewer.StiViewerOptions,
9
+ id?: string,
10
+
11
+ onPrepareVariables?: (args: Stimulsoft.Report.PrepareVariablesArgs, callback: (result: Stimulsoft.Report.PrepareVariablesObject[] | Stimulsoft.Report.PrepareVariablesArgs) => void) => void,
12
+ onBeginProcessData?: (args: Stimulsoft.Report.BeginProcessDataArgs, callback: (result: any) => void) => void,
13
+ onEndProcessData?: (args: Stimulsoft.Report.EndProcessDataArgs) => void,
14
+ onPrintReport?: (args: Stimulsoft.Viewer.PrintReportEventArgs, callback: () => void) => void,
15
+ onBeginExportReport?: (args: Stimulsoft.Viewer.BeginExportReportArgs, callback: () => void) => void,
16
+ onEndExportReport?: (args: Stimulsoft.Viewer.EndExportReportArgs, callback: () => void) => void,
17
+ onInteraction?: (args: Stimulsoft.Viewer.InteractionArgs, callback: () => void) => void,
18
+ onEmailReport?: (args: Stimulsoft.Viewer.EmailReportArgs, callback: () => void) => void,
19
+ onDesignReport?: (args: Stimulsoft.Viewer.DesignReportArgs) => void,
20
+ onShowReport?: (args: Stimulsoft.Viewer.ShowReportArgs, callback: () => void) => void,
21
+ onOpenReport?: (args: Stimulsoft.Viewer.OpenReportArgs, callback: () => void) => void,
22
+ onOpenedReport?: (args: Stimulsoft.Viewer.OpenedReportArgs, callback: () => void) => void
23
+ }
24
+
25
+ export const Viewer: React.FunctionComponent<ViewerProperties>;
package/viewer.js ADDED
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import { } from "./stimulsoft.reports.engine.mjs";
3
+ import { } from "./stimulsoft.reports.chart.mjs";
4
+ import { } from "./stimulsoft.reports.export.mjs";
5
+ import { } from "./stimulsoft.reports.import.xlsx.mjs";
6
+ import { } from "./stimulsoft.reports.maps.mjs";
7
+ import { } from "./stimulsoft.dashboards.mjs";
8
+ import { Stimulsoft } from "./stimulsoft.viewer.mjs";
9
+ export { Stimulsoft };
10
+
11
+ export class Viewer extends React.Component {
12
+ #viewer;
13
+ #parentRef = React.createRef();
14
+
15
+ #createViewer() {
16
+ this.#viewer = new Stimulsoft.Viewer.StiViewer(this.props.options, this.props.id, false);
17
+ this.#viewer.renderHtml(this.#parentRef.current);
18
+ this.#bindEvents();
19
+
20
+ this.#viewer.visible = this.props.visible ?? true;
21
+ }
22
+
23
+ #bindEvents() {
24
+ if (typeof this.props.onPrepareVariables == "function") this.#viewer.onPrepareVariables = this.props.onPrepareVariables?.bind(this);
25
+ if (typeof this.props.onBeginProcessData == "function") this.#viewer.onBeginProcessData = this.props.onPonBeginProcessDatarepareVariables?.bind(this);
26
+ if (typeof this.props.onEndProcessData == "function") this.#viewer.onEndProcessData = this.props.onEndProcessData?.bind(this);
27
+ if (typeof this.props.onPrintReport == "function") this.#viewer.onPrintReport = this.props.onPrintReport?.bind(this);
28
+ if (typeof this.props.onBeginExportReport == "function") this.#viewer.onBeginExportReport = this.props.onBeginExportReport?.bind(this);
29
+ if (typeof this.props.onEndExportReport == "function") this.#viewer.onEndExportReport = this.props.onEndExportReport?.bind(this);
30
+ if (typeof this.props.onInteraction == "function") this.#viewer.onInteraction = this.props.onInteraction?.bind(this);
31
+ if (typeof this.props.onEmailReport == "function") this.#viewer.onEmailReport = this.props.onEmailReport?.bind(this);
32
+ if (typeof this.props.onDesignReport == "function") this.#viewer.onDesignReport = this.props.onDesignReport?.bind(this);
33
+ if (typeof this.props.onShowReport == "function") this.#viewer.onShowReport = this.props.onShowReport?.bind(this);
34
+ if (typeof this.props.onOpenReport == "function") this.#viewer.onOpenReport = (args, callback) => {
35
+ args.preventDefault = false;
36
+ this.props.onOpenReport?.bind(this)(args, callback);
37
+ }
38
+ if (typeof this.props.onOpenedReport == "function") this.#viewer.onOpenedReport = this.props.onOpenedReport?.bind(this);
39
+ }
40
+
41
+ componentDidMount() {
42
+ this.#createViewer();
43
+ this.#viewer.report = this.props.report;
44
+ }
45
+
46
+ componentWillUnmount() {
47
+ if (this.#viewer != null)
48
+ this.#viewer.dispose();
49
+ }
50
+
51
+ componentDidUpdate(prevProps) {
52
+ if (this.props.options !== prevProps.options) {
53
+ this.#createViewer();
54
+ this.#viewer.report = this.props.report;
55
+ }
56
+ if (this.props.report !== prevProps.report)
57
+ this.#viewer.report = this.props.report;
58
+ if (this.props.visible !== prevProps.visible)
59
+ this.#viewer.visible = this.props.visible;
60
+ if (this.props.id !== prevProps.id) {
61
+ this.#createViewer();
62
+ this.#viewer.report = this.props.report;
63
+ }
64
+ }
65
+
66
+ render() {
67
+ return React.createElement('div', { ref: this.#parentRef });
68
+ }
69
+ }