bmdl-sdk 0.0.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/bin/cli.js +4 -0
- package/bmdl-sdk-0.0.2.tgz +0 -0
- package/dist/config.json +13 -0
- package/dist/index.js +2 -0
- package/dist/sdk.zip +0 -0
- package/dist/viewOptions.json +57 -0
- package/package.json +39 -0
- package/scripts/postbuild.js +81 -0
- package/src/app/App.js +79 -0
- package/src/app/App.tsx +124 -0
- package/src/config.js +17 -0
- package/src/config.ts +13 -0
- package/src/dataOptions.js +42 -0
- package/src/dataOptions.ts +45 -0
- package/src/index.js +79 -0
- package/src/index.ts +101 -0
- package/src/main.js +7 -0
- package/src/main.tsx +4 -0
- package/src/types/custom.js +20 -0
- package/src/types/custom.ts +17 -0
- package/src/types/index.js +21 -0
- package/src/types/index.ts +93 -0
- package/src/viewOptions.js +79 -0
- package/src/viewOptions.ts +68 -0
- package/tsconfig.json +7 -0
- package/vite.config.js +46 -0
- package/vite.config.ts +44 -0
package/src/main.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var App_1 = __importDefault(require("./app/App"));
|
|
7
|
+
exports.default = App_1.default;
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BarEViewKey = exports.GeneralEViewKey = exports.EBlockKey = void 0;
|
|
4
|
+
var EBlockKey;
|
|
5
|
+
(function (EBlockKey) {
|
|
6
|
+
EBlockKey["X"] = "X";
|
|
7
|
+
EBlockKey["Y"] = "Y";
|
|
8
|
+
EBlockKey["S"] = "S";
|
|
9
|
+
})(EBlockKey || (exports.EBlockKey = EBlockKey = {}));
|
|
10
|
+
//
|
|
11
|
+
var GeneralEViewKey;
|
|
12
|
+
(function (GeneralEViewKey) {
|
|
13
|
+
GeneralEViewKey["General"] = "General";
|
|
14
|
+
GeneralEViewKey["Title"] = "Title";
|
|
15
|
+
})(GeneralEViewKey || (exports.GeneralEViewKey = GeneralEViewKey = {}));
|
|
16
|
+
var BarEViewKey;
|
|
17
|
+
(function (BarEViewKey) {
|
|
18
|
+
BarEViewKey["ColType"] = "ColType";
|
|
19
|
+
BarEViewKey["ColorBy"] = "ColorBy";
|
|
20
|
+
})(BarEViewKey || (exports.BarEViewKey = BarEViewKey = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockIcon = exports.DataQueryFunction = exports.ColumnType = void 0;
|
|
4
|
+
var ColumnType;
|
|
5
|
+
(function (ColumnType) {
|
|
6
|
+
ColumnType["String"] = "string";
|
|
7
|
+
ColumnType["Number"] = "number";
|
|
8
|
+
ColumnType["Date"] = "date";
|
|
9
|
+
})(ColumnType || (exports.ColumnType = ColumnType = {}));
|
|
10
|
+
var DataQueryFunction;
|
|
11
|
+
(function (DataQueryFunction) {
|
|
12
|
+
DataQueryFunction["Group"] = "group";
|
|
13
|
+
DataQueryFunction["Sum"] = "sum";
|
|
14
|
+
DataQueryFunction["Avg"] = "avg";
|
|
15
|
+
DataQueryFunction["Count"] = "count";
|
|
16
|
+
})(DataQueryFunction || (exports.DataQueryFunction = DataQueryFunction = {}));
|
|
17
|
+
var BlockIcon;
|
|
18
|
+
(function (BlockIcon) {
|
|
19
|
+
BlockIcon["AxisX"] = "sys:axis-x";
|
|
20
|
+
BlockIcon["AxisY"] = "sys:axis-y";
|
|
21
|
+
})(BlockIcon || (exports.BlockIcon = BlockIcon = {}));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type Locale = 'ru' | 'en'
|
|
2
|
+
|
|
3
|
+
export interface LocalizedText {
|
|
4
|
+
ru: string
|
|
5
|
+
en: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Config {
|
|
9
|
+
label: LocalizedText
|
|
10
|
+
categories: string[]
|
|
11
|
+
icon: string
|
|
12
|
+
preview: string
|
|
13
|
+
version: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum ColumnType {
|
|
17
|
+
String = 'string',
|
|
18
|
+
Number = 'number',
|
|
19
|
+
Date = 'date',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum DataQueryFunction {
|
|
23
|
+
Group = 'group',
|
|
24
|
+
Sum = 'sum',
|
|
25
|
+
Avg = 'avg',
|
|
26
|
+
Count = 'count',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum BlockIcon {
|
|
30
|
+
AxisX = 'sys:axis-x',
|
|
31
|
+
AxisY = 'sys:axis-y',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DataBlock {
|
|
35
|
+
key: string
|
|
36
|
+
queryFn: DataQueryFunction
|
|
37
|
+
label: LocalizedText
|
|
38
|
+
icon?: BlockIcon
|
|
39
|
+
columnTypes: ColumnType[]
|
|
40
|
+
limit?: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type DataOptions = DataBlock[]
|
|
44
|
+
export type CreateDataOptions = () => DataOptions
|
|
45
|
+
|
|
46
|
+
///////////////////
|
|
47
|
+
|
|
48
|
+
export interface ViewOptionBase {
|
|
49
|
+
key: string
|
|
50
|
+
label: LocalizedText
|
|
51
|
+
defaultValue?: any
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CheckboxOption extends ViewOptionBase {
|
|
55
|
+
element: 'checkbox'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface SelectItem {
|
|
59
|
+
label: LocalizedText
|
|
60
|
+
value: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface SelectOption extends ViewOptionBase {
|
|
64
|
+
element: 'select'
|
|
65
|
+
options: SelectItem[]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface InputOption extends ViewOptionBase {
|
|
69
|
+
element: 'input'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GroupOption {
|
|
73
|
+
key: string
|
|
74
|
+
label: LocalizedText
|
|
75
|
+
defaultOpen: boolean
|
|
76
|
+
children: ViewOption[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ViewOption = CheckboxOption | SelectOption | InputOption
|
|
80
|
+
export type ViewOptions = Array<ViewOption | GroupOption>
|
|
81
|
+
export type CreateViewOptions = () => ViewOptions
|
|
82
|
+
|
|
83
|
+
export interface ChartData {
|
|
84
|
+
[key: string]: any
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ComponentProps {
|
|
88
|
+
dataOptions?: DataOptions
|
|
89
|
+
viewOptions?: ViewOptions
|
|
90
|
+
data?: ChartData[]
|
|
91
|
+
locale?: Locale
|
|
92
|
+
onError?: (error: Error) => void
|
|
93
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.createViewOptions = void 0;
|
|
15
|
+
var custom_1 = require("./types/custom");
|
|
16
|
+
var group = function (props) { return props; };
|
|
17
|
+
var checkbox = function (props) { return (__assign({ element: 'checkbox' }, props)); };
|
|
18
|
+
var select = function (props) { return (__assign({ element: 'select' }, props)); };
|
|
19
|
+
var input = function (props) { return (__assign({ element: 'input' }, props)); };
|
|
20
|
+
var colorBy = [
|
|
21
|
+
['red', { ru: 'Красный', en: 'Red' }],
|
|
22
|
+
['blue', { ru: 'Синий', en: 'Blue' }],
|
|
23
|
+
['green', { ru: 'Зеленый', en: 'Green' }],
|
|
24
|
+
];
|
|
25
|
+
var createViewOptions = function () {
|
|
26
|
+
return [
|
|
27
|
+
group({
|
|
28
|
+
key: custom_1.GeneralEViewKey.General,
|
|
29
|
+
label: {
|
|
30
|
+
ru: 'Заголовок',
|
|
31
|
+
en: 'Title',
|
|
32
|
+
},
|
|
33
|
+
defaultOpen: true,
|
|
34
|
+
children: [
|
|
35
|
+
checkbox({
|
|
36
|
+
key: custom_1.GeneralEViewKey.Title,
|
|
37
|
+
label: {
|
|
38
|
+
ru: 'Заголовок',
|
|
39
|
+
en: 'Title',
|
|
40
|
+
},
|
|
41
|
+
defaultValue: true,
|
|
42
|
+
}),
|
|
43
|
+
select({
|
|
44
|
+
key: custom_1.BarEViewKey.ColType,
|
|
45
|
+
label: {
|
|
46
|
+
ru: 'Тип столбцов',
|
|
47
|
+
en: 'Column type',
|
|
48
|
+
},
|
|
49
|
+
options: [
|
|
50
|
+
{
|
|
51
|
+
label: {
|
|
52
|
+
ru: 'Стандартный',
|
|
53
|
+
en: 'Default',
|
|
54
|
+
},
|
|
55
|
+
value: 'default',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: {
|
|
59
|
+
ru: 'Стандартный 2',
|
|
60
|
+
en: 'Default 2',
|
|
61
|
+
},
|
|
62
|
+
value: 'default2',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
defaultValue: 'default',
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
input({
|
|
70
|
+
key: custom_1.BarEViewKey.ColorBy,
|
|
71
|
+
label: {
|
|
72
|
+
ru: 'Цвет элемента',
|
|
73
|
+
en: 'Item color',
|
|
74
|
+
},
|
|
75
|
+
defaultValue: colorBy[0][0],
|
|
76
|
+
}),
|
|
77
|
+
];
|
|
78
|
+
};
|
|
79
|
+
exports.createViewOptions = createViewOptions;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CreateViewOptions } from './types'
|
|
2
|
+
import { BarEViewKey, GeneralEViewKey } from './types/custom'
|
|
3
|
+
|
|
4
|
+
const group = (props: any) => props
|
|
5
|
+
const checkbox = (props: any) => ({ element: 'checkbox', ...props })
|
|
6
|
+
const select = (props: any) => ({ element: 'select', ...props })
|
|
7
|
+
const input = (props: any) => ({ element: 'input', ...props })
|
|
8
|
+
|
|
9
|
+
const colorBy = [
|
|
10
|
+
['red', { ru: 'Красный', en: 'Red' }],
|
|
11
|
+
['blue', { ru: 'Синий', en: 'Blue' }],
|
|
12
|
+
['green', { ru: 'Зеленый', en: 'Green' }],
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const createViewOptions: CreateViewOptions = () => {
|
|
16
|
+
return [
|
|
17
|
+
group({
|
|
18
|
+
key: GeneralEViewKey.General,
|
|
19
|
+
label: {
|
|
20
|
+
ru: 'Заголовок',
|
|
21
|
+
en: 'Title',
|
|
22
|
+
},
|
|
23
|
+
defaultOpen: true,
|
|
24
|
+
children: [
|
|
25
|
+
checkbox({
|
|
26
|
+
key: GeneralEViewKey.Title,
|
|
27
|
+
label: {
|
|
28
|
+
ru: 'Заголовок',
|
|
29
|
+
en: 'Title',
|
|
30
|
+
},
|
|
31
|
+
defaultValue: true,
|
|
32
|
+
}),
|
|
33
|
+
select({
|
|
34
|
+
key: BarEViewKey.ColType,
|
|
35
|
+
label: {
|
|
36
|
+
ru: 'Тип столбцов',
|
|
37
|
+
en: 'Column type',
|
|
38
|
+
},
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
label: {
|
|
42
|
+
ru: 'Стандартный',
|
|
43
|
+
en: 'Default',
|
|
44
|
+
},
|
|
45
|
+
value: 'default',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: {
|
|
49
|
+
ru: 'Стандартный 2',
|
|
50
|
+
en: 'Default 2',
|
|
51
|
+
},
|
|
52
|
+
value: 'default2',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
defaultValue: 'default',
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
}),
|
|
59
|
+
input({
|
|
60
|
+
key: BarEViewKey.ColorBy,
|
|
61
|
+
label: {
|
|
62
|
+
ru: 'Цвет элемента',
|
|
63
|
+
en: 'Item color',
|
|
64
|
+
},
|
|
65
|
+
defaultValue: colorBy[0][0],
|
|
66
|
+
}),
|
|
67
|
+
]
|
|
68
|
+
}
|
package/tsconfig.json
ADDED
package/vite.config.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
7
|
+
var path_1 = require("path");
|
|
8
|
+
var vite_1 = require("vite");
|
|
9
|
+
exports.default = (0, vite_1.defineConfig)({
|
|
10
|
+
plugins: [
|
|
11
|
+
(0, plugin_react_1.default)({
|
|
12
|
+
jsxRuntime: 'classic',
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: (0, path_1.resolve)(__dirname, 'src/main.tsx'),
|
|
18
|
+
name: 'Component',
|
|
19
|
+
fileName: 'index',
|
|
20
|
+
formats: ['iife'],
|
|
21
|
+
},
|
|
22
|
+
rollupOptions: {
|
|
23
|
+
external: ['react'],
|
|
24
|
+
output: {
|
|
25
|
+
globals: {
|
|
26
|
+
react: 'React',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
minify: 'terser',
|
|
31
|
+
terserOptions: {
|
|
32
|
+
compress: {
|
|
33
|
+
global_defs: {
|
|
34
|
+
'process.env.NODE_ENV': 'production',
|
|
35
|
+
'process.browser': true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
format: {
|
|
39
|
+
comments: false,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
server: {
|
|
44
|
+
port: 3000,
|
|
45
|
+
},
|
|
46
|
+
});
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
react({
|
|
8
|
+
jsxRuntime: 'classic',
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
|
|
12
|
+
build: {
|
|
13
|
+
lib: {
|
|
14
|
+
entry: resolve(__dirname, 'src/main.tsx'),
|
|
15
|
+
name: 'Component',
|
|
16
|
+
fileName: 'index',
|
|
17
|
+
formats: ['iife'],
|
|
18
|
+
},
|
|
19
|
+
rollupOptions: {
|
|
20
|
+
external: ['react'],
|
|
21
|
+
output: {
|
|
22
|
+
globals: {
|
|
23
|
+
react: 'React',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
minify: 'terser',
|
|
28
|
+
terserOptions: {
|
|
29
|
+
compress: {
|
|
30
|
+
global_defs: {
|
|
31
|
+
'process.env.NODE_ENV': 'production',
|
|
32
|
+
'process.browser': true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
format: {
|
|
36
|
+
comments: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
server: {
|
|
42
|
+
port: 3000,
|
|
43
|
+
},
|
|
44
|
+
})
|