@nocobase/flow-engine 2.1.0-beta.23 → 2.1.0-beta.25
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/lib/components/dnd/gridDragPlanner.d.ts +59 -2
- package/lib/components/dnd/gridDragPlanner.js +595 -19
- package/lib/components/dnd/index.js +7 -5
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
- package/lib/models/flowModel.js +2 -0
- package/lib/utils/createCollectionContextMeta.js +6 -2
- package/package.json +4 -4
- package/src/__tests__/objectVariable.test.ts +24 -0
- package/src/components/__tests__/gridDragPlanner.test.ts +426 -5
- package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
- package/src/components/dnd/gridDragPlanner.ts +735 -17
- package/src/components/dnd/index.tsx +7 -3
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
- package/src/models/__tests__/flowModel.test.ts +19 -3
- package/src/models/flowModel.tsx +3 -0
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
- package/src/utils/createCollectionContextMeta.ts +6 -2
|
@@ -85,7 +85,7 @@ const resolveDraggableHostNode = /* @__PURE__ */ __name((activatorNode) => {
|
|
|
85
85
|
`[data-has-float-menu="true"][data-float-menu-model-uid="${toolbarModelUid}"]`
|
|
86
86
|
)
|
|
87
87
|
);
|
|
88
|
-
const popupRoot = floatToolbarContainer.closest(MENU_SUBMENU_POPUP_SELECTOR);
|
|
88
|
+
const popupRoot = floatToolbarContainer == null ? void 0 : floatToolbarContainer.closest(MENU_SUBMENU_POPUP_SELECTOR);
|
|
89
89
|
if (popupRoot) {
|
|
90
90
|
return matchedHosts.find((hostNode) => hostNode.closest(MENU_SUBMENU_POPUP_SELECTOR) === popupRoot) || activatorNode;
|
|
91
91
|
}
|
|
@@ -275,7 +275,9 @@ const Droppable = /* @__PURE__ */ __name(({ model, children }) => {
|
|
|
275
275
|
const DndProvider = /* @__PURE__ */ __name(({
|
|
276
276
|
persist = true,
|
|
277
277
|
children,
|
|
278
|
+
onDragStart,
|
|
278
279
|
onDragEnd,
|
|
280
|
+
onDragCancel,
|
|
279
281
|
...restProps
|
|
280
282
|
}) => {
|
|
281
283
|
const [activeId, setActiveId] = (0, import_react.useState)(null);
|
|
@@ -311,10 +313,10 @@ const DndProvider = /* @__PURE__ */ __name(({
|
|
|
311
313
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
312
314
|
import_core.DndContext,
|
|
313
315
|
{
|
|
316
|
+
...restProps,
|
|
314
317
|
onDragStart: (event) => {
|
|
315
|
-
var _a;
|
|
316
318
|
setActiveId(event.active.id);
|
|
317
|
-
|
|
319
|
+
onDragStart == null ? void 0 : onDragStart(event);
|
|
318
320
|
},
|
|
319
321
|
onDragEnd: (event) => {
|
|
320
322
|
setActiveId(null);
|
|
@@ -328,10 +330,9 @@ const DndProvider = /* @__PURE__ */ __name(({
|
|
|
328
330
|
}
|
|
329
331
|
},
|
|
330
332
|
onDragCancel: (event) => {
|
|
331
|
-
var _a;
|
|
332
333
|
setActiveId(null);
|
|
333
334
|
setDragAnchorPoint(null);
|
|
334
|
-
|
|
335
|
+
onDragCancel == null ? void 0 : onDragCancel(event);
|
|
335
336
|
},
|
|
336
337
|
...restProps
|
|
337
338
|
},
|
|
@@ -348,6 +349,7 @@ const DndProvider = /* @__PURE__ */ __name(({
|
|
|
348
349
|
activeId && /* @__PURE__ */ import_react.default.createElement(
|
|
349
350
|
"span",
|
|
350
351
|
{
|
|
352
|
+
"data-testid": "flow-drag-preview",
|
|
351
353
|
style: {
|
|
352
354
|
display: "inline-flex",
|
|
353
355
|
alignItems: "center",
|
|
@@ -15,5 +15,6 @@ export interface SelectWithTitleProps {
|
|
|
15
15
|
itemKey?: string;
|
|
16
16
|
onChange?: (...args: any[]) => void;
|
|
17
17
|
dropdownRender?: any;
|
|
18
|
+
tooltip?: any;
|
|
18
19
|
}
|
|
19
|
-
export declare function SelectWithTitle({ title, getDefaultValue, onChange, options, fieldNames, itemKey, ...others }: SelectWithTitleProps): React.JSX.Element;
|
|
20
|
+
export declare function SelectWithTitle({ title, getDefaultValue, onChange, options, fieldNames, itemKey, tooltip, ...others }: SelectWithTitleProps): React.JSX.Element;
|
|
@@ -50,6 +50,7 @@ function SelectWithTitle({
|
|
|
50
50
|
options,
|
|
51
51
|
fieldNames,
|
|
52
52
|
itemKey,
|
|
53
|
+
tooltip,
|
|
53
54
|
...others
|
|
54
55
|
}) {
|
|
55
56
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
@@ -80,6 +81,18 @@ function SelectWithTitle({
|
|
|
80
81
|
setValue(val);
|
|
81
82
|
onChange == null ? void 0 : onChange({ [itemKey]: val });
|
|
82
83
|
}, "handleChange");
|
|
84
|
+
const titleNode = /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
+
"span",
|
|
86
|
+
{
|
|
87
|
+
style: {
|
|
88
|
+
whiteSpace: "nowrap",
|
|
89
|
+
// 不换行
|
|
90
|
+
flexShrink: 0
|
|
91
|
+
// 不被挤压
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
title
|
|
95
|
+
);
|
|
83
96
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
84
97
|
"div",
|
|
85
98
|
{
|
|
@@ -94,18 +107,7 @@ function SelectWithTitle({
|
|
|
94
107
|
}, 200);
|
|
95
108
|
}
|
|
96
109
|
},
|
|
97
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
98
|
-
"span",
|
|
99
|
-
{
|
|
100
|
-
style: {
|
|
101
|
-
whiteSpace: "nowrap",
|
|
102
|
-
// 不换行
|
|
103
|
-
flexShrink: 0
|
|
104
|
-
// 不被挤压
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
title
|
|
108
|
-
),
|
|
110
|
+
tooltip ? /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: tooltip, placement: "top", destroyTooltipOnHide: true }, titleNode) : titleNode,
|
|
109
111
|
/* @__PURE__ */ import_react.default.createElement(
|
|
110
112
|
import_antd.Select,
|
|
111
113
|
{
|
package/lib/models/flowModel.js
CHANGED
|
@@ -622,6 +622,7 @@ const _FlowModel = class _FlowModel {
|
|
|
622
622
|
} else {
|
|
623
623
|
this.props = { ...this.props, ...props };
|
|
624
624
|
}
|
|
625
|
+
this._options.props = { ...this.props };
|
|
625
626
|
}
|
|
626
627
|
getProps() {
|
|
627
628
|
return this.props;
|
|
@@ -1163,6 +1164,7 @@ const _FlowModel = class _FlowModel {
|
|
|
1163
1164
|
const data = {
|
|
1164
1165
|
uid: this.uid,
|
|
1165
1166
|
...import_lodash.default.omit(this._options, ["flowEngine"]),
|
|
1167
|
+
props: { ...this.props },
|
|
1166
1168
|
stepParams: this.stepParams,
|
|
1167
1169
|
sortIndex: this.sortIndex,
|
|
1168
1170
|
flowRegistry: {}
|
|
@@ -32,6 +32,10 @@ __export(createCollectionContextMeta_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(createCollectionContextMeta_exports);
|
|
33
33
|
const RELATION_FIELD_TYPES = ["belongsTo", "hasOne", "hasMany", "belongsToMany", "belongsToArray"];
|
|
34
34
|
const NUMERIC_FIELD_TYPES = ["integer", "float", "double", "decimal"];
|
|
35
|
+
function shouldShowFieldInMeta(field, includeNonFilterable) {
|
|
36
|
+
return Boolean(field.interface && (includeNonFilterable || field.filterable));
|
|
37
|
+
}
|
|
38
|
+
__name(shouldShowFieldInMeta, "shouldShowFieldInMeta");
|
|
35
39
|
function createFieldMetadata(field, includeNonFilterable) {
|
|
36
40
|
const baseProperties = createMetaBaseProperties(field);
|
|
37
41
|
if (field.isAssociationField()) {
|
|
@@ -49,7 +53,7 @@ function createFieldMetadata(field, includeNonFilterable) {
|
|
|
49
53
|
properties: /* @__PURE__ */ __name(async () => {
|
|
50
54
|
const subProperties = {};
|
|
51
55
|
targetCollection.fields.forEach((subField) => {
|
|
52
|
-
if (includeNonFilterable
|
|
56
|
+
if (shouldShowFieldInMeta(subField, includeNonFilterable)) {
|
|
53
57
|
subProperties[subField.name] = createFieldMetadata(subField, includeNonFilterable);
|
|
54
58
|
}
|
|
55
59
|
});
|
|
@@ -104,7 +108,7 @@ function createCollectionContextMeta(collectionOrFactory, title, includeNonFilte
|
|
|
104
108
|
properties: /* @__PURE__ */ __name(async () => {
|
|
105
109
|
const properties = {};
|
|
106
110
|
collection.fields.forEach((field) => {
|
|
107
|
-
if (includeNonFilterable
|
|
111
|
+
if (shouldShowFieldInMeta(field, includeNonFilterable)) {
|
|
108
112
|
properties[field.name] = createFieldMetadata(field, includeNonFilterable);
|
|
109
113
|
}
|
|
110
114
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.1.0-beta.
|
|
12
|
-
"@nocobase/shared": "2.1.0-beta.
|
|
11
|
+
"@nocobase/sdk": "2.1.0-beta.25",
|
|
12
|
+
"@nocobase/shared": "2.1.0-beta.25",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"axios": "^1.7.0",
|
|
15
15
|
"dayjs": "^1.11.9",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
],
|
|
38
38
|
"author": "NocoBase Team",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "824f8b8200e9fe086135768934d3ef427b212446"
|
|
41
41
|
}
|
|
@@ -26,6 +26,7 @@ function setupEngineWithCollections() {
|
|
|
26
26
|
fields: [
|
|
27
27
|
{ name: 'id', type: 'integer', interface: 'number' },
|
|
28
28
|
{ name: 'name', type: 'string', interface: 'text' },
|
|
29
|
+
{ name: 'rawUserPayload', type: 'json', filterable: true },
|
|
29
30
|
],
|
|
30
31
|
});
|
|
31
32
|
ds.addCollection({
|
|
@@ -41,6 +42,8 @@ function setupEngineWithCollections() {
|
|
|
41
42
|
filterTargetKey: 'id',
|
|
42
43
|
fields: [
|
|
43
44
|
{ name: 'title', type: 'string', interface: 'text' },
|
|
45
|
+
{ name: 'internalName', type: 'string', interface: 'text' },
|
|
46
|
+
{ name: 'rawPostPayload', type: 'json', filterable: true },
|
|
44
47
|
{ name: 'author', type: 'belongsTo', target: 'users', interface: 'm2o' },
|
|
45
48
|
{ name: 'tags', type: 'belongsToMany', target: 'tags', interface: 'm2m' },
|
|
46
49
|
],
|
|
@@ -91,6 +94,27 @@ describe('objectVariable utilities', () => {
|
|
|
91
94
|
});
|
|
92
95
|
});
|
|
93
96
|
|
|
97
|
+
it('createAssociationAwareObjectMetaFactory should hide fields without interface from object variable meta', async () => {
|
|
98
|
+
const { collection } = setupEngineWithCollections();
|
|
99
|
+
const obj = { title: 'hello', internalName: 'internal', rawPostPayload: { secret: true }, author: 1 };
|
|
100
|
+
const metaFactory = createAssociationAwareObjectMetaFactory(
|
|
101
|
+
() => collection,
|
|
102
|
+
'Current object',
|
|
103
|
+
() => obj,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const meta = await metaFactory();
|
|
107
|
+
const props = await (meta?.properties as any)?.();
|
|
108
|
+
const authorFields = await props?.author?.properties?.();
|
|
109
|
+
|
|
110
|
+
expect(props).toHaveProperty('title');
|
|
111
|
+
expect(props).toHaveProperty('internalName');
|
|
112
|
+
expect(props).toHaveProperty('author');
|
|
113
|
+
expect(props).not.toHaveProperty('rawPostPayload');
|
|
114
|
+
expect(authorFields).toHaveProperty('name');
|
|
115
|
+
expect(authorFields).not.toHaveProperty('rawUserPayload');
|
|
116
|
+
});
|
|
117
|
+
|
|
94
118
|
it('integrates with FlowContext.resolveJsonTemplate to call variables:resolve with flattened contextParams', async () => {
|
|
95
119
|
const { engine, collection } = setupEngineWithCollections();
|
|
96
120
|
const obj = { author: 1 };
|