@nocobase/plugin-workflow 0.10.0-alpha.4 → 0.10.1-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.
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
- function _react() {
8
- const data = _interopRequireDefault(require("react"));
9
- _react = function _react() {
7
+ function _css() {
8
+ const data = require("@emotion/css");
9
+ _css = function _css() {
10
10
  return data;
11
11
  };
12
12
  return data;
@@ -18,9 +18,9 @@ function _antd() {
18
18
  };
19
19
  return data;
20
20
  }
21
- function _css() {
22
- const data = require("@emotion/css");
23
- _css = function _css() {
21
+ function _react() {
22
+ const data = _interopRequireDefault(require("react"));
23
+ _react = function _react() {
24
24
  return data;
25
25
  };
26
26
  return data;
@@ -62,6 +62,7 @@ function _default({
62
62
  value: quantity,
63
63
  onChange: v => _onChange(Math.round(v * option.value))
64
64
  }), _react().default.createElement(_antd().Select, {
65
+ dropdownMatchSelectWidth: false,
65
66
  value: option.value,
66
67
  onChange: unit => _onChange(Math.round(quantity * unit))
67
68
  }, UnitOptions.map(item => _react().default.createElement(_antd().Select.Option, {
@@ -69,6 +69,9 @@ const InternalExpression = (0, _react().observer)(props => {
69
69
  _useState2 = _slicedToArray(_useState, 2),
70
70
  collection = _useState2[0],
71
71
  setCollection = _useState2[1];
72
+ const compile = (0, _client().useCompile)();
73
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
74
+ getCollectionFields = _useCollectionManager.getCollectionFields;
72
75
  (0, _react().useFormEffects)(() => {
73
76
  (0, _core().onFormInitialValuesChange)(form => {
74
77
  setCollection(form.values.sourceCollection);
@@ -78,8 +81,10 @@ const InternalExpression = (0, _react().observer)(props => {
78
81
  onChange(null);
79
82
  });
80
83
  });
81
- const options = (0, _variable.useCollectionFieldOptions)({
82
- collection: collection
84
+ const options = (0, _variable.getCollectionFieldOptions)({
85
+ collection,
86
+ compile,
87
+ getCollectionFields
83
88
  });
84
89
  return _react2().default.createElement(_client().Variable.TextArea, _objectSpread(_objectSpread({}, props), {}, {
85
90
  scope: options
@@ -91,8 +96,13 @@ function Result(props) {
91
96
  const _useTranslation = (0, _reactI18next().useTranslation)(),
92
97
  t = _useTranslation.t;
93
98
  const values = (0, _client().useRecord)();
94
- const options = (0, _react2().useMemo)(() => (0, _variable.useCollectionFieldOptions)({
95
- collection: values.sourceCollection
99
+ const compile = (0, _client().useCompile)();
100
+ const _useCollectionManager2 = (0, _client().useCollectionManager)(),
101
+ getCollectionFields = _useCollectionManager2.getCollectionFields;
102
+ const options = (0, _react2().useMemo)(() => (0, _variable.getCollectionFieldOptions)({
103
+ collection: values.sourceCollection,
104
+ compile,
105
+ getCollectionFields
96
106
  }), [values.sourceCollection, values.sourceCollection]);
97
107
  return props.value ? _react2().default.createElement(_client().Variable.TextArea, _objectSpread(_objectSpread({}, props), {}, {
98
108
  scope: options
@@ -178,9 +178,15 @@ declare const _default: {
178
178
  };
179
179
  AssociatedConfig: typeof AssociatedConfig;
180
180
  };
181
- useVariables(current: any, { types }: {
181
+ useVariables({ id, title }: {
182
+ id: any;
183
+ title: any;
184
+ }, { types }: {
182
185
  types: any;
183
- }): any[];
186
+ }): {
187
+ value: string;
188
+ label: any;
189
+ };
184
190
  useInitializers(node: any): SchemaInitializerItemOptions | null;
185
191
  };
186
192
  export default _default;
@@ -38,7 +38,6 @@ var _FilterDynamicComponent = require("../components/FilterDynamicComponent");
38
38
  var _variable = require("../variable");
39
39
  var _FieldsSelect = require("../components/FieldsSelect");
40
40
  var _ValueBlock = require("../components/ValueBlock");
41
- var _ = require(".");
42
41
  const _excluded = ["value", "onChange"];
43
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); }
44
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; }
@@ -49,8 +48,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
49
48
  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); }
50
49
  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; }
51
50
  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; }
52
- function matchToManyField(field, depth) {
53
- return ['hasMany', 'belongsToMany'].includes(field.type) && depth;
51
+ function matchToManyField(field, appends) {
52
+ const fieldPrefix = `${field.name}.`;
53
+ return ['hasMany', 'belongsToMany'].includes(field.type) && (appends.includes(field.name) || appends.some(item => item.startsWith(fieldPrefix)));
54
54
  }
55
55
  function AssociatedConfig(_ref) {
56
56
  let value = _ref.value,
@@ -61,7 +61,6 @@ function AssociatedConfig(_ref) {
61
61
  const compile = (0, _client().useCompile)();
62
62
  const _useCollectionManager = (0, _client().useCollectionManager)(),
63
63
  getCollection = _useCollectionManager.getCollection;
64
- const current = (0, _.useNodeContext)();
65
64
  const options = [_variable.nodesOptions, _variable.triggerOptions].map(item => {
66
65
  var _item$useOptions;
67
66
  const children = (_item$useOptions = item.useOptions({
@@ -322,15 +321,19 @@ var _default = {
322
321
  ValueBlock: _ValueBlock.ValueBlock,
323
322
  AssociatedConfig
324
323
  },
325
- useVariables(current, {
324
+ useVariables({
325
+ id,
326
+ title
327
+ }, {
326
328
  types
327
329
  }) {
328
330
  if (types && !types.some(type => type in _variable.BaseTypeSets || Object.values(_variable.BaseTypeSets).some(set => set.has(type)))) {
329
331
  return null;
330
332
  }
331
- return [
332
- // { key: '', value: '', label: lang('Calculation result') }
333
- ];
333
+ return {
334
+ value: `${id}`,
335
+ label: title
336
+ };
334
337
  },
335
338
  useInitializers(node) {
336
339
  var _node$title;
@@ -1,14 +1,6 @@
1
1
  import { SchemaInitializerItemOptions } from '@nocobase/client';
2
2
  import React from 'react';
3
3
  import { RadioWithTooltip } from '../components/RadioWithTooltip';
4
- import { useWorkflowVariableOptions } from '../variable';
5
- declare function useWorkflowVariableEntityOptions(): {
6
- label: any;
7
- value: any;
8
- key: any;
9
- children: any;
10
- disabled: boolean;
11
- }[];
12
4
  declare const _default: {
13
5
  title: string;
14
6
  type: string;
@@ -44,9 +36,6 @@ declare const _default: {
44
36
  title: string;
45
37
  'x-decorator': string;
46
38
  'x-component': string;
47
- 'x-component-props': {
48
- scope: string;
49
- };
50
39
  "x-validator"(value: any, rules: any, { form }: {
51
40
  form: any;
52
41
  }): string;
@@ -75,7 +64,7 @@ declare const _default: {
75
64
  'x-decorator': string;
76
65
  'x-component': string;
77
66
  'x-component-props': {
78
- scope: string;
67
+ changeOnSelect: boolean;
79
68
  };
80
69
  'x-reactions': {
81
70
  dependencies: string[];
@@ -89,11 +78,11 @@ declare const _default: {
89
78
  };
90
79
  view: {};
91
80
  scope: {
92
- useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
93
- useWorkflowVariableEntityOptions: typeof useWorkflowVariableEntityOptions;
94
81
  renderEngineReference: (key: string) => React.JSX.Element;
95
82
  };
96
83
  components: {
84
+ CalculationExpression(props: any): React.JSX.Element;
85
+ ScopeSelect(props: any): React.JSX.Element;
97
86
  CalculationResult({ dataSource }: {
98
87
  dataSource: any;
99
88
  }): string | React.JSX.Element;
@@ -103,7 +92,13 @@ declare const _default: {
103
92
  onChange: any;
104
93
  }) => React.JSX.Element;
105
94
  };
106
- useVariables(current: any, options: any): any[];
95
+ useVariables({ id, title }: {
96
+ id: any;
97
+ title: any;
98
+ }, options: any): {
99
+ value: any;
100
+ label: any;
101
+ };
107
102
  useInitializers(node: any): SchemaInitializerItemOptions;
108
103
  };
109
104
  export default _default;
@@ -67,13 +67,20 @@ var _locale = require("../locale");
67
67
  var _variable = require("../variable");
68
68
  var _ValueBlock = require("../components/ValueBlock");
69
69
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
+ 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; }
71
+ 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; }
72
+ 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; }
73
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
74
+ 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); }
70
75
  function useDynamicExpressionCollectionFieldMatcher(field) {
71
- const _useCollectionManager = (0, _client().useCollectionManager)(),
72
- getCollectionFields = _useCollectionManager.getCollectionFields;
73
- if (field.type !== 'belongsTo') {
76
+ var _this$getCollection;
77
+ if (!['belongsTo', 'hasOne'].includes(field.type)) {
74
78
  return false;
75
79
  }
76
- const fields = getCollectionFields(field.target);
80
+ if (((_this$getCollection = this.getCollection(field.collectionName)) === null || _this$getCollection === void 0 ? void 0 : _this$getCollection.template) === 'expression') {
81
+ return true;
82
+ }
83
+ const fields = this.getCollectionFields(field.target);
77
84
  return fields.some(f => f.interface === 'expression');
78
85
  }
79
86
  const DynamicConfig = ({
@@ -82,8 +89,14 @@ const DynamicConfig = ({
82
89
  }) => {
83
90
  const _useTranslation = (0, _reactI18next().useTranslation)(),
84
91
  t = _useTranslation.t;
92
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
93
+ getCollectionFields = _useCollectionManager.getCollectionFields,
94
+ getCollection = _useCollectionManager.getCollection;
85
95
  const scope = (0, _variable.useWorkflowVariableOptions)({
86
- types: [useDynamicExpressionCollectionFieldMatcher]
96
+ types: [useDynamicExpressionCollectionFieldMatcher.bind({
97
+ getCollectionFields,
98
+ getCollection
99
+ })]
87
100
  });
88
101
  return _react().default.createElement(_antd().FormLayout, {
89
102
  layout: "vertical"
@@ -118,17 +131,6 @@ const DynamicConfig = ({
118
131
  scope: scope
119
132
  })) : null);
120
133
  };
121
- function useWorkflowVariableEntityOptions() {
122
- return (0, _variable.useWorkflowVariableOptions)({
123
- types: [{
124
- type: 'reference',
125
- options: {
126
- collection: '*',
127
- entity: true
128
- }
129
- }]
130
- });
131
- }
132
134
  var _default = {
133
135
  title: `{{t("Calculation", { ns: "${_locale.NAMESPACE}" })}}`,
134
136
  type: 'calculation',
@@ -164,10 +166,13 @@ var _default = {
164
166
  type: 'string',
165
167
  title: `{{t("Calculation expression", { ns: "${_locale.NAMESPACE}" })}}`,
166
168
  'x-decorator': 'FormItem',
167
- 'x-component': 'Variable.TextArea',
168
- 'x-component-props': {
169
- scope: '{{useWorkflowVariableOptions}}'
170
- },
169
+ 'x-component': 'CalculationExpression',
170
+ // NOTE: can not use Variable.Input and scope directly as below,
171
+ // because the scope will be cached.
172
+ // 'x-component': 'Variable.Input',
173
+ // 'x-component-props': {
174
+ // scope: '{{useWorkflowVariableOptions()}}',
175
+ // },
171
176
  ['x-validator'](value, rules, {
172
177
  form
173
178
  }) {
@@ -203,15 +208,15 @@ var _default = {
203
208
  type: 'string',
204
209
  title: `{{t("Variable datasource", { ns: "${_locale.NAMESPACE}" })}}`,
205
210
  'x-decorator': 'FormItem',
206
- 'x-component': 'Variable.Input',
211
+ 'x-component': 'ScopeSelect',
207
212
  'x-component-props': {
208
- scope: '{{useWorkflowVariableEntityOptions}}'
213
+ changeOnSelect: true
209
214
  },
210
215
  'x-reactions': {
211
216
  dependencies: ['dynamic'],
212
217
  fulfill: {
213
218
  state: {
214
- visible: '{{$deps[0] !== false}}'
219
+ visible: '{{$deps[0]}}'
215
220
  }
216
221
  }
217
222
  }
@@ -219,11 +224,29 @@ var _default = {
219
224
  },
220
225
  view: {},
221
226
  scope: {
222
- useWorkflowVariableOptions: _variable.useWorkflowVariableOptions,
223
- useWorkflowVariableEntityOptions,
224
227
  renderEngineReference: _renderEngineReference.renderEngineReference
225
228
  },
226
229
  components: {
230
+ CalculationExpression(props) {
231
+ const scope = (0, _variable.useWorkflowVariableOptions)();
232
+ return _react().default.createElement(_client().Variable.TextArea, _objectSpread({
233
+ scope: scope
234
+ }, props));
235
+ },
236
+ ScopeSelect(props) {
237
+ const scope = (0, _variable.useWorkflowVariableOptions)({
238
+ types: [{
239
+ type: 'reference',
240
+ options: {
241
+ collection: '*',
242
+ entity: true
243
+ }
244
+ }]
245
+ });
246
+ return _react().default.createElement(_client().Variable.Input, _objectSpread({
247
+ scope: scope
248
+ }, props));
249
+ },
227
250
  CalculationResult({
228
251
  dataSource
229
252
  }) {
@@ -247,15 +270,19 @@ var _default = {
247
270
  RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip,
248
271
  DynamicConfig
249
272
  },
250
- useVariables(current, options) {
273
+ useVariables({
274
+ id,
275
+ title
276
+ }, options) {
251
277
  const _ref = options !== null && options !== void 0 ? options : {},
252
278
  types = _ref.types;
253
279
  if (types && !types.some(type => type in _variable.BaseTypeSets || Object.values(_variable.BaseTypeSets).some(set => set.has(type)))) {
254
280
  return null;
255
281
  }
256
- return [
257
- // { key: '', value: '', label: lang('Calculation result') }
258
- ];
282
+ return {
283
+ value: id,
284
+ label: title
285
+ };
259
286
  },
260
287
  useInitializers(node) {
261
288
  var _node$title;
@@ -64,9 +64,6 @@ declare const _default: {
64
64
  title: string;
65
65
  'x-decorator': string;
66
66
  'x-component': string;
67
- 'x-component-props': {
68
- scope: string;
69
- };
70
67
  "x-validator"(value: any, rules: any, { form }: {
71
68
  form: any;
72
69
  }): string;
@@ -101,6 +98,7 @@ declare const _default: {
101
98
  };
102
99
  components: {
103
100
  CalculationConfig: typeof CalculationConfig;
101
+ CalculationExpression(props: any): React.JSX.Element;
104
102
  RadioWithTooltip: typeof RadioWithTooltip;
105
103
  };
106
104
  };
@@ -432,10 +432,7 @@ var _default = {
432
432
  type: 'string',
433
433
  title: `{{t("Condition expression", { ns: "${_locale.NAMESPACE}" })}}`,
434
434
  'x-decorator': 'FormItem',
435
- 'x-component': 'Variable.TextArea',
436
- 'x-component-props': {
437
- scope: '{{useWorkflowVariableOptions}}'
438
- },
435
+ 'x-component': 'CalculationExpression',
439
436
  ['x-validator'](value, rules, {
440
437
  form
441
438
  }) {
@@ -540,6 +537,12 @@ var _default = {
540
537
  },
541
538
  components: {
542
539
  CalculationConfig,
540
+ CalculationExpression(props) {
541
+ const scope = (0, _variable.useWorkflowVariableOptions)();
542
+ return _react().default.createElement(_client().Variable.TextArea, _objectSpread({
543
+ scope: scope
544
+ }, props));
545
+ },
543
546
  RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip
544
547
  }
545
548
  };
@@ -61,9 +61,11 @@ declare const _default: {
61
61
  CollectionFieldset: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Pick<any, string | number | symbol>>>;
62
62
  FieldsSelect: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Pick<any, string | number | symbol>>>;
63
63
  };
64
- useVariables({ config }: {
64
+ useVariables({ id, title, config }: {
65
+ id: any;
66
+ title: any;
65
67
  config: any;
66
- }, options: any): import("../variable").VariableOption[];
68
+ }, options: any): import("../variable").VariableOption;
67
69
  useInitializers(node: any): SchemaInitializerItemOptions | null;
68
70
  initializers: {};
69
71
  };
@@ -23,6 +23,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
23
23
  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; }
24
24
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
25
25
  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); }
26
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
+ 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."); }
28
+ 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); }
29
+ 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; }
30
+ 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; } }
31
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
32
  var _default = {
27
33
  title: `{{t("Create record", { ns: "${_locale.NAMESPACE}" })}}`,
28
34
  type: 'create',
@@ -57,15 +63,36 @@ var _default = {
57
63
  FieldsSelect: _FieldsSelect.FieldsSelect
58
64
  },
59
65
  useVariables({
66
+ id,
67
+ title,
60
68
  config
61
69
  }, options) {
62
- var _options$depth, _config$params, _config$params$append;
63
- const result = (0, _variable.useCollectionFieldOptions)(_objectSpread(_objectSpread({
64
- collection: config === null || config === void 0 ? void 0 : config.collection
65
- }, options), {}, {
66
- depth: ((_options$depth = options === null || options === void 0 ? void 0 : options.depth) !== null && _options$depth !== void 0 ? _options$depth : config === null || config === void 0 ? void 0 : (_config$params = config.params) === null || _config$params === void 0 ? void 0 : (_config$params$append = _config$params.appends) === null || _config$params$append === void 0 ? void 0 : _config$params$append.length) ? 1 : 0
67
- }));
68
- return (result === null || result === void 0 ? void 0 : result.length) ? result : null;
70
+ var _config$params, _config$params$append;
71
+ const compile = (0, _client().useCompile)();
72
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
73
+ getCollectionFields = _useCollectionManager.getCollectionFields;
74
+ // const depth = config?.params?.appends?.length
75
+ // ? config?.params?.appends.reduce((max, item) => Math.max(max, item.split('.').length), 1)
76
+ // : 0;
77
+ const name = `${id}`;
78
+ const _getCollectionFieldOp = (0, _variable.getCollectionFieldOptions)(_objectSpread(_objectSpread({}, options), {}, {
79
+ fields: [{
80
+ collectionName: config.collection,
81
+ name,
82
+ type: 'hasOne',
83
+ target: config.collection,
84
+ uiSchema: {
85
+ title
86
+ }
87
+ }],
88
+ // depth: options?.depth ?? depth,
89
+ appends: [name, ...(((_config$params = config.params) === null || _config$params === void 0 ? void 0 : (_config$params$append = _config$params.appends) === null || _config$params$append === void 0 ? void 0 : _config$params$append.map(item => `${name}.${item}`)) || [])],
90
+ compile,
91
+ getCollectionFields
92
+ })),
93
+ _getCollectionFieldOp2 = _slicedToArray(_getCollectionFieldOp, 1),
94
+ result = _getCollectionFieldOp2[0];
95
+ return result;
69
96
  },
70
97
  useInitializers(node) {
71
98
  var _node$title;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ISchema } from '@formily/react';
3
3
  import { Registry } from '@nocobase/utils/client';
4
4
  import { SchemaInitializerItemOptions } from '@nocobase/client';
5
- import { VariableOptions } from '../variable';
5
+ import { VariableOption, VariableOptions } from '../variable';
6
6
  export interface Instruction {
7
7
  title: string;
8
8
  type: string;
@@ -25,7 +25,7 @@ export interface Instruction {
25
25
  };
26
26
  component?(props: any): JSX.Element;
27
27
  endding?: boolean;
28
- useVariables?(node: any, options?: any): VariableOptions;
28
+ useVariables?(node: any, options?: any): VariableOption;
29
29
  useScopeVariables?(node: any, options?: any): VariableOptions;
30
30
  useInitializers?(node: any): SchemaInitializerItemOptions | null;
31
31
  initializers?: {
@@ -14,7 +14,9 @@ declare const _default: {
14
14
  'x-component': string;
15
15
  'x-component-props': {
16
16
  scope: string;
17
+ changeOnSelect: boolean;
17
18
  useTypedConstant: string[];
19
+ className: string;
18
20
  };
19
21
  required: boolean;
20
22
  };
@@ -66,8 +66,20 @@ var _default = {
66
66
  'x-decorator': 'FormItem',
67
67
  'x-component': 'Variable.Input',
68
68
  'x-component-props': {
69
- scope: '{{useWorkflowVariableOptions}}',
70
- useTypedConstant: ['string', 'number', 'null']
69
+ scope: '{{useWorkflowVariableOptions()}}',
70
+ changeOnSelect: true,
71
+ useTypedConstant: ['string', 'number', 'null'],
72
+ className: (0, _css().css)`
73
+ width: 100%;
74
+
75
+ .variable {
76
+ flex: 1;
77
+ }
78
+
79
+ .ant-input.null-value {
80
+ width: 100%;
81
+ }
82
+ `
71
83
  },
72
84
  required: true
73
85
  }
@@ -628,6 +628,7 @@ function Drawer() {
628
628
  }));
629
629
  }
630
630
  function Decorator({
631
+ params = {},
631
632
  children
632
633
  }) {
633
634
  const _useCollectionManager = (0, _client().useCollectionManager)(),
@@ -637,12 +638,13 @@ function Decorator({
637
638
  collection: 'users_jobs',
638
639
  resource: 'users_jobs',
639
640
  action: 'list',
640
- params: {
641
+ params: _objectSpread(_objectSpread({
641
642
  pageSize: 20,
642
- sort: ['-createdAt'],
643
+ sort: ['-createdAt']
644
+ }, params), {}, {
643
645
  appends: ['user', 'node', 'workflow'],
644
646
  except: ['node.config', 'workflow.config']
645
- },
647
+ }),
646
648
  rowKey: 'id',
647
649
  showIndex: true,
648
650
  dragSort: false
@@ -58,17 +58,23 @@ declare const _default: {
58
58
  ModeConfig: typeof ModeConfig;
59
59
  AssigneesSelect: typeof AssigneesSelect;
60
60
  };
61
- useVariables({ config }: {
61
+ useVariables({ id, title, config }: {
62
+ id: any;
63
+ title: any;
62
64
  config: any;
63
65
  }, { types }: {
64
66
  types: any;
65
67
  }): {
66
- key: string;
67
68
  value: string;
68
69
  label: any;
69
- title: any;
70
- children: import("../../variable").VariableOption[];
71
- }[];
70
+ children: {
71
+ key: string;
72
+ value: string;
73
+ label: any;
74
+ title: any;
75
+ children: import("../../variable").VariableOption[];
76
+ }[];
77
+ };
72
78
  useInitializers(node: any): SchemaInitializerItemOptions | null;
73
79
  initializers: {};
74
80
  };
@@ -94,11 +94,16 @@ var _default = {
94
94
  AssigneesSelect: _AssigneesSelect.AssigneesSelect
95
95
  },
96
96
  useVariables({
97
+ id,
98
+ title,
97
99
  config
98
100
  }, {
99
101
  types
100
102
  }) {
101
103
  var _config$forms;
104
+ const compile = (0, _client().useCompile)();
105
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
106
+ getCollectionFields = _useCollectionManager.getCollectionFields;
102
107
  const formKeys = Object.keys((_config$forms = config.forms) !== null && _config$forms !== void 0 ? _config$forms : {});
103
108
  if (!formKeys.length) {
104
109
  return null;
@@ -106,26 +111,32 @@ var _default = {
106
111
  const options = formKeys.map(formKey => {
107
112
  var _form$collection;
108
113
  const form = config.forms[formKey];
109
- // eslint-disable-next-line react-hooks/rules-of-hooks
110
- const options = (0, _variable.useCollectionFieldOptions)({
114
+ const fieldsOptions = (0, _variable.getCollectionFieldOptions)({
111
115
  fields: (_form$collection = form.collection) === null || _form$collection === void 0 ? void 0 : _form$collection.fields,
112
116
  collection: form.collection,
113
- types
117
+ types,
118
+ compile,
119
+ getCollectionFields
114
120
  });
115
- return options.length ? {
121
+ const label = compile(form.title) || formKey;
122
+ return fieldsOptions.length ? {
116
123
  key: formKey,
117
124
  value: formKey,
118
- label: form.title || formKey,
119
- title: form.title || formKey,
120
- children: options
125
+ label,
126
+ title: label,
127
+ children: fieldsOptions
121
128
  } : null;
122
129
  }).filter(Boolean);
123
- return options.length ? options : null;
130
+ return options.length ? {
131
+ value: `${id}`,
132
+ label: title,
133
+ children: options
134
+ } : null;
124
135
  },
125
136
  useInitializers(node) {
126
137
  var _node$config$forms;
127
- const _useCollectionManager = (0, _client().useCollectionManager)(),
128
- getCollection = _useCollectionManager.getCollection;
138
+ const _useCollectionManager2 = (0, _client().useCollectionManager)(),
139
+ getCollection = _useCollectionManager2.getCollection;
129
140
  const formKeys = Object.keys((_node$config$forms = node.config.forms) !== null && _node$config$forms !== void 0 ? _node$config$forms : {});
130
141
  if (!formKeys.length || node.config.mode) {
131
142
  return null;
@@ -77,9 +77,11 @@ declare const _default: {
77
77
  FilterDynamicComponent: typeof FilterDynamicComponent;
78
78
  FieldsSelect: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Pick<any, string | number | symbol>>>;
79
79
  };
80
- useVariables({ config }: {
80
+ useVariables({ id, title, config }: {
81
+ id: any;
82
+ title: any;
81
83
  config: any;
82
- }, options: any): import("../variable").VariableOption[];
84
+ }, options: any): import("../variable").VariableOption;
83
85
  useInitializers(node: any): SchemaInitializerItemOptions | null;
84
86
  initializers: {};
85
87
  };