@nocobase/plugin-workflow 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.
Files changed (106) hide show
  1. package/lib/client/AddButton.d.ts +2 -2
  2. package/lib/client/Branch.d.ts +2 -2
  3. package/lib/client/CanvasContent.d.ts +2 -2
  4. package/lib/client/ExecutionCanvas.d.ts +2 -2
  5. package/lib/client/ExecutionCanvas.js +1 -1
  6. package/lib/client/ExecutionLink.d.ts +2 -1
  7. package/lib/client/ExecutionPage.d.ts +2 -1
  8. package/lib/client/ExecutionPage.js +14 -15
  9. package/lib/client/ExecutionResourceProvider.d.ts +2 -1
  10. package/lib/client/WorkflowCanvas.d.ts +2 -2
  11. package/lib/client/WorkflowCanvas.js +31 -31
  12. package/lib/client/WorkflowLink.d.ts +2 -1
  13. package/lib/client/WorkflowPage.d.ts +2 -1
  14. package/lib/client/WorkflowPage.js +11 -10
  15. package/lib/client/WorkflowProvider.d.ts +1 -1
  16. package/lib/client/WorkflowProvider.js +15 -15
  17. package/lib/client/components/CollectionBlockInitializer.d.ts +2 -7
  18. package/lib/client/components/CollectionBlockInitializer.js +49 -17
  19. package/lib/client/components/CollectionFieldset.d.ts +2 -2
  20. package/lib/client/components/CollectionFieldset.js +18 -15
  21. package/lib/client/components/Duration.d.ts +2 -2
  22. package/lib/client/components/DynamicExpression.d.ts +3 -1
  23. package/lib/client/components/DynamicExpression.js +2 -0
  24. package/lib/client/components/FieldsSelect.d.ts +1 -1
  25. package/lib/client/components/FieldsSelect.js +2 -0
  26. package/lib/client/components/FilterDynamicComponent.d.ts +2 -2
  27. package/lib/client/components/NodeDescription.d.ts +2 -2
  28. package/lib/client/components/OpenDrawer.d.ts +2 -2
  29. package/lib/client/components/OpenDrawer.js +1 -1
  30. package/lib/client/components/RadioWithTooltip.d.ts +2 -2
  31. package/lib/client/components/renderEngineReference.d.ts +2 -1
  32. package/lib/client/constants.d.ts +2 -1
  33. package/lib/client/locale/zh-CN.d.ts +3 -0
  34. package/lib/client/locale/zh-CN.js +3 -0
  35. package/lib/client/nodes/aggregate.d.ts +1 -1
  36. package/lib/client/nodes/calculation.d.ts +4 -3
  37. package/lib/client/nodes/condition.d.ts +6 -4
  38. package/lib/client/nodes/condition.js +3 -1
  39. package/lib/client/nodes/create.d.ts +3 -6
  40. package/lib/client/nodes/create.js +1 -4
  41. package/lib/client/nodes/index.d.ts +5 -5
  42. package/lib/client/nodes/index.js +7 -4
  43. package/lib/client/nodes/loop.d.ts +4 -1
  44. package/lib/client/nodes/loop.js +3 -1
  45. package/lib/client/nodes/manual/AssigneesSelect.d.ts +2 -2
  46. package/lib/client/nodes/manual/DetailsBlockProvider.d.ts +2 -0
  47. package/lib/client/nodes/manual/DetailsBlockProvider.js +106 -0
  48. package/lib/client/nodes/manual/FormBlockInitializer.d.ts +2 -0
  49. package/lib/client/nodes/manual/FormBlockInitializer.js +106 -0
  50. package/lib/client/nodes/manual/FormBlockProvider.d.ts +2 -0
  51. package/lib/client/nodes/manual/FormBlockProvider.js +113 -0
  52. package/lib/client/nodes/manual/ModeConfig.d.ts +2 -2
  53. package/lib/client/nodes/manual/SchemaConfig.d.ts +43 -3
  54. package/lib/client/nodes/manual/SchemaConfig.js +42 -79
  55. package/lib/client/nodes/manual/WorkflowTodo.d.ts +5 -8
  56. package/lib/client/nodes/manual/WorkflowTodo.js +111 -76
  57. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -2
  58. package/lib/client/nodes/manual/forms/create.d.ts +3 -0
  59. package/lib/client/nodes/manual/forms/create.js +104 -0
  60. package/lib/client/nodes/manual/forms/custom.d.ts +3 -0
  61. package/lib/client/nodes/manual/forms/{customForm.js → custom.js} +63 -45
  62. package/lib/client/nodes/manual/forms/update.d.ts +3 -0
  63. package/lib/client/nodes/manual/forms/update.js +161 -0
  64. package/lib/client/nodes/manual/index.d.ts +2 -5
  65. package/lib/client/nodes/manual/index.js +17 -16
  66. package/lib/client/nodes/manual/utils.d.ts +2 -0
  67. package/lib/client/nodes/manual/utils.js +31 -0
  68. package/lib/client/nodes/parallel.d.ts +4 -1
  69. package/lib/client/nodes/parallel.js +3 -1
  70. package/lib/client/nodes/query.d.ts +2 -5
  71. package/lib/client/nodes/query.js +2 -5
  72. package/lib/client/nodes/request.d.ts +1 -1
  73. package/lib/client/nodes/request.js +1 -11
  74. package/lib/client/nodes/update.d.ts +1 -1
  75. package/lib/client/schemas/collection.js +1 -1
  76. package/lib/client/schemas/executions.d.ts +2 -0
  77. package/lib/client/triggers/collection.d.ts +2 -5
  78. package/lib/client/triggers/collection.js +5 -8
  79. package/lib/client/triggers/index.d.ts +1 -2
  80. package/lib/client/triggers/index.js +4 -3
  81. package/lib/client/triggers/schedule/DateFieldsSelect.js +14 -12
  82. package/lib/client/triggers/schedule/EndsByField.d.ts +2 -2
  83. package/lib/client/triggers/schedule/OnField.d.ts +2 -2
  84. package/lib/client/triggers/schedule/RepeatField.d.ts +2 -2
  85. package/lib/client/triggers/schedule/ScheduleConfig.d.ts +2 -1
  86. package/lib/client/triggers/schedule/index.d.ts +3 -6
  87. package/lib/client/triggers/schedule/index.js +1 -4
  88. package/lib/server/Processor.js +1 -2
  89. package/lib/server/instructions/manual/actions.js +42 -47
  90. package/lib/server/instructions/manual/forms/create.d.ts +5 -0
  91. package/lib/server/instructions/manual/forms/create.js +46 -0
  92. package/lib/server/instructions/manual/forms/index.d.ts +6 -0
  93. package/lib/server/instructions/manual/forms/index.js +15 -0
  94. package/lib/server/instructions/manual/forms/update.d.ts +6 -0
  95. package/lib/server/instructions/manual/forms/update.js +47 -0
  96. package/lib/server/instructions/manual/index.d.ts +3 -0
  97. package/lib/server/instructions/manual/index.js +16 -3
  98. package/lib/server/instructions/request.js +1 -1
  99. package/lib/server/migrations/20230612021134-manual-collection-block.d.ts +4 -0
  100. package/lib/server/migrations/20230612021134-manual-collection-block.js +155 -0
  101. package/package.json +16 -13
  102. package/lib/client/WorkflowShortcut.d.ts +0 -1
  103. package/lib/client/WorkflowShortcut.js +0 -48
  104. package/lib/client/components/CollectionFieldInitializers.d.ts +0 -2
  105. package/lib/client/components/CollectionFieldInitializers.js +0 -70
  106. package/lib/client/nodes/manual/forms/customForm.d.ts +0 -40
@@ -11,11 +11,19 @@ function _actions() {
11
11
  };
12
12
  return data;
13
13
  }
14
+ function _utils() {
15
+ const data = require("@nocobase/utils");
16
+ _utils = function _utils() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
14
21
  var _constants = require("../../constants");
15
22
  var _jobs = _interopRequireDefault(require("./collecions/jobs"));
16
23
  var _users = _interopRequireDefault(require("./collecions/users"));
17
24
  var _users_jobs = _interopRequireDefault(require("./collecions/users_jobs"));
18
25
  var _actions2 = require("./actions");
26
+ var _forms = _interopRequireDefault(require("./forms"));
19
27
  const _excluded = ["mode"];
20
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
29
  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; }
@@ -81,6 +89,7 @@ function getMode(mode) {
81
89
  class _default {
82
90
  constructor(plugin) {
83
91
  this.plugin = void 0;
92
+ this.formTypes = new (_utils().Registry)();
84
93
  this.plugin = plugin;
85
94
  plugin.db.collection(_users_jobs.default);
86
95
  plugin.db.extendCollection(_users.default);
@@ -104,6 +113,7 @@ class _default {
104
113
  submit: _actions2.submit
105
114
  }
106
115
  });
116
+ (0, _forms.default)(this);
107
117
  }
108
118
  run(node, prevJob, processor) {
109
119
  return _asyncToGenerator(function* () {
@@ -135,7 +145,7 @@ class _default {
135
145
  }
136
146
  resume(node, job, processor) {
137
147
  return _asyncToGenerator(function* () {
138
- var _job$latestUserJob$re, _job$latestUserJob, _getMode$getStatus;
148
+ var _getMode$getStatus, _job$latestUserJob$re, _job$latestUserJob;
139
149
  // NOTE: check all users jobs related if all done then continue as parallel
140
150
  const _node$config2 = node.config,
141
151
  _node$config2$assigne = _node$config2.assignees,
@@ -146,12 +156,15 @@ class _default {
146
156
  where: {
147
157
  jobId: job.id
148
158
  },
149
- group: ['status']
159
+ group: ['status'],
160
+ transaction: processor.transaction
150
161
  });
151
162
  const submitted = distribution.reduce((count, item) => item.status !== _constants.JOB_STATUS.PENDING ? count + item.count : count, 0);
163
+ const status = job.status || ((_getMode$getStatus = getMode(mode).getStatus(distribution, assignees)) !== null && _getMode$getStatus !== void 0 ? _getMode$getStatus : _constants.JOB_STATUS.PENDING);
152
164
  const result = mode ? (submitted || 0) / assignees.length : (_job$latestUserJob$re = (_job$latestUserJob = job.latestUserJob) === null || _job$latestUserJob === void 0 ? void 0 : _job$latestUserJob.result) !== null && _job$latestUserJob$re !== void 0 ? _job$latestUserJob$re : job.result;
165
+ processor.logger.debug(`manual resume job and next status: ${status}`);
153
166
  job.set({
154
- status: job.status || ((_getMode$getStatus = getMode(mode).getStatus(distribution, assignees)) !== null && _getMode$getStatus !== void 0 ? _getMode$getStatus : _constants.JOB_STATUS.PENDING),
167
+ status,
155
168
  result
156
169
  });
157
170
  return job;
@@ -80,7 +80,7 @@ class _default {
80
80
  _this.plugin.resume(job);
81
81
  });
82
82
  _this.plugin.app.logger.info(`[Workflow] request (#${node.id}) sent to "${config.url}", waiting for response...`);
83
- return job;
83
+ return null;
84
84
  })();
85
85
  }
86
86
  resume(node, job, processor) {
@@ -0,0 +1,4 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ up(): Promise<void>;
4
+ }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _server() {
8
+ const data = require("@nocobase/server");
9
+ _server = function _server() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _utils() {
15
+ const data = require("@nocobase/utils");
16
+ _utils = function _utils() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ const _excluded = ["schema"];
22
+ 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; }
23
+ 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; }
24
+ 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); } }
25
+ 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); }); }; }
26
+ 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; }
27
+ 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; }
28
+ 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; }
29
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
30
+ 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); }
31
+ function findSchema(root, filter, onlyLeaf = false) {
32
+ const result = [];
33
+ if (!root) {
34
+ return result;
35
+ }
36
+ if (filter(root) && (!onlyLeaf || !root.properties)) {
37
+ result.push(root);
38
+ return result;
39
+ }
40
+ if (root.properties) {
41
+ Object.keys(root.properties).forEach(key => {
42
+ result.push(...findSchema(root.properties[key], filter));
43
+ });
44
+ }
45
+ return result;
46
+ }
47
+ function migrateSchema(schema = {}) {
48
+ const root = {
49
+ properties: schema
50
+ };
51
+ const collectionBlocks = findSchema(root, item => {
52
+ return item['x-component'] === 'CardItem' && item['x-designer'] === 'SimpleDesigner' && item['x-decorator'] === 'CollectionProvider';
53
+ });
54
+ collectionBlocks.forEach(block => {
55
+ const id = (0, _utils().uid)();
56
+ const grid = block.properties.grid;
57
+ delete block.properties.grid;
58
+ const fields = findSchema(grid, item => {
59
+ return item['x-decorator'] === 'FormItem';
60
+ });
61
+ fields.forEach(field => {
62
+ Object.assign(field, {
63
+ 'x-component': 'CollectionField',
64
+ 'x-collection-field': `${block['x-decorator-props'].collection}.${field['x-collection-field']}`
65
+ });
66
+ });
67
+ Object.assign(block, {
68
+ 'x-decorator': 'DetailsBlockProvider',
69
+ 'x-decorator-props': _objectSpread(_objectSpread({}, block['x-decorator-props']), {}, {
70
+ dataSource: grid['x-context-datasource']
71
+ }),
72
+ properties: {
73
+ [id]: {
74
+ type: 'void',
75
+ name: id,
76
+ 'x-component': 'FormV2',
77
+ 'x-component-props': {
78
+ useProps: '{{useDetailsBlockProps}}'
79
+ },
80
+ properties: {
81
+ grid: {
82
+ type: 'void',
83
+ name: 'grid',
84
+ 'x-component': 'Grid',
85
+ 'x-initializer': 'ReadPrettyFormItemInitializers',
86
+ properties: grid.properties
87
+ }
88
+ }
89
+ }
90
+ }
91
+ });
92
+ });
93
+ const customForms = findSchema(root, item => {
94
+ return item['x-decorator'] === 'FormCollectionProvider';
95
+ });
96
+ customForms.forEach(item => {
97
+ Object.assign(item, {
98
+ 'x-decorator': 'CustomFormBlockProvider'
99
+ });
100
+ });
101
+ const customFormFields = findSchema(root, item => {
102
+ return item['x-interface-options'];
103
+ });
104
+ customFormFields.forEach(field => {
105
+ const options = field['x-interface-options'];
106
+ delete field['x-interface-options'];
107
+ Object.assign(field, {
108
+ 'x-component-props': {
109
+ field: options
110
+ }
111
+ });
112
+ });
113
+ return schema;
114
+ }
115
+ class _default extends _server().Migration {
116
+ up() {
117
+ var _this = this;
118
+ return _asyncToGenerator(function* () {
119
+ const match = yield _this.app.version.satisfies('<0.9.4-alpha.3');
120
+ if (!match) {
121
+ return;
122
+ }
123
+ const db = _this.context.db;
124
+ const NodeRepo = db.getRepository('flow_nodes');
125
+ yield db.sequelize.transaction( /*#__PURE__*/function () {
126
+ var _ref = _asyncToGenerator(function* (transaction) {
127
+ const nodes = yield NodeRepo.find({
128
+ filter: {
129
+ type: 'manual'
130
+ },
131
+ transaction
132
+ });
133
+ console.log('%d nodes need to be migrated.', nodes.length);
134
+ yield nodes.reduce((promise, node) => promise.then(() => {
135
+ const _node$config = node.config,
136
+ schema = _node$config.schema,
137
+ config = _objectWithoutProperties(_node$config, _excluded);
138
+ node.set('config', _objectSpread(_objectSpread({}, config), {}, {
139
+ schema: _objectSpread({}, migrateSchema(schema))
140
+ }));
141
+ node.changed('config', true);
142
+ return node.save({
143
+ silent: true,
144
+ transaction
145
+ });
146
+ }), Promise.resolve());
147
+ });
148
+ return function (_x) {
149
+ return _ref.apply(this, arguments);
150
+ };
151
+ }());
152
+ })();
153
+ }
154
+ }
155
+ exports.default = _default;
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow",
3
- "version": "0.9.4-alpha.2",
4
- "description": "",
3
+ "displayName": "workflow",
4
+ "displayName.zh-CN": "工作流",
5
+ "description": " a powerful workflow plugin designed to support business process management and automation. .",
6
+ "description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
7
+ "version": "0.10.0-alpha.2",
5
8
  "license": "AGPL-3.0",
6
9
  "main": "./lib/index.js",
7
10
  "types": "./lib/index.d.ts",
8
11
  "dependencies": {
9
- "@nocobase/actions": "0.9.4-alpha.2",
10
- "@nocobase/client": "0.9.4-alpha.2",
11
- "@nocobase/database": "0.9.4-alpha.2",
12
- "@nocobase/evaluators": "0.9.4-alpha.2",
13
- "@nocobase/logger": "0.9.4-alpha.2",
14
- "@nocobase/resourcer": "0.9.4-alpha.2",
15
- "@nocobase/server": "0.9.4-alpha.2",
16
- "@nocobase/utils": "0.9.4-alpha.2",
12
+ "@nocobase/actions": "0.10.0-alpha.2",
13
+ "@nocobase/client": "0.10.0-alpha.2",
14
+ "@nocobase/database": "0.10.0-alpha.2",
15
+ "@nocobase/evaluators": "0.10.0-alpha.2",
16
+ "@nocobase/logger": "0.10.0-alpha.2",
17
+ "@nocobase/resourcer": "0.10.0-alpha.2",
18
+ "@nocobase/server": "0.10.0-alpha.2",
19
+ "@nocobase/utils": "0.10.0-alpha.2",
17
20
  "antd": "^4.24.8",
18
21
  "axios": "^0.27.2",
19
22
  "classnames": "^2.3.1",
@@ -23,9 +26,9 @@
23
26
  "react-js-cron": "^3.1.0"
24
27
  },
25
28
  "devDependencies": {
26
- "@nocobase/plugin-formula-field": "0.9.4-alpha.2",
27
- "@nocobase/test": "0.9.4-alpha.2",
29
+ "@nocobase/plugin-formula-field": "0.10.0-alpha.2",
30
+ "@nocobase/test": "0.10.0-alpha.2",
28
31
  "@types/ejs": "^3.1.1"
29
32
  },
30
- "gitHead": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
33
+ "gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
31
34
  }
@@ -1 +0,0 @@
1
- export declare const WorkflowShortcut: () => JSX.Element;
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WorkflowShortcut = void 0;
7
- function _react() {
8
- const data = _interopRequireDefault(require("react"));
9
- _react = function _react() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _icons() {
15
- const data = require("@ant-design/icons");
16
- _icons = function _icons() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _reactRouterDom() {
22
- const data = require("react-router-dom");
23
- _reactRouterDom = function _reactRouterDom() {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _client() {
29
- const data = require("@nocobase/client");
30
- _client = function _client() {
31
- return data;
32
- };
33
- return data;
34
- }
35
- var _locale = require("./locale");
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
- const WorkflowShortcut = () => {
38
- const history = (0, _reactRouterDom().useHistory)();
39
- return _react().default.createElement(_client().PluginManager.Toolbar.Item, {
40
- key: "workflow",
41
- icon: _react().default.createElement(_icons().PartitionOutlined, null),
42
- title: (0, _locale.lang)('Workflow'),
43
- onClick: () => {
44
- history.push('/admin/settings/workflow/workflows');
45
- }
46
- });
47
- };
48
- exports.WorkflowShortcut = WorkflowShortcut;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function CollectionFieldInitializers(props: any): JSX.Element;
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CollectionFieldInitializers = CollectionFieldInitializers;
7
- function _react() {
8
- const data = _interopRequireDefault(require("react"));
9
- _react = function _react() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _lodash() {
15
- const data = require("lodash");
16
- _lodash = function _lodash() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _client() {
22
- const data = require("@nocobase/client");
23
- _client = function _client() {
24
- return data;
25
- };
26
- return data;
27
- }
28
- const _excluded = ["field"];
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
- 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; }
31
- 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; }
32
- 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; }
33
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
34
- 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); }
35
- 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; }
36
- 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; }
37
- function CollectionFieldInitializer(_ref) {
38
- var _uiSchema$title;
39
- let field = _ref.field,
40
- props = _objectWithoutProperties(_ref, _excluded);
41
- const uiSchema = (0, _lodash().cloneDeep)(field.uiSchema);
42
- delete uiSchema['x-uid'];
43
- return _react().default.createElement(_client().InitializerWithSwitch, _objectSpread(_objectSpread({}, props), {}, {
44
- schema: _objectSpread(_objectSpread({}, uiSchema), {}, {
45
- name: field.name,
46
- title: (_uiSchema$title = uiSchema.title) !== null && _uiSchema$title !== void 0 ? _uiSchema$title : field.name,
47
- 'x-decorator': 'FormItem',
48
- 'x-read-pretty': true,
49
- 'x-designer': 'FormItem.Designer',
50
- 'x-collection-field': field.name
51
- }),
52
- type: "x-collection-field"
53
- }));
54
- }
55
- function CollectionFieldInitializers(props) {
56
- const _useCollection = (0, _client().useCollection)(),
57
- fields = _useCollection.fields;
58
- const items = fields.filter(field => !['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type) && field.uiSchema).map(field => ({
59
- key: field.name,
60
- type: 'item',
61
- title: field.uiSchema.title,
62
- component: CollectionFieldInitializer,
63
- field
64
- }));
65
- return _react().default.createElement(_client().SchemaInitializer.Button, _objectSpread(_objectSpread({}, props), {}, {
66
- items: items,
67
- title: "{{t('Configure fields')}}",
68
- wrap: _client().gridRowColWrap
69
- }));
70
- }
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- declare function FormCollectionProvider(props: any): JSX.Element;
3
- declare function CustomFormBlockInitializer({ insert, ...props }: {
4
- [x: string]: any;
5
- insert: any;
6
- }): JSX.Element;
7
- declare function AddCustomFormField(props: any): JSX.Element;
8
- declare function useFormBlockProps(): {
9
- form: import("@formily/core").Form<any>;
10
- };
11
- declare const _default: {
12
- title: string;
13
- config: {
14
- initializer: {
15
- key: string;
16
- type: string;
17
- title: string;
18
- component: typeof CustomFormBlockInitializer;
19
- };
20
- initializers: {
21
- AddCustomFormField: typeof AddCustomFormField;
22
- };
23
- components: {
24
- FormCollectionProvider: typeof FormCollectionProvider;
25
- };
26
- };
27
- block: {
28
- scope: {
29
- useFormBlockProps: typeof useFormBlockProps;
30
- };
31
- components: {
32
- FormCollectionProvider: React.FC<{
33
- allowNull?: boolean;
34
- name?: string;
35
- collection?: import("@nocobase/client").CollectionOptions;
36
- }>;
37
- };
38
- };
39
- };
40
- export default _default;