@nocobase/flow-engine 2.1.0-alpha.40 → 2.1.0-alpha.46

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 (77) hide show
  1. package/lib/FlowContextProvider.d.ts +5 -1
  2. package/lib/FlowContextProvider.js +9 -2
  3. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +84 -32
  4. package/lib/components/subModel/LazyDropdown.js +208 -16
  5. package/lib/components/subModel/utils.d.ts +1 -0
  6. package/lib/components/subModel/utils.js +6 -2
  7. package/lib/data-source/index.d.ts +9 -0
  8. package/lib/data-source/index.js +12 -0
  9. package/lib/executor/FlowExecutor.js +0 -3
  10. package/lib/flowContext.d.ts +6 -1
  11. package/lib/flowContext.js +38 -6
  12. package/lib/flowEngine.d.ts +4 -3
  13. package/lib/flowEngine.js +72 -40
  14. package/lib/models/flowModel.js +48 -16
  15. package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +4 -3
  16. package/lib/runjs-context/contexts/JSBlockRunJSContext.js +4 -15
  17. package/lib/runjs-context/contexts/JSColumnRunJSContext.js +5 -2
  18. package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +5 -8
  19. package/lib/runjs-context/contexts/JSFieldRunJSContext.js +4 -3
  20. package/lib/runjs-context/contexts/JSItemRunJSContext.js +4 -3
  21. package/lib/runjs-context/contexts/base.js +464 -29
  22. package/lib/runjs-context/contexts/elementDoc.d.ts +11 -0
  23. package/lib/runjs-context/contexts/elementDoc.js +152 -0
  24. package/lib/utils/loadedPageCache.d.ts +24 -0
  25. package/lib/utils/loadedPageCache.js +139 -0
  26. package/lib/utils/parsePathnameToViewParams.d.ts +5 -1
  27. package/lib/utils/parsePathnameToViewParams.js +28 -4
  28. package/lib/views/ViewNavigation.d.ts +12 -2
  29. package/lib/views/ViewNavigation.js +22 -7
  30. package/lib/views/createViewMeta.js +114 -50
  31. package/lib/views/inheritLayoutContext.d.ts +10 -0
  32. package/lib/views/inheritLayoutContext.js +50 -0
  33. package/lib/views/useDialog.js +2 -0
  34. package/lib/views/useDrawer.js +2 -0
  35. package/lib/views/usePage.js +2 -0
  36. package/package.json +4 -4
  37. package/src/FlowContextProvider.tsx +9 -1
  38. package/src/__tests__/createViewMeta.popup.test.ts +115 -1
  39. package/src/__tests__/flowContext.test.ts +23 -0
  40. package/src/__tests__/flowEngine.moveModel.test.ts +81 -1
  41. package/src/__tests__/flowEngine.removeModel.test.ts +47 -3
  42. package/src/__tests__/runjsContext.test.ts +18 -0
  43. package/src/__tests__/runjsContextImplementations.test.ts +9 -2
  44. package/src/__tests__/runjsLocales.test.ts +6 -5
  45. package/src/__tests__/viewScopedFlowEngine.test.ts +133 -0
  46. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +90 -38
  47. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +155 -5
  48. package/src/components/subModel/LazyDropdown.tsx +237 -16
  49. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +254 -1
  50. package/src/components/subModel/utils.ts +6 -1
  51. package/src/data-source/index.ts +18 -0
  52. package/src/executor/FlowExecutor.ts +0 -3
  53. package/src/executor/__tests__/flowExecutor.test.ts +26 -0
  54. package/src/flowContext.ts +43 -6
  55. package/src/flowEngine.ts +75 -38
  56. package/src/models/__tests__/flowEngine.resolveUse.test.ts +0 -15
  57. package/src/models/__tests__/flowModel.test.ts +46 -62
  58. package/src/models/flowModel.tsx +65 -32
  59. package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +4 -3
  60. package/src/runjs-context/contexts/JSBlockRunJSContext.ts +4 -15
  61. package/src/runjs-context/contexts/JSColumnRunJSContext.ts +4 -2
  62. package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +5 -9
  63. package/src/runjs-context/contexts/JSFieldRunJSContext.ts +4 -3
  64. package/src/runjs-context/contexts/JSItemRunJSContext.ts +4 -3
  65. package/src/runjs-context/contexts/base.ts +467 -31
  66. package/src/runjs-context/contexts/elementDoc.ts +130 -0
  67. package/src/utils/__tests__/parsePathnameToViewParams.test.ts +21 -0
  68. package/src/utils/loadedPageCache.ts +147 -0
  69. package/src/utils/parsePathnameToViewParams.ts +45 -5
  70. package/src/views/ViewNavigation.ts +40 -7
  71. package/src/views/__tests__/ViewNavigation.test.ts +52 -0
  72. package/src/views/__tests__/inheritLayoutContext.test.ts +53 -0
  73. package/src/views/createViewMeta.ts +106 -34
  74. package/src/views/inheritLayoutContext.ts +26 -0
  75. package/src/views/useDialog.tsx +2 -0
  76. package/src/views/useDrawer.tsx +2 -0
  77. package/src/views/usePage.tsx +2 -0
@@ -8,14 +8,15 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  export class FormJSFieldItemRunJSContext extends FlowRunJSContext {}
13
14
 
14
15
  FormJSFieldItemRunJSContext.define({
15
16
  label: 'FormJSFieldItem RunJS context',
16
17
  properties: {
17
- element: `ElementProxy instance providing a safe DOM container for form field rendering.
18
- Supports innerHTML, append, and other DOM manipulation methods.`,
18
+ element: createElementPropertyDoc(`ElementProxy instance providing a safe DOM container for form field rendering.
19
+ Supports innerHTML, append, and other DOM manipulation methods.`),
19
20
  value: `Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).`,
20
21
  record: `Current record data object (read-only).
21
22
  Contains all field values of the parent record.`,
@@ -38,7 +39,7 @@ FormJSFieldItemRunJSContext.define(
38
39
  {
39
40
  label: '表单 JS 字段项 RunJS 上下文',
40
41
  properties: {
41
- element: 'ElementProxy,表单字段容器',
42
+ element: createZhCNElementPropertyDoc('ElementProxy,表单字段容器'),
42
43
  value: '字段值(展示模式为只读;受控场景用 setProps 修改)',
43
44
  record: '当前记录(只读)',
44
45
  formValues: {
@@ -8,21 +8,16 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  export class JSBlockRunJSContext extends FlowRunJSContext {}
13
14
 
14
15
  JSBlockRunJSContext.define({
15
16
  label: 'RunJS context',
16
17
  properties: {
17
- element: {
18
- description: `ElementProxy instance providing a safe DOM container.
18
+ element: createElementPropertyDoc(`ElementProxy instance providing a safe DOM container.
19
19
  Supports innerHTML, append, and other DOM manipulation methods.
20
- Use this to render content in the JS block.`,
21
- detail: 'ElementProxy',
22
- properties: {
23
- innerHTML: 'Set or read the HTML content of the container element.',
24
- },
25
- },
20
+ Use this to render content in the JS block.`),
26
21
  record: `Current record data object (read-only).
27
22
  Available when the JS block is within a data block or detail view context.`,
28
23
  value: 'Current value of the field or component, if available in the current context.',
@@ -44,13 +39,7 @@ JSBlockRunJSContext.define(
44
39
  {
45
40
  label: 'RunJS 上下文',
46
41
  properties: {
47
- element: {
48
- description: 'ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等',
49
- detail: 'ElementProxy',
50
- properties: {
51
- innerHTML: '读取或设置容器的 HTML 内容',
52
- },
53
- },
42
+ element: createZhCNElementPropertyDoc('ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等'),
54
43
  record: '当前记录(只读,用于数据区块/详情等场景)',
55
44
  value: '当前值(若存在)',
56
45
  React: 'React 库',
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  /**
13
14
  * RunJS context for JSColumnModel (table custom column).
@@ -18,8 +19,9 @@ export class JSColumnRunJSContext extends FlowRunJSContext {}
18
19
  JSColumnRunJSContext.define({
19
20
  label: 'JSColumn RunJS context',
20
21
  properties: {
21
- element:
22
+ element: createElementPropertyDoc(
22
23
  'ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs.',
24
+ ),
23
25
  record: 'Current row record object (read-only).',
24
26
  recordIndex: 'Index of the current row in the page (0-based).',
25
27
  collection: 'Collection definition metadata (read-only).',
@@ -40,7 +42,7 @@ JSColumnRunJSContext.define(
40
42
  {
41
43
  label: 'JS 列 RunJS 上下文',
42
44
  properties: {
43
- element: 'ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等',
45
+ element: createZhCNElementPropertyDoc('ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等'),
44
46
  record: '当前行记录对象(只读)',
45
47
  recordIndex: '当前行索引(从 0 开始)',
46
48
  collection: '集合定义元数据(只读)',
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  /**
13
14
  * RunJS context for JSEditableFieldModel (form editable custom field).
@@ -19,11 +20,9 @@ export class JSEditableFieldRunJSContext extends FlowRunJSContext {}
19
20
  JSEditableFieldRunJSContext.define({
20
21
  label: 'JSEditableField RunJS context',
21
22
  properties: {
22
- element: {
23
- description:
24
- 'ElementProxy instance providing a safe DOM container for field rendering. In editable mode this container is typically a <span> element.',
25
- detail: 'ElementProxy',
26
- },
23
+ element: createElementPropertyDoc(
24
+ 'ElementProxy instance providing a safe DOM container for field rendering. In editable mode this container is typically a <span> element.',
25
+ ),
27
26
  value: {
28
27
  description:
29
28
  'Current field value (read-only snapshot). In editable scenarios, prefer ctx.getValue()/ctx.setValue(v) for two-way binding.',
@@ -69,10 +68,7 @@ JSEditableFieldRunJSContext.define(
69
68
  {
70
69
  label: 'JS 可编辑字段 RunJS 上下文',
71
70
  properties: {
72
- element: {
73
- description: 'ElementProxy,字段渲染的安全容器(通常为 <span> 容器)。',
74
- detail: 'ElementProxy',
75
- },
71
+ element: createZhCNElementPropertyDoc('ElementProxy,字段渲染的安全容器(通常为 <span> 容器)。'),
76
72
  value: {
77
73
  description: '字段当前值(只读快照)。可编辑场景建议使用 ctx.getValue()/ctx.setValue(v) 做双向绑定。',
78
74
  detail: 'any',
@@ -8,14 +8,15 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  export class JSFieldRunJSContext extends FlowRunJSContext {}
13
14
 
14
15
  JSFieldRunJSContext.define({
15
16
  label: 'JSField RunJS context',
16
17
  properties: {
17
- element: `ElementProxy instance providing a safe DOM container for field rendering.
18
- Supports innerHTML, append, and other DOM manipulation methods.`,
18
+ element: createElementPropertyDoc(`ElementProxy instance providing a safe DOM container for field rendering.
19
+ Supports innerHTML, append, and other DOM manipulation methods.`),
19
20
  value: `Current value of the field (read-only).
20
21
  Contains the data value stored in this field.`,
21
22
  record: `Current record data object (read-only).
@@ -34,7 +35,7 @@ JSFieldRunJSContext.define(
34
35
  {
35
36
  label: 'JS 字段 RunJS 上下文',
36
37
  properties: {
37
- element: 'ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作',
38
+ element: createZhCNElementPropertyDoc('ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作'),
38
39
  value: '字段当前值(只读)',
39
40
  record: '当前记录对象(只读,包含父记录全部字段值)',
40
41
  collection: '集合定义元数据(只读,描述字段所属集合的 Schema)',
@@ -8,14 +8,15 @@
8
8
  */
9
9
 
10
10
  import { FlowRunJSContext } from '../../flowContext';
11
+ import { createElementPropertyDoc, createZhCNElementPropertyDoc } from './elementDoc';
11
12
 
12
13
  export class JSItemRunJSContext extends FlowRunJSContext {}
13
14
 
14
15
  JSItemRunJSContext.define({
15
16
  label: 'JSItem RunJS context',
16
17
  properties: {
17
- element: `ElementProxy instance providing a safe DOM container for form item rendering.
18
- Supports innerHTML, append, and other DOM manipulation methods.`,
18
+ element: createElementPropertyDoc(`ElementProxy instance providing a safe DOM container for form item rendering.
19
+ Supports innerHTML, append, and other DOM manipulation methods.`),
19
20
  resource: `Current resource instance (read-only).
20
21
  Provides access to the data resource associated with the current form context.`,
21
22
  record: `Current record data object (read-only).
@@ -36,7 +37,7 @@ JSItemRunJSContext.define(
36
37
  {
37
38
  label: 'JS 表单项 RunJS 上下文',
38
39
  properties: {
39
- element: 'ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作',
40
+ element: createZhCNElementPropertyDoc('ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作'),
40
41
  resource: '当前资源(只读)',
41
42
  record: '当前记录(只读)',
42
43
  formValues: {