@nocobase/plugin-workflow 0.7.4-alpha.4 → 0.7.5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.d.ts CHANGED
File without changes
package/client.js CHANGED
File without changes
@@ -1,13 +1,12 @@
1
1
  import React from "react";
2
+ import { Registry } from "@nocobase/utils/client";
2
3
  declare function NullRender(): any;
3
- export declare const calculators: {
4
- value: string;
5
- title: string;
6
- children: {
7
- value: string;
8
- name: string;
9
- }[];
10
- }[];
4
+ interface Calculator {
5
+ name: string;
6
+ type: 'boolean' | 'number' | 'string' | 'date' | 'unknown' | 'null' | 'array';
7
+ group: string;
8
+ }
9
+ export declare const calculators: Registry<Calculator>;
11
10
  export declare function parseStringValue(value: string, Types: any): {
12
11
  type: string;
13
12
  value: string;
@@ -97,5 +96,4 @@ export declare function VariableComponent({ value, onChange, renderSchemaCompone
97
96
  onChange: any;
98
97
  renderSchemaComponent: any;
99
98
  }): JSX.Element;
100
- export declare const CollectionFieldset: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
101
99
  export {};
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BaseTypeSet = void 0;
7
7
  exports.Calculation = Calculation;
8
- exports.CollectionFieldset = void 0;
9
8
  exports.Operand = Operand;
10
9
  exports.VariableComponent = VariableComponent;
11
10
  exports.calculators = exports.VariableTypesContext = exports.VariableTypes = void 0;
@@ -22,16 +21,6 @@ function _react() {
22
21
  return data;
23
22
  }
24
23
 
25
- function _react2() {
26
- const data = require("@formily/react");
27
-
28
- _react2 = function _react2() {
29
- return data;
30
- };
31
-
32
- return data;
33
- }
34
-
35
24
  function _antd() {
36
25
  const data = require("antd");
37
26
 
@@ -52,16 +41,6 @@ function _css() {
52
41
  return data;
53
42
  }
54
43
 
55
- function _icons() {
56
- const data = require("@ant-design/icons");
57
-
58
- _icons = function _icons() {
59
- return data;
60
- };
61
-
62
- return data;
63
- }
64
-
65
44
  function _client() {
66
45
  const data = require("@nocobase/client");
67
46
 
@@ -88,15 +67,17 @@ function _reactI18next() {
88
67
  return data;
89
68
  }
90
69
 
91
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
+ function _client2() {
71
+ const data = require("@nocobase/utils/client");
92
72
 
93
- 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; }
94
-
95
- 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; }
73
+ _client2 = function _client2() {
74
+ return data;
75
+ };
96
76
 
97
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
77
+ return data;
78
+ }
98
79
 
99
- 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
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
100
81
 
101
82
  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; }
102
83
 
@@ -120,75 +101,116 @@ function NullRender() {
120
101
  return null;
121
102
  }
122
103
 
123
- const calculators = [{
104
+ const calculators = new (_client2().Registry)();
105
+ exports.calculators = calculators;
106
+ calculators.register('equal', {
107
+ name: '=',
108
+ type: 'boolean',
109
+ group: 'boolean'
110
+ });
111
+ calculators.register('notEqual', {
112
+ name: '≠',
113
+ type: 'boolean',
114
+ group: 'boolean'
115
+ });
116
+ calculators.register('gt', {
117
+ name: '>',
118
+ type: 'boolean',
119
+ group: 'boolean'
120
+ });
121
+ calculators.register('gte', {
122
+ name: '≥',
123
+ type: 'boolean',
124
+ group: 'boolean'
125
+ });
126
+ calculators.register('lt', {
127
+ name: '<',
128
+ type: 'boolean',
129
+ group: 'boolean'
130
+ });
131
+ calculators.register('lte', {
132
+ name: '≤',
133
+ type: 'boolean',
134
+ group: 'boolean'
135
+ });
136
+ calculators.register('add', {
137
+ name: '+',
138
+ type: 'number',
139
+ group: 'number'
140
+ });
141
+ calculators.register('minus', {
142
+ name: '-',
143
+ type: 'number',
144
+ group: 'number'
145
+ });
146
+ calculators.register('multiple', {
147
+ name: '*',
148
+ type: 'number',
149
+ group: 'number'
150
+ });
151
+ calculators.register('divide', {
152
+ name: '/',
153
+ type: 'number',
154
+ group: 'number'
155
+ });
156
+ calculators.register('mod', {
157
+ name: '%',
158
+ type: 'number',
159
+ group: 'number'
160
+ });
161
+ calculators.register('includes', {
162
+ name: '{{t("contains")}}',
163
+ type: 'boolean',
164
+ group: 'string'
165
+ });
166
+ calculators.register('notIncludes', {
167
+ name: '{{t("does not contain")}}',
168
+ type: 'boolean',
169
+ group: 'string'
170
+ });
171
+ calculators.register('startsWith', {
172
+ name: '{{t("starts with")}}',
173
+ type: 'boolean',
174
+ group: 'string'
175
+ });
176
+ calculators.register('notStartsWith', {
177
+ name: '{{t("not starts with")}}',
178
+ type: 'boolean',
179
+ group: 'string'
180
+ });
181
+ calculators.register('endsWith', {
182
+ name: '{{t("ends with")}}',
183
+ type: 'boolean',
184
+ group: 'string'
185
+ });
186
+ calculators.register('notEndsWith', {
187
+ name: '{{t("not ends with")}}',
188
+ type: 'boolean',
189
+ group: 'string'
190
+ });
191
+ calculators.register('concat', {
192
+ name: '{{t("concat")}}',
193
+ type: 'string',
194
+ group: 'string'
195
+ });
196
+ const calculatorGroups = [{
124
197
  value: 'boolean',
125
- title: '{{t("Comparison")}}',
126
- children: [{
127
- value: 'equal',
128
- name: '='
129
- }, {
130
- value: 'notEqual',
131
- name: '≠'
132
- }, {
133
- value: 'gt',
134
- name: '>'
135
- }, {
136
- value: 'gte',
137
- name: '≥'
138
- }, {
139
- value: 'lt',
140
- name: '<'
141
- }, {
142
- value: 'lte',
143
- name: '≤'
144
- }]
198
+ title: '{{t("Comparison")}}'
145
199
  }, {
146
200
  value: 'number',
147
- title: '{{t("Arithmetic calculation")}}',
148
- children: [{
149
- value: 'add',
150
- name: '+'
151
- }, {
152
- value: 'minus',
153
- name: '-'
154
- }, {
155
- value: 'multiple',
156
- name: '*'
157
- }, {
158
- value: 'divide',
159
- name: '/'
160
- }, {
161
- value: 'mod',
162
- name: '%'
163
- }]
201
+ title: '{{t("Arithmetic calculation")}}'
164
202
  }, {
165
203
  value: 'string',
166
- title: '{{t("String operation")}}',
167
- children: [{
168
- value: 'includes',
169
- name: '{{t("contains")}}'
170
- }, {
171
- value: 'notIncludes',
172
- name: '{{t("does not contain")}}'
173
- }, {
174
- value: 'startsWith',
175
- name: '{{t("starts with")}}'
176
- }, {
177
- value: 'notStartsWith',
178
- name: '{{t("not starts with")}}'
179
- }, {
180
- value: 'endsWith',
181
- name: '{{t("ends with")}}'
182
- }, {
183
- value: 'notEndsWith',
184
- name: '{{t("not ends with")}}'
185
- }]
204
+ title: '{{t("String operation")}}'
186
205
  }, {
187
206
  value: 'date',
188
- title: '{{t("Date")}}',
189
- children: []
207
+ title: '{{t("Date")}}'
190
208
  }];
191
- exports.calculators = calculators;
209
+
210
+ function getGroupCalculators(group) {
211
+ return Array.from(calculators.getEntities()).filter(([key, value]) => value.group === group);
212
+ }
213
+
192
214
  const JT_VALUE_RE = /^\s*\{\{([\s\S]*)\}\}\s*$/;
193
215
 
194
216
  function parseStringValue(value, Types) {
@@ -577,13 +599,15 @@ function Calculation({
577
599
  calculator: v
578
600
  }),
579
601
  placeholder: t('Calculator')
580
- }, calculators.map(group => _react().default.createElement(_antd().Select.OptGroup, {
602
+ }, calculatorGroups.map(group => _react().default.createElement(_antd().Select.OptGroup, {
581
603
  key: group.value,
582
604
  label: compile(group.title)
583
- }, group.children.map(item => _react().default.createElement(_antd().Select.Option, {
584
- key: item.value,
585
- value: item.value
586
- }, compile(item.name)))))), _react().default.createElement(Operand, {
605
+ }, getGroupCalculators(group.value).map(([value, {
606
+ name
607
+ }]) => _react().default.createElement(_antd().Select.Option, {
608
+ key: value,
609
+ value: value
610
+ }, compile(name)))))), _react().default.createElement(Operand, {
587
611
  value: operands[1],
588
612
  onChange: v => _onChange5({
589
613
  calculator,
@@ -623,117 +647,4 @@ function VariableComponent({
623
647
  }
624
648
  }
625
649
  }, operand.type === 'constant' ? renderSchemaComponent() : null));
626
- } // NOTE: observer for watching useProps
627
-
628
-
629
- const CollectionFieldset = (0, _react2().observer)(({
630
- value,
631
- onChange: _onChange7
632
- }) => {
633
- var _data$config;
634
-
635
- const _useTranslation3 = (0, _reactI18next().useTranslation)(),
636
- t = _useTranslation3.t;
637
-
638
- const compile = (0, _client().useCompile)();
639
-
640
- const _useCollectionManager = (0, _client().useCollectionManager)(),
641
- getCollectionFields = _useCollectionManager.getCollectionFields;
642
-
643
- const _useForm = (0, _react2().useForm)(),
644
- data = _useForm.values;
645
-
646
- const fields = getCollectionFields(data === null || data === void 0 ? void 0 : (_data$config = data.config) === null || _data$config === void 0 ? void 0 : _data$config.collection).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false));
647
-
648
- const VTypes = _objectSpread(_objectSpread({}, VariableTypes), {}, {
649
- constant: {
650
- title: '{{t("Constant")}}',
651
- value: 'constant',
652
- options: undefined
653
- }
654
- });
655
-
656
- return _react().default.createElement("fieldset", {
657
- className: (0, _css().css)`
658
- margin-top: .5em;
659
-
660
- > .ant-formily-item{
661
- flex-direction: column;
662
-
663
- > .ant-formily-item-label{
664
- line-height: 32px;
665
- }
666
- }
667
- `
668
- }, fields.length ? _react().default.createElement(_react().default.Fragment, null, fields.filter(field => field.name in value).map(field => {
669
- var _field$uiSchema$title, _field$uiSchema;
670
-
671
- const operand = typeof value[field.name] === 'string' ? parseStringValue(value[field.name], VTypes) : {
672
- type: 'constant',
673
- value: value[field.name]
674
- }; // TODO: try to use <ObjectField> to replace this map
675
-
676
- return _react().default.createElement(_antd().Form.Item, {
677
- key: field.name,
678
- label: compile((_field$uiSchema$title = (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) !== null && _field$uiSchema$title !== void 0 ? _field$uiSchema$title : field.name),
679
- labelAlign: "left",
680
- className: (0, _css().css)`
681
- .ant-form-item-control-input-content{
682
- display: flex;
683
- }
684
- `
685
- }, _react().default.createElement(VariableTypesContext.Provider, {
686
- value: VTypes
687
- }, _react().default.createElement(Operand, {
688
- value: operand,
689
- onChange: next => {
690
- if (next.type !== operand.type && next.type === 'constant') {
691
- _onChange7(_objectSpread(_objectSpread({}, value), {}, {
692
- [field.name]: null
693
- }));
694
- } else {
695
- const stringify = VTypes[next.type].stringify;
696
-
697
- _onChange7(_objectSpread(_objectSpread({}, value), {}, {
698
- [field.name]: stringify(next)
699
- }));
700
- }
701
- }
702
- }, operand.type === 'constant' ? _react().default.createElement(_client().SchemaComponent, {
703
- schema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
704
- name: field.name
705
- })
706
- }) : null), _react().default.createElement(_antd().Button, {
707
- type: "link",
708
- icon: _react().default.createElement(_icons().CloseCircleOutlined, null),
709
- onClick: () => {
710
- const _field$name = field.name,
711
- _ = value[_field$name],
712
- rest = _objectWithoutProperties(value, [_field$name].map(_toPropertyKey));
713
-
714
- _onChange7(rest);
715
- }
716
- })));
717
- }), Object.keys(value).length < fields.length ? _react().default.createElement(_antd().Dropdown, {
718
- overlay: _react().default.createElement(_antd().Menu, {
719
- onClick: ({
720
- key
721
- }) => _onChange7(_objectSpread(_objectSpread({}, value), {}, {
722
- [key]: null
723
- })),
724
- className: (0, _css().css)`
725
- max-height: 300px;
726
- overflow-y: auto;
727
- `
728
- }, fields.filter(field => !(field.name in value)).map(field => {
729
- var _field$uiSchema$title2, _field$uiSchema2;
730
-
731
- return _react().default.createElement(_antd().Menu.Item, {
732
- key: field.name
733
- }, compile((_field$uiSchema$title2 = (_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title) !== null && _field$uiSchema$title2 !== void 0 ? _field$uiSchema$title2 : field.name));
734
- }))
735
- }, _react().default.createElement(_antd().Button, {
736
- icon: _react().default.createElement(_icons().PlusOutlined, null)
737
- }, t('Add field'))) : null) : _react().default.createElement("p", null, t('Please select collection first')));
738
- });
739
- exports.CollectionFieldset = CollectionFieldset;
650
+ }
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const _default: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
3
+ export default _default;
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function _react() {
9
+ const data = _interopRequireDefault(require("react"));
10
+
11
+ _react = function _react() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _react2() {
19
+ const data = require("@formily/react");
20
+
21
+ _react2 = function _react2() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _antd() {
29
+ const data = require("antd");
30
+
31
+ _antd = function _antd() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _icons() {
39
+ const data = require("@ant-design/icons");
40
+
41
+ _icons = function _icons() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _reactI18next() {
49
+ const data = require("react-i18next");
50
+
51
+ _reactI18next = function _reactI18next() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ function _css() {
59
+ const data = require("@emotion/css");
60
+
61
+ _css = function _css() {
62
+ return data;
63
+ };
64
+
65
+ return data;
66
+ }
67
+
68
+ function _client() {
69
+ const data = require("@nocobase/client");
70
+
71
+ _client = function _client() {
72
+ return data;
73
+ };
74
+
75
+ return data;
76
+ }
77
+
78
+ var _calculators = require("../calculators");
79
+
80
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
81
+
82
+ 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; }
83
+
84
+ 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; }
85
+
86
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
87
+
88
+ 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); }
89
+
90
+ 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; }
91
+
92
+ 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; }
93
+
94
+ 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; }
95
+
96
+ // NOTE: observer for watching useProps
97
+ var _default = (0, _react2().observer)(({
98
+ value,
99
+ onChange: _onChange
100
+ }) => {
101
+ var _data$config, _data$config2;
102
+
103
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
104
+ t = _useTranslation.t;
105
+
106
+ const compile = (0, _client().useCompile)();
107
+
108
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
109
+ getCollection = _useCollectionManager.getCollection,
110
+ getCollectionFields = _useCollectionManager.getCollectionFields;
111
+
112
+ const _useForm = (0, _react2().useForm)(),
113
+ data = _useForm.values;
114
+
115
+ const collectionName = data === null || data === void 0 ? void 0 : (_data$config = data.config) === null || _data$config === void 0 ? void 0 : _data$config.collection;
116
+ const fields = getCollectionFields(data === null || data === void 0 ? void 0 : (_data$config2 = data.config) === null || _data$config2 === void 0 ? void 0 : _data$config2.collection).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false) && !['linkTo', 'hasMany', 'hasOne', 'belongsToMany'].includes(field.type));
117
+ return _react().default.createElement("fieldset", {
118
+ className: (0, _css().css)`
119
+ margin-top: .5em;
120
+
121
+ > .ant-formily-item{
122
+ flex-direction: column;
123
+
124
+ > .ant-formily-item-label{
125
+ line-height: 32px;
126
+ }
127
+ }
128
+ `
129
+ }, fields.length ? _react().default.createElement(_client().CollectionProvider, {
130
+ collection: getCollection(collectionName)
131
+ }, fields.filter(field => field.name in value).map(field => {
132
+ var _field$uiSchema$title, _field$uiSchema;
133
+
134
+ const VTypes = _objectSpread({}, _calculators.VariableTypes);
135
+
136
+ let operand; // TODO: should refactor to support all types
137
+
138
+ if (field.type !== 'belongsTo') {
139
+ Object.assign(VTypes, {
140
+ constant: {
141
+ title: '{{t("Constant")}}',
142
+ value: 'constant',
143
+ options: undefined
144
+ }
145
+ });
146
+ operand = typeof value[field.name] === 'string' ? (0, _calculators.parseStringValue)(value[field.name], VTypes) : {
147
+ type: 'constant',
148
+ value: value[field.name]
149
+ };
150
+ } else {
151
+ delete VTypes.constant;
152
+ operand = typeof value[field.name] === 'string' ? (0, _calculators.parseStringValue)(value[field.name], VTypes) : {
153
+ type: '$context',
154
+ value: value[field.name]
155
+ };
156
+ } // TODO: try to use <ObjectField> to replace this map
157
+
158
+
159
+ return _react().default.createElement(_antd().Form.Item, {
160
+ key: field.name,
161
+ label: compile((_field$uiSchema$title = (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) !== null && _field$uiSchema$title !== void 0 ? _field$uiSchema$title : field.name),
162
+ labelAlign: "left",
163
+ className: (0, _css().css)`
164
+ .ant-form-item-control-input-content{
165
+ display: flex;
166
+ }
167
+ `
168
+ }, _react().default.createElement(_calculators.VariableTypesContext.Provider, {
169
+ value: VTypes
170
+ }, _react().default.createElement(_calculators.Operand, {
171
+ value: operand,
172
+ onChange: next => {
173
+ if (next.type !== operand.type && next.type === 'constant') {
174
+ _onChange(_objectSpread(_objectSpread({}, value), {}, {
175
+ [field.name]: null
176
+ }));
177
+ } else {
178
+ const stringify = VTypes[next.type].stringify;
179
+
180
+ _onChange(_objectSpread(_objectSpread({}, value), {}, {
181
+ [field.name]: stringify(next)
182
+ }));
183
+ }
184
+ }
185
+ }, operand.type === 'constant' ? _react().default.createElement(_client().SchemaComponent, {
186
+ schema: {
187
+ type: 'void',
188
+ properties: {
189
+ [field.name]: {
190
+ 'x-component': 'CollectionField'
191
+ }
192
+ }
193
+ },
194
+ components: {
195
+ CollectionField: _client().CollectionField
196
+ }
197
+ }) // ? <SchemaComponent schema={{ ...field.uiSchema, name: field.name }} />
198
+ : null), _react().default.createElement(_antd().Button, {
199
+ type: "link",
200
+ icon: _react().default.createElement(_icons().CloseCircleOutlined, null),
201
+ onClick: () => {
202
+ const _field$name = field.name,
203
+ _ = value[_field$name],
204
+ rest = _objectWithoutProperties(value, [_field$name].map(_toPropertyKey));
205
+
206
+ _onChange(rest);
207
+ }
208
+ })));
209
+ }), Object.keys(value).length < fields.length ? _react().default.createElement(_antd().Dropdown, {
210
+ overlay: _react().default.createElement(_antd().Menu, {
211
+ onClick: ({
212
+ key
213
+ }) => _onChange(_objectSpread(_objectSpread({}, value), {}, {
214
+ [key]: null
215
+ })),
216
+ className: (0, _css().css)`
217
+ max-height: 300px;
218
+ overflow-y: auto;
219
+ `
220
+ }, fields.filter(field => !(field.name in value)).map(field => {
221
+ var _field$uiSchema$title2, _field$uiSchema2;
222
+
223
+ return _react().default.createElement(_antd().Menu.Item, {
224
+ key: field.name
225
+ }, compile((_field$uiSchema$title2 = (_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title) !== null && _field$uiSchema$title2 !== void 0 ? _field$uiSchema$title2 : field.name));
226
+ }))
227
+ }, _react().default.createElement(_antd().Button, {
228
+ icon: _react().default.createElement(_icons().PlusOutlined, null)
229
+ }, t('Add field'))) : null) : _react().default.createElement("p", null, t('Please select collection first')));
230
+ });
231
+
232
+ exports.default = _default;
@@ -1,3 +1,4 @@
1
1
  export { triggers } from './triggers';
2
2
  export * from './nodes';
3
+ export { calculators } from './calculators';
3
4
  export { WorkflowProvider as default } from './WorkflowProvider';
@@ -4,8 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- triggers: true
7
+ triggers: true,
8
+ calculators: true
8
9
  };
10
+ Object.defineProperty(exports, "calculators", {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _calculators.calculators;
14
+ }
15
+ });
9
16
  Object.defineProperty(exports, "default", {
10
17
  enumerable: true,
11
18
  get: function get() {
@@ -35,4 +42,6 @@ Object.keys(_nodes).forEach(function (key) {
35
42
  });
36
43
  });
37
44
 
45
+ var _calculators = require("./calculators");
46
+
38
47
  var _WorkflowProvider = require("./WorkflowProvider");
@@ -25,14 +25,14 @@ function _client() {
25
25
  return data;
26
26
  }
27
27
 
28
- var _calculators = require("../calculators");
29
-
30
28
  var _collection = require("../schemas/collection");
31
29
 
32
30
  var _WorkflowCanvas = require("../WorkflowCanvas");
33
31
 
34
32
  var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
35
33
 
34
+ var _CollectionFieldset = _interopRequireDefault(require("../components/CollectionFieldset"));
35
+
36
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
37
 
38
38
  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; }
@@ -66,7 +66,7 @@ var _default = {
66
66
  useCollectionDataSource: _client().useCollectionDataSource
67
67
  },
68
68
  components: {
69
- CollectionFieldset: _calculators.CollectionFieldset
69
+ CollectionFieldset: _CollectionFieldset.default
70
70
  },
71
71
 
72
72
  getter(props) {
@@ -19,6 +19,10 @@ var _calculators = require("../calculators");
19
19
 
20
20
  var _collection = require("../schemas/collection");
21
21
 
22
+ var _CollectionFieldset = _interopRequireDefault(require("../components/CollectionFieldset"));
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
22
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; }
23
27
 
24
28
  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; }
@@ -42,7 +46,7 @@ var _default = {
42
46
  },
43
47
  components: {
44
48
  VariableComponent: _calculators.VariableComponent,
45
- CollectionFieldset: _calculators.CollectionFieldset
49
+ CollectionFieldset: _CollectionFieldset.default
46
50
  }
47
51
  };
48
52
  exports.default = _default;
@@ -25,6 +25,16 @@ function _antd() {
25
25
  return data;
26
26
  }
27
27
 
28
+ function _moment() {
29
+ const data = _interopRequireDefault(require("moment"));
30
+
31
+ _moment = function _moment() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
28
38
  function _react() {
29
39
  const data = _interopRequireWildcard(require("react"));
30
40
 
@@ -51,6 +61,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
51
61
 
52
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; }
53
63
 
64
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65
+
54
66
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
55
67
 
56
68
  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."); }
@@ -96,7 +108,7 @@ function EndsByField({
96
108
  onChange: _onChange
97
109
  }) : _react().default.createElement(_antd().DatePicker, {
98
110
  showTime: true,
99
- value: value,
111
+ value: (0, _moment().default)(value),
100
112
  onChange: _onChange
101
113
  }));
102
114
  }
@@ -177,8 +177,9 @@ calculators.register('notStartsWith', notStartsWith);
177
177
  calculators.register('endsWith', endsWith);
178
178
  calculators.register('notEndsWith', notEndsWith);
179
179
 
180
- function before(a, b) {
181
- return a < b;
180
+ function concat(a, b) {
181
+ return a.concat(b);
182
182
  }
183
183
 
184
+ calculators.register('concat', concat);
184
185
  calculators.register('now', () => new Date()); // TODO: add more common calculators
@@ -11,8 +11,10 @@ export interface Instruction {
11
11
  run(node: FlowNodeModel, input: any, processor: Processor): InstructionResult;
12
12
  resume?(node: FlowNodeModel, input: any, processor: Processor): InstructionResult;
13
13
  }
14
+ declare type InstructionConstructor<T> = {
15
+ new (p: Plugin): T;
16
+ };
14
17
  export default function <T extends Instruction>(plugin: any, more?: {
15
- [key: string]: T | {
16
- new (p: Plugin): T;
17
- };
18
+ [key: string]: T | InstructionConstructor<T>;
18
19
  }): void;
20
+ export {};
@@ -48,15 +48,14 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
48
48
  function _default(plugin, more = {}) {
49
49
  const instructions = plugin.instructions;
50
50
  const natives = ['calculation', 'condition', 'parallel', 'delay', 'prompt', 'query', 'create', 'update', 'destroy'].reduce((result, key) => Object.assign(result, {
51
- [key]: key
51
+ [key]: (0, _utils().requireModule)(_path().default.isAbsolute(key) ? key : _path().default.join(__dirname, key))
52
52
  }), {});
53
53
 
54
54
  for (var _i = 0, _Object$entries = Object.entries(_objectSpread(_objectSpread({}, more), natives)); _i < _Object$entries.length; _i++) {
55
55
  const _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
56
56
  name = _Object$entries$_i[0],
57
- value = _Object$entries$_i[1];
57
+ instruction = _Object$entries$_i[1];
58
58
 
59
- const instruction = typeof value === 'string' ? (0, _utils().requireModule)(_path().default.isAbsolute(value) ? value : _path().default.join(__dirname, value)) : value;
60
59
  instructions.register(name, typeof instruction === 'function' ? new instruction(plugin) : instruction);
61
60
  }
62
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow",
3
- "version": "0.7.4-alpha.4",
3
+ "version": "0.7.5-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -10,17 +10,17 @@
10
10
  }
11
11
  ],
12
12
  "dependencies": {
13
- "@nocobase/actions": "0.7.4-alpha.4",
14
- "@nocobase/client": "0.7.4-alpha.4",
15
- "@nocobase/database": "0.7.4-alpha.4",
16
- "@nocobase/server": "0.7.4-alpha.4",
17
- "@nocobase/utils": "0.7.4-alpha.4",
13
+ "@nocobase/actions": "0.7.5-alpha.1",
14
+ "@nocobase/client": "0.7.5-alpha.1",
15
+ "@nocobase/database": "0.7.5-alpha.1",
16
+ "@nocobase/server": "0.7.5-alpha.1",
17
+ "@nocobase/utils": "0.7.5-alpha.1",
18
18
  "cron-parser": "4.4.0",
19
19
  "json-templates": "^4.2.0",
20
20
  "react-js-cron": "^1.4.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@nocobase/test": "0.7.4-alpha.4"
23
+ "@nocobase/test": "0.7.5-alpha.1"
24
24
  },
25
- "gitHead": "726c06b721b217a6aa5c1421b899d1315e552b57"
25
+ "gitHead": "f6eb27b68185bb0c0b4c2cfca1df84205a9b9173"
26
26
  }
package/server.d.ts CHANGED
File without changes
package/server.js CHANGED
File without changes