@nocobase/client-v2 2.1.8 → 2.1.9

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 (33) hide show
  1. package/es/components/form/JsonTextArea.d.ts +2 -1
  2. package/es/components/form/VariableJsonTextArea.d.ts +19 -0
  3. package/es/components/form/index.d.ts +1 -0
  4. package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
  5. package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +5 -0
  6. package/es/flow/models/blocks/form/FormBlockModel.d.ts +4 -0
  7. package/es/flow/models/blocks/form/value-runtime/rules.d.ts +21 -0
  8. package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +21 -0
  9. package/es/flow/models/blocks/form/value-runtime/types.d.ts +2 -2
  10. package/es/index.mjs +102 -76
  11. package/lib/index.js +77 -51
  12. package/package.json +7 -7
  13. package/src/components/form/JsonTextArea.tsx +21 -11
  14. package/src/components/form/VariableJsonTextArea.tsx +175 -0
  15. package/src/components/form/__tests__/JsonTextArea.test.tsx +43 -0
  16. package/src/components/form/__tests__/VariableJsonTextArea.test.tsx +86 -0
  17. package/src/components/form/index.tsx +1 -0
  18. package/src/flow/actions/__tests__/fieldLinkageRules.scopeDepth.test.ts +150 -1
  19. package/src/flow/actions/__tests__/linkageAssignField.legacy.test.ts +135 -0
  20. package/src/flow/actions/linkageRules.tsx +75 -16
  21. package/src/flow/components/FieldAssignRulesEditor.tsx +62 -12
  22. package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +81 -4
  23. package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +30 -1
  24. package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +77 -0
  25. package/src/flow/models/blocks/form/EditFormModel.tsx +1 -0
  26. package/src/flow/models/blocks/form/FormBlockModel.tsx +7 -0
  27. package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +17 -0
  28. package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +880 -102
  29. package/src/flow/models/blocks/form/value-runtime/rules.ts +443 -11
  30. package/src/flow/models/blocks/form/value-runtime/runtime.ts +257 -13
  31. package/src/flow/models/blocks/form/value-runtime/types.ts +2 -2
  32. package/src/flow/models/fields/InputFieldModel.tsx +14 -22
  33. package/src/flow/models/fields/__tests__/InputFieldModel.test.tsx +17 -0
@@ -7,6 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import type { TextAreaProps } from 'antd/es/input';
10
+ import type { TextAreaRef } from 'antd/es/input/TextArea';
10
11
  import React from 'react';
11
12
  export interface JsonTextAreaProps extends Omit<TextAreaProps, 'value' | 'onChange'> {
12
13
  value?: unknown;
@@ -15,4 +16,4 @@ export interface JsonTextAreaProps extends Omit<TextAreaProps, 'value' | 'onChan
15
16
  json5?: boolean;
16
17
  showError?: boolean;
17
18
  }
18
- export declare const JsonTextArea: React.MemoExoticComponent<(props: JsonTextAreaProps) => React.JSX.Element>;
19
+ export declare const JsonTextArea: React.MemoExoticComponent<React.ForwardRefExoticComponent<JsonTextAreaProps & React.RefAttributes<TextAreaRef>>>;
@@ -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 MetaTreeNode } from '@nocobase/flow-engine';
10
+ import React from 'react';
11
+ import { type JsonTextAreaProps } from './JsonTextArea';
12
+ export interface VariableJsonTextAreaProps extends JsonTextAreaProps {
13
+ namespaces?: string[];
14
+ extraNodes?: MetaTreeNode[];
15
+ metaTree?: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
16
+ formatPathToValue?: (meta: MetaTreeNode) => string | undefined;
17
+ }
18
+ export declare const VariableJsonTextArea: React.MemoExoticComponent<(props: VariableJsonTextAreaProps) => React.JSX.Element>;
19
+ export declare const VariableJSON: React.MemoExoticComponent<(props: VariableJsonTextAreaProps) => React.JSX.Element>;
@@ -18,3 +18,4 @@ export * from './RemoteSelect';
18
18
  export * from './ScanInput';
19
19
  export * from './TypedVariableInput';
20
20
  export * from './VariableInput';
21
+ export * from './VariableJsonTextArea';
@@ -10,7 +10,7 @@ import type { FilterGroupType } from '@nocobase/utils/client';
10
10
  import React from 'react';
11
11
  import { FieldAssignValueInput } from './FieldAssignValueInput';
12
12
  import { type FieldAssignCascaderOption } from './fieldAssignOptions';
13
- export type AssignMode = 'default' | 'assign';
13
+ export type AssignMode = 'default' | 'assign' | 'override';
14
14
  type CollectionFieldLike = {
15
15
  name?: unknown;
16
16
  title?: unknown;
@@ -53,6 +53,8 @@ export interface FieldAssignRulesEditorProps {
53
53
  defaultMode?: AssignMode;
54
54
  /** 固定 mode:用于“仅默认值/仅赋值”的场景 */
55
55
  fixedMode?: AssignMode;
56
+ /** 可选 mode 列表;fixedMode 优先级更高 */
57
+ allowedModes?: AssignMode[];
56
58
  /** 是否显示 condition */
57
59
  showCondition?: boolean;
58
60
  /** 是否显示 enable 开关 */
@@ -24,6 +24,7 @@ export declare class FilterFormBlockModel extends FilterBlockModel<{
24
24
  private initialDefaultsPromise?;
25
25
  private initialRefreshHandledTargetIds;
26
26
  private lastDefaultValueByFieldName;
27
+ private userEditedFieldNames;
27
28
  private defaultValuesRefreshSeq;
28
29
  get form(): any;
29
30
  get title(): string;
@@ -39,6 +40,10 @@ export declare class FilterFormBlockModel extends FilterBlockModel<{
39
40
  markInitialTargetRefreshHandled(targetId: string): void;
40
41
  private ensureFilterItemsBeforeRender;
41
42
  private canApplyFormDefaultValue;
43
+ private canApplyFormOverrideValue;
44
+ private normalizeFieldValueMode;
45
+ private markFilterFormUserEditedFields;
46
+ private resetFilterFormUserEditedFields;
42
47
  private matchDefaultValueCondition;
43
48
  applyFormDefaultValues(options?: {
44
49
  force?: boolean;
@@ -51,6 +51,10 @@ export declare class FormBlockModel<T extends DefaultCollectionBlockModelStructu
51
51
  * @internal
52
52
  */
53
53
  resetUserModifiedFields(): void;
54
+ /**
55
+ * @internal
56
+ */
57
+ resetRuntimeUserEditedState(): void;
54
58
  onDispatchEventStart(eventName: string, options?: any, inputArgs?: Record<string, any>): Promise<void>;
55
59
  getStepParams(flowKey: string, stepKey: string): any | undefined;
56
60
  getStepParams(flowKey: string): Record<string, any> | undefined;
@@ -32,6 +32,7 @@ export type RuleEngineOptions = {
32
32
  getFormValueAtPath: (namePath: NamePath) => any;
33
33
  setFormValues: (callerCtx: any, patch: Patch, options?: SetOptions) => Promise<void>;
34
34
  findExplicitHit: (pathKey: string) => string | null;
35
+ findUserEditedHit: (pathKey: string) => string | null;
35
36
  lastDefaultValueByPathKey: Map<string, any>;
36
37
  lastWriteMetaByPathKey: Map<string, FormValueWriteMeta>;
37
38
  observableBindings: Map<string, ObservableBinding>;
@@ -122,6 +123,18 @@ export declare class RuleEngine {
122
123
  private resolveRunJSValue;
123
124
  private resolveTemplateValue;
124
125
  private commitRuleDeps;
126
+ private isScalarValueTarget;
127
+ private shouldSkipEmptyArrayAggregateForScalarTarget;
128
+ private normalizeUnresolvedToManyAggregateForScalarTarget;
129
+ private isArrayValueCollectionField;
130
+ private stringifyAggregateItem;
131
+ private normalizeAggregateArrayForScalarTarget;
132
+ private shouldSkipMultiValueAggregateForScalarTarget;
133
+ private getClearedAggregateValueForScalarTarget;
134
+ private isUserClearedToManyAggregate;
135
+ private isTextScalarTarget;
136
+ private getLatestWriteMetaForPath;
137
+ private getToManyAggregateSourceInfo;
125
138
  /**
126
139
  * Check if default rule value can be applied.
127
140
  * Default value can overwrite when:
@@ -130,6 +143,14 @@ export declare class RuleEngine {
130
143
  */
131
144
  private checkDefaultRuleCanApply;
132
145
  private createRuleEvaluationContext;
146
+ private getLocalFormValuesSnapshot;
147
+ private resolveLocalFormValuesPath;
148
+ private recordLocalFormValuesDep;
149
+ private extractSingleLocalFormValuesPath;
150
+ private stringifyTemplateReplacement;
151
+ private createLocalTemplateTokenStore;
152
+ private restoreLocalTemplateTokens;
153
+ private resolveLocalFormValuesTemplates;
133
154
  private buildItemChainValue;
134
155
  private getFieldIndexSignature;
135
156
  private updateRuleDeps;
@@ -17,6 +17,7 @@ export declare class FormValueRuntime {
17
17
  private readonly getForm;
18
18
  private readonly valuesMirror;
19
19
  private readonly explicitSet;
20
+ private readonly userEditedSet;
20
21
  private readonly lastDefaultValueByPathKey;
21
22
  private readonly lastWriteMetaByPathKey;
22
23
  private readonly observableBindings;
@@ -29,6 +30,8 @@ export declare class FormValueRuntime {
29
30
  private lastObservedSource;
30
31
  private lastObservedToken;
31
32
  private readonly formValuesProxy;
33
+ private readonly mountedFieldModelsByPathKey;
34
+ private readonly mountedFieldModelPathKeys;
32
35
  private mountedListener?;
33
36
  private unmountedListener?;
34
37
  private readonly formPatcher;
@@ -42,11 +45,14 @@ export declare class FormValueRuntime {
42
45
  *
43
46
  * - mode=default → source=default(遵循 explicit/空值覆盖语义)
44
47
  * - mode=assign → source=system(不受 explicit 影响,依赖变化时持续生效)
48
+ * - mode=override → source=override(首次覆盖已有值,用户修改后停止)
45
49
  */
46
50
  syncAssignRules(items: FormAssignRuleItem[]): void;
47
51
  get formValues(): any;
48
52
  getFormValuesSnapshot(): any;
53
+ private toMirrorSnapshot;
49
54
  canApplyDefaultValuePatch(namePath: NamePath, resolved: any): boolean;
55
+ canApplyOverrideValuePatch(namePath: NamePath): boolean;
50
56
  recordDefaultValuePatch(namePath: NamePath, value?: any): void;
51
57
  private getFormValueAtPath;
52
58
  mount(options?: {
@@ -54,6 +60,7 @@ export declare class FormValueRuntime {
54
60
  }): void;
55
61
  dispose(): void;
56
62
  resetAfterFormReset(): void;
63
+ resetUserEditedState(): void;
57
64
  isSuppressed(): boolean;
58
65
  handleFormFieldsChange(changedFields: Array<{
59
66
  name?: NamePath | string | number;
@@ -83,7 +90,19 @@ export declare class FormValueRuntime {
83
90
  private tryResolveNamePath;
84
91
  private bumpChangeTick;
85
92
  private emitFormValuesChange;
93
+ private syncMountedFieldModelValue;
94
+ private syncMountedFieldModelValueForModel;
95
+ private rebuildMountedFieldModelIndex;
96
+ private indexMountedFieldModelTree;
97
+ private unindexMountedFieldModelTree;
98
+ private visitModelAndForks;
99
+ private indexMountedFieldModel;
100
+ private unindexMountedFieldModel;
101
+ private isMountedModelInThisForm;
102
+ private getMountedModelNamePaths;
103
+ private normalizeNamePathValue;
86
104
  private markExplicit;
105
+ private markUserEdited;
87
106
  private normalizeObservedNamePath;
88
107
  private clearExplicitForDefaultPatch;
89
108
  private shouldPreserveDescendantDefaultsOnExplicit;
@@ -91,5 +110,7 @@ export declare class FormValueRuntime {
91
110
  private shouldKeepDefaultPathValueEnabled;
92
111
  private isExplicit;
93
112
  private findExplicitHit;
113
+ private findUserEditedHit;
114
+ private isDescendantPathKey;
94
115
  }
95
116
  export {};
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export type NamePath = Array<string | number>;
10
- export type ValueSource = 'default' | 'linkage' | 'user' | 'system';
10
+ export type ValueSource = 'default' | 'linkage' | 'user' | 'system' | 'override';
11
11
  export type Patch = Record<string, any> | Array<{
12
12
  path: string | NamePath;
13
13
  value: any;
@@ -48,7 +48,7 @@ export interface FormValuesChangePayload {
48
48
  allValues?: any;
49
49
  allValuesSnapshot?: any;
50
50
  }
51
- export type AssignMode = 'default' | 'assign';
51
+ export type AssignMode = 'default' | 'assign' | 'override';
52
52
  export type FormAssignRuleItem = {
53
53
  key?: string;
54
54
  enable?: boolean;