powerbi-client-react 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- 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 +8 -6
package/README.md
CHANGED
|
@@ -85,7 +85,6 @@ Redirect to http://localhost:8080/ to view in the browser.
|
|
|
85
85
|
|Apply style class|Pass the name(s) of style classes to be added to the embed container div to the _cssClassName_ props.|
|
|
86
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
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
88
|
|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
89
|
|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
90
|
|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|
|
|
@@ -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.2"),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,MAAM,CAACC,EAAkCC,EAAkCC,I,kCCT9EP,EAAOD,QAAUQ,C,UCAjBP,EAAOD,QAAUO,C,UCAjBN,EAAOD,QAAUM,C,GCCbG,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,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cU,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":"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,SA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AAOA,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.2\";"],"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.2";
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerbi-client-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE.txt"
|
|
9
11
|
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"prebuild": "npm run lint",
|
|
@@ -27,9 +29,6 @@
|
|
|
27
29
|
"url": "https://github.com/microsoft/powerbi-client-react.git"
|
|
28
30
|
},
|
|
29
31
|
"license": "MIT",
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"tag": "beta"
|
|
32
|
-
},
|
|
33
32
|
"dependencies": {
|
|
34
33
|
"lodash.isequal": "^4.5.0",
|
|
35
34
|
"powerbi-client": "^2.23.1"
|
|
@@ -57,6 +56,9 @@
|
|
|
57
56
|
"ts-loader": "^9.4.1",
|
|
58
57
|
"typescript": "^4.9.5",
|
|
59
58
|
"webpack": "^5.71.0",
|
|
60
|
-
"webpack-cli": "^4.9.2"
|
|
59
|
+
"webpack-cli": "^4.9.2",
|
|
60
|
+
"karma-coverage": "^2.2.0",
|
|
61
|
+
"karma-junit-reporter": "^2.0.1",
|
|
62
|
+
"karma-spec-reporter": "0.0.26"
|
|
61
63
|
}
|
|
62
64
|
}
|