plmt-constructor-sdk 0.13.2
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/__internal__/config.d.ts +53 -0
- package/__internal__/config.js +46 -0
- package/__internal__/dataset.d.ts +19 -0
- package/__internal__/dataset.js +12 -0
- package/__internal__/theme.d.ts +13 -0
- package/__internal__/theme.js +112 -0
- package/__internal__/view-settings.d.ts +24 -0
- package/__internal__/view-settings.js +50 -0
- package/__internal__/widget-io.d.ts +56 -0
- package/__internal__/widget-io.js +21 -0
- package/__internal__/widget-provide-data.d.ts +4 -0
- package/__internal__/widget-provide-data.js +112 -0
- package/__internal__/widget.d.ts +64 -0
- package/__internal__/widget.js +64 -0
- package/config.d.ts +142 -0
- package/config.js +198 -0
- package/data.d.ts +62 -0
- package/data.js +51 -0
- package/declare.d.ts +20 -0
- package/declare.js +131 -0
- package/index.d.ts +2 -0
- package/index.js +18 -0
- package/package.json +8 -0
- package/theme.d.ts +26 -0
- package/theme.js +19 -0
- package/widget.d.ts +63 -0
- package/widget.js +24 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Text, DataQueryMethod, DataQueryFunction } from '../config';
|
|
2
|
+
import { ColumnType } from '../data';
|
|
3
|
+
import { DatasetColumnType_Server } from './dataset';
|
|
4
|
+
export declare enum ConfigDataBlockType_Server {
|
|
5
|
+
Column = "column",
|
|
6
|
+
Filter = "filter",
|
|
7
|
+
Sort = "sort",
|
|
8
|
+
Colorizer = "colorizer",
|
|
9
|
+
Drilldown = "drilldown"
|
|
10
|
+
}
|
|
11
|
+
export interface Config_Server {
|
|
12
|
+
label: Text;
|
|
13
|
+
icon: string;
|
|
14
|
+
data_options: ConfigDataOption_Server[];
|
|
15
|
+
doc: {
|
|
16
|
+
info: string;
|
|
17
|
+
assets: string;
|
|
18
|
+
images: string[];
|
|
19
|
+
};
|
|
20
|
+
sdk_version: string;
|
|
21
|
+
version: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ConfigDataOption_Server {
|
|
24
|
+
key: string;
|
|
25
|
+
method: DataQueryMethod;
|
|
26
|
+
label?: Text;
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
validation?: {
|
|
30
|
+
required_some?: string[];
|
|
31
|
+
required_every?: string[];
|
|
32
|
+
};
|
|
33
|
+
blocks: ConfigDataOptionBlock_Server[];
|
|
34
|
+
}
|
|
35
|
+
export interface ConfigDataOptionBlock_Server {
|
|
36
|
+
type: ConfigDataBlockType_Server;
|
|
37
|
+
key: string;
|
|
38
|
+
label: Text;
|
|
39
|
+
icon?: string;
|
|
40
|
+
data_type?: DatasetColumnType_Server;
|
|
41
|
+
field_type?: ColumnType;
|
|
42
|
+
max?: number;
|
|
43
|
+
function?: DataQueryFunction;
|
|
44
|
+
}
|
|
45
|
+
export declare const configDataBlock_Server = "8316067a-d04b-4b21-bd4d-35529846617b";
|
|
46
|
+
export declare const blockFilterKey = "34642664-dbd1-4e35-b0ea-2eaabe796b48";
|
|
47
|
+
export declare const blockSortKey = "2c849ed6-6105-4aa2-a961-9f95135dfe3b";
|
|
48
|
+
export declare const blockColorizeKey = "badd51f7-82ce-45b2-a67e-37d52df88c5c";
|
|
49
|
+
export declare function decodeDrilldownData(source: string, additionalFilterSources: string[]): string;
|
|
50
|
+
export declare function encodeDrilldownData(key: string): {
|
|
51
|
+
source: string;
|
|
52
|
+
additionalFilterSources: string[];
|
|
53
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeDrilldownData = exports.decodeDrilldownData = exports.blockColorizeKey = exports.blockSortKey = exports.blockFilterKey = exports.configDataBlock_Server = exports.ConfigDataBlockType_Server = void 0;
|
|
4
|
+
// enums
|
|
5
|
+
var ConfigDataBlockType_Server;
|
|
6
|
+
(function (ConfigDataBlockType_Server) {
|
|
7
|
+
ConfigDataBlockType_Server["Column"] = "column";
|
|
8
|
+
ConfigDataBlockType_Server["Filter"] = "filter";
|
|
9
|
+
ConfigDataBlockType_Server["Sort"] = "sort";
|
|
10
|
+
ConfigDataBlockType_Server["Colorizer"] = "colorizer";
|
|
11
|
+
ConfigDataBlockType_Server["Drilldown"] = "drilldown";
|
|
12
|
+
})(ConfigDataBlockType_Server = exports.ConfigDataBlockType_Server || (exports.ConfigDataBlockType_Server = {}));
|
|
13
|
+
exports.configDataBlock_Server = '8316067a-d04b-4b21-bd4d-35529846617b';
|
|
14
|
+
exports.blockFilterKey = '34642664-dbd1-4e35-b0ea-2eaabe796b48';
|
|
15
|
+
exports.blockSortKey = '2c849ed6-6105-4aa2-a961-9f95135dfe3b';
|
|
16
|
+
exports.blockColorizeKey = 'badd51f7-82ce-45b2-a67e-37d52df88c5c';
|
|
17
|
+
function decodeDrilldownData(source, additionalFilterSources) {
|
|
18
|
+
const keyParts = [length(source.length), source];
|
|
19
|
+
additionalFilterSources.forEach((item) => keyParts.push(length(item.length), item));
|
|
20
|
+
return keyParts.join('');
|
|
21
|
+
function length(value) {
|
|
22
|
+
if (value > 0xff)
|
|
23
|
+
throw new RangeError();
|
|
24
|
+
return value > 0xf
|
|
25
|
+
? `0x${value.toString(16)}`
|
|
26
|
+
: `0x0${value.toString(16)}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.decodeDrilldownData = decodeDrilldownData;
|
|
30
|
+
function encodeDrilldownData(key) {
|
|
31
|
+
const parts = [];
|
|
32
|
+
parse();
|
|
33
|
+
const [source, ...additionalFilterSources] = parts;
|
|
34
|
+
return {
|
|
35
|
+
source,
|
|
36
|
+
additionalFilterSources,
|
|
37
|
+
};
|
|
38
|
+
function parse(offset = 0) {
|
|
39
|
+
const start = offset + 4;
|
|
40
|
+
const end = start + parseInt(key.slice(offset, start));
|
|
41
|
+
parts.push(key.slice(start, end));
|
|
42
|
+
if (end < key.length)
|
|
43
|
+
parse(end);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.encodeDrilldownData = encodeDrilldownData;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnType } from '../data';
|
|
2
|
+
export { ColumnType as ColumnFieldType_Server } from '../data';
|
|
3
|
+
export declare enum DatasetColumnType_Server {
|
|
4
|
+
Dimension = "dimension",
|
|
5
|
+
Fact = "fact",
|
|
6
|
+
Any = "any"
|
|
7
|
+
}
|
|
8
|
+
export interface Dataset_Server {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
columns_id: Column_Server[];
|
|
12
|
+
}
|
|
13
|
+
export interface Column_Server {
|
|
14
|
+
id: number;
|
|
15
|
+
name: string;
|
|
16
|
+
path: string;
|
|
17
|
+
base_type: ColumnType;
|
|
18
|
+
data_type?: DatasetColumnType_Server;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatasetColumnType_Server = exports.ColumnFieldType_Server = void 0;
|
|
4
|
+
// enums
|
|
5
|
+
var data_1 = require("../data");
|
|
6
|
+
Object.defineProperty(exports, "ColumnFieldType_Server", { enumerable: true, get: function () { return data_1.ColumnType; } });
|
|
7
|
+
var DatasetColumnType_Server;
|
|
8
|
+
(function (DatasetColumnType_Server) {
|
|
9
|
+
DatasetColumnType_Server["Dimension"] = "dimension";
|
|
10
|
+
DatasetColumnType_Server["Fact"] = "fact";
|
|
11
|
+
DatasetColumnType_Server["Any"] = "any";
|
|
12
|
+
})(DatasetColumnType_Server = exports.DatasetColumnType_Server || (exports.DatasetColumnType_Server = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Theme } from '../theme';
|
|
2
|
+
export interface ThemeProvide {
|
|
3
|
+
theme: Theme;
|
|
4
|
+
themeKey: string;
|
|
5
|
+
themeProjectKey: string;
|
|
6
|
+
}
|
|
7
|
+
export declare type ThemeKey = keyof Pick<Theme, 'background' | 'backgroundBright' | 'backgroundTint' | 'text' | 'textTint'>;
|
|
8
|
+
export declare type ThemeProjectKey = keyof Pick<Theme, 'colors'>;
|
|
9
|
+
export declare const themeKeys: ThemeKey[];
|
|
10
|
+
export declare const themeProjectKeys: ThemeProjectKey[];
|
|
11
|
+
export declare function provideCssVariables({ theme, themeKey, themeProjectKey, }: ThemeProvide): void;
|
|
12
|
+
export declare function colorizeClassName(i: number, j: number): string;
|
|
13
|
+
export declare function createColorizeColors(source: string[]): string[][];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createColorizeColors = exports.colorizeClassName = exports.provideCssVariables = exports.themeProjectKeys = exports.themeKeys = void 0;
|
|
4
|
+
const logical_not_1 = require("logical-not");
|
|
5
|
+
exports.themeKeys = [
|
|
6
|
+
'background',
|
|
7
|
+
'backgroundBright',
|
|
8
|
+
'backgroundTint',
|
|
9
|
+
'text',
|
|
10
|
+
'textTint',
|
|
11
|
+
];
|
|
12
|
+
exports.themeProjectKeys = ['colors'];
|
|
13
|
+
const head = document.querySelector('head');
|
|
14
|
+
const body = document.querySelector('body');
|
|
15
|
+
const providedCssVariablesMap = {};
|
|
16
|
+
let prevThemeClassName = '';
|
|
17
|
+
let prevThemeProjectClassName = '';
|
|
18
|
+
function provideCssVariables({ theme, themeKey, themeProjectKey, }) {
|
|
19
|
+
const themeClassName = `ptnl-theme-${kebabCase(themeKey)}`;
|
|
20
|
+
if ((0, logical_not_1.not)(themeClassName in providedCssVariablesMap)) {
|
|
21
|
+
const cssVariables = [];
|
|
22
|
+
Object.entries(theme).forEach(([key, source]) => {
|
|
23
|
+
if (exports.themeKeys.includes(key)) {
|
|
24
|
+
const name = kebabCase(key);
|
|
25
|
+
if (Array.isArray(source))
|
|
26
|
+
source.forEach((value, i) => cssVariables.push({
|
|
27
|
+
name: `--${name}-${i}`,
|
|
28
|
+
value,
|
|
29
|
+
}));
|
|
30
|
+
else
|
|
31
|
+
cssVariables.push({ name: `--${name}`, value: source });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
addStyles(themeClassName, [
|
|
35
|
+
{ className: themeClassName, cssProperties: cssVariables },
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
prevThemeClassName = switchClassName(prevThemeClassName, themeClassName);
|
|
39
|
+
const themeProjectClassName = `ptnl-project-${themeProjectKey}`;
|
|
40
|
+
if ((0, logical_not_1.not)(themeProjectClassName in providedCssVariablesMap)) {
|
|
41
|
+
const cssVariables = theme.colors.map((value, i) => ({
|
|
42
|
+
name: `--ptnl-color-${i}`,
|
|
43
|
+
value,
|
|
44
|
+
}));
|
|
45
|
+
addStyles(themeProjectClassName, [
|
|
46
|
+
{ className: themeProjectClassName, cssProperties: cssVariables },
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
prevThemeProjectClassName = switchClassName(prevThemeProjectClassName, themeProjectClassName);
|
|
50
|
+
if ((0, logical_not_1.not)('colorize' in providedCssVariablesMap)) {
|
|
51
|
+
const items = [];
|
|
52
|
+
theme.colorize.forEach((colors, i) => {
|
|
53
|
+
colors.forEach((value, j) => items.push({
|
|
54
|
+
className: colorizeClassName(i, j),
|
|
55
|
+
cssProperties: [
|
|
56
|
+
{
|
|
57
|
+
name: 'background-color',
|
|
58
|
+
value,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
addStyles(`colorize`, items);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.provideCssVariables = provideCssVariables;
|
|
67
|
+
function colorizeClassName(i, j) {
|
|
68
|
+
return `ptnl-colorize-${i}-${j}`;
|
|
69
|
+
}
|
|
70
|
+
exports.colorizeClassName = colorizeClassName;
|
|
71
|
+
const range10 = [...Array(10)].map((_, i) => i);
|
|
72
|
+
function createColorizeColors(source) {
|
|
73
|
+
return source.map((color) => {
|
|
74
|
+
const [r, g, b] = parseColor(color);
|
|
75
|
+
return range10.map((i) => `rgba(${r},${g},${b},${++i > 9 ? '1' : `0.${i}`})`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.createColorizeColors = createColorizeColors;
|
|
79
|
+
const color6hex = /([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})/i;
|
|
80
|
+
const color3hex = /([0-9abcdef])([0-9abcdef])([0-9abcdef])/i;
|
|
81
|
+
function parseColor(source) {
|
|
82
|
+
const [, r, g, b] = source.match(color6hex) ||
|
|
83
|
+
source.match(color3hex) || [, '0', '0', '0'];
|
|
84
|
+
return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
|
|
85
|
+
}
|
|
86
|
+
function addStyles(name, items) {
|
|
87
|
+
const style = document.createElement('style');
|
|
88
|
+
providedCssVariablesMap[name] = style;
|
|
89
|
+
const styleParts = [];
|
|
90
|
+
items.forEach(({ className, cssProperties }) => {
|
|
91
|
+
styleParts.push('.', className, '{\n');
|
|
92
|
+
cssProperties.forEach(({ name, value }) => styleParts.push(' ', name, ': ', value, ';\n'));
|
|
93
|
+
styleParts.push('}\n');
|
|
94
|
+
});
|
|
95
|
+
style.innerHTML = styleParts.join('');
|
|
96
|
+
head.append(style);
|
|
97
|
+
}
|
|
98
|
+
function switchClassName(prev, next) {
|
|
99
|
+
if (prev)
|
|
100
|
+
body.classList.remove(prev);
|
|
101
|
+
body.classList.add(next);
|
|
102
|
+
return next;
|
|
103
|
+
}
|
|
104
|
+
function kebabCase(source) {
|
|
105
|
+
const chars = Array(source.length);
|
|
106
|
+
for (let i = 0, lim = source.length; i < lim; i++) {
|
|
107
|
+
const char = source.charAt(i);
|
|
108
|
+
const lowerCaseChar = char.toLowerCase();
|
|
109
|
+
chars[i] = char === lowerCaseChar ? char : '-' + lowerCaseChar;
|
|
110
|
+
}
|
|
111
|
+
return chars.join('');
|
|
112
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Text, ViewSettingsItem } from '../config';
|
|
2
|
+
export declare enum ViewSettingsItemType {
|
|
3
|
+
Input = "text",
|
|
4
|
+
Checkbox = "checkbox",
|
|
5
|
+
Radio = "radio",
|
|
6
|
+
Select = "select",
|
|
7
|
+
ColorPicker = "color-picker",
|
|
8
|
+
Title = "title",
|
|
9
|
+
TextArea = "textArea"
|
|
10
|
+
}
|
|
11
|
+
export interface ViewSettingsItemValue {
|
|
12
|
+
type: ViewSettingsItemType;
|
|
13
|
+
key: string;
|
|
14
|
+
label: Text;
|
|
15
|
+
defaultValue?: any;
|
|
16
|
+
options?: {
|
|
17
|
+
label: Text;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
span?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const viewSettingsItemValue = "418d9556-a046-4623-be0b-4f4f69ccb783";
|
|
23
|
+
export declare function viewSettingsExtract(viewSettings: ViewSettingsItem[]): ViewSettingsItemValue[];
|
|
24
|
+
export declare function valueConversion(type: ViewSettingsItemType, source: any): any;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.valueConversion = exports.viewSettingsExtract = exports.viewSettingsItemValue = exports.ViewSettingsItemType = void 0;
|
|
4
|
+
var ViewSettingsItemType;
|
|
5
|
+
(function (ViewSettingsItemType) {
|
|
6
|
+
ViewSettingsItemType["Input"] = "text";
|
|
7
|
+
ViewSettingsItemType["Checkbox"] = "checkbox";
|
|
8
|
+
ViewSettingsItemType["Radio"] = "radio";
|
|
9
|
+
ViewSettingsItemType["Select"] = "select";
|
|
10
|
+
ViewSettingsItemType["ColorPicker"] = "color-picker";
|
|
11
|
+
ViewSettingsItemType["Title"] = "title";
|
|
12
|
+
ViewSettingsItemType["TextArea"] = "textArea";
|
|
13
|
+
})(ViewSettingsItemType = exports.ViewSettingsItemType || (exports.ViewSettingsItemType = {}));
|
|
14
|
+
exports.viewSettingsItemValue = '418d9556-a046-4623-be0b-4f4f69ccb783';
|
|
15
|
+
function viewSettingsExtract(viewSettings) {
|
|
16
|
+
return viewSettings
|
|
17
|
+
.map((item) => item[exports.viewSettingsItemValue])
|
|
18
|
+
.map((item) => ({
|
|
19
|
+
type: item.type,
|
|
20
|
+
key: item.key,
|
|
21
|
+
label: item.label,
|
|
22
|
+
defaultValue: valueConversion(item.type, item.defaultValue),
|
|
23
|
+
options: item.options || [],
|
|
24
|
+
span: getSpan(item.span),
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
exports.viewSettingsExtract = viewSettingsExtract;
|
|
28
|
+
function valueConversion(type, source) {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case ViewSettingsItemType.Input:
|
|
31
|
+
case ViewSettingsItemType.Radio:
|
|
32
|
+
case ViewSettingsItemType.Select:
|
|
33
|
+
case ViewSettingsItemType.ColorPicker:
|
|
34
|
+
case ViewSettingsItemType.TextArea:
|
|
35
|
+
return source ? String(source) : '';
|
|
36
|
+
case ViewSettingsItemType.Checkbox:
|
|
37
|
+
return Boolean(source);
|
|
38
|
+
default:
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.valueConversion = valueConversion;
|
|
43
|
+
function getSpan(source) {
|
|
44
|
+
source |= 0;
|
|
45
|
+
if (source > 24)
|
|
46
|
+
return 24;
|
|
47
|
+
if (source < 0)
|
|
48
|
+
return 0;
|
|
49
|
+
return source;
|
|
50
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Locale } from '../config';
|
|
2
|
+
import { Filter, Sort, Target } from '../data';
|
|
3
|
+
import { WidgetRenderEnv } from '../widget';
|
|
4
|
+
import { ThemeProvide } from './theme';
|
|
5
|
+
import { WidgetDataOptionColumn_Server, WidgetRepresent } from './widget';
|
|
6
|
+
export declare enum Input {
|
|
7
|
+
Change = "ptnl.input.change",
|
|
8
|
+
ChangeLang = "ptnl.input.changeLang",
|
|
9
|
+
ChangeTheme = "ptnl.input.changeTheme",
|
|
10
|
+
ChangeOtherFilters = "ptnl.input.ChangeOtherFilters",
|
|
11
|
+
ChangeWidgetRenderEnv = "ptnl.input.changeWidgetRenderEnv"
|
|
12
|
+
}
|
|
13
|
+
export declare enum Output {
|
|
14
|
+
Init = "ptnl.output.init",
|
|
15
|
+
Ready = "ptnl.output.ready",
|
|
16
|
+
SetFilter = "ptnl.output.setFilter",
|
|
17
|
+
RemoveFilterAt = "ptnl.output.RemoveFilterAt",
|
|
18
|
+
SetSort = "ptnl.output.setSort",
|
|
19
|
+
RemoveSortAt = "ptnl.output.RemoveSortAt",
|
|
20
|
+
Interact = "ptnl.output.interact"
|
|
21
|
+
}
|
|
22
|
+
export interface InputParameter extends Record<Input, any> {
|
|
23
|
+
[Input.Change]: WidgetRepresent;
|
|
24
|
+
[Input.ChangeLang]: Locale;
|
|
25
|
+
[Input.ChangeTheme]: ThemeProvide;
|
|
26
|
+
[Input.ChangeOtherFilters]: WidgetDataOptionColumn_Server[];
|
|
27
|
+
[Input.ChangeWidgetRenderEnv]: WidgetRenderEnv;
|
|
28
|
+
}
|
|
29
|
+
export interface OutputParameter extends Record<Output, any> {
|
|
30
|
+
[Output.Init]: void;
|
|
31
|
+
[Output.Ready]: void;
|
|
32
|
+
[Output.SetFilter]: {
|
|
33
|
+
filter: Filter;
|
|
34
|
+
target: Target;
|
|
35
|
+
rowIndex: number;
|
|
36
|
+
};
|
|
37
|
+
[Output.RemoveFilterAt]: {
|
|
38
|
+
index: number;
|
|
39
|
+
};
|
|
40
|
+
[Output.SetSort]: {
|
|
41
|
+
sort: Sort;
|
|
42
|
+
target: Target;
|
|
43
|
+
};
|
|
44
|
+
[Output.RemoveSortAt]: {
|
|
45
|
+
index: number;
|
|
46
|
+
};
|
|
47
|
+
[Output.Interact]: {
|
|
48
|
+
dataOptionId: number;
|
|
49
|
+
dataIndex: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface OutputData {
|
|
53
|
+
token: string;
|
|
54
|
+
type: Output;
|
|
55
|
+
payload?: any;
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Output = exports.Input = void 0;
|
|
4
|
+
var Input;
|
|
5
|
+
(function (Input) {
|
|
6
|
+
Input["Change"] = "ptnl.input.change";
|
|
7
|
+
Input["ChangeLang"] = "ptnl.input.changeLang";
|
|
8
|
+
Input["ChangeTheme"] = "ptnl.input.changeTheme";
|
|
9
|
+
Input["ChangeOtherFilters"] = "ptnl.input.ChangeOtherFilters";
|
|
10
|
+
Input["ChangeWidgetRenderEnv"] = "ptnl.input.changeWidgetRenderEnv";
|
|
11
|
+
})(Input = exports.Input || (exports.Input = {}));
|
|
12
|
+
var Output;
|
|
13
|
+
(function (Output) {
|
|
14
|
+
Output["Init"] = "ptnl.output.init";
|
|
15
|
+
Output["Ready"] = "ptnl.output.ready";
|
|
16
|
+
Output["SetFilter"] = "ptnl.output.setFilter";
|
|
17
|
+
Output["RemoveFilterAt"] = "ptnl.output.RemoveFilterAt";
|
|
18
|
+
Output["SetSort"] = "ptnl.output.setSort";
|
|
19
|
+
Output["RemoveSortAt"] = "ptnl.output.RemoveSortAt";
|
|
20
|
+
Output["Interact"] = "ptnl.output.interact";
|
|
21
|
+
})(Output = exports.Output || (exports.Output = {}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DataSettings } from '../widget';
|
|
2
|
+
import { WidgetRepresent } from './widget';
|
|
3
|
+
export declare type DataSettingsMethods = Pick<DataSettings, 'setFilter' | 'removeFilterAt' | 'setSort' | 'removeSortAt' | 'interact'>;
|
|
4
|
+
export declare function provideDataTo(widget: any, { dataOptionsMap, viewOptions }: WidgetRepresent, dataSettingsMethods?: DataSettingsMethods): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.provideDataTo = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const widget_1 = require("./widget");
|
|
6
|
+
const defaultDataSettingsMethods = {
|
|
7
|
+
setFilter() { },
|
|
8
|
+
removeFilterAt() { },
|
|
9
|
+
setSort() { },
|
|
10
|
+
removeSortAt() { },
|
|
11
|
+
interact() { },
|
|
12
|
+
};
|
|
13
|
+
function provideDataTo(widget, { dataOptionsMap, viewOptions }, dataSettingsMethods = defaultDataSettingsMethods) {
|
|
14
|
+
const widgetMultiData = {};
|
|
15
|
+
const widgetDataSettingsMap = {};
|
|
16
|
+
const formatters = window.parent['format']?.[widget.uid] || {};
|
|
17
|
+
widget.viewSettings = {};
|
|
18
|
+
Object.values(dataOptionsMap).forEach(({ data_option, rows, total }) => {
|
|
19
|
+
widgetMultiData[data_option.key] = rows;
|
|
20
|
+
const columns = data_option.dataset.columns_id.map((source) => ({
|
|
21
|
+
type: source.base_type,
|
|
22
|
+
id: source.id,
|
|
23
|
+
path: source.path,
|
|
24
|
+
format: formatters[source.path] || ((value) => value),
|
|
25
|
+
name: source.name,
|
|
26
|
+
}));
|
|
27
|
+
const columnsByBlock = {};
|
|
28
|
+
const filters = [];
|
|
29
|
+
const sort = [];
|
|
30
|
+
const colorize = [];
|
|
31
|
+
data_option.blocks.forEach((block) => {
|
|
32
|
+
if (block.block_type === config_1.ConfigDataBlockType_Server.Drilldown)
|
|
33
|
+
return;
|
|
34
|
+
switch (block.key) {
|
|
35
|
+
case config_1.blockFilterKey:
|
|
36
|
+
block.columns.forEach(({ column_id, action, value }) => {
|
|
37
|
+
const column = columns.find(({ id }) => column_id === id);
|
|
38
|
+
filters.push({
|
|
39
|
+
column,
|
|
40
|
+
method: action,
|
|
41
|
+
value,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
case config_1.blockSortKey:
|
|
46
|
+
block.columns.forEach(({ column_id, value: direction }) => {
|
|
47
|
+
const column = columns.find(({ id }) => column_id === id);
|
|
48
|
+
sort.push({
|
|
49
|
+
column,
|
|
50
|
+
direction,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
case config_1.blockColorizeKey:
|
|
55
|
+
block.columns.forEach(({ value }) => {
|
|
56
|
+
const source = value;
|
|
57
|
+
const column = columns.find(({ id }) => source.columnId === id);
|
|
58
|
+
colorize.push((0, widget_1.createColorizeItem)(widget, column, source));
|
|
59
|
+
});
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
columnsByBlock[block.key] = block.columns.map(({ column_id }) => {
|
|
63
|
+
return columns.find((item) => item.id === column_id);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const dataSettingsItem = {
|
|
68
|
+
columns,
|
|
69
|
+
columnsByBlock,
|
|
70
|
+
filters,
|
|
71
|
+
sort,
|
|
72
|
+
colorize,
|
|
73
|
+
total,
|
|
74
|
+
limit: data_option.limit_rows,
|
|
75
|
+
offset: data_option.offset,
|
|
76
|
+
...{
|
|
77
|
+
...dataSettingsMethods,
|
|
78
|
+
interact: dataSettingsMethods.interact.bind(data_option),
|
|
79
|
+
},
|
|
80
|
+
...getDataSettingsEvents(widget, data_option.key),
|
|
81
|
+
};
|
|
82
|
+
widgetDataSettingsMap[data_option.key] = dataSettingsItem;
|
|
83
|
+
});
|
|
84
|
+
if (widget_1.widgetDefaultKey in widgetDataSettingsMap) {
|
|
85
|
+
Object.assign(widget, {
|
|
86
|
+
data: widgetMultiData[widget_1.widgetDefaultKey],
|
|
87
|
+
dataSettings: widgetDataSettingsMap[widget_1.widgetDefaultKey],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
Object.assign(widget, {
|
|
92
|
+
data: widgetMultiData,
|
|
93
|
+
dataSettings: widgetDataSettingsMap,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
widget.viewSettings = {};
|
|
97
|
+
viewOptions.forEach(({ key, value }) => (widget.viewSettings[key] = value));
|
|
98
|
+
}
|
|
99
|
+
exports.provideDataTo = provideDataTo;
|
|
100
|
+
function getDataSettingsEvents(widget, key) {
|
|
101
|
+
const dataSettings = key === widget_1.widgetDefaultKey
|
|
102
|
+
? widget.dataSettings
|
|
103
|
+
: widget.dataSettings[key];
|
|
104
|
+
if (dataSettings)
|
|
105
|
+
return {
|
|
106
|
+
events: dataSettings.events,
|
|
107
|
+
};
|
|
108
|
+
else
|
|
109
|
+
return {
|
|
110
|
+
events: {},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DataQueryMethod, DataQueryFunction } from '../config';
|
|
2
|
+
import { Dataset_Server } from './dataset';
|
|
3
|
+
import { ConfigDataBlockType_Server } from './config';
|
|
4
|
+
import { ColorizeItem, Widget } from '../widget';
|
|
5
|
+
import { Column, DataItem } from '../data';
|
|
6
|
+
export declare const widgetDefaultKey = "ffed0a4d-4a9d-417f-b502-eb50142c6956";
|
|
7
|
+
export interface Widget_Server {
|
|
8
|
+
data_options: WidgetDataOption_Server[];
|
|
9
|
+
view_options: WidgetViewOption_Server[];
|
|
10
|
+
}
|
|
11
|
+
export interface WidgetRepresent {
|
|
12
|
+
dataOptionsMap: DatasetMultiData_Server;
|
|
13
|
+
viewOptions: WidgetViewOption_Server[];
|
|
14
|
+
}
|
|
15
|
+
export interface DatasetMultiData_Server {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
data_option: WidgetDataOption_Server;
|
|
18
|
+
rows: DataItem[];
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface WidgetDataOption_Server {
|
|
23
|
+
key: string;
|
|
24
|
+
id: number;
|
|
25
|
+
dataset: Dataset_Server;
|
|
26
|
+
method: DataQueryMethod;
|
|
27
|
+
limit_rows: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
blocks: WidgetDataOptionBlock_Server[];
|
|
30
|
+
}
|
|
31
|
+
export interface WidgetDataOptionParams_Server {
|
|
32
|
+
id?: number;
|
|
33
|
+
dataset_id: number;
|
|
34
|
+
method: DataQueryMethod;
|
|
35
|
+
limit_rows?: number;
|
|
36
|
+
offset?: number;
|
|
37
|
+
key?: string;
|
|
38
|
+
blocks: WidgetDataOptionBlock_Server[];
|
|
39
|
+
}
|
|
40
|
+
export interface WidgetDataOptionColumn_Server {
|
|
41
|
+
column_id: number;
|
|
42
|
+
value?: any;
|
|
43
|
+
action?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface WidgetDataOptionBlock_Server {
|
|
46
|
+
key: string;
|
|
47
|
+
block_type: ConfigDataBlockType_Server;
|
|
48
|
+
function: DataQueryFunction;
|
|
49
|
+
columns: WidgetDataOptionColumn_Server[];
|
|
50
|
+
}
|
|
51
|
+
export interface WidgetViewOption_Server {
|
|
52
|
+
key: string;
|
|
53
|
+
value: any;
|
|
54
|
+
}
|
|
55
|
+
export interface ColorizeSettings_Server {
|
|
56
|
+
columnId: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
min?: number;
|
|
59
|
+
threshold?: number;
|
|
60
|
+
colorAbove?: number;
|
|
61
|
+
colorBelow?: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function createColorizeItem(widget: Widget, column: Column, source: ColorizeSettings_Server): ColorizeItem;
|
|
64
|
+
export declare function dispatchChangeOtherFilters(widget: any, source: WidgetDataOptionColumn_Server[]): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatchChangeOtherFilters = exports.createColorizeItem = exports.widgetDefaultKey = void 0;
|
|
4
|
+
const data_1 = require("../data");
|
|
5
|
+
exports.widgetDefaultKey = 'ffed0a4d-4a9d-417f-b502-eb50142c6956';
|
|
6
|
+
function createColorizeItem(widget, column, source) {
|
|
7
|
+
const max = +source.max || 0;
|
|
8
|
+
const min = +source.min || 0;
|
|
9
|
+
const threshold = +source.threshold || 0;
|
|
10
|
+
const colorAbove = source.colorAbove;
|
|
11
|
+
const colorBelow = source.colorBelow;
|
|
12
|
+
const deltaAbove = max - threshold;
|
|
13
|
+
const deltaBelow = threshold - min;
|
|
14
|
+
return {
|
|
15
|
+
column,
|
|
16
|
+
getColor(value) {
|
|
17
|
+
value = +value || 0;
|
|
18
|
+
if (value > max || value < min)
|
|
19
|
+
return color();
|
|
20
|
+
if (value >= threshold) {
|
|
21
|
+
const colors = widget.theme.colorize[colorAbove] || [];
|
|
22
|
+
if (value === max)
|
|
23
|
+
return color(colors[colors.length - 1]);
|
|
24
|
+
const i = Math.floor(((value - threshold) / deltaAbove) * colors.length);
|
|
25
|
+
return color(colors[i]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const colors = widget.theme.colorize[colorBelow] || [];
|
|
29
|
+
if (value === min)
|
|
30
|
+
return color(colors[colors.length - 1]);
|
|
31
|
+
const i = Math.floor(((threshold - value) / deltaBelow) * colors.length);
|
|
32
|
+
return color(colors[i]);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.createColorizeItem = createColorizeItem;
|
|
38
|
+
function color(source) {
|
|
39
|
+
return source || 'transparent';
|
|
40
|
+
}
|
|
41
|
+
function dispatchChangeOtherFilters(widget, source) {
|
|
42
|
+
source.forEach(({ column_id, value }) => {
|
|
43
|
+
const dataSettings = getDataSettingsByColumnId(widget, column_id);
|
|
44
|
+
if (dataSettings &&
|
|
45
|
+
typeof dataSettings.events.onOtherFilterChange === 'function') {
|
|
46
|
+
const column = dataSettings.columns.find(({ id }) => id === column_id);
|
|
47
|
+
if (column)
|
|
48
|
+
dataSettings.events.onOtherFilterChange({
|
|
49
|
+
column,
|
|
50
|
+
method: data_1.FilterMethod.InList,
|
|
51
|
+
value,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.dispatchChangeOtherFilters = dispatchChangeOtherFilters;
|
|
57
|
+
function getDataSettingsByColumnId(widget, columnId) {
|
|
58
|
+
if (Array.isArray(widget.data))
|
|
59
|
+
return widget.dataSettings;
|
|
60
|
+
for (let dataSettings of Object.values(widget.dataSettings))
|
|
61
|
+
if (dataSettings.columns.find(({ id }) => id === columnId))
|
|
62
|
+
return dataSettings;
|
|
63
|
+
return null;
|
|
64
|
+
}
|