polymatica-widget-component-legacy 2.0.21 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polymatica-widget-component-legacy",
3
- "version": "2.0.21",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "polymatica-widget-component-legacy.js",
6
6
  "types": "types",
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolymaticaWidgetComponentLegacy=t():e.PolymaticaWidgetComponentLegacy=t()}(self,(()=>(()=>{var e={10:e=>{function t(e){return!e}e.exports=Object.defineProperties(t,{default:{value:t},not:{value:t},__esModule:{value:!0}})},279:e=>{var t;self,t=()=>(()=>{var e={10:e=>{function t(e){return!e}e.exports=Object.defineProperties(t,{default:{value:t},not:{value:t},__esModule:{value:!0}})},99:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.Output=t.Input=void 0,(o=t.Input||(t.Input={})).Change="poly.input.change",o.ChangeWidgetRenderEnv="poly.input.changeWidgetRenderEnv",o.ChangeLang="poly.input.changeLang",o.ChangeTheme="poly.input.changeTheme",o.Highlight="poly.input.highlight",o.UnHighlight="poly.input.unhighlight",(n=t.Output||(t.Output={})).Init="poly.output.init",n.Ready="poly.output.ready",n.Interact="poly.output.interact"},937:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ColumnType=void 0,(n=t.ColumnType||(t.ColumnType={})).String="string",n.Number="number",n.Date="date",n.Array="array",n.Object="object",n.Boolean="boolean"},204:function(e,t,n){"use strict";var o=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a<o.length;a++)t.indexOf(o[a])<0&&Object.prototype.propertyIsEnumerable.call(e,o[a])&&(n[o[a]]=e[o[a]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Declare=void 0;const a=n(10),r=n(99),i=new Map;function s(e,t){const{datasetId:n,columns:a,columnsByBlock:s}=e,c=o(e,["datasetId","columns","columnsByBlock"]),l=new Map,d=a.map((e=>{var{columnId:a}=e,i=o(e,["columnId"]);const s=Object.assign(Object.assign({},i),{interact(e){u(t,r.Output.Interact,{datasetId:n,columnId:a,dataIndex:e})}});return l.set(a,s),s})),p={};Object.entries(s).forEach((([e,t])=>{p[e]=[],t.forEach((t=>{const n=l.get(t);n&&p[e].push(n)}))}));const h=Object.assign(Object.assign({},c),{columns:d,columnsByBlock:p,events:{onHighlight(){}}});return i.set(n,h),h}function c(e,t,n){e[t]=n}function l(e,t){"function"==typeof e[t]&&e[t]()}function d(e,t){window.addEventListener("message",(({data:n})=>{n.type===e&&t(n.payload)}))}function u(e,t,n){const o={type:t,token:e,payload:n};window.parent.postMessage(o,"*")}t.Declare=function(){return e=>{const t=new e,n=function(e){const t="token=",n=window.location.search.split(/[?&]/).find((e=>e.startsWith(t)));return n?n.slice(t.length):""}();Object.assign(t,{options:{},ready(){u(n,r.Output.Ready)}});let o=!1;return d(r.Input.Change,(([e,r])=>{!function(e,t,n){if(i.clear(),"dataset"in t){const{dataset:o}=t;Object.assign(e,{dataset:s(o,n)})}else if(Array.isArray(t)){const{datasets:o}=t;Object.assign(e,{datasets:o.map((e=>s(e,n)))})}else{const o={};Object.entries(t).forEach((([e,t])=>{Array.isArray(t)?o[e]=t.map((e=>s(e,n))):o[e]=s(t,n)})),Object.assign(e,{datasets:o})}}(t,e,n),c(t,"options",r),(0,a.not)(o)&&(o=!0,l(t,"init")),l(t,"onChange")})),d(r.Input.ChangeWidgetRenderEnv,(e=>c(t,"renderEnv",e))),d(r.Input.ChangeLang,(e=>{c(t,"lang",e),o&&l(t,"onLangChange")})),d(r.Input.ChangeTheme,(e=>{c(t,"theme",e),o&&l(t,"onThemeChange")})),d(r.Input.Highlight,(({datasetId:e,rowIndexArray:t})=>{const n=i.get(e);null==n||n.events.onHighlight(t)})),u(n,r.Output.Init),e}}},974:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var a=Object.getOwnPropertyDescriptor(t,n);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,a)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(937),t),a(n(204),t),a(n(2),t),a(n(887),t),a(n(65),t)},2:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},887:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},65:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetRenderEnv=t.Widget=void 0,t.Widget=class{constructor(){this.renderEnv=n.Default}ready(){}init(){}onThemeChange(){}onLangChange(){}},function(e){e.Default="default",e.Print="print"}(n=t.WidgetRenderEnv||(t.WidgetRenderEnv={}))}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{EventType:()=>e,PolymaticaWidget:()=>d});var e,t=n(10),a=n(974),r=n(99);function i(e){for(const t of e){const e=t.target;switch(t.attributeName){case"render-env":e.renderEnv=e.getAttribute("render-env");break;case"widget-base-path":e.widgetBasePath=e.getAttribute("widget-base-path");break;case"locale":e.locale=e.getAttribute("locale")}}}!function(e){e.Ready="poly-ready",e.Interact="poly-interact"}(e||(e={}));const s=(e,t,n)=>{const o=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(o)};class c{constructor(e){this.widget=e,this.token=this.createToken(),this.isReady=!1,window.addEventListener("message",(({data:e})=>{e.token===this.token&&this.process(e)}))}get context(){return c.widgetContextMap.get(this.widget)}send(e,t){this.context.iframe.contentWindow?.postMessage({type:e,payload:t},"*")}process(t){switch(t.type){case r.Output.Init:{if(this.isReady)break;this.isReady=!0;const{context:e}=this;this.send(r.Input.ChangeWidgetRenderEnv,e.widgetRenderEnv||a.WidgetRenderEnv.Default),this.send(r.Input.ChangeTheme,e.theme),this.send(r.Input.ChangeLang,e.locale),this.send(r.Input.Change,[e.data,e.options]);break}case r.Output.Ready:s(this.widget,e.Ready,{});break;case r.Output.Interact:s(this.widget,e.Interact,t.payload)}}createToken(){return Math.random().toString(16).slice(2)}}const l=new WeakMap;c.widgetContextMap=l;class d extends HTMLElement{set renderEnv(e){e===a.WidgetRenderEnv.Print&&p(this,{widgetRenderEnv:e})}set widgetBasePath(e){p(this,{widgetBasePath:e})}set locale(e){p(this,{locale:e})}constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("iframe"),n=document.createElement("style");n.textContent="\n:host {\n display: block;\n}\n\niframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n",e.append(n);const o={iframe:t,inited:!1,shadowRoot:e,connector:new c(this)};l.set(this,o),new MutationObserver(i).observe(this,{attributes:!0})}provideData(e,t){p(this,{data:e,options:t})}provideTheme(e){p(this,{theme:e})}highlight(e,t){u(this).connector.send(r.Input.Highlight,{datasetId:e,rowIndexArray:t})}unhighlight(e){u(this).connector.send(r.Input.UnHighlight,{datasetId:e})}}function u(e){return l.get(e)}function p(e,n){const o=u(e);Object.assign(o,n);const{iframe:a,inited:i,data:s,options:c,locale:l,theme:d,widgetBasePath:p}=o;if(!(0,t.not)(s)&&!((0,t.not)(c)||(0,t.not)(l)||(0,t.not)(d)||(0,t.not)(p)))if((0,t.not)(i)){o.inited=!0;let e=p;(0,t.not)(e.endsWith("/"))&&(e+="/"),e+=`index.html?token=${o.connector.token}`,a.src=e,o.shadowRoot.append(a)}else{const{connector:e}=o;n.theme&&e.send(r.Input.ChangeTheme,d),n.locale&&e.send(r.Input.ChangeLang,l),(n.data||n.options)&&e.send(r.Input.Change,[o.data,o.options])}}customElements.define("polymatica-widget",d)})(),o})(),e.exports=t()},649:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDrilldownData=t.decodeDrilldownData=t.blockColorizeKey=t.blockSortKey=t.blockFilterKey=t.configDataBlock_Server=t.ConfigDataBlockType_Server=void 0,(n=t.ConfigDataBlockType_Server||(t.ConfigDataBlockType_Server={})).Column="column",n.Filter="filter",n.Sort="sort",n.Colorizer="colorizer",n.Drilldown="drilldown",t.configDataBlock_Server="8316067a-d04b-4b21-bd4d-35529846617b",t.blockFilterKey="34642664-dbd1-4e35-b0ea-2eaabe796b48",t.blockSortKey="2c849ed6-6105-4aa2-a961-9f95135dfe3b",t.blockColorizeKey="badd51f7-82ce-45b2-a67e-37d52df88c5c",t.decodeDrilldownData=function(e,t){const n=[o(e.length),e];return t.forEach((e=>n.push(o(e.length),e))),n.join("");function o(e){if(e>255)throw new RangeError;return e>15?`0x${e.toString(16)}`:`0x0${e.toString(16)}`}},t.encodeDrilldownData=function(e){const t=[];!function n(o=0){const a=o+4,r=a+parseInt(e.slice(o,a));t.push(e.slice(a,r)),r<e.length&&n(r)}();const[n,...o]=t;return{source:n,additionalFilterSources:o}}},661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DatasetColumnType_Server=t.ColumnFieldType_Server=void 0;var o,a=n(764);Object.defineProperty(t,"ColumnFieldType_Server",{enumerable:!0,get:function(){return a.ColumnType}}),(o=t.DatasetColumnType_Server||(t.DatasetColumnType_Server={})).Dimension="dimension",o.Fact="fact",o.Any="any"},539:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createColorizeColors=t.colorizeClassName=t.provideCssVariables=t.themeProjectKeys=t.themeKeys=void 0;const o=n(10);t.themeKeys=["background","backgroundBright","backgroundTint","text","textTint"],t.themeProjectKeys=["colors"];const a=document.querySelector("head"),r=document.querySelector("body"),i={};let s="",c="";function l(e,t){return`ptnl-colorize-${e}-${t}`}t.provideCssVariables=function({theme:e,themeKey:n,themeProjectKey:a}){const r=`ptnl-theme-${f(n)}`;if((0,o.not)(r in i)){const n=[];Object.entries(e).forEach((([e,o])=>{if(t.themeKeys.includes(e)){const t=f(e);Array.isArray(o)?o.forEach(((e,o)=>n.push({name:`--${t}-${o}`,value:e}))):n.push({name:`--${t}`,value:o})}})),h(r,[{className:r,cssProperties:n}])}s=g(s,r);const d=`ptnl-project-${a}`;if((0,o.not)(d in i)&&h(d,[{className:d,cssProperties:e.colors.map(((e,t)=>({name:`--ptnl-color-${t}`,value:e})))}]),c=g(c,d),(0,o.not)("colorize"in i)){const t=[];e.colorize.forEach(((e,n)=>{e.forEach(((e,o)=>t.push({className:l(n,o),cssProperties:[{name:"background-color",value:e}]})))})),h("colorize",t)}},t.colorizeClassName=l;const d=[...Array(10)].map(((e,t)=>t));t.createColorizeColors=function(e){return e.map((e=>{const[t,n,o]=function(e){const[,t,n,o]=e.match(u)||e.match(p)||[,"0","0","0"];return[parseInt(t,16),parseInt(n,16),parseInt(o,16)]}(e);return d.map((e=>`rgba(${t},${n},${o},${++e>9?"1":`0.${e}`})`))}))};const u=/([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})/i,p=/([0-9abcdef])([0-9abcdef])([0-9abcdef])/i;function h(e,t){const n=document.createElement("style");i[e]=n;const o=[];t.forEach((({className:e,cssProperties:t})=>{o.push(".",e,"{\n"),t.forEach((({name:e,value:t})=>o.push(" ",e,": ",t,";\n"))),o.push("}\n")})),n.innerHTML=o.join(""),a.append(n)}function g(e,t){return e&&r.classList.remove(e),r.classList.add(t),t}function f(e){const t=Array(e.length);for(let n=0,o=e.length;n<o;n++){const o=e.charAt(n),a=o.toLowerCase();t[n]=o===a?o:"-"+a}return t.join("")}},386:(e,t)=>{"use strict";var n;function o(e,t){switch(e){case n.Input:case n.Radio:case n.Select:case n.ColorPicker:case n.TextArea:return t?String(t):"";case n.Checkbox:return Boolean(t);default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.valueConversion=t.viewSettingsExtract=t.viewSettingsItemValue=t.ViewSettingsItemType=void 0,function(e){e.Input="text",e.Checkbox="checkbox",e.Radio="radio",e.Select="select",e.ColorPicker="color-picker",e.Title="title",e.TextArea="textArea"}(n=t.ViewSettingsItemType||(t.ViewSettingsItemType={})),t.viewSettingsItemValue="418d9556-a046-4623-be0b-4f4f69ccb783",t.viewSettingsExtract=function(e){return e.map((e=>e[t.viewSettingsItemValue])).map((e=>{return{type:e.type,key:e.key,label:e.label,defaultValue:o(e.type,e.defaultValue),options:e.options||[],span:(t=e.span,(t|=0)>24?24:t<0?0:t)};var t}))},t.valueConversion=o},897:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.Output=t.Input=void 0,(o=t.Input||(t.Input={})).Change="ptnl.input.change",o.ChangeLang="ptnl.input.changeLang",o.ChangeTheme="ptnl.input.changeTheme",o.ChangeOtherFilters="ptnl.input.ChangeOtherFilters",o.ChangeWidgetRenderEnv="ptnl.input.changeWidgetRenderEnv",(n=t.Output||(t.Output={})).Init="ptnl.output.init",n.Ready="ptnl.output.ready",n.SetFilter="ptnl.output.setFilter",n.RemoveFilterAt="ptnl.output.RemoveFilterAt",n.SetSort="ptnl.output.setSort",n.RemoveSortAt="ptnl.output.RemoveSortAt",n.Interact="ptnl.output.interact"},300:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.provideDataTo=void 0;const o=n(649),a=n(757),r={setFilter(){},removeFilterAt(){},setSort(){},removeSortAt(){},interact(){}};function i(e,t){const n=t===a.widgetDefaultKey?e.dataSettings:e.dataSettings[t];return n?{events:n.events}:{events:{}}}t.provideDataTo=function(e,{dataOptionsMap:t,viewOptions:n},s=r){const c={},l={},d=window.format||{};e.viewSettings={},Object.values(t).forEach((({data_option:t,rows:n,total:r})=>{c[t.key]=n;const u=t.dataset.columns_id.map((e=>({type:e.base_type,id:e.id,path:e.path,format:d[e.path]||(e=>String(e)),name:e.name}))),p={},h=[],g=[],f=[];t.blocks.forEach((t=>{if(t.block_type!==o.ConfigDataBlockType_Server.Drilldown)switch(t.key){case o.blockFilterKey:t.columns.forEach((({column_id:e,action:t,value:n})=>{const o=u.find((({id:t})=>e===t));h.push({column:o,method:t,value:n})}));break;case o.blockSortKey:t.columns.forEach((({column_id:e,value:t})=>{const n=u.find((({id:t})=>e===t));g.push({column:n,direction:t})}));break;case o.blockColorizeKey:t.columns.forEach((({value:t})=>{const n=t,o=u.find((({id:e})=>n.columnId===e));f.push((0,a.createColorizeItem)(e,o,n))}));break;default:p[t.key]=t.columns.map((({column_id:e})=>u.find((t=>t.id===e))))}}));const m={columns:u,columnsByBlock:p,filters:h,sort:g,colorize:f,total:r,limit:t.limit_rows,offset:t.offset,...{...s,interact:s.interact.bind(t)},...i(e,t.key)};l[t.key]=m})),a.widgetDefaultKey in l?Object.assign(e,{data:c[a.widgetDefaultKey],dataSettings:l[a.widgetDefaultKey]}):Object.assign(e,{data:c,dataSettings:l}),e.viewSettings={},n.forEach((({key:t,value:n})=>e.viewSettings[t]=n))}},757:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dispatchChangeOtherFilters=t.createColorizeItem=t.widgetDefaultKey=void 0;const o=n(764);function a(e){return e||"transparent"}t.widgetDefaultKey="ffed0a4d-4a9d-417f-b502-eb50142c6956",t.createColorizeItem=function(e,t,n){const o=+n.max||0,r=+n.min||0,i=+n.threshold||0,s=n.colorAbove,c=n.colorBelow,l=o-i,d=i-r;return{column:t,getColor(t){if((t=+t||0)>o||t<r)return a();if(t>=i){const n=e.theme.colorize[s]||[];return a(t===o?n[n.length-1]:n[Math.floor((t-i)/l*n.length)])}{const n=e.theme.colorize[c]||[];return a(t===r?n[n.length-1]:n[Math.floor((i-t)/d*n.length)])}}}},t.dispatchChangeOtherFilters=function(e,t){t.forEach((({column_id:t,value:n})=>{const a=function(e,t){if(Array.isArray(e.data))return e.dataSettings;for(let n of Object.values(e.dataSettings))if(n.columns.find((({id:e})=>e===t)))return n;return null}(e,t);if(a&&"function"==typeof a.events.onOtherFilterChange){const e=a.columns.find((({id:e})=>e===t));e&&a.events.onOtherFilterChange({column:e,method:o.FilterMethod.InList,value:n})}}))}},836:(e,t,n)=>{"use strict";t.wD=t.y8=t.JG=void 0;n(764),n(649),n(661),n(386);var o,a;(a=t.JG||(t.JG={})).Table="table",a.Aggregate="aggregate",(o=t.y8||(t.y8={})).Group="group",o.Sum="sum",o.Average="avg",o.Min="min",o.Max="max",o.First="first",o.Last="last",function(e){e.AxisX="sys:axis-x",e.AxisY="sys:axis-y",e.Value="sys:value-column"}(t.wD||(t.wD={}));Symbol()},764:(e,t)=>{"use strict";var n,o,a,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Target=t.SortDirection=t.FilterMethod=t.ColumnType=void 0,(r=t.ColumnType||(t.ColumnType={})).String="string",r.Number="number",r.Boolean="boolean",r.Date="date",r.Array="array",r.Object="object",(a=t.FilterMethod||(t.FilterMethod={})).Equal="equally",a.NotEqual="not_equal",a.GreaterThen="gt",a.LessThen="lt",a.GreaterThenOrEqual="gte",a.LessThenOrEqual="lte",a.Period="period",a.DateList="date_list",a.InList="in_list",a.NotInList="nin_list",a.StartsOnIndex="starts_on_i",a.StartsOn="starts_on",a.EndsOnIndex="ends_on_i",a.EndsOn="ends_on",a.ContainsIndex="contains_i",a.Contains="contains",a.NotContainIndex="not_contain_i",a.NotContain="not_contain",(o=t.SortDirection||(t.SortDirection={})).Asc="ASC",o.Desc="DESC",(n=t.Target||(t.Target={})).Self="self",n.Other="other",n.All="all"},362:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Declare=void 0;const o=n(10),a=n(764),r=n(897),i=n(300),s=n(539),c=n(757);function l(e,t){window.addEventListener("message",(({data:n})=>{n.type===e&&t(n.payload)}))}function d(e,t,n){const o={type:t,token:e,payload:n};window.parent.postMessage(o,"*")}t.Declare=function(e){return(0,o.not)(e)&&(e={provideCssVariables:!1}),t=>{const n=new t,u=function(e){const t="token=",n=window.location.search.split(/[?&]/).find((e=>e.startsWith(t)));return n?n.slice(t.length):""}();Object.assign(n,{viewSettings:{},ready(){d(u,r.Output.Ready)}});const p={setFilter(e,t=a.Target.Self){d(u,r.Output.SetFilter,{filter:e,target:t})},removeFilterAt(e){d(u,r.Output.RemoveFilterAt,{index:e})},setSort(e,t=a.Target.Self){d(u,r.Output.SetSort,{sort:e,target:t})},removeSortAt(e){d(u,r.Output.RemoveSortAt,{index:e})},interact(e){d(u,r.Output.Interact,{dataOptionId:this.id,dataIndex:e})}};let h=!1;return l(r.Input.Change,(e=>{(0,i.provideDataTo)(n,e,p),(0,o.not)(h)&&(h=!0,"function"==typeof n.onInit&&n.onInit()),"function"==typeof n.onChange&&n.onChange()})),l(r.Input.ChangeLang,(e=>{n.lang=e,n.onLangChange&&h&&n.onLangChange()})),l(r.Input.ChangeTheme,(t=>{n.theme=t.theme,e.provideCssVariables&&(0,s.provideCssVariables)(t),n.onThemeChange&&h&&n.onThemeChange()})),l(r.Input.ChangeOtherFilters,(e=>(0,c.dispatchChangeOtherFilters)(n,e))),l(r.Input.ChangeWidgetRenderEnv,(e=>{n.renderEnv=e})),d(u,r.Output.Init),t}}},391:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var a=Object.getOwnPropertyDescriptor(t,n);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,a)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(362),t),a(n(830),t)},830:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetRenderEnv=t.Widget=void 0,t.Widget=class{constructor(){this.renderEnv=n.Default}ready(){}onInit(){}onThemeChange(){}onLangChange(){}},function(e){e.Default="default",e.Print="print"}(n=t.WidgetRenderEnv||(t.WidgetRenderEnv={}))}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{PolymaticaWidgetLegacy:()=>g});var e=n(10),t=n(391),a=n(836),r=n(764),i=n(649),s=n(757),c=n(897);function l(e){for(const t of e){const e=t.target;switch(t.attributeName){case"render-env":e.renderEnv=e.getAttribute("render-env");break;case"widget-base-path":e.widgetBasePath=e.getAttribute("widget-base-path");break;case"locale":e.locale=e.getAttribute("locale")}}}var d=n(279);const u=(e,t,n)=>{const o=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(o)};class p{constructor(e){this.widget=e,this.token=this.createToken(),this.isReady=!1,window.addEventListener("message",(({data:e})=>{e.token===this.token&&this.process(e)}))}get context(){return p.widgetContextMap.get(this.widget)}send(e,t){this.context.iframe.contentWindow?.postMessage({type:e,payload:t},"*")}process(e){switch(e.type){case c.Output.Init:{if(this.isReady)break;this.isReady=!0;const{context:e}=this;this.send(c.Input.ChangeWidgetRenderEnv,e.widgetRenderEnv||t.WidgetRenderEnv.Default),this.send(c.Input.ChangeTheme,e.theme),this.send(c.Input.ChangeLang,e.locale),this.send(c.Input.Change,e.widgetRepresent);break}case c.Output.Ready:u(this.widget,d.EventType.Ready,{});break;case c.Output.SetFilter:{const{filter:t,target:n}=e.payload;if(n===r.Target.Other){const{data_option:e,rows:n}=this.context.widgetRepresent.dataOptionsMap[s.widgetDefaultKey],{column:{path:o,type:a},value:i}=t,c=a===r.ColumnType.Number?Number(i):i;this.context.otherFilterColumnId=t.column.id,u(this.widget,d.EventType.Interact,{datasetId:e.dataset.id,columnId:t.column.id,dataIndex:n.findIndex((e=>e[o]===c))})}break}}}createToken(){return Math.random().toString(16).slice(2)}}const h=new WeakMap;p.widgetContextMap=h;class g extends HTMLElement{set renderEnv(e){e===t.WidgetRenderEnv.Print&&m(this,{widgetRenderEnv:e})}set widgetBasePath(e){m(this,{widgetBasePath:e})}set locale(e){m(this,{locale:e})}constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("iframe"),n=document.createElement("style");n.textContent="\n:host {\n display: block;\n}\n\niframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n",e.append(n);const o={iframe:t,inited:!1,shadowRoot:e,connector:new p(this),otherFilterColumnId:0};h.set(this,o),function(e){new MutationObserver(l).observe(e,{attributes:!0})}(this)}initFormatterToWindow(e){const t={};e.columns.forEach((e=>{t[e.path]=e.format})),window.format=t}provideData(e,t){const{dataset:n}=e;this.initFormatterToWindow(n);const o=Object.entries(n.columnsByBlock).map((([e,t])=>({key:e,block_type:i.ConfigDataBlockType_Server.Column,function:a.y8.Group,columns:t.map((e=>({column_id:e})))}))),r=n.columns.map((e=>({id:e.columnId,name:e.name,path:e.path,base_type:e.type})));m(this,{widgetRepresent:{dataOptionsMap:{[s.widgetDefaultKey]:{data_option:{key:s.widgetDefaultKey,id:n.datasetId,dataset:{id:n.datasetId,name:"",columns_id:r},method:a.JG.Aggregate,limit_rows:-1,offset:0,blocks:o},rows:n.rows,total:n.rows.length}},viewOptions:Object.entries(t).map((([e,t])=>({key:e,value:t})))}})}provideTheme(e){m(this,{theme:{theme:{background:"rgb(241, 241, 242)",backgroundBright:"rgb(32, 33, 39)",backgroundTint:["rgb(230, 230, 234)","rgb(208, 208, 213)","rgb(163, 163, 172)","rgb(118, 118, 133)","rgb(64, 64, 83)","rgb(32, 33, 39)"],text:"rgb(0, 175, 215)",textTint:["#0d131e","#111827","#1f2937","#374151","#4b5563"],colors:e.palette,colorize:e.heatmap},themeKey:"polymatica",themeProjectKey:"polymatica"}})}highlight(e,t){const{connector:n,otherFilterColumnId:o,widgetRepresent:a}=f(this),i=[],l=a?.dataOptionsMap[s.widgetDefaultKey];if(l){const e=l.data_option.dataset.columns_id.find((({id:e})=>e===o));e&&t.forEach((t=>{t in l.rows&&i.push(l.rows[t][e.path])}))}n.send(c.Input.ChangeOtherFilters,[{column_id:o,value:i,action:r.FilterMethod.InList}])}unhighlight(e){const{connector:t,otherFilterColumnId:n}=f(this);t.send(c.Input.ChangeOtherFilters,[{column_id:n,value:[],action:r.FilterMethod.InList}])}}function f(e){return h.get(e)}function m(t,n){const o=f(t);Object.assign(o,n);const{iframe:a,inited:r,widgetRepresent:i,locale:s,theme:l,widgetBasePath:d}=o;if(!((0,e.not)(i)||(0,e.not)(s)||(0,e.not)(l)||(0,e.not)(d)))if((0,e.not)(r)){o.inited=!0;let t=d;(0,e.not)(t.endsWith("/"))&&(t+="/"),t+=`index.html?token=${o.connector.token}`,a.src=t,o.shadowRoot.append(a)}else{const{connector:e}=o;n.theme&&e.send(c.Input.ChangeTheme,l),n.locale&&e.send(c.Input.ChangeLang,s),n.widgetRepresent&&e.send(c.Input.Change,i)}}customElements.define("polymatica-widget-legacy",g)})(),o})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolymaticaWidgetComponentLegacy=t():e.PolymaticaWidgetComponentLegacy=t()}(self,(()=>(()=>{var e={10:e=>{function t(e){return!e}e.exports=Object.defineProperties(t,{default:{value:t},not:{value:t},__esModule:{value:!0}})},279:e=>{var t;self,t=()=>(()=>{var e={10:e=>{function t(e){return!e}e.exports=Object.defineProperties(t,{default:{value:t},not:{value:t},__esModule:{value:!0}})},107:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.JsxElementType=void 0,(n=t.JsxElementType||(t.JsxElementType={})).Component="component",n.Primitive="primitive"},517:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.listeners=t.elementBindings=void 0,t.elementBindings="⇠ element bindings",t.listeners="⇠ listeners"},292:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var a=Object.getOwnPropertyDescriptor(t,n);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,a)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(671),t)},671:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer=void 0;const o=n(10),a=n(107),r=n(517);var i;function s(e,t){switch(e.type){case a.JsxElementType.Component:return c(e,t);case a.JsxElementType.Primitive:return e.value}}function c(e,t){const{tagName:n}=e;if((0,o.not)(n))return d(e.children,t);switch(n){case"link":if(t.target!==i.Head)return"";l(e.attributes,"href",t.baseUrl);case"script":if(t.target!==i.Head)return"";l(e.attributes,"src",t.baseUrl)}const a=(r=e.attributes,Object.entries(r).map((([e,t])=>"data"===e?function(e){return Object.entries(e).map((([e,t])=>`data-${e}="${t}"`)).join(" ")}(t):("style"===e&&t instanceof Object&&(t=function(e){const t=Object.entries(e).map((([e,t])=>`${function(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}(e)}: ${t};`));return t.join("")}(t)),`${e}="${t}"`))).join(""));var r;return"input"===n?`<${n} ${a} />`:`<${n} ${a}>${d(e.children,t)}</${n}>`}function l(e,t,n){if(!(0,o.not)(t in e))try{const o=new URL(e[t],n);e[t]=o.toString()}catch(n){delete e[t]}}function d(e,t){return e.map((e=>{switch(e.type){case a.JsxElementType.Component:return c(e,t);case a.JsxElementType.Primitive:return e.value}})).join("")}t.Renderer=class{#e;#t;#n;constructor(e,t,n){e.innerHTML='<div style="display: contents;"></div>',this.#e=e.querySelector("div"),this.#t=t,this.#n=n,this.#o(t)}renderHead(e){const t=s(e,{target:i.Head,baseUrl:this.#n});this.#e.insertAdjacentHTML("beforebegin",t)}render(e){this.#e.innerHTML=s(e,{target:i.Body,baseUrl:this.#n}),this.#a()}#o(e){const t=e.constructor?.[r.listeners];if(Array.isArray(t)){const n=this.#e;t.forEach((({eventName:t,selector:a,callbackName:r})=>{const i=e[r];"function"==typeof i&&n.addEventListener(t,(t=>{if((0,o.not)(a)&&i.call(e,t),(0,o.not)(t.target))return;let r=t.target;for(;r&&r!==n;){if(r instanceof HTMLElement&&r.matches(a)){i.call(e,r,t);break}if(!r.parentElement)break;r=r.parentElement}}))}))}}#a(){const e=this.#t,t=e.constructor?.[r.elementBindings];if(Array.isArray(t)){const n=this.#e;t.forEach((({propertyName:t,selector:o,multi:a})=>{e[t]=a?n.querySelectorAll(o):n.querySelector(o)||void 0}))}}},function(e){e[e.Head=0]="Head",e[e.Body=1]="Body"}(i||(i={}))}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";var e;function t(e){for(const t of e){const e=t.target,{attributeName:n}=t;switch(n){case"render-env":e.renderEnv=a(e,"render-env");break;case"widget-base-path":e.widgetBasePath=a(e,"widget-base-path");break;case"locale":e.locale=a(e,"locale")}}}function a(e,t){return e.getAttribute(t)||""}n.r(o),n.d(o,{EventType:()=>e,PolymaticaWidget:()=>O}),function(e){e.ConfigProvided="plmt-config-provided",e.Ready="plmt-ready",e.Interact="plmt-interact"}(e||(e={}));class r{constructor(e){this.component=e}dispatch(e,t){const n=new CustomEvent(e,{detail:t,bubbles:!0});this.component.dispatchEvent(n)}}var i=n(10);class s{constructor(e,t){this.shadowRoot=e,this.events=t,this.widgetBasePath=""}load(e){if((0,i.not)(e))return;if(e===this.widgetBasePath)return;this.widgetBasePath=e;const t=function(e){const t=`id${c()}${c()}${c()}${c()}`,n=window;return n[t]=o=>{delete n[t],e(o)},t}((e=>{var t;t=e,(0,i.not)(t)||"function"!=typeof t.Widget||"object"!=typeof t.config||this.events.onLoad({entity:e,widgetBasePath:this.widgetBasePath})})),n=`\n import * as data from "${this.widgetBasePath}/index.js";\n\n ${t}(data);\n `;!function(e,t){const n=document.createElement("script");n.type="module",n.textContent=t,function(e,t){const{firstChild:n}=e;n?e.insertBefore(t,n):e.appendChild(t)}(e,n)}(this.shadowRoot,n)}}function c(){return Math.random().toString(16).slice(2)}var l=n(292);class d{constructor(){this.cache=Object.create(null)}load(e,t){const n=`${e}/assets/i18n/${t}.json`;return this.cache[n]?Promise.resolve(this.cache[n]):fetch(n).then((e=>e.json())).then((e=>(this.cache[n]=e,e)))}}class u{constructor(e){this.events=e,this.datasetsById=new Map}apply(e,t){var n;t.dataset?e.dataset=this.createWidgetDataset(t.dataset):h(t)?e.datasets=t.datasets.map((e=>this.createWidgetDataset(e))):(n=t).datasets&&(0,i.not)(h(n))&&(e.datasets={},Object.entries(t.datasets).forEach((([t,n])=>{const o=Array.isArray(n)?n.map((e=>this.createWidgetDataset(e))):this.createWidgetDataset(n);e.datasets[t]=o}))),t.options&&(e.options=t.options)}getDatasetById(e){return this.datasetsById.get(e)}reset(){this.datasetsById.clear()}createWidgetDataset(e){const{events:t}=this,{datasetId:n,name:o,rows:a}=e,r={},i=e.columns.map((e=>{const o=e.id,a={...p(e,"id"),interact(e){t.onInteract({datasetId:n,columnId:o,rowIndex:e})}};return r[o]=a,a})),s={};Object.entries(e.columnsByBlock).forEach((([e,t])=>{s[e]=[],t.forEach((t=>{const n=r[t];n&&s[e].push(n)}))}));const c={name:o,columns:i,columnsByBlock:s,rows:a,heatmap:{},events:{onHighlight(){}}};return this.datasetsById.set(n,c),c}}function h(e){return Array.isArray(e.datasets)}function p(e,t){const n={};return Object.entries(e).forEach((([e,o])=>{e!==t&&(n[e]=o)})),n}var f=function(e,t,n,o){var a,r=arguments.length,i=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(r<3?a(i):r>3?a(t,n,i):a(t,n))||i);return r>3&&i&&Object.defineProperty(t,n,i),i};class g{set renderEnv(e){}set theme(e){this.instance.theme=e,this.instance.onThemeChange()}set locale(e){this.loadTranslations(e)}set state(e){this.clearState(),this.stateManager.apply(this.instance,e),this.instance.onChange()}constructor(e,t){this.shadowRoot=e,this.events=t,this.context={translations:{loading:!1,first:!0}},this.stateManager=new u({onInteract:this.events.onInteract}),this.asyncCallbackMap={state:!1,theme:!1},this.translationsLoader=new d}provideWidgetEntity(e,t){this.context.entity=e,this.context.widgetBasePath=t,this.instantiate()}highlight(e,t){this.stateManager.getDatasetById(e)?.events.onHighlight(t)}async instantiate(){const{entity:e,renderEnv:t,theme:n,locale:o,state:a,widgetBasePath:r}=this.context;if((0,i.not)(e))return;if((0,i.not)(t))return;if((0,i.not)(n))return;if((0,i.not)(o))return;const s=new e.Widget;this.disposePrevious(),this.instance=s,s.renderEnv=t,s.theme=n,s.ready=()=>{this.events.onReady()};const c=new l.Renderer(this.shadowRoot,s,r),d=s.renderHead();d&&c.renderHead(d);const u=s.render;s.render=()=>{const e=u.call(s);return c.render(e),e},s.init(),e.config.useTranslations&&this.loadTranslations(o),a&&(this.state=a)}async loadTranslations(e){const{widgetBasePath:t}=this.context;if((0,i.not)(t))return;const{instance:n}=this;this.context.translations.loading=!0;const o=await this.translationsLoader.load(t,e);this.context.locale===e&&this.instance===n&&(this.instance&&(this.instance.translate=(e,t)=>{const n=o[e];return"string"!=typeof n?"":(0,i.not)(t)?n:n.replace(/\{\{(.+?)\}\}/g,((e,n)=>0===t[n]?"0":t[n]||""))}),this.context.translations.loading=!1,(0,i.not)(this.context.translations.first)&&this.instance?.onLangChange(),this.context.translations.first=!1,this.runAsyncCallback())}runAsyncCallback(){if((0,i.not)(this.instance))return;const{state:e,theme:t}=this.asyncCallbackMap;this.clearAsyncCallbackMap(),t&&this.context.theme&&(this.theme=this.context.theme),e&&this.context.state&&(this.state=this.context.state)}disposePrevious(){this.instance&&this.delete("render"),this.context.entity=void 0,this.context.state=void 0,this.context.translations={loading:!1,first:!0},this.clearAsyncCallbackMap()}delete(e){delete this.instance[e]}clearState(){const e=this.instance;delete e.dataset,delete e.datasets,delete e.options}clearAsyncCallbackMap(){this.asyncCallbackMap.state=!1,this.asyncCallbackMap.theme=!1}}function m(){return(e,t)=>{const{set:n}=Object.getOwnPropertyDescriptor(e,t),o=t;return{set(e){if(this.context[o]=e,this.context.translations.loading)switch(o){case"state":return void(this.asyncCallbackMap.state=!0);case"theme":return void(this.asyncCallbackMap.theme=!0)}(0,i.not)(this.instance)?this.instantiate():n.call(this,e)}}}}f([m()],g.prototype,"renderEnv",null),f([m()],g.prototype,"theme",null),f([m()],g.prototype,"locale",null),f([m()],g.prototype,"state",null);var y,v,b,w,C=function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)};class O extends HTMLElement{set renderEnv(e){C(this,b,"f").renderEnv=e}set widgetBasePath(e){C(this,w,"f").load(e)}set locale(e){C(this,b,"f").locale=e}constructor(){super(),y.set(this,this.attachShadow({mode:"open"})),v.set(this,new r(this)),b.set(this,new g(C(this,y,"f"),{onReady:()=>{C(this,v,"f").dispatch(e.Ready,null)},onInteract:t=>{C(this,v,"f").dispatch(e.Interact,t)}})),w.set(this,new s(C(this,y,"f"),{onLoad:({entity:t,widgetBasePath:n})=>{C(this,b,"f").provideWidgetEntity(t,n),C(this,v,"f").dispatch(e.ConfigProvided,t.config)}})),new MutationObserver(t).observe(this,{attributes:!0})}provide(e,t){(e||t)&&(C(this,b,"f").state={...e,options:t})}provideTheme(e){C(this,b,"f").theme=e}highlight(e,t){}}y=new WeakMap,v=new WeakMap,b=new WeakMap,w=new WeakMap,customElements.define("polymatica-widget",O)})(),o})(),e.exports=t()},649:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDrilldownData=t.decodeDrilldownData=t.blockColorizeKey=t.blockSortKey=t.blockFilterKey=t.configDataBlock_Server=t.ConfigDataBlockType_Server=void 0,(n=t.ConfigDataBlockType_Server||(t.ConfigDataBlockType_Server={})).Column="column",n.Filter="filter",n.Sort="sort",n.Colorizer="colorizer",n.Drilldown="drilldown",t.configDataBlock_Server="8316067a-d04b-4b21-bd4d-35529846617b",t.blockFilterKey="34642664-dbd1-4e35-b0ea-2eaabe796b48",t.blockSortKey="2c849ed6-6105-4aa2-a961-9f95135dfe3b",t.blockColorizeKey="badd51f7-82ce-45b2-a67e-37d52df88c5c",t.decodeDrilldownData=function(e,t){const n=[o(e.length),e];return t.forEach((e=>n.push(o(e.length),e))),n.join("");function o(e){if(e>255)throw new RangeError;return e>15?`0x${e.toString(16)}`:`0x0${e.toString(16)}`}},t.encodeDrilldownData=function(e){const t=[];!function n(o=0){const a=o+4,r=a+parseInt(e.slice(o,a));t.push(e.slice(a,r)),r<e.length&&n(r)}();const[n,...o]=t;return{source:n,additionalFilterSources:o}}},661:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DatasetColumnType_Server=t.ColumnFieldType_Server=void 0;var o,a=n(764);Object.defineProperty(t,"ColumnFieldType_Server",{enumerable:!0,get:function(){return a.ColumnType}}),(o=t.DatasetColumnType_Server||(t.DatasetColumnType_Server={})).Dimension="dimension",o.Fact="fact",o.Any="any"},539:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createColorizeColors=t.colorizeClassName=t.provideCssVariables=t.themeProjectKeys=t.themeKeys=void 0;const o=n(10);t.themeKeys=["background","backgroundBright","backgroundTint","text","textTint"],t.themeProjectKeys=["colors"];const a=document.querySelector("head"),r=document.querySelector("body"),i={};let s="",c="";function l(e,t){return`ptnl-colorize-${e}-${t}`}t.provideCssVariables=function({theme:e,themeKey:n,themeProjectKey:a}){const r=`ptnl-theme-${g(n)}`;if((0,o.not)(r in i)){const n=[];Object.entries(e).forEach((([e,o])=>{if(t.themeKeys.includes(e)){const t=g(e);Array.isArray(o)?o.forEach(((e,o)=>n.push({name:`--${t}-${o}`,value:e}))):n.push({name:`--${t}`,value:o})}})),p(r,[{className:r,cssProperties:n}])}s=f(s,r);const d=`ptnl-project-${a}`;if((0,o.not)(d in i)&&p(d,[{className:d,cssProperties:e.colors.map(((e,t)=>({name:`--ptnl-color-${t}`,value:e})))}]),c=f(c,d),(0,o.not)("colorize"in i)){const t=[];e.colorize.forEach(((e,n)=>{e.forEach(((e,o)=>t.push({className:l(n,o),cssProperties:[{name:"background-color",value:e}]})))})),p("colorize",t)}},t.colorizeClassName=l;const d=[...Array(10)].map(((e,t)=>t));t.createColorizeColors=function(e){return e.map((e=>{const[t,n,o]=function(e){const[,t,n,o]=e.match(u)||e.match(h)||[,"0","0","0"];return[parseInt(t,16),parseInt(n,16),parseInt(o,16)]}(e);return d.map((e=>`rgba(${t},${n},${o},${++e>9?"1":`0.${e}`})`))}))};const u=/([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})/i,h=/([0-9abcdef])([0-9abcdef])([0-9abcdef])/i;function p(e,t){const n=document.createElement("style");i[e]=n;const o=[];t.forEach((({className:e,cssProperties:t})=>{o.push(".",e,"{\n"),t.forEach((({name:e,value:t})=>o.push(" ",e,": ",t,";\n"))),o.push("}\n")})),n.innerHTML=o.join(""),a.append(n)}function f(e,t){return e&&r.classList.remove(e),r.classList.add(t),t}function g(e){const t=Array(e.length);for(let n=0,o=e.length;n<o;n++){const o=e.charAt(n),a=o.toLowerCase();t[n]=o===a?o:"-"+a}return t.join("")}},386:(e,t)=>{"use strict";var n;function o(e,t){switch(e){case n.Input:case n.Radio:case n.Select:case n.ColorPicker:case n.TextArea:return t?String(t):"";case n.Checkbox:return Boolean(t);default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.valueConversion=t.viewSettingsExtract=t.viewSettingsItemValue=t.ViewSettingsItemType=void 0,function(e){e.Input="text",e.Checkbox="checkbox",e.Radio="radio",e.Select="select",e.ColorPicker="color-picker",e.Title="title",e.TextArea="textArea"}(n=t.ViewSettingsItemType||(t.ViewSettingsItemType={})),t.viewSettingsItemValue="418d9556-a046-4623-be0b-4f4f69ccb783",t.viewSettingsExtract=function(e){return e.map((e=>e[t.viewSettingsItemValue])).map((e=>{return{type:e.type,key:e.key,label:e.label,defaultValue:o(e.type,e.defaultValue),options:e.options||[],span:(t=e.span,(t|=0)>24?24:t<0?0:t)};var t}))},t.valueConversion=o},897:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.Output=t.Input=void 0,(o=t.Input||(t.Input={})).Change="ptnl.input.change",o.ChangeLang="ptnl.input.changeLang",o.ChangeTheme="ptnl.input.changeTheme",o.ChangeOtherFilters="ptnl.input.ChangeOtherFilters",o.ChangeWidgetRenderEnv="ptnl.input.changeWidgetRenderEnv",(n=t.Output||(t.Output={})).Init="ptnl.output.init",n.Ready="ptnl.output.ready",n.SetFilter="ptnl.output.setFilter",n.RemoveFilterAt="ptnl.output.RemoveFilterAt",n.SetSort="ptnl.output.setSort",n.RemoveSortAt="ptnl.output.RemoveSortAt",n.Interact="ptnl.output.interact"},300:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.provideDataTo=void 0;const o=n(649),a=n(757),r={setFilter(){},removeFilterAt(){},setSort(){},removeSortAt(){},interact(){}};function i(e,t){const n=t===a.widgetDefaultKey?e.dataSettings:e.dataSettings[t];return n?{events:n.events}:{events:{}}}t.provideDataTo=function(e,{dataOptionsMap:t,viewOptions:n},s=r){const c={},l={},d=window.format||{};e.viewSettings={},Object.values(t).forEach((({data_option:t,rows:n,total:r})=>{c[t.key]=n;const u=t.dataset.columns_id.map((e=>({type:e.base_type,id:e.id,path:e.path,format:d[e.path]||(e=>String(e)),name:e.name}))),h={},p=[],f=[],g=[];t.blocks.forEach((t=>{if(t.block_type!==o.ConfigDataBlockType_Server.Drilldown)switch(t.key){case o.blockFilterKey:t.columns.forEach((({column_id:e,action:t,value:n})=>{const o=u.find((({id:t})=>e===t));p.push({column:o,method:t,value:n})}));break;case o.blockSortKey:t.columns.forEach((({column_id:e,value:t})=>{const n=u.find((({id:t})=>e===t));f.push({column:n,direction:t})}));break;case o.blockColorizeKey:t.columns.forEach((({value:t})=>{const n=t,o=u.find((({id:e})=>n.columnId===e));g.push((0,a.createColorizeItem)(e,o,n))}));break;default:h[t.key]=t.columns.map((({column_id:e})=>u.find((t=>t.id===e))))}}));const m={columns:u,columnsByBlock:h,filters:p,sort:f,colorize:g,total:r,limit:t.limit_rows,offset:t.offset,...{...s,interact:s.interact.bind(t)},...i(e,t.key)};l[t.key]=m})),a.widgetDefaultKey in l?Object.assign(e,{data:c[a.widgetDefaultKey],dataSettings:l[a.widgetDefaultKey]}):Object.assign(e,{data:c,dataSettings:l}),e.viewSettings={},n.forEach((({key:t,value:n})=>e.viewSettings[t]=n))}},757:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dispatchChangeOtherFilters=t.createColorizeItem=t.widgetDefaultKey=void 0;const o=n(764);function a(e){return e||"transparent"}t.widgetDefaultKey="ffed0a4d-4a9d-417f-b502-eb50142c6956",t.createColorizeItem=function(e,t,n){const o=+n.max||0,r=+n.min||0,i=+n.threshold||0,s=n.colorAbove,c=n.colorBelow,l=o-i,d=i-r;return{column:t,getColor(t){if((t=+t||0)>o||t<r)return a();if(t>=i){const n=e.theme.colorize[s]||[];return a(t===o?n[n.length-1]:n[Math.floor((t-i)/l*n.length)])}{const n=e.theme.colorize[c]||[];return a(t===r?n[n.length-1]:n[Math.floor((i-t)/d*n.length)])}}}},t.dispatchChangeOtherFilters=function(e,t){t.forEach((({column_id:t,value:n})=>{const a=function(e,t){if(Array.isArray(e.data))return e.dataSettings;for(let n of Object.values(e.dataSettings))if(n.columns.find((({id:e})=>e===t)))return n;return null}(e,t);if(a&&"function"==typeof a.events.onOtherFilterChange){const e=a.columns.find((({id:e})=>e===t));e&&a.events.onOtherFilterChange({column:e,method:o.FilterMethod.InList,value:n})}}))}},836:(e,t,n)=>{"use strict";t.wD=t.y8=t.JG=void 0;n(764),n(649),n(661),n(386);var o,a;(a=t.JG||(t.JG={})).Table="table",a.Aggregate="aggregate",(o=t.y8||(t.y8={})).Group="group",o.Sum="sum",o.Average="avg",o.Min="min",o.Max="max",o.First="first",o.Last="last",function(e){e.AxisX="sys:axis-x",e.AxisY="sys:axis-y",e.Value="sys:value-column"}(t.wD||(t.wD={}));Symbol()},764:(e,t)=>{"use strict";var n,o,a,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Target=t.SortDirection=t.FilterMethod=t.ColumnType=void 0,(r=t.ColumnType||(t.ColumnType={})).String="string",r.Number="number",r.Boolean="boolean",r.Date="date",r.Array="array",r.Object="object",(a=t.FilterMethod||(t.FilterMethod={})).Equal="equally",a.NotEqual="not_equal",a.GreaterThen="gt",a.LessThen="lt",a.GreaterThenOrEqual="gte",a.LessThenOrEqual="lte",a.Period="period",a.DateList="date_list",a.InList="in_list",a.NotInList="nin_list",a.StartsOnIndex="starts_on_i",a.StartsOn="starts_on",a.EndsOnIndex="ends_on_i",a.EndsOn="ends_on",a.ContainsIndex="contains_i",a.Contains="contains",a.NotContainIndex="not_contain_i",a.NotContain="not_contain",(o=t.SortDirection||(t.SortDirection={})).Asc="ASC",o.Desc="DESC",(n=t.Target||(t.Target={})).Self="self",n.Other="other",n.All="all"},362:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Declare=void 0;const o=n(10),a=n(764),r=n(897),i=n(300),s=n(539),c=n(757);function l(e,t){window.addEventListener("message",(({data:n})=>{n.type===e&&t(n.payload)}))}function d(e,t,n){const o={type:t,token:e,payload:n};window.parent.postMessage(o,"*")}t.Declare=function(e){return(0,o.not)(e)&&(e={provideCssVariables:!1}),t=>{const n=new t,u=function(e){const t="token=",n=window.location.search.split(/[?&]/).find((e=>e.startsWith(t)));return n?n.slice(t.length):""}();Object.assign(n,{viewSettings:{},ready(){d(u,r.Output.Ready)}});const h={setFilter(e,t=a.Target.Self){d(u,r.Output.SetFilter,{filter:e,target:t})},removeFilterAt(e){d(u,r.Output.RemoveFilterAt,{index:e})},setSort(e,t=a.Target.Self){d(u,r.Output.SetSort,{sort:e,target:t})},removeSortAt(e){d(u,r.Output.RemoveSortAt,{index:e})},interact(e){d(u,r.Output.Interact,{dataOptionId:this.id,dataIndex:e})}};let p=!1;return l(r.Input.Change,(e=>{(0,i.provideDataTo)(n,e,h),(0,o.not)(p)&&(p=!0,"function"==typeof n.onInit&&n.onInit()),"function"==typeof n.onChange&&n.onChange()})),l(r.Input.ChangeLang,(e=>{n.lang=e,n.onLangChange&&p&&n.onLangChange()})),l(r.Input.ChangeTheme,(t=>{n.theme=t.theme,e.provideCssVariables&&(0,s.provideCssVariables)(t),n.onThemeChange&&p&&n.onThemeChange()})),l(r.Input.ChangeOtherFilters,(e=>(0,c.dispatchChangeOtherFilters)(n,e))),l(r.Input.ChangeWidgetRenderEnv,(e=>{n.renderEnv=e})),d(u,r.Output.Init),t}}},391:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var a=Object.getOwnPropertyDescriptor(t,n);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,a)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(362),t),a(n(830),t)},830:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetRenderEnv=t.Widget=void 0,t.Widget=class{constructor(){this.renderEnv=n.Default}ready(){}onInit(){}onThemeChange(){}onLangChange(){}},function(e){e.Default="default",e.Print="print"}(n=t.WidgetRenderEnv||(t.WidgetRenderEnv={}))}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{PolymaticaWidgetLegacy:()=>f});var e=n(10),t=n(391),a=n(836),r=n(764),i=n(649),s=n(757),c=n(897);function l(e){for(const t of e){const e=t.target;switch(t.attributeName){case"render-env":e.renderEnv=e.getAttribute("render-env");break;case"widget-base-path":e.widgetBasePath=e.getAttribute("widget-base-path");break;case"locale":e.locale=e.getAttribute("locale")}}}var d=n(279);const u=(e,t,n)=>{const o=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(o)};class h{constructor(e){this.widget=e,this.token=this.createToken(),this.isReady=!1,window.addEventListener("message",(({data:e})=>{e.token===this.token&&this.process(e)}))}get context(){return h.widgetContextMap.get(this.widget)}send(e,t){this.context.iframe.contentWindow?.postMessage({type:e,payload:t},"*")}process(e){switch(e.type){case c.Output.Init:{if(this.isReady)break;this.isReady=!0;const{context:e}=this;this.send(c.Input.ChangeWidgetRenderEnv,e.widgetRenderEnv||t.WidgetRenderEnv.Default),this.send(c.Input.ChangeTheme,e.theme),this.send(c.Input.ChangeLang,e.locale),this.send(c.Input.Change,e.widgetRepresent);break}case c.Output.Ready:u(this.widget,d.EventType.Ready,{});break;case c.Output.SetFilter:{const{filter:t,target:n}=e.payload;if(n===r.Target.Other){const{data_option:e,rows:n}=this.context.widgetRepresent.dataOptionsMap[s.widgetDefaultKey],{column:{path:o,type:a},value:i}=t,c=a===r.ColumnType.Number?Number(i):i;this.context.otherFilterColumnId=t.column.id,u(this.widget,d.EventType.Interact,{datasetId:e.dataset.id,columnId:t.column.id,dataIndex:n.findIndex((e=>e[o]===c))})}break}}}createToken(){return Math.random().toString(16).slice(2)}}const p=new WeakMap;h.widgetContextMap=p;class f extends HTMLElement{constructor(){super();const e=this.attachShadow({mode:"closed"}),t=document.createElement("iframe"),n=document.createElement("style");n.textContent="\n:host {\n display: block;\n}\n\niframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n",e.append(n);const o={iframe:t,inited:!1,shadowRoot:e,connector:new h(this),otherFilterColumnId:0};p.set(this,o),function(e){new MutationObserver(l).observe(e,{attributes:!0})}(this)}set renderEnv(e){e===t.WidgetRenderEnv.Print&&m(this,{widgetRenderEnv:e})}set widgetBasePath(e){m(this,{widgetBasePath:e})}set locale(e){m(this,{locale:e})}set uid(e){this._uid=e}get uid(){return this._uid}initFormatterToWindow(e,t){const n=window.format||{};n[t]=n[t]||{},e.columns.forEach((e=>{n[t][e.path]=e.format})),window.format=n}provide(e,t){const{dataset:n}=e;this.uid&&this.initFormatterToWindow(n,this.uid);const o=Object.entries(n.columnsByBlock).map((([e,t])=>({key:e,block_type:i.ConfigDataBlockType_Server.Column,function:a.y8.Group,columns:t.map((e=>({column_id:e})))}))),r=n.columns.map((e=>({id:e.id,name:e.name,path:e.path,base_type:e.type})));m(this,{uid:this.uid,widgetRepresent:{dataOptionsMap:{[s.widgetDefaultKey]:{data_option:{key:s.widgetDefaultKey,id:n.datasetId,dataset:{id:n.datasetId,name:"",columns_id:r},method:a.JG.Aggregate,limit_rows:-1,offset:0,blocks:o},rows:n.rows,total:n.rows.length}},viewOptions:Object.entries(t||{}).map((([e,t])=>({key:e,value:t})))}})}provideTheme(e){m(this,{theme:{theme:{background:"rgb(241, 241, 242)",backgroundBright:"rgb(32, 33, 39)",backgroundTint:["rgb(230, 230, 234)","rgb(208, 208, 213)","rgb(163, 163, 172)","rgb(118, 118, 133)","rgb(64, 64, 83)","rgb(32, 33, 39)"],text:"rgb(0, 175, 215)",textTint:["#0d131e","#111827","#1f2937","#374151","#4b5563"],colors:e.palette,colorize:e.heatmap},themeKey:"polymatica",themeProjectKey:"polymatica"}})}highlight(e,t){const{connector:n,otherFilterColumnId:o,widgetRepresent:a}=g(this),i=[],l=a?.dataOptionsMap[s.widgetDefaultKey];if(l){const e=l.data_option.dataset.columns_id.find((({id:e})=>e===o));e&&t.forEach((t=>{t in l.rows&&i.push(l.rows[t][e.path])}))}n.send(c.Input.ChangeOtherFilters,[{column_id:o,value:i,action:r.FilterMethod.InList}])}}function g(e){return p.get(e)}function m(t,n){const o=g(t);Object.assign(o,n);const{iframe:a,inited:r,widgetRepresent:i,locale:s,theme:l,widgetBasePath:d}=o;if(!((0,e.not)(i)||(0,e.not)(s)||(0,e.not)(l)||(0,e.not)(d)))if((0,e.not)(r)){o.inited=!0;let t=d;(0,e.not)(t.endsWith("/"))&&(t+="/"),t+=`index.html?token=${o.connector.token}`,o.uid&&(t+=`&uid=${o.uid}`),a.src=t,o.shadowRoot.append(a)}else{const{connector:e}=o;n.theme&&e.send(c.Input.ChangeTheme,l),n.locale&&e.send(c.Input.ChangeLang,s),n.widgetRepresent&&e.send(c.Input.Change,i)}}customElements.define("polymatica-widget-legacy",f)})(),o})()));
@@ -3,6 +3,7 @@ import { Locale } from 'ptnl-constructor-sdk/config';
3
3
  import { ThemeProvide } from 'ptnl-constructor-sdk/__internal__/theme';
4
4
  import { WidgetRepresent } from 'ptnl-constructor-sdk/__internal__/widget';
5
5
  import { Connector } from './tools/connector';
6
+ export declare type UID = string;
6
7
  export interface Context {
7
8
  readonly iframe: HTMLIFrameElement;
8
9
  widgetRepresent?: WidgetRepresent;
@@ -10,6 +11,7 @@ export interface Context {
10
11
  theme?: ThemeProvide;
11
12
  widgetBasePath?: string;
12
13
  widgetRenderEnv?: WidgetRenderEnv;
14
+ uid?: UID;
13
15
  inited: boolean;
14
16
  shadowRoot: ShadowRoot;
15
17
  connector: Connector;
package/types/events.d.ts CHANGED
@@ -1 +1 @@
1
- export { EventType, EventDetailInteract, EventDetailReady, } from 'polymatica-widget-component';
1
+ export { EventType } from 'polymatica-widget-component';
@@ -1,19 +1,26 @@
1
- import { Column, Locale, Options, Theme } from 'polymatica-widget';
2
- import { InputData } from 'polymatica-widget/__internal__/io';
1
+ import { Locale, Options, Theme } from 'polymatica-widget';
2
+ import type { WidgetColumn, WidgetData } from 'polymatica-widget-component';
3
3
  import { WidgetRenderEnv } from 'ptnl-constructor-sdk';
4
+ import { UID } from './context';
4
5
  declare global {
5
6
  interface Window {
6
- format: Record<string, Column['format']>;
7
+ format: {
8
+ [uid: UID]: {
9
+ [columnPath: WidgetColumn['path']]: WidgetColumn['format'];
10
+ };
11
+ };
7
12
  }
8
13
  }
9
14
  export declare class PolymaticaWidgetLegacy extends HTMLElement {
10
15
  set renderEnv(value: WidgetRenderEnv);
11
16
  set widgetBasePath(value: string);
12
17
  set locale(value: Locale);
18
+ private _uid;
19
+ set uid(value: UID);
20
+ get uid(): UID;
13
21
  constructor();
14
22
  private initFormatterToWindow;
15
- provideData(data: InputData, options: Options): void;
23
+ provide(data: WidgetData | undefined, options: Options | undefined): void;
16
24
  provideTheme(theme: Theme): void;
17
25
  highlight(_: number, rowIndexArray: number[]): void;
18
- unhighlight(_: number): void;
19
26
  }
@@ -1,7 +1,6 @@
1
- import { EventDetailInteract, EventDetailReady, EventType } from '../events';
1
+ import { EventType } from '../events';
2
2
  import { PolymaticaWidgetLegacy } from '../polymatica-widget-component-legacy';
3
3
  export interface DispatchEvent {
4
- (target: PolymaticaWidgetLegacy, type: EventType.Ready, details: EventDetailReady): void;
5
- (target: PolymaticaWidgetLegacy, type: EventType.Interact, details: EventDetailInteract): void;
4
+ (target: PolymaticaWidgetLegacy, type: EventType, details: any): void;
6
5
  }
7
6
  export declare const dispatchEvent: DispatchEvent;