polymatica-widget 2.1.2 → 2.1.4
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__/widget-options.d.ts +2 -0
- package/__internal__/widget-options.js +8 -3
- package/config.d.ts +18 -22
- package/config.js +28 -30
- package/package.json +1 -1
|
@@ -29,5 +29,7 @@ export interface WidgetOptionConfig {
|
|
|
29
29
|
}[];
|
|
30
30
|
span?: number;
|
|
31
31
|
}
|
|
32
|
+
export declare const widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
|
|
33
|
+
export declare function setWidgetOptionsTarget(options: WidgetOptionConfig[]): void;
|
|
32
34
|
export declare function valueConversion(type: WidgetOptionType, source: any): any;
|
|
33
35
|
export declare function getSpan(source?: number): number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSpan = exports.valueConversion = exports.WidgetOptionType = void 0;
|
|
3
|
+
exports.getSpan = exports.valueConversion = exports.setWidgetOptionsTarget = exports.widgetOptionsTargetKey = exports.WidgetOptionType = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
var WidgetOptionType;
|
|
6
6
|
(function (WidgetOptionType) {
|
|
@@ -25,6 +25,11 @@ var WidgetOptionType;
|
|
|
25
25
|
WidgetOptionType["Select"] = "select";
|
|
26
26
|
WidgetOptionType["ColorPicker"] = "color-picker";
|
|
27
27
|
})(WidgetOptionType = exports.WidgetOptionType || (exports.WidgetOptionType = {}));
|
|
28
|
+
exports.widgetOptionsTargetKey = "6ba1fa0f-7eab-49f8-80ef-0fed376661e2";
|
|
29
|
+
function setWidgetOptionsTarget(options) {
|
|
30
|
+
global[exports.widgetOptionsTargetKey] = options;
|
|
31
|
+
}
|
|
32
|
+
exports.setWidgetOptionsTarget = setWidgetOptionsTarget;
|
|
28
33
|
function valueConversion(type, source) {
|
|
29
34
|
switch (type) {
|
|
30
35
|
case WidgetOptionType.Text:
|
|
@@ -73,8 +78,8 @@ function getSpan(source) {
|
|
|
73
78
|
const span = source | 0;
|
|
74
79
|
if (span > config_1.STEP)
|
|
75
80
|
return config_1.STEP;
|
|
76
|
-
if (span
|
|
77
|
-
return
|
|
81
|
+
if (span <= 0)
|
|
82
|
+
return config_1.STEP;
|
|
78
83
|
return span;
|
|
79
84
|
}
|
|
80
85
|
exports.getSpan = getSpan;
|
package/config.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ColumnType } from "./dataset";
|
|
2
2
|
import { Text } from "./locale";
|
|
3
3
|
import { Options } from "./widget";
|
|
4
|
-
import { WidgetOptionConfig } from "./__internal__/widget-options";
|
|
5
4
|
export declare enum Size {
|
|
6
5
|
Small = "small",
|
|
7
6
|
Medium = "medium",
|
|
@@ -55,7 +54,7 @@ export interface Block {
|
|
|
55
54
|
}
|
|
56
55
|
export interface OptionsConfig {
|
|
57
56
|
options: {
|
|
58
|
-
provider(options: Options, data: unknown):
|
|
57
|
+
provider(options: Options, data: unknown): void;
|
|
59
58
|
default: Options;
|
|
60
59
|
validators?: OptionsValidation;
|
|
61
60
|
};
|
|
@@ -73,63 +72,60 @@ interface Column {
|
|
|
73
72
|
readonly name: string;
|
|
74
73
|
readonly type: ColumnType;
|
|
75
74
|
}
|
|
76
|
-
declare class Option {
|
|
77
|
-
constructor(config: WidgetOptionConfig);
|
|
78
|
-
}
|
|
79
75
|
export declare const STEP = 24;
|
|
80
76
|
export declare function title(label: Text, params?: {
|
|
81
77
|
hint: Text;
|
|
82
|
-
}):
|
|
78
|
+
}): void;
|
|
83
79
|
export declare function label(label: Text, params?: {
|
|
84
80
|
hint: Text;
|
|
85
|
-
}):
|
|
86
|
-
export declare function spacer(span: number):
|
|
87
|
-
export declare function line():
|
|
81
|
+
}): void;
|
|
82
|
+
export declare function spacer(span: number): void;
|
|
83
|
+
export declare function line(): void;
|
|
88
84
|
export declare function text(params: {
|
|
89
85
|
key: string;
|
|
90
86
|
label: Text;
|
|
91
87
|
span?: number;
|
|
92
|
-
}):
|
|
88
|
+
}): void;
|
|
93
89
|
export declare function number(params: {
|
|
94
90
|
key: string;
|
|
95
91
|
label: Text;
|
|
96
92
|
span?: number;
|
|
97
|
-
}):
|
|
93
|
+
}): void;
|
|
98
94
|
export declare function integer(params: {
|
|
99
95
|
key: string;
|
|
100
96
|
label: Text;
|
|
101
97
|
span?: number;
|
|
102
|
-
}):
|
|
98
|
+
}): void;
|
|
103
99
|
export declare function range(params: {
|
|
104
100
|
key: string;
|
|
105
101
|
label: Text;
|
|
106
102
|
span?: number;
|
|
107
|
-
}):
|
|
103
|
+
}): void;
|
|
108
104
|
export declare function interval(params: {
|
|
109
105
|
key: string;
|
|
110
106
|
label: Text;
|
|
111
107
|
span?: number;
|
|
112
|
-
}):
|
|
108
|
+
}): void;
|
|
113
109
|
export declare function date(params: {
|
|
114
110
|
key: string;
|
|
115
111
|
label: Text;
|
|
116
112
|
span?: number;
|
|
117
|
-
}):
|
|
113
|
+
}): void;
|
|
118
114
|
export declare function time(params: {
|
|
119
115
|
key: string;
|
|
120
116
|
label: Text;
|
|
121
117
|
span?: number;
|
|
122
|
-
}):
|
|
118
|
+
}): void;
|
|
123
119
|
export declare function dateTime(params: {
|
|
124
120
|
key: string;
|
|
125
121
|
label: Text;
|
|
126
122
|
span?: number;
|
|
127
|
-
}):
|
|
123
|
+
}): void;
|
|
128
124
|
export declare function checkbox(params: {
|
|
129
125
|
key: string;
|
|
130
126
|
label: Text;
|
|
131
127
|
span?: number;
|
|
132
|
-
}):
|
|
128
|
+
}): void;
|
|
133
129
|
export declare function radio(params: {
|
|
134
130
|
key: string;
|
|
135
131
|
label: Text;
|
|
@@ -138,7 +134,7 @@ export declare function radio(params: {
|
|
|
138
134
|
value: string;
|
|
139
135
|
}[];
|
|
140
136
|
span?: number;
|
|
141
|
-
}):
|
|
137
|
+
}): void;
|
|
142
138
|
export declare function radioButton(params: {
|
|
143
139
|
key: string;
|
|
144
140
|
label: Text;
|
|
@@ -147,7 +143,7 @@ export declare function radioButton(params: {
|
|
|
147
143
|
value: string;
|
|
148
144
|
}[];
|
|
149
145
|
span?: number;
|
|
150
|
-
}):
|
|
146
|
+
}): void;
|
|
151
147
|
export declare function select(params: {
|
|
152
148
|
key: string;
|
|
153
149
|
label: Text;
|
|
@@ -156,12 +152,12 @@ export declare function select(params: {
|
|
|
156
152
|
value: string;
|
|
157
153
|
}[];
|
|
158
154
|
span?: number;
|
|
159
|
-
}):
|
|
155
|
+
}): void;
|
|
160
156
|
export declare function colorPicker(params: {
|
|
161
157
|
key: string;
|
|
162
158
|
label: Text;
|
|
163
159
|
span?: number;
|
|
164
|
-
}):
|
|
160
|
+
}): void;
|
|
165
161
|
export interface OptionsValidation {
|
|
166
162
|
[key: string]: OptionsValidator;
|
|
167
163
|
}
|
package/config.js
CHANGED
|
@@ -16,93 +16,91 @@ var Method;
|
|
|
16
16
|
Method["PivotTable"] = "pivot";
|
|
17
17
|
})(Method = exports.Method || (exports.Method = {}));
|
|
18
18
|
// widget options
|
|
19
|
-
class Option {
|
|
20
|
-
constructor(config) {
|
|
21
|
-
const value = Object.seal(config);
|
|
22
|
-
Object.defineProperty(this, "toJSON", {
|
|
23
|
-
value() {
|
|
24
|
-
return value;
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
19
|
exports.STEP = 24;
|
|
30
20
|
// layout
|
|
31
21
|
function title(label, params) {
|
|
32
22
|
const options = [];
|
|
33
23
|
if (params === null || params === void 0 ? void 0 : params.hint)
|
|
34
24
|
options.push({ label: params.hint, value: 0 });
|
|
35
|
-
|
|
25
|
+
push({
|
|
26
|
+
type: widget_options_1.WidgetOptionType.Title,
|
|
27
|
+
label,
|
|
28
|
+
options,
|
|
29
|
+
});
|
|
36
30
|
}
|
|
37
31
|
exports.title = title;
|
|
38
32
|
function label(label, params) {
|
|
39
33
|
const options = [];
|
|
40
34
|
if (params === null || params === void 0 ? void 0 : params.hint)
|
|
41
35
|
options.push({ label: params.hint, value: 0 });
|
|
42
|
-
|
|
36
|
+
push({
|
|
37
|
+
type: widget_options_1.WidgetOptionType.Label,
|
|
38
|
+
label,
|
|
39
|
+
options,
|
|
40
|
+
});
|
|
43
41
|
}
|
|
44
42
|
exports.label = label;
|
|
45
43
|
function spacer(span) {
|
|
46
|
-
|
|
44
|
+
push({ type: widget_options_1.WidgetOptionType.Spacer, span });
|
|
47
45
|
}
|
|
48
46
|
exports.spacer = spacer;
|
|
49
47
|
function line() {
|
|
50
|
-
|
|
51
|
-
type: widget_options_1.WidgetOptionType.LineHorizontal,
|
|
52
|
-
span: 0,
|
|
53
|
-
});
|
|
48
|
+
push({ type: widget_options_1.WidgetOptionType.LineHorizontal });
|
|
54
49
|
}
|
|
55
50
|
exports.line = line;
|
|
56
51
|
// controls
|
|
57
52
|
function text(params) {
|
|
58
|
-
|
|
53
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Text }));
|
|
59
54
|
}
|
|
60
55
|
exports.text = text;
|
|
61
56
|
function number(params) {
|
|
62
|
-
|
|
57
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Number }));
|
|
63
58
|
}
|
|
64
59
|
exports.number = number;
|
|
65
60
|
function integer(params) {
|
|
66
|
-
|
|
61
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Integer }));
|
|
67
62
|
}
|
|
68
63
|
exports.integer = integer;
|
|
69
64
|
function range(params) {
|
|
70
|
-
|
|
65
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Range }));
|
|
71
66
|
}
|
|
72
67
|
exports.range = range;
|
|
73
68
|
function interval(params) {
|
|
74
|
-
|
|
69
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Interval }));
|
|
75
70
|
}
|
|
76
71
|
exports.interval = interval;
|
|
77
72
|
function date(params) {
|
|
78
|
-
|
|
73
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Date }));
|
|
79
74
|
}
|
|
80
75
|
exports.date = date;
|
|
81
76
|
function time(params) {
|
|
82
|
-
|
|
77
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Time }));
|
|
83
78
|
}
|
|
84
79
|
exports.time = time;
|
|
85
80
|
function dateTime(params) {
|
|
86
|
-
|
|
81
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.DateTime }));
|
|
87
82
|
}
|
|
88
83
|
exports.dateTime = dateTime;
|
|
89
84
|
function checkbox(params) {
|
|
90
|
-
|
|
85
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Checkbox }));
|
|
91
86
|
}
|
|
92
87
|
exports.checkbox = checkbox;
|
|
93
88
|
function radio(params) {
|
|
94
|
-
|
|
89
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Radio }));
|
|
95
90
|
}
|
|
96
91
|
exports.radio = radio;
|
|
97
92
|
function radioButton(params) {
|
|
98
|
-
|
|
93
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.RadioButtons }));
|
|
99
94
|
}
|
|
100
95
|
exports.radioButton = radioButton;
|
|
101
96
|
function select(params) {
|
|
102
|
-
|
|
97
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.Select }));
|
|
103
98
|
}
|
|
104
99
|
exports.select = select;
|
|
105
100
|
function colorPicker(params) {
|
|
106
|
-
|
|
101
|
+
push(Object.assign(Object.assign({}, params), { type: widget_options_1.WidgetOptionType.ColorPicker }));
|
|
107
102
|
}
|
|
108
103
|
exports.colorPicker = colorPicker;
|
|
104
|
+
function push(option) {
|
|
105
|
+
const target = global[widget_options_1.widgetOptionsTargetKey];
|
|
106
|
+
}
|