-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnebula-barchart-ext.js
1 lines (1 loc) · 8.84 KB
/
nebula-barchart-ext.js
1
define(["qlik","translator","./dist/nebula-barchart-ext","./nlib/@nebula.js/stardust/dist/stardust"],(function(e,t,i,n){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i;const s=1;function o(e,t){const i=[];return function(e){return!!e.tooltips||e.interactionState===s&&!1!==e.tooltips}(e)&&i.push("passive"),e.interactionState===s&&!1!==e.tooltips&&!0!==e.limitedInteraction&&i.push("interact"),t.isSnapshot||(!1!==e.selections&&i.push("select"),i.push("fetch")),i}var r={};function a(){a.init.call(this)}r.isObject=function(e){return"object"==typeof e&&null!==e},r.isNumber=function(e){return"number"==typeof e},r.isUndefined=function(e){return void 0===e},r.isFunction=function(e){return"function"==typeof e};var c=a;a.EventEmitter=a,a.prototype._events=void 0,a.prototype._maxListeners=void 0,a.defaultMaxListeners=10,a.init=function(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if(!r.isNumber(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},a.prototype.emit=function(e){var t,i,n,s,o,a;if(this._events||(this._events={}),"error"===e&&!this._events.error)throw(t=arguments[1])instanceof Error?t:Error('Uncaught, unspecified "error" event.');if(i=this._events[e],r.isUndefined(i))return!1;if(r.isFunction(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,s=new Array(n-1),o=1;o<n;o++)s[o-1]=arguments[o];i.apply(this,s)}else if(r.isObject(i)){for(n=arguments.length,s=new Array(n-1),o=1;o<n;o++)s[o-1]=arguments[o];for(n=(a=i.slice()).length,o=0;o<n;o++)a[o].apply(this,s)}return!0},a.prototype.addListener=function(e,t){var i;if(!r.isFunction(t))throw TypeError("listener must be a function");(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r.isFunction(t.listener)?t.listener:t),this._events[e]?r.isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,r.isObject(this._events[e])&&!this._events[e].warned)&&((i=r.isUndefined(this._maxListeners)?a.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,r.isFunction(console.error)&&console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),r.isFunction(console.trace)&&console.trace()));return this},a.prototype.on=a.prototype.addListener,a.prototype.once=function(e,t){if(!r.isFunction(t))throw TypeError("listener must be a function");var i=!1;function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},a.prototype.removeListener=function(e,t){var i,n,s,o;if(!r.isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(i=this._events[e]).length,n=-1,i===t||r.isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r.isObject(i)){for(o=s;o-- >0;)if(i[o]===t||i[o].listener&&i[o].listener===t){n=o;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},a.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],r.isFunction(i))this.removeListener(e,i);else if(Array.isArray(i))for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},a.prototype.listeners=function(e){return this._events&&this._events[e]?r.isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},a.listenerCount=function(e,t){return e._events&&e._events[t]?r.isFunction(e._events[t])?1:e._events[t].length:0};var l=e=>{const t={begin(){e.selectionsApi.activated(),e.backendApi.beginSelections(),t.emit("activated")},clear(){e.backendApi.model.resetMadeSelections()},confirm(){e.selectionsApi.confirm()},cancel(){e.selectionsApi.cancel()},select(t){e.selectionsApi.active||e.backendApi.beginSelections(),e.backendApi.model[t.method](...t.params).then(t=>{t||(e.selectionsApi.selectionsMade=!1,this.clear())}),e.selectionsApi.selectionsMade="resetMadeSelections"!==t.method},isActive:()=>e.selectionsApi.active,refreshToolbar(){e.selectionsApi.refreshToolbar()}};var i;return i=t,Object.keys(c.prototype).forEach(e=>{i[e]=c.prototype[e]}),c.init(i),e.selectionsApi.confirm=()=>{e.backendApi.endSelections(!0).then(()=>{e.selectionsApi.deactivated(),t.emit("deactivated")})},e.selectionsApi.clear=()=>{e.backendApi.clearSelections(),e.selectionsApi.selectionsMade=!1,t.emit("cleared")},e.selectionsApi.cancel=()=>{e.backendApi.endSelections(!1),e.selectionsApi.deactivated(),t.emit("canceled")},t};const{generator:h,theme:p,locale:d}=n.__DO_NOT_USE__,u=d({initial:t.language}),m={...u.translator,get(e,i){const n=t.get(e,i);return n===e?u.translator.get(e,i):n}},v=["viewState","direction","renderer"];function f(e,t){const i={};let n=!1;return Object.keys(e).forEach(s=>{-1!==v.indexOf(s)&&(i[s]=e[s],t[s]!==e[s]&&(n=!0))}),n?i:t}function b(t){return e.currApp(t).theme.getApplied().then(e=>{t.nTheme.externalAPI.name()!==e.id&&t.nTheme.internalAPI.setTheme(e.properties,e.id)})}const g=h(i,{translator:m,flags:{isEnabled:()=>!1},anything:{}}),_={}||{};let y;if(g.qae.data.targets[0]){const e=g.qae.data.targets[0],t=e=>({...e,add:e.added,remove:e.removed,replace:e.replaced,move:e.moved});y={},e.dimensions&&(y.dimensions=t(e.dimensions)),e.measures&&(y.measures=t(e.measures))}return{definition:{type:"items",component:"accordion",items:{data:y?{uses:"data"}:void 0,sorting:y?{uses:"sorting"}:void 0,settings:{uses:"settings"}}},data:y,getSelectionToolbar(){return[...this.senseItems,{name:"Tooltip.clearSelection",tid:"selection-toolbar.clear",isIcon:!0,buttonClass:"clear",iconClass:"lui-icon lui-icon--clear-selections",action:function(){this.selectionsApi.clear()},isDisabled:function(){return!this.selectionsApi.selectionsMade}}]},..._,initialProperties:g.qae.properties.initial,template:'<div style="height: 100%;position: relative"></div>',mounted(e){const t=e[0].children[0],i=l(this.$scope),n=g.create({model:this.backendApi.model,app:this.backendApi.model.session.app,selections:i,explicitResize:!0});this.sn=n,this.snComponent=n.component,this.snComponent.created(),this.snComponent.mounted(t),this.senseItems=[];const{senseItems:s}=this;this.snComponent.observeActions(e=>{s.length=0,s.push(...function(e){return e.map(e=>{const t={isIcon:!0,buttonClass:"sel-toolbar-icon-toggle",isActive:()=>e.active,isDisabled:()=>e.disabled,action(){e.action()},getSvgIcon(){const t=e.getSvgIconShape(),{viewBox:i="0 0 16 16"}=t;return`<i style="display:inline-block;font-style:normal;line-height:0;text-align:center;text-transform:none;vertical-align:-.2em;text-rendering:optimizeLegibility;web-kit-font-smoothing:antialiased;moz-osx-font-smoothing:grayscale"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="${i}" fill="currentColor">${t.shapes.map(({type:e,attrs:t})=>`<${e} ${Object.keys(t).map(e=>`${e}="${t[e]}"`).join(" ")}/>`).join("")}</svg></i>`}};return Object.defineProperties(t,{name:{get:()=>e.label},hidden:{get:()=>e.hidden}}),t})}(e)),this.$scope.selectionsApi.refreshToolbar()}),this.nTheme=p(),this.initiatedTheme=b(this)},suppressOnPaint:()=>!1,paint(){const e=o(this.options,this.backendApi),t={passive:-1===e.indexOf("passive")||void 0,active:-1===e.indexOf("interact")||void 0,select:-1===e.indexOf("select")||void 0},i=f(this.options,this.snComponent.context.options);return this._pureLayout=this.backendApi.model.pureLayout||this.backendApi.model.layout,this.initiatedTheme.then(()=>(b(this),this.snComponent.render({layout:this.backendApi.model.pureLayout||this.backendApi.model.layout,context:{appLayout:{qLocaleInfo:this.backendApi.localeInfo},constraints:t,theme:this.nTheme.externalAPI},options:i})))},resize(){if(this._pureLayout!==this.backendApi.model.pureLayout)return this.paint();const e=f(this.options,this.snComponent.context.options);return this.snComponent.context.options=e,this.snComponent.resize()},setInteractionState(){this.paint()},setSnapshotData(e){return this.snComponent.setSnapshotData(e)},getViewState(){const e=this.snComponent.getImperativeHandle();if(e&&"function"==typeof e.getViewState)return e.getViewState()},destroy(){this.sn.destroy(),this.snComponent&&(this.snComponent.willUnmount(),this.snComponent.destroy())}}}));