@progress/telerik-react-report-viewer 27.25.1001 → 28.25.1119

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.
@@ -1,6 +1,805 @@
1
1
  import '../dependencies/initExtDeps';
2
2
  import React from 'react';
3
3
  import { ReportViewer } from '../dependencies/telerikReportViewer.js';
4
+
5
+ /**
6
+ * Defines options for configuring report parameter editors in the React Report Viewer.
7
+ *
8
+ * @typedef {Object} ParametersOptions
9
+ * @property {Object} [editors] - Allows you to specify the editor type for single-value and multi-value report parameters.
10
+ * @property {string} [editors.singleSelect="LIST_VIEW"] - Editor type for single-value parameters.
11
+ * - "COMBO_BOX": Uses a ComboBox widget as the editor.
12
+ * - "LIST_VIEW": Uses a ListView widget as the editor.
13
+ * - Default: "LIST_VIEW"
14
+ * @property {string} [editors.multiSelect="LIST_VIEW"] - Editor type for multi-value parameters.
15
+ * - "COMBO_BOX": Uses a MultiSelect widget as the editor.
16
+ * - "LIST_VIEW": Uses a ListView widget as the editor.
17
+ * - Default: "LIST_VIEW"
18
+ *
19
+ * @example
20
+ * // React: Specify editor types for report parameters
21
+ *
22
+ * <TelerikReportViewer
23
+ * serviceUrl="api/reports/"
24
+ * reportSource={{ report: "Dashboard.trdp" }}
25
+ * parameters={{
26
+ * editors: {
27
+ * singleSelect: "COMBO_BOX",
28
+ * multiSelect: "LIST_VIEW"
29
+ * }
30
+ * }}
31
+ * />
32
+ */
33
+
34
+ /**
35
+ * Describes an interactive action triggered by the user in the report viewer.
36
+ * The shape of the `Value` property depends on the action `Type`.
37
+ *
38
+ * @typedef {Object} InteractiveAction
39
+ * @property {string} Id - The identifier of the action (a GUID).
40
+ * @property {string} Type - The type of the action. One of:
41
+ * "sorting", "toggleVisibility", "navigateToUrl", "navigateToBookmark", "navigateToReport", "customAction".
42
+ * @property {string} ReportItemName - The name of the report item associated with the action.
43
+ * @property {Object} [Value] - Additional data for the action, depending on the Type:
44
+ * - For "navigateToUrl": { Url: string, Target: "NewWindow"|"SameWindow" }
45
+ * - For "navigateToBookmark": string (the target bookmark)
46
+ * - For "navigateToReport": { report: string, parameters: Object }
47
+ * - For "customAction": { Parameters: Object }
48
+ */
49
+
50
+ /**
51
+ * Configuration for connecting to a Telerik Report Server instance.
52
+ *
53
+ * The authentication method depends on the Report Server version:
54
+ * - Report Server for .NET: Supports Token authentication (getPersonalAccessToken) or username/password authentication. The token can be from any user, including the Guest user.
55
+ * - Report Server for .NET Framework 4.6.2: Supports username/password authentication or Guest account (url only, if Guest is enabled on the server).
56
+ *
57
+ * @typedef {Object} ReportServer
58
+ * @property {string} url - The URL to the Telerik Report Server instance. (required)
59
+ * @property {function} [getPersonalAccessToken] - A callback function that returns the Token for authentication against the Telerik Report Server for .NET instance wrapped in a Promise. This is the recommended authentication method for Report Server for .NET. The token can be from any user account, including the Guest user. Only supported by Report Server for .NET. (optional)
60
+ * @property {string} [username] - A registered username in the Report Server that will be used to get access to the reports. Supported by both Report Server for .NET and Report Server for .NET Framework 4.6.2. If omitted when connecting to Report Server for .NET Framework 4.6.2 with Guest enabled, the built-in Guest account will be used. (optional)
61
+ * @property {string} [password] - The password for the provided username. Supported by both Report Server for .NET and Report Server for .NET Framework 4.6.2. Can be omitted only when connecting with the Guest account to Report Server for .NET Framework 4.6.2. (optional)
62
+ *
63
+ * @example <propertyName>getPersonalAccessToken</propertyName>
64
+ * // Example: Report Server for .NET - Token authentication (recommended)
65
+ * <TelerikReportViewer
66
+ * reportServer={{
67
+ * url: "https://my-report-server-net/",
68
+ * getPersonalAccessToken: function() {
69
+ * return Promise.resolve("<personal-access-token>");
70
+ * }
71
+ * }}
72
+ * reportSource={{ report: "Samples/Dashboard" }}
73
+ * />
74
+ *
75
+ * @example <propertyName>getPersonalAccessToken</propertyName>
76
+ * // Example: Report Server for .NET - Token authentication with a secure endpoint
77
+ * <TelerikReportViewer
78
+ * reportServer={{
79
+ * url: "https://my-report-server-net/",
80
+ * getPersonalAccessToken: function() {
81
+ * return fetch('/rs-token')
82
+ * .then(response => response.text());
83
+ * }
84
+ * }}
85
+ * reportSource={{ report: "Samples/Dashboard" }}
86
+ * />
87
+ *
88
+ * @example <propertyName>getPersonalAccessToken</propertyName>
89
+ * // Example: Report Server for .NET - Token authentication with Guest user token
90
+ * <TelerikReportViewer
91
+ * reportServer={{
92
+ * url: "https://my-report-server-net/",
93
+ * getPersonalAccessToken: function() {
94
+ * return Promise.resolve("<guest-user-token>");
95
+ * }
96
+ * }}
97
+ * reportSource={{ report: "Samples/Dashboard" }}
98
+ * />
99
+ *
100
+ * @example <propertyName>username</propertyName>
101
+ * // Example: Report Server for .NET - Username/password authentication
102
+ * <TelerikReportViewer
103
+ * reportServer={{
104
+ * url: "https://my-report-server-net/",
105
+ * username: "myUser",
106
+ * password: "myPassword"
107
+ * }}
108
+ * reportSource={{ report: "Samples/Dashboard" }}
109
+ * />
110
+ *
111
+ * @example <propertyName>username</propertyName>
112
+ * // Example: Report Server for .NET Framework 4.6.2 - Username/password authentication
113
+ * <TelerikReportViewer
114
+ * reportServer={{
115
+ * url: "https://my-report-server-framework/",
116
+ * username: "myUser",
117
+ * password: "myPassword"
118
+ * }}
119
+ * reportSource={{ report: "Samples/Dashboard" }}
120
+ * />
121
+ *
122
+ * @example <propertyName>url</propertyName>
123
+ * // Example: Report Server for .NET Framework 4.6.2 - Guest account (requires Guest enabled on server)
124
+ * <TelerikReportViewer
125
+ * reportServer={{
126
+ * url: "https://my-report-server-framework/"
127
+ * }}
128
+ * reportSource={{ report: "Samples/Dashboard" }}
129
+ * />
130
+ *
131
+ * @example <propertyName>reportServer</propertyName>
132
+ * // Example: Complete Report Viewer initialization with Report Server for .NET using Token authentication
133
+ * <TelerikReportViewer
134
+ * reportServer={{
135
+ * url: "https://my-report-server-net/",
136
+ * getPersonalAccessToken: function() {
137
+ * return Promise.resolve("<personal-access-token>");
138
+ * }
139
+ * }}
140
+ * reportSource={{
141
+ * report: "Samples/Dashboard",
142
+ * parameters: {
143
+ * ReportYear: 2004
144
+ * }
145
+ * }}
146
+ * />
147
+ */
148
+
149
+ /**
150
+ * Configuration object that identifies the report to be displayed and provides initial parameter values.
151
+ * @typedef {Object} ReportSource
152
+ * @property {string} [report] - A string that represents a report on the server. On the server side, this string will be converted to a ReportSource through an IReportResolver. This may be an assembly qualified type name that can be converted to TypeReportSource, a path to a report definition file (.trdp/.trdx) as in the UriReportSource, or even a report id that a dedicated IReportSourceResolver will use to read the report definition stored in a database. When using the viewer with Report Server, the report should be provided in the format: "{Category}/{ReportName}".
153
+ * @property {ReportParameters} [parameters] - A JSON object with properties name/value equal to the report parameters' names and values used in the report definition.
154
+ *
155
+ * @example <propertyName>report</propertyName>
156
+ * // Example: Minimal report source with only the report name
157
+ * const reportSource = {
158
+ * report: "MyReport"
159
+ * };
160
+ *
161
+ * @example <propertyName>parameters</propertyName>
162
+ * // Example: Report source with parameters
163
+ * const reportSource = {
164
+ * report: "SalesReport",
165
+ * parameters: {
166
+ * StartDate: "2024-01-01",
167
+ * EndDate: "2024-12-31",
168
+ * Region: "North America"
169
+ * }
170
+ * };
171
+ *
172
+ * @example <propertyName>report</propertyName>
173
+ * // Example: Report Server format
174
+ * const reportSource = {
175
+ * report: "Finance/MonthlyReport"
176
+ * };
177
+ *
178
+ * @example
179
+ * // Example: Using ReportSource with the React Report Viewer
180
+ * <TelerikReportViewer
181
+ * serviceUrl="api/reports/"
182
+ * reportSource={{
183
+ * report: "InventoryReport",
184
+ * parameters: {
185
+ * Category: "Electronics",
186
+ * InStock: true
187
+ * }
188
+ * }}
189
+ * />
190
+ */
191
+
192
+ /**
193
+ * @typedef {Object.<string, any>} ReportParameters
194
+ * An object where each property name corresponds to a report parameter's name,
195
+ * and the value is the value assigned to that parameter as used in the report definition.
196
+ *
197
+ * @example
198
+ * {
199
+ * "StartDate": "2024-01-01",
200
+ * "EndDate": "2024-12-31",
201
+ * "Category": "Books"
202
+ * }
203
+ */
204
+
205
+ /**
206
+ * Configuration options for the Send Email feature in the Report Viewer.
207
+ * Allows customization of the email dialog, default values, and available document formats when sending a report via email.
208
+ *
209
+ * @typedef {Object} SendEmailOptions
210
+ * @property {boolean} enabled - Indicates whether to show the Send Mail Message toolbar button. Default value: false.
211
+ * @property {string} [from] - E-mail address used for the MailMessage FROM value.
212
+ * @property {string} [to] - E-mail address used for the MailMessage TO value.
213
+ * @property {string} [cc] - E-mail address used for the MailMessage Carbon Copy value.
214
+ * @property {string} [subject] - A string used for the MailMessage Subject value.
215
+ * @property {string} [body] - Sentences used for the MailMessage Content value.
216
+ * @property {string} [format] - The preselected report document format.
217
+ *
218
+ * @example
219
+ * // Enable Send Email with default values and PDF as the default format
220
+ * <TelerikReportViewer
221
+ * serviceUrl="api/reports/"
222
+ * reportSource={{ report: "Dashboard.trdp" }}
223
+ * sendEmail={{
224
+ * enabled: true,
225
+ * from: "reports@company.com",
226
+ * to: "recipient@domain.com",
227
+ * cc: "manager@domain.com",
228
+ * subject: "Monthly Sales Report",
229
+ * body: "Please find the attached monthly sales report.",
230
+ * format: "PDF"
231
+ * }}
232
+ * />
233
+ *
234
+ * @example
235
+ * // Basic email configuration with minimal options
236
+ * <TelerikReportViewer
237
+ * serviceUrl="api/reports/"
238
+ * reportSource={{ report: "Dashboard.trdp" }}
239
+ * sendEmail={{
240
+ * enabled: true,
241
+ * from: "noreply@company.com"
242
+ * }}
243
+ * />
244
+ */
245
+
246
+ /**
247
+ * Represents the API of a parameter editor instance returned by createEditor.
248
+ * @typedef {Object} ParameterEditorInstance
249
+ * @property {function(Object):void} beginEdit - Creates the editor UI and populates it with the parameter settings.
250
+ * @property {function(Object):void} addAccessibility - Adds accessibility to the parameter editor and populates its string resources.
251
+ * @property {function(Object):void} setAccessibilityErrorState - Sets the error state of the parameter editor's accessibility functionality and its error attributes.
252
+ * @property {function(boolean):void} enable - Enables or disables the parameter editor.
253
+ * @property {function():void} [clearPendingChange] - Invoked when parameter changes (optional, not present on all editors).
254
+ * @property {function():void} [destroy] - Invoked to destroy the parameter editor (optional, not present on all editors).
255
+ */
256
+
257
+ /**
258
+ * Describes a parameter editor for the Telerik Report Viewer parameter panel.
259
+ * @typedef {Object} ParameterEditor
260
+ * @property {function(Object): boolean} match - Determines if the editor is suitable for the parameter.
261
+ * @property {function(HTMLElement, Object): ParameterEditorInstance} createEditor - Creates the editor UI.
262
+ * @example
263
+ * // Example: Custom match function for single-select parameters
264
+ * var match = function(parameter) {
265
+ * // Use parameter properties to determine if this editor should be used
266
+ * return Boolean(parameter.availableValues) && !parameter.multivalue;
267
+ * };
268
+ *
269
+ * @example
270
+ * // Example: Custom createEditor function using Kendo DateTimePicker
271
+ * function match(parameter) {
272
+ * return parameter.type === "System.DateTime";
273
+ * }
274
+ *
275
+ * function createEditor(placeholder, options) {
276
+ * var dateTimePicker = $(placeholder).html('<input type="datetime"/>'),
277
+ * parameter,
278
+ * valueChangedCallback = options.parameterChanged,
279
+ * dropDownList;
280
+ * function onChange() {
281
+ * var val = dropDownList.value();
282
+ * valueChangedCallback(parameter, val);
283
+ * }
284
+ * return {
285
+ * beginEdit: function (param) {
286
+ * parameter = param;
287
+ * $(dateTimePicker).find("input").kendoDateTimePicker({
288
+ * dataTextField: "name",
289
+ * dataValueField: "value",
290
+ * value: parameter.value,
291
+ * dataSource: parameter.availableValues,
292
+ * change: onChange
293
+ * });
294
+ * dropDownList = $(dateTimePicker).find("input").data("kendoDateTimePicker");
295
+ * }
296
+ * };
297
+ * }
298
+ *
299
+ * @example
300
+ * // Example: Registering the custom ParameterEditor
301
+ * ParameterEditors.push({
302
+ * match: match,
303
+ * createEditor: createEditor
304
+ * });
305
+ *
306
+ */
307
+
308
+ /**
309
+ * @typedef {Object} TelerikReportViewerProps
310
+ * @description Configuration props for the TelerikReportViewer React component.
311
+ * @property {string} [id] - Sets the unique identifier of the ReportViewer instance. If not specified, the id of the target HTML element will be used (if such is set). The id of the ReportViewer is used to identify the client session of the viewer when persistSession is enabled (true).
312
+ * @example <propertyName>id</propertyName>
313
+ * // Set a custom viewer ID
314
+ * <TelerikReportViewer
315
+ * serviceUrl="api/reports/"
316
+ * reportSource={{ report: "Dashboard.trdp" }}
317
+ * id="myUniqueViewer"
318
+ * />
319
+ *
320
+ * @property {string} [serviceUrl] - Sets the address of the Report REST Service. Required if reportServer is not provided.
321
+ * @example <propertyName>serviceUrl</propertyName>
322
+ * // Set the service URL for the report viewer
323
+ * <TelerikReportViewer
324
+ * serviceUrl="api/reports/"
325
+ * reportSource={{ report: "Dashboard.trdp" }}
326
+ * />
327
+ *
328
+ * @property {ReportServer} [reportServer] - Sets the configuration details for Telerik Report Server. Required if serviceUrl is not provided.
329
+ * @example <propertyName>reportServer</propertyName>
330
+ * // Use Report Server authentication with Token (recommended for RS.NET)
331
+ * <TelerikReportViewer
332
+ * reportServer={{
333
+ * url: "https://yourReportServerUrl:port",
334
+ * getPersonalAccessToken: function() {
335
+ * return Promise.resolve("<personal-access-token>");
336
+ * }
337
+ * }}
338
+ * reportSource={{ report: "Samples/Dashboard" }}
339
+ * />
340
+ *
341
+ * @example <propertyName>reportServer</propertyName>
342
+ * // Use Report Server authentication with username/password (not recommended)
343
+ * <TelerikReportViewer
344
+ * reportServer={{
345
+ * url: "https://myserver.com/",
346
+ * username: "reportuser",
347
+ * password: "password123"
348
+ * }}
349
+ * reportSource={{ report: "Finance/Dashboard" }}
350
+ * />
351
+ *
352
+ * @property {string} [templateUrl] - Sets the address of the html page that contains the viewer templates. If omitted, the default template will be downloaded from the REST service. Note: Internally mapped to trvTemplateUrl property.
353
+ * @example <propertyName>templateUrl</propertyName>
354
+ * // Use a custom template
355
+ * <TelerikReportViewer
356
+ * serviceUrl="api/reports/"
357
+ * reportSource={{ report: "Dashboard.trdp" }}
358
+ * templateUrl="/templates/customViewer.html"
359
+ * />
360
+ *
361
+ * @property {ReportSource} [reportSource] - Sets the report and initial report parameter values for the viewer to be displayed.
362
+ * @example <propertyName>reportSource</propertyName>
363
+ * // Basic report source
364
+ * <TelerikReportViewer
365
+ * serviceUrl="api/reports/"
366
+ * reportSource={{ report: "Dashboard.trdp" }}
367
+ * />
368
+ *
369
+ * @example
370
+ * <propertyName>reportSource</propertyName>
371
+ * // Report source with parameters
372
+ * <TelerikReportViewer
373
+ * serviceUrl="api/reports/"
374
+ * reportSource={{
375
+ * report: "SalesReport.trdp",
376
+ * parameters: { StartDate: "2024-01-01", EndDate: "2024-12-31" }
377
+ * }}
378
+ * />
379
+ *
380
+ * @example
381
+ * <propertyName>reportSource</propertyName>
382
+ * // Report Server format
383
+ * <TelerikReportViewer
384
+ * reportServer={{ url: "https://myserver/" }}
385
+ * reportSource={{ report: "Finance/MonthlyReport" }}
386
+ * />
387
+ *
388
+ * @property {SendEmailOptions} [sendEmail] - Configuration for the Send Mail Message feature.
389
+ * @example <propertyName>sendEmail</propertyName>
390
+ * // Enable send email with default values
391
+ * <TelerikReportViewer
392
+ * serviceUrl="api/reports/"
393
+ * reportSource={{ report: "Dashboard.trdp" }}
394
+ * sendEmail={{
395
+ * enabled: true,
396
+ * from: "reports@company.com",
397
+ * to: "recipient@domain.com",
398
+ * subject: "Monthly Report",
399
+ * format: "PDF"
400
+ * }}
401
+ * />
402
+ *
403
+ * @property {number} [scale] - Sets the scale factor for the report pages. The scale takes effect when scaleMode is set to "SPECIFIC". Default value is 1.0 (100%).
404
+ * @example <propertyName>scale</propertyName>
405
+ * // Set zoom to 150%
406
+ * <TelerikReportViewer
407
+ * serviceUrl="api/reports/"
408
+ * reportSource={{ report: "Dashboard.trdp" }}
409
+ * scale={1.5}
410
+ * scaleMode="SPECIFIC"
411
+ * />
412
+ *
413
+ * @property {string} [scaleMode] - Sets how the report pages are scaled. Available options: "FIT_PAGE_WIDTH" (pages scaled to fit entire width), "FIT_PAGE" (pages scaled to fit entire page), "SPECIFIC" (pages scaled with scale value). Default value is "FIT_PAGE".
414
+ * @example <propertyName>scaleMode</propertyName>
415
+ * // Fit page width
416
+ * <TelerikReportViewer
417
+ * serviceUrl="api/reports/"
418
+ * reportSource={{ report: "Dashboard.trdp" }}
419
+ * scaleMode="FIT_PAGE_WIDTH"
420
+ * />
421
+ *
422
+ * @property {string} [viewMode] - Sets if the report is displayed in interactive mode or in print preview. Available values: "INTERACTIVE" (enables drill-down interactivity), "PRINT_PREVIEW" (paged according to page settings). Default value is "INTERACTIVE".
423
+ * @example <propertyName>viewMode</propertyName>
424
+ * // Set view mode to print preview
425
+ * <TelerikReportViewer
426
+ * serviceUrl="api/reports/"
427
+ * reportSource={{ report: "Dashboard.trdp" }}
428
+ * viewMode="PRINT_PREVIEW"
429
+ * />
430
+ *
431
+ * @property {string} [pageMode] - Sets if the report is displayed in Single page or Continuous scroll mode. Available values: "SINGLE_PAGE" (only one page loaded), "CONTINUOUS_SCROLL" (multiple pages loaded). Default value is "CONTINUOUS_SCROLL".
432
+ * @example <propertyName>pageMode</propertyName>
433
+ * // Set page mode to single page
434
+ * <TelerikReportViewer
435
+ * serviceUrl="api/reports/"
436
+ * reportSource={{ report: "Dashboard.trdp" }}
437
+ * pageMode="SINGLE_PAGE"
438
+ * />
439
+ *
440
+ * @property {boolean} [persistSession] - Sets whether the viewer's client session is persisted between page refreshes (e.g., postback). The session is stored in the browser's sessionStorage and is available for the duration of the page session. Default value is false.
441
+ * @example <propertyName>persistSession</propertyName>
442
+ * // Enable session persistence
443
+ * <TelerikReportViewer
444
+ * serviceUrl="api/reports/"
445
+ * reportSource={{ report: "Dashboard.trdp" }}
446
+ * persistSession={true}
447
+ * id="myConstantId"
448
+ * />
449
+ *
450
+ * @property {ParametersOptions} [parameters] - Allows the user to define parameter options for the report parameters.
451
+ * @example <propertyName>parameters</propertyName>
452
+ * // Configure parameter editors
453
+ * <TelerikReportViewer
454
+ * serviceUrl="api/reports/"
455
+ * reportSource={{ report: "Dashboard.trdp" }}
456
+ * parameters={{
457
+ * editors: {
458
+ * singleSelect: "COMBO_BOX",
459
+ * multiSelect: "LIST_VIEW"
460
+ * }
461
+ * }}
462
+ * />
463
+ *
464
+ * @property {ParameterEditor} [parameterEditors] - Allows the user to define custom editors for the report parameters.
465
+ * @example <propertyName>parameterEditors</propertyName>
466
+ * // Register custom parameter editors
467
+ * const customEditors = [{
468
+ * match: function(param) { return param.name === "MyParam"; },
469
+ * createEditor: function(placeholder, options) { return {}; }
470
+ * }];
471
+ * // Use with component: parameterEditors={customEditors}
472
+ *
473
+ * @property {string} [authenticationToken] - If provided, a Bearer token will be set in the Authorization header for every request to the REST service.
474
+ * @example <propertyName>authenticationToken</propertyName>
475
+ * // Set authentication token
476
+ * const token = "YOUR_AUTH_TOKEN";
477
+ * // Use with component: authenticationToken={token}
478
+ *
479
+ * @property {string} [printMode] - Specifies how the viewer should print reports. Available values: "AUTO_SELECT" (automatically decide based on browser), "FORCE_PDF_FILE" (download as PDF file), "FORCE_PDF_PLUGIN" (use PDF plug-in). Default value is "AUTO_SELECT".
480
+ * @example <propertyName>printMode</propertyName>
481
+ * // Force PDF file for printing
482
+ * // Use with component: printMode="FORCE_PDF_FILE"
483
+ *
484
+ * @property {string} [selector] - A selector used in conjunction with the data- attributes. Whenever a command is attached to an element outside of the report viewer via the data-attributes this selector must be provided.
485
+ * @example <propertyName>selector</propertyName>
486
+ * // Set a custom selector for external commands
487
+ * // Use with component: selector="#customToolbar"
488
+ *
489
+ * @property {string} [disabledButtonClass] - A class used in conjunction with the data- attributes. Whenever a command is in the disabled state this class will be added to the respective button.
490
+ * @example <propertyName>disabledButtonClass</propertyName>
491
+ * // Custom disabled button styling
492
+ * // Use with component: disabledButtonClass="btn-disabled"
493
+ *
494
+ * @property {string} [checkedButtonClass] - A class used in conjunction with the data- attributes. Whenever a command is in the checked state this class will be added to the respective button.
495
+ * @example <propertyName>checkedButtonClass</propertyName>
496
+ * // Custom checked button styling
497
+ * // Use with component: checkedButtonClass="btn-active"
498
+ *
499
+ * @property {boolean} [enableAccessibility] - Determines whether the viewer should provide support for accessibility features. Default value is false.
500
+ * @example <propertyName>enableAccessibility</propertyName>
501
+ * // Enable accessibility features
502
+ * // Use with component: enableAccessibility={true}
503
+ * <TelerikReportViewer
504
+ * serviceUrl="api/reports/"
505
+ * reportSource={{ report: "Dashboard.trdp" }}
506
+ * enableAccessibility={true}
507
+ * />
508
+ *
509
+ * @property {boolean} [parametersAreaVisible] - Determines whether the viewer's parameters area is displayed if any parameter editor exists.
510
+ * @example <propertyName>parametersAreaVisible</propertyName>
511
+ * // Hide parameters area
512
+ * <TelerikReportViewer
513
+ * serviceUrl="api/reports/"
514
+ * reportSource={{ report: "Dashboard.trdp" }}
515
+ * parametersAreaVisible={false}
516
+ * />
517
+ *
518
+ * @property {boolean} [documentMapVisible] - Determines whether the viewer's document map is displayed if any bookmark is defined.
519
+ * @example <propertyName>documentMapVisible</propertyName>
520
+ * // Show document map
521
+ * <TelerikReportViewer
522
+ * serviceUrl="api/reports/"
523
+ * reportSource={{ report: "Dashboard.trdp" }}
524
+ * documentMapVisible={true}
525
+ * />
526
+ *
527
+ * @property {string} [parametersAreaPosition] - Specifies where the Parameters Area should be displayed. Available values: "RIGHT", "TOP", "LEFT", "BOTTOM". Default value is "RIGHT".
528
+ * @example <propertyName>parametersAreaPosition</propertyName>
529
+ * // Place parameters area on the left
530
+ * <TelerikReportViewer
531
+ * serviceUrl="api/reports/"
532
+ * reportSource={{ report: "Dashboard.trdp" }}
533
+ * parametersAreaPosition="LEFT"
534
+ * />
535
+ *
536
+ * @property {string} [documentMapAreaPosition] - Specifies where the Document Map should be displayed. Available values: "RIGHT", "LEFT". Default value is "LEFT".
537
+ * @example <propertyName>documentMapAreaPosition</propertyName>
538
+ * // Place document map on the right
539
+ * <TelerikReportViewer
540
+ * serviceUrl="api/reports/"
541
+ * reportSource={{ report: "Dashboard.trdp" }}
542
+ * documentMapAreaPosition="RIGHT"
543
+ * />
544
+ *
545
+ * @property {boolean} [searchMetadataOnDemand] - Determines whether the search metadata will be delivered on demand (true) or by default (false). Default value is false.
546
+ * @example <propertyName>searchMetadataOnDemand</propertyName>
547
+ * // Enable search metadata on demand
548
+ * <TelerikReportViewer
549
+ * serviceUrl="api/reports/"
550
+ * reportSource={{ report: "Dashboard.trdp" }}
551
+ * searchMetadataOnDemand={true}
552
+ * />
553
+ *
554
+ * @property {string} [initialPageAreaImageUrl] - The image URL for the PageArea background image. Used only when the parameter values are missing or invalid. The image should be in PNG, GIF, or JPG file format.
555
+ * @example <propertyName>initialPageAreaImageUrl</propertyName>
556
+ * // Set a background image for empty page area
557
+ * <TelerikReportViewer
558
+ * serviceUrl="api/reports/"
559
+ * reportSource={{ report: "Dashboard.trdp" }}
560
+ * initialPageAreaImageUrl="/images/reportBackground.png"
561
+ * />
562
+ *
563
+ * @property {boolean} [keepClientAlive] - Determines whether the client will be kept alive. Default value is true.
564
+ * @example <propertyName>keepClientAlive</propertyName>
565
+ * // Keep client alive
566
+ * <TelerikReportViewer
567
+ * serviceUrl="api/reports/"
568
+ * reportSource={{ report: "Dashboard.trdp" }}
569
+ * keepClientAlive={true}
570
+ * />
571
+ *
572
+ * @property {Object} [viewerContainerStyle] - CSS styles to apply to the viewer container div.
573
+ * @example <propertyName>viewerContainerStyle</propertyName>
574
+ * // Set container styles
575
+ * <TelerikReportViewer
576
+ * serviceUrl="api/reports/"
577
+ * reportSource={{ report: "Dashboard.trdp" }}
578
+ * viewerContainerStyle={{
579
+ * width: '100%',
580
+ * height: '600px',
581
+ * border: '1px solid #ccc'
582
+ * }}
583
+ * />
584
+ *
585
+ * @property {function} [ready] - A callback function that is called when the viewer content has been loaded from the template and is ready to display reports or perform any other operations.
586
+ * @example <propertyName>ready</propertyName>
587
+ * // Ready callback
588
+ * <TelerikReportViewer
589
+ * serviceUrl="api/reports/"
590
+ * reportSource={{ report: "Dashboard.trdp" }}
591
+ * ready={() => console.log("Report viewer is ready")}
592
+ * />
593
+ *
594
+ * @property {function} [exportBegin] - Called before exporting the report. Receives two parameters: `e` (the event object) and `args` (an object with properties: `format` (string), `deviceInfo` (object), and `handled` (boolean, set to true to prevent the default export)).
595
+ * @example <propertyName>exportBegin</propertyName>
596
+ * // Export begin handler
597
+ * <TelerikReportViewer
598
+ * serviceUrl="api/reports/"
599
+ * reportSource={{ report: "Dashboard.trdp" }}
600
+ * exportBegin={(e, args) => {
601
+ * console.log("Exporting report in format: " + args.format);
602
+ * }}
603
+ * />
604
+ *
605
+ * @property {function} [exportEnd] - Called after exporting the report. Receives two parameters: `e` (the event object) and `args` (an object with properties: `url` (string), `format` (string), `handled` (boolean), and `windowOpenTarget` (string)).
606
+ * @example <propertyName>exportEnd</propertyName>
607
+ * // Export end handler
608
+ * <TelerikReportViewer
609
+ * serviceUrl="api/reports/"
610
+ * reportSource={{ report: "Dashboard.trdp" }}
611
+ * exportEnd={(e, args) => {
612
+ * args.windowOpenTarget = "_blank";
613
+ * console.log("The exported report can be found at " + args.url);
614
+ * }}
615
+ * />
616
+ *
617
+ * @property {function} [printBegin] - Called before printing the report. Receives two parameters: `e` (the event object) and `args` (an object with properties: `deviceInfo` (object), and `handled` (boolean)).
618
+ * @example <propertyName>printBegin</propertyName>
619
+ * // Print begin handler
620
+ * <TelerikReportViewer
621
+ * serviceUrl="api/reports/"
622
+ * reportSource={{ report: "Dashboard.trdp" }}
623
+ * printBegin={(e, args) => {
624
+ * console.log("About to print the report.");
625
+ * }}
626
+ * />
627
+ *
628
+ * @property {function} [printEnd] - Called after printing the report. Receives two parameters: `e` (the event object) and `args` (an object with properties: `url` (string), and `handled` (boolean)).
629
+ * @example <propertyName>printEnd</propertyName>
630
+ * // Print end handler
631
+ * <TelerikReportViewer
632
+ * serviceUrl="api/reports/"
633
+ * reportSource={{ report: "Dashboard.trdp" }}
634
+ * printEnd={(e, args) => {
635
+ * console.log("The printed report can be found at " + args.url);
636
+ * }}
637
+ * />
638
+ *
639
+ * @property {function} [renderingBegin] - Called before rendering the report (preview only, not for export or print). Receives two parameters: `e` (the event object) and `args` (an object with property: `deviceInfo` (object)).
640
+ * @example <propertyName>renderingBegin</propertyName>
641
+ * // Rendering begin handler
642
+ * <TelerikReportViewer
643
+ * serviceUrl="api/reports/"
644
+ * reportSource={{ report: "Dashboard.trdp" }}
645
+ * renderingBegin={(e, args) => {
646
+ * // The deviceInfo property can be used to pass a specific culture to the REST Service so it renders the report with it.
647
+ * const culture = "yourCulture";
648
+ * args.deviceInfo["CurrentCulture"] = culture;
649
+ * args.deviceInfo["CurrentUICulture"] = culture;
650
+ * console.log("About to render the report.");
651
+ * }}
652
+ * />
653
+ *
654
+ * @property {function} [renderingEnd] - Called after rendering the report. Receives two parameters: `e` (the event object) and `args` (an object with properties: `bookmarkNodes` (array), `documentMapAvailable` (boolean), `documentMapNodes` (array), `documentReady` (boolean), and `pageCount` (number)).
655
+ * @example <propertyName>renderingEnd</propertyName>
656
+ * // Rendering end handler
657
+ * <TelerikReportViewer
658
+ * serviceUrl="api/reports/"
659
+ * reportSource={{ report: "Dashboard.trdp" }}
660
+ * renderingEnd={(e, args) => {
661
+ * console.log("The rendered report is " + (args.documentReady ? "" : "not ") + "ready.");
662
+ * console.log("The rendered report has " + args.pageCount + " pages.");
663
+ * }}
664
+ * />
665
+ *
666
+ * @property {function} [sendEmailBegin] - Called before the report is exported and the E-mail message is sent. Receives two parameters: `e` (the event object) and `args` (an object with properties: `deviceInfo` (object), `handled` (boolean), and `format` (string)).
667
+ * @example <propertyName>sendEmailBegin</propertyName>
668
+ * // Send email begin handler
669
+ * <TelerikReportViewer
670
+ * serviceUrl="api/reports/"
671
+ * reportSource={{ report: "Dashboard.trdp" }}
672
+ * sendEmailBegin={(e, args) => {
673
+ * console.log("About to export and send report in format: " + args.format);
674
+ * }}
675
+ * />
676
+ *
677
+ * @property {function} [sendEmailEnd] - Called after the report is exported and before the E-mail message is sent. Receives two parameters: `e` (the event object) and `args` (an object with properties: `handled` (boolean), `from` (string), `to` (string), `cc` (string), `format` (string), `subject` (string), `body` (string), and `url` (string)).
678
+ * @example <propertyName>sendEmailEnd</propertyName>
679
+ * // Send email end handler
680
+ * <TelerikReportViewer
681
+ * serviceUrl="api/reports/"
682
+ * reportSource={{ report: "Dashboard.trdp" }}
683
+ * sendEmailEnd={(e, args) => {
684
+ * args.format = "XLS";
685
+ * console.log("The exported report can be found at " + args.url);
686
+ * }}
687
+ * />
688
+ *
689
+ * @property {function} [updateUi] - Called when the state of the viewer changes. Receives one parameter: `e` (the event object).
690
+ * @example <propertyName>updateUi</propertyName>
691
+ * // Update UI handler
692
+ * <TelerikReportViewer
693
+ * serviceUrl="api/reports/"
694
+ * reportSource={{ report: "Dashboard.trdp" }}
695
+ * updateUi={(e) => {
696
+ * console.log("Viewer UI state changed.");
697
+ * }}
698
+ * />
699
+ *
700
+ * @property {function} [pageReady] - Called after a page of the report is ready. Receives two parameters: `e` (the event object) and `args` (an object with property: `pageContent` (string)).
701
+ * @example <propertyName>pageReady</propertyName>
702
+ * // Page ready handler
703
+ * <TelerikReportViewer
704
+ * serviceUrl="api/reports/"
705
+ * reportSource={{ report: "Dashboard.trdp" }}
706
+ * pageReady={(e, args) => {
707
+ * console.log("The content of the page is: " + args.pageContent);
708
+ * }}
709
+ * />
710
+ *
711
+ * @property {function} [error] - Called when an error occurs. Receives two parameters: `e` (the event object) and `args` (a string containing the error message).
712
+ * @example <propertyName>error</propertyName>
713
+ * // Error handler
714
+ * <TelerikReportViewer
715
+ * serviceUrl="api/reports/"
716
+ * reportSource={{ report: "Dashboard.trdp" }}
717
+ * error={(e, args) => {
718
+ * console.log("The error message is: " + args);
719
+ * }}
720
+ * />
721
+ *
722
+ * @property {function} [interactiveActionExecuting] - Called before an interactive action executes, allowing cancellation. Receives two parameters: `e` (the event object) and `args` (an object with properties: `element` (DOM element), `action` ({@link InteractiveAction}), and `cancel` (boolean, set to true to cancel the action)).
723
+ * @example <propertyName>interactiveActionExecuting</propertyName>
724
+ * // Interactive action executing handler
725
+ * <TelerikReportViewer
726
+ * serviceUrl="api/reports/"
727
+ * reportSource={{ report: "Dashboard.trdp" }}
728
+ * interactiveActionExecuting={(e, args) => {
729
+ * if (args.action.Type === "navigateToUrl") {
730
+ * const url = args.action.Value.Url;
731
+ * const target = args.action.Value.Target;
732
+ * }
733
+ * }}
734
+ * />
735
+ *
736
+ * @property {function} [interactiveActionEnter] - Called when entering an interactive action area. Receives two parameters: `e` (the event object) and `args` (an object with properties: `element` (DOM element), `action` ({@link InteractiveAction})).
737
+ * @example <propertyName>interactiveActionEnter</propertyName>
738
+ * // Interactive action enter handler
739
+ * <TelerikReportViewer
740
+ * serviceUrl="api/reports/"
741
+ * reportSource={{ report: "Dashboard.trdp" }}
742
+ * interactiveActionEnter={(e, args) => {
743
+ * if (args.action.Type === "sorting") {
744
+ * // Custom logic for sorting action
745
+ * }
746
+ * }}
747
+ * />
748
+ *
749
+ * @property {function} [interactiveActionLeave] - Called when leaving an interactive action area. Receives two parameters: `e` (the event object) and `args` (an object with properties: `element` (DOM element), `action` ({@link InteractiveAction})).
750
+ * @example <propertyName>interactiveActionLeave</propertyName>
751
+ * // Interactive action leave handler
752
+ * <TelerikReportViewer
753
+ * serviceUrl="api/reports/"
754
+ * reportSource={{ report: "Dashboard.trdp" }}
755
+ * interactiveActionLeave={(e, args) => {
756
+ * if (args.action.Type === "toggleVisibility") {
757
+ * // Custom logic for toggleVisibility action
758
+ * }
759
+ * }}
760
+ * />
761
+ *
762
+ * @property {function} [viewerToolTipOpening] - Called before a tooltip is opened, allowing cancellation. Receives two parameters: `e` (the event object) and `args` (an object with properties: `element` (DOM element), `toolTip` (object with `title` and `text`), and `cancel` (boolean, set to true to cancel the tooltip)).
763
+ * @example <propertyName>viewerToolTipOpening</propertyName>
764
+ * // Viewer tooltip opening handler
765
+ * <TelerikReportViewer
766
+ * serviceUrl="api/reports/"
767
+ * reportSource={{ report: "Dashboard.trdp" }}
768
+ * viewerToolTipOpening={(e, args) => {
769
+ * // Example: disable tooltip if title contains '2004'
770
+ * args.cancel = (/2004/i.test(args.toolTip.title));
771
+ * }}
772
+ * />
773
+ */
774
+
775
+ /**
776
+ * React wrapper component for the Telerik HTML5 Report Viewer.
777
+ * Provides a React-friendly interface to the Telerik Report Viewer functionality.
778
+ *
779
+ * @class TelerikReportViewer
780
+ * @extends {React.Component}
781
+ * @param {TelerikReportViewerProps} props - Configuration props for the component.
782
+ * @example
783
+ * // Basic usage
784
+ * <TelerikReportViewer
785
+ * serviceUrl="api/reports/"
786
+ * reportSource={{ report: "Dashboard.trdp" }}
787
+ * viewerContainerStyle={{ width: '100%', height: '600px' }}
788
+ * />
789
+ *
790
+ * @example
791
+ * // With parameters and event handlers
792
+ * <TelerikReportViewer
793
+ * serviceUrl="api/reports/"
794
+ * reportSource={{
795
+ * report: "SalesReport",
796
+ * parameters: { StartDate: "2024-01-01", EndDate: "2024-12-31" }
797
+ * }}
798
+ * ready={() => console.log("Report viewer is ready")}
799
+ * error={(e, args) => console.error("Error:", args)}
800
+ * viewerContainerStyle={{ width: '100%', height: '800px' }}
801
+ * />
802
+ */
4
803
  export class TelerikReportViewer extends React.Component {
5
804
  constructor() {
6
805
  super();
@@ -71,65 +870,663 @@ export class TelerikReportViewer extends React.Component {
71
870
  ref: el => this.el = el
72
871
  });
73
872
  }
873
+
874
+ /**
875
+ * Reloads/refreshes the current report.
876
+ * @function
877
+ * @returns {TelerikReportViewer} The current ReportViewer object.
878
+ * @example
879
+ * // Using ref to call refreshReport
880
+ * const reportViewerRef = useRef();
881
+ * <TelerikReportViewer ref={reportViewerRef} serviceUrl="api/reports/" reportSource={{ report: "Dashboard.trdp" }} />
882
+ * // ...
883
+ * reportViewerRef.current.refreshReport();
884
+ */
74
885
  refreshReport() {
75
886
  return this.viewerObject.refreshReport();
76
887
  }
888
+
889
+ /**
890
+ * Gets the current ReportSource - report and parameters.
891
+ * @function
892
+ * @returns {{report: string, parameters: Object}} An object with properties: report (string), parameters (JSON).
893
+ * @example
894
+ * // Get current report source
895
+ * const reportSource = reportViewerRef.current.getReportSource();
896
+ * console.log("Current report:", reportSource.report);
897
+ * console.log("Current parameters:", reportSource.parameters);
898
+ */
77
899
  getReportSource() {
78
900
  return this.viewerObject.reportSource();
79
901
  }
902
+
903
+ /**
904
+ * Sets the report source - report and parameters. Automatically reloads the report (if any) into the view.
905
+ * @function
906
+ * @param {{report: string, parameters: Object}} rs - The report source object to set. Object with properties: report (string) and parameters (JSON).
907
+ * @returns {TelerikReportViewer} The current ReportViewer object.
908
+ * @example
909
+ * // Set a new report source
910
+ * reportViewerRef.current.setReportSource({
911
+ * report: "SalesReport",
912
+ * parameters: { StartDate: "2024-01-01", EndDate: "2024-12-31" }
913
+ * });
914
+ */
80
915
  setReportSource(rs) {
81
916
  return this.viewerObject.reportSource(rs);
82
917
  }
918
+
919
+ /**
920
+ * Gets the current view mode.
921
+ * @function
922
+ * @returns {string} The current view mode.
923
+ * @example
924
+ * // Get current view mode
925
+ * const viewMode = reportViewerRef.current.getViewMode();
926
+ * console.log("Current view mode:", viewMode);
927
+ */
83
928
  getViewMode() {
84
929
  return this.viewerObject.viewMode();
85
930
  }
931
+
932
+ /**
933
+ * Sets the view mode and automatically reloads the current report (if any) into the new view.
934
+ * @function
935
+ * @param {string} vm - The view mode to set.
936
+ * @returns {TelerikReportViewer} The current ReportViewer object.
937
+ * @example
938
+ * // Set view mode to print preview
939
+ * reportViewerRef.current.setViewMode("PRINT_PREVIEW");
940
+ */
86
941
  setViewMode(vm) {
87
942
  return this.viewerObject.viewMode(vm);
88
943
  }
944
+
945
+ /**
946
+ * Gets the viewer’s scale factor and scale mode.
947
+ * @function
948
+ * @returns {{scale: number, scaleMode: string}} An object with properties: scale (number), scaleMode (string).
949
+ * @example
950
+ * // Get current scale and scale mode
951
+ * const scaleInfo = reportViewerRef.current.getScale();
952
+ * console.log("Scale:", scaleInfo.scale, "Scale mode:", scaleInfo.scaleMode);
953
+ */
89
954
  getScale() {
90
955
  return this.viewerObject.scale();
91
956
  }
957
+
958
+ /**
959
+ * Sets the scale factor and scale mode.
960
+ * @function
961
+ * @param {{scale: number, scaleMode: string}} scale - The scale object to set.
962
+ * @returns {TelerikReportViewer} The current ReportViewer object.
963
+ * @example
964
+ * // Set scale to 150% and mode to SPECIFIC
965
+ * reportViewerRef.current.setScale({ scale: 1.5, scaleMode: "SPECIFIC" });
966
+ */
92
967
  setScale(scale) {
93
968
  return this.viewerObject.scale(scale);
94
969
  }
970
+
971
+ /**
972
+ * Gets the total page count of viewer’s currently displayed report.
973
+ * @function
974
+ * @returns {number} The total page count.
975
+ * @example
976
+ * // Get total page count
977
+ * const totalPages = reportViewerRef.current.pageCount();
978
+ * console.log("Total pages:", totalPages);
979
+ */
95
980
  pageCount() {
96
981
  return this.viewerObject.pageCount();
97
982
  }
983
+
984
+ /**
985
+ * Gets the viewer’s current page that is displayed.
986
+ * @function
987
+ * @returns {number} The current page number (1-based).
988
+ * @example
989
+ * // Get current page number
990
+ * const currentPage = reportViewerRef.current.currentPage();
991
+ * console.log("Current page:", currentPage);
992
+ */
98
993
  currentPage() {
99
994
  return this.viewerObject.currentPage();
100
995
  }
996
+
997
+ /**
998
+ * Sets the authentication token.
999
+ * @function
1000
+ * @param {string} token - The authentication token to set.
1001
+ * @returns {TelerikReportViewer} The current ReportViewer object.
1002
+ * @example
1003
+ * // Set authentication token
1004
+ * reportViewerRef.current.setAuthenticationToken("YOUR_AUTH_TOKEN");
1005
+ */
101
1006
  setAuthenticationToken(token) {
102
1007
  return this.viewerObject.authenticationToken(token);
103
1008
  }
1009
+
1010
+ /**
1011
+ * Gets the shortcut keys used when the report viewer is in accessible mode (enableAccessibility=true).
1012
+ * @function
1013
+ * @returns {Object} The current accessibility key map.
1014
+ * @example
1015
+ * // Get accessibility key map
1016
+ * const keyMap = reportViewerRef.current.getAccessibilityKeyMap();
1017
+ * if (keyMap) {
1018
+ * console.log("Accessibility key map:", keyMap);
1019
+ * }
1020
+ */
104
1021
  getAccessibilityKeyMap() {
105
1022
  return this.viewerObject.accessibilityKeyMap();
106
1023
  }
1024
+
1025
+ /**
1026
+ * Sets the shortcut keys used when the report viewer is in accessible mode. It is recommended to set the new key map when the report rendering is complete, because the accessibility routines require the report viewer template to be loaded.
1027
+ * @function
1028
+ * @param {Object} keyMap - The key map object with keyboard shortcuts.
1029
+ * @returns {TelerikReportViewer} The current ReportViewer object.
1030
+ * @example
1031
+ * // Set custom accessibility key map
1032
+ * reportViewerRef.current.setAccessibilityKeyMap({
1033
+ * CONFIRM_KEY: 13,
1034
+ * MENU_AREA_KEY: 77,
1035
+ * CONTENT_AREA_KEY: 67,
1036
+ * PARAMETERS_AREA_KEY: 80,
1037
+ * DOCUMENT_MAP_AREA_KEY: 68
1038
+ * });
1039
+ */
107
1040
  setAccessibilityKeyMap(keyMap) {
108
1041
  return this.viewerObject.accessibilityKeyMap(keyMap);
109
1042
  }
1043
+
1044
+ /**
1045
+ * Binds an event handler to the specified event.
1046
+ * @function
1047
+ * @param {string} eventName - The name of the event to bind to.
1048
+ * @param {function} eventHandler - The handler function to invoke when the event occurs.
1049
+ * @example
1050
+ * // Bind to pageReady event
1051
+ * reportViewerRef.current.bind("pageReady", (e, args) => {
1052
+ * console.log("Page is ready!", args);
1053
+ * });
1054
+ *
1055
+ * @example
1056
+ * // Bind to error event
1057
+ * reportViewerRef.current.bind("error", (e, args) => {
1058
+ * console.error("Report viewer error:", args);
1059
+ * });
1060
+ */
110
1061
  bind(eventName, eventHandler) {
111
1062
  this.viewerObject.bind(eventName, eventHandler);
112
1063
  }
1064
+
1065
+ /**
1066
+ * Unbinds an event handler from the specified event.
1067
+ * @function
1068
+ * @param {string} eventName - The name of the event to unbind from.
1069
+ * @param {function} [eventHandler] - The handler function to remove. If omitted, all handlers are removed.
1070
+ * @example
1071
+ * // Unbind specific handler
1072
+ * reportViewerRef.current.unbind("error", myErrorHandler);
1073
+ *
1074
+ * @example
1075
+ * // Unbind all handlers for an event
1076
+ * reportViewerRef.current.unbind("pageReady");
1077
+ */
113
1078
  unbind(eventName, eventHandler) {
114
1079
  this.viewerObject.unbind(eventName, eventHandler);
115
1080
  }
1081
+
1082
+ /**
1083
+ * Unbinds all event handlers from the specified event.
1084
+ * @function
1085
+ * @param {string} eventName - The name of the event to unbind all handlers from.
1086
+ * @example
1087
+ * // Unbind all error handlers
1088
+ * reportViewerRef.current.unbindAll("error");
1089
+ */
116
1090
  unbindAll(eventName) {
117
1091
  this.viewerObject.unbind(eventName);
118
1092
  }
1093
+
1094
+ /**
1095
+ * Gets the current page mode of the viewer.
1096
+ * @function
1097
+ * @returns {string} The current page mode (e.g., "SINGLE_PAGE" or "CONTINUOUS_SCROLL").
1098
+ * @example
1099
+ * // Get current page mode
1100
+ * const pageMode = reportViewerRef.current.getPageMode();
1101
+ * console.log("Current page mode:", pageMode);
1102
+ */
119
1103
  getPageMode() {
120
1104
  return this.viewerObject.pageMode();
121
1105
  }
1106
+
1107
+ /**
1108
+ * Sets the page mode of the viewer.
1109
+ * @function
1110
+ * @param {string} psm - The page mode to set (use PageModes constants).
1111
+ * @returns {*} The result from the underlying report viewer's pageMode method.
1112
+ * @example
1113
+ * // Set page mode to single page
1114
+ * reportViewerRef.current.setPageMode("SINGLE_PAGE");
1115
+ */
122
1116
  setPageMode(psm) {
123
1117
  return this.viewerObject.pageMode(psm);
124
1118
  }
1119
+
1120
+ /**
1121
+ * Clears the current reportSource from the viewer internal state and from its persisted session in the browser. Called in order to force the viewer to respect the newly set reportSource on the next postback.
1122
+ * @function
1123
+ * @returns {void}
1124
+ * @example
1125
+ * // Clear report source before setting a new one
1126
+ * reportViewerRef.current.clearReportSource();
1127
+ * reportViewerRef.current.setReportSource({ report: "NewReport" });
1128
+ */
125
1129
  clearReportSource() {
126
1130
  return this.viewerObject.clearReportSource();
127
1131
  }
1132
+
1133
+ /**
1134
+ * Stops sending keep alive requests to the server, if keep client alive was enabled. Disposes the viewer instance, cleaning up resources and event handlers. Should be called when the component is unmounted or no longer needed.
1135
+ * @function
1136
+ * @returns {void}
1137
+ * @example
1138
+ * // Manually dispose the viewer
1139
+ * reportViewerRef.current.dispose();
1140
+ */
128
1141
  dispose() {
129
1142
  return this.viewerObject.dispose();
130
1143
  }
1144
+
1145
+ /**
1146
+ * Returns an immutable array of name-value objects representing the current evaluated report parameters.
1147
+ * @function
1148
+ * @returns {Array<{name: string, value: any}>} Array containing the name and the value of each report parameter.
1149
+ * @example
1150
+ * // Get current report parameters
1151
+ * const parameters = reportViewerRef.current.getReportParameters();
1152
+ * parameters.forEach(param => {
1153
+ * console.log(`Parameter ${param.name}: ${param.value}`);
1154
+ * });
1155
+ */
131
1156
  getReportParameters() {
132
1157
  return this.viewerObject.getReportParameters();
133
1158
  }
134
1159
  }
135
- export default TelerikReportViewer;
1160
+ export default TelerikReportViewer;
1161
+
1162
+ /**
1163
+ * Represents a command that can be executed on the report viewer.
1164
+ * Each command is an object with the following methods:
1165
+ * - exec(): Executes the command (optionally with parameters).
1166
+ * - enabled(): Returns a boolean indicating if the command is currently enabled.
1167
+ * - checked(): Returns a boolean indicating if the command is in a checked state (for toggle commands).
1168
+ *
1169
+ * @typedef {Object} ReportViewerCommand
1170
+ * @property {Function} exec - Executes the command. Some commands accept parameters (see below).
1171
+ * @property {Function} enabled - Returns whether the command is currently enabled.
1172
+ * @property {Function} checked - Returns whether the command is in a checked state (for toggle commands).
1173
+ */
1174
+
1175
+ /**
1176
+ * Collection of all available commands for the report viewer. Each property is a command name mapped to a {@link ReportViewerCommand} instance.
1177
+ *
1178
+ * @typedef {Object} ReportViewerCommands
1179
+
1180
+ * @property {ReportViewerCommand} historyBack - Goes back to the previously rendered report from history.
1181
+ * @example <propertyName>historyBack</propertyName>
1182
+ * // Execute the command
1183
+ * let viewer;
1184
+ * ReactDOM.render(
1185
+ * <>
1186
+ * <TelerikReportViewer />
1187
+ * <button onClick={() => viewer.commands.historyBack.exec()}>Back</button>
1188
+ * </>
1189
+ * );
1190
+ * @example <propertyName>historyBack</propertyName>
1191
+ * // Check if the command is enabled
1192
+ * const isEnabled = viewer.commands.historyBack.enabled();
1193
+ * @example <propertyName>historyBack</propertyName>
1194
+ * // Check if the command is checked
1195
+ * const isChecked = viewer.commands.historyBack.checked();
1196
+ * @property {ReportViewerCommand} historyForward - Goes forward to the next rendered report from history.
1197
+ * @example <propertyName>historyForward</propertyName>
1198
+ * // Execute the command
1199
+ * let viewer;
1200
+ * ReactDOM.render(
1201
+ * <>
1202
+ * <TelerikReportViewer />
1203
+ * <button onClick={() => viewer.commands.historyForward.exec()}>Forward</button>
1204
+ * </>
1205
+ * );
1206
+ * @example <propertyName>historyForward</propertyName>
1207
+ * // Check if the command is enabled
1208
+ * const isEnabled = viewer.commands.historyForward.enabled();
1209
+ * @example <propertyName>historyForward</propertyName>
1210
+ * // Check if the command is checked
1211
+ * const isChecked = viewer.commands.historyForward.checked();
1212
+ * @property {ReportViewerCommand} refresh - Refreshes the report.
1213
+ * @example <propertyName>refresh</propertyName>
1214
+ * // Execute the command
1215
+ * let viewer;
1216
+ * ReactDOM.render(
1217
+ * <>
1218
+ * <TelerikReportViewer />
1219
+ * <button onClick={() => viewer.commands.refresh.exec()}>Refresh</button>
1220
+ * </>
1221
+ * );
1222
+ * @example <propertyName>refresh</propertyName>
1223
+ * // Check if the command is enabled
1224
+ * const isEnabled = viewer.commands.refresh.enabled();
1225
+ * @example <propertyName>refresh</propertyName>
1226
+ * // Check if the command is checked
1227
+ * const isChecked = viewer.commands.refresh.checked();
1228
+ * @property {ReportViewerCommand} goToFirstPage - Goes to the first page of the report.
1229
+ * @example <propertyName>goToFirstPage</propertyName>
1230
+ * // Execute the command
1231
+ * let viewer;
1232
+ * ReactDOM.render(
1233
+ * <>
1234
+ * <TelerikReportViewer />
1235
+ * <button onClick={() => viewer.commands.goToFirstPage.exec()}>First Page</button>
1236
+ * </>
1237
+ * );
1238
+ * @example <propertyName>goToFirstPage</propertyName>
1239
+ * // Check if the command is enabled
1240
+ * const isEnabled = viewer.commands.goToFirstPage.enabled();
1241
+ * @example <propertyName>goToFirstPage</propertyName>
1242
+ * // Check if the command is checked
1243
+ * const isChecked = viewer.commands.goToFirstPage.checked();
1244
+ * @property {ReportViewerCommand} goToPrevPage - Goes to the previous page of the report.
1245
+ * @example <propertyName>goToPrevPage</propertyName>
1246
+ * // Execute the command
1247
+ * let viewer;
1248
+ * ReactDOM.render(
1249
+ * <>
1250
+ * <TelerikReportViewer />
1251
+ * <button onClick={() => viewer.commands.goToPrevPage.exec()}>Previous</button>
1252
+ * </>
1253
+ * );
1254
+ * @example <propertyName>goToPrevPage</propertyName>
1255
+ * // Check if the command is enabled
1256
+ * const isEnabled = viewer.commands.goToPrevPage.enabled();
1257
+ * @example <propertyName>goToPrevPage</propertyName>
1258
+ * // Check if the command is checked
1259
+ * const isChecked = viewer.commands.goToPrevPage.checked();
1260
+ * @property {ReportViewerCommand} goToPage - Goes to a specific page of the report. Accepts a page number as parameter: exec(pageNumber).
1261
+ * @example <propertyName>goToPage</propertyName>
1262
+ * // Execute the command
1263
+ * let viewer;
1264
+ * ReactDOM.render(
1265
+ * <>
1266
+ * <TelerikReportViewer />
1267
+ * <button onClick={() => viewer.commands.goToPage.exec(5)}>Go to Page 5</button>
1268
+ * </>
1269
+ * );
1270
+ * @example <propertyName>goToPage</propertyName>
1271
+ * // Check if the command is enabled
1272
+ * const isEnabled = viewer.commands.goToPage.enabled();
1273
+ * @example <propertyName>goToPage</propertyName>
1274
+ * // Check if the command is checked
1275
+ * const isChecked = viewer.commands.goToPage.checked();
1276
+ * @property {ReportViewerCommand} goToNextPage - Goes to the next page of the report.
1277
+ * @example <propertyName>goToNextPage</propertyName>
1278
+ * // Execute the command
1279
+ * let viewer;
1280
+ * ReactDOM.render(
1281
+ * <>
1282
+ * <TelerikReportViewer />
1283
+ * <button onClick={() => viewer.commands.goToNextPage.exec()}>Next</button>
1284
+ * </>
1285
+ * );
1286
+ * @example <propertyName>goToNextPage</propertyName>
1287
+ * // Check if the command is enabled
1288
+ * const isEnabled = viewer.commands.goToNextPage.enabled();
1289
+ * @example <propertyName>goToNextPage</propertyName>
1290
+ * // Check if the command is checked
1291
+ * const isChecked = viewer.commands.goToNextPage.checked();
1292
+ * @property {ReportViewerCommand} goToLastPage - Goes to the last page of the report.
1293
+ * @example <propertyName>goToLastPage</propertyName>
1294
+ * // Execute the command
1295
+ * let viewer;
1296
+ * ReactDOM.render(
1297
+ * <>
1298
+ * <TelerikReportViewer />
1299
+ * <button onClick={() => viewer.commands.goToLastPage.exec()}>Last Page</button>
1300
+ * </>
1301
+ * );
1302
+ * @example <propertyName>goToLastPage</propertyName>
1303
+ * // Check if the command is enabled
1304
+ * const isEnabled = viewer.commands.goToLastPage.enabled();
1305
+ * @example <propertyName>goToLastPage</propertyName>
1306
+ * // Check if the command is checked
1307
+ * const isChecked = viewer.commands.goToLastPage.checked();
1308
+ * @property {ReportViewerCommand} togglePrintPreview - Toggles between Print Preview and Interactive view modes.
1309
+ * @example <propertyName>togglePrintPreview</propertyName>
1310
+ * // Execute the command
1311
+ * let viewer;
1312
+ * ReactDOM.render(
1313
+ * <>
1314
+ * <TelerikReportViewer />
1315
+ * <button onClick={() => viewer.commands.togglePrintPreview.exec()}>Toggle Print Preview</button>
1316
+ * </>
1317
+ * );
1318
+ * @example <propertyName>togglePrintPreview</propertyName>
1319
+ * // Check if the command is enabled
1320
+ * const isEnabled = viewer.commands.togglePrintPreview.enabled();
1321
+ * @example <propertyName>togglePrintPreview</propertyName>
1322
+ * // Check if the command is checked
1323
+ * const isChecked = viewer.commands.togglePrintPreview.checked();
1324
+ * @property {ReportViewerCommand} export - Exports the report, using the respective rendering extension name. Accepts a rendering extension name as parameter: exec("PDF"), exec("XLSX"), etc.
1325
+ * @example <propertyName>export</propertyName>
1326
+ * // Execute the command
1327
+ * let viewer;
1328
+ * ReactDOM.render(
1329
+ * <>
1330
+ * <TelerikReportViewer />
1331
+ * <button onClick={() => viewer.commands.export.exec('PDF')}>Export PDF</button>
1332
+ * </>
1333
+ * );
1334
+ * @example <propertyName>export</propertyName>
1335
+ * // Check if the command is enabled
1336
+ * const isEnabled = viewer.commands.export.enabled();
1337
+ * @example <propertyName>export</propertyName>
1338
+ * // Check if the command is checked
1339
+ * const isChecked = viewer.commands.export.checked();
1340
+ * @property {ReportViewerCommand} print - Triggers the report printing.
1341
+ * @example <propertyName>print</propertyName>
1342
+ * // Execute the command
1343
+ * let viewer;
1344
+ * ReactDOM.render(
1345
+ * <>
1346
+ * <TelerikReportViewer />
1347
+ * <button onClick={() => viewer.commands.print.exec()}>Print</button>
1348
+ * </>
1349
+ * );
1350
+ * @example <propertyName>print</propertyName>
1351
+ * // Check if the command is enabled
1352
+ * const isEnabled = viewer.commands.print.enabled();
1353
+ * @example <propertyName>print</propertyName>
1354
+ * // Check if the command is checked
1355
+ * const isChecked = viewer.commands.print.checked();
1356
+ * @property {ReportViewerCommand} toggleDocumentMap - Shows or hides the document map.
1357
+ * @example <propertyName>toggleDocumentMap</propertyName>
1358
+ * // Execute the command
1359
+ * let viewer;
1360
+ * ReactDOM.render(
1361
+ * <>
1362
+ * <TelerikReportViewer />
1363
+ * <button onClick={() => viewer.commands.toggleDocumentMap.exec()}>Toggle Document Map</button>
1364
+ * </>
1365
+ * );
1366
+ * @example <propertyName>toggleDocumentMap</propertyName>
1367
+ * // Check if the command is enabled
1368
+ * const isEnabled = viewer.commands.toggleDocumentMap.enabled();
1369
+ * @example <propertyName>toggleDocumentMap</propertyName>
1370
+ * // Check if the command is checked
1371
+ * const isChecked = viewer.commands.toggleDocumentMap.checked();
1372
+ * @property {ReportViewerCommand} toggleParametersArea - Shows or hides the parameters area.
1373
+ * @example <propertyName>toggleParametersArea</propertyName>
1374
+ * // Execute the command
1375
+ * let viewer;
1376
+ * ReactDOM.render(
1377
+ * <>
1378
+ * <TelerikReportViewer />
1379
+ * <button onClick={() => viewer.commands.toggleParametersArea.exec()}>Toggle Parameters</button>
1380
+ * </>
1381
+ * );
1382
+ * @example <propertyName>toggleParametersArea</propertyName>
1383
+ * // Check if the command is enabled
1384
+ * const isEnabled = viewer.commands.toggleParametersArea.enabled();
1385
+ * @example <propertyName>toggleParametersArea</propertyName>
1386
+ * // Check if the command is checked
1387
+ * const isChecked = viewer.commands.toggleParametersArea.checked();
1388
+ * @property {ReportViewerCommand} zoomIn - Zoom-in the report.
1389
+ * @example <propertyName>zoomIn</propertyName>
1390
+ * // Execute the command
1391
+ * let viewer;
1392
+ * ReactDOM.render(
1393
+ * <>
1394
+ * <TelerikReportViewer />
1395
+ * <button onClick={() => viewer.commands.zoomIn.exec()}>Zoom In</button>
1396
+ * </>
1397
+ * );
1398
+ * @example <propertyName>zoomIn</propertyName>
1399
+ * // Check if the command is enabled
1400
+ * const isEnabled = viewer.commands.zoomIn.enabled();
1401
+ * @example <propertyName>zoomIn</propertyName>
1402
+ * // Check if the command is checked
1403
+ * const isChecked = viewer.commands.zoomIn.checked();
1404
+ * @property {ReportViewerCommand} zoomOut - Zoom-out the report.
1405
+ * @example <propertyName>zoomOut</propertyName>
1406
+ * // Execute the command
1407
+ * let viewer;
1408
+ * ReactDOM.render(
1409
+ * <>
1410
+ * <TelerikReportViewer />
1411
+ * <button onClick={() => viewer.commands.zoomOut.exec()}>Zoom Out</button>
1412
+ * </>
1413
+ * );
1414
+ * @example <propertyName>zoomOut</propertyName>
1415
+ * // Check if the command is enabled
1416
+ * const isEnabled = viewer.commands.zoomOut.enabled();
1417
+ * @example <propertyName>zoomOut</propertyName>
1418
+ * // Check if the command is checked
1419
+ * const isChecked = viewer.commands.zoomOut.checked();
1420
+ * @property {ReportViewerCommand} zoom - Zoom with a specified ratio. Accepts a zoom ratio as parameter: exec(1.5).
1421
+ * @example <propertyName>zoom</propertyName>
1422
+ * // Execute the command
1423
+ * let viewer;
1424
+ * ReactDOM.render(
1425
+ * <>
1426
+ * <TelerikReportViewer />
1427
+ * <button onClick={() => viewer.commands.zoom.exec(1.5)}>Zoom 150%</button>
1428
+ * </>
1429
+ * );
1430
+ * @example <propertyName>zoom</propertyName>
1431
+ * // Check if the command is enabled
1432
+ * const isEnabled = viewer.commands.zoom.enabled();
1433
+ * @example <propertyName>zoom</propertyName>
1434
+ * // Check if the command is checked
1435
+ * const isChecked = viewer.commands.zoom.checked();
1436
+ * @property {ReportViewerCommand} toggleZoomMode - Changes the zoom mode of the report.
1437
+ * @example <propertyName>toggleZoomMode</propertyName>
1438
+ * // Execute the command
1439
+ * let viewer;
1440
+ * ReactDOM.render(
1441
+ * <>
1442
+ * <TelerikReportViewer />
1443
+ * <button onClick={() => viewer.commands.toggleZoomMode.exec()}>Toggle Zoom Mode</button>
1444
+ * </>
1445
+ * );
1446
+ * @example <propertyName>toggleZoomMode</propertyName>
1447
+ * // Check if the command is enabled
1448
+ * const isEnabled = viewer.commands.toggleZoomMode.enabled();
1449
+ * @example <propertyName>toggleZoomMode</propertyName>
1450
+ * // Check if the command is checked
1451
+ * const isChecked = viewer.commands.toggleZoomMode.checked();
1452
+ * @property {ReportViewerCommand} toggleSideMenu - Shows or hides the side menu.
1453
+ * @example <propertyName>toggleSideMenu</propertyName>
1454
+ * // Execute the command
1455
+ * let viewer;
1456
+ * ReactDOM.render(
1457
+ * <>
1458
+ * <TelerikReportViewer />
1459
+ * <button onClick={() => viewer.commands.toggleSideMenu.exec()}>Toggle Side Menu</button>
1460
+ * </>
1461
+ * );
1462
+ * @example <propertyName>toggleSideMenu</propertyName>
1463
+ * // Check if the command is enabled
1464
+ * const isEnabled = viewer.commands.toggleSideMenu.enabled();
1465
+ * @example <propertyName>toggleSideMenu</propertyName>
1466
+ * // Check if the command is checked
1467
+ * const isChecked = viewer.commands.toggleSideMenu.checked();
1468
+ * @property {ReportViewerCommand} toggleSearchDialog - Shows or hides the search dialog.
1469
+ * @example <propertyName>toggleSearchDialog</propertyName>
1470
+ * // Execute the command
1471
+ * let viewer;
1472
+ * ReactDOM.render(
1473
+ * <>
1474
+ * <TelerikReportViewer />
1475
+ * <button onClick={() => viewer.commands.toggleSearchDialog.exec()}>Toggle Search</button>
1476
+ * </>
1477
+ * );
1478
+ * @example <propertyName>toggleSearchDialog</propertyName>
1479
+ * // Check if the command is enabled
1480
+ * const isEnabled = viewer.commands.toggleSearchDialog.enabled();
1481
+ * @example <propertyName>toggleSearchDialog</propertyName>
1482
+ * // Check if the command is checked
1483
+ * const isChecked = viewer.commands.toggleSearchDialog.checked();
1484
+ * @property {ReportViewerCommand} stopRendering - Stops the rendering of the current report.
1485
+ * @example <propertyName>stopRendering</propertyName>
1486
+ * // Execute the command
1487
+ * let viewer;
1488
+ * ReactDOM.render(
1489
+ * <>
1490
+ * <TelerikReportViewer />
1491
+ * <button onClick={() => viewer.commands.stopRendering.exec()}>Stop Rendering</button>
1492
+ * </>
1493
+ * );
1494
+ * @example <propertyName>stopRendering</propertyName>
1495
+ * // Check if the command is enabled
1496
+ * const isEnabled = viewer.commands.stopRendering.enabled();
1497
+ * @example <propertyName>stopRendering</propertyName>
1498
+ * // Check if the command is checked
1499
+ * const isChecked = viewer.commands.stopRendering.checked();
1500
+ * @property {ReportViewerCommand} toggleSendEmailDialog - Shows or hides the send email dialog.
1501
+ * @example <propertyName>toggleSendEmailDialog</propertyName>
1502
+ * // Execute the command
1503
+ * let viewer;
1504
+ * ReactDOM.render(
1505
+ * <>
1506
+ * <TelerikReportViewer />
1507
+ * <button onClick={() => viewer.commands.toggleSendEmailDialog.exec()}>Toggle Send Email</button>
1508
+ * </>
1509
+ * );
1510
+ * @example <propertyName>toggleSendEmailDialog</propertyName>
1511
+ * // Check if the command is enabled
1512
+ * const isEnabled = viewer.commands.toggleSendEmailDialog.enabled();
1513
+ * @example <propertyName>toggleSendEmailDialog</propertyName>
1514
+ * // Check if the command is checked
1515
+ * const isChecked = viewer.commands.toggleSendEmailDialog.checked();
1516
+ * @property {ReportViewerCommand} toggleAiPromptDialog - Shows or hides the AI prompt dialog.
1517
+ * @example <propertyName>toggleAiPromptDialog</propertyName>
1518
+ * // Execute the command
1519
+ * let viewer;
1520
+ * ReactDOM.render(
1521
+ * <>
1522
+ * <TelerikReportViewer />
1523
+ * <button onClick={() => viewer.commands.toggleAiPromptDialog.exec()}>Toggle AI Prompt</button>
1524
+ * </>
1525
+ * );
1526
+ * @example <propertyName>toggleAiPromptDialog</propertyName>
1527
+ * // Check if the command is enabled
1528
+ * const isEnabled = viewer.commands.toggleAiPromptDialog.enabled();
1529
+ * @example <propertyName>toggleAiPromptDialog</propertyName>
1530
+ * // Check if the command is checked
1531
+ * const isChecked = viewer.commands.toggleAiPromptDialog.checked();
1532
+ */