@nocobase/flow-engine
Version:
A standalone flow engine for NocoBase, managing workflows, models, and actions.
137 lines (135 loc) • 5.34 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 __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var VariableTrigger_exports = {};
__export(VariableTrigger_exports, {
VariableTrigger: () => VariableTrigger
});
module.exports = __toCommonJS(VariableTrigger_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_FlowContextSelector = require("../FlowContextSelector");
const VariableTrigger = /* @__PURE__ */ __name(({
attributes,
children,
element,
metaTree,
onVariableSelect,
onTriggerClose
}) => {
const [open, setOpen] = (0, import_react.useState)(true);
const handleVariableSelect = /* @__PURE__ */ __name((value, item) => {
if (item) {
setOpen(false);
onVariableSelect == null ? void 0 : onVariableSelect(element.triggerId, value, item);
}
}, "handleVariableSelect");
const handleOpenChange = /* @__PURE__ */ __name((visible) => {
if (!visible) {
setOpen(false);
onTriggerClose == null ? void 0 : onTriggerClose(element.triggerId);
}
}, "handleOpenChange");
return /* @__PURE__ */ import_react.default.createElement(
import_antd.Popover,
{
content: /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "fit-content" } }, /* @__PURE__ */ import_react.default.createElement("style", null, `
.variable-trigger-popover {
width: fit-content !important;
}
.variable-trigger-popover .ant-popover-content,
.variable-trigger-popover .ant-popover-inner {
background: transparent !important;
box-shadow: none !important;
border: none !important;
padding: 0 !important;
width: fit-content !important;
}
.variable-trigger-popover .ant-popover-arrow { display: none !important; }
.variable-trigger-popover .ant-cascader-menu {
max-height: 50vh !important;
overflow-y: auto !important;
width: auto !important;
min-width: auto !important;
}
.variable-trigger-popover .ant-cascader-menus { width: fit-content !important; }
`), /* @__PURE__ */ import_react.default.createElement(
import_FlowContextSelector.FlowContextSelector,
{
metaTree,
onChange: handleVariableSelect,
open: true,
showSearch: false,
dropdownStyle: { boxShadow: "none", border: "none" },
style: { display: "none" }
},
/* @__PURE__ */ import_react.default.createElement("div", null)
)),
open,
trigger: "click",
placement: "bottomLeft",
onOpenChange: handleOpenChange,
overlayClassName: "variable-trigger-popover",
destroyTooltipOnHide: true
},
/* @__PURE__ */ import_react.default.createElement(
"span",
{
...attributes,
contentEditable: false,
style: {
backgroundColor: "#e6f7ff",
border: "1px dashed #1890ff",
borderRadius: 4,
padding: "1px 4px",
margin: "0 1px",
cursor: "pointer",
display: "inline-block",
fontSize: "12px",
color: "#1890ff",
userSelect: "none"
},
"data-slate-void": true
},
"{{}}",
/* @__PURE__ */ import_react.default.createElement("span", { style: { display: "none" } }, children)
)
);
}, "VariableTrigger");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
VariableTrigger
});