@nocobase/client-v2 2.1.0-alpha.45 → 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/es/authRedirect.d.ts +12 -0
  2. package/es/components/form/TypedVariableInput.d.ts +75 -0
  3. package/es/components/form/index.d.ts +1 -0
  4. package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
  5. package/es/flow/components/ConditionBuilder.d.ts +1 -0
  6. package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
  7. package/es/flow/components/FieldAssignValueInput.d.ts +1 -0
  8. package/es/flow/components/fieldAssignOptions.d.ts +10 -0
  9. package/es/flow/components/filter/LinkageFilterItem.d.ts +1 -0
  10. package/es/flow/components/filter/VariableFilterItem.d.ts +1 -0
  11. package/es/flow/components/filter/metaTreeAssociationDepth.d.ts +13 -0
  12. package/es/flow/models/base/AssociationFieldGroupModel.d.ts +2 -33
  13. package/es/flow/models/blocks/assign-form/assignFieldValuesFlow.d.ts +8 -0
  14. package/es/flow/models/blocks/table/TableColumnModel.d.ts +2 -0
  15. package/es/index.mjs +103 -103
  16. package/lib/index.js +105 -105
  17. package/package.json +7 -7
  18. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +5 -0
  19. package/src/authRedirect.ts +43 -0
  20. package/src/components/README.md +48 -0
  21. package/src/components/README.zh-CN.md +48 -0
  22. package/src/components/form/TypedVariableInput.tsx +441 -0
  23. package/src/components/form/__tests__/TypedVariableInput.test.tsx +152 -0
  24. package/src/components/form/index.tsx +1 -0
  25. package/src/flow/__tests__/FlowRoute.test.tsx +8 -1
  26. package/src/flow/actions/__tests__/linkageRules.hiddenSync.restore.test.ts +100 -0
  27. package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +23 -1
  28. package/src/flow/actions/dataScope.tsx +8 -1
  29. package/src/flow/actions/linkageRules.tsx +8 -5
  30. package/src/flow/actions/linkageRulesRefresh.tsx +2 -3
  31. package/src/flow/actions/setTargetDataScope.tsx +1 -1
  32. package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +15 -1
  33. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +75 -1
  34. package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +11 -0
  35. package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +2 -4
  36. package/src/flow/common/Markdown/Edit.tsx +32 -4
  37. package/src/flow/components/ConditionBuilder.tsx +12 -2
  38. package/src/flow/components/FieldAssignRulesEditor.tsx +37 -46
  39. package/src/flow/components/FieldAssignValueInput.tsx +8 -4
  40. package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +112 -1
  41. package/src/flow/components/__tests__/fieldAssignOptions.test.ts +71 -1
  42. package/src/flow/components/code-editor/__tests__/runjsCompletions.test.ts +272 -27
  43. package/src/flow/components/code-editor/runjsCompletions.ts +490 -9
  44. package/src/flow/components/fieldAssignOptions.ts +23 -6
  45. package/src/flow/components/filter/LinkageFilterItem.tsx +22 -9
  46. package/src/flow/components/filter/VariableFilterItem.tsx +27 -9
  47. package/src/flow/components/filter/__tests__/fieldsToOptions.test.ts +48 -0
  48. package/src/flow/components/filter/__tests__/metaTreeAssociationDepth.test.ts +60 -0
  49. package/src/flow/components/filter/fieldsToOptions.ts +9 -4
  50. package/src/flow/components/filter/metaTreeAssociationDepth.ts +69 -0
  51. package/src/flow/models/actions/FilterActionModel.tsx +15 -3
  52. package/src/flow/models/actions/__tests__/AssignFormRefill.test.ts +90 -0
  53. package/src/flow/models/base/AssociationFieldGroupModel.tsx +20 -3
  54. package/src/flow/models/base/GridModel.tsx +1 -1
  55. package/src/flow/models/base/PageModel/ChildPageModel.tsx +5 -1
  56. package/src/flow/models/base/PageModel/__tests__/ChildPageModel.test.ts +12 -0
  57. package/src/flow/models/base/__tests__/AssociationFieldGroupModel.test.ts +86 -0
  58. package/src/flow/models/base/__tests__/GridModel.render.test.tsx +53 -0
  59. package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +12 -3
  60. package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +14 -4
  61. package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.editor.test.tsx +216 -0
  62. package/src/flow/models/blocks/assign-form/assignFieldValuesFlow.tsx +142 -40
  63. package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +1 -1
  64. package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +6 -1
  65. package/src/flow/models/blocks/filter-manager/flow-actions/connectFields.tsx +48 -6
  66. package/src/flow/models/blocks/form/FormAssociationItemModel.tsx +9 -0
  67. package/src/flow/models/blocks/form/FormItemModel.tsx +9 -0
  68. package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +17 -0
  69. package/src/flow/models/blocks/form/__tests__/FormItemModel.defineChildren.test.ts +27 -2
  70. package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +29 -0
  71. package/src/flow/models/blocks/form/value-runtime/runtime.ts +5 -1
  72. package/src/flow/models/blocks/table/TableColumnModel.tsx +15 -5
  73. package/src/flow/models/blocks/table/TableCustomColumnModel.tsx +2 -2
  74. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +18 -0
  75. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +6 -7
  76. package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +5 -3
  77. package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +70 -0
@@ -17,6 +17,18 @@ type LocationLike = {
17
17
  search?: string;
18
18
  hash?: string;
19
19
  };
20
+ /**
21
+ * The runtime URL segment under which the modern (v2) client is served.
22
+ * Injected by the server as `window.__nocobase_modern_client_prefix__`. Falls
23
+ * back to the trailing segment of `window.__nocobase_public_path__`, then to
24
+ * the default `v`. Returns a bare segment (no slashes).
25
+ */
26
+ export declare function getModernClientPrefix(): string;
27
+ /**
28
+ * Strip the trailing modern-client prefix segment from a public path,
29
+ * recovering the app root public path (e.g. `/nocobase/v/` -> `/nocobase/`).
30
+ */
31
+ export declare function stripModernClientPrefix(publicPath?: string): string;
20
32
  export declare function getV2EffectiveBasePath(app: AppLike): string;
21
33
  declare function getDefaultV2AdminRedirectPath(app: AppLike): string;
22
34
  /**
@@ -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;
@@ -15,4 +15,5 @@ export * from './FileSizeInput';
15
15
  export * from './JsonTextArea';
16
16
  export * from './PasswordInput';
17
17
  export * from './RemoteSelect';
18
+ export * from './TypedVariableInput';
18
19
  export * from './VariableInput';
@@ -45,6 +45,7 @@ export declare class AdminLayoutMenuItemModel extends FlowModel<AdminLayoutMenuI
45
45
  * @returns {boolean} 是否需要走 FlowModel 默认保存链路
46
46
  */
47
47
  hasPersistableInstanceFlows(): boolean;
48
+ serialize(): ReturnType<FlowModel['serialize']>;
48
49
  setHidden(value: boolean): void;
49
50
  protected renderHiddenInConfig(): React.ReactNode | undefined;
50
51
  createMenuRoute(route: NocoBaseDesktopRoute, options?: {
@@ -13,5 +13,6 @@ export declare const ConditionBuilder: React.MemoExoticComponent<import("@formil
13
13
  value: FilterGroupType;
14
14
  onChange: (value: FilterGroupType) => void;
15
15
  extraMetaTree?: MetaTreeNode[];
16
+ maxAssociationFieldDepth?: number;
16
17
  }>>;
17
18
  export declare const commonConditionHandler: (ctx: any, params: any) => void;
@@ -9,7 +9,7 @@
9
9
  import type { FilterGroupType } from '@nocobase/utils/client';
10
10
  import React from 'react';
11
11
  import { FieldAssignValueInput } from './FieldAssignValueInput';
12
- import type { FieldAssignCascaderOption } from './fieldAssignOptions';
12
+ import { type FieldAssignCascaderOption } from './fieldAssignOptions';
13
13
  export type AssignMode = 'default' | 'assign';
14
14
  type CollectionFieldLike = {
15
15
  name?: unknown;
@@ -17,6 +17,7 @@ type CollectionFieldLike = {
17
17
  type?: unknown;
18
18
  interface?: unknown;
19
19
  uiSchema?: unknown;
20
+ target?: unknown;
20
21
  targetKey?: unknown;
21
22
  targetCollectionTitleFieldName?: unknown;
22
23
  targetCollection?: any;
@@ -66,6 +67,7 @@ export interface FieldAssignRulesEditorProps {
66
67
  onSyncAssociationTitleField?: (params: SyncAssociationTitleFieldParams) => Promise<void> | void;
67
68
  /** 在日期字段下启用“日期变量替换 Constant 位”。 */
68
69
  enableDateVariableAsConstant?: boolean;
70
+ maxAssociationFieldDepth?: number;
69
71
  }
70
72
  export declare const FieldAssignRulesEditor: React.FC<FieldAssignRulesEditorProps>;
71
73
  export {};
@@ -52,6 +52,7 @@ interface Props {
52
52
  * 默认 false,保持历史行为。
53
53
  */
54
54
  enableDateVariableAsConstant?: boolean;
55
+ maxAssociationFieldDepth?: number;
55
56
  }
56
57
  export declare function mergeItemMetaTreeForAssignValue(baseTree: MetaTreeNode[], extraTree: MetaTreeNode[]): MetaTreeNode[];
57
58
  export declare function resolveAssignValueFieldPath(itemModel: any): string | undefined;
@@ -15,9 +15,19 @@ export type FieldAssignCascaderOption = {
15
15
  loading?: boolean;
16
16
  children?: FieldAssignCascaderOption[];
17
17
  };
18
+ type CollectionLike = {
19
+ getField?: (name: string) => unknown;
20
+ getFields?: () => unknown[];
21
+ };
22
+ export declare function buildFieldAssignCascaderOptionsFromCollection(collection: CollectionLike | null, t: (key: string) => string, options?: {
23
+ associationDepth?: number;
24
+ maxAssociationFieldDepth?: number;
25
+ }): FieldAssignCascaderOption[];
18
26
  export declare function collectFieldAssignCascaderOptions(options: {
19
27
  formBlockModel: any;
20
28
  t: (key: string) => string;
21
29
  /** 子表单模型递归深度(FormItemModel 层级);默认不限制(只受实际配置与循环引用约束) */
22
30
  maxFormItemDepth?: number;
31
+ maxAssociationFieldDepth?: number;
23
32
  }): FieldAssignCascaderOption[];
33
+ export {};
@@ -20,6 +20,7 @@ export interface LinkageFilterItemProps {
20
20
  model: FlowModel;
21
21
  /** 向变量树额外注入节点(置于根部) */
22
22
  extraMetaTree?: MetaTreeNode[];
23
+ maxAssociationFieldDepth?: number;
23
24
  }
24
25
  type OperatorMeta = {
25
26
  value: string;
@@ -30,6 +30,7 @@ export interface VariableFilterItemProps {
30
30
  */
31
31
  rightMetaTree?: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
32
32
  ignoreFieldNames?: string[];
33
+ maxAssociationFieldDepth?: number;
33
34
  }
34
35
  /**
35
36
  * 上下文筛选项组件
@@ -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 type { MetaTreeNode } from '@nocobase/flow-engine';
10
+ export declare function limitAssociationMetaTree(nodes: MetaTreeNode[] | undefined, options?: {
11
+ associationDepth?: number;
12
+ maxAssociationDepth?: number;
13
+ }): MetaTreeNode[];
@@ -9,41 +9,10 @@
9
9
  import { FlowModel, FlowModelContext } from '@nocobase/flow-engine';
10
10
  export declare class AssociationFieldGroupModel extends FlowModel {
11
11
  static itemModelName: string;
12
+ static maxAssociationFieldDepth: number;
12
13
  static defineChildren(ctx: FlowModelContext): {
13
14
  key: string;
14
15
  label: string;
15
- children: () => ({
16
- key: string;
17
- label: string;
18
- type: string;
19
- children: {
20
- key: string;
21
- label: string;
22
- useModel: string;
23
- toggleable: (subModel: any) => boolean;
24
- createModelOptions: {
25
- stepParams: {
26
- fieldSettings: {
27
- init: {
28
- dataSourceKey: any;
29
- collectionName: any;
30
- fieldPath: string;
31
- associationPathName: any;
32
- };
33
- };
34
- };
35
- subModels: {
36
- field: {
37
- use: string;
38
- };
39
- };
40
- };
41
- }[];
42
- } | {
43
- key: string;
44
- label: string;
45
- type: string;
46
- children: any[];
47
- })[];
16
+ children: () => any;
48
17
  }[];
49
18
  }
@@ -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
  };
@@ -10,6 +10,8 @@ import { DisplayItemModel, FlowModelContext, ModelRenderMode } from '@nocobase/f
10
10
  import { TableColumnProps } from 'antd';
11
11
  import React from 'react';
12
12
  export declare function FieldDeletePlaceholder(props: any): React.JSX.Element;
13
+ export declare const TABLE_COLUMN_MIN_WIDTH = 10;
14
+ export declare function normalizeTableColumnWidth(width: number | null | undefined): number;
13
15
  export declare const CustomWidth: ({ setOpen, t, handleChange, defaultValue }: {
14
16
  setOpen: any;
15
17
  t: any;