powerbi-client-react 1.3.5 → 1.4.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/LICENSE.txt CHANGED
@@ -1,3 +1,5 @@
1
+ powerbi-client-react
2
+
1
3
  Copyright (c) Microsoft Corporation.
2
4
 
3
5
  MIT License
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # powerbi-client-react
2
- Power BI React component. This library lets you embed Power BI report, dashboard, dashboard tile, report visual, or Q&A in your React application.
2
+ Power BI React component. This library enables you to embed Power BI reports, dashboards, dashboard tiles, report visuals, Q&A or paginated reports in your React application, and to create new Power BI reports directly in your application.
3
3
 
4
4
  ## Quick Start
5
5
 
@@ -13,11 +13,11 @@ import { PowerBIEmbed } from 'powerbi-client-react';
13
13
  ```jsx
14
14
  <PowerBIEmbed
15
15
  embedConfig = {{
16
- type: 'report', // Supported types: report, dashboard, tile, visual and qna
16
+ type: 'report', // Supported types: report, dashboard, tile, visual, qna, paginated report and create
17
17
  id: '<Report Id>',
18
18
  embedUrl: '<Embed Url>',
19
19
  accessToken: '<Access Token>',
20
- tokenType: models.TokenType.Embed,
20
+ tokenType: models.TokenType.Embed, // Use models.TokenType.Aad for SaaS embed
21
21
  settings: {
22
22
  panes: {
23
23
  filters: {
@@ -29,15 +29,17 @@ import { PowerBIEmbed } from 'powerbi-client-react';
29
29
  }
30
30
  }}
31
31
 
32
- eventHandlers = {
32
+ eventHandlers = {
33
33
  new Map([
34
34
  ['loaded', function () {console.log('Report loaded');}],
35
35
  ['rendered', function () {console.log('Report rendered');}],
36
- ['error', function (event) {console.log(event.detail);}]
36
+ ['error', function (event) {console.log(event.detail);}],
37
+ ['visualClicked', () => console.log('visual clicked')],
38
+ ['pageChanged', (event) => console.log(event)],
37
39
  ])
38
40
  }
39
-
40
- cssClassName = { "report-style-class" }
41
+
42
+ cssClassName = { "reportClass" }
41
43
 
42
44
  getEmbeddedComponent = { (embeddedReport) => {
43
45
  this.report = embeddedReport as Report;
@@ -45,30 +47,31 @@ import { PowerBIEmbed } from 'powerbi-client-react';
45
47
  />
46
48
  ```
47
49
 
48
- ### How to [bootstrap a PowerBI report](https://aka.ms/PbieBootstrap):
50
+ ### How to [bootstrap a PowerBI report](https://learn.microsoft.com/javascript/api/overview/powerbi/bootstrap-better-performance):
49
51
  ```jsx
50
52
  <PowerBIEmbed
51
53
  embedConfig = {{
52
- type: 'report', // Supported types: report, dashboard, tile, visual and qna
53
- id: undefined,
54
+ type: 'report', // Supported types: report, dashboard, tile, visual, qna and paginated report
55
+ id: undefined,
54
56
  embedUrl: undefined,
55
57
  accessToken: undefined, // Keep as empty string, null or undefined
56
58
  tokenType: models.TokenType.Embed
57
59
  }}
58
60
  />
59
61
  ```
60
- __Note__: To embed the report after bootstrap, update the props (with atleast accessToken).
62
+ __Note__: To embed the report after bootstrap, update the props (with at least accessToken).
61
63
 
62
64
  ### Demo
63
65
 
64
- A React application that embeds a sample report using the _PowerBIEmbed_ component.<br/>
65
- It demonstrates the complete flow from bootstrapping the report, to embedding and updating the embedded report.<br/>
66
- It also demonstrates the usage of _powerbi report authoring_ library by deleting a visual from report on click of "Delete a Visual" button.
66
+ This demo includes a React application that demonstrates the complete flow of embedding a sample report using the PowerBIEmbed component.
67
+
68
+ The demo shows how to bootstrap the report, embed it, and update it. Additionally, the demo showcases the usage of the powerbi report authoring library by enabling the user to change the type of visual from a report using the "Change visual type" button.
69
+
70
+ The demo also sets a "DataSelected" event, which allows the user to interact with the embedded report and retrieve information about the selected data.
67
71
 
68
72
  To run the demo on localhost, run the following commands:
69
73
 
70
74
  ```
71
- npm run install:demo
72
75
  npm run demo
73
76
  ```
74
77
 
@@ -77,18 +80,19 @@ Redirect to http://localhost:8080/ to view in the browser.
77
80
  ### Usage
78
81
  |Use case|Details|
79
82
  |:------|:------|
80
- |Embed Power BI|To embed your powerbi artifact, pass the component with atleast _type_, _embedUrl_ and _accessToken_ in _embedConfig_ prop.|
83
+ |Embed Power BI|To embed your powerbi artifact, pass the component with at least _type_, _embedUrl_ and _accessToken_ in _embedConfig_ prop.|
81
84
  |Get reference to the embedded object|Pass a callback method which accepts the embedded object as parameter to the _getEmbed_ of props.<br/>Refer to the _getEmbed_ prop in [Quick Start](#quick-start).|
82
85
  |Apply style class|Pass the name(s) of style classes to be added to the embed container div to the _cssClassName_ props.|
83
86
  |Set event handlers|Pass a map object of event name (string) and event handler (function) to the _eventHandlers_ prop. <br/>__Key__: Event name <br/>__Value__: Event handler method to be triggered<br/>Event handler method takes 2 optional params:<br/>First parameter: Event<br/>Second parameter: Reference to the embedded entity|
84
87
  |Reset event handlers|To reset event handler for an event, set the event handler's value as `null` in the _eventHandlers_ map of props.|
85
88
  |Set new accessToken|To set new accessToken in the same embedded powerbi artifact, pass the updated _accessToken_ in _embedConfig_ of props. <br/>Reload manually with report.reload() after providing new token if the current token in report has already expired<br/>Example scenario: _Current token has expired_.|
86
89
  |Update settings (Report type only)|To update the report settings, update the _embedConfig.settings_ property of props.<br/>Refer to the _embedConfig.settings_ prop in [Quick Start](#quick-start).<br/>__Note__: Update the settings only by updating embedConfig prop|
87
- |Bootstrap Power BI|To [bootstrap your powerbi entity](https://aka.ms/PbieBootstrap), pass the props to the component without _accessToken_ in _embedConfig_.<br/>__Note__: _embedConfig_ of props should atleast contain __type__ of the powerbi entity being embedded. <br/>Available types: "report", "dashboard", "tile", "visual" and "qna".<br/>Refer to _How to bootstrap a report_ section in [Quick Start](#quick-start).|
90
+ |Bootstrap Power BI|To [bootstrap your powerbi entity](https://learn.microsoft.com/javascript/api/overview/powerbi/bootstrap-better-performance), pass the props to the component without _accessToken_ in _embedConfig_.<br/>__Note__: _embedConfig_ of props should at least contain __type__ of the powerbi entity being embedded. <br/>Available types: "report", "dashboard", "tile", "visual", "qna" and "paginated report".<br/>Refer to _How to bootstrap a report_ section in [Quick Start](#quick-start).|
88
91
  |Using with PowerBI Report Authoring|1. Install [powerbi-report-authoring](https://www.npmjs.com/package/powerbi-report-authoring) as npm dependency.<br>2. Use the report authoring APIs using the embedded report's instance|
89
- |Phased embedding (Report type only)|Set phasedEmbedding prop's value as `true` <br/> Refer to [Phased embedding docs](https://github.com/microsoft/PowerBI-JavaScript/wiki/Phased-Embedding).|
92
+ |Phased embedding (Report type only)|Set phasedEmbedding prop's value as `true` <br/> Refer to [Phased embedding docs](https://learn.microsoft.com/javascript/api/overview/powerbi/phased-embedding).|
90
93
  |Apply Filters (Report type only)|1. To apply updated filters, update filters in _embedConfig_ props.<br/>2. To remove the applied filters, update the _embedConfig_ prop with the filters removed or set as undefined/null.|
91
- |Set Page (Report type only)|To set a page when embedding a report or on an embedded report, provide pageName field in the _embedConfig_.
94
+ |Set Page (Report type only)|To set a page when embedding a report or on an embedded report, provide pageName field in the _embedConfig_.|
95
+ |Create report|To create a new report, pass the component with at least _type_, _embedUrl_ and _datasetId_ in _embedConfig_ prop.|
92
96
 
93
97
  __Note__: To use this library in IE browser, use [react-app-polyfill](https://www.npmjs.com/package/react-app-polyfill) to add support for the incompatible features. Refer to the imports of [demo/index.tsx](https://github.com/microsoft/powerbi-client-react/blob/master/demo/index.tsx).
94
98
 
@@ -105,7 +109,8 @@ interface EmbedProps {
105
109
  | ITileEmbedConfiguration
106
110
  | IQnaEmbedConfiguration
107
111
  | IVisualEmbedConfiguration
108
- | IEmbedConfiguration
112
+ | IPaginatedReportLoadConfiguration
113
+ | IReportCreateConfiguration
109
114
 
110
115
  // Callback method to get the embedded PowerBI entity object (optional)
111
116
  getEmbed?: { (embeddedComponent: Embed): void }
@@ -122,12 +127,67 @@ interface EmbedProps {
122
127
  // Provide instance of PowerBI service (optional)
123
128
  service?: service.Service
124
129
  }
130
+ ```
131
+
125
132
 
126
- type EventHandler = {
127
- (event?: service.ICustomEvent<any>, embeddedEntity?: Embed): void | null;
128
- };
133
+ ## Supported Events
134
+
135
+
136
+ ### Events supported by various Power BI entities:
137
+
138
+ |Entity|Event|
139
+ |:----- |:----- |
140
+ | Report | "buttonClicked", "commandTriggered", "dataHyperlinkClicked", "dataSelected", "loaded", "pageChanged", "rendered", "saveAsTriggered", "saved", "selectionChanged", "visualClicked", "visualRendered" |
141
+ | Dashboard | "loaded", "tileClicked" |
142
+ | Tile | "tileLoaded", "tileClicked" |
143
+ | QnA | "visualRendered" |
144
+
145
+ ### Event Handler to be used with Map
146
+ ```ts
147
+ type EventHandler = (event?: service.ICustomEvent<any>, embeddedEntity?: Embed) => void | null;
129
148
  ```
130
149
 
150
+
151
+ ## Using supported SDK methods for Power BI artifacts
152
+
153
+ ### Import
154
+ *Import the 'PowerBIEmbed' inside your targeted component file:*
155
+ ```ts
156
+ import { PowerBIEmbed } from 'powerbi-client-react';
157
+ ```
158
+
159
+ ### Use
160
+ You can use ```report``` state to call supported SDK APIs.
161
+
162
+ Steps:
163
+ 1. Create one state for storing the report object, for example, ```const [report, setReport] = useState<Report>();```.
164
+
165
+ 2. Use the ```setReport``` method inside the component to set the report object.
166
+ <br />
167
+
168
+ ```ts
169
+ <PowerBIEmbed
170
+ embedConfig = { sampleReportConfig }
171
+ eventHandlers = { eventHandlersMap }
172
+ cssClassName = { reportClass }
173
+ getEmbeddedComponent = { (embedObject: Embed) => {
174
+ setReport(embedObject as Report);
175
+ } }
176
+ />
177
+ ```
178
+
179
+ 3. Once the report object is set, it can be used to call SDK methods such as ```getVisuals```, ```getBookmarks```, etc.
180
+ <br />
181
+
182
+ ```ts
183
+ async getReportPages(): Page[] {
184
+ // this.report is a class variable, initialized in step 3
185
+ const activePage: Page | undefined = await report.getActivePage();
186
+ console.log(pages);
187
+ }
188
+ ```
189
+
190
+
131
191
  ### Dependencies
132
192
 
133
193
  [powerbi-client](https://www.npmjs.com/package/powerbi-client)
@@ -136,10 +196,24 @@ type EventHandler = {
136
196
 
137
197
  [react](https://www.npmjs.com/package/react)
138
198
 
199
+ ### Trademarks
200
+
201
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.
202
+
139
203
  ### Contributing
140
204
 
141
205
  This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
142
206
 
143
207
  When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
144
208
 
145
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments
209
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments
210
+
211
+ ### Data Collection.
212
+
213
+ The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications.
214
+
215
+ If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement.
216
+ Our privacy statement is located at [Microsoft Privacy Statement](https://privacy.microsoft.com/privacystatement). You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
217
+
218
+ ### Support
219
+ Our public support page is available at [Microsoft Support Statement](https://powerbi.microsoft.com/support/).
@@ -1,16 +1,17 @@
1
1
  import * as React from 'react';
2
- import { service, Embed, IEmbedConfiguration, IQnaEmbedConfiguration, IVisualEmbedConfiguration, IReportEmbedConfiguration, IDashboardEmbedConfiguration, ITileEmbedConfiguration } from 'powerbi-client';
2
+ import { service, Embed, IQnaEmbedConfiguration, IVisualEmbedConfiguration, IReportEmbedConfiguration, IDashboardEmbedConfiguration, ITileEmbedConfiguration } from 'powerbi-client';
3
+ import { IReportCreateConfiguration, IPaginatedReportLoadConfiguration } from 'powerbi-models';
3
4
  /**
4
5
  * Type for event handler function of embedded entity
5
6
  */
6
- export declare type EventHandler = {
7
+ export type EventHandler = {
7
8
  (event?: service.ICustomEvent<any>, embeddedEntity?: Embed): void | null;
8
9
  };
9
10
  /**
10
11
  * Props interface for PowerBIEmbed component
11
12
  */
12
13
  export interface EmbedProps {
13
- embedConfig: IReportEmbedConfiguration | IDashboardEmbedConfiguration | ITileEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration | IEmbedConfiguration;
14
+ embedConfig: IReportEmbedConfiguration | IDashboardEmbedConfiguration | ITileEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration | IPaginatedReportLoadConfiguration | IReportCreateConfiguration;
14
15
  getEmbeddedComponent?: {
15
16
  (embeddedComponent: Embed): void;
16
17
  };
@@ -20,6 +21,7 @@ export interface EmbedProps {
20
21
  service?: service.Service;
21
22
  }
22
23
  export declare enum EmbedType {
24
+ Create = "create",
23
25
  Report = "report",
24
26
  Dashboard = "dashboard",
25
27
  Tile = "tile",