polymatica-widget 0.7.1 → 2.0.3
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/README.md +3 -0
- package/__internal__/io.d.ts +55 -0
- package/__internal__/io.js +16 -0
- package/__internal__/widget-options.d.ts +32 -0
- package/__internal__/widget-options.js +79 -0
- package/{src/config.ts → config.d.ts} +0 -1
- package/config.js +2 -0
- package/dataset.d.ts +16 -0
- package/dataset.js +13 -0
- package/declare.d.ts +1 -0
- package/declare.js +122 -0
- package/{src/index.ts → index.d.ts} +0 -0
- package/index.js +19 -1
- package/locale.d.ts +2 -0
- package/locale.js +2 -0
- package/package.json +3 -12
- package/{src/theme.ts → theme.d.ts} +1 -1
- package/theme.js +2 -0
- package/widget-config.d.ts +133 -0
- package/widget-config.js +79 -0
- package/{src/widget.ts → widget.d.ts} +21 -31
- package/widget.js +10 -0
- package/.prettierrc.json +0 -6
- package/scripts/build.js +0 -23
- package/src/__internal__/io.ts +0 -68
- package/src/__internal__/widget-config.ts +0 -72
- package/src/__internal__/widget-options.ts +0 -83
- package/src/dataset.ts +0 -22
- package/src/declare.ts +0 -186
- package/src/locale.ts +0 -2
- package/src/widget-config.ts +0 -325
- package/tsconfig.json +0 -16
package/src/widget-config.ts
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import { ColumnType } from './dataset';
|
|
2
|
-
import { Text } from './locale';
|
|
3
|
-
import { Options } from './widget';
|
|
4
|
-
import {
|
|
5
|
-
Block,
|
|
6
|
-
BlockType,
|
|
7
|
-
decodeDrilldownData,
|
|
8
|
-
} from './__internal__/widget-config';
|
|
9
|
-
import {
|
|
10
|
-
WidgetOptionConfig,
|
|
11
|
-
WidgetOptionType,
|
|
12
|
-
} from './__internal__/widget-options';
|
|
13
|
-
|
|
14
|
-
// enums
|
|
15
|
-
|
|
16
|
-
export enum DataQueryMethod {
|
|
17
|
-
Table = 'table',
|
|
18
|
-
Aggregate = 'aggregate',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export enum AggregateFunction {
|
|
22
|
-
Group = 'group',
|
|
23
|
-
Sum = 'sum',
|
|
24
|
-
Average = 'avg',
|
|
25
|
-
Min = 'min',
|
|
26
|
-
Max = 'max',
|
|
27
|
-
First = 'first',
|
|
28
|
-
Last = 'last',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export enum Icon {
|
|
32
|
-
AxisX = 'ico://axis-x',
|
|
33
|
-
AxisY = 'ico://axis-y',
|
|
34
|
-
Value = 'ico://value-column',
|
|
35
|
-
Filter = 'ico://filter',
|
|
36
|
-
Sort = 'ico://sort',
|
|
37
|
-
Heatmap = 'ico://heatmap',
|
|
38
|
-
Drilldown = 'ico://drilldown',
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// interfaces
|
|
42
|
-
|
|
43
|
-
export interface WidgetConfig {
|
|
44
|
-
data?: {
|
|
45
|
-
view: DataConfigView | (DataConfigView & WithKey)[];
|
|
46
|
-
request?: DataRequest;
|
|
47
|
-
};
|
|
48
|
-
options?: {
|
|
49
|
-
view: GetWidgetOptionsView;
|
|
50
|
-
default: Options;
|
|
51
|
-
validation?: OptionsValidation;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface DataConfigView {
|
|
56
|
-
blocks: Block[];
|
|
57
|
-
method: DataQueryMethod;
|
|
58
|
-
label?: Text;
|
|
59
|
-
validation?: {
|
|
60
|
-
requiredSome?: string[];
|
|
61
|
-
requiredEvery?: string[];
|
|
62
|
-
};
|
|
63
|
-
repeatable?: boolean;
|
|
64
|
-
min?: number;
|
|
65
|
-
max?: number;
|
|
66
|
-
pagination?: boolean;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface WithKey {
|
|
70
|
-
key: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface DataConfigItem {
|
|
74
|
-
blocks: Block[];
|
|
75
|
-
method: DataQueryMethod;
|
|
76
|
-
rowsLimit: number;
|
|
77
|
-
pagination?: boolean;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type DataConfig =
|
|
81
|
-
| DataConfigItem
|
|
82
|
-
| DataConfigItem[]
|
|
83
|
-
| { [key: string]: DataConfigItem | DataConfigItem[] };
|
|
84
|
-
|
|
85
|
-
export interface DataRequest {
|
|
86
|
-
(viewConfig: DataConfig, options: Options): DataConfig;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// blocks
|
|
90
|
-
|
|
91
|
-
export function data(params: {
|
|
92
|
-
key: string;
|
|
93
|
-
label: Text;
|
|
94
|
-
icon?: string;
|
|
95
|
-
aggregateFunction?: AggregateFunction;
|
|
96
|
-
columnTypes?: ColumnType[];
|
|
97
|
-
max?: number;
|
|
98
|
-
}): Block {
|
|
99
|
-
return Object.assign({ type: BlockType.Data }, params);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function filter(
|
|
103
|
-
params: {
|
|
104
|
-
label?: Text;
|
|
105
|
-
icon?: Icon | string;
|
|
106
|
-
} = {},
|
|
107
|
-
): Block {
|
|
108
|
-
return {
|
|
109
|
-
type: BlockType.Filter,
|
|
110
|
-
label: params.label || {
|
|
111
|
-
ru: 'Фильтры',
|
|
112
|
-
en: 'Filters',
|
|
113
|
-
},
|
|
114
|
-
icon: params.icon || Icon.Filter,
|
|
115
|
-
key: '',
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function sort(
|
|
120
|
-
params: {
|
|
121
|
-
label?: Text;
|
|
122
|
-
icon?: Icon | string;
|
|
123
|
-
} = {},
|
|
124
|
-
): Block {
|
|
125
|
-
return {
|
|
126
|
-
type: BlockType.Sort,
|
|
127
|
-
label: params.label || {
|
|
128
|
-
ru: 'Сортировка',
|
|
129
|
-
en: 'Sort',
|
|
130
|
-
},
|
|
131
|
-
icon: params.icon || Icon.Sort,
|
|
132
|
-
key: '',
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function heatmap(
|
|
137
|
-
params: {
|
|
138
|
-
label?: Text;
|
|
139
|
-
icon?: Icon | string;
|
|
140
|
-
max?: number;
|
|
141
|
-
} = {},
|
|
142
|
-
): Block {
|
|
143
|
-
return {
|
|
144
|
-
type: BlockType.Heatmap,
|
|
145
|
-
label: params.label || {
|
|
146
|
-
ru: 'Тепловая карта',
|
|
147
|
-
en: 'Heatmap',
|
|
148
|
-
},
|
|
149
|
-
icon: params.icon || Icon.Heatmap,
|
|
150
|
-
max: params.max || 0,
|
|
151
|
-
key: '',
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function drilldown(params: {
|
|
156
|
-
source: string;
|
|
157
|
-
additionalFilterSources?: string[];
|
|
158
|
-
label?: Text;
|
|
159
|
-
icon?: Icon | string;
|
|
160
|
-
max?: number;
|
|
161
|
-
}): Block {
|
|
162
|
-
return {
|
|
163
|
-
type: BlockType.Drilldown,
|
|
164
|
-
key: decodeDrilldownData(
|
|
165
|
-
params.source,
|
|
166
|
-
params.additionalFilterSources || [],
|
|
167
|
-
),
|
|
168
|
-
label: params.label || {
|
|
169
|
-
ru: 'Drilldown',
|
|
170
|
-
en: 'Drilldown',
|
|
171
|
-
},
|
|
172
|
-
icon: params.icon || Icon.Drilldown,
|
|
173
|
-
max: params.max || 4,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function rowsLimit(
|
|
178
|
-
params: {
|
|
179
|
-
label?: Text;
|
|
180
|
-
} = {},
|
|
181
|
-
): Block {
|
|
182
|
-
return {
|
|
183
|
-
type: BlockType.RowsLimit,
|
|
184
|
-
label: params.label || {
|
|
185
|
-
ru: 'Количество записей на странице',
|
|
186
|
-
en: 'Rows limit',
|
|
187
|
-
},
|
|
188
|
-
key: '',
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// widget optiosn
|
|
193
|
-
|
|
194
|
-
export const STEP = 48;
|
|
195
|
-
|
|
196
|
-
export interface GetWidgetOptionsView {
|
|
197
|
-
(options: Options, dataConfig?: DataConfig): WidgetOptionConfig[];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function text(params: {
|
|
201
|
-
key: string;
|
|
202
|
-
label: Text;
|
|
203
|
-
span?: number;
|
|
204
|
-
defaultValue?: string;
|
|
205
|
-
}): WidgetOptionConfig {
|
|
206
|
-
return Object.assign({ type: WidgetOptionType.Text }, params);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function number(params: {
|
|
210
|
-
key: string;
|
|
211
|
-
label: Text;
|
|
212
|
-
span?: number;
|
|
213
|
-
defaultValue?: string;
|
|
214
|
-
}): WidgetOptionConfig {
|
|
215
|
-
return Object.assign({ type: WidgetOptionType.Number }, params);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export function integer(params: {
|
|
219
|
-
key: string;
|
|
220
|
-
label: Text;
|
|
221
|
-
span?: number;
|
|
222
|
-
defaultValue?: string;
|
|
223
|
-
}): WidgetOptionConfig {
|
|
224
|
-
return Object.assign({ type: WidgetOptionType.Integer }, params);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function range(params: {
|
|
228
|
-
key: string;
|
|
229
|
-
label: Text;
|
|
230
|
-
span?: number;
|
|
231
|
-
defaultValue?: string;
|
|
232
|
-
}): WidgetOptionConfig {
|
|
233
|
-
return Object.assign({ type: WidgetOptionType.Range }, params);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export function interval(params: {
|
|
237
|
-
key: string;
|
|
238
|
-
label: Text;
|
|
239
|
-
span?: number;
|
|
240
|
-
defaultValue?: string;
|
|
241
|
-
}): WidgetOptionConfig {
|
|
242
|
-
return Object.assign({ type: WidgetOptionType.Interval }, params);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export function date(params: {
|
|
246
|
-
key: string;
|
|
247
|
-
label: Text;
|
|
248
|
-
span?: number;
|
|
249
|
-
defaultValue?: string;
|
|
250
|
-
}): WidgetOptionConfig {
|
|
251
|
-
return Object.assign({ type: WidgetOptionType.Date }, params);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export function time(params: {
|
|
255
|
-
key: string;
|
|
256
|
-
label: Text;
|
|
257
|
-
span?: number;
|
|
258
|
-
defaultValue?: string;
|
|
259
|
-
}): WidgetOptionConfig {
|
|
260
|
-
return Object.assign({ type: WidgetOptionType.Time }, params);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function dateTime(params: {
|
|
264
|
-
key: string;
|
|
265
|
-
label: Text;
|
|
266
|
-
span?: number;
|
|
267
|
-
defaultValue?: string;
|
|
268
|
-
}): WidgetOptionConfig {
|
|
269
|
-
return Object.assign({ type: WidgetOptionType.DateTime }, params);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function checkbox(params: {
|
|
273
|
-
key: string;
|
|
274
|
-
label: Text;
|
|
275
|
-
span?: number;
|
|
276
|
-
defaultValue?: boolean;
|
|
277
|
-
}): WidgetOptionConfig {
|
|
278
|
-
return Object.assign({ type: WidgetOptionType.Checkbox }, params);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export function radio(params: {
|
|
282
|
-
key: string;
|
|
283
|
-
label: Text;
|
|
284
|
-
options: { label: Text; value: string }[];
|
|
285
|
-
span?: number;
|
|
286
|
-
defaultValue?: string;
|
|
287
|
-
}): WidgetOptionConfig {
|
|
288
|
-
return Object.assign({ type: WidgetOptionType.Radio }, params);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export function select(params: {
|
|
292
|
-
key: string;
|
|
293
|
-
label: Text;
|
|
294
|
-
options: { label: Text; value: string }[];
|
|
295
|
-
span?: number;
|
|
296
|
-
defaultValue?: string;
|
|
297
|
-
}): WidgetOptionConfig {
|
|
298
|
-
return Object.assign({ type: WidgetOptionType.Select }, params);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export function colorPicker(params: {
|
|
302
|
-
key: string;
|
|
303
|
-
label: Text;
|
|
304
|
-
span?: number;
|
|
305
|
-
defaultValue?: string;
|
|
306
|
-
}): WidgetOptionConfig {
|
|
307
|
-
return Object.assign({ type: WidgetOptionType.ColorPicker }, params);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export function title(label: Text, description?: Text): WidgetOptionConfig {
|
|
311
|
-
return {
|
|
312
|
-
type: WidgetOptionType.Title,
|
|
313
|
-
label,
|
|
314
|
-
defaultValue: description,
|
|
315
|
-
key: '',
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export interface OptionsValidation {
|
|
320
|
-
[key: string]: OptionsValidator;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export interface OptionsValidator {
|
|
324
|
-
(value: any): Text | null;
|
|
325
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"rootDir": "./src",
|
|
4
|
-
"outDir": "./package",
|
|
5
|
-
"module": "CommonJS",
|
|
6
|
-
"moduleResolution": "Node",
|
|
7
|
-
"target": "ES2017",
|
|
8
|
-
"lib": ["ES2017", "dom"],
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"experimentalDecorators": true,
|
|
11
|
-
"strict": true
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
"include": ["./src/**/*.ts"],
|
|
15
|
-
"exclude": []
|
|
16
|
-
}
|