polymatica-widget-component-legacy 2.0.3 → 2.0.8
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 +4 -3
- package/polymatica-widget-component-legacy.js +1 -1
- package/types/context.d.ts +14 -0
- package/types/css.d.ts +1 -0
- package/types/events.d.ts +10 -0
- package/types/polymatica-widget-component-legacy.d.ts +2 -2
- package/types/tools/attributes-watcher.d.ts +2 -0
- package/types/tools/connector.d.ts +14 -0
- package/types/tools/dispatch-event.d.ts +7 -0
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polymatica-widget-component-legacy",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "polymatica-widget-component.js",
|
|
5
|
+
"main": "polymatica-widget-component-legacy.js",
|
|
6
6
|
"types": "types",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"polymatica-widget": "^2.0.0",
|
|
10
|
-
"polymatica-widget-component": "^2.0.2"
|
|
10
|
+
"polymatica-widget-component": "^2.0.2",
|
|
11
|
+
"ptnl-constructor-sdk": "^0.7.148"
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -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,(function(){return(()=>{var e={
|
|
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,(function(){return(()=>{var e={10:e=>{function t(e){return!e}e.exports=Object.defineProperties(t,{default:{value:t},not:{value:t},__esModule:{value:!0}})},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,i=a+parseInt(e.slice(o,a));t.push(e.slice(a,i)),i<e.length&&n(i)}();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"},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;t.r_=t.II=void 0,(o=t.II||(t.II={})).Change="ptnl.input.change",o.ChangeLang="ptnl.input.changeLang",o.ChangeTheme="ptnl.input.changeTheme",o.ChangeOtherFilters="ptnl.input.ChangeOtherFilters",(n=t.r_||(t.r_={})).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"},757:(e,t,n)=>{"use strict";t.lS=void 0;n(764);t.lS="ffed0a4d-4a9d-417f-b502-eb50142c6956"},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,i;Object.defineProperty(t,"__esModule",{value:!0}),t.Target=t.SortDirection=t.FilterMethod=t.ColumnType=void 0,(i=t.ColumnType||(t.ColumnType={})).String="string",i.Number="number",i.Boolean="boolean",i.Date="date",i.Array="array",i.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"}},t={};function n(o){var a=t[o];if(void 0!==a)return a.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.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:()=>p});var e,t=n(10),a=n(836),i=n(649),r=n(757),s=n(897);function c(e){for(const t of e){const e=t.target;switch(t.attributeName){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 l=(e,t,n)=>{const o=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(o)};class d{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 d.widgetContextMap.get(this.widget)}send(e,t){this.context.iframe.contentWindow?.postMessage({type:e,payload:t},"*")}process(t){switch(t.type){case s.r_.Init:{if(this.isReady)break;this.isReady=!0;const{context:e}=this;this.send(s.II.ChangeTheme,e.theme),this.send(s.II.ChangeLang,e.locale),this.send(s.II.Change,e.widgetRepresent);break}case s.r_.Ready:l(this.widget,e.Ready,{});break;case s.r_.Interact:l(this.widget,e.Interact,{datasetId:t.payload.dataOptionId,dataIndex:t.payload.dataIndex})}}createToken(){return Math.random().toString(16).slice(2)}}const u=new WeakMap;d.widgetContextMap=u;class p extends HTMLElement{set widgetBasePath(e){g(this,{widgetBasePath:e})}set locale(e){g(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 d(this)};u.set(this,o),function(e){new MutationObserver(c).observe(e,{attributes:!0})}(this)}provideData(e,t){const{dataset:n}=e,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.id})))})));g(this,{widgetRepresent:{dataOptionsMap:{[r.lS]:{data_option:{key:r.lS,id:n.datasetId,dataset:{id:n.datasetId,name:"",columns_id:n.columns.map((e=>({id:e.id,name:e.name,path:e.path,base_type:e.type})))},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){g(this,{theme:{theme:{background:"#f9fafb",backgroundBright:"#0ea5e9",backgroundTint:["#f3f4f6","#e5e7eb","#d1d5db","#9ca3af","#6b7280"],text:"#000",textTint:["#0d131e","#111827","#1f2937","#374151","#4b5563"],colors:["#00afd7","#10069f","#1857f0","#c724b1","#fedb00","#ff9900","#78d64b","#0c83e4","#8a1f7a","#e45d2b","#f5c7d1","#0e0f7d","#ed6881","#70b5ec","#d76bc8","#6f6cc3"],colorize:[]},themeKey:"polymatica",themeProjectKey:"polymatica"}})}highlight(e,t){}}function g(e,n){const o=function(e){return u.get(e)}(e);Object.assign(o,n);const{iframe:a,inited:i,widgetRepresent:r,locale:c,theme:l,widgetBasePath:d}=o;if(!((0,t.not)(r)||(0,t.not)(c)||(0,t.not)(l)||(0,t.not)(d)))if((0,t.not)(i)){o.inited=!0;let e=d;(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(s.II.ChangeTheme,l),n.locale&&e.send(s.II.ChangeLang,c),n.widgetRepresent&&e.send(s.II.Change,r)}}customElements.define("polymatica-widget-legacy",p)})(),o})()}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Locale } from 'ptnl-constructor-sdk/config';
|
|
2
|
+
import { ThemeProvide } from 'ptnl-constructor-sdk/__internal__/theme';
|
|
3
|
+
import { WidgetRepresent } from 'ptnl-constructor-sdk/__internal__/widget';
|
|
4
|
+
import { Connector } from './tools/connector';
|
|
5
|
+
export interface Context {
|
|
6
|
+
readonly iframe: HTMLIFrameElement;
|
|
7
|
+
widgetRepresent?: WidgetRepresent;
|
|
8
|
+
locale?: Locale;
|
|
9
|
+
theme?: ThemeProvide;
|
|
10
|
+
widgetBasePath?: string;
|
|
11
|
+
inited: boolean;
|
|
12
|
+
shadowRoot: ShadowRoot;
|
|
13
|
+
connector: Connector;
|
|
14
|
+
}
|
package/types/css.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const css = "\n:host {\n display: block;\n}\n\niframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Locale, Options, Theme } from 'polymatica-widget';
|
|
2
|
-
import { PolymaticaWidget } from 'polymatica-widget-component';
|
|
3
2
|
import { InputData } from 'polymatica-widget/__internal__/io';
|
|
4
|
-
export declare class PolymaticaWidgetLegacy extends
|
|
3
|
+
export declare class PolymaticaWidgetLegacy extends HTMLElement {
|
|
5
4
|
set widgetBasePath(value: string);
|
|
6
5
|
set locale(value: Locale);
|
|
6
|
+
constructor();
|
|
7
7
|
provideData(data: InputData, options: Options): void;
|
|
8
8
|
provideTheme(theme: Theme): void;
|
|
9
9
|
highlight(datasetId: number, rowIndexArray: number[]): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Input, InputParameter } from 'ptnl-constructor-sdk/__internal__/widget-io';
|
|
2
|
+
import { Context } from '../context';
|
|
3
|
+
import { PolymaticaWidgetLegacy } from '../polymatica-widget-component-legacy';
|
|
4
|
+
export declare class Connector {
|
|
5
|
+
private readonly widget;
|
|
6
|
+
static widgetContextMap: WeakMap<PolymaticaWidgetLegacy, Context>;
|
|
7
|
+
readonly token: string;
|
|
8
|
+
private isReady;
|
|
9
|
+
private get context();
|
|
10
|
+
constructor(widget: PolymaticaWidgetLegacy);
|
|
11
|
+
send<T extends Input>(type: T, payload: InputParameter[T]): void;
|
|
12
|
+
private process;
|
|
13
|
+
private createToken;
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EventDetailInteract, EventDetailReady, EventType } from '../events';
|
|
2
|
+
import { PolymaticaWidgetLegacy } from '../polymatica-widget-component-legacy';
|
|
3
|
+
export interface DispatchEvent {
|
|
4
|
+
(target: PolymaticaWidgetLegacy, type: EventType.Ready, details: EventDetailReady): void;
|
|
5
|
+
(target: PolymaticaWidgetLegacy, type: EventType.Interact, details: EventDetailInteract): void;
|
|
6
|
+
}
|
|
7
|
+
export declare const dispatchEvent: DispatchEvent;
|