@nocobase/plugin-charts 0.9.4-alpha.2 → 0.10.0-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.
- package/lib/client/ChartBlockEngine.d.ts +3 -2
- package/lib/client/ChartBlockEngineDesigner.d.ts +4 -3
- package/lib/client/ChartBlockInitializer.d.ts +2 -2
- package/lib/client/ChartBlockInitializer.js +2 -0
- package/lib/client/ChartQueryBlockInitializer.d.ts +2 -1
- package/lib/client/DataSetPreviewTable.d.ts +2 -1
- package/lib/client/hooks/index.js +1 -1
- package/lib/client/index.d.ts +2 -2
- package/lib/client/index.js +3 -1
- package/lib/client/select/ReadPretty.d.ts +1 -1
- package/lib/client/select/ReadPretty.js +2 -0
- package/lib/client/settings/AddNewQuery.d.ts +3 -2
- package/lib/client/settings/AddNewQuery.js +2 -2
- package/lib/client/settings/ConfigureFields.d.ts +2 -1
- package/lib/client/settings/QueriesTable.d.ts +2 -1
- package/package.json +9 -5
- package/src/client/ChartBlockInitializer.tsx +21 -18
- package/src/client/hooks/index.ts +1 -1
- package/src/client/index.tsx +5 -2
- package/src/client/select/ReadPretty.tsx +25 -22
- package/src/client/select/index.md +3 -10
- package/src/client/settings/AddNewQuery.tsx +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface IQueryConfig {
|
|
2
3
|
id: number;
|
|
3
4
|
}
|
|
@@ -21,7 +22,7 @@ export declare const useGetDataSet: (chartQueryId: number) => {
|
|
|
21
22
|
declare const ChartBlockEngine: {
|
|
22
23
|
({ chartBlockEngineMetaData }: {
|
|
23
24
|
chartBlockEngineMetaData: ChartBlockEngineMetaData;
|
|
24
|
-
}): JSX.Element;
|
|
25
|
-
Designer: () => JSX.Element;
|
|
25
|
+
}): React.JSX.Element;
|
|
26
|
+
Designer: () => React.JSX.Element;
|
|
26
27
|
};
|
|
27
28
|
export { ChartBlockEngine };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const jsonConfigDesc: (title: string, link: string) => React.JSX.Element;
|
|
3
|
+
export declare const ChartBlockEngineDesigner: () => React.JSX.Element;
|
|
4
|
+
export declare const ChartBlockEngineDesignerInitializer: (props: any) => React.JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const Options: React.MemoExoticComponent<
|
|
3
|
-
export declare const ChartBlockInitializer: (props: any) => JSX.Element;
|
|
2
|
+
export declare const Options: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
|
|
3
|
+
export declare const ChartBlockInitializer: (props: any) => React.JSX.Element;
|
|
@@ -100,6 +100,8 @@ const Options = (0, _react().observer)(props => {
|
|
|
100
100
|
return _react2().default.createElement(_react().RecursionField, {
|
|
101
101
|
schema: s
|
|
102
102
|
});
|
|
103
|
+
}, {
|
|
104
|
+
displayName: 'Options'
|
|
103
105
|
});
|
|
104
106
|
exports.Options = Options;
|
|
105
107
|
const ChartBlockInitializer = props => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface ChartQueryMetadata {
|
|
2
3
|
id: number;
|
|
3
4
|
title: string;
|
|
@@ -6,4 +7,4 @@ export interface ChartQueryMetadata {
|
|
|
6
7
|
name: string;
|
|
7
8
|
}[];
|
|
8
9
|
}
|
|
9
|
-
export declare const ChartQueryBlockInitializer: (props: any) => JSX.Element;
|
|
10
|
+
export declare const ChartQueryBlockInitializer: (props: any) => React.JSX.Element;
|
|
@@ -28,7 +28,7 @@ const useFieldsById = queryId => {
|
|
|
28
28
|
const chartQueryList = ctx === null || ctx === void 0 ? void 0 : ctx.data;
|
|
29
29
|
if (chartQueryList && Array.isArray(chartQueryList)) {
|
|
30
30
|
const currentQuery = chartQueryList.find(chartQuery => chartQuery.id === queryId);
|
|
31
|
-
setFields(currentQuery === null || currentQuery === void 0 ? void 0 : currentQuery.fields);
|
|
31
|
+
setFields((currentQuery === null || currentQuery === void 0 ? void 0 : currentQuery.fields) || []);
|
|
32
32
|
}
|
|
33
33
|
}, [queryId]);
|
|
34
34
|
return {
|
package/lib/client/index.d.ts
CHANGED
package/lib/client/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
-
|
|
68
|
+
const Charts = _react().default.memo(props => {
|
|
69
69
|
const api = (0, _client().useAPIClient)();
|
|
70
70
|
const items = (0, _react().useContext)(_client().SchemaInitializerContext);
|
|
71
71
|
const children = items.BlockInitializers.items[0].children;
|
|
@@ -125,4 +125,6 @@ var _default = _react().default.memo(props => {
|
|
|
125
125
|
value: items
|
|
126
126
|
}, props.children))));
|
|
127
127
|
});
|
|
128
|
+
Charts.displayName = 'Charts';
|
|
129
|
+
var _default = Charts;
|
|
128
130
|
exports.default = _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const ReadPretty: React.MemoExoticComponent<
|
|
2
|
+
export declare const ReadPretty: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const AddNewQuery: () => React.JSX.Element;
|
|
3
|
+
export declare const EditQuery: () => React.JSX.Element;
|
|
@@ -211,7 +211,7 @@ const AddNewQuery = () => {
|
|
|
211
211
|
}, "API"), _react2().default.createElement(_antd().Menu.Item, {
|
|
212
212
|
disabled: true
|
|
213
213
|
}, "Collection"));
|
|
214
|
-
return _react2().default.createElement(_client().
|
|
214
|
+
return _react2().default.createElement(_client().ActionContextProvider, {
|
|
215
215
|
value: {
|
|
216
216
|
visible,
|
|
217
217
|
setVisible
|
|
@@ -241,7 +241,7 @@ const EditQuery = () => {
|
|
|
241
241
|
form,
|
|
242
242
|
isNewRecord: false
|
|
243
243
|
});
|
|
244
|
-
return _react2().default.createElement(_client().
|
|
244
|
+
return _react2().default.createElement(_client().ActionContextProvider, {
|
|
245
245
|
value: {
|
|
246
246
|
visible,
|
|
247
247
|
setVisible
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const ConfigureFields: () => React.JSX.Element;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const QueriesTable: () => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-charts",
|
|
3
|
-
"
|
|
3
|
+
"displayName": "charts",
|
|
4
|
+
"displayName.zh-CN": "图表",
|
|
5
|
+
"description": "Out-of-the-box, feature-rich chart plugins.",
|
|
6
|
+
"description.zh-CN": "开箱即用、丰富的报表。",
|
|
7
|
+
"version": "0.10.0-alpha.2",
|
|
4
8
|
"main": "lib/server/index.js",
|
|
5
9
|
"devDependencies": {
|
|
6
|
-
"@nocobase/client": "0.
|
|
7
|
-
"@nocobase/server": "0.
|
|
8
|
-
"@nocobase/test": "0.
|
|
10
|
+
"@nocobase/client": "0.10.0-alpha.2",
|
|
11
|
+
"@nocobase/server": "0.10.0-alpha.2",
|
|
12
|
+
"@nocobase/test": "0.10.0-alpha.2"
|
|
9
13
|
},
|
|
10
14
|
"dependencies": {
|
|
11
15
|
"json5": "^2.2.3"
|
|
12
16
|
},
|
|
13
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
|
|
14
18
|
}
|
|
@@ -20,24 +20,27 @@ import DataSetPreviewTable from './DataSetPreviewTable';
|
|
|
20
20
|
import { lang, useChartsTranslation } from './locale';
|
|
21
21
|
import { templates } from './templates';
|
|
22
22
|
|
|
23
|
-
export const Options = observer(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
form
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
23
|
+
export const Options = observer(
|
|
24
|
+
(props) => {
|
|
25
|
+
const form = useForm<ChartFormInterface>();
|
|
26
|
+
const field = useField<Field>();
|
|
27
|
+
const [s, setSchema] = useState(new Schema({}));
|
|
28
|
+
const [chartType, setChartType] = useState(form.values.type);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
// form.clearFormGraph('options.*');
|
|
31
|
+
setChartType(form?.values?.type);
|
|
32
|
+
if (chartType !== form?.values?.type) {
|
|
33
|
+
form.clearFormGraph('options.*');
|
|
34
|
+
}
|
|
35
|
+
if (form.values.type) {
|
|
36
|
+
const template = templates.get(form.values.type);
|
|
37
|
+
setSchema(new Schema(template.configurableProperties || {}));
|
|
38
|
+
}
|
|
39
|
+
}, [form.values.type]);
|
|
40
|
+
return <RecursionField schema={s} />;
|
|
41
|
+
},
|
|
42
|
+
{ displayName: 'Options' },
|
|
43
|
+
);
|
|
41
44
|
|
|
42
45
|
interface ChartFormInterface {
|
|
43
46
|
type: string;
|
|
@@ -8,7 +8,7 @@ const useFieldsById = (queryId: number) => {
|
|
|
8
8
|
const chartQueryList = ctx?.data;
|
|
9
9
|
if (chartQueryList && Array.isArray(chartQueryList)) {
|
|
10
10
|
const currentQuery = chartQueryList.find((chartQuery) => chartQuery.id === queryId);
|
|
11
|
-
setFields(currentQuery?.fields);
|
|
11
|
+
setFields(currentQuery?.fields || []);
|
|
12
12
|
}
|
|
13
13
|
}, [queryId]);
|
|
14
14
|
return {
|
package/src/client/index.tsx
CHANGED
|
@@ -39,9 +39,9 @@ registerValidateRules({
|
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const Charts = React.memo((props) => {
|
|
43
43
|
const api = useAPIClient();
|
|
44
|
-
const items = useContext(SchemaInitializerContext);
|
|
44
|
+
const items = useContext<any>(SchemaInitializerContext);
|
|
45
45
|
const children = items.BlockInitializers.items[0].children;
|
|
46
46
|
if (children) {
|
|
47
47
|
const hasChartItem = children.some((child) => child?.component === 'ChartBlockInitializer');
|
|
@@ -99,3 +99,6 @@ export default React.memo((props) => {
|
|
|
99
99
|
</ChartQueryMetadataProvider>
|
|
100
100
|
);
|
|
101
101
|
});
|
|
102
|
+
Charts.displayName = 'Charts';
|
|
103
|
+
|
|
104
|
+
export default Charts;
|
|
@@ -11,26 +11,29 @@ type Composed = {
|
|
|
11
11
|
Object?: React.FC<any>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const ReadPretty = observer(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export const ReadPretty = observer(
|
|
15
|
+
(props: any) => {
|
|
16
|
+
const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
|
|
17
|
+
const field = useField<any>();
|
|
18
|
+
const compile = useCompile();
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
20
|
+
if (!isValid(props.value)) {
|
|
21
|
+
return <div />;
|
|
22
|
+
}
|
|
23
|
+
if (isArrayField(field) && field?.value?.length === 0) {
|
|
24
|
+
return <div />;
|
|
25
|
+
}
|
|
26
|
+
const dataSource = field.dataSource || props.options || [];
|
|
27
|
+
const options = getCurrentOptions(field.value, dataSource, fieldNames);
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
{options.map((option, key) => (
|
|
31
|
+
<Tag key={key} color={option[fieldNames.color]} icon={option.icon}>
|
|
32
|
+
{compile(option[fieldNames.label])}
|
|
33
|
+
</Tag>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
{ displayName: 'ReadPretty' },
|
|
39
|
+
);
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
---
|
|
2
|
-
nav:
|
|
3
|
-
path: /client
|
|
4
|
-
group:
|
|
5
|
-
path: /schema-components
|
|
6
|
-
---
|
|
7
|
-
|
|
8
1
|
# Select
|
|
9
2
|
|
|
10
3
|
## Examples
|
|
11
4
|
|
|
12
5
|
### 单选
|
|
13
6
|
|
|
14
|
-
<code src="./demos/demo1.tsx"
|
|
7
|
+
<code src="./demos/demo1.tsx"></code>
|
|
15
8
|
|
|
16
9
|
### 多选
|
|
17
10
|
|
|
18
|
-
<code src="./demos/demo2.tsx"
|
|
11
|
+
<code src="./demos/demo2.tsx"></code>
|
|
19
12
|
|
|
20
13
|
### 值为 Object 类型的 Select
|
|
21
14
|
|
|
22
|
-
<code src="./demos/demo3.tsx"
|
|
15
|
+
<code src="./demos/demo3.tsx"></code>
|
|
23
16
|
|
|
24
17
|
## API
|
|
25
18
|
|
|
@@ -3,7 +3,7 @@ import { createForm } from '@formily/core';
|
|
|
3
3
|
import { ISchema, useForm } from '@formily/react';
|
|
4
4
|
import { uid } from '@formily/shared';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
ActionContextProvider,
|
|
7
7
|
SchemaComponent,
|
|
8
8
|
useActionContext,
|
|
9
9
|
useRecord,
|
|
@@ -129,14 +129,14 @@ export const AddNewQuery = () => {
|
|
|
129
129
|
</Menu>
|
|
130
130
|
);
|
|
131
131
|
return (
|
|
132
|
-
<
|
|
132
|
+
<ActionContextProvider value={{ visible, setVisible }}>
|
|
133
133
|
<Dropdown overlay={menu}>
|
|
134
134
|
<Button icon={<PlusOutlined />} type={'primary'}>
|
|
135
135
|
{lang('Add query')} <DownOutlined />
|
|
136
136
|
</Button>
|
|
137
137
|
</Dropdown>
|
|
138
138
|
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} />
|
|
139
|
-
</
|
|
139
|
+
</ActionContextProvider>
|
|
140
140
|
);
|
|
141
141
|
};
|
|
142
142
|
|
|
@@ -146,7 +146,7 @@ export const EditQuery = () => {
|
|
|
146
146
|
const form = useMemo(() => createForm(), []);
|
|
147
147
|
const schema = getSchema(record, { form, isNewRecord: false });
|
|
148
148
|
return (
|
|
149
|
-
<
|
|
149
|
+
<ActionContextProvider value={{ visible, setVisible }}>
|
|
150
150
|
<a
|
|
151
151
|
onClick={() => {
|
|
152
152
|
form.setValues(record);
|
|
@@ -156,6 +156,6 @@ export const EditQuery = () => {
|
|
|
156
156
|
{lang('Edit')}
|
|
157
157
|
</a>
|
|
158
158
|
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} />
|
|
159
|
-
</
|
|
159
|
+
</ActionContextProvider>
|
|
160
160
|
);
|
|
161
161
|
};
|