polymatica-widget-component-legacy 2.1.18 → 2.1.19

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/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright (c) 2021, Polymatica <E-mail address>
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any
4
- purpose with or without fee is hereby granted, provided that the above
5
- copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ Copyright (c) 2021, Polymatica <E-mail address>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # polymatica-widget-component-legacy
2
-
3
- ![build: success](https://raw.githubusercontent.com/git@gitlab.ptnl.moscow:constructor/platform/polymatica-widget-component-legacy/master/badges/build.svg)
4
- ![license: ISC](https://raw.githubusercontent.com/git@gitlab.ptnl.moscow:constructor/platform/polymatica-widget-component-legacy/master/badges/license.svg)
5
-
6
- readme
1
+ # polymatica-widget-component-legacy
2
+
3
+ ![build: success](https://raw.githubusercontent.com/git@gitlab.ptnl.moscow:constructor/platform/polymatica-widget-component-legacy/master/badges/build.svg)
4
+ ![license: ISC](https://raw.githubusercontent.com/git@gitlab.ptnl.moscow:constructor/platform/polymatica-widget-component-legacy/master/badges/license.svg)
5
+
6
+ readme
package/esm/context.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { WidgetRenderEnv } from 'plmt-constructor-sdk';
2
- import { Locale } from 'plmt-constructor-sdk/config';
3
- import { ConfigDataOption_Server } from 'plmt-constructor-sdk/__internal__/config';
4
- import { ThemeProvide } from 'plmt-constructor-sdk/__internal__/theme';
5
- import { WidgetRepresent } from 'plmt-constructor-sdk/__internal__/widget';
6
- import { Connector } from './tools/connector';
7
- export type UID = string;
8
- export interface Context {
9
- readonly iframe: HTMLIFrameElement;
10
- dataConfig?: ConfigDataOption_Server;
11
- widgetRepresent?: WidgetRepresent;
12
- locale?: Locale;
13
- theme?: ThemeProvide;
14
- widgetBasePath?: string;
15
- widgetRenderEnv?: WidgetRenderEnv;
16
- uid?: UID;
17
- inited: boolean;
18
- shadowRoot: ShadowRoot;
19
- connector: Connector;
20
- otherFilterColumnId: number;
21
- }
1
+ import { WidgetRenderEnv } from 'plmt-constructor-sdk';
2
+ import { Locale } from 'plmt-constructor-sdk/config';
3
+ import { ConfigDataOption_Server } from 'plmt-constructor-sdk/__internal__/config';
4
+ import { ThemeProvide } from 'plmt-constructor-sdk/__internal__/theme';
5
+ import { WidgetRepresent } from 'plmt-constructor-sdk/__internal__/widget';
6
+ import { Connector } from './tools/connector';
7
+ export type UID = string;
8
+ export interface Context {
9
+ readonly iframe: HTMLIFrameElement;
10
+ dataConfig?: ConfigDataOption_Server;
11
+ widgetRepresent?: WidgetRepresent;
12
+ locale?: Locale;
13
+ theme?: ThemeProvide;
14
+ widgetBasePath?: string;
15
+ widgetRenderEnv?: WidgetRenderEnv;
16
+ uid?: UID;
17
+ inited: boolean;
18
+ shadowRoot: ShadowRoot;
19
+ connector: Connector;
20
+ otherFilterColumnId: number;
21
+ }
package/esm/context.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=context.js.map
package/esm/css.d.ts CHANGED
@@ -1 +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
+ export declare const css = "\n:host {\n display: block;\n}\n\niframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n";
package/esm/css.js CHANGED
@@ -1,12 +1,12 @@
1
- export const css = `
2
- :host {
3
- display: block;
4
- }
5
-
6
- iframe {
7
- border: none;
8
- width: 100%;
9
- height: 100%;
10
- }
11
- `;
1
+ export const css = `
2
+ :host {
3
+ display: block;
4
+ }
5
+
6
+ iframe {
7
+ border: none;
8
+ width: 100%;
9
+ height: 100%;
10
+ }
11
+ `;
12
12
  //# sourceMappingURL=css.js.map
package/esm/events.d.ts CHANGED
@@ -1 +1 @@
1
- export { EventType } from 'polymatica-widget-component';
1
+ export { EventType } from 'polymatica-widget-component';
package/esm/events.js CHANGED
@@ -1,2 +1,2 @@
1
- export { EventType } from 'polymatica-widget-component';
1
+ export { EventType } from 'polymatica-widget-component';
2
2
  //# sourceMappingURL=events.js.map
package/esm/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './polymatica-widget-component-legacy';
1
+ export * from './polymatica-widget-component-legacy';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PolymaticaWidgetLegacy } from './polymatica-widget-component-legacy';
2
- export * from './polymatica-widget-component-legacy';
3
- customElements.define('polymatica-widget-legacy', PolymaticaWidgetLegacy);
1
+ import { PolymaticaWidgetLegacy } from './polymatica-widget-component-legacy';
2
+ export * from './polymatica-widget-component-legacy';
3
+ customElements.define('polymatica-widget-legacy', PolymaticaWidgetLegacy);
4
4
  //# sourceMappingURL=index.js.map
@@ -1,29 +1,29 @@
1
- import { Locale, Options, Theme } from 'polymatica-widget';
2
- import { PolymaticaWidget, WidgetColumn, WidgetData, WidgetDatasetRef } from 'polymatica-widget-component';
3
- import { WidgetRenderEnv } from 'plmt-constructor-sdk';
4
- import { ConfigDataOption_Server } from 'plmt-constructor-sdk/__internal__/config';
5
- import { UID } from './context';
6
- declare global {
7
- interface Window {
8
- format: {
9
- [uid: UID]: {
10
- [columnPath: WidgetColumn['path']]: WidgetColumn['format'];
11
- };
12
- };
13
- }
14
- }
15
- export declare class PolymaticaWidgetLegacy extends HTMLElement implements Omit<PolymaticaWidget, '#private'> {
16
- set renderEnv(value: WidgetRenderEnv);
17
- set widgetBasePath(value: string);
18
- set locale(value: Locale);
19
- private _uid;
20
- set uid(value: UID);
21
- get uid(): UID;
22
- constructor();
23
- private initFormatterToWindow;
24
- setDataConfig(dataConfig: ConfigDataOption_Server): void;
25
- provide(data: WidgetData | undefined, options: Options | undefined): void;
26
- provideTheme(theme: Theme): void;
27
- highlight(_: WidgetDatasetRef, rowIndexArray: number[]): void;
28
- setInteractColumnId(id: number): void;
29
- }
1
+ import { Locale, Options, Theme } from 'polymatica-widget';
2
+ import { PolymaticaWidget, WidgetColumn, WidgetData, WidgetDatasetRef } from 'polymatica-widget-component';
3
+ import { WidgetRenderEnv } from 'plmt-constructor-sdk';
4
+ import { ConfigDataOption_Server } from 'plmt-constructor-sdk/__internal__/config';
5
+ import { UID } from './context';
6
+ declare global {
7
+ interface Window {
8
+ format: {
9
+ [uid: UID]: {
10
+ [columnPath: WidgetColumn['path']]: WidgetColumn['format'];
11
+ };
12
+ };
13
+ }
14
+ }
15
+ export declare class PolymaticaWidgetLegacy extends HTMLElement implements Omit<PolymaticaWidget, '#private'> {
16
+ set renderEnv(value: WidgetRenderEnv);
17
+ set widgetBasePath(value: string);
18
+ set locale(value: Locale);
19
+ private _uid;
20
+ set uid(value: UID);
21
+ get uid(): UID;
22
+ constructor();
23
+ private initFormatterToWindow;
24
+ setDataConfig(dataConfig: ConfigDataOption_Server): void;
25
+ provide(data: WidgetData | undefined, options: Options | undefined): void;
26
+ provideTheme(theme: Theme): void;
27
+ highlight(_: WidgetDatasetRef, rowIndexArray: number[]): void;
28
+ setInteractColumnId(id: number): void;
29
+ }
@@ -1,224 +1,224 @@
1
- import { not } from 'logical-not';
2
- import { WidgetRenderEnv } from 'plmt-constructor-sdk';
3
- import { DataQueryFunction, DataQueryMethod, } from 'plmt-constructor-sdk/config';
4
- import { FilterMethod } from 'plmt-constructor-sdk/data';
5
- import { ConfigDataBlockType_Server, blockFilterKey, blockSortKey, } from 'plmt-constructor-sdk/__internal__/config';
6
- import { widgetDefaultKey, } from 'plmt-constructor-sdk/__internal__/widget';
7
- import { Input } from 'plmt-constructor-sdk/__internal__/widget-io';
8
- import { css } from './css';
9
- import { attributesWatcher } from './tools/attributes-watcher';
10
- import { Connector } from './tools/connector';
11
- const map = new WeakMap();
12
- Connector.widgetContextMap = map;
13
- export class PolymaticaWidgetLegacy extends HTMLElement {
14
- set renderEnv(value) {
15
- switch (value) {
16
- case WidgetRenderEnv.Print:
17
- change(this, { widgetRenderEnv: value });
18
- break;
19
- }
20
- }
21
- set widgetBasePath(value) {
22
- change(this, { widgetBasePath: value });
23
- }
24
- set locale(value) {
25
- change(this, { locale: value });
26
- }
27
- set uid(value) {
28
- this._uid = value;
29
- }
30
- get uid() {
31
- return this._uid;
32
- }
33
- constructor() {
34
- super();
35
- const shadowRoot = this.attachShadow({ mode: 'closed' });
36
- const iframe = document.createElement('iframe');
37
- const style = document.createElement('style');
38
- style.textContent = css;
39
- shadowRoot.append(style);
40
- const context = {
41
- iframe,
42
- inited: false,
43
- shadowRoot,
44
- connector: new Connector(this),
45
- otherFilterColumnId: 0,
46
- };
47
- map.set(this, context);
48
- attributesWatcher(this);
49
- }
50
- initFormatterToWindow(dataset, uid) {
51
- const format = window['format'] || {};
52
- format[uid] = format[uid] || {};
53
- dataset.columns.forEach((column) => {
54
- format[uid][column.path] = column.format;
55
- });
56
- window.format = format;
57
- }
58
- setDataConfig(dataConfig) {
59
- change(this, { dataConfig });
60
- }
61
- provide(data, options) {
62
- const { dataset } = data;
63
- if (this.uid) {
64
- this.initFormatterToWindow(dataset, this.uid);
65
- }
66
- const blocks = Object.entries(dataset.columnsByBlock).map(([key, columnIds]) => ({
67
- key,
68
- block_type: ConfigDataBlockType_Server.Column,
69
- function: DataQueryFunction.Group,
70
- columns: columnIds.map((column_id) => ({
71
- column_id,
72
- })),
73
- }));
74
- if (options?.sort?.length) {
75
- const sortBlock = {
76
- key: blockSortKey,
77
- block_type: ConfigDataBlockType_Server.Sort,
78
- function: null,
79
- columns: options.sort.map(({ column_id, direction }) => {
80
- return { column_id, value: direction };
81
- }),
82
- };
83
- blocks.push(sortBlock);
84
- }
85
- if (options?.filters) {
86
- const filterBlock = {
87
- key: blockFilterKey,
88
- block_type: ConfigDataBlockType_Server.Filter,
89
- function: null,
90
- columns: options.filters.map(({ column_id, action, value }) => {
91
- return { column_id, action, value };
92
- }),
93
- };
94
- blocks.push(filterBlock);
95
- }
96
- const columns = dataset.columns.map((column) => ({
97
- id: column.id,
98
- name: column.name,
99
- path: column.path,
100
- base_type: column.type,
101
- }));
102
- change(this, {
103
- uid: this.uid,
104
- widgetRepresent: {
105
- dataOptionsMap: {
106
- [widgetDefaultKey]: {
107
- data_option: {
108
- key: widgetDefaultKey,
109
- id: 0,
110
- dataset: {
111
- id: 0,
112
- name: '',
113
- columns_id: columns,
114
- },
115
- method: DataQueryMethod.Aggregate,
116
- limit_rows: -1,
117
- offset: 0,
118
- blocks,
119
- },
120
- rows: dataset.rows,
121
- total: dataset.rows.length,
122
- },
123
- },
124
- viewOptions: Object.entries(options || {}).map(([key, value]) => ({
125
- key,
126
- value,
127
- })),
128
- },
129
- });
130
- }
131
- provideTheme(theme) {
132
- change(this, {
133
- theme: {
134
- theme: {
135
- background: 'rgb(241, 241, 242)',
136
- backgroundBright: 'rgb(32, 33, 39)',
137
- backgroundTint: [
138
- 'rgb(230, 230, 234)',
139
- 'rgb(208, 208, 213)',
140
- 'rgb(163, 163, 172)',
141
- 'rgb(118, 118, 133)',
142
- 'rgb(64, 64, 83)',
143
- 'rgb(32, 33, 39)',
144
- ],
145
- text: 'rgb(0, 175, 215)',
146
- textTint: [
147
- '#0d131e',
148
- '#111827',
149
- '#1f2937',
150
- '#374151',
151
- '#4b5563',
152
- ],
153
- colors: theme.palette,
154
- colorize: theme.heatmap ?? [],
155
- },
156
- themeKey: 'polymatica',
157
- themeProjectKey: 'polymatica',
158
- },
159
- });
160
- }
161
- highlight(_, rowIndexArray) {
162
- const { connector, otherFilterColumnId, widgetRepresent } = getContext(this);
163
- const value = [];
164
- const data = widgetRepresent?.dataOptionsMap[widgetDefaultKey];
165
- if (data) {
166
- const column = data.data_option.dataset.columns_id.find(({ id }) => id === otherFilterColumnId);
167
- if (column) {
168
- rowIndexArray.forEach((i) => {
169
- if (i in data.rows)
170
- value.push(data.rows[i][column.path]);
171
- });
172
- }
173
- }
174
- connector.send(Input.ChangeOtherFilters, [
175
- {
176
- column_id: otherFilterColumnId,
177
- value,
178
- action: FilterMethod.InList,
179
- },
180
- ]);
181
- }
182
- setInteractColumnId(id) {
183
- const context = getContext(this);
184
- context.otherFilterColumnId = id;
185
- }
186
- }
187
- function getContext(widget) {
188
- return map.get(widget);
189
- }
190
- function change(widget, slice) {
191
- const context = getContext(widget);
192
- Object.assign(context, slice);
193
- const { iframe, inited, widgetRepresent, locale, theme, widgetBasePath } = context;
194
- if (not(widgetRepresent))
195
- return;
196
- if (not(locale))
197
- return;
198
- if (not(theme))
199
- return;
200
- if (not(widgetBasePath))
201
- return;
202
- if (not(inited)) {
203
- context.inited = true;
204
- let src = widgetBasePath;
205
- if (not(src.endsWith('/')))
206
- src += '/';
207
- src += `index.html?token=${context.connector.token}`;
208
- if (context.uid) {
209
- src += `&uid=${context.uid}`;
210
- }
211
- iframe.src = src;
212
- context.shadowRoot.append(iframe);
213
- }
214
- else {
215
- const { connector } = context;
216
- if (slice.theme)
217
- connector.send(Input.ChangeTheme, theme);
218
- if (slice.locale)
219
- connector.send(Input.ChangeLang, locale);
220
- if (slice.widgetRepresent)
221
- connector.send(Input.Change, widgetRepresent);
222
- }
223
- }
1
+ import { not } from 'logical-not';
2
+ import { WidgetRenderEnv } from 'plmt-constructor-sdk';
3
+ import { DataQueryFunction, DataQueryMethod, } from 'plmt-constructor-sdk/config';
4
+ import { FilterMethod } from 'plmt-constructor-sdk/data';
5
+ import { ConfigDataBlockType_Server, blockFilterKey, blockSortKey, } from 'plmt-constructor-sdk/__internal__/config';
6
+ import { widgetDefaultKey, } from 'plmt-constructor-sdk/__internal__/widget';
7
+ import { Input } from 'plmt-constructor-sdk/__internal__/widget-io';
8
+ import { css } from './css';
9
+ import { attributesWatcher } from './tools/attributes-watcher';
10
+ import { Connector } from './tools/connector';
11
+ const map = new WeakMap();
12
+ Connector.widgetContextMap = map;
13
+ export class PolymaticaWidgetLegacy extends HTMLElement {
14
+ set renderEnv(value) {
15
+ switch (value) {
16
+ case WidgetRenderEnv.Print:
17
+ change(this, { widgetRenderEnv: value });
18
+ break;
19
+ }
20
+ }
21
+ set widgetBasePath(value) {
22
+ change(this, { widgetBasePath: value });
23
+ }
24
+ set locale(value) {
25
+ change(this, { locale: value });
26
+ }
27
+ set uid(value) {
28
+ this._uid = value;
29
+ }
30
+ get uid() {
31
+ return this._uid;
32
+ }
33
+ constructor() {
34
+ super();
35
+ const shadowRoot = this.attachShadow({ mode: 'closed' });
36
+ const iframe = document.createElement('iframe');
37
+ const style = document.createElement('style');
38
+ style.textContent = css;
39
+ shadowRoot.append(style);
40
+ const context = {
41
+ iframe,
42
+ inited: false,
43
+ shadowRoot,
44
+ connector: new Connector(this),
45
+ otherFilterColumnId: 0,
46
+ };
47
+ map.set(this, context);
48
+ attributesWatcher(this);
49
+ }
50
+ initFormatterToWindow(dataset, uid) {
51
+ const format = window['format'] || {};
52
+ format[uid] = format[uid] || {};
53
+ dataset.columns.forEach((column) => {
54
+ format[uid][column.path] = column.format;
55
+ });
56
+ window.format = format;
57
+ }
58
+ setDataConfig(dataConfig) {
59
+ change(this, { dataConfig });
60
+ }
61
+ provide(data, options) {
62
+ const { dataset } = data;
63
+ if (this.uid) {
64
+ this.initFormatterToWindow(dataset, this.uid);
65
+ }
66
+ const blocks = Object.entries(dataset.columnsByBlock).map(([key, columnIds]) => ({
67
+ key,
68
+ block_type: ConfigDataBlockType_Server.Column,
69
+ function: DataQueryFunction.Group,
70
+ columns: columnIds.map((column_id) => ({
71
+ column_id,
72
+ })),
73
+ }));
74
+ if (options?.sort?.length) {
75
+ const sortBlock = {
76
+ key: blockSortKey,
77
+ block_type: ConfigDataBlockType_Server.Sort,
78
+ function: null,
79
+ columns: options.sort.map(({ column_id, direction }) => {
80
+ return { column_id, value: direction };
81
+ }),
82
+ };
83
+ blocks.push(sortBlock);
84
+ }
85
+ if (options?.filters) {
86
+ const filterBlock = {
87
+ key: blockFilterKey,
88
+ block_type: ConfigDataBlockType_Server.Filter,
89
+ function: null,
90
+ columns: options.filters.map(({ column_id, action, value }) => {
91
+ return { column_id, action, value };
92
+ }),
93
+ };
94
+ blocks.push(filterBlock);
95
+ }
96
+ const columns = dataset.columns.map((column) => ({
97
+ id: column.id,
98
+ name: column.name,
99
+ path: column.path,
100
+ base_type: column.type,
101
+ }));
102
+ change(this, {
103
+ uid: this.uid,
104
+ widgetRepresent: {
105
+ dataOptionsMap: {
106
+ [widgetDefaultKey]: {
107
+ data_option: {
108
+ key: widgetDefaultKey,
109
+ id: 0,
110
+ dataset: {
111
+ id: 0,
112
+ name: '',
113
+ columns_id: columns,
114
+ },
115
+ method: DataQueryMethod.Aggregate,
116
+ limit_rows: -1,
117
+ offset: 0,
118
+ blocks,
119
+ },
120
+ rows: dataset.rows,
121
+ total: dataset.rows.length,
122
+ },
123
+ },
124
+ viewOptions: Object.entries(options || {}).map(([key, value]) => ({
125
+ key,
126
+ value,
127
+ })),
128
+ },
129
+ });
130
+ }
131
+ provideTheme(theme) {
132
+ change(this, {
133
+ theme: {
134
+ theme: {
135
+ background: 'rgb(241, 241, 242)',
136
+ backgroundBright: 'rgb(32, 33, 39)',
137
+ backgroundTint: [
138
+ 'rgb(230, 230, 234)',
139
+ 'rgb(208, 208, 213)',
140
+ 'rgb(163, 163, 172)',
141
+ 'rgb(118, 118, 133)',
142
+ 'rgb(64, 64, 83)',
143
+ 'rgb(32, 33, 39)',
144
+ ],
145
+ text: 'rgb(0, 175, 215)',
146
+ textTint: [
147
+ '#0d131e',
148
+ '#111827',
149
+ '#1f2937',
150
+ '#374151',
151
+ '#4b5563',
152
+ ],
153
+ colors: theme.palette,
154
+ colorize: theme.heatmap ?? [],
155
+ },
156
+ themeKey: 'polymatica',
157
+ themeProjectKey: 'polymatica',
158
+ },
159
+ });
160
+ }
161
+ highlight(_, rowIndexArray) {
162
+ const { connector, otherFilterColumnId, widgetRepresent } = getContext(this);
163
+ const value = [];
164
+ const data = widgetRepresent?.dataOptionsMap[widgetDefaultKey];
165
+ if (data) {
166
+ const column = data.data_option.dataset.columns_id.find(({ id }) => id === otherFilterColumnId);
167
+ if (column) {
168
+ rowIndexArray.forEach((i) => {
169
+ if (i in data.rows)
170
+ value.push(data.rows[i][column.path]);
171
+ });
172
+ }
173
+ }
174
+ connector.send(Input.ChangeOtherFilters, [
175
+ {
176
+ column_id: otherFilterColumnId,
177
+ value,
178
+ action: FilterMethod.InList,
179
+ },
180
+ ]);
181
+ }
182
+ setInteractColumnId(id) {
183
+ const context = getContext(this);
184
+ context.otherFilterColumnId = id;
185
+ }
186
+ }
187
+ function getContext(widget) {
188
+ return map.get(widget);
189
+ }
190
+ function change(widget, slice) {
191
+ const context = getContext(widget);
192
+ Object.assign(context, slice);
193
+ const { iframe, inited, widgetRepresent, locale, theme, widgetBasePath } = context;
194
+ if (not(widgetRepresent))
195
+ return;
196
+ if (not(locale))
197
+ return;
198
+ if (not(theme))
199
+ return;
200
+ if (not(widgetBasePath))
201
+ return;
202
+ if (not(inited)) {
203
+ context.inited = true;
204
+ let src = widgetBasePath;
205
+ if (not(src.endsWith('/')))
206
+ src += '/';
207
+ src += `index.html?token=${context.connector.token}`;
208
+ if (context.uid) {
209
+ src += `&uid=${context.uid}`;
210
+ }
211
+ iframe.src = src;
212
+ context.shadowRoot.append(iframe);
213
+ }
214
+ else {
215
+ const { connector } = context;
216
+ if (slice.theme)
217
+ connector.send(Input.ChangeTheme, theme);
218
+ if (slice.locale)
219
+ connector.send(Input.ChangeLang, locale);
220
+ if (slice.widgetRepresent)
221
+ connector.send(Input.Change, widgetRepresent);
222
+ }
223
+ }
224
224
  //# sourceMappingURL=polymatica-widget-component-legacy.js.map
@@ -1,2 +1,2 @@
1
- import { PolymaticaWidgetLegacy } from '../polymatica-widget-component-legacy';
2
- export declare function attributesWatcher(widget: PolymaticaWidgetLegacy): void;
1
+ import { PolymaticaWidgetLegacy } from '../polymatica-widget-component-legacy';
2
+ export declare function attributesWatcher(widget: PolymaticaWidgetLegacy): void;