UNPKG

@nocobase/flow-engine

Version:

A standalone flow engine for NocoBase, managing workflows, models, and actions.

149 lines (147 loc) 5.53 kB
/** * 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 VariableTag_exports = {}; __export(VariableTag_exports, { VariableTag: () => VariableTag }); module.exports = __toCommonJS(VariableTag_exports); var import_react = __toESM(require("react")); var import_antd = require("antd"); var import_css = require("@emotion/css"); var import_utils = require("./utils"); var import_useResolvedMetaTree = require("./useResolvedMetaTree"); var import_ahooks = require("ahooks"); var import_FlowContextProvider = require("../../FlowContextProvider"); const VariableTagComponent = /* @__PURE__ */ __name(({ value, onClear, className, style, metaTreeNode, metaTree }) => { const { resolvedMetaTree } = (0, import_useResolvedMetaTree.useResolvedMetaTree)(metaTree); const ctx = (0, import_FlowContextProvider.useFlowContext)(); const { data: displayedValue } = (0, import_ahooks.useRequest)( async () => { if (metaTreeNode) { return metaTreeNode.parentTitles ? [...metaTreeNode.parentTitles, metaTreeNode.title].map(ctx.t).join("/") : ctx.t(metaTreeNode.title) || ""; } if (!value) return String(value); const path = (0, import_utils.parseValueToPath)(value); return path ? path.join("/") : String(value); }, { refreshDeps: [resolvedMetaTree, value, metaTreeNode] } ); const { token } = import_antd.theme.useToken(); const shrinkableOverflowItem = import_css.css` /* 选择器容器允许收缩并隐藏超出 */ & .ant-select-selector { min-width: 0; overflow: hidden; } /* rc-overflow 只展示单行,避免换行导致容器增高 */ & .rc-overflow { flex-wrap: nowrap; } `; const customTagRender = /* @__PURE__ */ __name((props) => { const { label } = props; const fullText = typeof label === "string" ? label : String(label); return /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: fullText, placement: "top", getPopupContainer: () => document.body }, /* @__PURE__ */ import_react.default.createElement( import_antd.Tag, { color: "blue", style: { margin: `0 ${token.marginXXS || token.marginXS}px`, borderRadius: token.borderRadiusSM, fontSize: token.fontSizeSM, display: "inline-flex", alignItems: "center", padding: `0 ${token.paddingXXS}px`, minWidth: 0, maxWidth: "100%", overflow: "hidden", width: "100%" } }, /* @__PURE__ */ import_react.default.createElement( "span", { style: { minWidth: 0, width: "100%", overflow: "hidden", whiteSpace: "nowrap", display: "inline-block" } }, fullText ) )); }, "customTagRender"); return /* @__PURE__ */ import_react.default.createElement( import_antd.Select, { className: (0, import_css.cx)("variable", shrinkableOverflowItem, className), style: { // Fill the available width of the surrounding layout. // A fixed maxWidth here caused the input to shrink when a variable is selected. width: "100%", minWidth: 0, flex: "1 1 auto", ...style }, value: displayedValue ? [displayedValue] : [], mode: "tags", open: false, allowClear: !!onClear, onClear, disabled: !onClear, variant: "outlined", suffixIcon: null, tagRender: customTagRender, onClick: (e) => e.preventDefault(), removeIcon: null } ); }, "VariableTagComponent"); const VariableTag = import_react.default.memo(VariableTagComponent); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { VariableTag });