@nocobase/plugin-charts 0.11.1-alpha.4 → 0.12.0-alpha.1

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 (180) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/{lib → dist}/client/index.d.ts +1 -0
  4. package/dist/client/index.js +3234 -0
  5. package/{lib → dist}/index.d.ts +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/locale/en-US.js +26 -0
  8. package/{src/locale/es-ES.ts → dist/locale/es-ES.js} +22 -18
  9. package/dist/locale/fr-FR.js +5 -0
  10. package/dist/locale/ja-JP.js +5 -0
  11. package/dist/locale/pt-BR.js +26 -0
  12. package/dist/locale/ru-RU.js +5 -0
  13. package/dist/locale/tr-TR.js +5 -0
  14. package/dist/locale/zh-CN.js +65 -0
  15. package/dist/node_modules/json5/dist/index.js +1737 -0
  16. package/dist/node_modules/json5/dist/index.min.js +1 -0
  17. package/dist/node_modules/json5/lib/cli.js +152 -0
  18. package/dist/node_modules/json5/lib/index.d.ts +4 -0
  19. package/dist/node_modules/json5/lib/index.js +1 -0
  20. package/dist/node_modules/json5/lib/parse.d.ts +15 -0
  21. package/dist/node_modules/json5/lib/parse.js +1114 -0
  22. package/dist/node_modules/json5/lib/register.js +13 -0
  23. package/dist/node_modules/json5/lib/require.js +4 -0
  24. package/dist/node_modules/json5/lib/stringify.d.ts +89 -0
  25. package/dist/node_modules/json5/lib/stringify.js +261 -0
  26. package/dist/node_modules/json5/lib/unicode.d.ts +3 -0
  27. package/dist/node_modules/json5/lib/unicode.js +4 -0
  28. package/dist/node_modules/json5/lib/util.d.ts +5 -0
  29. package/dist/node_modules/json5/lib/util.js +35 -0
  30. package/dist/node_modules/json5/package.json +1 -0
  31. package/dist/server/actions/chartsQueries.js +57 -0
  32. package/dist/server/actions/index.js +2 -0
  33. package/dist/server/collections/chartsQueries.js +30 -0
  34. package/dist/server/index.js +11 -0
  35. package/dist/server/plugin.js +66 -0
  36. package/dist/server/query.js +39 -0
  37. package/dist/server/shared/index.js +5 -0
  38. package/package.json +17 -28
  39. package/server.d.ts +2 -3
  40. package/server.js +1 -1
  41. package/lib/client/ChartBlockEngine.js +0 -146
  42. package/lib/client/ChartBlockEngineDesigner.js +0 -293
  43. package/lib/client/ChartBlockInitializer.js +0 -263
  44. package/lib/client/ChartQueryBlockInitializer.js +0 -191
  45. package/lib/client/ChartQueryMetadataProvider.js +0 -91
  46. package/lib/client/DataSetPreviewTable.js +0 -113
  47. package/lib/client/Icons.js +0 -210
  48. package/lib/client/chartRenderComponents/index.js +0 -20
  49. package/lib/client/hooks/index.js +0 -38
  50. package/lib/client/index.js +0 -143
  51. package/lib/client/locale/index.js +0 -37
  52. package/lib/client/select/CustomSelect.js +0 -148
  53. package/lib/client/select/ReadPretty.js +0 -77
  54. package/lib/client/select/index.js +0 -27
  55. package/lib/client/select/shared.js +0 -66
  56. package/lib/client/settings/AddNewQuery.js +0 -270
  57. package/lib/client/settings/ConfigureFields.js +0 -39
  58. package/lib/client/settings/QueriesTable.js +0 -77
  59. package/lib/client/settings/queryTypes.js +0 -77
  60. package/lib/client/settings/schemas/chartsQueries.js +0 -353
  61. package/lib/client/templates/AreaTemplate.js +0 -81
  62. package/lib/client/templates/BarTemplate.js +0 -98
  63. package/lib/client/templates/ColumnTemplate.js +0 -98
  64. package/lib/client/templates/FunnelTemplate.js +0 -82
  65. package/lib/client/templates/LineTemplate.js +0 -89
  66. package/lib/client/templates/PieTemplate.js +0 -87
  67. package/lib/client/templates/RadarTemplate.js +0 -88
  68. package/lib/client/templates/ScatterTemplate.js +0 -107
  69. package/lib/client/templates/TableTemplate.js +0 -54
  70. package/lib/client/templates/index.js +0 -25
  71. package/lib/client/utils.js +0 -50
  72. package/lib/index.js +0 -13
  73. package/lib/locale/en-US.js +0 -29
  74. package/lib/locale/es-ES.js +0 -59
  75. package/lib/locale/fr-FR.js +0 -8
  76. package/lib/locale/ja-JP.js +0 -8
  77. package/lib/locale/pt-BR.js +0 -29
  78. package/lib/locale/ru-RU.js +0 -8
  79. package/lib/locale/tr-TR.js +0 -8
  80. package/lib/locale/zh-CN.js +0 -68
  81. package/lib/server/actions/chartsQueries.js +0 -89
  82. package/lib/server/actions/index.js +0 -1
  83. package/lib/server/collections/chartsQueries.js +0 -33
  84. package/lib/server/index.js +0 -13
  85. package/lib/server/plugin.js +0 -106
  86. package/lib/server/query.js +0 -71
  87. package/lib/server/shared/index.js +0 -8
  88. package/src/client/ChartBlockEngine.tsx +0 -121
  89. package/src/client/ChartBlockEngineDesigner.tsx +0 -248
  90. package/src/client/ChartBlockInitializer.tsx +0 -223
  91. package/src/client/ChartQueryBlockInitializer.tsx +0 -156
  92. package/src/client/ChartQueryMetadataProvider.tsx +0 -64
  93. package/src/client/DataSetPreviewTable.tsx +0 -71
  94. package/src/client/Icons.tsx +0 -99
  95. package/src/client/chartRenderComponents/index.ts +0 -7
  96. package/src/client/hooks/index.ts +0 -19
  97. package/src/client/index.tsx +0 -115
  98. package/src/client/locale/index.ts +0 -18
  99. package/src/client/select/CustomSelect.tsx +0 -126
  100. package/src/client/select/ReadPretty.tsx +0 -39
  101. package/src/client/select/index.md +0 -31
  102. package/src/client/select/index.ts +0 -2
  103. package/src/client/select/shared.ts +0 -37
  104. package/src/client/settings/AddNewQuery.tsx +0 -176
  105. package/src/client/settings/ConfigureFields.tsx +0 -18
  106. package/src/client/settings/QueriesTable.tsx +0 -26
  107. package/src/client/settings/queryTypes.ts +0 -65
  108. package/src/client/settings/schemas/chartsQueries.ts +0 -319
  109. package/src/client/templates/AreaTemplate.tsx +0 -64
  110. package/src/client/templates/BarTemplate.tsx +0 -80
  111. package/src/client/templates/ColumnTemplate.tsx +0 -81
  112. package/src/client/templates/FunnelTemplate.tsx +0 -65
  113. package/src/client/templates/LineTemplate.tsx +0 -72
  114. package/src/client/templates/PieTemplate.tsx +0 -68
  115. package/src/client/templates/RadarTemplate.tsx +0 -71
  116. package/src/client/templates/ScatterTemplate.tsx +0 -90
  117. package/src/client/templates/TableTemplate.tsx +0 -48
  118. package/src/client/templates/index.ts +0 -21
  119. package/src/client/utils.ts +0 -39
  120. package/src/index.ts +0 -1
  121. package/src/locale/en-US.ts +0 -23
  122. package/src/locale/fr-FR.ts +0 -1
  123. package/src/locale/ja-JP.ts +0 -1
  124. package/src/locale/pt-BR.ts +0 -23
  125. package/src/locale/ru-RU.ts +0 -1
  126. package/src/locale/tr-TR.ts +0 -1
  127. package/src/locale/zh-CN.ts +0 -64
  128. package/src/server/actions/chartsQueries.ts +0 -49
  129. package/src/server/actions/index.ts +0 -0
  130. package/src/server/collections/.gitkeep +0 -0
  131. package/src/server/collections/chartsQueries.ts +0 -26
  132. package/src/server/index.ts +0 -1
  133. package/src/server/plugin.ts +0 -61
  134. package/src/server/query.ts +0 -39
  135. package/src/server/shared/index.ts +0 -2
  136. /package/{lib → dist}/client/ChartBlockEngine.d.ts +0 -0
  137. /package/{lib → dist}/client/ChartBlockEngineDesigner.d.ts +0 -0
  138. /package/{lib → dist}/client/ChartBlockInitializer.d.ts +0 -0
  139. /package/{lib → dist}/client/ChartQueryBlockInitializer.d.ts +0 -0
  140. /package/{lib → dist}/client/ChartQueryMetadataProvider.d.ts +0 -0
  141. /package/{lib → dist}/client/DataSetPreviewTable.d.ts +0 -0
  142. /package/{lib → dist}/client/Icons.d.ts +0 -0
  143. /package/{lib → dist}/client/chartRenderComponents/index.d.ts +0 -0
  144. /package/{lib → dist}/client/hooks/index.d.ts +0 -0
  145. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  146. /package/{lib → dist}/client/select/CustomSelect.d.ts +0 -0
  147. /package/{lib → dist}/client/select/ReadPretty.d.ts +0 -0
  148. /package/{lib → dist}/client/select/index.d.ts +0 -0
  149. /package/{lib → dist}/client/select/shared.d.ts +0 -0
  150. /package/{lib → dist}/client/settings/AddNewQuery.d.ts +0 -0
  151. /package/{lib → dist}/client/settings/ConfigureFields.d.ts +0 -0
  152. /package/{lib → dist}/client/settings/QueriesTable.d.ts +0 -0
  153. /package/{lib → dist}/client/settings/queryTypes.d.ts +0 -0
  154. /package/{lib → dist}/client/settings/schemas/chartsQueries.d.ts +0 -0
  155. /package/{lib → dist}/client/templates/AreaTemplate.d.ts +0 -0
  156. /package/{lib → dist}/client/templates/BarTemplate.d.ts +0 -0
  157. /package/{lib → dist}/client/templates/ColumnTemplate.d.ts +0 -0
  158. /package/{lib → dist}/client/templates/FunnelTemplate.d.ts +0 -0
  159. /package/{lib → dist}/client/templates/LineTemplate.d.ts +0 -0
  160. /package/{lib → dist}/client/templates/PieTemplate.d.ts +0 -0
  161. /package/{lib → dist}/client/templates/RadarTemplate.d.ts +0 -0
  162. /package/{lib → dist}/client/templates/ScatterTemplate.d.ts +0 -0
  163. /package/{lib → dist}/client/templates/TableTemplate.d.ts +0 -0
  164. /package/{lib → dist}/client/templates/index.d.ts +0 -0
  165. /package/{lib → dist}/client/utils.d.ts +0 -0
  166. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  167. /package/{lib → dist}/locale/es-ES.d.ts +0 -0
  168. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  169. /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
  170. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  171. /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
  172. /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
  173. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  174. /package/{lib → dist}/server/actions/chartsQueries.d.ts +0 -0
  175. /package/{lib → dist}/server/actions/index.d.ts +0 -0
  176. /package/{lib → dist}/server/collections/chartsQueries.d.ts +0 -0
  177. /package/{lib → dist}/server/index.d.ts +0 -0
  178. /package/{lib → dist}/server/plugin.d.ts +0 -0
  179. /package/{lib → dist}/server/query.d.ts +0 -0
  180. /package/{lib → dist}/server/shared/index.d.ts +0 -0
@@ -1,176 +0,0 @@
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
- ActionContextProvider,
7
- SchemaComponent,
8
- useActionContext,
9
- useRecord,
10
- useResourceActionContext,
11
- useResourceContext,
12
- } from '@nocobase/client';
13
- import { Button, Dropdown, MenuProps } from 'antd';
14
- import React, { useMemo, useState } from 'react';
15
- import { useChartQueryMetadataContext } from '../ChartQueryMetadataProvider';
16
- import { lang } from '../locale';
17
- import { getQueryTypeSchema } from './queryTypes';
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
-
116
- const menu = useMemo<MenuProps>(() => {
117
- return {
118
- onClick: (info) => {
119
- setVisible(true);
120
- form.setValues({ type: info.key });
121
- setSchema(getSchema({ type: info.key }, { form, isNewRecord: true }));
122
- },
123
- items: [
124
- {
125
- key: 'json',
126
- label: 'JSON',
127
- },
128
- {
129
- key: 'sql',
130
- label: 'SQL',
131
- },
132
- {
133
- key: 'api',
134
- label: 'API',
135
- disabled: true,
136
- },
137
- {
138
- key: 'collection',
139
- label: 'Collection',
140
- disabled: true,
141
- },
142
- ],
143
- };
144
- }, [form]);
145
-
146
- return (
147
- <ActionContextProvider value={{ visible, setVisible }}>
148
- <Dropdown menu={menu}>
149
- <Button icon={<PlusOutlined />} type={'primary'}>
150
- {lang('Add query')} <DownOutlined />
151
- </Button>
152
- </Dropdown>
153
- <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} />
154
- </ActionContextProvider>
155
- );
156
- };
157
-
158
- export const EditQuery = () => {
159
- const [visible, setVisible] = useState(false);
160
- const record = useRecord();
161
- const form = useMemo(() => createForm(), []);
162
- const schema = getSchema(record, { form, isNewRecord: false });
163
- return (
164
- <ActionContextProvider value={{ visible, setVisible }}>
165
- <a
166
- onClick={() => {
167
- form.setValues(record);
168
- setVisible(true);
169
- }}
170
- >
171
- {lang('Edit')}
172
- </a>
173
- <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} />
174
- </ActionContextProvider>
175
- );
176
- };
@@ -1,18 +0,0 @@
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
- };
@@ -1,26 +0,0 @@
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
- };
@@ -1,65 +0,0 @@
1
- import { ISchema } from '@formily/react';
2
- import { lodash } from '@nocobase/utils/client';
3
-
4
- export const json: ISchema = {
5
- type: 'object',
6
- properties: {
7
- data: {
8
- title: 'JSON',
9
- required: true,
10
- 'x-component': 'Input.TextArea',
11
- 'x-validator': { json5: true },
12
- 'x-component-props': {
13
- autoSize: {
14
- maxRows: 20,
15
- minRows: 10,
16
- },
17
- },
18
- 'x-decorator': 'FormItem',
19
- },
20
- },
21
- };
22
-
23
- export const sql: ISchema = {
24
- type: 'object',
25
- properties: {
26
- sql: {
27
- title: 'SQL',
28
- required: true,
29
- 'x-component': 'Input.TextArea',
30
- 'x-decorator': 'FormItem',
31
- 'x-validator': {
32
- triggerType: 'onBlur',
33
- validator: '{{validateSQL}}',
34
- },
35
- 'x-component-props': {
36
- autoSize: {
37
- maxRows: 20,
38
- minRows: 10,
39
- },
40
- },
41
- },
42
- },
43
- };
44
-
45
- export const api: ISchema = {
46
- type: 'object',
47
- properties: {
48
- api: {
49
- title: 'API',
50
- required: true,
51
- 'x-component': 'Input',
52
- 'x-decorator': 'FormItem',
53
- },
54
- },
55
- };
56
-
57
- const types = {
58
- json,
59
- sql,
60
- api,
61
- };
62
-
63
- export const getQueryTypeSchema = (type) => {
64
- return lodash.cloneDeep(types[type]);
65
- };
@@ -1,319 +0,0 @@
1
- import { ISchema } from '@formily/react';
2
- import { uid } from '@formily/shared';
3
- import {
4
- useActionContext,
5
- useRecord,
6
- useRequest,
7
- useResourceActionContext,
8
- useResourceContext,
9
- } from '@nocobase/client';
10
- import { useChartQueryMetadataContext } from '../../ChartQueryMetadataProvider';
11
-
12
- const collection = {
13
- name: 'chartsQueries',
14
- fields: [
15
- {
16
- type: 'integer',
17
- name: 'title',
18
- interface: 'input',
19
- uiSchema: {
20
- title: '{{t("Title",{ns:"charts"})}}',
21
- type: 'string',
22
- 'x-component': 'Input',
23
- required: true,
24
- } as ISchema,
25
- },
26
- {
27
- type: 'string',
28
- name: 'type',
29
- interface: 'select',
30
- uiSchema: {
31
- title: '{{t("Type",{ns:"charts"})}}',
32
- type: 'string',
33
- 'x-component': 'Select',
34
- required: true,
35
- enum: [
36
- { label: '{{t("API")}}', value: 'api' },
37
- { label: '{{t("SQL")}}', value: 'sql' },
38
- { label: '{{t("JSON")}}', value: 'json' },
39
- ],
40
- } as ISchema,
41
- },
42
- ],
43
- };
44
-
45
- export const useDestroyQueryItemAction = () => {
46
- const ctx = useChartQueryMetadataContext();
47
- const { refresh } = useResourceActionContext();
48
- const { resource, targetKey } = useResourceContext();
49
- const { [targetKey]: filterByTk } = useRecord();
50
- return {
51
- async run() {
52
- await resource.destroy({ filterByTk });
53
- refresh();
54
- ctx.refresh();
55
- },
56
- };
57
- };
58
-
59
- export const useDestroyAllSelectedQueriesAction = () => {
60
- const ctx = useChartQueryMetadataContext();
61
- const { state, setState, refresh } = useResourceActionContext();
62
- const { resource, targetKey } = useResourceContext();
63
- return {
64
- async run() {
65
- await resource.destroy({
66
- filterByTk: state?.selectedRowKeys || [],
67
- });
68
- setState?.({ selectedRowKeys: [] });
69
- refresh();
70
- ctx.refresh();
71
- },
72
- };
73
- };
74
-
75
- export const chartsQueriesSchema: ISchema = {
76
- type: 'object',
77
- properties: {
78
- [uid()]: {
79
- type: 'void',
80
- 'x-decorator': 'ResourceActionProvider',
81
- 'x-decorator-props': {
82
- collection,
83
- resourceName: 'chartsQueries',
84
- request: {
85
- resource: 'chartsQueries',
86
- action: 'list',
87
- params: {
88
- pageSize: 50,
89
- sort: ['-id'],
90
- appends: [],
91
- },
92
- },
93
- },
94
- 'x-component': 'CollectionProvider',
95
- 'x-component-props': {
96
- collection,
97
- },
98
- properties: {
99
- actions: {
100
- type: 'void',
101
- 'x-component': 'ActionBar',
102
- 'x-component-props': {
103
- style: {
104
- marginBottom: 16,
105
- },
106
- },
107
- properties: {
108
- delete: {
109
- type: 'void',
110
- title: '{{ t("Delete") }}',
111
- 'x-component': 'Action',
112
- 'x-component-props': {
113
- useAction: '{{ useDestroyAllSelectedQueriesAction }}',
114
- confirm: {
115
- title: '{{t("Delete queries",{ns:"charts"})}}',
116
- content: "{{t('Are you sure you want to delete it?')}}",
117
- },
118
- },
119
- },
120
- create: {
121
- type: 'void',
122
- title: '{{t("Add query")}}',
123
- 'x-component': 'AddNewQuery',
124
- 'x-component-props': {
125
- type: 'primary',
126
- },
127
- properties: {
128
- drawer: {
129
- type: 'void',
130
- 'x-component': 'Action.Drawer',
131
- 'x-decorator': 'Form',
132
- 'x-decorator-props': {
133
- useValues(options) {
134
- const ctx = useActionContext();
135
- return useRequest(
136
- () =>
137
- Promise.resolve({
138
- data: {
139
- name: `s_${uid()}`,
140
- },
141
- }),
142
- { ...options, refreshDeps: [ctx.visible] },
143
- );
144
- },
145
- },
146
- title: '{{t("Add query",{ns:"charts"})}}',
147
- properties: {
148
- title: {
149
- 'x-component': 'CollectionField',
150
- 'x-decorator': 'FormItem',
151
- },
152
- type: {
153
- 'x-component': 'CollectionField',
154
- 'x-decorator': 'FormItem',
155
- },
156
- footer: {
157
- type: 'void',
158
- 'x-component': 'Action.Drawer.Footer',
159
- properties: {
160
- cancel: {
161
- title: '{{t("Cancel",{ns:"charts"})}}',
162
- 'x-component': 'Action',
163
- 'x-component-props': {
164
- useAction: '{{ cm.useCancelAction }}',
165
- },
166
- },
167
- submit: {
168
- title: '{{t("Submit",{ns:"charts"})}}',
169
- 'x-component': 'Action',
170
- 'x-component-props': {
171
- type: 'primary',
172
- useAction: '{{ cm.useCreateAction }}',
173
- },
174
- },
175
- },
176
- },
177
- },
178
- },
179
- },
180
- },
181
- },
182
- },
183
- table: {
184
- type: 'void',
185
- 'x-uid': 'input',
186
- 'x-component': 'Table.Void',
187
- 'x-component-props': {
188
- rowKey: 'id',
189
- rowSelection: {
190
- type: 'checkbox',
191
- },
192
- useDataSource: '{{ cm.useDataSourceFromRAC }}',
193
- },
194
- properties: {
195
- title: {
196
- type: 'void',
197
- 'x-decorator': 'Table.Column.Decorator',
198
- 'x-component': 'Table.Column',
199
- properties: {
200
- title: {
201
- type: 'number',
202
- 'x-component': 'CollectionField',
203
- 'x-read-pretty': true,
204
- },
205
- },
206
- },
207
- type: {
208
- type: 'void',
209
- 'x-decorator': 'Table.Column.Decorator',
210
- 'x-component': 'Table.Column',
211
- properties: {
212
- type: {
213
- type: 'string',
214
- 'x-component': 'CollectionField',
215
- 'x-read-pretty': true,
216
- },
217
- },
218
- },
219
- actions: {
220
- type: 'void',
221
- title: '{{t("Actions")}}',
222
- 'x-component': 'Table.Column',
223
- properties: {
224
- actions: {
225
- type: 'void',
226
- 'x-component': 'Space',
227
- 'x-component-props': {
228
- split: '|',
229
- },
230
- properties: {
231
- fields: {
232
- type: 'void',
233
- title: '{{t("Configure fields")}}',
234
- 'x-component': 'Action.Link',
235
- 'x-component-props': {
236
- type: 'primary',
237
- },
238
- properties: {
239
- drawer: {
240
- type: 'void',
241
- 'x-component': 'Action.Drawer',
242
- title: '{{t("Configure fields")}}',
243
- properties: {
244
- configure: {
245
- type: 'void',
246
- 'x-component': 'ConfigureFields',
247
- },
248
- },
249
- },
250
- },
251
- },
252
- update: {
253
- type: 'void',
254
- title: '{{t("Edit")}}',
255
- 'x-component': 'EditQuery',
256
- 'x-component-props': {
257
- type: 'primary',
258
- },
259
- properties: {
260
- drawer: {
261
- type: 'void',
262
- 'x-component': 'Action.Drawer',
263
- 'x-decorator': 'Form',
264
- 'x-decorator-props': {
265
- useValues: '{{ cm.useValuesFromRecord }}',
266
- },
267
- title: '{{t("Edit")}}',
268
- properties: {
269
- title: {
270
- 'x-component': 'CollectionField',
271
- 'x-decorator': 'FormItem',
272
- },
273
- footer: {
274
- type: 'void',
275
- 'x-component': 'Action.Drawer.Footer',
276
- properties: {
277
- cancel: {
278
- title: '{{t("Cancel",{ns:"charts"})}}',
279
- 'x-component': 'Action',
280
- 'x-component-props': {
281
- useAction: '{{ cm.useCancelAction }}',
282
- },
283
- },
284
- submit: {
285
- title: '{{t("Submit",{ns:"charts"})}}',
286
- 'x-component': 'Action',
287
- 'x-component-props': {
288
- type: 'primary',
289
- useAction: '{{ cm.useUpdateAction }}',
290
- },
291
- },
292
- },
293
- },
294
- },
295
- },
296
- },
297
- },
298
- delete: {
299
- type: 'void',
300
- title: '{{ t("Delete") }}',
301
- 'x-component': 'Action.Link',
302
- 'x-component-props': {
303
- confirm: {
304
- title: '{{t("Delete query",{ns:"charts"})}}',
305
- content: "{{t('Are you sure you want to delete it?')}}",
306
- },
307
- useAction: '{{ useDestroyQueryItemAction }}',
308
- },
309
- },
310
- },
311
- },
312
- },
313
- },
314
- },
315
- },
316
- },
317
- },
318
- },
319
- };
@@ -1,64 +0,0 @@
1
- import JSON5 from 'json5';
2
-
3
- const chartConfig = {
4
- yField: '{{metric}}',
5
- xField: '{{dimension}}',
6
- seriesField: '{{category}}',
7
- };
8
-
9
- export const areaTemplate = {
10
- description: '1 「time」or 「Ordered Noun」 field,1 「Numerical」 field,1 「Unordered Noun」 field (optional)',
11
- type: 'Area',
12
- title: 'Area',
13
- iconId: 'icon-area',
14
- group: 2,
15
- renderComponent: 'G2Plot',
16
- defaultChartOptions: chartConfig,
17
- configurableProperties: {
18
- type: 'void',
19
- properties: {
20
- dimension: {
21
- required: true,
22
- type: 'string',
23
- title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
24
- 'x-decorator': 'FormItem',
25
- 'x-component': 'Select',
26
- enum: '{{dataSource}}',
27
- },
28
- metric: {
29
- required: true,
30
- type: 'string',
31
- title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
32
- 'x-decorator': 'FormItem',
33
- 'x-component': 'Select',
34
- enum: '{{dataSource}}',
35
- },
36
- category: {
37
- type: 'string',
38
- title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
39
- 'x-decorator': 'FormItem',
40
- 'x-component': 'Select',
41
- enum: '{{dataSource}}',
42
- },
43
- jsonConfig: {
44
- type: 'void',
45
- 'x-component': 'div',
46
- properties: {
47
- template: {
48
- required: true,
49
- title: '{{t("JSON config",{ns:"charts"})}}',
50
- type: 'string',
51
- default: JSON5.stringify(chartConfig, null, 2),
52
- 'x-decorator': 'FormItem',
53
- 'x-component': 'Input.TextArea',
54
- 'x-component-props': {
55
- autoSize: { minRows: 8, maxRows: 16 },
56
- },
57
- description: '{{jsonConfigDesc("Area | G2Plot","https://g2plot.antv.antgroup.com/api/plots/area")}}',
58
- 'x-validator': { json5: true },
59
- },
60
- },
61
- },
62
- },
63
- },
64
- };