@nocobase/flow-engine
Version:
A standalone flow engine for NocoBase, managing workflows, models, and actions.
96 lines (94 loc) • 3.76 kB
JavaScript
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var getMousePositionOnElement_exports = {};
__export(getMousePositionOnElement_exports, {
ElementPosition: () => ElementPosition,
getMousePositionOnElement: () => getMousePositionOnElement
});
module.exports = __toCommonJS(getMousePositionOnElement_exports);
var ElementPosition = /* @__PURE__ */ ((ElementPosition2) => {
ElementPosition2["TOP"] = "top";
ElementPosition2["BOTTOM"] = "bottom";
ElementPosition2["LEFT"] = "left";
ElementPosition2["RIGHT"] = "right";
ElementPosition2["TOP_EDGE"] = "top-edge";
ElementPosition2["BOTTOM_EDGE"] = "bottom-edge";
ElementPosition2["LEFT_EDGE"] = "left-edge";
ElementPosition2["RIGHT_EDGE"] = "right-edge";
return ElementPosition2;
})(ElementPosition || {});
const getMousePositionOnElement = /* @__PURE__ */ __name(({
initialMousePos,
mouseOffset,
elementBounds,
edgeThreshold = 5,
topBottomHeightRatio = 0.25
}) => {
const currentMouseX = initialMousePos.x + mouseOffset.x;
const currentMouseY = initialMousePos.y + mouseOffset.y;
const relativeX = currentMouseX - elementBounds.x;
const relativeY = currentMouseY - elementBounds.y;
if (relativeX < 0 || relativeX > elementBounds.width || relativeY < 0 || relativeY > elementBounds.height) {
if (relativeY < 0) return "top" /* TOP */;
if (relativeY > elementBounds.height) return "bottom" /* BOTTOM */;
if (relativeX < 0) return "left" /* LEFT */;
return "right" /* RIGHT */;
}
const topBottomHeight = elementBounds.height * topBottomHeightRatio;
const middleAreaTop = topBottomHeight;
const middleAreaBottom = elementBounds.height - topBottomHeight;
const middleAreaHeight = middleAreaBottom - middleAreaTop;
if (relativeY <= topBottomHeight) {
if (relativeY <= edgeThreshold) {
return "top-edge" /* TOP_EDGE */;
}
return "top" /* TOP */;
} else if (relativeY >= middleAreaBottom) {
if (relativeY >= elementBounds.height - edgeThreshold) {
return "bottom-edge" /* BOTTOM_EDGE */;
}
return "bottom" /* BOTTOM */;
} else {
const middleAreaCenterX = elementBounds.width / 2;
if (relativeX <= middleAreaCenterX) {
if (relativeX <= edgeThreshold) {
return "left-edge" /* LEFT_EDGE */;
}
return "left" /* LEFT */;
} else {
if (relativeX >= elementBounds.width - edgeThreshold) {
return "right-edge" /* RIGHT_EDGE */;
}
return "right" /* RIGHT */;
}
}
}, "getMousePositionOnElement");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ElementPosition,
getMousePositionOnElement
});