powerbi-client-react 2.0.0 → 2.0.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/dist/powerbi-client-react.js +1 -1
- package/dist/powerbi-client-react.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -5
- package/LICENSE.txt +0 -23
- package/README.md +0 -226
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("powerbi-client"),require("lodash.isequal")):"function"==typeof define&&define.amd?define(["react","powerbi-client","lodash.isequal"],t):"object"==typeof exports?exports["powerbi-client-react"]=t(require("react"),require("powerbi-client"),require("lodash.isequal")):e["powerbi-client-react"]=t(e.react,e["powerbi-client"],e["lodash.isequal"])}(self,(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("powerbi-client"),require("lodash.isequal")):"function"==typeof define&&define.amd?define(["react","powerbi-client","lodash.isequal"],t):"object"==typeof exports?exports["powerbi-client-react"]=t(require("react"),require("powerbi-client"),require("lodash.isequal")):e["powerbi-client-react"]=t(e.react,e["powerbi-client"],e["lodash.isequal"])}(self,(e,t,r)=>(()=>{"use strict";var n={155(t){t.exports=e},164(e){e.exports=t},695(e){e.exports=r}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};i.r(s),i.d(s,{EmbedType:()=>p,PowerBIEmbed:()=>h});var a,p,c=i(155),l=i(164),u=i(695),d=i.n(u),f=(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),b=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e.Create="create",e.Report="report",e.Dashboard="dashboard",e.Tile="tile",e.Qna="qna",e.Visual="visual"}(p||(p={}));var h=function(e){function t(t){var r=e.call(this,t)||this;return r.containerRef=c.createRef(),r.prevEventHandlerMapString="",r.props.service?r.powerbi=r.props.service:r.powerbi=new l.service.Service(l.factories.hpmFactory,l.factories.wpmpFactory,l.factories.routerFactory),r.powerbi.setSdkInfo("powerbi-client-react","2.0.1"),r}return f(t,e),Object.defineProperty(t.prototype,"embed",{get:function(){return this._embed},set:function(e){this._embed=e,this.invokeGetEmbedCallback()},enumerable:!1,configurable:!0}),t.prototype.componentDidMount=function(){this.containerRef.current&&(this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl?this.embedEntity():this.embed=this.powerbi.bootstrap(this.containerRef.current,this.props.embedConfig)),this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers)},t.prototype.componentDidUpdate=function(e){return t=this,r=void 0,o=function(){return function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(p){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,p])}}}(this,function(t){return this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers),d()(this.props.embedConfig,e.embedConfig)||this.embedEntity(),[2]})},new((n=void 0)||(n=Promise))(function(e,i){function s(e){try{p(o.next(e))}catch(e){i(e)}}function a(e){try{p(o.throw(e))}catch(e){i(e)}}function p(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(e){e(r)})).then(s,a)}p((o=o.apply(t,r||[])).next())});var t,r,n,o},t.prototype.componentWillUnmount=function(){this.containerRef.current&&this.powerbi.reset(this.containerRef.current),this.prevEventHandlerMapString=""},t.prototype.render=function(){return c.createElement("div",{ref:this.containerRef,className:this.props.cssClassName})},t.prototype.embedEntity=function(){this.containerRef.current&&this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl&&(this.props.phasedEmbedding&&this.props.embedConfig.type===p.Report?this.embed=this.powerbi.load(this.containerRef.current,this.props.embedConfig):(this.props.phasedEmbedding&&console.error("Phased embedding is not supported for type ".concat(this.props.embedConfig.type)),this.props.embedConfig.type===p.Create?this.embed=this.powerbi.createReport(this.containerRef.current,this.props.embedConfig):this.embed=this.powerbi.embed(this.containerRef.current,this.props.embedConfig)))},t.prototype.setEventHandlers=function(e,t){var r=this,n=function(e){if(!e)return"";var t=Array.from(e);return JSON.stringify(t.map(function(e){return[e[0],e[1]?e[1].toString():""]}))}(this.props.eventHandlers);if(this.prevEventHandlerMapString!==n){this.prevEventHandlerMapString=n;var o=l.Embed.allowedEvents,i=e.embedtype;switch(i){case p.Create:break;case p.Report:o=b(b([],o,!0),l.Report.allowedEvents,!0);break;case p.Dashboard:o=b(b([],o,!0),l.Dashboard.allowedEvents,!0);break;case p.Tile:o=b(b([],o,!0),l.Tile.allowedEvents,!0);break;case p.Qna:o=b(b([],o,!0),l.Qna.allowedEvents,!0);break;case p.Visual:o=b(b([],o,!0),l.Visual.allowedEvents,!0);break;default:console.error("Invalid embed type ".concat(i))}var s=[];t.forEach(function(t,n){o.includes(n)?(e.off(n),t&&e.on(n,function(e){t(e,r.embed)})):s.push(n)}),s.length&&console.error("Following events are invalid: ".concat(s.join(",")))}},t.prototype.invokeGetEmbedCallback=function(){this.props.getEmbeddedComponent&&this.embed&&this.props.getEmbeddedComponent(this.embed)},t}(c.Component);return s})());
|
|
2
2
|
//# sourceMappingURL=powerbi-client-react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerbi-client-react.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,SAAUA,QAAQ,kBAAmBA,QAAQ,mBACrD,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,QAAS,iBAAkB,kBAAmBJ,GAC5B,iBAAZC,QACdA,QAAQ,wBAA0BD,EAAQG,QAAQ,SAAUA,QAAQ,kBAAmBA,QAAQ,mBAE/FJ,EAAK,wBAA0BC,EAAQD,EAAY,MAAGA,EAAK,kBAAmBA,EAAK,kBACpF,CATD,CASGO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+B,GAGrCnB,EAAgBoB,SAAQ,SAACC,EAAoBC,GAExCX,EAAcY,SAASD,IAG1B1C,EAAM4C,IAAIF,GAGND,GAGHzC,EAAM6C,GAAGH,GAAW,SAACI,GACpBL,EAAmBK,EAAO,EAAK9C,MAChC,KAMDuC,EAAcQ,KAAKL,EAErB,IAGIH,EAAcS,QACjBhC,QAAQC,MAAM,wCAAiCsB,EAAcU,KAAK,M,CAEpE,EAOQ,YAAAxD,uBAAR,WACKH,KAAKX,MAAMuE,sBAAwB5D,KAAKU,OAC3CV,KAAKX,MAAMuE,qBAAqB5D,KAAKU,MAEvC,EACD,EAzNA,CAAkC,a","sources":["webpack://powerbi-client-react/webpack/universalModuleDefinition","webpack://powerbi-client-react/external umd \"lodash.isequal\"","webpack://powerbi-client-react/external umd \"powerbi-client\"","webpack://powerbi-client-react/external umd \"react\"","webpack://powerbi-client-react/webpack/bootstrap","webpack://powerbi-client-react/webpack/runtime/compat get default export","webpack://powerbi-client-react/webpack/runtime/define property getters","webpack://powerbi-client-react/webpack/runtime/hasOwnProperty shorthand","webpack://powerbi-client-react/webpack/runtime/make namespace object","webpack://powerbi-client-react/./src/PowerBIEmbed.tsx","webpack://powerbi-client-react/./src/utils.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"powerbi-client\", \"lodash.isequal\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"powerbi-client-react\"] = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse\n\t\troot[\"powerbi-client-react\"] = factory(root[\"react\"], root[\"powerbi-client\"], root[\"lodash.isequal\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__155__, __WEBPACK_EXTERNAL_MODULE__164__, __WEBPACK_EXTERNAL_MODULE__695__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__695__;","module.exports = __WEBPACK_EXTERNAL_MODULE__164__;","module.exports = __WEBPACK_EXTERNAL_MODULE__155__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport * as React from 'react';\r\nimport {\r\n\tservice,\r\n\tfactories,\r\n\tReport,\r\n\tEmbed,\r\n\tDashboard,\r\n\tTile,\r\n\tQna,\r\n\tVisual,\r\n\tIQnaEmbedConfiguration,\r\n\tIVisualEmbedConfiguration,\r\n\tIReportEmbedConfiguration,\r\n\tIDashboardEmbedConfiguration,\r\n\tITileEmbedConfiguration,\r\n} from 'powerbi-client';\r\nimport { IReportCreateConfiguration, IPaginatedReportLoadConfiguration } from 'powerbi-models';\r\nimport isEqual from 'lodash.isequal';\r\nimport { stringifyMap, SdkType, SdkWrapperVersion } from './utils';\r\n\r\n/**\r\n * Type for event handler function of embedded entity\r\n */\r\nexport type EventHandler = ((event?: service.ICustomEvent<any>, embeddedEntity?: Embed) => void) | null;\r\n\r\n/**\r\n * Props interface for PowerBIEmbed component\r\n */\r\nexport interface EmbedProps {\r\n\r\n\t// Configuration for embedding the PowerBI entity (Required)\r\n\tembedConfig:\r\n\t\t| IReportEmbedConfiguration\r\n\t\t| IDashboardEmbedConfiguration\r\n\t\t| ITileEmbedConfiguration\r\n\t\t| IQnaEmbedConfiguration\r\n\t\t| IVisualEmbedConfiguration\r\n\t\t| IPaginatedReportLoadConfiguration\r\n\t\t| IReportCreateConfiguration;\r\n\r\n\t// Callback method to get the embedded PowerBI entity object (Optional)\r\n\tgetEmbeddedComponent?: { (embeddedComponent: Embed): void };\r\n\r\n\t// Map of pair of event name and its handler method to be triggered on the event (Optional)\r\n\teventHandlers?: Map<string, EventHandler>;\r\n\r\n\t// CSS class to be set on the embedding container (Optional)\r\n\tcssClassName?: string;\r\n\r\n\t// Phased embedding flag (Optional)\r\n\tphasedEmbedding?: boolean;\r\n\r\n\t// Provide a custom implementation of PowerBI service (Optional)\r\n\tservice?: service.Service;\r\n}\r\n\r\nexport enum EmbedType {\r\n\tCreate = 'create',\r\n\tReport = 'report',\r\n\tDashboard = 'dashboard',\r\n\tTile = 'tile',\r\n\tQna = 'qna',\r\n\tVisual = 'visual'\r\n}\r\n\r\n/**\r\n * Base react component to embed Power BI entities like: reports, dashboards, tiles, visual and qna containers.\r\n */\r\nexport class PowerBIEmbed extends React.Component<EmbedProps> {\r\n\r\n\t// Embedded entity\r\n\t// Note: Do not read or assign to this member variable directly, instead use the getter and setter\r\n\tprivate _embed?: Embed;\r\n\r\n\t// Powerbi service\r\n\tprivate powerbi: service.Service;\r\n\r\n\t// Ref to the HTML div element\r\n\tprivate containerRef = React.createRef<HTMLDivElement>();\r\n\r\n\t// JSON stringify of prev event handler map\r\n\tprivate prevEventHandlerMapString = '';\r\n\r\n\t// Getter for this._embed\r\n\tprivate get embed(): Embed | undefined {\r\n\t\treturn this._embed;\r\n\t};\r\n\r\n\t// Setter for this._embed\r\n\tprivate set embed(newEmbedInstance: Embed | undefined) {\r\n\t\tthis._embed = newEmbedInstance;\r\n\r\n\t\t// Invoke callback method in props to return this embed instance\r\n\t\tthis.invokeGetEmbedCallback();\r\n\t};\r\n\r\n\tconstructor(props: EmbedProps) {\r\n\t\tsuper(props);\r\n\r\n\t\tif (this.props.service) {\r\n\t\t\tthis.powerbi = this.props.service;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tthis.powerbi = new service.Service(\r\n\t\t\t\tfactories.hpmFactory,\r\n\t\t\t\tfactories.wpmpFactory,\r\n\t\t\t\tfactories.routerFactory);\r\n\t\t}\r\n\r\n\t\tthis.powerbi.setSdkInfo(SdkType, SdkWrapperVersion);\r\n\t};\r\n\r\n\tcomponentDidMount(): void {\r\n\r\n\t\t// Check if HTML container is available\r\n\t\tif (this.containerRef.current) {\r\n\r\n\t\t\t// Decide to embed, load or bootstrap\r\n\t\t\tif (this.props.embedConfig.accessToken && this.props.embedConfig.embedUrl) {\r\n\t\t\t\tthis.embedEntity();\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.bootstrap(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\t};\r\n\r\n\tasync componentDidUpdate(prevProps: EmbedProps): Promise<void> {\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\r\n\t\t// Re-embed when the current embedConfig differs from the previous embedConfig\r\n\t\tif(!isEqual(this.props.embedConfig, prevProps.embedConfig)){\r\n\t\t\tthis.embedEntity();\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentWillUnmount(): void {\r\n\t\t// Clean Up\r\n\t\tif (this.containerRef.current) {\r\n\t\t\tthis.powerbi.reset(this.containerRef.current);\r\n\t\t}\r\n\r\n\t\t// Set the previous event handler map string to empty\r\n\t\tthis.prevEventHandlerMapString = '';\r\n\t};\r\n\r\n\trender(): JSX.Element {\r\n\t\treturn (\r\n\t\t\t<div\r\n\t\t\t\tref={this.containerRef}\r\n\t\t\t\tclassName={this.props.cssClassName}>\r\n\t\t\t</div>\r\n\t\t)\r\n\t};\r\n\r\n\t/**\r\n\t * Embed the powerbi entity (Load for phased embedding)\r\n\t */\r\n\tprivate embedEntity(): void {\r\n\t\t// Ensure that the HTML container is rendered and available\r\n\t\t// Also check if the Embed URL and Access Token are present in current props\r\n\t\tif (!this.containerRef.current || !this.props.embedConfig.accessToken || !this.props.embedConfig.embedUrl) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Load when props.phasedEmbedding is true and embed type is report, embed otherwise\r\n\t\tif (this.props.phasedEmbedding && this.props.embedConfig.type === EmbedType.Report) {\r\n\t\t\tthis.embed = this.powerbi.load(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (this.props.phasedEmbedding) {\r\n\t\t\t\tconsole.error(`Phased embedding is not supported for type ${this.props.embedConfig.type}`)\r\n\t\t\t}\r\n\r\n\t\t\tif (this.props.embedConfig.type === EmbedType.Create) {\r\n\t\t\t\tthis.embed = this.powerbi.createReport(this.containerRef.current, this.props.embedConfig as IReportCreateConfiguration);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.embed(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all event handlers from the props on the embedded entity\r\n\t *\r\n\t * @param embed Embedded object\r\n\t * @param eventHandlers Array of eventhandlers to be set on embedded entity\r\n\t * @returns void\r\n\t */\r\n\tprivate setEventHandlers(\r\n\t\tembed: Embed,\r\n\t\teventHandlerMap: Map<string, EventHandler>\r\n\t): void {\r\n\t\t// Get string representation of eventHandlerMap\r\n\t\tconst eventHandlerMapString = stringifyMap(this.props.eventHandlers);\r\n\r\n\t\t// Check if event handler map changed\r\n\t\tif (this.prevEventHandlerMapString === eventHandlerMapString) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update prev string representation of event handler map\r\n\t\tthis.prevEventHandlerMapString = eventHandlerMapString;\r\n\r\n\t\t// List of allowed events\r\n\t\tlet allowedEvents = Embed.allowedEvents;\r\n\r\n\t\tconst entityType = embed.embedtype;\r\n\r\n\t\t// Append entity specific events\r\n\t\tswitch (entityType) {\r\n\t\t\tcase EmbedType.Create:\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Report:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Report.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Dashboard.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Tile.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Qna.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Visual.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${entityType}`);\r\n\t\t}\r\n\r\n\t\t// Holds list of events which are not allowed\r\n\t\tconst invalidEvents: Array<string> = [];\r\n\r\n\t\t// Apply all provided event handlers\r\n\t\teventHandlerMap.forEach((eventHandlerMethod, eventName) => {\r\n\t\t\t// Check if this event is allowed\r\n\t\t\tif (allowedEvents.includes(eventName)) {\r\n\r\n\t\t\t\t// Removes event handler for this event\r\n\t\t\t\tembed.off(eventName);\r\n\r\n\t\t\t\t// Event handler is effectively removed for this event when eventHandlerMethod is null\r\n\t\t\t\tif (eventHandlerMethod) {\r\n\r\n\t\t\t\t\t// Set single event handler\r\n\t\t\t\t\tembed.on(eventName, (event: service.ICustomEvent<any>): void => {\r\n\t\t\t\t\t\teventHandlerMethod(event, this.embed);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Add this event name to the list of invalid events\r\n\t\t\t\tinvalidEvents.push(eventName);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Handle invalid events\r\n\t\tif (invalidEvents.length) {\r\n\t\t\tconsole.error(`Following events are invalid: ${invalidEvents.join(',')}`);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Returns the embedded object via _getEmbed_ callback method provided in props\r\n\t *\r\n\t * @returns void\r\n\t */\r\n\tprivate invokeGetEmbedCallback(): void {\r\n\t\tif (this.props.getEmbeddedComponent && this.embed) {\r\n\t\t\tthis.props.getEmbeddedComponent(this.embed);\r\n\t\t}\r\n\t};\r\n}","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport { EmbedProps } from \"./PowerBIEmbed\";\r\n\r\n/**\r\n * Get JSON string representation of the given map.\r\n *\r\n * @param map Map of event and corresponding handler method\r\n *\r\n * For example:\r\n * Input:\r\n * ```\r\n * Map([\r\n\t\t['loaded', null],\r\n\t\t['rendered', function () { console.log('Rendered'); }]\r\n\t]);\r\n * ```\r\n * Output:\r\n * ```\r\n * `[[\"loaded\",\"\"],[\"rendered\",\"function () { console.log('Rendered'); }\"]]`\r\n * ```\r\n */\r\nexport function stringifyMap(map: EmbedProps['eventHandlers']): string {\r\n\r\n\t// Return empty string for empty/null map\r\n\tif (!map) {\r\n\t\treturn '';\r\n\t}\r\n\r\n\t// Get entries of map as array\r\n\tconst mapEntries = Array.from(map);\r\n\r\n\t// Return JSON string\r\n\treturn JSON.stringify(mapEntries.map((mapEntry) => {\r\n\r\n\t\t// Convert event handler method to a string containing its source code for comparison\r\n\t\treturn [\r\n\t\t\tmapEntry[0],\r\n\t\t\tmapEntry[1] ? mapEntry[1].toString() : ''\r\n\t\t];\r\n\t}));\r\n};\r\n\r\n// SDK information to be used with service instance\r\nexport const SdkType = \"powerbi-client-react\";\r\nexport const SdkWrapperVersion = \"2.0.0\";"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__155__","__WEBPACK_EXTERNAL_MODULE__164__","__WEBPACK_EXTERNAL_MODULE__695__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","EmbedType","props","containerRef","prevEventHandlerMapString","service","powerbi","Service","factories","hpmFactory","wpmpFactory","routerFactory","setSdkInfo","this","_embed","newEmbedInstance","invokeGetEmbedCallback","componentDidMount","current","embedConfig","accessToken","embedUrl","embedEntity","embed","bootstrap","eventHandlers","setEventHandlers","componentDidUpdate","prevProps","componentWillUnmount","reset","render","ref","className","cssClassName","phasedEmbedding","type","Report","load","console","error","Create","createReport","eventHandlerMap","eventHandlerMapString","map","mapEntries","Array","from","JSON","stringify","mapEntry","toString","stringifyMap","allowedEvents","Embed","entityType","embedtype","Dashboard","Tile","Qna","Visual","invalidEvents","forEach","eventHandlerMethod","eventName","includes","off","on","event","push","length","join","getEmbeddedComponent"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"powerbi-client-react.js","mappings":"CAA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AAG,EAAAI,UAAUJ,eAAa,GAC7D,MACD,KAAKrD,EAAU0D,KACdL,EAAgB,EAAH,KAAOA,GAAe,GAAG,EAAAK,KAAKL,eAAa,GACxD,MACD,KAAKrD,EAAU2D,IACdN,EAAgB,EAAH,KAAOA,GAAe,GAAG,EAAAM,IAAIN,eAAa,GACvD,MACD,KAAKrD,EAAU4D,OACdP,EAAgB,EAAH,KAAOA,GAAe,GAAG,EAAAO,OAAOP,eAAa,GAC1D,MACD,QACCf,QAAQC,MAAM,6BAAsBgB,IAItC,IAAMM,EAA+B,GAGrCnB,EAAgBoB,QAAQ,SAACC,EAAoBC,GAExCX,EAAcY,SAASD,IAG1B1C,EAAM4C,IAAIF,GAGND,GAGHzC,EAAM6C,GAAGH,EAAW,SAACI,GACpBL,EAAmBK,EAAO,EAAK9C,MAChC,IAMDuC,EAAcQ,KAAKL,EAErB,GAGIH,EAAcS,QACjBhC,QAAQC,MAAM,wCAAiCsB,EAAcU,KAAK,M,CAEpE,EAOQ,YAAAxD,uBAAR,WACKH,KAAKX,MAAMuE,sBAAwB5D,KAAKU,OAC3CV,KAAKX,MAAMuE,qBAAqB5D,KAAKU,MAEvC,EACD,EAzNA,CAAkC,a","sources":["webpack://powerbi-client-react/webpack/universalModuleDefinition","webpack://powerbi-client-react/external umd \"react\"","webpack://powerbi-client-react/external umd \"powerbi-client\"","webpack://powerbi-client-react/external umd \"lodash.isequal\"","webpack://powerbi-client-react/webpack/bootstrap","webpack://powerbi-client-react/webpack/runtime/compat get default export","webpack://powerbi-client-react/webpack/runtime/define property getters","webpack://powerbi-client-react/webpack/runtime/hasOwnProperty shorthand","webpack://powerbi-client-react/webpack/runtime/make namespace object","webpack://powerbi-client-react/./src/PowerBIEmbed.tsx","webpack://powerbi-client-react/./src/utils.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"powerbi-client\", \"lodash.isequal\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"powerbi-client-react\"] = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse\n\t\troot[\"powerbi-client-react\"] = factory(root[\"react\"], root[\"powerbi-client\"], root[\"lodash.isequal\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__155__, __WEBPACK_EXTERNAL_MODULE__164__, __WEBPACK_EXTERNAL_MODULE__695__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__155__;","module.exports = __WEBPACK_EXTERNAL_MODULE__164__;","module.exports = __WEBPACK_EXTERNAL_MODULE__695__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport * as React from 'react';\r\nimport {\r\n\tservice,\r\n\tfactories,\r\n\tReport,\r\n\tEmbed,\r\n\tDashboard,\r\n\tTile,\r\n\tQna,\r\n\tVisual,\r\n\tIQnaEmbedConfiguration,\r\n\tIVisualEmbedConfiguration,\r\n\tIReportEmbedConfiguration,\r\n\tIDashboardEmbedConfiguration,\r\n\tITileEmbedConfiguration,\r\n} from 'powerbi-client';\r\nimport { IReportCreateConfiguration, IPaginatedReportLoadConfiguration } from 'powerbi-models';\r\nimport isEqual from 'lodash.isequal';\r\nimport { stringifyMap, SdkType, SdkWrapperVersion } from './utils';\r\n\r\n/**\r\n * Type for event handler function of embedded entity\r\n */\r\nexport type EventHandler = ((event?: service.ICustomEvent<any>, embeddedEntity?: Embed) => void) | null;\r\n\r\n/**\r\n * Props interface for PowerBIEmbed component\r\n */\r\nexport interface EmbedProps {\r\n\r\n\t// Configuration for embedding the PowerBI entity (Required)\r\n\tembedConfig:\r\n\t\t| IReportEmbedConfiguration\r\n\t\t| IDashboardEmbedConfiguration\r\n\t\t| ITileEmbedConfiguration\r\n\t\t| IQnaEmbedConfiguration\r\n\t\t| IVisualEmbedConfiguration\r\n\t\t| IPaginatedReportLoadConfiguration\r\n\t\t| IReportCreateConfiguration;\r\n\r\n\t// Callback method to get the embedded PowerBI entity object (Optional)\r\n\tgetEmbeddedComponent?: { (embeddedComponent: Embed): void };\r\n\r\n\t// Map of pair of event name and its handler method to be triggered on the event (Optional)\r\n\teventHandlers?: Map<string, EventHandler>;\r\n\r\n\t// CSS class to be set on the embedding container (Optional)\r\n\tcssClassName?: string;\r\n\r\n\t// Phased embedding flag (Optional)\r\n\tphasedEmbedding?: boolean;\r\n\r\n\t// Provide a custom implementation of PowerBI service (Optional)\r\n\tservice?: service.Service;\r\n}\r\n\r\nexport enum EmbedType {\r\n\tCreate = 'create',\r\n\tReport = 'report',\r\n\tDashboard = 'dashboard',\r\n\tTile = 'tile',\r\n\tQna = 'qna',\r\n\tVisual = 'visual'\r\n}\r\n\r\n/**\r\n * Base react component to embed Power BI entities like: reports, dashboards, tiles, visual and qna containers.\r\n */\r\nexport class PowerBIEmbed extends React.Component<EmbedProps> {\r\n\r\n\t// Embedded entity\r\n\t// Note: Do not read or assign to this member variable directly, instead use the getter and setter\r\n\tprivate _embed?: Embed;\r\n\r\n\t// Powerbi service\r\n\tprivate powerbi: service.Service;\r\n\r\n\t// Ref to the HTML div element\r\n\tprivate containerRef = React.createRef<HTMLDivElement>();\r\n\r\n\t// JSON stringify of prev event handler map\r\n\tprivate prevEventHandlerMapString = '';\r\n\r\n\t// Getter for this._embed\r\n\tprivate get embed(): Embed | undefined {\r\n\t\treturn this._embed;\r\n\t};\r\n\r\n\t// Setter for this._embed\r\n\tprivate set embed(newEmbedInstance: Embed | undefined) {\r\n\t\tthis._embed = newEmbedInstance;\r\n\r\n\t\t// Invoke callback method in props to return this embed instance\r\n\t\tthis.invokeGetEmbedCallback();\r\n\t};\r\n\r\n\tconstructor(props: EmbedProps) {\r\n\t\tsuper(props);\r\n\r\n\t\tif (this.props.service) {\r\n\t\t\tthis.powerbi = this.props.service;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tthis.powerbi = new service.Service(\r\n\t\t\t\tfactories.hpmFactory,\r\n\t\t\t\tfactories.wpmpFactory,\r\n\t\t\t\tfactories.routerFactory);\r\n\t\t}\r\n\r\n\t\tthis.powerbi.setSdkInfo(SdkType, SdkWrapperVersion);\r\n\t};\r\n\r\n\tcomponentDidMount(): void {\r\n\r\n\t\t// Check if HTML container is available\r\n\t\tif (this.containerRef.current) {\r\n\r\n\t\t\t// Decide to embed, load or bootstrap\r\n\t\t\tif (this.props.embedConfig.accessToken && this.props.embedConfig.embedUrl) {\r\n\t\t\t\tthis.embedEntity();\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.bootstrap(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\t};\r\n\r\n\tasync componentDidUpdate(prevProps: EmbedProps): Promise<void> {\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\r\n\t\t// Re-embed when the current embedConfig differs from the previous embedConfig\r\n\t\tif(!isEqual(this.props.embedConfig, prevProps.embedConfig)){\r\n\t\t\tthis.embedEntity();\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentWillUnmount(): void {\r\n\t\t// Clean Up\r\n\t\tif (this.containerRef.current) {\r\n\t\t\tthis.powerbi.reset(this.containerRef.current);\r\n\t\t}\r\n\r\n\t\t// Set the previous event handler map string to empty\r\n\t\tthis.prevEventHandlerMapString = '';\r\n\t};\r\n\r\n\trender(): JSX.Element {\r\n\t\treturn (\r\n\t\t\t<div\r\n\t\t\t\tref={this.containerRef}\r\n\t\t\t\tclassName={this.props.cssClassName}>\r\n\t\t\t</div>\r\n\t\t)\r\n\t};\r\n\r\n\t/**\r\n\t * Embed the powerbi entity (Load for phased embedding)\r\n\t */\r\n\tprivate embedEntity(): void {\r\n\t\t// Ensure that the HTML container is rendered and available\r\n\t\t// Also check if the Embed URL and Access Token are present in current props\r\n\t\tif (!this.containerRef.current || !this.props.embedConfig.accessToken || !this.props.embedConfig.embedUrl) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Load when props.phasedEmbedding is true and embed type is report, embed otherwise\r\n\t\tif (this.props.phasedEmbedding && this.props.embedConfig.type === EmbedType.Report) {\r\n\t\t\tthis.embed = this.powerbi.load(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (this.props.phasedEmbedding) {\r\n\t\t\t\tconsole.error(`Phased embedding is not supported for type ${this.props.embedConfig.type}`)\r\n\t\t\t}\r\n\r\n\t\t\tif (this.props.embedConfig.type === EmbedType.Create) {\r\n\t\t\t\tthis.embed = this.powerbi.createReport(this.containerRef.current, this.props.embedConfig as IReportCreateConfiguration);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.embed(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all event handlers from the props on the embedded entity\r\n\t *\r\n\t * @param embed Embedded object\r\n\t * @param eventHandlers Array of eventhandlers to be set on embedded entity\r\n\t * @returns void\r\n\t */\r\n\tprivate setEventHandlers(\r\n\t\tembed: Embed,\r\n\t\teventHandlerMap: Map<string, EventHandler>\r\n\t): void {\r\n\t\t// Get string representation of eventHandlerMap\r\n\t\tconst eventHandlerMapString = stringifyMap(this.props.eventHandlers);\r\n\r\n\t\t// Check if event handler map changed\r\n\t\tif (this.prevEventHandlerMapString === eventHandlerMapString) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update prev string representation of event handler map\r\n\t\tthis.prevEventHandlerMapString = eventHandlerMapString;\r\n\r\n\t\t// List of allowed events\r\n\t\tlet allowedEvents = Embed.allowedEvents;\r\n\r\n\t\tconst entityType = embed.embedtype;\r\n\r\n\t\t// Append entity specific events\r\n\t\tswitch (entityType) {\r\n\t\t\tcase EmbedType.Create:\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Report:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Report.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Dashboard.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Tile.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Qna.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Visual.allowedEvents];\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${entityType}`);\r\n\t\t}\r\n\r\n\t\t// Holds list of events which are not allowed\r\n\t\tconst invalidEvents: Array<string> = [];\r\n\r\n\t\t// Apply all provided event handlers\r\n\t\teventHandlerMap.forEach((eventHandlerMethod, eventName) => {\r\n\t\t\t// Check if this event is allowed\r\n\t\t\tif (allowedEvents.includes(eventName)) {\r\n\r\n\t\t\t\t// Removes event handler for this event\r\n\t\t\t\tembed.off(eventName);\r\n\r\n\t\t\t\t// Event handler is effectively removed for this event when eventHandlerMethod is null\r\n\t\t\t\tif (eventHandlerMethod) {\r\n\r\n\t\t\t\t\t// Set single event handler\r\n\t\t\t\t\tembed.on(eventName, (event: service.ICustomEvent<any>): void => {\r\n\t\t\t\t\t\teventHandlerMethod(event, this.embed);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Add this event name to the list of invalid events\r\n\t\t\t\tinvalidEvents.push(eventName);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Handle invalid events\r\n\t\tif (invalidEvents.length) {\r\n\t\t\tconsole.error(`Following events are invalid: ${invalidEvents.join(',')}`);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Returns the embedded object via _getEmbed_ callback method provided in props\r\n\t *\r\n\t * @returns void\r\n\t */\r\n\tprivate invokeGetEmbedCallback(): void {\r\n\t\tif (this.props.getEmbeddedComponent && this.embed) {\r\n\t\t\tthis.props.getEmbeddedComponent(this.embed);\r\n\t\t}\r\n\t};\r\n}","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport { EmbedProps } from \"./PowerBIEmbed\";\r\n\r\n/**\r\n * Get JSON string representation of the given map.\r\n *\r\n * @param map Map of event and corresponding handler method\r\n *\r\n * For example:\r\n * Input:\r\n * ```\r\n * Map([\r\n\t\t['loaded', null],\r\n\t\t['rendered', function () { console.log('Rendered'); }]\r\n\t]);\r\n * ```\r\n * Output:\r\n * ```\r\n * `[[\"loaded\",\"\"],[\"rendered\",\"function () { console.log('Rendered'); }\"]]`\r\n * ```\r\n */\r\nexport function stringifyMap(map: EmbedProps['eventHandlers']): string {\r\n\r\n\t// Return empty string for empty/null map\r\n\tif (!map) {\r\n\t\treturn '';\r\n\t}\r\n\r\n\t// Get entries of map as array\r\n\tconst mapEntries = Array.from(map);\r\n\r\n\t// Return JSON string\r\n\treturn JSON.stringify(mapEntries.map((mapEntry) => {\r\n\r\n\t\t// Convert event handler method to a string containing its source code for comparison\r\n\t\treturn [\r\n\t\t\tmapEntry[0],\r\n\t\t\tmapEntry[1] ? mapEntry[1].toString() : ''\r\n\t\t];\r\n\t}));\r\n};\r\n\r\n// SDK information to be used with service instance\r\nexport const SdkType = \"powerbi-client-react\";\r\nexport const SdkWrapperVersion = \"2.0.1\";"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__155__","__WEBPACK_EXTERNAL_MODULE__164__","__WEBPACK_EXTERNAL_MODULE__695__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","EmbedType","props","containerRef","prevEventHandlerMapString","service","powerbi","Service","factories","hpmFactory","wpmpFactory","routerFactory","setSdkInfo","this","_embed","newEmbedInstance","invokeGetEmbedCallback","componentDidMount","current","embedConfig","accessToken","embedUrl","embedEntity","embed","bootstrap","eventHandlers","setEventHandlers","componentDidUpdate","prevProps","componentWillUnmount","reset","render","ref","className","cssClassName","phasedEmbedding","type","Report","load","console","error","Create","createReport","eventHandlerMap","eventHandlerMapString","map","mapEntries","Array","from","JSON","stringify","mapEntry","toString","stringifyMap","allowedEvents","Embed","entityType","embedtype","Dashboard","Tile","Qna","Visual","invalidEvents","forEach","eventHandlerMethod","eventName","includes","off","on","event","push","length","join","getEmbeddedComponent"],"ignoreList":[],"sourceRoot":""}
|
package/dist/utils.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ import { EmbedProps } from "./PowerBIEmbed";
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function stringifyMap(map: EmbedProps['eventHandlers']): string;
|
|
21
21
|
export declare const SdkType = "powerbi-client-react";
|
|
22
|
-
export declare const SdkWrapperVersion = "2.0.
|
|
22
|
+
export declare const SdkWrapperVersion = "2.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerbi-client-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "React wrapper for powerbi-client library",
|
|
5
5
|
"main": "dist/powerbi-client-react.js",
|
|
6
6
|
"types": "dist/powerbi-client-react.d.ts",
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
"url": "https://github.com/microsoft/powerbi-client-react.git"
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT",
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"tag": "beta"
|
|
32
|
-
},
|
|
33
30
|
"dependencies": {
|
|
34
31
|
"lodash.isequal": "^4.5.0",
|
|
35
32
|
"powerbi-client": "^2.23.1"
|
|
@@ -57,6 +54,9 @@
|
|
|
57
54
|
"ts-loader": "^9.4.1",
|
|
58
55
|
"typescript": "^4.9.5",
|
|
59
56
|
"webpack": "^5.71.0",
|
|
60
|
-
"webpack-cli": "^4.9.2"
|
|
57
|
+
"webpack-cli": "^4.9.2",
|
|
58
|
+
"karma-coverage": "^2.2.0",
|
|
59
|
+
"karma-junit-reporter": "^2.0.1",
|
|
60
|
+
"karma-spec-reporter": "0.0.26"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
powerbi-client-react
|
|
2
|
-
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
MIT License
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
# powerbi-client-react
|
|
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
|
-
|
|
4
|
-
## Quick Start
|
|
5
|
-
|
|
6
|
-
### Import
|
|
7
|
-
|
|
8
|
-
```jsx
|
|
9
|
-
import { PowerBIEmbed } from 'powerbi-client-react';
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
### Embed a Power BI report
|
|
13
|
-
```jsx
|
|
14
|
-
<PowerBIEmbed
|
|
15
|
-
embedConfig = {{
|
|
16
|
-
type: 'report', // Supported types: report, dashboard, tile, visual, qna, paginated report and create
|
|
17
|
-
id: '<Report Id>',
|
|
18
|
-
embedUrl: '<Embed Url>',
|
|
19
|
-
accessToken: '<Access Token>',
|
|
20
|
-
tokenType: models.TokenType.Embed, // Use models.TokenType.Aad for SaaS embed
|
|
21
|
-
settings: {
|
|
22
|
-
panes: {
|
|
23
|
-
filters: {
|
|
24
|
-
expanded: false,
|
|
25
|
-
visible: false
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
background: models.BackgroundType.Transparent,
|
|
29
|
-
}
|
|
30
|
-
}}
|
|
31
|
-
|
|
32
|
-
eventHandlers = {
|
|
33
|
-
new Map([
|
|
34
|
-
['loaded', function () {console.log('Report loaded');}],
|
|
35
|
-
['rendered', function () {console.log('Report rendered');}],
|
|
36
|
-
['error', function (event) {console.log(event.detail);}],
|
|
37
|
-
['visualClicked', () => console.log('visual clicked')],
|
|
38
|
-
['pageChanged', (event) => console.log(event)],
|
|
39
|
-
])
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
cssClassName = { "reportClass" }
|
|
43
|
-
|
|
44
|
-
getEmbeddedComponent = { (embeddedReport) => {
|
|
45
|
-
this.report = embeddedReport as Report;
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### How to [bootstrap a PowerBI report](https://learn.microsoft.com/javascript/api/overview/powerbi/bootstrap-better-performance):
|
|
51
|
-
```jsx
|
|
52
|
-
<PowerBIEmbed
|
|
53
|
-
embedConfig = {{
|
|
54
|
-
type: 'report', // Supported types: report, dashboard, tile, visual, qna and paginated report
|
|
55
|
-
id: undefined,
|
|
56
|
-
embedUrl: undefined,
|
|
57
|
-
accessToken: undefined, // Keep as empty string, null or undefined
|
|
58
|
-
tokenType: models.TokenType.Embed
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
```
|
|
62
|
-
__Note__: To embed the report after bootstrap, update the props (with at least accessToken).
|
|
63
|
-
|
|
64
|
-
### Demo
|
|
65
|
-
|
|
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.
|
|
71
|
-
|
|
72
|
-
To run the demo on localhost, run the following commands:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
npm run demo
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Redirect to http://localhost:8080/ to view in the browser.
|
|
79
|
-
|
|
80
|
-
### Usage
|
|
81
|
-
|Use case|Details|
|
|
82
|
-
|:------|:------|
|
|
83
|
-
|Embed Power BI|To embed your powerbi artifact, pass the component with at least _type_, _embedUrl_ and _accessToken_ in _embedConfig_ prop.|
|
|
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).|
|
|
85
|
-
|Apply style class|Pass the name(s) of style classes to be added to the embed container div to the _cssClassName_ props.|
|
|
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|
|
|
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.|
|
|
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_.|
|
|
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|
|
|
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).|
|
|
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|
|
|
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).|
|
|
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.|
|
|
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.|
|
|
96
|
-
|
|
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).
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Props interface
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
interface EmbedProps {
|
|
104
|
-
|
|
105
|
-
// Configuration for embedding the PowerBI entity (required)
|
|
106
|
-
embedConfig:
|
|
107
|
-
| IReportEmbedConfiguration
|
|
108
|
-
| IDashboardEmbedConfiguration
|
|
109
|
-
| ITileEmbedConfiguration
|
|
110
|
-
| IQnaEmbedConfiguration
|
|
111
|
-
| IVisualEmbedConfiguration
|
|
112
|
-
| IPaginatedReportLoadConfiguration
|
|
113
|
-
| IReportCreateConfiguration
|
|
114
|
-
|
|
115
|
-
// Callback method to get the embedded PowerBI entity object (optional)
|
|
116
|
-
getEmbed?: { (embeddedComponent: Embed): void }
|
|
117
|
-
|
|
118
|
-
// Map of pair of event name and its handler method to be triggered on the event (optional)
|
|
119
|
-
eventHandlers?: Map<string, EventHandler>
|
|
120
|
-
|
|
121
|
-
// CSS class to be set on the embedding container (optional)
|
|
122
|
-
cssClassName?: string
|
|
123
|
-
|
|
124
|
-
// Phased embedding flag (optional)
|
|
125
|
-
phasedEmbedding?: boolean;
|
|
126
|
-
|
|
127
|
-
// Provide instance of PowerBI service (optional)
|
|
128
|
-
service?: service.Service
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
|
|
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;
|
|
148
|
-
```
|
|
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
|
-
|
|
191
|
-
## Note
|
|
192
|
-
|
|
193
|
-
The library supports React applications having version **>= 18**.
|
|
194
|
-
|
|
195
|
-
## Dependencies
|
|
196
|
-
|
|
197
|
-
[powerbi-client](https://www.npmjs.com/package/powerbi-client)
|
|
198
|
-
|
|
199
|
-
## Peer dependencies
|
|
200
|
-
|
|
201
|
-
[react](https://www.npmjs.com/package/react)
|
|
202
|
-
|
|
203
|
-
## Trademarks
|
|
204
|
-
|
|
205
|
-
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.
|
|
206
|
-
|
|
207
|
-
## Contributing
|
|
208
|
-
|
|
209
|
-
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>.
|
|
210
|
-
|
|
211
|
-
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.
|
|
212
|
-
|
|
213
|
-
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
|
|
214
|
-
|
|
215
|
-
## Data Collection.
|
|
216
|
-
|
|
217
|
-
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.
|
|
218
|
-
|
|
219
|
-
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.
|
|
220
|
-
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.
|
|
221
|
-
|
|
222
|
-
## Support
|
|
223
|
-
|
|
224
|
-
- **Feature Requests:** Submit your ideas and suggestions to the [Fabric Ideas Portal](https://ideas.fabric.microsoft.com/), where you can also vote on ideas from other developers.
|
|
225
|
-
- **Bug Reports and Technical Assistance:** Visit the [Fabric Developer Community Forum](https://community.fabric.microsoft.com/t5/Developer/bd-p/Developer). Our team and community experts are ready to assist you.
|
|
226
|
-
- **Additional Support:** Contact your account manager or reach out to the [Fabric Support Team](https://support.fabric.microsoft.com/en-us/support/).
|