@nocobase/plugin-charts 0.10.1-alpha.1 → 0.11.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.
package/client.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
- export * from './lib/client';
3
- export { default } from './lib/client';
1
+ export * from './src/client';
2
+ export { default } from './src/client';
4
3
 
package/client.js CHANGED
@@ -1,30 +1 @@
1
- "use strict";
2
-
3
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4
-
5
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6
-
7
- var _index = _interopRequireWildcard(require("./lib/client"));
8
-
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- var _exportNames = {};
13
- Object.defineProperty(exports, "default", {
14
- enumerable: true,
15
- get: function get() {
16
- return _index.default;
17
- }
18
- });
19
-
20
- Object.keys(_index).forEach(function (key) {
21
- if (key === "default" || key === "__esModule") return;
22
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
- if (key in exports && exports[key] === _index[key]) return;
24
- Object.defineProperty(exports, key, {
25
- enumerable: true,
26
- get: function get() {
27
- return _index[key];
28
- }
29
- });
30
- });
1
+ module.exports = require('./lib/client/index.js');
@@ -4,16 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.jsonConfigDesc = exports.ChartBlockEngineDesignerInitializer = exports.ChartBlockEngineDesigner = void 0;
7
- function _css() {
8
- const data = require("@emotion/css");
9
- _css = function _css() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _antd() {
15
- const data = require("@formily/antd");
16
- _antd = function _antd() {
7
+ function _antdV() {
8
+ const data = require("@formily/antd-v5");
9
+ _antdV = function _antdV() {
17
10
  return data;
18
11
  };
19
12
  return data;
@@ -32,9 +25,9 @@ function _client() {
32
25
  };
33
26
  return data;
34
27
  }
35
- function _antd2() {
28
+ function _antd() {
36
29
  const data = require("antd");
37
- _antd2 = function _antd2() {
30
+ _antd = function _antd() {
38
31
  return data;
39
32
  };
40
33
  return data;
@@ -145,12 +138,12 @@ const ChartBlockEngineDesignerInitializer = props => {
145
138
  return _react2().default.createElement(_client().SchemaSettings.Item, {
146
139
  onClick: function () {
147
140
  var _onClick = _asyncToGenerator(function* () {
148
- (0, _antd().FormDialog)({
141
+ (0, _antdV().FormDialog)({
149
142
  okText: compile('{{t("Submit")}}'),
150
143
  title: (0, _locale.lang)('Edit chart block'),
151
144
  width: 1200,
152
145
  bodyStyle: {
153
- background: '#f0f2f5',
146
+ background: 'var(--nb-box-bg)',
154
147
  maxHeight: '65vh',
155
148
  overflow: 'auto'
156
149
  }
@@ -176,18 +169,18 @@ const ChartBlockEngineDesignerInitializer = props => {
176
169
  scope: options.scope,
177
170
  components: _objectSpread({}, options.components)
178
171
  }, _react2().default.createElement("section", {
179
- className: (0, _css().css)`
172
+ className: (0, _client().css)`
180
173
  display: flex;
181
174
  gap: 24px;
182
175
  `
183
- }, _react2().default.createElement(_antd2().Card, {
176
+ }, _react2().default.createElement(_antd().Card, {
184
177
  bordered: false,
185
178
  title: _client().i18n.t('Chart config'),
186
179
  size: 'default',
187
- className: (0, _css().css)`
180
+ className: (0, _client().css)`
188
181
  flex: 1;
189
182
  `
190
- }, _react2().default.createElement(_antd().FormLayout, {
183
+ }, _react2().default.createElement(_antdV().FormLayout, {
191
184
  layout: 'vertical'
192
185
  }, _react2().default.createElement(_client().SchemaComponent, {
193
186
  scope: {
@@ -227,11 +220,11 @@ const ChartBlockEngineDesignerInitializer = props => {
227
220
  }
228
221
  }
229
222
  }))), _react2().default.createElement("div", {
230
- className: (0, _css().css)`
223
+ className: (0, _client().css)`
231
224
  flex: 1;
232
225
  min-width: 600px;
233
226
  `
234
- }, _react2().default.createElement(_antd2().Card, {
227
+ }, _react2().default.createElement(_antd().Card, {
235
228
  size: 'default',
236
229
  title: (0, _locale.lang)('Chart preview')
237
230
  }, chartBlockEngineMetaData && _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_client().SchemaComponent, {
@@ -247,10 +240,10 @@ const ChartBlockEngineDesignerInitializer = props => {
247
240
  }
248
241
  }
249
242
  }
250
- }))), _react2().default.createElement(_antd2().Card, {
243
+ }))), _react2().default.createElement(_antd().Card, {
251
244
  size: 'default',
252
245
  title: (0, _locale.lang)('Data preview'),
253
- className: (0, _css().css)`
246
+ className: (0, _client().css)`
254
247
  margin-top: 24px;
255
248
  overflow: scroll;
256
249
  `
@@ -4,16 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Options = exports.ChartBlockInitializer = void 0;
7
- function _css() {
8
- const data = require("@emotion/css");
9
- _css = function _css() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _antd() {
15
- const data = require("@formily/antd");
16
- _antd = function _antd() {
7
+ function _antdV() {
8
+ const data = require("@formily/antd-v5");
9
+ _antdV = function _antdV() {
17
10
  return data;
18
11
  };
19
12
  return data;
@@ -32,9 +25,9 @@ function _client() {
32
25
  };
33
26
  return data;
34
27
  }
35
- function _antd2() {
28
+ function _antd() {
36
29
  const data = require("antd");
37
- _antd2 = function _antd2() {
30
+ _antd = function _antd() {
38
31
  return data;
39
32
  };
40
33
  return data;
@@ -123,12 +116,12 @@ const ChartBlockInitializer = props => {
123
116
  value: field.name
124
117
  };
125
118
  });
126
- const values = yield (0, _antd().FormDialog)({
119
+ const values = yield (0, _antdV().FormDialog)({
127
120
  okText: compile('{{t("Submit")}}'),
128
121
  title: (0, _locale.lang)('Create chart block'),
129
122
  width: 1200,
130
123
  bodyStyle: {
131
- background: '#f0f2f5',
124
+ background: 'var(--nb-box-bg)',
132
125
  maxHeight: '65vh',
133
126
  overflow: 'auto'
134
127
  }
@@ -155,19 +148,19 @@ const ChartBlockInitializer = props => {
155
148
  scope: options.scope,
156
149
  components: _objectSpread({}, options.components)
157
150
  }, _react2().default.createElement("section", {
158
- className: (0, _css().css)`
151
+ className: (0, _client().css)`
159
152
  display: flex;
160
153
  gap: 24px;
161
154
  `
162
- }, _react2().default.createElement(_antd2().Card, {
155
+ }, _react2().default.createElement(_antd().Card, {
163
156
  title: (0, _locale.lang)('Chart config'),
164
157
  size: 'default',
165
- className: (0, _css().css)`
158
+ className: (0, _client().css)`
166
159
  flex: 1;
167
160
  `
168
161
  }, _react2().default.createElement(_client().FormProvider, {
169
162
  form: form
170
- }, _react2().default.createElement(_antd().FormLayout, {
163
+ }, _react2().default.createElement(_antdV().FormLayout, {
171
164
  layout: 'vertical'
172
165
  }, _react2().default.createElement(_client().SchemaComponent, {
173
166
  scope: {
@@ -207,11 +200,11 @@ const ChartBlockInitializer = props => {
207
200
  }
208
201
  }
209
202
  })))), _react2().default.createElement("div", {
210
- className: (0, _css().css)`
203
+ className: (0, _client().css)`
211
204
  flex: 1;
212
205
  min-width: 600px;
213
206
  `
214
- }, _react2().default.createElement(_antd2().Card, {
207
+ }, _react2().default.createElement(_antd().Card, {
215
208
  size: 'default',
216
209
  title: (0, _locale.lang)('Chart preview')
217
210
  }, chartBlockEngineMetaData && _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_client().SchemaComponent, {
@@ -227,10 +220,10 @@ const ChartBlockInitializer = props => {
227
220
  }
228
221
  }
229
222
  }
230
- }))), _react2().default.createElement(_antd2().Card, {
223
+ }))), _react2().default.createElement(_antd().Card, {
231
224
  size: 'default',
232
225
  title: (0, _locale.lang)('Data preview'),
233
- className: (0, _css().css)`
226
+ className: (0, _client().css)`
234
227
  margin-top: 24px;
235
228
  overflow: scroll;
236
229
  `
@@ -11,9 +11,9 @@ function _icons() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _antd() {
15
- const data = require("@formily/antd");
16
- _antd = function _antd() {
14
+ function _antdV() {
15
+ const data = require("@formily/antd-v5");
16
+ _antdV = function _antdV() {
17
17
  return data;
18
18
  };
19
19
  return data;
@@ -74,14 +74,14 @@ const ChartQueryBlockInitializer = props => {
74
74
  const ctx = (0, _ChartQueryMetadataProvider.useChartQueryMetadataContext)();
75
75
  const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
76
76
  const onAddQuery = (0, _react2().useCallback)(info => {
77
- (0, _antd().FormDialog)({
77
+ (0, _antdV().FormDialog)({
78
78
  sql: (0, _locale.lang)('Add SQL query'),
79
79
  json: (0, _locale.lang)('Add JSON query')
80
80
  }[info.key], () => {
81
81
  return _react2().default.createElement("div", null, _react2().default.createElement(_client().SchemaComponentOptions, {
82
82
  scope: options.scope,
83
83
  components: _objectSpread({}, options.components)
84
- }, _react2().default.createElement(_antd().FormLayout, {
84
+ }, _react2().default.createElement(_antdV().FormLayout, {
85
85
  layout: 'vertical'
86
86
  }, _react2().default.createElement(_client().SchemaComponent, {
87
87
  schema: {
@@ -105,7 +105,7 @@ const ChartQueryBlockInitializer = props => {
105
105
  var _ref = _asyncToGenerator(function* (values) {
106
106
  try {
107
107
  var _apiClient$resource;
108
- if ((_apiClient$resource = apiClient.resource('chartsQueries')) === null || _apiClient$resource === void 0 ? void 0 : _apiClient$resource.create) {
108
+ if ((_apiClient$resource = apiClient.resource('chartsQueries')) !== null && _apiClient$resource !== void 0 && _apiClient$resource.create) {
109
109
  const _yield$apiClient$reso = yield apiClient.resource('chartsQueries').create({
110
110
  values
111
111
  }),
@@ -106,8 +106,8 @@ var _default = ({
106
106
  Input: _client().Input,
107
107
  FormItem: _client().FormItem
108
108
  }
109
- }, _react().default.createElement(_client().BlockSchemaComponentProvider, null, _react().default.createElement(_client().SchemaComponent, {
109
+ }, _react().default.createElement(_client().SchemaComponent, {
110
110
  schema: schema
111
- })));
111
+ }));
112
112
  };
113
113
  exports.default = _default;
@@ -1,4 +1,6 @@
1
- import React from 'react';
1
+ import { Plugin } from '@nocobase/client';
2
2
  import './Icons';
3
- declare const Charts: React.NamedExoticComponent<object>;
4
- export default Charts;
3
+ export declare class ChartsPlugin extends Plugin {
4
+ load(): Promise<void>;
5
+ }
6
+ export default ChartsPlugin;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.ChartsPlugin = void 0;
7
7
  function _core() {
8
8
  const data = require("@formily/core");
9
9
  _core = function _core() {
@@ -42,6 +42,8 @@ var _QueriesTable = require("./settings/QueriesTable");
42
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
43
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
46
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
45
47
  (0, _core().registerValidateRules)({
46
48
  json5: (value, rule) => {
47
49
  if (!value) {
@@ -65,7 +67,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
65
67
  }
66
68
  }
67
69
  });
68
- const Charts = _react().default.memo(props => {
70
+ const ChartsProvider = _react().default.memo(props => {
69
71
  const api = (0, _client().useAPIClient)();
70
72
  const items = (0, _react().useContext)(_client().SchemaInitializerContext);
71
73
  const children = items.BlockInitializers.items[0].children;
@@ -125,6 +127,17 @@ const Charts = _react().default.memo(props => {
125
127
  value: items
126
128
  }, props.children))));
127
129
  });
128
- Charts.displayName = 'Charts';
129
- var _default = Charts;
130
+ ChartsProvider.displayName = 'ChartsProvider';
131
+ class ChartsPlugin extends _client().Plugin {
132
+ load() {
133
+ var _this = this;
134
+ return _asyncToGenerator(function* () {
135
+ _this.app.use(ChartsProvider);
136
+ // TODO: 主应用应该会有这个插件,按道理不需要再注册
137
+ _this.app.pm.add(_client().BlockSchemaComponentPlugin);
138
+ })();
139
+ }
140
+ }
141
+ exports.ChartsPlugin = ChartsPlugin;
142
+ var _default = ChartsPlugin;
130
143
  exports.default = _default;
@@ -11,13 +11,6 @@ function _icons() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _css() {
15
- const data = require("@emotion/css");
16
- _css = function _css() {
17
- return data;
18
- };
19
- return data;
20
- }
21
14
  function _react() {
22
15
  const data = require("@formily/react");
23
16
  _react = function _react() {
@@ -105,7 +98,7 @@ const InternalSelect = (0, _react().connect)(props => {
105
98
  },
106
99
  trigger: "hover"
107
100
  }, _react2().default.createElement("div", {
108
- className: (0, _css().css)`
101
+ className: (0, _client().css)`
109
102
  display: flex;
110
103
  gap: 4px;
111
104
  align-items: center;
@@ -129,7 +122,7 @@ const InternalSelect = (0, _react().connect)(props => {
129
122
  },
130
123
  trigger: "hover"
131
124
  }, _react2().default.createElement("div", {
132
- className: (0, _css().css)`
125
+ className: (0, _client().css)`
133
126
  display: flex;
134
127
  gap: 4px;
135
128
  align-items: center;
@@ -145,7 +138,7 @@ const InternalSelect = (0, _react().connect)(props => {
145
138
  loading: true
146
139
  }, (props, field) => {
147
140
  return _objectSpread(_objectSpread({}, props), {}, {
148
- suffixIcon: (field === null || field === void 0 ? void 0 : field['loading']) || (field === null || field === void 0 ? void 0 : field['validating']) ? _react2().default.createElement(_icons().LoadingOutlined, null) : props === null || props === void 0 ? void 0 : props.suffixIcon
141
+ suffixIcon: field !== null && field !== void 0 && field['loading'] || field !== null && field !== void 0 && field['validating'] ? _react2().default.createElement(_icons().LoadingOutlined, null) : props === null || props === void 0 ? void 0 : props.suffixIcon
149
142
  });
150
143
  }), (0, _react().mapReadPretty)(_ReadPretty.ReadPretty));
151
144
  const CustomSelect = InternalSelect;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const ReadPretty: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
2
+ export declare const ReadPretty: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getCurrentOptions = exports.defaultFieldNames = void 0;
7
- function _lodash() {
8
- const data = require("lodash");
9
- _lodash = function _lodash() {
7
+ function _client() {
8
+ const data = require("@nocobase/utils/client");
9
+ _client = function _client() {
10
10
  return data;
11
11
  };
12
12
  return data;
@@ -39,7 +39,7 @@ const getCurrentOptions = (values, dataSource, fieldNames) => {
39
39
  return newArr;
40
40
  }
41
41
  const result = flatData(dataSource);
42
- values = (0, _lodash().castArray)(values).filter(item => item != null).map(val => typeof val === 'object' ? val[fieldNames.value] : val);
42
+ values = _client().lodash.castArray(values).filter(item => item != null).map(val => typeof val === 'object' ? val[fieldNames.value] : val);
43
43
  const findOptions = options => {
44
44
  if (!options) return [];
45
45
  const current = [];
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sql = exports.json = exports.getQueryTypeSchema = exports.api = void 0;
7
- function _cloneDeep() {
8
- const data = _interopRequireDefault(require("lodash/cloneDeep"));
9
- _cloneDeep = function _cloneDeep() {
7
+ function _client() {
8
+ const data = require("@nocobase/utils/client");
9
+ _client = function _client() {
10
10
  return data;
11
11
  };
12
12
  return data;
13
13
  }
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  const json = {
16
15
  type: 'object',
17
16
  properties: {
@@ -73,6 +72,6 @@ const types = {
73
72
  api
74
73
  };
75
74
  const getQueryTypeSchema = type => {
76
- return (0, _cloneDeep().default)(types[type]);
75
+ return _client().lodash.cloneDeep(types[type]);
77
76
  };
78
77
  exports.getQueryTypeSchema = getQueryTypeSchema;
@@ -39,7 +39,7 @@ const parseDataSetString = str => {
39
39
  if (dataSetDataArray.every(item => {
40
40
  return typeof item === 'object' && Object.keys(item).length > 1;
41
41
  })) dataSetDataArray.map(item => {
42
- if (!(item === null || item === void 0 ? void 0 : item.id)) {
42
+ if (!(item !== null && item !== void 0 && item.id)) {
43
43
  item.id = (0, _shared().uid)();
44
44
  }
45
45
  return item;
@@ -1 +0,0 @@
1
-
package/package.json CHANGED
@@ -4,15 +4,37 @@
4
4
  "displayName.zh-CN": "图表",
5
5
  "description": "Out-of-the-box, feature-rich chart plugins.",
6
6
  "description.zh-CN": "开箱即用、丰富的报表。",
7
- "version": "0.10.1-alpha.1",
8
- "main": "lib/server/index.js",
9
- "devDependencies": {
10
- "@nocobase/client": "0.10.1-alpha.1",
11
- "@nocobase/server": "0.10.1-alpha.1",
12
- "@nocobase/test": "0.10.1-alpha.1"
13
- },
7
+ "version": "0.11.0-alpha.1",
8
+ "main": "./lib/server/index.js",
9
+ "files": [
10
+ "lib",
11
+ "src",
12
+ "README.md",
13
+ "README.zh-CN.md",
14
+ "CHANGELOG.md",
15
+ "server.js",
16
+ "server.d.ts",
17
+ "client.js",
18
+ "client.d.ts"
19
+ ],
14
20
  "dependencies": {
15
21
  "json5": "^2.2.3"
16
22
  },
17
- "gitHead": "8f415f5e0ee2e72d681f9ab16af5911b52c374a9"
23
+ "devDependencies": {
24
+ "@ant-design/icons": "^5.1.4",
25
+ "@formily/antd-v5": "1.1.0-beta.4",
26
+ "@formily/core": "2.2.26",
27
+ "@formily/react": "2.2.26",
28
+ "@formily/shared": "2.2.26",
29
+ "@nocobase/client": "0.11.0-alpha.1",
30
+ "@nocobase/database": "0.11.0-alpha.1",
31
+ "@nocobase/server": "0.11.0-alpha.1",
32
+ "@nocobase/test": "0.11.0-alpha.1",
33
+ "@nocobase/utils": "0.11.0-alpha.1",
34
+ "antd": "^5.6.4",
35
+ "react": "^18.2.0",
36
+ "react-i18next": "^11.15.1",
37
+ "react-router-dom": "^6.11.2"
38
+ },
39
+ "gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
18
40
  }
package/server.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
- export * from './lib/server';
3
- export { default } from './lib/server';
1
+ export * from './src/server';
2
+ export { default } from './src/server';
4
3
 
package/server.js CHANGED
@@ -1,30 +1 @@
1
- "use strict";
2
-
3
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4
-
5
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6
-
7
- var _index = _interopRequireWildcard(require("./lib/server"));
8
-
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- var _exportNames = {};
13
- Object.defineProperty(exports, "default", {
14
- enumerable: true,
15
- get: function get() {
16
- return _index.default;
17
- }
18
- });
19
-
20
- Object.keys(_index).forEach(function (key) {
21
- if (key === "default" || key === "__esModule") return;
22
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
- if (key in exports && exports[key] === _index[key]) return;
24
- Object.defineProperty(exports, key, {
25
- enumerable: true,
26
- get: function get() {
27
- return _index[key];
28
- }
29
- });
30
- });
1
+ module.exports = require('./lib/server/index.js');
@@ -1,13 +1,13 @@
1
- import { css } from '@emotion/css';
2
- import { FormDialog, FormLayout } from '@formily/antd';
1
+ import { FormDialog, FormLayout } from '@formily/antd-v5';
3
2
  import { SchemaOptionsContext, useField, useFieldSchema } from '@formily/react';
4
3
  import {
5
4
  APIClientProvider,
6
5
  GeneralSchemaDesigner,
7
- i18n,
8
6
  SchemaComponent,
9
7
  SchemaComponentOptions,
10
8
  SchemaSettings,
9
+ css,
10
+ i18n,
11
11
  useAPIClient,
12
12
  useCompile,
13
13
  useDesignable,
@@ -95,7 +95,7 @@ export const ChartBlockEngineDesignerInitializer = (props) => {
95
95
  okText: compile('{{t("Submit")}}'),
96
96
  title: lang('Edit chart block'),
97
97
  width: 1200,
98
- bodyStyle: { background: '#f0f2f5', maxHeight: '65vh', overflow: 'auto' },
98
+ bodyStyle: { background: 'var(--nb-box-bg)', maxHeight: '65vh', overflow: 'auto' },
99
99
  },
100
100
  (form) => {
101
101
  const [chartBlockEngineMetaData, setChartBlockEngineMetaData] = useState<ChartBlockEngineMetaData>(null);
@@ -1,12 +1,12 @@
1
- import { css } from '@emotion/css';
2
- import { FormDialog, FormLayout } from '@formily/antd';
1
+ import { FormDialog, FormLayout } from '@formily/antd-v5';
3
2
  import { Field } from '@formily/core';
4
- import { observer, RecursionField, Schema, SchemaOptionsContext, useField, useForm } from '@formily/react';
3
+ import { RecursionField, Schema, SchemaOptionsContext, observer, useField, useForm } from '@formily/react';
5
4
  import {
6
5
  APIClientProvider,
7
6
  FormProvider,
8
7
  SchemaComponent,
9
8
  SchemaComponentOptions,
9
+ css,
10
10
  useAPIClient,
11
11
  useCompile,
12
12
  } from '@nocobase/client';
@@ -74,7 +74,7 @@ export const ChartBlockInitializer = (props) => {
74
74
  okText: compile('{{t("Submit")}}'),
75
75
  title: lang('Create chart block'),
76
76
  width: 1200,
77
- bodyStyle: { background: '#f0f2f5', maxHeight: '65vh', overflow: 'auto' },
77
+ bodyStyle: { background: 'var(--nb-box-bg)', maxHeight: '65vh', overflow: 'auto' },
78
78
  },
79
79
  () => {
80
80
  const form = useForm<ChartFormInterface>();
@@ -1,5 +1,5 @@
1
1
  import { TableOutlined } from '@ant-design/icons';
2
- import { FormDialog, FormLayout } from '@formily/antd';
2
+ import { FormDialog, FormLayout } from '@formily/antd-v5';
3
3
  import { SchemaOptionsContext } from '@formily/react';
4
4
  import {
5
5
  SchemaComponent,
@@ -1,12 +1,5 @@
1
1
  import { ISchema } from '@formily/react';
2
- import {
3
- BlockSchemaComponentProvider,
4
- FormItem,
5
- Input,
6
- SchemaComponent,
7
- SchemaComponentProvider,
8
- TableV2,
9
- } from '@nocobase/client';
2
+ import { FormItem, Input, SchemaComponent, SchemaComponentProvider, TableV2 } from '@nocobase/client';
10
3
  import { Empty, Spin } from 'antd';
11
4
  import React from 'react';
12
5
  import { useGetDataSet } from './ChartBlockEngine';
@@ -72,9 +65,7 @@ export default ({ queryId, fields }: { queryId: number; fields }) => {
72
65
  });
73
66
  return (
74
67
  <SchemaComponentProvider scope={{ dataSet }} components={{ TableV2, Input, FormItem }}>
75
- <BlockSchemaComponentProvider>
76
- <SchemaComponent schema={schema} />
77
- </BlockSchemaComponentProvider>
68
+ <SchemaComponent schema={schema} />
78
69
  </SchemaComponentProvider>
79
70
  );
80
71
  };
@@ -1,5 +1,7 @@
1
1
  import { registerValidateRules } from '@formily/core';
2
2
  import {
3
+ BlockSchemaComponentPlugin,
4
+ Plugin,
3
5
  SchemaComponentOptions,
4
6
  SchemaInitializerContext,
5
7
  SettingsCenterProvider,
@@ -39,7 +41,7 @@ registerValidateRules({
39
41
  },
40
42
  });
41
43
 
42
- const Charts = React.memo((props) => {
44
+ const ChartsProvider = React.memo((props) => {
43
45
  const api = useAPIClient();
44
46
  const items = useContext<any>(SchemaInitializerContext);
45
47
  const children = items.BlockInitializers.items[0].children;
@@ -99,6 +101,15 @@ const Charts = React.memo((props) => {
99
101
  </ChartQueryMetadataProvider>
100
102
  );
101
103
  });
102
- Charts.displayName = 'Charts';
104
+ ChartsProvider.displayName = 'ChartsProvider';
103
105
 
104
- export default Charts;
106
+ export class ChartsPlugin extends Plugin {
107
+ async load() {
108
+ this.app.use(ChartsProvider);
109
+
110
+ // TODO: 主应用应该会有这个插件,按道理不需要再注册
111
+ this.app.pm.add(BlockSchemaComponentPlugin);
112
+ }
113
+ }
114
+
115
+ export default ChartsPlugin;
@@ -1,8 +1,7 @@
1
1
  import { LoadingOutlined } from '@ant-design/icons';
2
- import { css } from '@emotion/css';
3
2
  import { connect, mapProps, mapReadPretty } from '@formily/react';
4
3
  import { isValid } from '@formily/shared';
5
- import { Icon } from '@nocobase/client';
4
+ import { css, Icon } from '@nocobase/client';
6
5
  import type { SelectProps } from 'antd';
7
6
  import { Popover, Select as AntdSelect } from 'antd';
8
7
  import React from 'react';
@@ -1,4 +1,4 @@
1
- import { castArray } from 'lodash';
1
+ import { lodash } from '@nocobase/utils/client';
2
2
 
3
3
  export const defaultFieldNames = {
4
4
  label: 'label',
@@ -20,7 +20,8 @@ export const getCurrentOptions = (values, dataSource, fieldNames) => {
20
20
  return newArr;
21
21
  }
22
22
  const result = flatData(dataSource);
23
- values = castArray(values)
23
+ values = lodash
24
+ .castArray(values)
24
25
  .filter((item) => item != null)
25
26
  .map((val) => (typeof val === 'object' ? val[fieldNames.value] : val));
26
27
  const findOptions = (options: any[]) => {
@@ -1,5 +1,6 @@
1
1
  import { ISchema } from '@formily/react';
2
- import cloneDeep from 'lodash/cloneDeep';
2
+ import { lodash } from '@nocobase/utils/client';
3
+
3
4
  export const json: ISchema = {
4
5
  type: 'object',
5
6
  properties: {
@@ -60,5 +61,5 @@ const types = {
60
61
  };
61
62
 
62
63
  export const getQueryTypeSchema = (type) => {
63
- return cloneDeep(types[type]);
64
+ return lodash.cloneDeep(types[type]);
64
65
  };