@nocobase/flow-engine 2.1.0-alpha.4 → 2.1.0-alpha.45
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/LICENSE +201 -661
- package/README.md +79 -10
- package/lib/FlowContextProvider.d.ts +5 -1
- package/lib/FlowContextProvider.js +9 -2
- package/lib/JSRunner.d.ts +10 -1
- package/lib/JSRunner.js +50 -5
- package/lib/ViewScopedFlowEngine.js +5 -1
- package/lib/components/FieldModelRenderer.js +2 -2
- package/lib/components/FlowModelRenderer.d.ts +3 -1
- package/lib/components/FlowModelRenderer.js +12 -6
- package/lib/components/FormItem.d.ts +6 -0
- package/lib/components/FormItem.js +11 -3
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +59 -2
- package/lib/components/dnd/gridDragPlanner.js +613 -21
- package/lib/components/dnd/index.d.ts +31 -2
- package/lib/components/dnd/index.js +244 -23
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -11
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +23 -43
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +352 -295
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +274 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +315 -0
- package/lib/components/subModel/AddSubModelButton.js +27 -1
- package/lib/components/subModel/LazyDropdown.js +293 -52
- package/lib/components/subModel/index.d.ts +1 -0
- package/lib/components/subModel/index.js +19 -0
- package/lib/components/subModel/utils.d.ts +1 -1
- package/lib/components/subModel/utils.js +9 -3
- package/lib/components/variables/VariableHybridInput.d.ts +27 -0
- package/lib/components/variables/VariableHybridInput.js +499 -0
- package/lib/components/variables/index.d.ts +2 -0
- package/lib/components/variables/index.js +3 -0
- package/lib/data-source/index.d.ts +84 -0
- package/lib/data-source/index.js +259 -5
- package/lib/executor/FlowExecutor.js +32 -9
- package/lib/flow-registry/DetachedFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/DetachedFlowRegistry.js +80 -0
- package/lib/flow-registry/index.d.ts +1 -0
- package/lib/flow-registry/index.js +3 -1
- package/lib/flowContext.d.ts +3 -0
- package/lib/flowContext.js +46 -1
- package/lib/flowEngine.d.ts +151 -1
- package/lib/flowEngine.js +392 -18
- package/lib/flowI18n.js +2 -1
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +34 -6
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/models/flowModel.d.ts +13 -10
- package/lib/models/flowModel.js +81 -21
- package/lib/provider.js +38 -23
- package/lib/reactive/observer.js +46 -16
- package/lib/runjs-context/registry.d.ts +1 -1
- package/lib/runjs-context/setup.js +20 -12
- package/lib/runjs-context/snippets/index.js +13 -2
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +5 -1
- package/lib/scheduler/ModelOperationScheduler.js +3 -2
- package/lib/types.d.ts +50 -2
- package/lib/types.js +1 -0
- package/lib/utils/createCollectionContextMeta.js +6 -2
- package/lib/utils/index.d.ts +3 -2
- package/lib/utils/index.js +7 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +5 -1
- package/lib/utils/parsePathnameToViewParams.js +29 -5
- package/lib/utils/randomId.d.ts +39 -0
- package/lib/utils/randomId.js +45 -0
- package/lib/utils/runjsTemplateCompat.js +1 -1
- package/lib/utils/runjsValue.js +41 -11
- package/lib/utils/schema-utils.d.ts +7 -1
- package/lib/utils/schema-utils.js +19 -0
- package/lib/views/FlowView.d.ts +7 -1
- package/lib/views/FlowView.js +11 -1
- package/lib/views/PageComponent.js +8 -6
- package/lib/views/ViewNavigation.d.ts +12 -2
- package/lib/views/ViewNavigation.js +28 -9
- package/lib/views/createViewMeta.js +114 -50
- package/lib/views/inheritLayoutContext.d.ts +10 -0
- package/lib/views/inheritLayoutContext.js +50 -0
- package/lib/views/runViewBeforeClose.d.ts +10 -0
- package/lib/views/runViewBeforeClose.js +45 -0
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +22 -3
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +22 -3
- package/lib/views/usePage.d.ts +5 -11
- package/lib/views/usePage.js +304 -144
- package/package.json +6 -5
- package/src/FlowContextProvider.tsx +9 -1
- package/src/JSRunner.ts +68 -4
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/JSRunner.test.ts +27 -1
- package/src/__tests__/createViewMeta.popup.test.ts +115 -1
- package/src/__tests__/flow-engine.test.ts +166 -0
- package/src/__tests__/flowContext.test.ts +82 -1
- package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
- package/src/__tests__/flowEngine.removeModel.test.ts +47 -3
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/objectVariable.test.ts +24 -0
- package/src/__tests__/provider.test.tsx +24 -2
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +16 -0
- package/src/__tests__/runjsContextRuntime.test.ts +2 -0
- package/src/__tests__/runjsPreprocessDefault.test.ts +23 -0
- package/src/__tests__/runjsSnippets.test.ts +21 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/components/FieldModelRenderer.tsx +2 -1
- package/src/components/FlowModelRenderer.tsx +18 -6
- package/src/components/FormItem.tsx +7 -1
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
- package/src/components/__tests__/FormItem.test.tsx +25 -0
- package/src/components/__tests__/dnd.test.ts +44 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
- package/src/components/__tests__/gridDragPlanner.test.ts +558 -3
- package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
- package/src/components/dnd/gridDragPlanner.ts +758 -19
- package/src/components/dnd/index.tsx +305 -28
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +99 -11
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +487 -440
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +194 -5
- package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +778 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +360 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +361 -0
- package/src/components/subModel/AddSubModelButton.tsx +32 -2
- package/src/components/subModel/LazyDropdown.tsx +332 -56
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +522 -37
- package/src/components/subModel/__tests__/utils.test.ts +24 -0
- package/src/components/subModel/index.ts +1 -0
- package/src/components/subModel/utils.ts +7 -1
- package/src/components/variables/VariableHybridInput.tsx +531 -0
- package/src/components/variables/index.ts +2 -0
- package/src/data-source/__tests__/collection.test.ts +41 -2
- package/src/data-source/__tests__/index.test.ts +68 -1
- package/src/data-source/index.ts +322 -6
- package/src/executor/FlowExecutor.ts +35 -10
- package/src/executor/__tests__/flowExecutor.test.ts +85 -0
- package/src/flow-registry/DetachedFlowRegistry.ts +46 -0
- package/src/flow-registry/__tests__/detachedFlowRegistry.test.ts +47 -0
- package/src/flow-registry/index.ts +1 -0
- package/src/flowContext.ts +50 -3
- package/src/flowEngine.ts +449 -14
- package/src/flowI18n.ts +2 -1
- package/src/flowSettings.ts +40 -6
- package/src/index.ts +2 -0
- package/src/lazy-helper.tsx +57 -0
- package/src/locale/en-US.json +1 -0
- package/src/locale/zh-CN.json +1 -0
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +214 -0
- package/src/models/__tests__/flowEngine.resolveUse.test.ts +0 -15
- package/src/models/__tests__/flowModel.test.ts +80 -37
- package/src/models/flowModel.tsx +122 -36
- package/src/provider.tsx +41 -25
- package/src/reactive/__tests__/observer.test.tsx +82 -0
- package/src/reactive/observer.tsx +87 -25
- package/src/runjs-context/registry.ts +1 -1
- package/src/runjs-context/setup.ts +22 -12
- package/src/runjs-context/snippets/index.ts +12 -1
- package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
- package/src/scheduler/ModelOperationScheduler.ts +14 -3
- package/src/types.ts +62 -0
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +28 -0
- package/src/utils/__tests__/runjsValue.test.ts +11 -0
- package/src/utils/__tests__/utils.test.ts +62 -0
- package/src/utils/createCollectionContextMeta.ts +6 -2
- package/src/utils/index.ts +5 -1
- package/src/utils/parsePathnameToViewParams.ts +47 -7
- package/src/utils/randomId.ts +48 -0
- package/src/utils/runjsTemplateCompat.ts +1 -1
- package/src/utils/runjsValue.ts +50 -11
- package/src/utils/schema-utils.ts +30 -1
- package/src/views/FlowView.tsx +22 -2
- package/src/views/PageComponent.tsx +7 -4
- package/src/views/ViewNavigation.ts +46 -9
- package/src/views/__tests__/FlowView.usePage.test.tsx +243 -3
- package/src/views/__tests__/ViewNavigation.test.ts +52 -0
- package/src/views/__tests__/inheritLayoutContext.test.ts +53 -0
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +13 -12
- package/src/views/createViewMeta.ts +106 -34
- package/src/views/inheritLayoutContext.ts +26 -0
- package/src/views/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +27 -3
- package/src/views/useDrawer.tsx +27 -3
- package/src/views/usePage.tsx +367 -179
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var useFloatToolbarVisibility_exports = {};
|
|
29
|
+
__export(useFloatToolbarVisibility_exports, {
|
|
30
|
+
useFloatToolbarVisibility: () => useFloatToolbarVisibility
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(useFloatToolbarVisibility_exports);
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_dnd = require("../../../dnd");
|
|
35
|
+
const TOOLBAR_HIDE_DELAY = 180;
|
|
36
|
+
const CHILD_FLOAT_MENU_ACTIVITY_EVENT = "nb-float-menu-child-activity";
|
|
37
|
+
const isNodeWithin = /* @__PURE__ */ __name((target, container) => {
|
|
38
|
+
return target instanceof Node && !!(container == null ? void 0 : container.contains(target));
|
|
39
|
+
}, "isNodeWithin");
|
|
40
|
+
const getToolbarModelUidFromTarget = /* @__PURE__ */ __name((target) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!(target instanceof Element)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return ((_a = target.closest(".nb-toolbar-container[data-model-uid]")) == null ? void 0 : _a.getAttribute("data-model-uid")) || null;
|
|
46
|
+
}, "getToolbarModelUidFromTarget");
|
|
47
|
+
const isNodeWithinDescendantFloatToolbar = /* @__PURE__ */ __name((target, container, currentModelUid) => {
|
|
48
|
+
const targetModelUid = getToolbarModelUidFromTarget(target);
|
|
49
|
+
if (!container || !targetModelUid || targetModelUid === currentModelUid) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return Array.from(
|
|
53
|
+
container.querySelectorAll('[data-has-float-menu="true"][data-float-menu-model-uid]')
|
|
54
|
+
).some(
|
|
55
|
+
(hostElement) => hostElement !== container && hostElement.getAttribute("data-float-menu-model-uid") === targetModelUid
|
|
56
|
+
);
|
|
57
|
+
}, "isNodeWithinDescendantFloatToolbar");
|
|
58
|
+
const useFloatToolbarVisibility = /* @__PURE__ */ __name(({
|
|
59
|
+
modelUid,
|
|
60
|
+
containerRef,
|
|
61
|
+
toolbarContainerRef,
|
|
62
|
+
updatePortalRect,
|
|
63
|
+
schedulePortalRectUpdate
|
|
64
|
+
}) => {
|
|
65
|
+
const [hideMenu, setHideMenu] = (0, import_react.useState)(false);
|
|
66
|
+
const [isHostHovered, setIsHostHovered] = (0, import_react.useState)(false);
|
|
67
|
+
const [isToolbarHovered, setIsToolbarHovered] = (0, import_react.useState)(false);
|
|
68
|
+
const [isDraggingToolbar, setIsDraggingToolbar] = (0, import_react.useState)(false);
|
|
69
|
+
const [isDraggingToolbarItem, setIsDraggingToolbarItem] = (0, import_react.useState)(false);
|
|
70
|
+
const [isToolbarPinned, setIsToolbarPinned] = (0, import_react.useState)(false);
|
|
71
|
+
const [isHidePending, setIsHidePending] = (0, import_react.useState)(false);
|
|
72
|
+
const [activeChildToolbarIds, setActiveChildToolbarIds] = (0, import_react.useState)([]);
|
|
73
|
+
const hideToolbarTimerRef = (0, import_react.useRef)(null);
|
|
74
|
+
const reportedChildActivityToAncestorsRef = (0, import_react.useRef)(false);
|
|
75
|
+
const isHostHoveredRef = (0, import_react.useRef)(false);
|
|
76
|
+
const isToolbarHoveredRef = (0, import_react.useRef)(false);
|
|
77
|
+
const isDraggingToolbarRef = (0, import_react.useRef)(false);
|
|
78
|
+
const isDraggingToolbarItemRef = (0, import_react.useRef)(false);
|
|
79
|
+
const isToolbarPinnedRef = (0, import_react.useRef)(false);
|
|
80
|
+
const setHostHovered = (0, import_react.useCallback)((value) => {
|
|
81
|
+
isHostHoveredRef.current = value;
|
|
82
|
+
setIsHostHovered(value);
|
|
83
|
+
}, []);
|
|
84
|
+
const setToolbarHovered = (0, import_react.useCallback)((value) => {
|
|
85
|
+
isToolbarHoveredRef.current = value;
|
|
86
|
+
setIsToolbarHovered(value);
|
|
87
|
+
}, []);
|
|
88
|
+
const setDraggingToolbar = (0, import_react.useCallback)((value) => {
|
|
89
|
+
isDraggingToolbarRef.current = value;
|
|
90
|
+
setIsDraggingToolbar(value);
|
|
91
|
+
}, []);
|
|
92
|
+
const setDraggingToolbarItem = (0, import_react.useCallback)((value) => {
|
|
93
|
+
isDraggingToolbarItemRef.current = value;
|
|
94
|
+
setIsDraggingToolbarItem(value);
|
|
95
|
+
}, []);
|
|
96
|
+
const setToolbarPinned = (0, import_react.useCallback)((value) => {
|
|
97
|
+
isToolbarPinnedRef.current = value;
|
|
98
|
+
setIsToolbarPinned(value);
|
|
99
|
+
}, []);
|
|
100
|
+
const hasActiveChildToolbar = activeChildToolbarIds.length > 0;
|
|
101
|
+
const isToolbarVisible = !hideMenu && !hasActiveChildToolbar && (isHostHovered || isToolbarHovered || isDraggingToolbar || isDraggingToolbarItem || isToolbarPinned);
|
|
102
|
+
const shouldRenderToolbar = isToolbarVisible || isToolbarPinned || isDraggingToolbar || isDraggingToolbarItem;
|
|
103
|
+
const isToolbarInteractionActive = isHostHovered || isToolbarHovered || isDraggingToolbar || isDraggingToolbarItem || isToolbarPinned || isHidePending;
|
|
104
|
+
const clearHideToolbarTimer = (0, import_react.useCallback)(() => {
|
|
105
|
+
if (hideToolbarTimerRef.current !== null) {
|
|
106
|
+
window.clearTimeout(hideToolbarTimerRef.current);
|
|
107
|
+
hideToolbarTimerRef.current = null;
|
|
108
|
+
}
|
|
109
|
+
setIsHidePending(false);
|
|
110
|
+
}, []);
|
|
111
|
+
const scheduleHideToolbar = (0, import_react.useCallback)(() => {
|
|
112
|
+
clearHideToolbarTimer();
|
|
113
|
+
setIsHidePending(true);
|
|
114
|
+
hideToolbarTimerRef.current = window.setTimeout(() => {
|
|
115
|
+
hideToolbarTimerRef.current = null;
|
|
116
|
+
setIsHidePending(false);
|
|
117
|
+
if (isDraggingToolbarRef.current || isDraggingToolbarItemRef.current || isToolbarPinnedRef.current) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setHostHovered(false);
|
|
121
|
+
setToolbarHovered(false);
|
|
122
|
+
}, TOOLBAR_HIDE_DELAY);
|
|
123
|
+
}, [clearHideToolbarTimer, setHostHovered, setToolbarHovered]);
|
|
124
|
+
const handleSettingsMenuOpenChange = (0, import_react.useCallback)(
|
|
125
|
+
(open) => {
|
|
126
|
+
setToolbarPinned(open);
|
|
127
|
+
},
|
|
128
|
+
[setToolbarPinned]
|
|
129
|
+
);
|
|
130
|
+
(0, import_react.useEffect)(() => {
|
|
131
|
+
const hostElement = containerRef.current;
|
|
132
|
+
if (!hostElement) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const handleChildToolbarActivity = /* @__PURE__ */ __name((event) => {
|
|
136
|
+
var _a;
|
|
137
|
+
const customEvent = event;
|
|
138
|
+
if (!(customEvent.target instanceof HTMLElement) || customEvent.target === hostElement) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const childModelUid = (_a = customEvent.detail) == null ? void 0 : _a.modelUid;
|
|
142
|
+
if (!childModelUid) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setActiveChildToolbarIds((prevIds) => {
|
|
146
|
+
var _a2;
|
|
147
|
+
return ((_a2 = customEvent.detail) == null ? void 0 : _a2.active) ? prevIds.includes(childModelUid) ? prevIds : [...prevIds, childModelUid] : prevIds.filter((id) => id !== childModelUid);
|
|
148
|
+
});
|
|
149
|
+
}, "handleChildToolbarActivity");
|
|
150
|
+
hostElement.addEventListener(CHILD_FLOAT_MENU_ACTIVITY_EVENT, handleChildToolbarActivity);
|
|
151
|
+
return () => {
|
|
152
|
+
hostElement.removeEventListener(CHILD_FLOAT_MENU_ACTIVITY_EVENT, handleChildToolbarActivity);
|
|
153
|
+
};
|
|
154
|
+
}, [containerRef]);
|
|
155
|
+
(0, import_react.useEffect)(() => {
|
|
156
|
+
const hostElement = containerRef.current;
|
|
157
|
+
const ownerDocument = hostElement == null ? void 0 : hostElement.ownerDocument;
|
|
158
|
+
if (!ownerDocument) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const handleToolbarDragActivity = /* @__PURE__ */ __name((event) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const customEvent = event;
|
|
164
|
+
if (((_a = customEvent.detail) == null ? void 0 : _a.modelUid) !== modelUid) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if ((_b = customEvent.detail) == null ? void 0 : _b.active) {
|
|
168
|
+
clearHideToolbarTimer();
|
|
169
|
+
setDraggingToolbarItem(true);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setDraggingToolbarItem(false);
|
|
173
|
+
if (isHostHoveredRef.current || isToolbarHoveredRef.current || isToolbarPinnedRef.current) {
|
|
174
|
+
clearHideToolbarTimer();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
scheduleHideToolbar();
|
|
178
|
+
}, "handleToolbarDragActivity");
|
|
179
|
+
ownerDocument.addEventListener(import_dnd.TOOLBAR_DRAG_ACTIVITY_EVENT, handleToolbarDragActivity);
|
|
180
|
+
return () => {
|
|
181
|
+
ownerDocument.removeEventListener(import_dnd.TOOLBAR_DRAG_ACTIVITY_EVENT, handleToolbarDragActivity);
|
|
182
|
+
};
|
|
183
|
+
}, [clearHideToolbarTimer, containerRef, modelUid, scheduleHideToolbar, setDraggingToolbarItem]);
|
|
184
|
+
(0, import_react.useEffect)(() => {
|
|
185
|
+
const hostElement = containerRef.current;
|
|
186
|
+
if (!hostElement || reportedChildActivityToAncestorsRef.current === isToolbarInteractionActive) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
reportedChildActivityToAncestorsRef.current = isToolbarInteractionActive;
|
|
190
|
+
hostElement.dispatchEvent(
|
|
191
|
+
new CustomEvent(CHILD_FLOAT_MENU_ACTIVITY_EVENT, {
|
|
192
|
+
bubbles: true,
|
|
193
|
+
detail: { active: isToolbarInteractionActive, modelUid }
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
}, [containerRef, isToolbarInteractionActive, modelUid]);
|
|
197
|
+
(0, import_react.useEffect)(() => {
|
|
198
|
+
const hostElement = containerRef.current;
|
|
199
|
+
return () => {
|
|
200
|
+
if (hostElement && reportedChildActivityToAncestorsRef.current) {
|
|
201
|
+
hostElement.dispatchEvent(
|
|
202
|
+
new CustomEvent(CHILD_FLOAT_MENU_ACTIVITY_EVENT, {
|
|
203
|
+
bubbles: true,
|
|
204
|
+
detail: { active: false, modelUid }
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
reportedChildActivityToAncestorsRef.current = false;
|
|
208
|
+
}
|
|
209
|
+
clearHideToolbarTimer();
|
|
210
|
+
};
|
|
211
|
+
}, [clearHideToolbarTimer, containerRef, modelUid]);
|
|
212
|
+
(0, import_react.useEffect)(() => {
|
|
213
|
+
if (isToolbarPinned) {
|
|
214
|
+
clearHideToolbarTimer();
|
|
215
|
+
updatePortalRect();
|
|
216
|
+
}
|
|
217
|
+
}, [clearHideToolbarTimer, isToolbarPinned, updatePortalRect]);
|
|
218
|
+
const handleChildHover = (0, import_react.useCallback)(
|
|
219
|
+
(e) => {
|
|
220
|
+
const target = e.target;
|
|
221
|
+
const childWithMenu = target.closest("[data-has-float-menu]");
|
|
222
|
+
const isCurrentHostTarget = !childWithMenu || childWithMenu === containerRef.current;
|
|
223
|
+
if (isCurrentHostTarget) {
|
|
224
|
+
clearHideToolbarTimer();
|
|
225
|
+
setHostHovered(true);
|
|
226
|
+
}
|
|
227
|
+
setHideMenu(!!childWithMenu && childWithMenu !== containerRef.current);
|
|
228
|
+
},
|
|
229
|
+
[clearHideToolbarTimer, containerRef, setHostHovered]
|
|
230
|
+
);
|
|
231
|
+
const handleHostMouseEnter = (0, import_react.useCallback)(() => {
|
|
232
|
+
clearHideToolbarTimer();
|
|
233
|
+
setHideMenu(false);
|
|
234
|
+
updatePortalRect();
|
|
235
|
+
setHostHovered(true);
|
|
236
|
+
}, [clearHideToolbarTimer, setHostHovered, updatePortalRect]);
|
|
237
|
+
const handleHostMouseLeave = (0, import_react.useCallback)(
|
|
238
|
+
(e) => {
|
|
239
|
+
if (isToolbarPinnedRef.current) {
|
|
240
|
+
setHostHovered(false);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (isNodeWithin(e.relatedTarget, toolbarContainerRef.current)) {
|
|
244
|
+
clearHideToolbarTimer();
|
|
245
|
+
setHostHovered(false);
|
|
246
|
+
setToolbarHovered(true);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (isNodeWithinDescendantFloatToolbar(e.relatedTarget, containerRef.current, modelUid)) {
|
|
250
|
+
clearHideToolbarTimer();
|
|
251
|
+
setHideMenu(false);
|
|
252
|
+
setHostHovered(true);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
scheduleHideToolbar();
|
|
256
|
+
},
|
|
257
|
+
[
|
|
258
|
+
clearHideToolbarTimer,
|
|
259
|
+
containerRef,
|
|
260
|
+
modelUid,
|
|
261
|
+
scheduleHideToolbar,
|
|
262
|
+
setHostHovered,
|
|
263
|
+
setToolbarHovered,
|
|
264
|
+
toolbarContainerRef
|
|
265
|
+
]
|
|
266
|
+
);
|
|
267
|
+
const handleToolbarMouseEnter = (0, import_react.useCallback)(() => {
|
|
268
|
+
clearHideToolbarTimer();
|
|
269
|
+
updatePortalRect();
|
|
270
|
+
setHostHovered(false);
|
|
271
|
+
setToolbarHovered(true);
|
|
272
|
+
}, [clearHideToolbarTimer, setHostHovered, setToolbarHovered, updatePortalRect]);
|
|
273
|
+
const handleToolbarMouseLeave = (0, import_react.useCallback)(
|
|
274
|
+
(e) => {
|
|
275
|
+
if (isToolbarPinnedRef.current || isDraggingToolbarItemRef.current) {
|
|
276
|
+
clearHideToolbarTimer();
|
|
277
|
+
setToolbarHovered(false);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
setToolbarHovered(false);
|
|
281
|
+
if (isNodeWithin(e.relatedTarget, containerRef.current)) {
|
|
282
|
+
clearHideToolbarTimer();
|
|
283
|
+
setHostHovered(true);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
scheduleHideToolbar();
|
|
287
|
+
},
|
|
288
|
+
[clearHideToolbarTimer, containerRef, scheduleHideToolbar, setHostHovered, setToolbarHovered]
|
|
289
|
+
);
|
|
290
|
+
const handleResizeDragStart = (0, import_react.useCallback)(() => {
|
|
291
|
+
updatePortalRect();
|
|
292
|
+
setDraggingToolbar(true);
|
|
293
|
+
schedulePortalRectUpdate();
|
|
294
|
+
}, [schedulePortalRectUpdate, setDraggingToolbar, updatePortalRect]);
|
|
295
|
+
const handleResizeDragEnd = (0, import_react.useCallback)(() => {
|
|
296
|
+
setDraggingToolbar(false);
|
|
297
|
+
schedulePortalRectUpdate();
|
|
298
|
+
}, [schedulePortalRectUpdate, setDraggingToolbar]);
|
|
299
|
+
return {
|
|
300
|
+
isToolbarVisible,
|
|
301
|
+
shouldRenderToolbar,
|
|
302
|
+
handleSettingsMenuOpenChange,
|
|
303
|
+
handleChildHover,
|
|
304
|
+
handleHostMouseEnter,
|
|
305
|
+
handleHostMouseLeave,
|
|
306
|
+
handleToolbarMouseEnter,
|
|
307
|
+
handleToolbarMouseLeave,
|
|
308
|
+
handleResizeDragStart,
|
|
309
|
+
handleResizeDragEnd
|
|
310
|
+
};
|
|
311
|
+
}, "useFloatToolbarVisibility");
|
|
312
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
313
|
+
0 && (module.exports = {
|
|
314
|
+
useFloatToolbarVisibility
|
|
315
|
+
});
|
|
@@ -376,6 +376,21 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
376
376
|
}),
|
|
377
377
|
[model, subModelKey, subModelType]
|
|
378
378
|
);
|
|
379
|
+
import_react.default.useEffect(() => {
|
|
380
|
+
var _a, _b, _c;
|
|
381
|
+
const handleSubModelChanged = /* @__PURE__ */ __name(() => {
|
|
382
|
+
setRefreshTick((x) => x + 1);
|
|
383
|
+
}, "handleSubModelChanged");
|
|
384
|
+
(_a = model.emitter) == null ? void 0 : _a.on("onSubModelAdded", handleSubModelChanged);
|
|
385
|
+
(_b = model.emitter) == null ? void 0 : _b.on("onSubModelRemoved", handleSubModelChanged);
|
|
386
|
+
(_c = model.emitter) == null ? void 0 : _c.on("onSubModelReplaced", handleSubModelChanged);
|
|
387
|
+
return () => {
|
|
388
|
+
var _a2, _b2, _c2;
|
|
389
|
+
(_a2 = model.emitter) == null ? void 0 : _a2.off("onSubModelAdded", handleSubModelChanged);
|
|
390
|
+
(_b2 = model.emitter) == null ? void 0 : _b2.off("onSubModelRemoved", handleSubModelChanged);
|
|
391
|
+
(_c2 = model.emitter) == null ? void 0 : _c2.off("onSubModelReplaced", handleSubModelChanged);
|
|
392
|
+
};
|
|
393
|
+
}, [model]);
|
|
379
394
|
const onClick = /* @__PURE__ */ __name(async (info) => {
|
|
380
395
|
const clickedItem = info.originalItem || info;
|
|
381
396
|
const item = clickedItem.originalItem || clickedItem;
|
|
@@ -415,7 +430,7 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
415
430
|
}
|
|
416
431
|
let addedModel;
|
|
417
432
|
try {
|
|
418
|
-
addedModel = model.flowEngine.
|
|
433
|
+
addedModel = await model.flowEngine.createModelAsync({
|
|
419
434
|
...import_lodash.default.cloneDeep(createOpts),
|
|
420
435
|
parentId: model.uid,
|
|
421
436
|
subKey: subModelKey,
|
|
@@ -461,6 +476,17 @@ const AddSubModelButtonCore = /* @__PURE__ */ __name(function AddSubModelButton(
|
|
|
461
476
|
() => transformItems(finalItems, model, subModelKey, subModelType),
|
|
462
477
|
[finalItems, model, subModelKey, subModelType]
|
|
463
478
|
);
|
|
479
|
+
(0, import_react.useEffect)(() => {
|
|
480
|
+
const handleSubModelChange = /* @__PURE__ */ __name(() => {
|
|
481
|
+
setRefreshTick((x) => x + 1);
|
|
482
|
+
}, "handleSubModelChange");
|
|
483
|
+
model.emitter.on("onSubModelAdded", handleSubModelChange);
|
|
484
|
+
model.emitter.on("onSubModelRemoved", handleSubModelChange);
|
|
485
|
+
return () => {
|
|
486
|
+
model.emitter.off("onSubModelAdded", handleSubModelChange);
|
|
487
|
+
model.emitter.off("onSubModelRemoved", handleSubModelChange);
|
|
488
|
+
};
|
|
489
|
+
}, [model]);
|
|
464
490
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
465
491
|
import_LazyDropdown.default,
|
|
466
492
|
{
|