@nocobase/client-v2 2.1.0-beta.41 → 2.1.0-beta.43
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.
- package/es/components/form/TypedVariableInput.d.ts +75 -0
- package/es/components/form/index.d.ts +1 -0
- package/es/flow/models/blocks/assign-form/assignFieldValuesFlow.d.ts +8 -0
- package/es/index.mjs +70 -70
- package/lib/index.js +91 -91
- package/package.json +7 -7
- package/src/components/README.md +48 -0
- package/src/components/README.zh-CN.md +48 -0
- package/src/components/form/TypedVariableInput.tsx +441 -0
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +152 -0
- package/src/components/form/index.tsx +1 -0
- package/src/flow/actions/__tests__/linkageRules.hiddenSync.restore.test.ts +100 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +23 -1
- package/src/flow/actions/linkageRules.tsx +5 -4
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -3
- package/src/flow/components/code-editor/__tests__/runjsCompletions.test.ts +272 -27
- package/src/flow/components/code-editor/runjsCompletions.ts +490 -9
- package/src/flow/models/actions/__tests__/AssignFormRefill.test.ts +90 -0
- package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +1 -3
- package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +14 -4
- package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.editor.test.tsx +216 -0
- package/src/flow/models/blocks/assign-form/assignFieldValuesFlow.tsx +142 -40
|
@@ -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 MetaTreeNode } from '@nocobase/flow-engine';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { type VariableDelimiters } from './VariableInput';
|
|
12
|
+
/**
|
|
13
|
+
* Constant types this input can edit. Subset of v1 `Variable.Input`
|
|
14
|
+
* `useTypedConstant` — drops `'object'` (no v2 JSON editor yet) and `'null'`
|
|
15
|
+
* (handled by the dedicated `nullable` prop).
|
|
16
|
+
*/
|
|
17
|
+
export type TypedConstantType = 'string' | 'number' | 'boolean' | 'date';
|
|
18
|
+
/**
|
|
19
|
+
* One allowed constant type. Either a bare type name (`'number'`) or a
|
|
20
|
+
* `[type, editorProps]` pair (`['number', { min: 1, max: 65535 }]`) where
|
|
21
|
+
* `editorProps` is forwarded to the antd editor for that type — same
|
|
22
|
+
* shape as v1 `useTypedConstant`.
|
|
23
|
+
*/
|
|
24
|
+
export type TypedConstantSpec = TypedConstantType | [TypedConstantType, Record<string, unknown>];
|
|
25
|
+
export interface TypedVariableInputProps {
|
|
26
|
+
/**
|
|
27
|
+
* Stored value. A `{{ ... }}` string is treated as a variable reference;
|
|
28
|
+
* anything else is a constant of the inferred type.
|
|
29
|
+
*/
|
|
30
|
+
value?: unknown;
|
|
31
|
+
onChange?: (next: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Allowed constant types. The `Constant` switcher entry always exposes a
|
|
34
|
+
* typed submenu (matching v1 `Variable.Input`) so users can see what type
|
|
35
|
+
* the constant is, even when only one type is permitted. Default: all four
|
|
36
|
+
* supported types.
|
|
37
|
+
*/
|
|
38
|
+
types?: TypedConstantSpec[];
|
|
39
|
+
/**
|
|
40
|
+
* Restrict the variable picker to specific top-level meta-tree namespaces
|
|
41
|
+
* (e.g. `['$env']`). When omitted, every registered top-level property is
|
|
42
|
+
* exposed — matching `VariableInput`'s default behaviour.
|
|
43
|
+
*/
|
|
44
|
+
namespaces?: string[];
|
|
45
|
+
/** Additional leaves appended to the picker after the namespace-filtered nodes. */
|
|
46
|
+
extraNodes?: MetaTreeNode[];
|
|
47
|
+
/**
|
|
48
|
+
* When true (default), the switcher exposes a `Null` option that resets the
|
|
49
|
+
* value to `null`. When false, the value is constrained to one of the
|
|
50
|
+
* allowed types or a variable reference.
|
|
51
|
+
*/
|
|
52
|
+
nullable?: boolean;
|
|
53
|
+
/** Variable-token delimiters. Default `['{{', '}}']` — see `VariableInput`. */
|
|
54
|
+
delimiters?: VariableDelimiters;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
style?: React.CSSProperties;
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Constant-or-variable input. Port of v1 `Variable.Input` typed-constant
|
|
62
|
+
* Cascader pattern (the `[Null | Constant<type> | Variable<…namespaces>]`
|
|
63
|
+
* switcher). Use this when a field can accept either a typed literal
|
|
64
|
+
* (number, boolean, date, string) or a variable reference like
|
|
65
|
+
* `{{ $env.SMTP_PORT }}` — see `plugin-notification-email`'s port / secure
|
|
66
|
+
* fields for the canonical example.
|
|
67
|
+
*
|
|
68
|
+
* Pure literal fields should keep using the antd primitive
|
|
69
|
+
* (`InputNumber`, `Select`, `DatePicker`). Pure variable fields should keep
|
|
70
|
+
* using `EnvVariableInput` / `VariableInput`. This component carries the
|
|
71
|
+
* Cascader switcher overhead, so reach for it only when the field
|
|
72
|
+
* genuinely accepts both shapes.
|
|
73
|
+
*/
|
|
74
|
+
export declare function TypedVariableInput(props: TypedVariableInputProps): React.JSX.Element;
|
|
75
|
+
export default TypedVariableInput;
|
|
@@ -23,6 +23,9 @@ type AssignFieldValuesModel = {
|
|
|
23
23
|
uid: string;
|
|
24
24
|
assignFormUid?: string;
|
|
25
25
|
context?: AssignFieldValuesContext;
|
|
26
|
+
subModels?: {
|
|
27
|
+
assignForm?: AssignFormModel;
|
|
28
|
+
};
|
|
26
29
|
getStepParams?: (flowKey: string, stepKey: string) => {
|
|
27
30
|
assignedValues?: AssignedValues;
|
|
28
31
|
} | undefined;
|
|
@@ -77,7 +80,12 @@ export declare function createAssignFieldValuesStep(options: AssignFieldValuesSt
|
|
|
77
80
|
model: AssignFieldValuesModel;
|
|
78
81
|
engine: {
|
|
79
82
|
getModel?: (uid: string, fromRoot?: boolean) => AssignFormModel | undefined;
|
|
83
|
+
findModelByParentId?: (parentId: string, subKey: string) => AssignFormModel | undefined | null;
|
|
80
84
|
};
|
|
85
|
+
}, params?: {
|
|
86
|
+
assignedValues?: AssignedValues;
|
|
87
|
+
}, previousParams?: {
|
|
88
|
+
assignedValues?: AssignedValues;
|
|
81
89
|
}): Promise<void>;
|
|
82
90
|
handler(): void;
|
|
83
91
|
};
|