@nocobase/plugin-charts 0.9.1-alpha.2 → 0.9.2-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 (43) hide show
  1. package/lib/client/ChartBlockEngine.js +17 -71
  2. package/lib/client/ChartBlockEngineDesigner.js +13 -73
  3. package/lib/client/ChartBlockInitializer.js +16 -72
  4. package/lib/client/ChartQueryBlockInitializer.js +18 -65
  5. package/lib/client/ChartQueryMetadataProvider.js +1 -28
  6. package/lib/client/DataSetPreviewTable.js +14 -28
  7. package/lib/client/Icons.js +3 -19
  8. package/lib/client/chartRenderComponents/index.js +0 -6
  9. package/lib/client/hooks/index.js +4 -18
  10. package/lib/client/index.js +0 -33
  11. package/lib/client/locale/index.js +2 -11
  12. package/lib/client/locale/pt-BR.d.ts +23 -0
  13. package/lib/client/locale/pt-BR.js +29 -0
  14. package/lib/client/select/CustomSelect.js +9 -47
  15. package/lib/client/select/ReadPretty.js +3 -30
  16. package/lib/client/select/index.js +0 -4
  17. package/lib/client/select/shared.js +4 -24
  18. package/lib/client/settings/AddNewQuery.js +22 -81
  19. package/lib/client/settings/ConfigureFields.js +0 -12
  20. package/lib/client/settings/QueriesTable.js +5 -36
  21. package/lib/client/settings/queryTypes.js +0 -7
  22. package/lib/client/settings/schemas/chartsQueries.js +12 -37
  23. package/lib/client/templates/AreaTemplate.js +0 -5
  24. package/lib/client/templates/BarTemplate.js +0 -5
  25. package/lib/client/templates/ColumnTemplate.js +0 -5
  26. package/lib/client/templates/FunnelTemplate.js +0 -5
  27. package/lib/client/templates/LineTemplate.js +4 -7
  28. package/lib/client/templates/PieTemplate.js +0 -5
  29. package/lib/client/templates/RadarTemplate.js +0 -5
  30. package/lib/client/templates/ScatterTemplate.js +0 -5
  31. package/lib/client/templates/index.js +2 -10
  32. package/lib/client/utils.js +0 -16
  33. package/lib/index.js +0 -2
  34. package/lib/server/actions/chartsQueries.js +16 -31
  35. package/lib/server/collections/chartsQueries.js +2 -5
  36. package/lib/server/index.js +0 -2
  37. package/lib/server/plugin.js +0 -36
  38. package/lib/server/query.js +5 -25
  39. package/package.json +5 -5
  40. package/src/client/DataSetPreviewTable.tsx +8 -1
  41. package/src/client/locale/pt-BR.ts +23 -0
  42. package/src/server/actions/chartsQueries.ts +11 -6
  43. package/src/server/collections/chartsQueries.ts +2 -0
@@ -4,142 +4,96 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Options = exports.ChartBlockInitializer = void 0;
7
-
8
7
  function _css() {
9
8
  const data = require("@emotion/css");
10
-
11
9
  _css = function _css() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _antd() {
19
15
  const data = require("@formily/antd");
20
-
21
16
  _antd = function _antd() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _react() {
29
22
  const data = require("@formily/react");
30
-
31
23
  _react = function _react() {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _client() {
39
29
  const data = require("@nocobase/client");
40
-
41
30
  _client = function _client() {
42
31
  return data;
43
32
  };
44
-
45
33
  return data;
46
34
  }
47
-
48
35
  function _antd2() {
49
36
  const data = require("antd");
50
-
51
37
  _antd2 = function _antd2() {
52
38
  return data;
53
39
  };
54
-
55
40
  return data;
56
41
  }
57
-
58
42
  function _json() {
59
43
  const data = _interopRequireDefault(require("json5"));
60
-
61
44
  _json = function _json() {
62
45
  return data;
63
46
  };
64
-
65
47
  return data;
66
48
  }
67
-
68
49
  function _react2() {
69
50
  const data = _interopRequireWildcard(require("react"));
70
-
71
51
  _react2 = function _react2() {
72
52
  return data;
73
53
  };
74
-
75
54
  return data;
76
55
  }
77
-
78
56
  var _ChartBlockEngineDesigner = require("./ChartBlockEngineDesigner");
79
-
80
57
  var _ChartQueryBlockInitializer = require("./ChartQueryBlockInitializer");
81
-
82
58
  var _DataSetPreviewTable = _interopRequireDefault(require("./DataSetPreviewTable"));
83
-
84
59
  var _locale = require("./locale");
85
-
86
60
  var _templates = require("./templates");
87
-
88
61
  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); }
89
-
90
62
  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; }
91
-
92
63
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
93
-
94
64
  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); } }
95
-
96
65
  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); }); }; }
97
-
98
66
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
99
-
100
67
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
101
-
102
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
103
-
68
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
69
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
70
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
104
71
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
105
-
106
72
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
107
-
108
73
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
109
-
110
74
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
111
-
112
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
113
-
75
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
114
76
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
115
-
116
77
  const Options = (0, _react().observer)(props => {
117
78
  const form = (0, _react().useForm)();
118
79
  const field = (0, _react().useField)();
119
-
120
80
  const _useState = (0, _react2().useState)(new (_react().Schema)({})),
121
- _useState2 = _slicedToArray(_useState, 2),
122
- s = _useState2[0],
123
- setSchema = _useState2[1];
124
-
81
+ _useState2 = _slicedToArray(_useState, 2),
82
+ s = _useState2[0],
83
+ setSchema = _useState2[1];
125
84
  const _useState3 = (0, _react2().useState)(form.values.type),
126
- _useState4 = _slicedToArray(_useState3, 2),
127
- chartType = _useState4[0],
128
- setChartType = _useState4[1];
129
-
85
+ _useState4 = _slicedToArray(_useState3, 2),
86
+ chartType = _useState4[0],
87
+ setChartType = _useState4[1];
130
88
  (0, _react2().useEffect)(() => {
131
89
  var _form$values, _form$values2;
132
-
133
90
  // form.clearFormGraph('options.*');
134
91
  setChartType(form === null || form === void 0 ? void 0 : (_form$values = form.values) === null || _form$values === void 0 ? void 0 : _form$values.type);
135
-
136
92
  if (chartType !== (form === null || form === void 0 ? void 0 : (_form$values2 = form.values) === null || _form$values2 === void 0 ? void 0 : _form$values2.type)) {
137
93
  form.clearFormGraph('options.*');
138
94
  }
139
-
140
95
  if (form.values.type) {
141
96
  const template = _templates.templates.get(form.values.type);
142
-
143
97
  setSchema(new (_react().Schema)(template.configurableProperties || {}));
144
98
  }
145
99
  }, [form.values.type]);
@@ -148,16 +102,13 @@ const Options = (0, _react().observer)(props => {
148
102
  });
149
103
  });
150
104
  exports.Options = Options;
151
-
152
105
  const ChartBlockInitializer = props => {
153
106
  const insert = props.insert;
154
107
  const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
155
108
  const api = (0, _client().useAPIClient)();
156
109
  const compile = (0, _client().useCompile)();
157
-
158
110
  const _useChartsTranslation = (0, _locale.useChartsTranslation)(),
159
- t = _useChartsTranslation.t;
160
-
111
+ t = _useChartsTranslation.t;
161
112
  return _react2().default.createElement(_ChartQueryBlockInitializer.ChartQueryBlockInitializer, _objectSpread(_objectSpread({}, props), {}, {
162
113
  componentType: 'Charts',
163
114
  onCreateBlockSchema: function () {
@@ -181,22 +132,19 @@ const ChartBlockInitializer = props => {
181
132
  }
182
133
  }, () => {
183
134
  var _chartBlockEngineMeta, _chartBlockEngineMeta2;
184
-
185
135
  const form = (0, _react().useForm)();
186
-
187
136
  const _useState5 = (0, _react2().useState)(null),
188
- _useState6 = _slicedToArray(_useState5, 2),
189
- chartBlockEngineMetaData = _useState6[0],
190
- setChartBlockEngineMetaData = _useState6[1];
191
-
137
+ _useState6 = _slicedToArray(_useState5, 2),
138
+ chartBlockEngineMetaData = _useState6[0],
139
+ setChartBlockEngineMetaData = _useState6[1];
192
140
  (0, _react2().useEffect)(() => {
193
141
  const chartBlockEngineMetaData = {
194
142
  query: {
195
143
  id: chartQueryMetadata === null || chartQueryMetadata === void 0 ? void 0 : chartQueryMetadata.id
196
144
  },
197
145
  chart: form.values //TODO
198
-
199
146
  };
147
+
200
148
  setChartBlockEngineMetaData(chartBlockEngineMetaData);
201
149
  }, [form.values.type]);
202
150
  return _react2().default.createElement(_client().APIClientProvider, {
@@ -291,7 +239,6 @@ const ChartBlockInitializer = props => {
291
239
  }).open({
292
240
  initialValues: {}
293
241
  });
294
-
295
242
  if (values) {
296
243
  const chartBlockEngineMetaData = {
297
244
  query: {
@@ -311,14 +258,11 @@ const ChartBlockInitializer = props => {
311
258
  });
312
259
  }
313
260
  });
314
-
315
- function onCreateBlockSchema(_x) {
261
+ function onCreateBlockSchema(_x2) {
316
262
  return _onCreateBlockSchema.apply(this, arguments);
317
263
  }
318
-
319
264
  return onCreateBlockSchema;
320
265
  }()
321
266
  }));
322
267
  };
323
-
324
268
  exports.ChartBlockInitializer = ChartBlockInitializer;
@@ -4,121 +4,83 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ChartQueryBlockInitializer = void 0;
7
-
8
7
  function _icons() {
9
8
  const data = require("@ant-design/icons");
10
-
11
9
  _icons = function _icons() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _antd() {
19
15
  const data = require("@formily/antd");
20
-
21
16
  _antd = function _antd() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _react() {
29
22
  const data = require("@formily/react");
30
-
31
23
  _react = function _react() {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _client() {
39
29
  const data = require("@nocobase/client");
40
-
41
30
  _client = function _client() {
42
31
  return data;
43
32
  };
44
-
45
33
  return data;
46
34
  }
47
-
48
35
  function _react2() {
49
36
  const data = _interopRequireWildcard(require("react"));
50
-
51
37
  _react2 = function _react2() {
52
38
  return data;
53
39
  };
54
-
55
40
  return data;
56
41
  }
57
-
58
42
  var _ChartQueryMetadataProvider = require("./ChartQueryMetadataProvider");
59
-
60
43
  var _locale = require("./locale");
61
-
62
44
  var _queryTypes = require("./settings/queryTypes");
63
-
64
45
  const _excluded = ["templateWrap", "onCreateBlockSchema", "componentType", "createBlockSchema", "insert"];
65
-
66
46
  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); }
67
-
68
47
  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; }
69
-
70
48
  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); } }
71
-
72
49
  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); }); }; }
73
-
74
50
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
75
-
76
51
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
77
-
78
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
79
-
52
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
54
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
80
55
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
81
-
82
56
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
83
-
84
57
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
85
-
86
58
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
87
-
88
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
89
-
59
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
90
60
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
91
-
92
61
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
93
-
94
62
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
95
-
96
63
  const ChartQueryBlockInitializer = props => {
97
64
  const defaultItems = [{
98
65
  type: 'itemGroup',
99
66
  title: (0, _locale.lang)('Select query data'),
100
67
  children: []
101
68
  }];
102
-
103
69
  const templateWrap = props.templateWrap,
104
- onCreateBlockSchema = props.onCreateBlockSchema,
105
- componentType = props.componentType,
106
- createBlockSchema = props.createBlockSchema,
107
- insert = props.insert,
108
- others = _objectWithoutProperties(props, _excluded);
109
-
70
+ onCreateBlockSchema = props.onCreateBlockSchema,
71
+ componentType = props.componentType,
72
+ createBlockSchema = props.createBlockSchema,
73
+ insert = props.insert,
74
+ others = _objectWithoutProperties(props, _excluded);
110
75
  const _useContext = (0, _react2().useContext)(_client().SchemaInitializerButtonContext),
111
- setVisible = _useContext.setVisible;
112
-
76
+ setVisible = _useContext.setVisible;
113
77
  const _useState = (0, _react2().useState)(defaultItems),
114
- _useState2 = _slicedToArray(_useState, 2),
115
- items = _useState2[0],
116
- setItems = _useState2[1];
117
-
78
+ _useState2 = _slicedToArray(_useState, 2),
79
+ items = _useState2[0],
80
+ setItems = _useState2[1];
118
81
  const apiClient = (0, _client().useAPIClient)();
119
82
  const ctx = (0, _ChartQueryMetadataProvider.useChartQueryMetadataContext)();
120
83
  const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
121
-
122
84
  const onAddQuery = info => {
123
85
  (0, _antd().FormDialog)({
124
86
  sql: (0, _locale.lang)('Add SQL query'),
@@ -151,16 +113,13 @@ const ChartQueryBlockInitializer = props => {
151
113
  var _ref = _asyncToGenerator(function* (values) {
152
114
  try {
153
115
  var _apiClient$resource, _apiClient$resource$c;
154
-
155
116
  const _yield$apiClient$reso = yield (_apiClient$resource = apiClient.resource('chartsQueries')) === null || _apiClient$resource === void 0 ? void 0 : (_apiClient$resource$c = _apiClient$resource.create) === null || _apiClient$resource$c === void 0 ? void 0 : _apiClient$resource$c.call(_apiClient$resource, {
156
- values
157
- }),
158
- data = _yield$apiClient$reso.data;
159
-
117
+ values
118
+ }),
119
+ data = _yield$apiClient$reso.data;
160
120
  const items = yield ctx.refresh();
161
121
  const item = items.find(item => {
162
122
  var _data$data;
163
-
164
123
  return item.id === (data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.id);
165
124
  });
166
125
  onCreateBlockSchema({
@@ -169,16 +128,13 @@ const ChartQueryBlockInitializer = props => {
169
128
  setVisible(false);
170
129
  } catch (error) {}
171
130
  });
172
-
173
- return function (_x) {
131
+ return function (_x2) {
174
132
  return _ref.apply(this, arguments);
175
133
  };
176
134
  }()).catch(() => {});
177
135
  };
178
-
179
136
  (0, _react2().useEffect)(() => {
180
137
  const chartQueryMetadata = ctx.data;
181
-
182
138
  if (chartQueryMetadata && Array.isArray(chartQueryMetadata)) {
183
139
  setItems([chartQueryMetadata.length > 0 ? {
184
140
  type: 'itemGroup',
@@ -216,15 +172,12 @@ const ChartQueryBlockInitializer = props => {
216
172
  });
217
173
  setVisible(false);
218
174
  });
219
-
220
- function onClick(_x2) {
175
+ function onClick(_x3) {
221
176
  return _onClick.apply(this, arguments);
222
177
  }
223
-
224
178
  return onClick;
225
179
  }(),
226
180
  items: items
227
181
  }));
228
182
  };
229
-
230
183
  exports.ChartQueryBlockInitializer = ChartQueryBlockInitializer;
@@ -4,64 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useChartQueryMetadataContext = exports.ChartQueryMetadataProvider = exports.ChartQueryMetadataContext = void 0;
7
-
8
7
  function _client() {
9
8
  const data = require("@nocobase/client");
10
-
11
9
  _client = function _client() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _antd() {
19
15
  const data = require("antd");
20
-
21
16
  _antd = function _antd() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _react() {
29
22
  const data = _interopRequireWildcard(require("react"));
30
-
31
23
  _react = function _react() {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _reactRouterDom() {
39
29
  const data = require("react-router-dom");
40
-
41
30
  _reactRouterDom = function _reactRouterDom() {
42
31
  return data;
43
32
  };
44
-
45
33
  return data;
46
34
  }
47
-
48
35
  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); }
49
-
50
36
  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; }
51
-
52
37
  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); } }
53
-
54
38
  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); }); }; }
55
-
56
39
  const ChartQueryMetadataContext = (0, _react().createContext)({
57
40
  refresh: () => {},
58
41
  data: []
59
42
  });
60
43
  exports.ChartQueryMetadataContext = ChartQueryMetadataContext;
61
-
62
44
  const ChartQueryMetadataProvider = props => {
63
45
  var _service$data;
64
-
65
46
  const api = (0, _client().useAPIClient)();
66
47
  const options = {
67
48
  resource: 'chartsQueries',
@@ -82,25 +63,20 @@ const ChartQueryMetadataProvider = props => {
82
63
  service.run();
83
64
  }
84
65
  }, [isAdminPage, token]);
85
-
86
66
  const refresh = /*#__PURE__*/function () {
87
67
  var _ref = _asyncToGenerator(function* () {
88
68
  const _yield$api$request = yield api.request(options),
89
- data = _yield$api$request.data;
90
-
69
+ data = _yield$api$request.data;
91
70
  service.mutate(data);
92
71
  return (data === null || data === void 0 ? void 0 : data.data) || [];
93
72
  });
94
-
95
73
  return function refresh() {
96
74
  return _ref.apply(this, arguments);
97
75
  };
98
76
  }();
99
-
100
77
  if (service.loading) {
101
78
  return _react().default.createElement(_antd().Spin, null);
102
79
  }
103
-
104
80
  return _react().default.createElement(ChartQueryMetadataContext.Provider, {
105
81
  value: {
106
82
  refresh,
@@ -108,11 +84,8 @@ const ChartQueryMetadataProvider = props => {
108
84
  }
109
85
  }, props.children);
110
86
  };
111
-
112
87
  exports.ChartQueryMetadataProvider = ChartQueryMetadataProvider;
113
-
114
88
  const useChartQueryMetadataContext = () => {
115
89
  return (0, _react().useContext)(ChartQueryMetadataContext);
116
90
  };
117
-
118
91
  exports.useChartQueryMetadataContext = useChartQueryMetadataContext;
@@ -4,62 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _client() {
9
8
  const data = require("@nocobase/client");
10
-
11
9
  _client = function _client() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _antd() {
19
15
  const data = require("antd");
20
-
21
16
  _antd = function _antd() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _react() {
29
22
  const data = _interopRequireDefault(require("react"));
30
-
31
23
  _react = function _react() {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  var _ChartBlockEngine = require("./ChartBlockEngine");
39
-
40
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
-
42
30
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
43
-
44
31
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
-
46
32
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
47
-
48
33
  var _default = ({
49
34
  queryId,
50
35
  fields
51
36
  }) => {
52
37
  const _useGetDataSet = (0, _ChartBlockEngine.useGetDataSet)(queryId),
53
- dataSet = _useGetDataSet.dataSet,
54
- loading = _useGetDataSet.loading,
55
- error = _useGetDataSet.error;
56
-
38
+ dataSet = _useGetDataSet.dataSet,
39
+ loading = _useGetDataSet.loading,
40
+ error = _useGetDataSet.error;
57
41
  const columns = {};
58
-
59
42
  if (fields) {
60
43
  var _iterator = _createForOfIteratorHelper(fields),
61
- _step;
62
-
44
+ _step;
63
45
  try {
64
46
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
47
  const field = _step.value;
@@ -67,7 +49,8 @@ var _default = ({
67
49
  type: 'void',
68
50
  title: field.name,
69
51
  'x-component': 'TableV2.Column',
70
- 'x-component-props': {// width: 200,
52
+ 'x-component-props': {
53
+ // width: 200,
71
54
  },
72
55
  properties: {
73
56
  [field.name]: {
@@ -84,7 +67,6 @@ var _default = ({
84
67
  _iterator.f();
85
68
  }
86
69
  }
87
-
88
70
  const schema = {
89
71
  type: 'void',
90
72
  properties: {
@@ -92,7 +74,6 @@ var _default = ({
92
74
  type: 'array',
93
75
  'x-component': 'TableV2',
94
76
  'x-component-props': {
95
- rowKey: 'id',
96
77
  scroll: {
97
78
  y: 300
98
79
  }
@@ -102,14 +83,20 @@ var _default = ({
102
83
  }
103
84
  }
104
85
  };
105
-
106
86
  if (error) {
107
87
  return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Empty, {
108
88
  description: _react().default.createElement("span", null, "May be this chart block's query data has been deleted,please check!")
109
89
  }));
110
90
  }
111
-
112
91
  if (loading) return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Spin, null));
92
+ //对dataset中引用类型数据类型进行序列化处理
93
+ dataSet.forEach(item => {
94
+ for (const key in item) {
95
+ if (item[key] && item[key] instanceof Object) {
96
+ item[key] = JSON.stringify(item[key]);
97
+ }
98
+ }
99
+ });
113
100
  return _react().default.createElement(_client().SchemaComponentProvider, {
114
101
  scope: {
115
102
  dataSet
@@ -123,5 +110,4 @@ var _default = ({
123
110
  schema: schema
124
111
  })));
125
112
  };
126
-
127
113
  exports.default = _default;