@nocobase/plugin-charts 0.9.1-alpha.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.
Files changed (139) hide show
  1. package/client.d.ts +4 -0
  2. package/client.js +30 -0
  3. package/lib/client/ChartBlockEngine.d.ts +27 -0
  4. package/lib/client/ChartBlockEngine.js +201 -0
  5. package/lib/client/ChartBlockEngineDesigner.d.ts +3 -0
  6. package/lib/client/ChartBlockEngineDesigner.js +348 -0
  7. package/lib/client/ChartBlockInitializer.d.ts +3 -0
  8. package/lib/client/ChartBlockInitializer.js +324 -0
  9. package/lib/client/ChartQueryBlockInitializer.d.ts +9 -0
  10. package/lib/client/ChartQueryBlockInitializer.js +230 -0
  11. package/lib/client/ChartQueryMetadataProvider.d.ts +10 -0
  12. package/lib/client/ChartQueryMetadataProvider.js +118 -0
  13. package/lib/client/DataSetPreviewTable.d.ts +5 -0
  14. package/lib/client/DataSetPreviewTable.js +127 -0
  15. package/lib/client/Icons.d.ts +1 -0
  16. package/lib/client/Icons.js +226 -0
  17. package/lib/client/chartRenderComponents/index.d.ts +2 -0
  18. package/lib/client/chartRenderComponents/index.js +26 -0
  19. package/lib/client/hooks/index.d.ts +4 -0
  20. package/lib/client/hooks/index.js +52 -0
  21. package/lib/client/index.d.ts +4 -0
  22. package/lib/client/index.js +161 -0
  23. package/lib/client/locale/en-US.d.ts +23 -0
  24. package/lib/client/locale/en-US.js +29 -0
  25. package/lib/client/locale/index.d.ts +3 -0
  26. package/lib/client/locale/index.js +46 -0
  27. package/lib/client/locale/ja-JP.d.ts +2 -0
  28. package/lib/client/locale/ja-JP.js +8 -0
  29. package/lib/client/locale/ru-RU.d.ts +2 -0
  30. package/lib/client/locale/ru-RU.js +8 -0
  31. package/lib/client/locale/tr-TR.d.ts +2 -0
  32. package/lib/client/locale/tr-TR.js +8 -0
  33. package/lib/client/locale/zh-CN.d.ts +61 -0
  34. package/lib/client/locale/zh-CN.js +67 -0
  35. package/lib/client/select/CustomSelect.d.ts +11 -0
  36. package/lib/client/select/CustomSelect.js +193 -0
  37. package/lib/client/select/ReadPretty.d.ts +2 -0
  38. package/lib/client/select/ReadPretty.js +102 -0
  39. package/lib/client/select/index.d.ts +2 -0
  40. package/lib/client/select/index.js +31 -0
  41. package/lib/client/select/shared.d.ts +7 -0
  42. package/lib/client/select/shared.js +86 -0
  43. package/lib/client/settings/AddNewQuery.d.ts +2 -0
  44. package/lib/client/settings/AddNewQuery.js +321 -0
  45. package/lib/client/settings/ConfigureFields.d.ts +1 -0
  46. package/lib/client/settings/ConfigureFields.js +51 -0
  47. package/lib/client/settings/QueriesTable.d.ts +1 -0
  48. package/lib/client/settings/QueriesTable.js +108 -0
  49. package/lib/client/settings/queryTypes.d.ts +5 -0
  50. package/lib/client/settings/queryTypes.js +85 -0
  51. package/lib/client/settings/schemas/chartsQueries.d.ts +8 -0
  52. package/lib/client/settings/schemas/chartsQueries.js +378 -0
  53. package/lib/client/templates/AreaTemplate.d.ts +65 -0
  54. package/lib/client/templates/AreaTemplate.js +86 -0
  55. package/lib/client/templates/BarTemplate.d.ts +80 -0
  56. package/lib/client/templates/BarTemplate.js +103 -0
  57. package/lib/client/templates/ColumnTemplate.d.ts +80 -0
  58. package/lib/client/templates/ColumnTemplate.js +103 -0
  59. package/lib/client/templates/FunnelTemplate.d.ts +66 -0
  60. package/lib/client/templates/FunnelTemplate.js +87 -0
  61. package/lib/client/templates/LineTemplate.d.ts +67 -0
  62. package/lib/client/templates/LineTemplate.js +92 -0
  63. package/lib/client/templates/PieTemplate.d.ts +71 -0
  64. package/lib/client/templates/PieTemplate.js +92 -0
  65. package/lib/client/templates/RadarTemplate.d.ts +71 -0
  66. package/lib/client/templates/RadarTemplate.js +93 -0
  67. package/lib/client/templates/ScatterTemplate.d.ts +91 -0
  68. package/lib/client/templates/ScatterTemplate.js +112 -0
  69. package/lib/client/templates/TableTemplate.d.ts +28 -0
  70. package/lib/client/templates/TableTemplate.js +54 -0
  71. package/lib/client/templates/index.d.ts +1 -0
  72. package/lib/client/templates/index.js +33 -0
  73. package/lib/client/utils.d.ts +3 -0
  74. package/lib/client/utils.js +66 -0
  75. package/lib/index.d.ts +1 -0
  76. package/lib/index.js +15 -0
  77. package/lib/server/actions/chartsQueries.d.ts +3 -0
  78. package/lib/server/actions/chartsQueries.js +104 -0
  79. package/lib/server/actions/index.d.ts +1 -0
  80. package/lib/server/actions/index.js +1 -0
  81. package/lib/server/collections/chartsQueries.d.ts +2 -0
  82. package/lib/server/collections/chartsQueries.js +36 -0
  83. package/lib/server/index.d.ts +1 -0
  84. package/lib/server/index.js +15 -0
  85. package/lib/server/plugin.d.ts +14 -0
  86. package/lib/server/plugin.js +142 -0
  87. package/lib/server/query.d.ts +12 -0
  88. package/lib/server/query.js +91 -0
  89. package/lib/server/shared/index.d.ts +2 -0
  90. package/lib/server/shared/index.js +8 -0
  91. package/package.json +14 -0
  92. package/server.d.ts +4 -0
  93. package/server.js +30 -0
  94. package/src/client/ChartBlockEngine.tsx +120 -0
  95. package/src/client/ChartBlockEngineDesigner.tsx +238 -0
  96. package/src/client/ChartBlockInitializer.tsx +216 -0
  97. package/src/client/ChartQueryBlockInitializer.tsx +136 -0
  98. package/src/client/ChartQueryMetadataProvider.tsx +62 -0
  99. package/src/client/DataSetPreviewTable.tsx +73 -0
  100. package/src/client/Icons.tsx +99 -0
  101. package/src/client/chartRenderComponents/index.ts +7 -0
  102. package/src/client/hooks/index.ts +19 -0
  103. package/src/client/index.tsx +101 -0
  104. package/src/client/locale/en-US.ts +23 -0
  105. package/src/client/locale/index.ts +18 -0
  106. package/src/client/locale/ja-JP.ts +1 -0
  107. package/src/client/locale/ru-RU.ts +1 -0
  108. package/src/client/locale/tr-TR.ts +1 -0
  109. package/src/client/locale/zh-CN.ts +63 -0
  110. package/src/client/select/CustomSelect.tsx +127 -0
  111. package/src/client/select/ReadPretty.tsx +36 -0
  112. package/src/client/select/index.md +38 -0
  113. package/src/client/select/index.ts +2 -0
  114. package/src/client/select/shared.ts +36 -0
  115. package/src/client/settings/AddNewQuery.tsx +161 -0
  116. package/src/client/settings/ConfigureFields.tsx +18 -0
  117. package/src/client/settings/QueriesTable.tsx +26 -0
  118. package/src/client/settings/queryTypes.ts +64 -0
  119. package/src/client/settings/schemas/chartsQueries.ts +319 -0
  120. package/src/client/templates/AreaTemplate.tsx +64 -0
  121. package/src/client/templates/BarTemplate.tsx +80 -0
  122. package/src/client/templates/ColumnTemplate.tsx +81 -0
  123. package/src/client/templates/FunnelTemplate.tsx +65 -0
  124. package/src/client/templates/LineTemplate.tsx +72 -0
  125. package/src/client/templates/PieTemplate.tsx +68 -0
  126. package/src/client/templates/RadarTemplate.tsx +71 -0
  127. package/src/client/templates/ScatterTemplate.tsx +90 -0
  128. package/src/client/templates/TableTemplate.tsx +48 -0
  129. package/src/client/templates/index.ts +21 -0
  130. package/src/client/utils.ts +39 -0
  131. package/src/index.ts +1 -0
  132. package/src/server/actions/chartsQueries.ts +44 -0
  133. package/src/server/actions/index.ts +0 -0
  134. package/src/server/collections/.gitkeep +0 -0
  135. package/src/server/collections/chartsQueries.ts +24 -0
  136. package/src/server/index.ts +1 -0
  137. package/src/server/plugin.ts +61 -0
  138. package/src/server/query.ts +39 -0
  139. package/src/server/shared/index.ts +2 -0
@@ -0,0 +1,127 @@
1
+ import { LoadingOutlined } from '@ant-design/icons';
2
+ import { css } from '@emotion/css';
3
+ import { connect, mapProps, mapReadPretty } from '@formily/react';
4
+ import { isValid } from '@formily/shared';
5
+ import { Icon } from '@nocobase/client';
6
+ import type { SelectProps } from 'antd';
7
+ import { Popover, Select as AntdSelect } from 'antd';
8
+ import React from 'react';
9
+ import { lang } from '../locale';
10
+ import { ReadPretty } from './ReadPretty';
11
+
12
+ type Props = SelectProps<any, any> & { objectValue?: boolean; onChange?: (v: any) => void; multiple: boolean };
13
+
14
+ const isEmptyObject = (val: any) => !isValid(val) || (typeof val === 'object' && Object.keys(val).length === 0);
15
+
16
+ const { Option, OptGroup } = AntdSelect;
17
+ const filterOption = (input, option) => (option?.label ?? '').toLowerCase().includes((input || '').toLowerCase());
18
+
19
+ const InternalSelect = connect(
20
+ (props: Props) => {
21
+ const { ...others } = props;
22
+ const { options, ...othersProps } = { ...others };
23
+ const mode = props.mode || props.multiple ? 'multiple' : undefined;
24
+ const group1 = options.filter((option) => option.group === 2);
25
+ const group2 = options.filter((option) => option.group === 1);
26
+ return (
27
+ <AntdSelect
28
+ showSearch
29
+ filterOption={filterOption}
30
+ allowClear
31
+ {...othersProps}
32
+ onChange={(changed) => {
33
+ props.onChange?.(changed === undefined ? null : changed);
34
+ }}
35
+ mode={mode}
36
+ >
37
+ <OptGroup label={lang('Basic charts')}>
38
+ {group1.map((option) => (
39
+ <Option value={option.key} label={lang(option.title)}>
40
+ <Popover
41
+ placement={'right'}
42
+ zIndex={99999999999}
43
+ content={() => (
44
+ <span>
45
+ {lang(option?.description)
46
+ ?.split(',')
47
+ .map((item) => (
48
+ <div>{item}</div>
49
+ ))}
50
+ </span>
51
+ )}
52
+ trigger="hover"
53
+ >
54
+ <div
55
+ className={css`
56
+ display: flex;
57
+ gap: 4px;
58
+ align-items: center;
59
+ `}
60
+ >
61
+ <Icon type={option.iconId} />
62
+ <span role="img" aria-label={lang(option.title)}>
63
+ {lang(option.title)}
64
+ </span>
65
+ </div>
66
+ </Popover>
67
+ </Option>
68
+ ))}
69
+ </OptGroup>
70
+ <OptGroup label={lang('More charts')}>
71
+ {group2.map((option) => (
72
+ <Option value={option.key} label={lang(option.title)}>
73
+ <Popover
74
+ placement={'right'}
75
+ zIndex={99999999999}
76
+ content={() => (
77
+ <span>
78
+ {lang(option?.description)
79
+ ?.split(',')
80
+ .map((item) => (
81
+ <div>{item}</div>
82
+ ))}
83
+ </span>
84
+ )}
85
+ trigger="hover"
86
+ >
87
+ <div
88
+ className={css`
89
+ display: flex;
90
+ gap: 4px;
91
+ align-items: center;
92
+ `}
93
+ >
94
+ <Icon type={option.iconId} />
95
+ <span role="img" aria-label={lang(option.title)}>
96
+ {lang(option.title)}
97
+ </span>
98
+ </div>
99
+ </Popover>
100
+ </Option>
101
+ ))}
102
+ </OptGroup>
103
+ </AntdSelect>
104
+ );
105
+ },
106
+ mapProps(
107
+ {
108
+ dataSource: 'options',
109
+ loading: true,
110
+ },
111
+ (props, field) => {
112
+ return {
113
+ ...props,
114
+ suffixIcon: field?.['loading'] || field?.['validating'] ? <LoadingOutlined /> : props?.suffixIcon,
115
+ };
116
+ },
117
+ ),
118
+ mapReadPretty(ReadPretty),
119
+ );
120
+
121
+ export const CustomSelect = InternalSelect as unknown as typeof InternalSelect & {
122
+ ReadPretty: typeof ReadPretty;
123
+ };
124
+
125
+ CustomSelect.ReadPretty = ReadPretty;
126
+
127
+ export default CustomSelect;
@@ -0,0 +1,36 @@
1
+ import { isArrayField } from '@formily/core';
2
+ import { observer, useField } from '@formily/react';
3
+ import { isValid } from '@formily/shared';
4
+ import { Tag } from 'antd';
5
+ import React from 'react';
6
+ import { defaultFieldNames, getCurrentOptions } from './shared';
7
+ import { useCompile } from '@nocobase/client';
8
+
9
+ type Composed = {
10
+ Select?: React.FC<any>;
11
+ Object?: React.FC<any>;
12
+ };
13
+
14
+ export const ReadPretty = observer((props: any) => {
15
+ const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
16
+ const field = useField<any>();
17
+ const compile = useCompile();
18
+
19
+ if (!isValid(props.value)) {
20
+ return <div />;
21
+ }
22
+ if (isArrayField(field) && field?.value?.length === 0) {
23
+ return <div />;
24
+ }
25
+ const dataSource = field.dataSource || props.options || [];
26
+ const options = getCurrentOptions(field.value, dataSource, fieldNames);
27
+ return (
28
+ <div>
29
+ {options.map((option, key) => (
30
+ <Tag key={key} color={option[fieldNames.color]} icon={option.icon}>
31
+ {compile(option[fieldNames.label])}
32
+ </Tag>
33
+ ))}
34
+ </div>
35
+ );
36
+ });
@@ -0,0 +1,38 @@
1
+ ---
2
+ nav:
3
+ path: /client
4
+ group:
5
+ path: /schema-components
6
+ ---
7
+
8
+ # Select
9
+
10
+ ## Examples
11
+
12
+ ### 单选
13
+
14
+ <code src="./demos/demo1.tsx" />
15
+
16
+ ### 多选
17
+
18
+ <code src="./demos/demo2.tsx" />
19
+
20
+ ### 值为 Object 类型的 Select
21
+
22
+ <code src="./demos/demo3.tsx" />
23
+
24
+ ## API
25
+
26
+ 基于 Ant Design 的 [Select](https://ant.design/components/select/#API),相关扩展属性有:
27
+
28
+ - `objectValue` 值为 object 类型
29
+ - `fieldNames` 默认值有区别
30
+
31
+ ```ts
32
+ export const defaultFieldNames = {
33
+ label: 'label',
34
+ value: 'value',
35
+ color: 'color',
36
+ options: 'children',
37
+ };
38
+ ```
@@ -0,0 +1,2 @@
1
+ export * from './CustomSelect';
2
+ export * from './shared';
@@ -0,0 +1,36 @@
1
+ import { castArray } from 'lodash';
2
+
3
+ export const defaultFieldNames = {
4
+ label: 'label',
5
+ value: 'value',
6
+ color: 'color',
7
+ options: 'children',
8
+ };
9
+
10
+ export const getCurrentOptions = (values, dataSource, fieldNames) => {
11
+ function flatData(data) {
12
+ let newArr = [];
13
+ for (let i = 0; i < data.length; i++) {
14
+ const children = data[i][fieldNames.options];
15
+ if (Array.isArray(children)) {
16
+ newArr.push(...flatData(children));
17
+ }
18
+ newArr.push({ ...data[i] });
19
+ }
20
+ return newArr;
21
+ }
22
+ const result = flatData(dataSource);
23
+ values = castArray(values)
24
+ .filter((item) => item != null)
25
+ .map((val) => (typeof val === 'object' ? val[fieldNames.value] : val));
26
+ const findOptions = (options: any[]) => {
27
+ if (!options) return [];
28
+ let current = [];
29
+ for (const value of values) {
30
+ const option = options.find((v) => v[fieldNames.value] === value) || { value: value, label: value };
31
+ current.push(option);
32
+ }
33
+ return current;
34
+ };
35
+ return findOptions(result);
36
+ };
@@ -0,0 +1,161 @@
1
+ import { DownOutlined, PlusOutlined } from '@ant-design/icons';
2
+ import { createForm } from '@formily/core';
3
+ import { ISchema, useForm } from '@formily/react';
4
+ import { uid } from '@formily/shared';
5
+ import {
6
+ ActionContext,
7
+ SchemaComponent,
8
+ useActionContext,
9
+ useRecord,
10
+ useResourceActionContext,
11
+ useResourceContext,
12
+ } from '@nocobase/client';
13
+ import { Button, Dropdown, Menu } from 'antd';
14
+ import React, { useMemo, useState } from 'react';
15
+ import { useChartQueryMetadataContext } from '../ChartQueryMetadataProvider';
16
+ import { getQueryTypeSchema } from './queryTypes';
17
+ import { lang } from '../locale';
18
+
19
+ const useCreateAction = () => {
20
+ const { setVisible } = useActionContext();
21
+ const form = useForm();
22
+ const { refresh } = useResourceActionContext();
23
+ const { resource } = useResourceContext();
24
+ const ctx = useChartQueryMetadataContext();
25
+ return {
26
+ async run() {
27
+ await form.submit();
28
+ await resource.create({ values: form.values });
29
+ setVisible(false);
30
+ await form.reset();
31
+ refresh();
32
+ ctx.refresh();
33
+ },
34
+ };
35
+ };
36
+
37
+ const useUpdateAction = () => {
38
+ const { setVisible } = useActionContext();
39
+ const form = useForm();
40
+ const { refresh } = useResourceActionContext();
41
+ const { resource, targetKey } = useResourceContext();
42
+ const { [targetKey]: filterByTk } = useRecord();
43
+ const ctx = useChartQueryMetadataContext();
44
+ return {
45
+ async run() {
46
+ await form.submit();
47
+ await resource.update({ filterByTk, values: form.values });
48
+ setVisible(false);
49
+ await form.reset();
50
+ refresh();
51
+ ctx.refresh();
52
+ },
53
+ };
54
+ };
55
+
56
+ const useCloseAction = () => {
57
+ const { setVisible } = useActionContext();
58
+ return {
59
+ async run() {
60
+ setVisible(false);
61
+ },
62
+ };
63
+ };
64
+
65
+ const getSchema = (initialValue, { form, isNewRecord }) => {
66
+ const type = initialValue.type;
67
+ const schema: ISchema = {
68
+ type: 'void',
69
+ name: uid(),
70
+ 'x-component': 'Action.Drawer',
71
+ 'x-decorator': 'Form',
72
+ 'x-decorator-props': {
73
+ form,
74
+ // initialValue: JSON.parse(JSON.stringify(initialValue)),
75
+ },
76
+ title: isNewRecord ? lang('Add query') : lang('Edit query'),
77
+ properties: {
78
+ title: {
79
+ title: lang('Title'),
80
+ required: true,
81
+ 'x-component': 'Input',
82
+ 'x-decorator': 'FormItem',
83
+ },
84
+ options: getQueryTypeSchema(type),
85
+ footer: {
86
+ type: 'void',
87
+ 'x-component': 'Action.Drawer.Footer',
88
+ properties: {
89
+ cancel: {
90
+ 'x-component': 'Action',
91
+ title: lang('Cancel'),
92
+ 'x-component-props': {
93
+ useAction: '{{ useCloseAction }}',
94
+ },
95
+ },
96
+ submit: {
97
+ 'x-component': 'Action',
98
+ title: lang('Submit'),
99
+ 'x-component-props': {
100
+ type: 'primary',
101
+ useAction: '{{ useSubmitAction }}',
102
+ },
103
+ },
104
+ },
105
+ },
106
+ },
107
+ };
108
+ return schema;
109
+ };
110
+
111
+ export const AddNewQuery = () => {
112
+ const [visible, setVisible] = useState(false);
113
+ const [schema, setSchema] = useState({});
114
+ const form = useMemo(() => createForm(), []);
115
+ const menu = (
116
+ <Menu
117
+ onClick={(info) => {
118
+ setVisible(true);
119
+ form.setValues({ type: info.key });
120
+ setSchema(getSchema({ type: info.key }, { form, isNewRecord: true }));
121
+ }}
122
+ >
123
+ <Menu.Item key={'json'}>JSON</Menu.Item>
124
+ <Menu.Item key={'sql'}>SQL</Menu.Item>
125
+ <Menu.Item disabled key={'api'}>
126
+ API
127
+ </Menu.Item>
128
+ <Menu.Item disabled>Collection</Menu.Item>
129
+ </Menu>
130
+ );
131
+ return (
132
+ <ActionContext.Provider value={{ visible, setVisible }}>
133
+ <Dropdown overlay={menu}>
134
+ <Button icon={<PlusOutlined />} type={'primary'}>
135
+ {lang('Add query')} <DownOutlined />
136
+ </Button>
137
+ </Dropdown>
138
+ <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} />
139
+ </ActionContext.Provider>
140
+ );
141
+ };
142
+
143
+ export const EditQuery = () => {
144
+ const [visible, setVisible] = useState(false);
145
+ const record = useRecord();
146
+ const form = useMemo(() => createForm(), []);
147
+ const schema = getSchema(record, { form, isNewRecord: false });
148
+ return (
149
+ <ActionContext.Provider value={{ visible, setVisible }}>
150
+ <a
151
+ onClick={() => {
152
+ form.setValues(record);
153
+ setVisible(true);
154
+ }}
155
+ >
156
+ {lang('Edit')}
157
+ </a>
158
+ <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} />
159
+ </ActionContext.Provider>
160
+ );
161
+ };
@@ -0,0 +1,18 @@
1
+ import { useRecord } from '@nocobase/client';
2
+ import { Table } from 'antd';
3
+ import React from 'react';
4
+
5
+ export const ConfigureFields = () => {
6
+ const record = useRecord();
7
+ return (
8
+ <Table
9
+ columns={[
10
+ {
11
+ title: '字段标识',
12
+ dataIndex: 'name',
13
+ },
14
+ ]}
15
+ dataSource={record.fields || []}
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,26 @@
1
+ import { SchemaComponent } from '@nocobase/client';
2
+ import { Card } from 'antd';
3
+ import React, { useState } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { AddNewQuery, EditQuery } from './AddNewQuery';
6
+ import { ConfigureFields } from './ConfigureFields';
7
+ import {
8
+ chartsQueriesSchema,
9
+ useDestroyAllSelectedQueriesAction,
10
+ useDestroyQueryItemAction,
11
+ } from './schemas/chartsQueries';
12
+ import JSON5 from 'json5';
13
+
14
+ export const QueriesTable = () => {
15
+ const [visible, setVisible] = useState(false);
16
+ const { t } = useTranslation();
17
+ return (
18
+ <Card bordered={false}>
19
+ <SchemaComponent
20
+ scope={{ JSON5, useDestroyQueryItemAction, useDestroyAllSelectedQueriesAction }}
21
+ schema={chartsQueriesSchema}
22
+ components={{ AddNewQuery, EditQuery, ConfigureFields }}
23
+ />
24
+ </Card>
25
+ );
26
+ };
@@ -0,0 +1,64 @@
1
+ import { ISchema } from '@formily/react';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
+ export const json: ISchema = {
4
+ type: 'object',
5
+ properties: {
6
+ data: {
7
+ title: 'JSON',
8
+ required: true,
9
+ 'x-component': 'Input.TextArea',
10
+ 'x-validator': { json5: true },
11
+ 'x-component-props': {
12
+ autoSize: {
13
+ maxRows: 20,
14
+ minRows: 10,
15
+ },
16
+ },
17
+ 'x-decorator': 'FormItem',
18
+ },
19
+ },
20
+ };
21
+
22
+ export const sql: ISchema = {
23
+ type: 'object',
24
+ properties: {
25
+ sql: {
26
+ title: 'SQL',
27
+ required: true,
28
+ 'x-component': 'Input.TextArea',
29
+ 'x-decorator': 'FormItem',
30
+ 'x-validator': {
31
+ triggerType: 'onBlur',
32
+ validator: '{{validateSQL}}',
33
+ },
34
+ 'x-component-props': {
35
+ autoSize: {
36
+ maxRows: 20,
37
+ minRows: 10,
38
+ },
39
+ },
40
+ },
41
+ },
42
+ };
43
+
44
+ export const api: ISchema = {
45
+ type: 'object',
46
+ properties: {
47
+ api: {
48
+ title: 'API',
49
+ required: true,
50
+ 'x-component': 'Input',
51
+ 'x-decorator': 'FormItem',
52
+ },
53
+ },
54
+ };
55
+
56
+ const types = {
57
+ json,
58
+ sql,
59
+ api,
60
+ };
61
+
62
+ export const getQueryTypeSchema = (type) => {
63
+ return cloneDeep(types[type]);
64
+ };