@nocobase/flow-engine 2.1.0-alpha.3 → 2.1.0-alpha.30

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 (160) 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/FieldModelRenderer.js +2 -2
  7. package/lib/components/FlowModelRenderer.d.ts +3 -1
  8. package/lib/components/FlowModelRenderer.js +12 -6
  9. package/lib/components/MobilePopup.js +6 -5
  10. package/lib/components/dnd/gridDragPlanner.d.ts +59 -2
  11. package/lib/components/dnd/gridDragPlanner.js +601 -21
  12. package/lib/components/dnd/index.d.ts +19 -1
  13. package/lib/components/dnd/index.js +243 -23
  14. package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
  15. package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
  16. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
  17. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +68 -10
  18. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +23 -43
  19. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +352 -295
  20. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
  21. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
  22. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +274 -0
  23. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
  24. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +315 -0
  25. package/lib/components/subModel/AddSubModelButton.js +27 -1
  26. package/lib/components/subModel/index.d.ts +1 -0
  27. package/lib/components/subModel/index.js +19 -0
  28. package/lib/components/subModel/utils.d.ts +1 -1
  29. package/lib/components/subModel/utils.js +2 -2
  30. package/lib/data-source/index.d.ts +73 -0
  31. package/lib/data-source/index.js +211 -1
  32. package/lib/executor/FlowExecutor.js +31 -8
  33. package/lib/flowContext.d.ts +2 -0
  34. package/lib/flowContext.js +31 -1
  35. package/lib/flowEngine.d.ts +151 -1
  36. package/lib/flowEngine.js +389 -15
  37. package/lib/flowI18n.js +2 -1
  38. package/lib/flowSettings.d.ts +14 -6
  39. package/lib/flowSettings.js +34 -6
  40. package/lib/lazy-helper.d.ts +14 -0
  41. package/lib/lazy-helper.js +71 -0
  42. package/lib/locale/en-US.json +1 -0
  43. package/lib/locale/index.d.ts +2 -0
  44. package/lib/locale/zh-CN.json +1 -0
  45. package/lib/models/DisplayItemModel.d.ts +1 -1
  46. package/lib/models/EditableItemModel.d.ts +1 -1
  47. package/lib/models/FilterableItemModel.d.ts +1 -1
  48. package/lib/models/flowModel.d.ts +13 -10
  49. package/lib/models/flowModel.js +78 -18
  50. package/lib/provider.js +38 -23
  51. package/lib/reactive/observer.js +46 -16
  52. package/lib/runjs-context/registry.d.ts +1 -1
  53. package/lib/runjs-context/setup.js +20 -12
  54. package/lib/runjs-context/snippets/index.js +13 -2
  55. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
  56. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
  57. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
  58. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
  59. package/lib/scheduler/ModelOperationScheduler.d.ts +5 -1
  60. package/lib/scheduler/ModelOperationScheduler.js +3 -2
  61. package/lib/types.d.ts +47 -1
  62. package/lib/utils/createCollectionContextMeta.js +6 -2
  63. package/lib/utils/index.d.ts +2 -2
  64. package/lib/utils/index.js +4 -0
  65. package/lib/utils/parsePathnameToViewParams.js +1 -1
  66. package/lib/utils/runjsTemplateCompat.js +1 -1
  67. package/lib/utils/runjsValue.js +41 -11
  68. package/lib/utils/schema-utils.d.ts +7 -1
  69. package/lib/utils/schema-utils.js +19 -0
  70. package/lib/views/FlowView.d.ts +7 -1
  71. package/lib/views/runViewBeforeClose.d.ts +10 -0
  72. package/lib/views/runViewBeforeClose.js +45 -0
  73. package/lib/views/useDialog.d.ts +2 -1
  74. package/lib/views/useDialog.js +20 -3
  75. package/lib/views/useDrawer.d.ts +2 -1
  76. package/lib/views/useDrawer.js +20 -3
  77. package/lib/views/usePage.d.ts +2 -1
  78. package/lib/views/usePage.js +10 -3
  79. package/package.json +6 -5
  80. package/src/JSRunner.ts +68 -4
  81. package/src/ViewScopedFlowEngine.ts +4 -0
  82. package/src/__tests__/JSRunner.test.ts +27 -1
  83. package/src/__tests__/flow-engine.test.ts +166 -0
  84. package/src/__tests__/flowContext.test.ts +65 -1
  85. package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
  86. package/src/__tests__/flowSettings.test.ts +94 -15
  87. package/src/__tests__/objectVariable.test.ts +24 -0
  88. package/src/__tests__/provider.test.tsx +24 -2
  89. package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
  90. package/src/__tests__/runjsContext.test.ts +16 -0
  91. package/src/__tests__/runjsContextRuntime.test.ts +2 -0
  92. package/src/__tests__/runjsPreprocessDefault.test.ts +23 -0
  93. package/src/__tests__/runjsSnippets.test.ts +21 -0
  94. package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
  95. package/src/components/FieldModelRenderer.tsx +2 -1
  96. package/src/components/FlowModelRenderer.tsx +18 -6
  97. package/src/components/MobilePopup.tsx +4 -2
  98. package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
  99. package/src/components/__tests__/dnd.test.ts +44 -0
  100. package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
  101. package/src/components/__tests__/gridDragPlanner.test.ts +512 -3
  102. package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
  103. package/src/components/dnd/gridDragPlanner.ts +743 -19
  104. package/src/components/dnd/index.tsx +291 -27
  105. package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
  106. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +88 -10
  107. package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +487 -440
  108. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
  109. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +189 -3
  110. package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +778 -0
  111. package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +360 -0
  112. package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +361 -0
  113. package/src/components/subModel/AddSubModelButton.tsx +32 -2
  114. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +142 -32
  115. package/src/components/subModel/index.ts +1 -0
  116. package/src/components/subModel/utils.ts +1 -1
  117. package/src/data-source/__tests__/index.test.ts +34 -1
  118. package/src/data-source/index.ts +258 -2
  119. package/src/executor/FlowExecutor.ts +34 -9
  120. package/src/executor/__tests__/flowExecutor.test.ts +57 -0
  121. package/src/flowContext.ts +37 -3
  122. package/src/flowEngine.ts +445 -11
  123. package/src/flowI18n.ts +2 -1
  124. package/src/flowSettings.ts +40 -6
  125. package/src/lazy-helper.tsx +57 -0
  126. package/src/locale/en-US.json +1 -0
  127. package/src/locale/zh-CN.json +1 -0
  128. package/src/models/DisplayItemModel.tsx +1 -1
  129. package/src/models/EditableItemModel.tsx +1 -1
  130. package/src/models/FilterableItemModel.tsx +1 -1
  131. package/src/models/__tests__/dispatchEvent.when.test.ts +214 -0
  132. package/src/models/__tests__/flowModel.test.ts +19 -3
  133. package/src/models/flowModel.tsx +119 -33
  134. package/src/provider.tsx +41 -25
  135. package/src/reactive/__tests__/observer.test.tsx +82 -0
  136. package/src/reactive/observer.tsx +87 -25
  137. package/src/runjs-context/registry.ts +1 -1
  138. package/src/runjs-context/setup.ts +22 -12
  139. package/src/runjs-context/snippets/index.ts +12 -1
  140. package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
  141. package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
  142. package/src/scheduler/ModelOperationScheduler.ts +14 -3
  143. package/src/types.ts +60 -0
  144. package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
  145. package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -0
  146. package/src/utils/__tests__/runjsValue.test.ts +11 -0
  147. package/src/utils/__tests__/utils.test.ts +62 -0
  148. package/src/utils/createCollectionContextMeta.ts +6 -2
  149. package/src/utils/index.ts +2 -1
  150. package/src/utils/parsePathnameToViewParams.ts +2 -2
  151. package/src/utils/runjsTemplateCompat.ts +1 -1
  152. package/src/utils/runjsValue.ts +50 -11
  153. package/src/utils/schema-utils.ts +30 -1
  154. package/src/views/FlowView.tsx +11 -1
  155. package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
  156. package/src/views/__tests__/useDialog.closeDestroy.test.tsx +13 -12
  157. package/src/views/runViewBeforeClose.ts +19 -0
  158. package/src/views/useDialog.tsx +25 -3
  159. package/src/views/useDrawer.tsx +25 -3
  160. 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) {
@@ -40,7 +40,7 @@ __export(FieldModelRenderer_exports, {
40
40
  FieldModelRenderer: () => FieldModelRenderer
41
41
  });
42
42
  module.exports = __toCommonJS(FieldModelRenderer_exports);
43
- var import_flow_engine = require("@nocobase/flow-engine");
43
+ var import_FlowModelRenderer = require("./FlowModelRenderer");
44
44
  var import_lodash = __toESM(require("lodash"));
45
45
  var import_react = __toESM(require("react"));
46
46
  const flowModelRendererPropKeys = [
@@ -93,7 +93,7 @@ function FieldModelRenderer(props) {
93
93
  (0, import_react.useEffect)(() => {
94
94
  model && model.setProps(modelProps);
95
95
  }, [modelProps]);
96
- return /* @__PURE__ */ import_react.default.createElement(import_flow_engine.FlowModelRenderer, { model, ...rest });
96
+ return /* @__PURE__ */ import_react.default.createElement(import_FlowModelRenderer.FlowModelRenderer, { model, ...rest });
97
97
  }
98
98
  __name(FieldModelRenderer, "FieldModelRenderer");
99
99
  // Annotate the CommonJS export names for ESM import in node:
@@ -19,7 +19,9 @@ export interface FlowModelRendererProps {
19
19
  showBackground?: boolean;
20
20
  showBorder?: boolean;
21
21
  showDragHandle?: boolean;
22
- /** 自定义工具栏样式 */
22
+ /** 是否显示事件流入口,默认 true */
23
+ showDynamicFlowsEditor?: boolean;
24
+ /** 自定义工具栏样式,`top/left/right/bottom` 会作为 portal overlay 的 inset 使用 */
23
25
  style?: React.CSSProperties;
24
26
  /**
25
27
  * @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) {
@@ -134,6 +135,7 @@ const FlowModelRendererCore = (0, import_reactive.observer)(
134
135
  showBackground: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showBackground : void 0,
135
136
  showBorder: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showBorder : void 0,
136
137
  showDragHandle: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showDragHandle : void 0,
138
+ showDynamicFlowsEditor: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showDynamicFlowsEditor : void 0,
137
139
  settingsMenuLevel,
138
140
  extraToolbarItems,
139
141
  toolbarStyle: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.style : void 0,
@@ -166,6 +168,7 @@ const FlowModelRendererCore = (0, import_reactive.observer)(
166
168
  showBackground: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showBackground : void 0,
167
169
  showBorder: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showBorder : void 0,
168
170
  showDragHandle: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showDragHandle : void 0,
171
+ showDynamicFlowsEditor: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.showDynamicFlowsEditor : void 0,
169
172
  settingsMenuLevel,
170
173
  extraToolbarItems,
171
174
  toolbarStyle: import_lodash.default.isObject(showFlowSettings) ? showFlowSettings.style : void 0,
@@ -195,13 +198,15 @@ const FlowModelRenderer = (0, import_reactive.observer)(
195
198
  extraToolbarItems,
196
199
  useCache
197
200
  }) => {
201
+ var _a;
202
+ const resolvedUseCache = typeof useCache === "boolean" ? useCache : (_a = model == null ? void 0 : model.context) == null ? void 0 : _a.useCache;
198
203
  (0, import_react.useEffect)(() => {
199
- if (model == null ? void 0 : model.context) {
204
+ if ((model == null ? void 0 : model.context) && typeof resolvedUseCache !== "undefined") {
200
205
  model.context.defineProperty("useCache", {
201
- value: typeof useCache === "boolean" ? useCache : model.context.useCache
206
+ value: resolvedUseCache
202
207
  });
203
208
  }
204
- }, [model == null ? void 0 : model.context, useCache]);
209
+ }, [model == null ? void 0 : model.context, resolvedUseCache]);
205
210
  if (!model || typeof model.render !== "function") {
206
211
  console.warn("FlowModelRenderer: Invalid model or render method not found.", model);
207
212
  return null;
@@ -218,7 +223,8 @@ const FlowModelRenderer = (0, import_reactive.observer)(
218
223
  showErrorFallback,
219
224
  settingsMenuLevel,
220
225
  extraToolbarItems,
221
- fallback
226
+ fallback,
227
+ useCache: resolvedUseCache
222
228
  }
223
229
  );
224
230
  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)
@@ -32,6 +32,33 @@ export interface GridLayoutData {
32
32
  rows: Record<string, string[][]>;
33
33
  sizes: Record<string, number[]>;
34
34
  rowOrder?: string[];
35
+ layout?: GridLayoutV2;
36
+ }
37
+ export interface GridLayoutV2 {
38
+ version: 2;
39
+ rows: GridRowV2[];
40
+ }
41
+ export interface GridRowV2 {
42
+ id: string;
43
+ cells: GridCellV2[];
44
+ sizes: number[];
45
+ }
46
+ export interface GridCellV2 {
47
+ id: string;
48
+ items?: string[];
49
+ rows?: GridRowV2[];
50
+ }
51
+ export interface GridLayoutPathEntry {
52
+ rowId: string;
53
+ cellId?: string;
54
+ }
55
+ export type GridLayoutPath = GridLayoutPathEntry[];
56
+ export interface GridLayoutPosition {
57
+ path: GridLayoutPath;
58
+ rowIndex: number;
59
+ cellIndex: number;
60
+ itemIndex: number;
61
+ itemUid: string;
35
62
  }
36
63
  export interface ColumnSlot {
37
64
  type: 'column';
@@ -40,6 +67,7 @@ export interface ColumnSlot {
40
67
  insertIndex: number;
41
68
  position: 'before' | 'after';
42
69
  rect: Rect;
70
+ path?: GridLayoutPath;
43
71
  }
44
72
  export interface ColumnEdgeSlot {
45
73
  type: 'column-edge';
@@ -47,12 +75,14 @@ export interface ColumnEdgeSlot {
47
75
  columnIndex: number;
48
76
  direction: 'left' | 'right';
49
77
  rect: Rect;
78
+ path?: GridLayoutPath;
50
79
  }
51
80
  export interface RowGapSlot {
52
81
  type: 'row-gap';
53
82
  targetRowId: string;
54
83
  position: 'above' | 'below';
55
84
  rect: Rect;
85
+ path?: GridLayoutPath;
56
86
  }
57
87
  export interface EmptyRowSlot {
58
88
  type: 'empty-row';
@@ -63,8 +93,19 @@ export interface EmptyColumnSlot {
63
93
  rowId: string;
64
94
  columnIndex: number;
65
95
  rect: Rect;
96
+ path?: GridLayoutPath;
66
97
  }
67
- export type LayoutSlot = ColumnSlot | ColumnEdgeSlot | RowGapSlot | EmptyRowSlot | EmptyColumnSlot;
98
+ export interface ItemEdgeSlot {
99
+ type: 'item-edge';
100
+ rowId: string;
101
+ columnIndex: number;
102
+ itemIndex: number;
103
+ itemUid: string;
104
+ direction: 'left' | 'right';
105
+ rect: Rect;
106
+ path?: GridLayoutPath;
107
+ }
108
+ export type LayoutSlot = ColumnSlot | ColumnEdgeSlot | RowGapSlot | EmptyRowSlot | EmptyColumnSlot | ItemEdgeSlot;
68
109
  /**
69
110
  * 列内插入的配置
70
111
  */
@@ -122,10 +163,26 @@ export interface BuildLayoutSnapshotOptions {
122
163
  export declare const buildLayoutSnapshot: ({ container }: BuildLayoutSnapshotOptions) => LayoutSnapshot;
123
164
  export declare const getSlotKey: (slot: LayoutSlot) => string;
124
165
  export declare const resolveDropIntent: (point: Point, slots: LayoutSlot[]) => LayoutSlot | null;
166
+ export declare const projectLayoutToLegacyRows: (layout: GridLayoutV2) => GridLayoutData;
167
+ export declare const normalizeGridLayout: ({ layout, rows, sizes, rowOrder, itemUids, generateId, logger, gridUid, }: {
168
+ layout?: GridLayoutV2 | null;
169
+ rows?: Record<string, string[][]>;
170
+ sizes?: Record<string, number[]>;
171
+ rowOrder?: string[];
172
+ itemUids?: string[];
173
+ generateId?: () => string;
174
+ logger?: Pick<Console, 'warn'>;
175
+ gridUid?: string;
176
+ }) => GridLayoutV2;
177
+ export declare const replaceUidInGridLayout: (layout: GridLayoutV2, fromUid: string, toUid: string) => GridLayoutV2;
178
+ export declare const findModelUidLayoutPosition: (layout: GridLayoutV2, uidValue: string) => GridLayoutPosition | null;
179
+ export declare const isSameGridLayout: (a: GridLayoutV2, b: GridLayoutV2) => boolean;
125
180
  export interface SimulateLayoutOptions {
126
181
  slot: LayoutSlot;
127
182
  sourceUid: string;
128
183
  layout: GridLayoutData;
129
184
  generateRowId?: () => string;
185
+ generatedIds?: Map<string, string>;
186
+ generateId?: (key: string) => string;
130
187
  }
131
- export declare const simulateLayoutForSlot: ({ slot, sourceUid, layout, generateRowId, }: SimulateLayoutOptions) => GridLayoutData;
188
+ export declare const simulateLayoutForSlot: ({ slot, sourceUid, layout, generateRowId, generatedIds, generateId, }: SimulateLayoutOptions) => GridLayoutData;