@nocobase/client 2.0.0-beta.9 → 2.0.1

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 (137) hide show
  1. package/.dumirc.ts +8 -0
  2. package/es/ai/ai-manager.d.ts +15 -0
  3. package/es/ai/index.d.ts +11 -0
  4. package/es/ai/tools-manager/hooks/context.d.ts +17 -0
  5. package/es/ai/tools-manager/hooks/index.d.ts +11 -0
  6. package/es/ai/tools-manager/hooks/provider.d.ts +16 -0
  7. package/es/ai/tools-manager/index.d.ts +21 -0
  8. package/es/ai/tools-manager/types.d.ts +80 -0
  9. package/es/ai/utils.d.ts +10 -0
  10. package/es/api-client/APIClient.d.ts +1 -0
  11. package/es/application/Application.d.ts +2 -0
  12. package/es/application/Plugin.d.ts +1 -0
  13. package/es/application/globalOperators.d.ts +11 -0
  14. package/es/block-provider/TableUidContext.d.ts +10 -0
  15. package/es/data-source/collection/utils.d.ts +2 -4
  16. package/es/flow/actions/blockHeight.d.ts +9 -0
  17. package/es/flow/actions/filterFormDefaultValues.d.ts +9 -0
  18. package/es/flow/actions/formAssignRules.d.ts +9 -0
  19. package/es/flow/actions/index.d.ts +4 -0
  20. package/es/flow/actions/numberFormat.d.ts +9 -0
  21. package/es/flow/components/BlockItemCard.d.ts +1 -0
  22. package/es/flow/components/ConditionBuilder.d.ts +2 -0
  23. package/es/flow/components/DefaultValue.d.ts +1 -0
  24. package/es/flow/components/FieldAssignEditor.d.ts +32 -0
  25. package/es/flow/components/FieldAssignExactDatePicker.d.ts +23 -0
  26. package/es/flow/components/FieldAssignRulesEditor.d.ts +70 -0
  27. package/es/flow/components/FieldAssignValueInput.d.ts +42 -1
  28. package/es/flow/components/RunJSValueEditor.d.ts +19 -0
  29. package/es/flow/components/code-editor/core/EditorCore.d.ts +3 -1
  30. package/es/flow/components/code-editor/formatDocInfo.d.ts +17 -0
  31. package/es/flow/components/code-editor/hooks/useCodeRunner.d.ts +3 -1
  32. package/es/flow/components/code-editor/index.d.ts +1 -0
  33. package/es/flow/components/code-editor/linter.d.ts +10 -2
  34. package/es/flow/components/code-editor/runjsCompletionSource.d.ts +20 -0
  35. package/es/flow/components/code-editor/runjsDiagnostics.d.ts +43 -0
  36. package/es/flow/components/fieldAssignOptions.d.ts +23 -0
  37. package/es/flow/components/filter/LinkageFilterItem.d.ts +4 -1
  38. package/es/flow/components/useAssociationTitleFieldSync.d.ts +13 -0
  39. package/es/flow/index.d.ts +1 -0
  40. package/es/flow/internal/utils/modelUtils.d.ts +23 -0
  41. package/es/flow/internal/utils/saveStepParamsWithSubModels.d.ts +11 -0
  42. package/es/flow/internal/utils/titleFieldQuickSync.d.ts +35 -0
  43. package/es/flow/models/base/BlockModel.d.ts +3 -1
  44. package/es/flow/models/base/CollectionBlockModel.d.ts +29 -56
  45. package/es/flow/models/base/PageModel/PageModel.d.ts +16 -0
  46. package/es/flow/models/blocks/details/DetailsGridModel.d.ts +1 -0
  47. package/es/flow/models/blocks/details/utils.d.ts +16 -0
  48. package/es/flow/models/blocks/filter-form/FieldOperatorSelect.d.ts +10 -0
  49. package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +6 -0
  50. package/es/flow/models/blocks/filter-form/FilterFormItemModel.d.ts +5 -37
  51. package/es/flow/models/blocks/filter-form/customFieldOperators.d.ts +34 -0
  52. package/es/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.d.ts +16 -0
  53. package/es/flow/models/blocks/filter-form/fields/FilterFormCustomRecordSelectFieldModel.d.ts +20 -0
  54. package/es/flow/models/blocks/filter-form/fields/FilterFormRecordSelectFieldModel.d.ts +12 -0
  55. package/es/flow/models/blocks/filter-form/fields/index.d.ts +2 -0
  56. package/es/flow/models/blocks/filter-form/index.d.ts +4 -0
  57. package/es/flow/models/blocks/filter-form/legacyDefaultValueMigration.d.ts +13 -0
  58. package/es/flow/models/blocks/filter-form/valueNormalization.d.ts +17 -0
  59. package/es/flow/models/blocks/filter-manager/flow-actions/defaultOperator.d.ts +1 -3
  60. package/es/flow/models/blocks/form/CreateFormModel.d.ts +2 -1
  61. package/es/flow/models/blocks/form/EditFormModel.d.ts +2 -1
  62. package/es/flow/models/blocks/form/FormAssociationFieldGroupModel.d.ts +12 -0
  63. package/es/flow/models/blocks/form/FormAssociationItemModel.d.ts +39 -0
  64. package/es/flow/models/blocks/form/FormBlockModel.d.ts +34 -2
  65. package/es/flow/models/blocks/form/FormGridModel.d.ts +1 -0
  66. package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +4 -1
  67. package/es/flow/models/blocks/form/assignRulesUpdateAssociationValues.d.ts +18 -0
  68. package/es/flow/models/blocks/form/dynamicNamePath.d.ts +19 -0
  69. package/es/flow/models/blocks/form/index.d.ts +2 -0
  70. package/es/flow/models/blocks/form/legacyDefaultValueMigration.d.ts +13 -0
  71. package/es/flow/models/blocks/form/submitHandler.d.ts +1 -1
  72. package/es/flow/models/blocks/form/submitValues.d.ts +19 -0
  73. package/es/flow/models/blocks/form/value-runtime/conditions.d.ts +9 -0
  74. package/es/flow/models/blocks/form/value-runtime/deps.d.ts +23 -0
  75. package/es/flow/models/blocks/form/value-runtime/form-patch.d.ts +19 -0
  76. package/es/flow/models/blocks/form/value-runtime/index.d.ts +11 -0
  77. package/es/flow/models/blocks/form/value-runtime/path.d.ts +25 -0
  78. package/es/flow/models/blocks/form/value-runtime/rules.d.ts +129 -0
  79. package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +75 -0
  80. package/es/flow/models/blocks/form/value-runtime/types.d.ts +62 -0
  81. package/es/flow/models/blocks/form/value-runtime/utils.d.ts +12 -0
  82. package/es/flow/models/blocks/shared/legacyDefaultValueMigrationBase.d.ts +20 -0
  83. package/es/flow/models/blocks/table/TableSelectModel.d.ts +0 -1
  84. package/es/flow/models/blocks/table/dragSort/dragSortComponents.d.ts +14 -0
  85. package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +13 -0
  86. package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +39 -0
  87. package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +37 -0
  88. package/es/flow/models/blocks/table/dragSort/index.d.ts +12 -0
  89. package/es/flow/models/blocks/table/utils.d.ts +8 -8
  90. package/es/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.d.ts +16 -0
  91. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionGroupModel.d.ts +11 -0
  92. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableActionsColumnModel.d.ts +19 -0
  93. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.d.ts +30 -0
  94. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableEditActionModel.d.ts +28 -0
  95. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableFormSubmitActionModel.d.ts +16 -0
  96. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableRemoveActionModel.d.ts +14 -0
  97. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/blocks/PopupSubTableFormModel.d.ts +36 -0
  98. package/es/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/index.d.ts +17 -0
  99. package/es/flow/models/fields/AssociationFieldModel/RecordPickerFieldModel.d.ts +8 -1
  100. package/es/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.d.ts +15 -0
  101. package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.d.ts +4 -1
  102. package/es/flow/models/fields/AssociationFieldModel/index.d.ts +1 -0
  103. package/es/flow/models/fields/AssociationFieldModel/itemChain.d.ts +94 -0
  104. package/es/flow/models/fields/AssociationFieldModel/recordSelectShared.d.ts +15 -5
  105. package/es/flow/models/fields/RichTextFieldModel/registerFontSize.d.ts +9 -0
  106. package/es/flow/models/fields/RichTextFieldModel/registerImageResize.d.ts +9 -0
  107. package/es/flow/models/fields/RichTextFieldModel/registerSmartBreak.d.ts +12 -0
  108. package/es/flow/models/fields/index.d.ts +0 -1
  109. package/es/flow/utils/useJsonTemplateResolver.d.ts +9 -0
  110. package/es/index.d.ts +1 -0
  111. package/es/index.mjs +35733 -24106
  112. package/es/route-switch/antd/admin-layout/index.d.ts +1 -1
  113. package/es/schema-component/antd/form-item/hooks/useLazyLoadDisplayAssociationFieldsOfForm.d.ts +26 -0
  114. package/es/variables/index.d.ts +1 -1
  115. package/lib/index.js +444 -297
  116. package/lib/locale/de-DE.json +2 -0
  117. package/lib/locale/en-US.json +51 -0
  118. package/lib/locale/es-ES.json +2 -0
  119. package/lib/locale/fr-FR.json +2 -0
  120. package/lib/locale/hu-HU.json +2 -0
  121. package/lib/locale/id-ID.json +2 -0
  122. package/lib/locale/it-IT.json +2 -0
  123. package/lib/locale/ja-JP.json +2 -0
  124. package/lib/locale/ko-KR.json +2 -0
  125. package/lib/locale/nl-NL.json +2 -0
  126. package/lib/locale/pt-BR.json +2 -0
  127. package/lib/locale/ru-RU.json +2 -0
  128. package/lib/locale/tr-TR.json +2 -0
  129. package/lib/locale/uk-UA.json +2 -0
  130. package/lib/locale/vi-VN.json +2 -0
  131. package/lib/locale/zh-CN.json +77 -7
  132. package/lib/locale/zh-TW.json +12 -0
  133. package/package.json +8 -7
  134. package/es/flow/models/fields/UploadFieldModel.d.ts +0 -22
  135. package/es/index-C3fHjsMw.mjs +0 -279
  136. package/lib/index-C3fHjsMw-Phbdz1-R.js +0 -2249
  137. package/lib/style.css +0 -1
@@ -6,6 +6,4 @@
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 { FlowContext } from '@nocobase/flow-engine';
10
- import { FilterFormFieldModel } from '../../filter-form/fields';
11
- export declare const defaultOperator: import("@nocobase/flow-engine").ActionDefinition<FilterFormFieldModel, FlowContext>;
9
+ export declare const defaultOperator: any;
@@ -15,6 +15,7 @@ export declare class CreateFormModel extends FormBlockModel {
15
15
  private actionExtraToolbarItems;
16
16
  createResource(ctx: any, params: any): SingleRecordResource<unknown>;
17
17
  getAclActionName(): string;
18
- submit(params?: any): Promise<void>;
18
+ submitHandler(ctx: any, params: any, cb?: (values?: any, filterByTk?: any) => void): Promise<void>;
19
+ submit(params?: any, cb?: (values?: any, filterByTk?: any) => void): Promise<void>;
19
20
  renderComponent(): React.JSX.Element;
20
21
  }
@@ -18,6 +18,7 @@ export declare class EditFormModel extends FormBlockModel {
18
18
  getCurrentRecord(): any;
19
19
  getAclActionName(): string;
20
20
  handlePageChange: (page: number) => Promise<void>;
21
- submit(params?: any): Promise<void>;
21
+ submitHandler(ctx: any, params: any, cb?: (values?: any, filterByTk?: any) => void): Promise<void>;
22
+ submit(params?: any, cb?: (values?: any, filterByTk?: any) => void): Promise<void>;
22
23
  renderComponent(): React.JSX.Element;
23
24
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { AssociationFieldGroupModel } from '../../base';
10
+ export declare class FormAssociationFieldGroupModel extends AssociationFieldGroupModel {
11
+ static itemModelName: string;
12
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { DisplayItemModel, FlowModelContext } from '@nocobase/flow-engine';
10
+ import React from 'react';
11
+ export declare class FormAssociationItemModel extends DisplayItemModel {
12
+ static defineChildren(ctx: FlowModelContext): {
13
+ key: any;
14
+ label: string;
15
+ refreshTargets: string[];
16
+ toggleable: (subModel: any) => boolean;
17
+ useModel: string;
18
+ createModelOptions: () => {
19
+ use: string;
20
+ stepParams: {
21
+ fieldSettings: {
22
+ init: {
23
+ dataSourceKey: any;
24
+ collectionName: any;
25
+ fieldPath: any;
26
+ };
27
+ };
28
+ };
29
+ subModels: {
30
+ field: {
31
+ use: string;
32
+ props: any;
33
+ };
34
+ };
35
+ };
36
+ }[];
37
+ onInit(options: any): void;
38
+ renderItem(): React.JSX.Element;
39
+ }
@@ -13,6 +13,7 @@ import { BlockGridModel } from '../../base/BlockGridModel';
13
13
  import { CollectionBlockModel } from '../../base/CollectionBlockModel';
14
14
  import { FormActionModel } from './FormActionModel';
15
15
  import { FormGridModel } from './FormGridModel';
16
+ import { FormValueRuntime } from './value-runtime';
16
17
  type DefaultCollectionBlockModelStructure = {
17
18
  parent?: BlockGridModel;
18
19
  subModels?: {
@@ -22,16 +23,33 @@ type DefaultCollectionBlockModelStructure = {
22
23
  };
23
24
  type CustomFormBlockModelClassesEnum = {};
24
25
  export declare class FormBlockModel<T extends DefaultCollectionBlockModelStructure = DefaultCollectionBlockModelStructure> extends CollectionBlockModel<T> {
26
+ formValueRuntime?: FormValueRuntime;
27
+ private userModifiedTopLevelFields;
25
28
  get form(): FormInstance<any>;
26
29
  _defaultCustomModelClasses: {
27
30
  FormActionGroupModel: string;
28
31
  FormItemModel: string;
29
- FormCustomItemModel: string;
32
+ FormAssociationFieldGroupModel: string;
30
33
  };
31
34
  customModelClasses: CustomFormBlockModelClassesEnum;
32
35
  renderConfigureActions(): React.JSX.Element;
33
36
  setFieldsValue(values: any): void;
34
- setFieldValue(fieldName: string, value: any): void;
37
+ setFieldValue(fieldName: any, value: any): void;
38
+ /**
39
+ * @internal
40
+ *
41
+ * 仅用于编辑表单刷新保护:只记录「用户交互」触发的改动(来自 antd Form.onValuesChange)。
42
+ * 程序化 setFieldValue/setFieldsValue 不会触发 onValuesChange(见 linkageRules 的手动 emit),因此不会污染该集合。
43
+ */
44
+ markUserModifiedFields(changedValues: any): void;
45
+ /**
46
+ * @internal
47
+ */
48
+ getUserModifiedFields(): Set<string>;
49
+ /**
50
+ * @internal
51
+ */
52
+ resetUserModifiedFields(): void;
35
53
  onDispatchEventStart(eventName: string, options?: any, inputArgs?: Record<string, any>): Promise<void>;
36
54
  getStepParams(flowKey: string, stepKey: string): any | undefined;
37
55
  getStepParams(flowKey: string): Record<string, any> | undefined;
@@ -44,6 +62,7 @@ export declare class FormBlockModel<T extends DefaultCollectionBlockModelStructu
44
62
  useHooksBeforeRender(): void;
45
63
  onInit(options: any): void;
46
64
  protected onMount(): void;
65
+ onUnmount(): void;
47
66
  getCurrentRecord(): {};
48
67
  renderComponent(): void;
49
68
  }
@@ -53,7 +72,20 @@ export declare function FormComponent({ model, children, layoutProps, initialVal
53
72
  layoutProps?: any;
54
73
  initialValues?: any;
55
74
  onFinish?: (values: any) => void;
75
+ [key: string]: any;
56
76
  }): React.JSX.Element;
77
+ type FormBlockContentProps = {
78
+ model: FormBlockModel;
79
+ gridModel: FormGridModel;
80
+ layoutProps?: any;
81
+ onFinish?: (values: any) => void;
82
+ grid: React.ReactNode;
83
+ actions?: React.ReactNode;
84
+ footer?: React.ReactNode;
85
+ heightMode?: string;
86
+ height?: number;
87
+ };
88
+ export declare const FormBlockContent: ({ model, gridModel, layoutProps, onFinish, grid, actions, footer, heightMode, height, }: FormBlockContentProps) => React.JSX.Element;
57
89
  /**
58
90
  * 兼容旧版本
59
91
  * @deprecated use FormBlockModel instead
@@ -30,4 +30,5 @@ export declare class FormGridModel<T extends DefaultFormGridStructure = DefaultF
30
30
  };
31
31
  dragOverlayConfig: DragOverlayConfig;
32
32
  renderAddSubModelButton(): React.JSX.Element;
33
+ render(): React.JSX.Element;
33
34
  }
@@ -16,6 +16,7 @@ export declare class QuickEditFormModel extends FlowModel {
16
16
  viewContainer: any;
17
17
  __onSubmitSuccess: any;
18
18
  _fieldProps: any;
19
+ _onOk: any;
19
20
  get form(): any;
20
21
  useHooksBeforeRender(): void;
21
22
  static open(options: {
@@ -24,10 +25,12 @@ export declare class QuickEditFormModel extends FlowModel {
24
25
  dataSourceKey: string;
25
26
  collectionName: string;
26
27
  fieldPath: string;
27
- filterByTk: string;
28
28
  record: any;
29
+ filterByTk?: string;
29
30
  onSuccess?: (values: any) => void;
30
31
  fieldProps?: any;
32
+ sourceFieldModelUid?: string;
33
+ onOk?: (values: any) => void;
31
34
  }): Promise<void>;
32
35
  onInit(options: any): void;
33
36
  addAppends(fieldPath: string, refresh?: boolean): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /**
10
+ * 从 assignRules 的 targetPath 推导需要注入到请求中的 updateAssociationValues。
11
+ *
12
+ * 规则:仅当 targetPath 穿过至少一段关联字段(association)时返回该关联路径:
13
+ * - user.name -> user
14
+ * - user.profile.name -> user.profile
15
+ */
16
+ export declare function collectUpdateAssociationValuesFromAssignRules(items: Array<{
17
+ targetPath?: string;
18
+ } | any>, rootCollection: any): string[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export type DynamicNamePart = string | number;
10
+ /**
11
+ * Build a dynamic NamePath based on current subform list row index.
12
+ *
13
+ * fieldIndex is an array like: ["products:0", "products:2"] (nested lists allowed, including same-name lists).
14
+ *
15
+ * For example:
16
+ * - nameParts: ["products", "products"] + fieldIndex: ["products:0"] => [0, "products"]
17
+ * - nameParts: ["products", "products", "id"] + fieldIndex: ["products:1", "products:0"] => [0, "id"]
18
+ */
19
+ export declare function buildDynamicNamePath(nameParts: DynamicNamePart[], fieldIndex?: string[]): DynamicNamePart[];
@@ -17,3 +17,5 @@ export * from './FormItemModel';
17
17
  export * from './FormJSFieldItemModel';
18
18
  export * from './JSFormActionModel';
19
19
  export * from './QuickEditFormModel';
20
+ export * from './FormAssociationFieldGroupModel';
21
+ export * from './FormAssociationItemModel';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { mergeAssignRulesWithLegacyDefaults } from '../shared/legacyDefaultValueMigrationBase';
10
+ import type { FieldAssignRuleItem } from '../../../components/FieldAssignRulesEditor';
11
+ export declare function collectLegacyDefaultValueRulesFromFormModel(formModel: any): FieldAssignRuleItem[];
12
+ export declare function clearLegacyDefaultValuesFromFormModel(formModel: any): any[];
13
+ export { mergeAssignRulesWithLegacyDefaults };
@@ -6,4 +6,4 @@
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
- export declare function submitHandler(ctx: any, params: any): Promise<void>;
9
+ export declare function submitHandler(ctx: any, params: any, cb?: (values?: any, filterByTk?: any) => void): Promise<void>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { FormBlockModel } from './FormBlockModel';
10
+ /**
11
+ * 提交前过滤:移除当前表单 block 中被「联动规则隐藏」的字段值(`model.hidden === true`)。
12
+ *
13
+ * 说明:
14
+ * - 仅对 “隐藏 / Hidden” 生效(对应 `model.hidden=true`)。
15
+ * - “隐藏并保留值 / Hidden (reserved value)” 在实现上是 `props.hidden=true` 但 `model.hidden=false`,
16
+ * 因此仍会提交(保持现有语义)。
17
+ * - 不会清空 antd Form 的内部 store,只影响本次提交 payload。
18
+ */
19
+ export declare function omitHiddenModelValuesFromSubmit<T = any>(values: T, blockModel: FormBlockModel): T;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare function evaluateCondition(ctx: any, condition: any): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { NamePath } from './types';
10
+ export type DepCollector = {
11
+ deps: Set<string>;
12
+ wildcard: boolean;
13
+ };
14
+ export declare function recordDep(namePath: NamePath, collector: DepCollector | undefined): void;
15
+ export declare function createFormValuesProxy(options: {
16
+ valuesMirror: any;
17
+ basePath: NamePath;
18
+ collector?: DepCollector;
19
+ getFormValuesSnapshot: () => any;
20
+ getFormValueAtPath: (namePath: NamePath) => any;
21
+ }): any;
22
+ export declare function collectStaticDepsFromTemplateValue(value: any, collector: DepCollector): void;
23
+ export declare function collectStaticDepsFromRunJSValue(value: any, collector: DepCollector): void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { FormInstance } from 'antd';
10
+ import type { Patch, SetOptions } from './types';
11
+ export type FormPatcher = {
12
+ patch: (form: FormInstance) => void;
13
+ restore: () => void;
14
+ };
15
+ export declare function createFormPatcher(options: {
16
+ isSuppressed: () => boolean;
17
+ getCallerContext: () => any;
18
+ setFormValues: (callerCtx: any, patch: Patch, options?: SetOptions) => Promise<void>;
19
+ }): FormPatcher;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export * from './types';
10
+ export { FormValueRuntime } from './runtime';
11
+ export { isEmptyValue } from './utils';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { NamePath } from './types';
10
+ export type PathSegment = string | number | {
11
+ placeholder: string;
12
+ };
13
+ export declare function parsePathString(path: string): PathSegment[];
14
+ /**
15
+ * Resolve a dynamic NamePath using the current row index context (`fieldIndex`).
16
+ *
17
+ * - Supports placeholders: `users[placeholder].name`
18
+ * - Auto-fills to-many index when omitted: `users.name` -> `users[ctxIndex].name`
19
+ *
20
+ * Returns `null` when a placeholder can't be resolved in current context.
21
+ */
22
+ export declare function resolveDynamicNamePath(path: string | NamePath, fieldIndex?: unknown): NamePath | null;
23
+ export declare function namePathToPathKey(namePath: Array<string | number>): string;
24
+ export declare function pathKeyToNamePath(pathKey: string): NamePath;
25
+ export declare function buildAncestorKeys(namePath: NamePath): string[];
@@ -0,0 +1,129 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { FlowModel } from '@nocobase/flow-engine';
10
+ import { DepCollector } from './deps';
11
+ import type { FormAssignRuleItem, FormValueWriteMeta, NamePath, Patch, SetOptions, ValueSource } from './types';
12
+ type ObservableBinding = {
13
+ source: ValueSource;
14
+ dispose: () => void;
15
+ };
16
+ export type RuleEngineOptions = {
17
+ getBlockModelUid: () => string;
18
+ getActionName: () => string | undefined;
19
+ getBlockContext: () => any;
20
+ getEngine: () => any;
21
+ getEngineModel: (uid: string) => FlowModel | null;
22
+ isDisposed: () => boolean;
23
+ valuesMirror: any;
24
+ changeTick: {
25
+ value: number;
26
+ };
27
+ getWriteSeq: () => number;
28
+ txWriteCounts: Map<string, Map<string, number>>;
29
+ createTrackingFormValues: (collector: DepCollector) => any;
30
+ tryResolveNamePath: (callerCtx: any, path: string | NamePath) => NamePath | null;
31
+ getFormValueAtPath: (namePath: NamePath) => any;
32
+ setFormValues: (callerCtx: any, patch: Patch, options?: SetOptions) => Promise<void>;
33
+ findExplicitHit: (pathKey: string) => string | null;
34
+ lastDefaultValueByPathKey: Map<string, any>;
35
+ lastWriteMetaByPathKey: Map<string, FormValueWriteMeta>;
36
+ observableBindings: Map<string, ObservableBinding>;
37
+ };
38
+ export declare class RuleEngine {
39
+ private readonly options;
40
+ private readonly rules;
41
+ private readonly lastRuleWriteByTargetKey;
42
+ private readonly assignTemplatesByTargetPath;
43
+ /** 当前表单中“已配置到 UI 的字段(FormItemModel)”的 targetPath 集合,用于避免对 row grid 重复注册规则 */
44
+ private readonly formItemTargetPaths;
45
+ /** targetPath -> updateAssociation(SubForm/SubTable 等) */
46
+ private readonly updateAssociationByTargetPath;
47
+ private readonly pendingRuleIds;
48
+ private readonly ruleDebounceUntilById;
49
+ private readonly ruleDebounceTimersById;
50
+ private readonly defaultRuleIdsByMasterUid;
51
+ private readonly defaultRuleMasterDisposers;
52
+ private runningRules;
53
+ private rulesEnabled;
54
+ private currentRuleTxId;
55
+ constructor(options: RuleEngineOptions);
56
+ private getAssignRuleBlockId;
57
+ private removeAssignRuleBlockInstance;
58
+ private removeRowGridAssignRuleInstances;
59
+ private hasAnyNonBlockAssignRuleInstance;
60
+ private ensureBlockAssignRuleInstancesForTargetPath;
61
+ private getCollectionFromContext;
62
+ private getRootCollection;
63
+ private shouldCreateBlockLevelAssignRule;
64
+ /**
65
+ * 对关联字段嵌套属性(如 user.name / user.profile.name):
66
+ * - 依赖应包含关联对象本身(user / user.profile),否则当关联对象从 null -> {id} 时,user.name 仍为 undefined,无法触发 rule re-run。
67
+ * - 写入前需校验关联对象已存在,避免隐式创建关联对象。
68
+ */
69
+ private collectAssociationPrefixPaths;
70
+ private shouldSkipToManyAssociationWriteWithoutIndex;
71
+ private shouldSkipAssociationNestedWrite;
72
+ private getAssociationTargetKeyFields;
73
+ private resolveAssociationFieldByPrefixPath;
74
+ private isAssociationTargetKeyWrite;
75
+ private collectUpdateAssociationInitPatches;
76
+ dispose(): void;
77
+ enable(): void;
78
+ syncAssignRules(items: FormAssignRuleItem[]): void;
79
+ onModelMounted(model: FlowModel): void;
80
+ onModelUnmounted(model: FlowModel): void;
81
+ private isModelInThisForm;
82
+ private cacheUpdateAssociationForModel;
83
+ private getUpdateAssociationForTargetPath;
84
+ private getDefaultRuleId;
85
+ private getModelTargetNamePath;
86
+ private tryRegisterDefaultRuleInstance;
87
+ private getModelTargetPath;
88
+ private getAssignRuleInstanceId;
89
+ private getDeepestFieldIndexKey;
90
+ private getDeepestToManyAssociationKey;
91
+ private isRowGridModel;
92
+ private tryRegisterAssignRuleInstancesForModel;
93
+ private tryUnregisterAssignRuleInstancesForModel;
94
+ private tryUnregisterDefaultRuleInstance;
95
+ private bindMasterInitialValue;
96
+ private removeRule;
97
+ private scheduleRule;
98
+ private flushRules;
99
+ private runRule;
100
+ private isTzAwareTargetInterface;
101
+ private normalizeDateOnlyToStartOfDayIso;
102
+ private normalizeResolvedValueForTarget;
103
+ private isPrimitiveAssociationTargetValue;
104
+ private extractAssociationIdentity;
105
+ private isAssociationTargetSemanticallyEqual;
106
+ private resolveCollectionFieldByNamePath;
107
+ private normalizeResolvedValueForAssociationTarget;
108
+ private prepareRuleContext;
109
+ private shouldApplyDefaultRuleInCurrentState;
110
+ private shouldRunRule;
111
+ private createRuleCollectorAndContext;
112
+ private evaluateRuleCondition;
113
+ private resolveRuleValue;
114
+ private resolveRunJSValue;
115
+ private resolveTemplateValue;
116
+ private commitRuleDeps;
117
+ /**
118
+ * Check if default rule value can be applied.
119
+ * Default value can overwrite when:
120
+ * 1. Current value is empty
121
+ * 2. Current value equals the last default value (user hasn't modified it)
122
+ */
123
+ private checkDefaultRuleCanApply;
124
+ private createRuleEvaluationContext;
125
+ private buildItemChainValue;
126
+ private getFieldIndexSignature;
127
+ private updateRuleDeps;
128
+ }
129
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { FormInstance } from 'antd';
10
+ import type { FlowModel } from '@nocobase/flow-engine';
11
+ import type { FormAssignRuleItem, NamePath, Patch, SetOptions } from './types';
12
+ type FormBlockModel = FlowModel & {
13
+ getAclActionName?: () => string;
14
+ };
15
+ export declare class FormValueRuntime {
16
+ private readonly model;
17
+ private readonly getForm;
18
+ private readonly valuesMirror;
19
+ private readonly explicitSet;
20
+ private readonly lastDefaultValueByPathKey;
21
+ private readonly lastWriteMetaByPathKey;
22
+ private readonly observableBindings;
23
+ private readonly changeTick;
24
+ private readonly txWriteCounts;
25
+ private writeSeq;
26
+ private disposed;
27
+ private suppressFormCallbackDepth;
28
+ private lastObservedChangedPaths;
29
+ private lastObservedSource;
30
+ private lastObservedToken;
31
+ private readonly formValuesProxy;
32
+ private mountedListener?;
33
+ private unmountedListener?;
34
+ private readonly formPatcher;
35
+ private readonly ruleEngine;
36
+ constructor(options: {
37
+ model: FormBlockModel;
38
+ getForm: () => FormInstance;
39
+ });
40
+ /**
41
+ * 同步“表单赋值”配置到运行时规则引擎。
42
+ *
43
+ * - mode=default → source=default(遵循 explicit/空值覆盖语义)
44
+ * - mode=assign → source=system(不受 explicit 影响,依赖变化时持续生效)
45
+ */
46
+ syncAssignRules(items: FormAssignRuleItem[]): void;
47
+ get formValues(): any;
48
+ getFormValuesSnapshot(): any;
49
+ private getFormValueAtPath;
50
+ mount(options?: {
51
+ sync?: boolean;
52
+ }): void;
53
+ dispose(): void;
54
+ isSuppressed(): boolean;
55
+ handleFormFieldsChange(changedFields: Array<{
56
+ name?: NamePath | string | number;
57
+ touched?: boolean;
58
+ }>): void;
59
+ handleFormValuesChange(changedValues: any, allValues: any): void;
60
+ private deriveExplicitPaths;
61
+ private collectExplicitDiffPaths;
62
+ private pushExplicitPath;
63
+ private isPlainObjectValue;
64
+ private isObjectCleared;
65
+ setFormValues(callerCtx: any, patch: Patch, options?: SetOptions): Promise<void>;
66
+ private applyBoundValue;
67
+ private resolveNamePath;
68
+ private tryResolveNamePath;
69
+ private bumpChangeTick;
70
+ private emitFormValuesChange;
71
+ private markExplicit;
72
+ private isExplicit;
73
+ private findExplicitHit;
74
+ }
75
+ export {};
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export type NamePath = Array<string | number>;
10
+ export type ValueSource = 'default' | 'linkage' | 'user' | 'system';
11
+ export type Patch = Record<string, any> | Array<{
12
+ path: string | NamePath;
13
+ value: any;
14
+ condition?: any;
15
+ }>;
16
+ export interface SetOptions {
17
+ source?: ValueSource;
18
+ triggerEvent?: boolean;
19
+ markExplicit?: boolean;
20
+ txId?: string;
21
+ /**
22
+ * linkage 规则定义所在层级,数值越大表示层级越内层。
23
+ * 仅在 source='linkage' 且 linkageTxId 有效时参与同事务冲突裁决。
24
+ */
25
+ linkageScopeDepth?: number;
26
+ /**
27
+ * linkage 链路事务 id(通常来自 formValuesChange payload 的 txId)。
28
+ * 仅在 source='linkage' 时使用。
29
+ */
30
+ linkageTxId?: string;
31
+ }
32
+ export interface FormValueWriteMeta {
33
+ source: ValueSource;
34
+ writeSeq: number;
35
+ linkageScopeDepth?: number;
36
+ linkageTxId?: string;
37
+ }
38
+ export interface FormValuesChangePayload {
39
+ source: ValueSource;
40
+ txId: string;
41
+ /**
42
+ * linkage 链路根事务 id。
43
+ * 用于跨事件继续沿用同一 linkage 冲突裁决边界。
44
+ */
45
+ linkageTxId?: string;
46
+ changedPaths: NamePath[];
47
+ changedValues?: any;
48
+ allValues?: any;
49
+ allValuesSnapshot?: any;
50
+ }
51
+ export type AssignMode = 'default' | 'assign';
52
+ export type FormAssignRuleItem = {
53
+ key?: string;
54
+ enable?: boolean;
55
+ /** 赋值目标路径,例如 `title` / `users.nickname` / `user.name` */
56
+ targetPath?: string;
57
+ /** 规则级 title field 覆盖(仅当前规则生效,不影响 collection 全局) */
58
+ valueTitleField?: string;
59
+ mode?: AssignMode;
60
+ condition?: any;
61
+ value?: any;
62
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /** Maximum writes per path per transaction to prevent rule oscillation loops */
10
+ export declare const MAX_WRITES_PER_PATH_PER_TX = 20;
11
+ export declare function isEmptyValue(v: any): boolean;
12
+ export declare function createTxId(): string;