@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.
@@ -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
- export declare const jsonConfigDesc: (title: string, link: string) => JSX.Element;
2
- export declare const ChartBlockEngineDesigner: () => JSX.Element;
3
- export declare const ChartBlockEngineDesignerInitializer: (props: any) => JSX.Element;
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<React.FunctionComponent<unknown>>;
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;
@@ -1,5 +1,6 @@
1
+ import React from 'react';
1
2
  declare const _default: ({ queryId, fields }: {
2
3
  queryId: number;
3
4
  fields: any;
4
- }) => JSX.Element;
5
+ }) => React.JSX.Element;
5
6
  export default _default;
@@ -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 {
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import './Icons';
3
- declare const _default: React.NamedExoticComponent<object>;
4
- export default _default;
3
+ declare const Charts: React.NamedExoticComponent<object>;
4
+ export default Charts;
@@ -65,7 +65,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
65
65
  }
66
66
  }
67
67
  });
68
- var _default = _react().default.memo(props => {
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<React.FunctionComponent<Pick<any, string | number | symbol>>>;
2
+ export declare const ReadPretty: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
@@ -71,5 +71,7 @@ const ReadPretty = (0, _react().observer)(props => {
71
71
  color: option[fieldNames.color],
72
72
  icon: option.icon
73
73
  }, compile(option[fieldNames.label]))));
74
+ }, {
75
+ displayName: 'ReadPretty'
74
76
  });
75
77
  exports.ReadPretty = ReadPretty;
@@ -1,2 +1,3 @@
1
- export declare const AddNewQuery: () => JSX.Element;
2
- export declare const EditQuery: () => JSX.Element;
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().ActionContext.Provider, {
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().ActionContext.Provider, {
244
+ return _react2().default.createElement(_client().ActionContextProvider, {
245
245
  value: {
246
246
  visible,
247
247
  setVisible
@@ -1 +1,2 @@
1
- export declare const ConfigureFields: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const ConfigureFields: () => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const QueriesTable: () => JSX.Element;
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
- "version": "0.9.4-alpha.2",
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.9.4-alpha.2",
7
- "@nocobase/server": "0.9.4-alpha.2",
8
- "@nocobase/test": "0.9.4-alpha.2"
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": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
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((props) => {
24
- const form = useForm<ChartFormInterface>();
25
- const field = useField<Field>();
26
- const [s, setSchema] = useState(new Schema({}));
27
- const [chartType, setChartType] = useState(form.values.type);
28
- useEffect(() => {
29
- // form.clearFormGraph('options.*');
30
- setChartType(form?.values?.type);
31
- if (chartType !== form?.values?.type) {
32
- form.clearFormGraph('options.*');
33
- }
34
- if (form.values.type) {
35
- const template = templates.get(form.values.type);
36
- setSchema(new Schema(template.configurableProperties || {}));
37
- }
38
- }, [form.values.type]);
39
- return <RecursionField schema={s} />;
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 {
@@ -39,9 +39,9 @@ registerValidateRules({
39
39
  },
40
40
  });
41
41
 
42
- export default React.memo((props) => {
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((props: any) => {
15
- const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
16
- const field = useField<any>();
17
- const compile = useCompile();
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
- 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
- });
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
- ActionContext,
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
- <ActionContext.Provider value={{ visible, setVisible }}>
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
- </ActionContext.Provider>
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
- <ActionContext.Provider value={{ visible, setVisible }}>
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
- </ActionContext.Provider>
159
+ </ActionContextProvider>
160
160
  );
161
161
  };