├── .babelrc ├── .editorconfig ├── .eslintrc ├── .github └── workflows │ └── npmpublish.yml ├── .gitignore ├── LICENSE ├── README.md ├── example ├── example.tsx └── index.html ├── jest.config.js ├── lib ├── index.d.ts ├── react-powerbi.min.js └── react-powerbi.min.js.map ├── package-lock.json ├── package.json ├── src └── index.tsx ├── test ├── __snapshots__ │ └── library.spec.tsx.snap ├── library.spec.tsx └── setupEnzyme.ts ├── tsconfig.jest.json ├── tsconfig.json └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = LF 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | 8 | "globals": { 9 | "document": false, 10 | "escape": false, 11 | "navigator": false, 12 | "unescape": false, 13 | "window": false, 14 | "describe": true, 15 | "before": true, 16 | "it": true, 17 | "expect": true, 18 | "sinon": true 19 | }, 20 | 21 | "parser": "@typescript-eslint/parser", 22 | "extends": [ 23 | "plugin:react/recommended", 24 | "plugin:@typescript-eslint/recommended" 25 | ], 26 | 27 | "parserOptions": { 28 | "ecmaVersion": 6, 29 | "sourceType": "module", 30 | "ecmaFeatures": { 31 | "globalReturn": true, 32 | "jsx": true, 33 | "modules": true 34 | }, 35 | "parserOptions": { 36 | "project": "./tsconfig.json" 37 | } 38 | }, 39 | 40 | "plugins": [], 41 | 42 | "rules": { 43 | "block-scoped-var": 2, 44 | "brace-style": [2, "1tbs", { "allowSingleLine": true }], 45 | "camelcase": [2, { "allow": ["^UNSAFE_"] }], 46 | "comma-dangle": [2, "never"], 47 | "comma-spacing": [2, { "before": false, "after": true }], 48 | "comma-style": [2, "last"], 49 | "complexity": 0, 50 | "consistent-return": 2, 51 | "consistent-this": 0, 52 | "curly": [2, "multi-line"], 53 | "default-case": 0, 54 | "dot-location": [2, "property"], 55 | "dot-notation": 0, 56 | "eol-last": 2, 57 | "eqeqeq": [2, "allow-null"], 58 | "func-names": 0, 59 | "func-style": 0, 60 | "generator-star-spacing": [2, "both"], 61 | "guard-for-in": 0, 62 | "handle-callback-err": [2, "^(err|error|anySpecificError)$"], 63 | "indent": [2, 2, { "SwitchCase": 1 }], 64 | "key-spacing": [2, { "beforeColon": false, "afterColon": true }], 65 | "keyword-spacing": [2, { "before": true, "after": true }], 66 | "linebreak-style": 0, 67 | "max-depth": 0, 68 | "max-len": [2, 120, 4], 69 | "max-nested-callbacks": 0, 70 | "max-params": 0, 71 | "max-statements": 0, 72 | "new-cap": [2, { "newIsCap": true, "capIsNew": false }], 73 | "newline-after-var": [2, "always"], 74 | "new-parens": 2, 75 | "no-alert": 0, 76 | "no-array-constructor": 2, 77 | "no-bitwise": 0, 78 | "no-caller": 2, 79 | "no-catch-shadow": 0, 80 | "no-cond-assign": 2, 81 | "no-console": 0, 82 | "no-constant-condition": 0, 83 | "no-continue": 0, 84 | "no-control-regex": 2, 85 | "no-debugger": 2, 86 | "no-delete-var": 2, 87 | "no-div-regex": 0, 88 | "no-dupe-args": 2, 89 | "no-dupe-keys": 2, 90 | "no-duplicate-case": 2, 91 | "no-else-return": 2, 92 | "no-empty": 0, 93 | "no-empty-character-class": 2, 94 | "no-eq-null": 0, 95 | "no-eval": 2, 96 | "no-ex-assign": 2, 97 | "no-extend-native": 2, 98 | "no-extra-bind": 2, 99 | "no-extra-boolean-cast": 2, 100 | "no-extra-parens": 0, 101 | "no-extra-semi": 0, 102 | "no-extra-strict": 0, 103 | "no-fallthrough": 2, 104 | "no-floating-decimal": 2, 105 | "no-func-assign": 2, 106 | "no-implied-eval": 2, 107 | "no-inline-comments": 0, 108 | "no-inner-declarations": [2, "functions"], 109 | "no-invalid-regexp": 2, 110 | "no-irregular-whitespace": 2, 111 | "no-iterator": 2, 112 | "no-label-var": 2, 113 | "no-labels": 2, 114 | "no-lone-blocks": 0, 115 | "no-lonely-if": 0, 116 | "no-loop-func": 0, 117 | "no-mixed-requires": 0, 118 | "no-mixed-spaces-and-tabs": [2, false], 119 | "no-multi-spaces": 2, 120 | "no-multi-str": 2, 121 | "no-multiple-empty-lines": [2, { "max": 1 }], 122 | "no-native-reassign": 2, 123 | "no-negated-in-lhs": 2, 124 | "no-nested-ternary": 0, 125 | "no-new": 2, 126 | "no-new-func": 2, 127 | "no-new-object": 2, 128 | "no-new-require": 2, 129 | "no-new-wrappers": 2, 130 | "no-obj-calls": 2, 131 | "no-octal": 2, 132 | "no-octal-escape": 2, 133 | "no-path-concat": 0, 134 | "no-plusplus": 0, 135 | "no-process-env": 0, 136 | "no-process-exit": 0, 137 | "no-proto": 2, 138 | "no-redeclare": 2, 139 | "no-regex-spaces": 2, 140 | "no-reserved-keys": 0, 141 | "no-restricted-modules": 0, 142 | "no-return-assign": 2, 143 | "no-script-url": 0, 144 | "no-self-compare": 2, 145 | "no-sequences": 2, 146 | "no-shadow": 0, 147 | "no-shadow-restricted-names": 2, 148 | "no-spaced-func": 2, 149 | "no-sparse-arrays": 2, 150 | "no-sync": 0, 151 | "no-ternary": 0, 152 | "no-throw-literal": 2, 153 | "no-trailing-spaces": 2, 154 | "no-undef": 2, 155 | "no-undef-init": 2, 156 | "no-undefined": 0, 157 | "no-underscore-dangle": 0, 158 | "no-unneeded-ternary": 2, 159 | "no-unreachable": 2, 160 | "no-unused-expressions": 0, 161 | "no-unused-vars": [2, { "vars": "all", "args": "none" }], 162 | "no-use-before-define": 2, 163 | "no-var": 0, 164 | "no-void": 0, 165 | "no-warning-comments": 0, 166 | "no-with": 2, 167 | "one-var": 0, 168 | "operator-assignment": 0, 169 | "operator-linebreak": [2, "after"], 170 | "padded-blocks": 0, 171 | "quote-props": 0, 172 | "quotes": [2, "single", "avoid-escape"], 173 | "radix": 2, 174 | "semi": [2, "never"], 175 | "semi-spacing": 0, 176 | "sort-vars": 0, 177 | "space-before-blocks": [2, "always"], 178 | "space-before-function-paren": [ 179 | 2, 180 | { "anonymous": "always", "named": "always" } 181 | ], 182 | "space-in-brackets": 0, 183 | "space-in-parens": [2, "never"], 184 | "space-infix-ops": 2, 185 | "space-unary-ops": [2, { "words": true, "nonwords": false }], 186 | "spaced-comment": [2, "always"], 187 | "strict": 0, 188 | "use-isnan": 2, 189 | "valid-jsdoc": 0, 190 | "valid-typeof": 2, 191 | "vars-on-top": 2, 192 | "wrap-iife": [2, "any"], 193 | "wrap-regex": 0, 194 | "yoda": [2, "never"] 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v1 16 | with: 17 | node-version: 12 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - uses: actions/setup-node@v1 27 | with: 28 | node-version: 12 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | 35 | publish-gpr: 36 | needs: build 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | - uses: actions/setup-node@v1 41 | with: 42 | node-version: 12 43 | registry-url: https://npm.pkg.github.com/ 44 | scope: '@your-github-username' 45 | - run: npm ci 46 | - run: npm publish 47 | env: 48 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | 29 | # Remove some common IDE working directories 30 | .idea 31 | .vscode 32 | 33 | # Remove cache 34 | .cache 35 | dist 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Krasimir Tsonev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React PowerBI Component 2 | 3 | This is to get you quickly embed your powerbi reports to your React Application. 4 | 5 | Right now (before v1), it's very much a work in progress. Please submit your issues. 6 | 7 | ## How to Use 8 | 9 | ```jsx 10 | import React, { Component } from 'react' 11 | import PowerbiEmbedded from 'react-powerbi' 12 | 13 | class App extends Component { 14 | render () { 15 | return ( 16 |
17 | 33 |
34 | ) 35 | } 36 | } 37 | 38 | export default App 39 | ``` 40 | #### Mobile Optimization 41 | You only need to add **mobile** prop as boolean. 42 | 43 | That set a configuration `{ layoutType: models.LayoutType.MobilePortrait }`. 44 | 45 | Check this [reference](https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-For-Mobile) 46 | 47 | #### Embed Type 48 | The embed type variable allows you to pass in the requested PowerBI "Type", be that a `report`, `dashboard` or `tile`. See [reference](https://microsoft.github.io/PowerBI-JavaScript/interfaces/_src_embed_.iembedconfigurationbase.html#type). By default, `report` is selected. 49 | 50 | ## TODO 51 | - [x] Add .d.ts file for typescript (Thanks @Joonaspraks!) 52 | -------------------------------------------------------------------------------- /example/example.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react' 2 | import ReactDOM from 'react-dom' 3 | import PowerBiEmbedded from '../src/index' 4 | 5 | type Props = { 6 | token: string; 7 | } 8 | 9 | // eslint-disable-next-line react/prop-types 10 | const Example: React.FC = ({token}) => { 11 | const [mobileVal, setMobileVal] = useState(false) 12 | const [widthValue, setWidthValue] = useState(400) 13 | 14 | return
15 | 16 | 17 | {setWidthValue(+evt.target.value)}} value={widthValue}/> 18 | console.log('loaded!!!!!')} 25 | permissions={7} 26 | embedType="report" 27 | // eslint-disable-next-line max-len 28 | embedUrl="https://app.powerbi.com/reportEmbed?reportId=f6bfd646-b718-44dc-a378-b73e6b528204&groupId=be8908da-da25-452e-b220-163f52476cdd&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly9XQUJJLVVTLU5PUlRILUNFTlRSQUwtcmVkaXJlY3QuYW5hbHlzaXMud2luZG93cy5uZXQiLCJlbWJlZEZlYXR1cmVzIjp7Im1vZGVybkVtYmVkIjp0cnVlfX0%3d" 29 | accessToken={token} 30 | /> 31 |
32 | } 33 | 34 | fetch('https://powerbiplaygroundbe.azurewebsites.net/api/Reports/SampleReport') 35 | .then(res => res.json()) 36 | .then((data) => { 37 | const token = data.embedToken.token 38 | 39 | ReactDOM.render( 40 | 41 | 42 | , 43 | document.getElementById('root') 44 | ) 45 | }) 46 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | preset: 'ts-jest', 4 | 'roots': [ 5 | '' 6 | ], 7 | 'testMatch': [ 8 | '**/?(*.)+(spec|test).+(ts|tsx|js)' 9 | ], 10 | 'transform': { 11 | '^.+\\.(ts|tsx)$': 'ts-jest' 12 | }, 13 | 'snapshotSerializers': ['enzyme-to-json/serializer'], 14 | 'setupFilesAfterEnv': ['/test/setupEnzyme.ts'], 15 | globals: { 16 | // we must specify a custom tsconfig for tests because we need the typescript transform 17 | // to transform jsx into js rather than leaving it jsx such as the next build requires. you 18 | // can see this setting in tsconfig.jest.json -> "jsx": "react" 19 | 'ts-jest': { 20 | tsConfig: 'tsconfig.jest.json' 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/index.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { IEmbedConfiguration } from 'embed'; 3 | declare type EmbedType = 'report' | 'dashboard' | 'tile'; 4 | declare type ExtraSettings = { 5 | embedType?: EmbedType; 6 | mobile?: boolean; 7 | filterPaneEnabled?: boolean; 8 | navContentPaneEnabled?: boolean; 9 | }; 10 | declare type PowerBIEmbeddedProps = React.HTMLAttributes & IEmbedConfiguration & ExtraSettings; 11 | declare const PowerBIEmbedded: React.FC; 12 | export default PowerBIEmbedded; 13 | -------------------------------------------------------------------------------- /lib/react-powerbi.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define("react-powerbi",["react"],e):"object"==typeof exports?exports["react-powerbi"]=e(require("react")):t["react-powerbi"]=e(t.react)}(window,(function(t){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(a,i,function(e){return t[e]}.bind(null,i));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a,i=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],a=!0,i=!1,o=void 0;try{for(var n,l=t[Symbol.iterator]();!(a=(n=l.next()).done)&&(r.push(n.value),!e||r.length!==e);a=!0);}catch(t){i=!0,o=t}finally{try{!a&&l.return&&l.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},o=r(1),n=(a=o)&&a.__esModule?a:{default:a},l=r(2),d=r(3);var s=function(t,e){var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(r[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i0&&void 0!==arguments[0]?arguments[0]:"report",e=arguments[1],r={report:l.models.validateReportLoad,dashboard:l.models.validateDashboardLoad,tile:l.models.validateTileLoad},a=r[t](e);return console.error("PowerBI Embed Config Error, See Error Array -> ",a),void 0===a}function V(t,e){var r=t.embedType,a=t.mobile,i=t.tokenType,o=t.permissions,n=t.filterPaneEnabled,u=t.navContentPaneEnabled,p=t.settings,c=s(t,["embedType","mobile","tokenType","permissions","filterPaneEnabled","navContentPaneEnabled","settings"]);return Object.assign(Object.assign(Object.assign({},e),c),{settings:Object.assign(Object.assign({},p),{filterPaneEnabled:n,navContentPaneEnabled:u,layoutType:a?l.models.LayoutType.MobilePortrait:void 0}),permissions:o||d.Permissions.All,tokenType:i||d.TokenType.Embed,type:r||"report"})}return(0,o.useEffect)((function(){return function(){var t=a.current;u.reset(t),r.current=null}}),[t.mobile]),(0,o.useEffect)((function(){console.log("tried to run");var i=V(t);if(h(e,i)){console.log("validated");var o=u.embed(a.current,i);v(o)}return function(){var t=a.current;u.reset(t),r.current=null}}),[]),(0,o.useEffect)((function(){if(f){var r=V(t);h(e,r)&&u.embed(a.current,r)}}),[t]),n.default.createElement("div",{className:"powerbi-container",style:{width:t.width,height:t.height},ref:function(t){a.current=t}})};p.defaultProps={embedType:"report"},e.default=p},function(e,r){e.exports=t},function(t,e,r){ 2 | /*! powerbi-client v2.11.0 | (c) 2016 Microsoft Corporation MIT */ 3 | var a;a=function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var i=e[a]={exports:{},id:a,loaded:!1};return t[a].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.m=t,r.c=e,r.p="",r(0)}([function(t,e,r){var a=r(1);e.service=a;var i=r(17);e.factories=i;var o=r(5);e.models=o;var n=r(7);e.Report=n.Report;var l=r(13);e.Dashboard=l.Dashboard;var d=r(14);e.Tile=d.Tile;var s=r(2);e.Embed=s.Embed;var u=r(8);e.Page=u.Page;var p=r(15);e.Qna=p.Qna;var c=r(16);e.Visual=c.Visual;var f=r(9);e.VisualDescriptor=f.VisualDescriptor;var v=new a.Service(i.hpmFactory,i.wpmpFactory,i.routerFactory);window.powerbi=v},function(t,e,r){var a=r(2),i=r(7),o=r(12),n=r(13),l=r(14),d=r(8),s=r(15),u=r(16),p=r(3),c=function(){function t(e,r,a,i){var o=this;void 0===i&&(i={}),this.wpmp=r(i.wpmpName,i.logMessages),this.hpm=e(this.wpmp,null,i.version,i.type),this.router=a(this.wpmp),this.uniqueSessionId=p.generateUUID(),this.router.post("/reports/:uniqueId/events/:eventName",(function(t,e){var r={type:"report",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/reports/:uniqueId/pages/:pageName/events/:eventName",(function(t,e){var r={type:"report",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName",(function(t,e){var r={type:"report",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/dashboards/:uniqueId/events/:eventName",(function(t,e){var r={type:"dashboard",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/tile/:uniqueId/events/:eventName",(function(t,e){var r={type:"tile",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/qna/:uniqueId/events/:eventName",(function(t,e){var r={type:"qna",id:t.params.uniqueId,name:t.params.eventName,value:t.body};o.handleEvent(r)})),this.router.post("/ready/:uniqueId",(function(t,e){var r={type:"report",id:t.params.uniqueId,name:"ready",value:t.body};o.handleEvent(r)})),this.embeds=[],this.config=p.assign({},t.defaultConfig,i),this.config.autoEmbedOnContentLoaded&&this.enableAutoEmbed()}return t.prototype.createReport=function(t,e){e.type="create";var r=t,a=new o.Create(this,r,e);return r.powerBiEmbed=a,this.addOrOverwriteEmbed(a,t),a},t.prototype.init=function(t,e){var r=this;return void 0===e&&(e=void 0),t=t&&t instanceof HTMLElement?t:document.body,Array.prototype.slice.call(t.querySelectorAll("["+a.Embed.embedUrlAttribute+"]")).map((function(t){return r.embed(t,e)}))},t.prototype.embed=function(t,e){return void 0===e&&(e={}),this.embedInternal(t,e)},t.prototype.load=function(t,e){return void 0===e&&(e={}),this.embedInternal(t,e,!0,!1)},t.prototype.bootstrap=function(t,e){return this.embedInternal(t,e,!1,!0)},t.prototype.embedInternal=function(t,e,r,a){var i;void 0===e&&(e={});var o=t;if(o.powerBiEmbed){if(a)throw new Error("Attempted to bootstrap element "+t.outerHTML+", but the element is already a powerbi element.");i=this.embedExisting(o,e,r)}else i=this.embedNew(o,e,r,a);return i},t.prototype.getNumberOfComponents=function(){return this.embeds?this.embeds.length:0},t.prototype.getSdkSessionId=function(){return this.uniqueSessionId},t.prototype.embedNew=function(e,r,o,n){var l=r.type||e.getAttribute(a.Embed.typeAttribute);if(!l)throw new Error("Attempted to embed using config "+JSON.stringify(r)+" on element "+e.outerHTML+", but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '"+a.Embed.typeAttribute+'="'+i.Report.type.toLowerCase()+"\"'.");r.type=l;var d=p.find((function(t){return l===t.type.toLowerCase()}),t.components);if(!d)throw new Error("Attempted to embed component of type: "+l+" but did not find any matching component. Please verify the type you specified is intended.");var s=new d(this,e,r,o,n);return e.powerBiEmbed=s,this.addOrOverwriteEmbed(s,e),s},t.prototype.embedExisting=function(t,e,r){var a=p.find((function(e){return e.element===t}),this.embeds);if(!a)throw new Error("Attempted to embed using config "+JSON.stringify(e)+" on element "+t.outerHTML+" which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.");if(e.type&&"qna"===e.type.toLowerCase())return this.embedNew(t,e);if("string"==typeof e.type&&e.type!==a.config.type){if("report"===e.type&&"create"===a.config.type){var o=new i.Report(this,t,e,!1,!1,t.powerBiEmbed.iframe);return o.load(e),t.powerBiEmbed=o,this.addOrOverwriteEmbed(a,t),o}throw new Error("Embedding on an existing element with a different type than the previous embed object is not supported. Attempted to embed using config "+JSON.stringify(e)+" on element "+t.outerHTML+", but the existing element contains an embed of type: "+this.config.type+" which does not match the new type: "+e.type)}return a.populateConfig(e,!1),a.load(a.config,r),a},t.prototype.enableAutoEmbed=function(){var t=this;window.addEventListener("DOMContentLoaded",(function(e){return t.init(document.body)}),!1)},t.prototype.get=function(t){var e=t;if(!e.powerBiEmbed)throw new Error("You attempted to get an instance of powerbi component associated with element: "+t.outerHTML+" but there was no associated instance.");return e.powerBiEmbed},t.prototype.find=function(t){return p.find((function(e){return e.config.uniqueId===t}),this.embeds)},t.prototype.addOrOverwriteEmbed=function(t,e){this.embeds=this.embeds.filter((function(t){return t.element.id!==e.id})),this.embeds.push(t)},t.prototype.reset=function(t){var e=t;if(e.powerBiEmbed){var r=e.powerBiEmbed;r.frontLoadHandler&&r.element.removeEventListener("ready",r.frontLoadHandler,!1),p.remove((function(t){return t===e.powerBiEmbed}),this.embeds),delete e.powerBiEmbed;var a=t.querySelector("iframe");a&&(void 0!==a.remove?a.remove():a.parentElement.removeChild(a))}},t.prototype.handleTileEvents=function(t){"tile"===t.type&&this.handleEvent(t)},t.prototype.handleEvent=function(t){var e=p.find((function(e){return e.config.uniqueId===t.id}),this.embeds);if(e){var r=t.value;if("pageChanged"===t.name){var a=r.newPage;if(!a)throw new Error("Page model not found at 'event.value.newPage'.");r.newPage=new d.Page(e,a.name,a.displayName,!0)}p.raiseCustomEvent(e.element,t.name,r)}},t.prototype.preload=function(t,e){var r=document.createElement("iframe");r.setAttribute("style","display:none;"),r.setAttribute("src",t.embedUrl),r.setAttribute("scrolling","no"),r.setAttribute("allowfullscreen","false");var a=e;return a||(a=document.getElementsByTagName("body")[0]),a.appendChild(r),r.onload=function(){p.raiseCustomEvent(r,"preloaded",{})},r},t.components=[l.Tile,i.Report,n.Dashboard,s.Qna,u.Visual],t.defaultConfig={autoEmbedOnContentLoaded:!1,onError:function(){for(var t=[],e=0;e0?"&":"?";return t+=a+e+"="+r},e.isSavedInternal=function(t,e,r){return t.get("/report/hasUnsavedChanges",{uid:e},r).then((function(t){return!t.body}),(function(t){throw t.body}))},e.isRDLEmbed=function(t){return t.toLowerCase().indexOf("/rdlembed?")>=0},e.autoAuthInEmbedUrl=function(t){return t&&decodeURIComponent(t).toLowerCase().indexOf("autoauth=true")>=0},e.getRandomValue=a},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default={version:"2.11.0",type:"js"}},function(t,e,r){ 4 | /*! powerbi-models v1.3.3 | (c) 2016 Microsoft Corporation MIT */ 5 | var a;window,a=function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(a,i,function(e){return t[e]}.bind(null,i));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){var a,i,o=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.Validators=r(1).Validators,function(t){t[t.Information=0]="Information",t[t.Verbose=1]="Verbose",t[t.Warning=2]="Warning",t[t.Error=3]="Error",t[t.ExpectedError=4]="ExpectedError",t[t.UnexpectedError=5]="UnexpectedError",t[t.Fatal=6]="Fatal"}(e.TraceType||(e.TraceType={})),function(t){t[t.Widescreen=0]="Widescreen",t[t.Standard=1]="Standard",t[t.Cortana=2]="Cortana",t[t.Letter=3]="Letter",t[t.Custom=4]="Custom"}(e.PageSizeType||(e.PageSizeType={})),function(t){t[t.FitToPage=0]="FitToPage",t[t.FitToWidth=1]="FitToWidth",t[t.ActualSize=2]="ActualSize"}(e.DisplayOption||(e.DisplayOption={})),function(t){t[t.Default=0]="Default",t[t.Transparent=1]="Transparent"}(e.BackgroundType||(e.BackgroundType={})),function(t){t[t.Visible=0]="Visible",t[t.Hidden=1]="Hidden"}(e.VisualContainerDisplayMode||(e.VisualContainerDisplayMode={})),function(t){t[t.Master=0]="Master",t[t.Custom=1]="Custom",t[t.MobilePortrait=2]="MobilePortrait",t[t.MobileLandscape=3]="MobileLandscape"}(e.LayoutType||(e.LayoutType={})),function(t){t[t.Navigate=0]="Navigate",t[t.NavigateAndRaiseEvent=1]="NavigateAndRaiseEvent",t[t.RaiseEvent=2]="RaiseEvent"}(e.HyperlinkClickBehavior||(e.HyperlinkClickBehavior={})),function(t){t[t.AlwaysVisible=0]="AlwaysVisible",t[t.HiddenInViewMode=1]="HiddenInViewMode"}(e.SectionVisibility||(e.SectionVisibility={})),function(t){t[t.Read=0]="Read",t[t.ReadWrite=1]="ReadWrite",t[t.Copy=2]="Copy",t[t.Create=4]="Create",t[t.All=7]="All"}(e.Permissions||(e.Permissions={})),function(t){t[t.View=0]="View",t[t.Edit=1]="Edit"}(e.ViewMode||(e.ViewMode={})),function(t){t[t.Aad=0]="Aad",t[t.Embed=1]="Embed"}(e.TokenType||(e.TokenType={})),function(t){t[t.None=0]="None",t[t.HighContrast1=1]="HighContrast1",t[t.HighContrast2=2]="HighContrast2",t[t.HighContrastBlack=3]="HighContrastBlack",t[t.HighContrastWhite=4]="HighContrastWhite"}(e.ContrastMode||(e.ContrastMode={})),function(t){t[t.Bottom=0]="Bottom",t[t.Top=1]="Top"}(e.MenuLocation||(e.MenuLocation={})),function(t){t[t.Report=0]="Report",t[t.Page=1]="Page",t[t.Visual=2]="Visual"}(e.FiltersLevel||(e.FiltersLevel={})),function(t){t[t.Advanced=0]="Advanced",t[t.Basic=1]="Basic",t[t.Unknown=2]="Unknown",t[t.IncludeExclude=3]="IncludeExclude",t[t.RelativeDate=4]="RelativeDate",t[t.TopN=5]="TopN",t[t.Tuple=6]="Tuple"}(i=e.FilterType||(e.FilterType={})),function(t){t[t.Days=0]="Days",t[t.Weeks=1]="Weeks",t[t.CalendarWeeks=2]="CalendarWeeks",t[t.Months=3]="Months",t[t.CalendarMonths=4]="CalendarMonths",t[t.Years=5]="Years",t[t.CalendarYears=6]="CalendarYears"}(e.RelativeDateFilterTimeUnit||(e.RelativeDateFilterTimeUnit={})),function(t){t[t.InLast=0]="InLast",t[t.InThis=1]="InThis",t[t.InNext=2]="InNext"}(e.RelativeDateOperators||(e.RelativeDateOperators={}));var n=function(){function t(t,e){this.target=t,this.filterType=e}return t.prototype.toJSON=function(){var t={$schema:this.schemaUrl,target:this.target,filterType:this.filterType};return void 0!==this.displaySettings&&(t.displaySettings=this.displaySettings),t},t}();e.Filter=n;var l=function(t){function e(r,a,o){var n=t.call(this,r,i.Unknown)||this;return n.message=a,n.notSupportedTypeName=o,n.schemaUrl=e.schemaUrl,n}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.message=this.message,e.notSupportedTypeName=this.notSupportedTypeName,e},e.schemaUrl="http://powerbi.com/product/schema#notSupported",e}(n);e.NotSupportedFilter=l;var d=function(t){function e(r,a,o){var n=t.call(this,r,i.IncludeExclude)||this;return n.values=o,n.isExclude=a,n.schemaUrl=e.schemaUrl,n}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.isExclude=this.isExclude,e.values=this.values,e},e.schemaUrl="http://powerbi.com/product/schema#includeExclude",e}(n);e.IncludeExcludeFilter=d;var s=function(t){function e(r,a,o,n){var l=t.call(this,r,i.TopN)||this;return l.operator=a,l.itemCount=o,l.schemaUrl=e.schemaUrl,l.orderBy=n,l}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.operator=this.operator,e.itemCount=this.itemCount,e.orderBy=this.orderBy,e},e.schemaUrl="http://powerbi.com/product/schema#topN",e}(n);e.TopNFilter=s;var u=function(t){function e(r,a,o,n,l){var d=t.call(this,r,i.RelativeDate)||this;return d.operator=a,d.timeUnitsCount=o,d.timeUnitType=n,d.includeToday=l,d.schemaUrl=e.schemaUrl,d}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.operator=this.operator,e.timeUnitsCount=this.timeUnitsCount,e.timeUnitType=this.timeUnitType,e.includeToday=this.includeToday,e},e.schemaUrl="http://powerbi.com/product/schema#relativeDate",e}(n);e.RelativeDateFilter=u;var p=function(t){function e(r,a){for(var o=[],n=2;n0&&!i)throw new Error("You should pass the values to be filtered for each key. You passed: no values and "+n+" keys");if(0===n&&i&&i.length>0)throw new Error("You passed key values but your target object doesn't contain the keys to be filtered");for(var l=0;l2)throw new Error("AdvancedFilters may not have more than two conditions. You passed: "+o.length);if(1===l.length&&"And"!==a)throw new Error('Logical Operator must be "And" when there is only one condition provided');return d.conditions=l,d}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.logicalOperator=this.logicalOperator,e.conditions=this.conditions,e},e.schemaUrl="http://powerbi.com/product/schema#advanced",e}(n);function h(t){if(t.filterType)return t.filterType;var e=t,r=t;return"string"==typeof e.operator&&Array.isArray(e.values)?i.Basic:"string"==typeof r.logicalOperator&&Array.isArray(r.conditions)?i.Advanced:i.Unknown}function V(t){return!(!t.table||!t.column||t.aggregationFunction)}e.AdvancedFilter=v,e.isFilterKeyColumnsTarget=function(t){return V(t)&&!!t.keys},e.isBasicFilterWithKeys=function(t){return h(t)===i.Basic&&!!t.keyValues},e.getFilterType=h,e.isMeasure=function(t){return void 0!==t.table&&void 0!==t.measure},e.isColumn=V,e.isHierarchyLevel=function(t){return!(!(t.table&&t.hierarchy&&t.hierarchyLevel)||t.aggregationFunction)},e.isHierarchyLevelAggr=function(t){return!!(t.table&&t.hierarchy&&t.hierarchyLevel&&t.aggregationFunction)},e.isColumnAggr=function(t){return!!(t.table&&t.column&&t.aggregationFunction)},function(t){t[t.Interactive=0]="Interactive",t[t.ResultOnly=1]="ResultOnly"}(e.QnaMode||(e.QnaMode={})),function(t){t[t.Summarized=0]="Summarized",t[t.Underlying=1]="Underlying"}(e.ExportDataType||(e.ExportDataType={})),function(t){t[t.Off=0]="Off",t[t.Presentation=1]="Presentation"}(e.BookmarksPlayMode||(e.BookmarksPlayMode={})),e.CommonErrorCodes={TokenExpired:"TokenExpired",NotFound:"PowerBIEntityNotFound",InvalidParameters:"Invalid parameters",LoadReportFailed:"LoadReportFailed",NotAuthorized:"PowerBINotAuthorizedException",FailedToLoadModel:"ExplorationContainer_FailedToLoadModel_DefaultDetails"},e.TextAlignment={Left:"left",Center:"center",Right:"right"},e.LegendPosition={Top:"Top",Bottom:"Bottom",Right:"Right",Left:"Left",TopCenter:"TopCenter",BottomCenter:"BottomCenter",RightCenter:"RightCenter",LeftCenter:"LeftCenter"},function(t){t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(e.SortDirection||(e.SortDirection={}));var y=function(){function t(t){this.$schema=t}return t.prototype.toJSON=function(){return{$schema:this.$schema}},t}();e.Selector=y;var m=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.pageName=r,a}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.pageName=this.pageName,e},e.schemaUrl="http://powerbi.com/product/schema#pageSelector",e}(y);e.PageSelector=m;var g=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.visualName=r,a}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualName=this.visualName,e},e.schemaUrl="http://powerbi.com/product/schema#visualSelector",e}(y);e.VisualSelector=g;var w=function(t){function e(e){var r=t.call(this,g.schemaUrl)||this;return r.visualType=e,r}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualType=this.visualType,e},e.schemaUrl="http://powerbi.com/product/schema#visualTypeSelector",e}(y);e.VisualTypeSelector=w;var b=function(t){function e(e){var r=t.call(this,g.schemaUrl)||this;return r.target=e,r}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.target=this.target,e},e.schemaUrl="http://powerbi.com/product/schema#slicerTargetSelector",e}(y);function _(t){var e=t.message;return e||(e=t.path+" is invalid. Not meeting "+t.keyword+" constraint"),{message:e}}e.SlicerTargetSelector=b,function(t){t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t[t.Hidden=2]="Hidden"}(e.CommandDisplayOption||(e.CommandDisplayOption={})),function(t){t[t.Grouping=0]="Grouping",t[t.Measure=1]="Measure",t[t.GroupingOrMeasure=2]="GroupingOrMeasure"}(e.VisualDataRoleKind||(e.VisualDataRoleKind={})),function(t){t[t.Measure=0]="Measure",t[t.Grouping=1]="Grouping"}(e.VisualDataRoleKindPreference||(e.VisualDataRoleKindPreference={})),e.validateVisualSelector=function(t){var r=e.Validators.visualSelectorValidator.validate(t);return r?r.map(_):void 0},e.validateSlicer=function(t){var r=e.Validators.slicerValidator.validate(t);return r?r.map(_):void 0},e.validateSlicerState=function(t){var r=e.Validators.slicerStateValidator.validate(t);return r?r.map(_):void 0},e.validatePlayBookmarkRequest=function(t){var r=e.Validators.playBookmarkRequestValidator.validate(t);return r?r.map(_):void 0},e.validateAddBookmarkRequest=function(t){var r=e.Validators.addBookmarkRequestValidator.validate(t);return r?r.map(_):void 0},e.validateApplyBookmarkByNameRequest=function(t){var r=e.Validators.applyBookmarkByNameRequestValidator.validate(t);return r?r.map(_):void 0},e.validateApplyBookmarkStateRequest=function(t){var r=e.Validators.applyBookmarkStateRequestValidator.validate(t);return r?r.map(_):void 0},e.validateSettings=function(t){var r=e.Validators.settingsValidator.validate(t);return r?r.map(_):void 0},e.validateCustomPageSize=function(t){var r=e.Validators.customPageSizeValidator.validate(t);return r?r.map(_):void 0},e.validateExtension=function(t){var r=e.Validators.extensionValidator.validate(t);return r?r.map(_):void 0},e.validateReportLoad=function(t){var r=e.Validators.reportLoadValidator.validate(t);return r?r.map(_):void 0},e.validateCreateReport=function(t){var r=e.Validators.reportCreateValidator.validate(t);return r?r.map(_):void 0},e.validateDashboardLoad=function(t){var r=e.Validators.dashboardLoadValidator.validate(t);return r?r.map(_):void 0},e.validateTileLoad=function(t){var r=e.Validators.tileLoadValidator.validate(t);return r?r.map(_):void 0},e.validatePage=function(t){var r=e.Validators.pageValidator.validate(t);return r?r.map(_):void 0},e.validateFilter=function(t){var r=e.Validators.filtersValidator.validate(t);return r?r.map(_):void 0},e.validateSaveAsParameters=function(t){var r=e.Validators.saveAsParametersValidator.validate(t);return r?r.map(_):void 0},e.validateLoadQnaConfiguration=function(t){var r=e.Validators.loadQnaValidator.validate(t);return r?r.map(_):void 0},e.validateQnaInterpretInputData=function(t){var r=e.Validators.qnaInterpretInputDataValidator.validate(t);return r?r.map(_):void 0},e.validateExportDataRequest=function(t){var r=e.Validators.exportDataRequestValidator.validate(t);return r?r.map(_):void 0},e.validateVisualHeader=function(t){var r=e.Validators.visualHeaderValidator.validate(t);return r?r.map(_):void 0},e.validateVisualSettings=function(t){var r=e.Validators.visualSettingsValidator.validate(t);return r?r.map(_):void 0},e.validateCommandsSettings=function(t){var r=e.Validators.commandsSettingsValidator.validate(t);return r?r.map(_):void 0},e.validateCustomTheme=function(t){var r=e.Validators.customThemeValidator.validate(t);return r?r.map(_):void 0}},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var a=r(2),i=r(3),o=r(5),n=r(6),l=r(7),d=r(8),s=r(9),u=r(10),p=r(11),c=r(12),f=r(13),v=r(14),h=r(15),V=r(16),y=r(17),m=r(18),g=r(19),w=r(20),b=r(21),_=r(22),O=r(23),S=r(24),T=r(25);e.Validators={addBookmarkRequestValidator:new n.AddBookmarkRequestValidator,advancedFilterTypeValidator:new a.EnumValidator([0]),advancedFilterValidator:new l.AdvancedFilterValidator,anyArrayValidator:new a.ArrayValidator([new s.AnyOfValidator([new a.StringValidator,new a.NumberValidator,new a.BooleanValidator])]),anyFilterValidator:new s.AnyOfValidator([new l.BasicFilterValidator,new l.AdvancedFilterValidator,new l.IncludeExcludeFilterValidator,new l.NotSupportedFilterValidator,new l.RelativeDateFilterValidator,new l.TopNFilterValidator]),anyValueValidator:new s.AnyOfValidator([new a.StringValidator,new a.NumberValidator,new a.BooleanValidator]),applyBookmarkByNameRequestValidator:new n.ApplyBookmarkByNameRequestValidator,applyBookmarkStateRequestValidator:new n.ApplyBookmarkStateRequestValidator,applyBookmarkValidator:new s.AnyOfValidator([new n.ApplyBookmarkByNameRequestValidator,new n.ApplyBookmarkStateRequestValidator]),backgroundValidator:new a.EnumValidator([0,1]),basicFilterTypeValidator:new a.EnumValidator([1]),basicFilterValidator:new l.BasicFilterValidator,booleanArrayValidator:new a.BooleanArrayValidator,booleanValidator:new a.BooleanValidator,commandDisplayOptionValidator:new a.EnumValidator([0,1,2]),commandExtensionSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),commandExtensionValidator:new i.CommandExtensionValidator,commandsSettingsArrayValidator:new a.ArrayValidator([new O.CommandsSettingsValidator]),commandsSettingsValidator:new O.CommandsSettingsValidator,conditionItemValidator:new l.ConditionItemValidator,contrastModeValidator:new a.EnumValidator([0,1,2,3,4]),customLayoutDisplayOptionValidator:new a.EnumValidator([0,1,2]),customLayoutValidator:new m.CustomLayoutValidator,customPageSizeValidator:new v.CustomPageSizeValidator,customThemeValidator:new S.CustomThemeValidator,dashboardLoadValidator:new c.DashboardLoadValidator,datasetBindingValidator:new T.DatasetBindingValidator,displayStateModeValidator:new a.EnumValidator([0,1]),displayStateValidator:new m.DisplayStateValidator,exportDataRequestValidator:new g.ExportDataRequestValidator,extensionArrayValidator:new a.ArrayValidator([new i.ExtensionValidator]),extensionPointsValidator:new i.ExtensionPointsValidator,extensionValidator:new i.ExtensionValidator,fieldRequiredValidator:new d.FieldRequiredValidator,filterColumnTargetValidator:new l.FilterColumnTargetValidator,filterConditionsValidator:new a.ArrayValidator([new l.ConditionItemValidator]),filterHierarchyTargetValidator:new l.FilterHierarchyTargetValidator,filterMeasureTargetValidator:new l.FilterMeasureTargetValidator,filterTargetValidator:new s.AnyOfValidator([new l.FilterColumnTargetValidator,new l.FilterHierarchyTargetValidator,new l.FilterMeasureTargetValidator]),filtersArrayValidator:new a.ArrayValidator([new s.AnyOfValidator([new l.BasicFilterValidator,new l.AdvancedFilterValidator,new l.RelativeDateFilterValidator])]),filtersValidator:new l.FilterValidator,hyperlinkClickBehaviorValidator:new a.EnumValidator([0,1,2]),includeExcludeFilterValidator:new l.IncludeExcludeFilterValidator,includeExludeFilterTypeValidator:new a.EnumValidator([3]),layoutTypeValidator:new a.EnumValidator([0,1,2,3]),loadQnaValidator:new h.LoadQnaValidator,menuExtensionValidator:new i.MenuExtensionValidator,menuLocationValidator:new a.EnumValidator([0,1]),notSupportedFilterTypeValidator:new a.EnumValidator([2]),notSupportedFilterValidator:new l.NotSupportedFilterValidator,numberArrayValidator:new a.NumberArrayValidator,numberValidator:new a.NumberValidator,pageLayoutValidator:new y.MapValidator([new a.StringValidator],[new m.VisualLayoutValidator]),pageSizeTypeValidator:new a.EnumValidator([0,1,2,3,4,5]),pageSizeValidator:new v.PageSizeValidator,pageValidator:new v.PageValidator,pageViewFieldValidator:new v.PageViewFieldValidator,pagesLayoutValidator:new y.MapValidator([new a.StringValidator],[new m.PageLayoutValidator]),permissionsValidator:new a.EnumValidator([0,1,2,4,7]),playBookmarkRequestValidator:new n.PlayBookmarkRequestValidator,qnaInterpretInputDataValidator:new h.QnaInterpretInputDataValidator,qnaSettingValidator:new h.QnaSettingsValidator,relativeDateFilterOperatorValidator:new a.EnumValidator([0,1,2]),relativeDateFilterTimeUnitTypeValidator:new a.EnumValidator([0,1,2,3,4,5,6]),relativeDateFilterTypeValidator:new a.EnumValidator([4]),relativeDateFilterValidator:new l.RelativeDateFilterValidator,reportCreateValidator:new p.ReportCreateValidator,reportLoadValidator:new u.ReportLoadValidator,saveAsParametersValidator:new V.SaveAsParametersValidator,settingsValidator:new o.SettingsValidator,singleCommandSettingsValidator:new O.SingleCommandSettingsValidator,slicerSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.SlicerTargetSelectorValidator]),slicerStateValidator:new b.SlicerStateValidator,slicerTargetValidator:new s.AnyOfValidator([new l.FilterColumnTargetValidator,new l.FilterHierarchyTargetValidator,new l.FilterMeasureTargetValidator,new l.FilterKeyColumnsTargetValidator,new l.FilterKeyHierarchyTargetValidator]),slicerValidator:new b.SlicerValidator,stringArrayValidator:new a.StringArrayValidator,stringValidator:new a.StringValidator,tileLoadValidator:new f.TileLoadValidator,tokenTypeValidator:new a.EnumValidator([0,1]),topNFilterTypeValidator:new a.EnumValidator([5]),topNFilterValidator:new l.TopNFilterValidator,viewModeValidator:new a.EnumValidator([0,1]),visualCommandSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),visualHeaderSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),visualHeaderSettingsValidator:new _.VisualHeaderSettingsValidator,visualHeaderValidator:new _.VisualHeaderValidator,visualHeadersValidator:new a.ArrayValidator([new _.VisualHeaderValidator]),visualLayoutValidator:new m.VisualLayoutValidator,visualSelectorValidator:new w.VisualSelectorValidator,visualSettingsValidator:new _.VisualSettingsValidator,visualTypeSelectorValidator:new w.VisualTypeSelectorValidator}},function(t,e){var r,a=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function a(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(){}return t.prototype.validate=function(t,e,r){return null==t?null:"object"!=typeof t||Array.isArray(t)?[{message:void 0!==r?r+" must be an object":"input must be an object",path:e,keyword:"type"}]:null},t}();e.ObjectValidator=i;var o=function(){function t(t){this.itemValidators=t}return t.prototype.validate=function(t,e,r){if(null==t)return null;if(!Array.isArray(t))return[{message:r+" property is invalid",path:(e?e+".":"")+r,keyword:"type"}];for(var a=0;a2&&"[]"===n.slice(l-2)&&(d=!0,r[n=n.slice(0,l-2)]||(r[n]=[])),i=o[1]?m(o[1]):""),d?r[n].push(i):r[n]=i}return r},recognize:function(t){var e,r,a,i=[this.rootState],o={},n=!1;if(-1!==(a=t.indexOf("?"))){var l=t.substr(a+1,t.length);t=t.substr(0,a),o=this.parseQueryString(l)}for("/"!==(t=decodeURI(t)).charAt(0)&&(t="/"+t),(e=t.length)>1&&"/"===t.charAt(e-1)&&(t=t.substr(0,e-1),n=!0),r=0;r0&&!i)throw new Error("You should pass the values to be filtered for each key. You passed: no values and "+n+" keys");if(0===n&&i&&i.length>0)throw new Error("You passed key values but your target object doesn't contain the keys to be filtered");for(var l=0;l2)throw new Error("AdvancedFilters may not have more than two conditions. You passed: "+o.length);if(1===l.length&&"And"!==a)throw new Error('Logical Operator must be "And" when there is only one condition provided');return d.conditions=l,d}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.logicalOperator=this.logicalOperator,e.conditions=this.conditions,e},e.schemaUrl="http://powerbi.com/product/schema#advanced",e}(n);function h(t){if(t.filterType)return t.filterType;var e=t,r=t;return"string"==typeof e.operator&&Array.isArray(e.values)?i.Basic:"string"==typeof r.logicalOperator&&Array.isArray(r.conditions)?i.Advanced:i.Unknown}function V(t){return!(!t.table||!t.column||t.aggregationFunction)}e.AdvancedFilter=v,e.isFilterKeyColumnsTarget=function(t){return V(t)&&!!t.keys},e.isBasicFilterWithKeys=function(t){return h(t)===i.Basic&&!!t.keyValues},e.getFilterType=h,e.isMeasure=function(t){return void 0!==t.table&&void 0!==t.measure},e.isColumn=V,e.isHierarchyLevel=function(t){return!(!(t.table&&t.hierarchy&&t.hierarchyLevel)||t.aggregationFunction)},e.isHierarchyLevelAggr=function(t){return!!(t.table&&t.hierarchy&&t.hierarchyLevel&&t.aggregationFunction)},e.isColumnAggr=function(t){return!!(t.table&&t.column&&t.aggregationFunction)},function(t){t[t.Interactive=0]="Interactive",t[t.ResultOnly=1]="ResultOnly"}(e.QnaMode||(e.QnaMode={})),function(t){t[t.Summarized=0]="Summarized",t[t.Underlying=1]="Underlying"}(e.ExportDataType||(e.ExportDataType={})),function(t){t[t.Off=0]="Off",t[t.Presentation=1]="Presentation"}(e.BookmarksPlayMode||(e.BookmarksPlayMode={})),e.CommonErrorCodes={TokenExpired:"TokenExpired",NotFound:"PowerBIEntityNotFound",InvalidParameters:"Invalid parameters",LoadReportFailed:"LoadReportFailed",NotAuthorized:"PowerBINotAuthorizedException",FailedToLoadModel:"ExplorationContainer_FailedToLoadModel_DefaultDetails"},e.TextAlignment={Left:"left",Center:"center",Right:"right"},e.LegendPosition={Top:"Top",Bottom:"Bottom",Right:"Right",Left:"Left",TopCenter:"TopCenter",BottomCenter:"BottomCenter",RightCenter:"RightCenter",LeftCenter:"LeftCenter"},function(t){t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(e.SortDirection||(e.SortDirection={}));var y=function(){function t(t){this.$schema=t}return t.prototype.toJSON=function(){return{$schema:this.$schema}},t}();e.Selector=y;var m=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.pageName=r,a}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.pageName=this.pageName,e},e.schemaUrl="http://powerbi.com/product/schema#pageSelector",e}(y);e.PageSelector=m;var g=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.visualName=r,a}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualName=this.visualName,e},e.schemaUrl="http://powerbi.com/product/schema#visualSelector",e}(y);e.VisualSelector=g;var w=function(t){function e(e){var r=t.call(this,g.schemaUrl)||this;return r.visualType=e,r}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualType=this.visualType,e},e.schemaUrl="http://powerbi.com/product/schema#visualTypeSelector",e}(y);e.VisualTypeSelector=w;var b=function(t){function e(e){var r=t.call(this,g.schemaUrl)||this;return r.target=e,r}return o(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.target=this.target,e},e.schemaUrl="http://powerbi.com/product/schema#slicerTargetSelector",e}(y);function _(t){var e=t.message;return e||(e=t.path+" is invalid. Not meeting "+t.keyword+" constraint"),{message:e}}e.SlicerTargetSelector=b,function(t){t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t[t.Hidden=2]="Hidden"}(e.CommandDisplayOption||(e.CommandDisplayOption={})),function(t){t[t.Grouping=0]="Grouping",t[t.Measure=1]="Measure",t[t.GroupingOrMeasure=2]="GroupingOrMeasure"}(e.VisualDataRoleKind||(e.VisualDataRoleKind={})),function(t){t[t.Measure=0]="Measure",t[t.Grouping=1]="Grouping"}(e.VisualDataRoleKindPreference||(e.VisualDataRoleKindPreference={})),e.validateVisualSelector=function(t){var r=e.Validators.visualSelectorValidator.validate(t);return r?r.map(_):void 0},e.validateSlicer=function(t){var r=e.Validators.slicerValidator.validate(t);return r?r.map(_):void 0},e.validateSlicerState=function(t){var r=e.Validators.slicerStateValidator.validate(t);return r?r.map(_):void 0},e.validatePlayBookmarkRequest=function(t){var r=e.Validators.playBookmarkRequestValidator.validate(t);return r?r.map(_):void 0},e.validateAddBookmarkRequest=function(t){var r=e.Validators.addBookmarkRequestValidator.validate(t);return r?r.map(_):void 0},e.validateApplyBookmarkByNameRequest=function(t){var r=e.Validators.applyBookmarkByNameRequestValidator.validate(t);return r?r.map(_):void 0},e.validateApplyBookmarkStateRequest=function(t){var r=e.Validators.applyBookmarkStateRequestValidator.validate(t);return r?r.map(_):void 0},e.validateSettings=function(t){var r=e.Validators.settingsValidator.validate(t);return r?r.map(_):void 0},e.validateCustomPageSize=function(t){var r=e.Validators.customPageSizeValidator.validate(t);return r?r.map(_):void 0},e.validateExtension=function(t){var r=e.Validators.extensionValidator.validate(t);return r?r.map(_):void 0},e.validateReportLoad=function(t){var r=e.Validators.reportLoadValidator.validate(t);return r?r.map(_):void 0},e.validateCreateReport=function(t){var r=e.Validators.reportCreateValidator.validate(t);return r?r.map(_):void 0},e.validateDashboardLoad=function(t){var r=e.Validators.dashboardLoadValidator.validate(t);return r?r.map(_):void 0},e.validateTileLoad=function(t){var r=e.Validators.tileLoadValidator.validate(t);return r?r.map(_):void 0},e.validatePage=function(t){var r=e.Validators.pageValidator.validate(t);return r?r.map(_):void 0},e.validateFilter=function(t){var r=e.Validators.filtersValidator.validate(t);return r?r.map(_):void 0},e.validateSaveAsParameters=function(t){var r=e.Validators.saveAsParametersValidator.validate(t);return r?r.map(_):void 0},e.validateLoadQnaConfiguration=function(t){var r=e.Validators.loadQnaValidator.validate(t);return r?r.map(_):void 0},e.validateQnaInterpretInputData=function(t){var r=e.Validators.qnaInterpretInputDataValidator.validate(t);return r?r.map(_):void 0},e.validateExportDataRequest=function(t){var r=e.Validators.exportDataRequestValidator.validate(t);return r?r.map(_):void 0},e.validateVisualHeader=function(t){var r=e.Validators.visualHeaderValidator.validate(t);return r?r.map(_):void 0},e.validateVisualSettings=function(t){var r=e.Validators.visualSettingsValidator.validate(t);return r?r.map(_):void 0},e.validateCommandsSettings=function(t){var r=e.Validators.commandsSettingsValidator.validate(t);return r?r.map(_):void 0},e.validateCustomTheme=function(t){var r=e.Validators.customThemeValidator.validate(t);return r?r.map(_):void 0}},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var a=r(2),i=r(3),o=r(5),n=r(6),l=r(7),d=r(8),s=r(9),u=r(10),p=r(11),c=r(12),f=r(13),v=r(14),h=r(15),V=r(16),y=r(17),m=r(18),g=r(19),w=r(20),b=r(21),_=r(22),O=r(23),S=r(24),T=r(25);e.Validators={addBookmarkRequestValidator:new n.AddBookmarkRequestValidator,advancedFilterTypeValidator:new a.EnumValidator([0]),advancedFilterValidator:new l.AdvancedFilterValidator,anyArrayValidator:new a.ArrayValidator([new s.AnyOfValidator([new a.StringValidator,new a.NumberValidator,new a.BooleanValidator])]),anyFilterValidator:new s.AnyOfValidator([new l.BasicFilterValidator,new l.AdvancedFilterValidator,new l.IncludeExcludeFilterValidator,new l.NotSupportedFilterValidator,new l.RelativeDateFilterValidator,new l.TopNFilterValidator]),anyValueValidator:new s.AnyOfValidator([new a.StringValidator,new a.NumberValidator,new a.BooleanValidator]),applyBookmarkByNameRequestValidator:new n.ApplyBookmarkByNameRequestValidator,applyBookmarkStateRequestValidator:new n.ApplyBookmarkStateRequestValidator,applyBookmarkValidator:new s.AnyOfValidator([new n.ApplyBookmarkByNameRequestValidator,new n.ApplyBookmarkStateRequestValidator]),backgroundValidator:new a.EnumValidator([0,1]),basicFilterTypeValidator:new a.EnumValidator([1]),basicFilterValidator:new l.BasicFilterValidator,booleanArrayValidator:new a.BooleanArrayValidator,booleanValidator:new a.BooleanValidator,commandDisplayOptionValidator:new a.EnumValidator([0,1,2]),commandExtensionSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),commandExtensionValidator:new i.CommandExtensionValidator,commandsSettingsArrayValidator:new a.ArrayValidator([new O.CommandsSettingsValidator]),commandsSettingsValidator:new O.CommandsSettingsValidator,conditionItemValidator:new l.ConditionItemValidator,contrastModeValidator:new a.EnumValidator([0,1,2,3,4]),customLayoutDisplayOptionValidator:new a.EnumValidator([0,1,2]),customLayoutValidator:new m.CustomLayoutValidator,customPageSizeValidator:new v.CustomPageSizeValidator,customThemeValidator:new S.CustomThemeValidator,dashboardLoadValidator:new c.DashboardLoadValidator,datasetBindingValidator:new T.DatasetBindingValidator,displayStateModeValidator:new a.EnumValidator([0,1]),displayStateValidator:new m.DisplayStateValidator,exportDataRequestValidator:new g.ExportDataRequestValidator,extensionArrayValidator:new a.ArrayValidator([new i.ExtensionValidator]),extensionPointsValidator:new i.ExtensionPointsValidator,extensionValidator:new i.ExtensionValidator,fieldRequiredValidator:new d.FieldRequiredValidator,filterColumnTargetValidator:new l.FilterColumnTargetValidator,filterConditionsValidator:new a.ArrayValidator([new l.ConditionItemValidator]),filterHierarchyTargetValidator:new l.FilterHierarchyTargetValidator,filterMeasureTargetValidator:new l.FilterMeasureTargetValidator,filterTargetValidator:new s.AnyOfValidator([new l.FilterColumnTargetValidator,new l.FilterHierarchyTargetValidator,new l.FilterMeasureTargetValidator]),filtersArrayValidator:new a.ArrayValidator([new s.AnyOfValidator([new l.BasicFilterValidator,new l.AdvancedFilterValidator,new l.RelativeDateFilterValidator])]),filtersValidator:new l.FilterValidator,hyperlinkClickBehaviorValidator:new a.EnumValidator([0,1,2]),includeExcludeFilterValidator:new l.IncludeExcludeFilterValidator,includeExludeFilterTypeValidator:new a.EnumValidator([3]),layoutTypeValidator:new a.EnumValidator([0,1,2,3]),loadQnaValidator:new h.LoadQnaValidator,menuExtensionValidator:new i.MenuExtensionValidator,menuLocationValidator:new a.EnumValidator([0,1]),notSupportedFilterTypeValidator:new a.EnumValidator([2]),notSupportedFilterValidator:new l.NotSupportedFilterValidator,numberArrayValidator:new a.NumberArrayValidator,numberValidator:new a.NumberValidator,pageLayoutValidator:new y.MapValidator([new a.StringValidator],[new m.VisualLayoutValidator]),pageSizeTypeValidator:new a.EnumValidator([0,1,2,3,4,5]),pageSizeValidator:new v.PageSizeValidator,pageValidator:new v.PageValidator,pageViewFieldValidator:new v.PageViewFieldValidator,pagesLayoutValidator:new y.MapValidator([new a.StringValidator],[new m.PageLayoutValidator]),permissionsValidator:new a.EnumValidator([0,1,2,4,7]),playBookmarkRequestValidator:new n.PlayBookmarkRequestValidator,qnaInterpretInputDataValidator:new h.QnaInterpretInputDataValidator,qnaSettingValidator:new h.QnaSettingsValidator,relativeDateFilterOperatorValidator:new a.EnumValidator([0,1,2]),relativeDateFilterTimeUnitTypeValidator:new a.EnumValidator([0,1,2,3,4,5,6]),relativeDateFilterTypeValidator:new a.EnumValidator([4]),relativeDateFilterValidator:new l.RelativeDateFilterValidator,reportCreateValidator:new p.ReportCreateValidator,reportLoadValidator:new u.ReportLoadValidator,saveAsParametersValidator:new V.SaveAsParametersValidator,settingsValidator:new o.SettingsValidator,singleCommandSettingsValidator:new O.SingleCommandSettingsValidator,slicerSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.SlicerTargetSelectorValidator]),slicerStateValidator:new b.SlicerStateValidator,slicerTargetValidator:new s.AnyOfValidator([new l.FilterColumnTargetValidator,new l.FilterHierarchyTargetValidator,new l.FilterMeasureTargetValidator,new l.FilterKeyColumnsTargetValidator,new l.FilterKeyHierarchyTargetValidator]),slicerValidator:new b.SlicerValidator,stringArrayValidator:new a.StringArrayValidator,stringValidator:new a.StringValidator,tileLoadValidator:new f.TileLoadValidator,tokenTypeValidator:new a.EnumValidator([0,1]),topNFilterTypeValidator:new a.EnumValidator([5]),topNFilterValidator:new l.TopNFilterValidator,viewModeValidator:new a.EnumValidator([0,1]),visualCommandSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),visualHeaderSelectorValidator:new s.AnyOfValidator([new w.VisualSelectorValidator,new w.VisualTypeSelectorValidator]),visualHeaderSettingsValidator:new _.VisualHeaderSettingsValidator,visualHeaderValidator:new _.VisualHeaderValidator,visualHeadersValidator:new a.ArrayValidator([new _.VisualHeaderValidator]),visualLayoutValidator:new m.VisualLayoutValidator,visualSelectorValidator:new w.VisualSelectorValidator,visualSettingsValidator:new _.VisualSettingsValidator,visualTypeSelectorValidator:new w.VisualTypeSelectorValidator}},function(t,e){var r,a=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function a(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)});Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(){}return t.prototype.validate=function(t,e,r){return null==t?null:"object"!=typeof t||Array.isArray(t)?[{message:void 0!==r?r+" must be an object":"input must be an object",path:e,keyword:"type"}]:null},t}();e.ObjectValidator=i;var o=function(){function t(t){this.itemValidators=t}return t.prototype.validate=function(t,e,r){if(null==t)return null;if(!Array.isArray(t))return[{message:r+" property is invalid",path:(e?e+".":"")+r,keyword:"type"}];for(var a=0;a & IEmbedConfiguration & ExtraSettings 22 | 23 | const PowerBIEmbedded: React.FC = (props: PowerBIEmbeddedProps) => { 24 | const { embedType } = props 25 | const component = useRef() 26 | const rootElement = useRef() 27 | const [ embedObj, setEmbedObj ] = useState() 28 | 29 | function validateConfig ( 30 | embedType: PowerBIEmbeddedProps['embedType'] = 'report', config: IEmbedConfiguration): boolean { 31 | const validateFuncs = { 32 | 'report': models.validateReportLoad, 33 | 'dashboard': models.validateDashboardLoad, 34 | 'tile': models.validateTileLoad 35 | } 36 | const errors = validateFuncs[embedType](config) 37 | 38 | console.error('PowerBI Embed Config Error, See Error Array -> ', errors) 39 | return errors === undefined 40 | } 41 | 42 | function getConfigFromProps (props: PowerBIEmbeddedProps, prev?: IEmbedConfiguration): IEmbedConfiguration { 43 | const { 44 | embedType, 45 | mobile, 46 | tokenType, 47 | permissions, 48 | filterPaneEnabled, 49 | navContentPaneEnabled, 50 | settings, 51 | ...rest 52 | } = props 53 | 54 | return { 55 | ...prev, 56 | ...rest, 57 | settings: { 58 | ...settings, 59 | filterPaneEnabled, 60 | navContentPaneEnabled, 61 | layoutType: mobile ? models.LayoutType.MobilePortrait : undefined 62 | }, 63 | permissions: permissions || Permissions.All, 64 | tokenType: tokenType || TokenType.Embed, 65 | type: embedType || 'report' 66 | } 67 | } 68 | 69 | useEffect(() => { 70 | return (): void => { 71 | const currentRootElement = rootElement.current as HTMLElement 72 | 73 | powerbi.reset(currentRootElement) 74 | component.current = null 75 | } 76 | }, [props.mobile]) 77 | 78 | useEffect(() => { 79 | console.log('tried to run') 80 | const config = getConfigFromProps(props) 81 | 82 | if (validateConfig(embedType, config)) { 83 | console.log('validated') 84 | const embed = powerbi.embed(rootElement.current as HTMLDivElement, config) 85 | 86 | setEmbedObj(embed) 87 | } 88 | return (): void => { 89 | const currentRootElement = rootElement.current as HTMLElement 90 | 91 | powerbi.reset(currentRootElement) 92 | component.current = null 93 | } 94 | }, []) 95 | 96 | useEffect(() => { 97 | if (!embedObj) { 98 | return 99 | } 100 | const config = getConfigFromProps(props) 101 | 102 | if (!validateConfig(embedType, config)) { 103 | return 104 | } 105 | powerbi.embed(rootElement.current as HTMLDivElement, config) 106 | }, [props]) 107 | 108 | return ( 109 |
{ rootElement.current = el }} 112 | > 113 |
114 | ) 115 | } 116 | 117 | PowerBIEmbedded.defaultProps = { 118 | embedType: 'report' 119 | } 120 | 121 | export default PowerBIEmbedded 122 | -------------------------------------------------------------------------------- /test/__snapshots__/library.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`accepts props 1`] = ` 4 |
13 | `; 14 | 15 | exports[`renders a component 1`] = ` 16 |
25 | `; 26 | -------------------------------------------------------------------------------- /test/library.spec.tsx: -------------------------------------------------------------------------------- 1 | /* global test */ 2 | 3 | import React from 'react' 4 | import { shallow } from 'enzyme' 5 | import PowerbiEmbedded from '../src/index' 6 | 7 | test('renders a component', () => { 8 | const embedded = shallow() 9 | 10 | expect(embedded).toMatchSnapshot() 11 | }) 12 | 13 | test('accepts props', () => { 14 | const embedded = shallow() 16 | 17 | expect(embedded).toMatchSnapshot() 18 | }) 19 | -------------------------------------------------------------------------------- /test/setupEnzyme.ts: -------------------------------------------------------------------------------- 1 | import { configure } from 'enzyme' 2 | import EnzymeAdapter from 'enzyme-adapter-react-16' 3 | 4 | configure({ adapter: new EnzymeAdapter()}) 5 | // eslint-disable-next-line @typescript-eslint/no-var-requires 6 | const crypto = require('crypto') 7 | 8 | Object.defineProperty(global, 'crypto', { 9 | writable: true, 10 | value: { 11 | getRandomValues: (arr: any) => crypto.randomBytes(arr.length) 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /tsconfig.jest.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "jsx": "react" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "jsx": "preserve", 6 | "noEmit": true, 7 | "strict": true, 8 | "allowJs": true, 9 | "baseUrl": "./src", 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "forceConsistentCasingInFileNames": true, 14 | "types": ["node", "jest"], 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "strictPropertyInitialization": false, 18 | "declaration": true, 19 | "outDir": "lib" 20 | }, 21 | "include": ["src"] 22 | } 23 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const webpack = require('webpack') 3 | const { CleanWebpackPlugin } = require('clean-webpack-plugin') 4 | const { TsConfigPathsPlugin } = require('awesome-typescript-loader') 5 | const env = require('yargs').argv.env // use --env with webpack 2 6 | 7 | const libraryName = 'react-powerbi' 8 | 9 | const plugins = 10 | [ 11 | new CleanWebpackPlugin() 12 | ] 13 | 14 | let rootName = libraryName 15 | 16 | if (env === 'build') { 17 | rootName += '.min' 18 | } 19 | const outputFile = rootName + '.js' 20 | 21 | const config = { 22 | entry: './src/index.tsx', 23 | devtool: 'source-map', 24 | context: __dirname, 25 | output: { 26 | path: path.resolve('./lib'), 27 | filename: outputFile, 28 | library: libraryName, 29 | libraryTarget: 'umd', 30 | umdNamedDefine: true 31 | }, 32 | module: { 33 | rules: [ 34 | { 35 | test: /\.(ts|js)x?$/, 36 | loader: 'babel-loader', 37 | exclude: /(node_modules|bower_components)/ 38 | }, 39 | { 40 | test: /(\.tsx|\.ts)$/, 41 | loader: 'awesome-typescript-loader', 42 | exclude: /node_modules/ 43 | } 44 | ] 45 | }, 46 | resolve: { 47 | modules: [path.resolve('./node_modules'), path.resolve('./src')], 48 | extensions: ['.json', '.js', '.ts', '.tsx'], 49 | plugins: [new TsConfigPathsPlugin({ 50 | tsconfig: __dirname + '/tsconfig.json' 51 | })] 52 | }, 53 | externals: { 54 | 'jsdom': 'window', 55 | 'react': 'react' 56 | }, 57 | plugins: plugins 58 | } 59 | 60 | module.exports = config 61 | --------------------------------------------------------------------------------