@nocobase/flow-engine 2.1.0-beta.2 → 2.1.0-beta.21

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.
Files changed (126) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/lib/JSRunner.d.ts +10 -1
  4. package/lib/JSRunner.js +50 -5
  5. package/lib/ViewScopedFlowEngine.js +5 -1
  6. package/lib/components/FlowModelRenderer.d.ts +1 -1
  7. package/lib/components/FlowModelRenderer.js +10 -6
  8. package/lib/components/MobilePopup.js +6 -5
  9. package/lib/components/dnd/gridDragPlanner.js +6 -2
  10. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
  11. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +48 -9
  12. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +19 -43
  13. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +339 -295
  14. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
  15. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
  16. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +272 -0
  17. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
  18. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +247 -0
  19. package/lib/components/subModel/AddSubModelButton.js +27 -1
  20. package/lib/components/subModel/utils.js +2 -2
  21. package/lib/data-source/index.js +6 -0
  22. package/lib/executor/FlowExecutor.js +31 -8
  23. package/lib/flowContext.js +31 -1
  24. package/lib/flowEngine.d.ts +151 -1
  25. package/lib/flowEngine.js +389 -15
  26. package/lib/flowSettings.d.ts +14 -6
  27. package/lib/flowSettings.js +34 -6
  28. package/lib/lazy-helper.d.ts +14 -0
  29. package/lib/lazy-helper.js +71 -0
  30. package/lib/locale/en-US.json +1 -0
  31. package/lib/locale/index.d.ts +2 -0
  32. package/lib/locale/zh-CN.json +1 -0
  33. package/lib/models/flowModel.d.ts +2 -1
  34. package/lib/models/flowModel.js +28 -9
  35. package/lib/reactive/observer.js +46 -16
  36. package/lib/runjs-context/registry.d.ts +1 -1
  37. package/lib/runjs-context/setup.js +20 -12
  38. package/lib/runjs-context/snippets/index.js +13 -2
  39. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
  40. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
  41. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
  42. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
  43. package/lib/scheduler/ModelOperationScheduler.d.ts +5 -1
  44. package/lib/scheduler/ModelOperationScheduler.js +3 -2
  45. package/lib/types.d.ts +47 -1
  46. package/lib/utils/index.d.ts +2 -2
  47. package/lib/utils/index.js +4 -0
  48. package/lib/utils/parsePathnameToViewParams.js +1 -1
  49. package/lib/utils/runjsTemplateCompat.js +1 -1
  50. package/lib/utils/runjsValue.js +41 -11
  51. package/lib/utils/schema-utils.d.ts +7 -1
  52. package/lib/utils/schema-utils.js +19 -0
  53. package/lib/views/FlowView.d.ts +7 -1
  54. package/lib/views/runViewBeforeClose.d.ts +10 -0
  55. package/lib/views/runViewBeforeClose.js +45 -0
  56. package/lib/views/useDialog.d.ts +2 -1
  57. package/lib/views/useDialog.js +20 -3
  58. package/lib/views/useDrawer.d.ts +2 -1
  59. package/lib/views/useDrawer.js +20 -3
  60. package/lib/views/usePage.d.ts +2 -1
  61. package/lib/views/usePage.js +10 -3
  62. package/package.json +6 -5
  63. package/src/JSRunner.ts +68 -4
  64. package/src/ViewScopedFlowEngine.ts +4 -0
  65. package/src/__tests__/JSRunner.test.ts +27 -1
  66. package/src/__tests__/flow-engine.test.ts +166 -0
  67. package/src/__tests__/flowContext.test.ts +65 -1
  68. package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
  69. package/src/__tests__/flowSettings.test.ts +94 -15
  70. package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
  71. package/src/__tests__/runjsContext.test.ts +16 -0
  72. package/src/__tests__/runjsContextRuntime.test.ts +2 -0
  73. package/src/__tests__/runjsPreprocessDefault.test.ts +23 -0
  74. package/src/__tests__/runjsSnippets.test.ts +21 -0
  75. package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
  76. package/src/components/FlowModelRenderer.tsx +12 -6
  77. package/src/components/MobilePopup.tsx +4 -2
  78. package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
  79. package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
  80. package/src/components/__tests__/gridDragPlanner.test.ts +88 -0
  81. package/src/components/dnd/gridDragPlanner.ts +8 -2
  82. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +63 -9
  83. package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +468 -440
  84. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
  85. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +95 -0
  86. package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +609 -0
  87. package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +358 -0
  88. package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +281 -0
  89. package/src/components/subModel/AddSubModelButton.tsx +32 -2
  90. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +142 -32
  91. package/src/components/subModel/utils.ts +1 -1
  92. package/src/data-source/index.ts +6 -0
  93. package/src/executor/FlowExecutor.ts +34 -9
  94. package/src/executor/__tests__/flowExecutor.test.ts +57 -0
  95. package/src/flowContext.ts +35 -3
  96. package/src/flowEngine.ts +445 -11
  97. package/src/flowSettings.ts +40 -6
  98. package/src/lazy-helper.tsx +57 -0
  99. package/src/locale/en-US.json +1 -0
  100. package/src/locale/zh-CN.json +1 -0
  101. package/src/models/__tests__/dispatchEvent.when.test.ts +214 -0
  102. package/src/models/flowModel.tsx +31 -10
  103. package/src/reactive/__tests__/observer.test.tsx +82 -0
  104. package/src/reactive/observer.tsx +87 -25
  105. package/src/runjs-context/registry.ts +1 -1
  106. package/src/runjs-context/setup.ts +22 -12
  107. package/src/runjs-context/snippets/index.ts +12 -1
  108. package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
  109. package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
  110. package/src/scheduler/ModelOperationScheduler.ts +14 -3
  111. package/src/types.ts +60 -0
  112. package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -0
  113. package/src/utils/__tests__/runjsValue.test.ts +11 -0
  114. package/src/utils/__tests__/utils.test.ts +62 -0
  115. package/src/utils/index.ts +2 -1
  116. package/src/utils/parsePathnameToViewParams.ts +2 -2
  117. package/src/utils/runjsTemplateCompat.ts +1 -1
  118. package/src/utils/runjsValue.ts +50 -11
  119. package/src/utils/schema-utils.ts +30 -1
  120. package/src/views/FlowView.tsx +11 -1
  121. package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
  122. package/src/views/__tests__/useDialog.closeDestroy.test.tsx +13 -12
  123. package/src/views/runViewBeforeClose.ts +19 -0
  124. package/src/views/useDialog.tsx +25 -3
  125. package/src/views/useDrawer.tsx +25 -3
  126. package/src/views/usePage.tsx +12 -3
package/README.md CHANGED
@@ -1,17 +1,24 @@
1
1
  # NocoBase
2
2
 
3
3
  <video width="100%" controls>
4
- <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
4
+ <source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
5
5
  </video>
6
6
 
7
+ <p align="center">
8
+ <a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
9
+ <a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
10
+ </p>
7
11
 
8
12
  ## What is NocoBase
9
13
 
10
- NocoBase is a scalability-first, open-source no-code development platform.
11
- Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
14
+ NocoBase is the most extensible AI-powered no-code platform.
15
+ Total control. Infinite extensibility. AI collaboration.
16
+ Enable your team to adapt quickly and cut costs dramatically.
17
+ No years of development. No millions wasted.
18
+ Deploy NocoBase in minutes — and take control of everything.
12
19
 
13
20
  Homepage:
14
- https://www.nocobase.com/
21
+ https://www.nocobase.com/
15
22
 
16
23
  Online Demo:
17
24
  https://demo.nocobase.com/new
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
19
26
  Documents:
20
27
  https://docs.nocobase.com/
21
28
 
22
- Commericial license & plugins:
23
- https://www.nocobase.com/en/commercial
29
+ Forum:
30
+ https://forum.nocobase.com/
24
31
 
25
- License agreement:
26
- https://www.nocobase.com/en/agreement
32
+ Use Cases:
33
+ https://www.nocobase.com/en/blog/tags/customer-stories
27
34
 
35
+ ## Release Notes
28
36
 
29
- ## Contact Us:
30
- hello@nocobase.com
37
+ Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
38
+
39
+ ## Distinctive features
40
+
41
+ ### 1. Data model-driven, not form/table–driven
42
+
43
+ Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
44
+
45
+ - UI and data structure are fully decoupled
46
+ - Multiple blocks and actions can be created for the same table or record in any quantity or form
47
+ - Supports the main database, external databases, and third-party APIs as data sources
48
+
49
+ ![model](https://static-docs.nocobase.com/model.png)
50
+
51
+ ### 2. AI employees, integrated into your business systems
52
+ Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
53
+
54
+ - Define AI employees for roles such as translator, analyst, researcher, or assistant
55
+ - Seamless AI–human collaboration in interfaces and workflows
56
+ - Ensure AI usage is secure, transparent, and customizable for your business needs
57
+
58
+ ![AI-employee](https://static-docs.nocobase.com/ai-employee-home.png)
59
+
60
+ ### 3. What you see is what you get, incredibly easy to use
61
+
62
+ While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
63
+
64
+ - One-click switch between usage mode and configuration mode
65
+ - Pages serve as a canvas to arrange blocks and actions, similar to Notion
66
+ - Configuration mode is designed for ordinary users, not just programmers
67
+
68
+ ![wysiwyg](https://static-docs.nocobase.com/wysiwyg.gif)
69
+
70
+ ### 4. Everything is a plugin, designed for extension
71
+ Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
72
+
73
+ - All functionalities are plugins, similar to WordPress
74
+ - Plugins are ready to use upon installation
75
+ - Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
76
+
77
+ ![plugins](https://static-docs.nocobase.com/plugins.png)
78
+
79
+ ## Installation
80
+
81
+ NocoBase supports three installation methods:
82
+
83
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
84
+
85
+ Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
86
+
87
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
88
+
89
+ The business code of the project is completely independent and supports low-code development.
90
+
91
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
92
+
93
+ If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
94
+
95
+ ## How NocoBase works
96
+
97
+ <video width="100%" controls>
98
+ <source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
99
+ </video>
package/lib/JSRunner.d.ts CHANGED
@@ -13,11 +13,20 @@ export interface JSRunnerOptions {
13
13
  version?: string;
14
14
  /**
15
15
  * Enable RunJS template compatibility preprocessing for `{{ ... }}`.
16
- * When enabled via `ctx.runjs(code, vars, { preprocessTemplates: true })` (default),
16
+ * When enabled (or falling back to version default),
17
17
  * the code will be rewritten to call `ctx.resolveJsonTemplate(...)` at runtime.
18
18
  */
19
19
  preprocessTemplates?: boolean;
20
20
  }
21
+ /**
22
+ * Decide whether RunJS `{{ ... }}` compatibility preprocessing should run.
23
+ *
24
+ * Priority:
25
+ * 1. Explicit `preprocessTemplates` option always wins.
26
+ * 2. Otherwise, `version === 'v2'` disables preprocessing.
27
+ * 3. Fallback keeps v1-compatible behavior (enabled).
28
+ */
29
+ export declare function shouldPreprocessRunJSTemplates(options?: Pick<JSRunnerOptions, 'preprocessTemplates' | 'version'>): boolean;
21
30
  export declare class JSRunner {
22
31
  private globals;
23
32
  private timeoutMs;
package/lib/JSRunner.js CHANGED
@@ -27,11 +27,53 @@ var __copyProps = (to, from, except, desc) => {
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var JSRunner_exports = {};
29
29
  __export(JSRunner_exports, {
30
- JSRunner: () => JSRunner
30
+ JSRunner: () => JSRunner,
31
+ shouldPreprocessRunJSTemplates: () => shouldPreprocessRunJSTemplates
31
32
  });
32
33
  module.exports = __toCommonJS(JSRunner_exports);
33
34
  var import_ses = require("ses");
34
35
  var import_exceptions = require("./utils/exceptions");
36
+ function shouldPreprocessRunJSTemplates(options) {
37
+ if (typeof (options == null ? void 0 : options.preprocessTemplates) === "boolean") {
38
+ return options.preprocessTemplates;
39
+ }
40
+ return (options == null ? void 0 : options.version) !== "v2";
41
+ }
42
+ __name(shouldPreprocessRunJSTemplates, "shouldPreprocessRunJSTemplates");
43
+ const BARE_CTX_TEMPLATE_RE = /(^|[=(:,[\s)])(\{\{\s*(ctx(?:\.|\[|\?\.)[^}]*)\s*\}\})/m;
44
+ function extractDeprecatedCtxTemplateUsage(code) {
45
+ const src = String(code || "");
46
+ const m = src.match(BARE_CTX_TEMPLATE_RE);
47
+ if (!m) return null;
48
+ const placeholder = String(m[2] || "").trim();
49
+ const expression = String(m[3] || "").trim();
50
+ if (!placeholder || !expression) return null;
51
+ return { placeholder, expression };
52
+ }
53
+ __name(extractDeprecatedCtxTemplateUsage, "extractDeprecatedCtxTemplateUsage");
54
+ function shouldHintCtxTemplateSyntax(err, usage) {
55
+ const isSyntaxError = err instanceof SyntaxError || String((err == null ? void 0 : err.name) || "") === "SyntaxError";
56
+ if (!isSyntaxError) return false;
57
+ if (!usage) return false;
58
+ const msg = String((err == null ? void 0 : err.message) || err || "");
59
+ return /unexpected token/i.test(msg);
60
+ }
61
+ __name(shouldHintCtxTemplateSyntax, "shouldHintCtxTemplateSyntax");
62
+ function toCtxTemplateSyntaxHintError(err, usage) {
63
+ const hint = `"${usage.placeholder}" has been deprecated and cannot be used as executable RunJS syntax. Use await ctx.getVar("${usage.expression}") instead, or keep "${usage.placeholder}" as a plain string.`;
64
+ const out = new SyntaxError(hint);
65
+ try {
66
+ out.cause = err;
67
+ } catch (_) {
68
+ }
69
+ try {
70
+ out.__runjsHideLocation = true;
71
+ out.stack = `${out.name}: ${out.message}`;
72
+ } catch (_) {
73
+ }
74
+ return out;
75
+ }
76
+ __name(toCtxTemplateSyntaxHintError, "toCtxTemplateSyntaxHintError");
35
77
  const _JSRunner = class _JSRunner {
36
78
  globals;
37
79
  timeoutMs;
@@ -111,11 +153,13 @@ const _JSRunner = class _JSRunner {
111
153
  if (err instanceof import_exceptions.FlowExitAllException) {
112
154
  throw err;
113
155
  }
114
- console.error(err);
156
+ const usage = extractDeprecatedCtxTemplateUsage(code);
157
+ const outErr = shouldHintCtxTemplateSyntax(err, usage) && usage ? toCtxTemplateSyntaxHintError(err, usage) : err;
158
+ console.error(outErr);
115
159
  return {
116
160
  success: false,
117
- error: err,
118
- timeout: err.message === "Execution timed out"
161
+ error: outErr,
162
+ timeout: (outErr == null ? void 0 : outErr.message) === "Execution timed out"
119
163
  };
120
164
  }
121
165
  }
@@ -124,5 +168,6 @@ __name(_JSRunner, "JSRunner");
124
168
  let JSRunner = _JSRunner;
125
169
  // Annotate the CommonJS export names for ESM import in node:
126
170
  0 && (module.exports = {
127
- JSRunner
171
+ JSRunner,
172
+ shouldPreprocessRunJSTemplates
128
173
  });
@@ -65,7 +65,11 @@ function createViewScopedEngine(parent) {
65
65
  "_previousEngine",
66
66
  "_nextEngine",
67
67
  // getModel 需要在本地执行以确保全局查找时正确遍历整个引擎栈
68
- "getModel"
68
+ "getModel",
69
+ // 视图销毁回调需要在本地存储,每个视图引擎有自己的销毁逻辑
70
+ "_destroyView",
71
+ "setDestroyView",
72
+ "destroyView"
69
73
  ]);
70
74
  const handler = {
71
75
  get(target, prop, receiver) {
@@ -19,7 +19,7 @@ export interface FlowModelRendererProps {
19
19
  showBackground?: boolean;
20
20
  showBorder?: boolean;
21
21
  showDragHandle?: boolean;
22
- /** 自定义工具栏样式 */
22
+ /** 自定义工具栏样式,`top/left/right/bottom` 会作为 portal overlay 的 inset 使用 */
23
23
  style?: React.CSSProperties;
24
24
  /**
25
25
  * @default 'inside'
@@ -61,11 +61,12 @@ const FlowModelRendererWithAutoFlows = (0, import_reactive.observer)(
61
61
  showErrorFallback,
62
62
  settingsMenuLevel,
63
63
  extraToolbarItems,
64
- fallback
64
+ fallback,
65
+ useCache
65
66
  }) => {
66
67
  const { loading: pending, error: autoFlowsError } = (0, import_hooks.useApplyAutoFlows)(model, inputArgs, {
67
68
  throwOnError: false,
68
- useCache: model.context.useCache
69
+ useCache
69
70
  });
70
71
  (0, import_utils.setAutoFlowError)(model, autoFlowsError || null);
71
72
  if (pending) {
@@ -195,13 +196,15 @@ const FlowModelRenderer = (0, import_reactive.observer)(
195
196
  extraToolbarItems,
196
197
  useCache
197
198
  }) => {
199
+ var _a;
200
+ const resolvedUseCache = typeof useCache === "boolean" ? useCache : (_a = model == null ? void 0 : model.context) == null ? void 0 : _a.useCache;
198
201
  (0, import_react.useEffect)(() => {
199
- if (model == null ? void 0 : model.context) {
202
+ if ((model == null ? void 0 : model.context) && typeof resolvedUseCache !== "undefined") {
200
203
  model.context.defineProperty("useCache", {
201
- value: typeof useCache === "boolean" ? useCache : model.context.useCache
204
+ value: resolvedUseCache
202
205
  });
203
206
  }
204
- }, [model == null ? void 0 : model.context, useCache]);
207
+ }, [model == null ? void 0 : model.context, resolvedUseCache]);
205
208
  if (!model || typeof model.render !== "function") {
206
209
  console.warn("FlowModelRenderer: Invalid model or render method not found.", model);
207
210
  return null;
@@ -218,7 +221,8 @@ const FlowModelRenderer = (0, import_reactive.observer)(
218
221
  showErrorFallback,
219
222
  settingsMenuLevel,
220
223
  extraToolbarItems,
221
- fallback
224
+ fallback,
225
+ useCache: resolvedUseCache
222
226
  }
223
227
  );
224
228
  if (showErrorFallback) {
@@ -41,11 +41,12 @@ __export(MobilePopup_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(MobilePopup_exports);
43
43
  var import_antd = require("antd");
44
- var import_antd_mobile = require("antd-mobile");
45
44
  var import_react = __toESM(require("react"));
46
- var import_antd_mobile_icons = require("antd-mobile-icons");
47
45
  var import_MobilePopup = require("./MobilePopup.style");
48
46
  var import_react_i18next = require("react-i18next");
47
+ var import_lazy_helper = require("../lazy-helper");
48
+ const { Popup } = (0, import_lazy_helper.lazy)(() => import("antd-mobile"), "Popup");
49
+ const { CloseOutline } = (0, import_lazy_helper.lazy)(() => import("antd-mobile-icons"), "CloseOutline");
49
50
  const MobilePopup = /* @__PURE__ */ __name((props) => {
50
51
  const { title, visible, onClose: closePopup, children, minHeight, className, footer } = props;
51
52
  const { t } = (0, import_react_i18next.useTranslation)();
@@ -67,7 +68,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
67
68
  };
68
69
  }, []);
69
70
  return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { theme }, /* @__PURE__ */ import_react.default.createElement(
70
- import_antd_mobile.Popup,
71
+ Popup,
71
72
  {
72
73
  className: `${componentCls} ${hashId} ${className || ""}`,
73
74
  visible,
@@ -81,7 +82,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
81
82
  style,
82
83
  destroyOnClose: true
83
84
  },
84
- /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(import_antd_mobile_icons.CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span", null, title), /* @__PURE__ */ import_react.default.createElement(
85
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span", null, title), /* @__PURE__ */ import_react.default.createElement(
85
86
  "span",
86
87
  {
87
88
  className: "nb-mobile-action-drawer-close-icon",
@@ -90,7 +91,7 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
90
91
  tabIndex: 0,
91
92
  "aria-label": t("Close")
92
93
  },
93
- /* @__PURE__ */ import_react.default.createElement(import_antd_mobile_icons.CloseOutline, null)
94
+ /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)
94
95
  )),
95
96
  children,
96
97
  footer && /* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-footer" }, footer)
@@ -220,7 +220,9 @@ const buildLayoutSnapshot = /* @__PURE__ */ __name(({ container }) => {
220
220
  }
221
221
  const columnElements = Array.from(
222
222
  container.querySelectorAll(`[data-grid-column-row-id="${rowId}"][data-grid-column-index]`)
223
- );
223
+ ).filter((el) => {
224
+ return el.closest("[data-grid-row-id]") === rowElement;
225
+ });
224
226
  const sortedColumns = columnElements.sort((a, b) => {
225
227
  const indexA = Number(a.dataset.gridColumnIndex || 0);
226
228
  const indexB = Number(b.dataset.gridColumnIndex || 0);
@@ -245,7 +247,9 @@ const buildLayoutSnapshot = /* @__PURE__ */ __name(({ container }) => {
245
247
  });
246
248
  const itemElements = Array.from(
247
249
  columnElement.querySelectorAll(`[data-grid-item-row-id="${rowId}"][data-grid-column-index="${columnIndex}"]`)
248
- );
250
+ ).filter((el) => {
251
+ return el.closest("[data-grid-column-row-id][data-grid-column-index]") === columnElement;
252
+ });
249
253
  const sortedItems = itemElements.sort((a, b) => {
250
254
  const indexA = Number(a.dataset.gridItemIndex || 0);
251
255
  const indexB = Number(b.dataset.gridItemIndex || 0);
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import type { DropdownProps } from 'antd';
9
10
  import React from 'react';
10
11
  import { FlowModel } from '../../../../models';
11
12
  /**
@@ -18,6 +19,8 @@ interface DefaultSettingsIconProps {
18
19
  showCopyUidButton?: boolean;
19
20
  menuLevels?: number;
20
21
  flattenSubMenus?: boolean;
22
+ onDropdownVisibleChange?: (open: boolean) => void;
23
+ getPopupContainer?: DropdownProps['getPopupContainer'];
21
24
  [key: string]: any;
22
25
  }
23
26
  export declare const DefaultSettingsIcon: React.FC<DefaultSettingsIconProps>;
@@ -41,6 +41,7 @@ __export(DefaultSettingsIcon_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(DefaultSettingsIcon_exports);
43
43
  var import_icons = require("@ant-design/icons");
44
+ var import_css = require("@emotion/css");
44
45
  var import_antd = require("antd");
45
46
  var import_react = __toESM(require("react"));
46
47
  var import_models = require("../../../../models");
@@ -149,13 +150,32 @@ const MenuLabelItem = /* @__PURE__ */ __name(({ title, uiMode, itemProps }) => {
149
150
  }
150
151
  return /* @__PURE__ */ import_react.default.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } }, content, /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: disabledReason, placement: "right", destroyTooltipOnHide: true }, /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, { style: { color: disabledIconColor } })));
151
152
  }, "MenuLabelItem");
153
+ const TOOLBAR_ICONS_SELECTOR = ".nb-toolbar-container-icons";
154
+ const TOOLBAR_CONTAINER_SELECTOR = ".nb-toolbar-container";
155
+ const TOOLBAR_DROPDOWN_OVERLAY_CLASS = import_css.css`
156
+ width: max-content;
157
+ min-width: max-content;
158
+
159
+ .ant-dropdown-menu {
160
+ width: max-content;
161
+ min-width: max-content;
162
+ }
163
+ `;
164
+ const getToolbarPopupContainer = /* @__PURE__ */ __name((triggerNode) => {
165
+ if (!triggerNode) {
166
+ return null;
167
+ }
168
+ return triggerNode.closest(TOOLBAR_ICONS_SELECTOR) || triggerNode.closest(TOOLBAR_CONTAINER_SELECTOR);
169
+ }, "getToolbarPopupContainer");
152
170
  const DefaultSettingsIcon = /* @__PURE__ */ __name(({
153
171
  model,
154
172
  showDeleteButton = true,
155
173
  showCopyUidButton = true,
156
174
  menuLevels = 1,
157
175
  // 默认一级菜单
158
- flattenSubMenus = true
176
+ flattenSubMenus = true,
177
+ onDropdownVisibleChange,
178
+ getPopupContainer
159
179
  }) => {
160
180
  const { message } = import_antd.App.useApp();
161
181
  const t = (0, import_react.useMemo)(() => (0, import_utils.getT)(model), [model]);
@@ -168,14 +188,30 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
168
188
  const [isLoading, setIsLoading] = (0, import_react.useState)(true);
169
189
  const closeDropdown = (0, import_react.useCallback)(() => {
170
190
  setVisible(false);
171
- }, []);
172
- const handleOpenChange = (0, import_react.useCallback)((nextOpen, info) => {
173
- if (info.source === "trigger" || nextOpen) {
174
- (0, import_react.startTransition)(() => {
175
- setVisible(nextOpen);
176
- });
177
- }
178
- }, []);
191
+ onDropdownVisibleChange == null ? void 0 : onDropdownVisibleChange(false);
192
+ }, [onDropdownVisibleChange]);
193
+ const resolvePopupContainer = (0, import_react.useCallback)(
194
+ (triggerNode) => {
195
+ return getToolbarPopupContainer(triggerNode) || (getPopupContainer == null ? void 0 : getPopupContainer(triggerNode)) || (triggerNode == null ? void 0 : triggerNode.parentElement) || document.body;
196
+ },
197
+ [getPopupContainer]
198
+ );
199
+ const handleOpenChange = (0, import_react.useCallback)(
200
+ (nextOpen, info) => {
201
+ if (info.source === "trigger" || nextOpen) {
202
+ (0, import_react.startTransition)(() => {
203
+ setVisible(nextOpen);
204
+ });
205
+ onDropdownVisibleChange == null ? void 0 : onDropdownVisibleChange(nextOpen);
206
+ }
207
+ },
208
+ [onDropdownVisibleChange]
209
+ );
210
+ (0, import_react.useEffect)(() => {
211
+ return () => {
212
+ onDropdownVisibleChange == null ? void 0 : onDropdownVisibleChange(false);
213
+ };
214
+ }, [onDropdownVisibleChange]);
179
215
  const dropdownMaxHeight = (0, import_hooks.useNiceDropdownMaxHeight)([visible]);
180
216
  (0, import_react.useEffect)(() => {
181
217
  let mounted = true;
@@ -671,6 +707,9 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
671
707
  return /* @__PURE__ */ import_react.default.createElement(
672
708
  import_antd.Dropdown,
673
709
  {
710
+ getPopupContainer: resolvePopupContainer,
711
+ overlayClassName: TOOLBAR_DROPDOWN_OVERLAY_CLASS,
712
+ overlayStyle: { width: "max-content", minWidth: "max-content" },
674
713
  onOpenChange: handleOpenChange,
675
714
  open: visible,
676
715
  menu: {
@@ -9,13 +9,14 @@
9
9
  import React from 'react';
10
10
  import { FlowModel } from '../../../../models';
11
11
  import { ToolbarItemConfig } from '../../../../types';
12
- interface ModelProvidedProps {
13
- model: FlowModel<any>;
12
+ type ToolbarPosition = 'inside' | 'above' | 'below';
13
+ interface BaseFloatContextMenuProps {
14
14
  children?: React.ReactNode;
15
15
  enabled?: boolean;
16
16
  showDeleteButton?: boolean;
17
17
  showCopyUidButton?: boolean;
18
18
  containerStyle?: React.CSSProperties;
19
+ /** 自定义工具栏样式,`top/left/right/bottom` 会作为 portal overlay 的 inset 使用。 */
19
20
  toolbarStyle?: React.CSSProperties;
20
21
  className?: string;
21
22
  /**
@@ -45,65 +46,40 @@ interface ModelProvidedProps {
45
46
  /**
46
47
  * @default 'inside'
47
48
  */
48
- toolbarPosition?: 'inside' | 'above' | 'below';
49
+ toolbarPosition?: ToolbarPosition;
50
+ }
51
+ interface ModelProvidedProps extends BaseFloatContextMenuProps {
52
+ model: FlowModel<any>;
49
53
  }
50
- interface ModelByIdProps {
54
+ interface ModelByIdProps extends BaseFloatContextMenuProps {
51
55
  uid: string;
52
56
  modelClassName: string;
53
- children?: React.ReactNode;
54
- enabled?: boolean;
55
- showDeleteButton?: boolean;
56
- showCopyUidButton?: boolean;
57
- containerStyle?: React.CSSProperties;
58
- className?: string;
59
- /**
60
- * @default true
61
- */
62
- showBorder?: boolean;
63
- /**
64
- * @default true
65
- */
66
- showBackground?: boolean;
67
- /**
68
- * @default false
69
- */
70
- showTitle?: boolean;
71
- /**
72
- * Settings menu levels: 1=current model only (default), 2=include sub-models
73
- */
74
- settingsMenuLevel?: number;
75
- /**
76
- * Extra toolbar items to add to this context menu instance
77
- */
78
- extraToolbarItems?: ToolbarItemConfig[];
79
- /**
80
- * @default 'inside'
81
- */
82
- toolbarPosition?: 'inside' | 'above' | 'below';
83
57
  }
84
58
  type FlowsFloatContextMenuProps = ModelProvidedProps | ModelByIdProps;
85
59
  /**
86
- * FlowsFloatContextMenu组件 - 悬浮配置图标组件
60
+ * FlowsFloatContextMenu组件 - 悬浮配置工具栏组件
87
61
  *
88
62
  * 功能特性:
89
63
  * - 鼠标悬浮显示右上角配置图标
90
64
  * - 点击图标显示配置菜单
91
65
  * - 支持删除功能
92
66
  * - Wrapper 模式支持
93
- * - 使用与 NocoBase x-settings 一致的样式
94
- * - 按flow分组显示steps
67
+ * - 使用 portal overlay 避免被宿主或祖先裁剪
68
+ * - 设置菜单与工具栏共享同一个 popup 容器
95
69
  *
96
70
  * 支持两种使用方式:
97
- * 1. 直接提供model: <FlowsFloatContextMenu model={myModel}>{children}</FlowsFloatContextMenu>
98
- * 2. 通过uid和modelClassName获取model: <FlowsFloatContextMenu uid="model1" modelClassName="MyModel">{children}</FlowsFloatContextMenu>
71
+ * 1. 直接提供 model: `<FlowsFloatContextMenu model={myModel}>{children}</FlowsFloatContextMenu>`
72
+ * 2. 通过 uid modelClassName 获取 model:
73
+ * `<FlowsFloatContextMenu uid="model1" modelClassName="MyModel">{children}</FlowsFloatContextMenu>`
99
74
  *
100
75
  * @param props.children 子组件,必须提供
101
- * @param props.enabled 是否启用悬浮菜单,默认为true
102
- * @param props.showDeleteButton 是否显示删除按钮,默认为true
103
- * @param props.showCopyUidButton 是否显示复制UID按钮,默认为true
76
+ * @param props.enabled 是否启用悬浮菜单,默认为 true
77
+ * @param props.showDeleteButton 是否显示删除按钮,默认为 true
78
+ * @param props.showCopyUidButton 是否显示复制 UID 按钮,默认为 true
104
79
  * @param props.containerStyle 容器自定义样式
80
+ * @param props.toolbarStyle 工具栏自定义样式;`top/left/right/bottom` 会作为 portal overlay 的 inset 使用
105
81
  * @param props.className 容器自定义类名
106
- * @param props.showTitle 是否在边框左上角显示模型title,默认为false
82
+ * @param props.showTitle 是否在边框左上角显示模型 title,默认为 false
107
83
  * @param props.settingsMenuLevel 设置菜单层级:1=仅当前模型(默认),2=包含子模型
108
84
  * @param props.extraToolbarItems 额外的工具栏项目,仅应用于此实例
109
85
  */