@nocobase/client-v2 2.1.0-alpha.34 → 2.1.0-alpha.35

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 (88) hide show
  1. package/es/BaseApplication.d.ts +1 -0
  2. package/es/PluginManager.d.ts +1 -0
  3. package/es/components/form/DrawerFormLayout.d.ts +49 -0
  4. package/es/components/form/EnvVariableInput.d.ts +42 -0
  5. package/es/components/form/FileSizeInput.d.ts +27 -0
  6. package/es/components/form/createFormRegistry.d.ts +33 -0
  7. package/es/components/form/index.d.ts +13 -0
  8. package/es/components/index.d.ts +1 -1
  9. package/es/flow/components/FieldAssignRulesEditor.d.ts +1 -0
  10. package/es/flow/internal/utils/enumOptionsUtils.d.ts +5 -0
  11. package/es/flow/models/actions/AssociationActionUtils.d.ts +5 -0
  12. package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +4 -0
  13. package/es/flow/models/blocks/filter-manager/FilterManager.d.ts +5 -1
  14. package/es/flow/models/blocks/shared/legacyDefaultValueMigrationBase.d.ts +1 -0
  15. package/es/flow/models/blocks/table/TableSelectModel.d.ts +8 -0
  16. package/es/flow/models/fields/DisplayEnumFieldModel.d.ts +6 -0
  17. package/es/flow/models/fields/DisplayTitleFieldModel.d.ts +1 -1
  18. package/es/flow/models/utils/displayValueUtils.d.ts +12 -0
  19. package/es/flow-compat/passwordUtils.d.ts +1 -1
  20. package/es/index.mjs +117 -106
  21. package/es/utils/remotePlugins.d.ts +0 -4
  22. package/lib/index.js +122 -111
  23. package/package.json +8 -5
  24. package/src/BaseApplication.tsx +14 -8
  25. package/src/PluginManager.ts +1 -0
  26. package/src/__tests__/app.test.tsx +28 -1
  27. package/src/__tests__/remotePlugins.test.ts +29 -18
  28. package/src/components/form/DrawerFormLayout.tsx +103 -0
  29. package/src/components/form/EnvVariableInput.tsx +126 -0
  30. package/src/components/form/FileSizeInput.tsx +105 -0
  31. package/src/components/form/createFormRegistry.ts +60 -0
  32. package/src/components/form/index.tsx +14 -0
  33. package/src/components/index.ts +1 -1
  34. package/src/flow/actions/__tests__/dataScopeFilter.test.ts +92 -13
  35. package/src/flow/actions/__tests__/formAssignRules.legacyMigration.test.tsx +173 -0
  36. package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +476 -1
  37. package/src/flow/actions/filterFormDefaultValues.tsx +30 -9
  38. package/src/flow/actions/formAssignRules.tsx +24 -9
  39. package/src/flow/actions/linkageRules.tsx +240 -258
  40. package/src/flow/actions/setTargetDataScope.tsx +32 -3
  41. package/src/flow/actions/titleField.tsx +1 -1
  42. package/src/flow/actions/validation.tsx +1 -1
  43. package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +0 -4
  44. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +13 -5
  45. package/src/flow/components/FieldAssignRulesEditor.tsx +2 -0
  46. package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +81 -4
  47. package/src/flow/components/filter/LinkageFilterItem.tsx +9 -2
  48. package/src/flow/components/filter/VariableFilterItem.tsx +2 -6
  49. package/src/flow/components/filter/__tests__/LinkageFilterItem.test.tsx +71 -0
  50. package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +48 -0
  51. package/src/flow/internal/utils/__tests__/enumOptionsUtils.test.ts +10 -1
  52. package/src/flow/internal/utils/enumOptionsUtils.ts +29 -0
  53. package/src/flow/models/actions/AssociateActionModel.tsx +2 -2
  54. package/src/flow/models/actions/AssociationActionUtils.ts +14 -0
  55. package/src/flow/models/actions/__tests__/AssociationActionModel.test.ts +63 -0
  56. package/src/flow/models/base/CollectionBlockModel.tsx +7 -0
  57. package/src/flow/models/base/PageModel/RootPageModel.tsx +1 -1
  58. package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +33 -9
  59. package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +53 -13
  60. package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.getFilterValue.test.ts +63 -3
  61. package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +33 -1
  62. package/src/flow/models/blocks/filter-form/__tests__/legacyDefaultValueMigration.test.ts +3 -0
  63. package/src/flow/models/blocks/filter-manager/FilterManager.ts +66 -2
  64. package/src/flow/models/blocks/filter-manager/__tests__/FilterManager.test.ts +270 -0
  65. package/src/flow/models/blocks/form/FormBlockModel.tsx +8 -5
  66. package/src/flow/models/blocks/form/FormItemModel.tsx +1 -1
  67. package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +30 -0
  68. package/src/flow/models/blocks/form/__tests__/legacyDefaultValueMigration.test.ts +3 -0
  69. package/src/flow/models/blocks/form/value-runtime/rules.ts +6 -1
  70. package/src/flow/models/blocks/form/value-runtime/runtime.ts +6 -1
  71. package/src/flow/models/blocks/shared/legacyDefaultValueMigrationBase.ts +21 -5
  72. package/src/flow/models/blocks/table/TableBlockModel.tsx +11 -6
  73. package/src/flow/models/blocks/table/TableColumnModel.tsx +8 -2
  74. package/src/flow/models/blocks/table/TableSelectModel.tsx +36 -26
  75. package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowClick.test.ts +69 -0
  76. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +132 -1
  77. package/src/flow/models/blocks/table/__tests__/TableSelectModel.test.ts +41 -0
  78. package/src/flow/models/fields/ClickableFieldModel.tsx +9 -4
  79. package/src/flow/models/fields/DisplayEnumFieldModel.tsx +44 -0
  80. package/src/flow/models/fields/DisplayTitleFieldModel.tsx +12 -4
  81. package/src/flow/models/fields/SelectFieldModel.tsx +31 -1
  82. package/src/flow/models/fields/__tests__/ClickableFieldModel.test.ts +23 -0
  83. package/src/flow/models/fields/__tests__/DisplayEnumFieldModel.test.tsx +39 -0
  84. package/src/flow/models/fields/mobile-components/MobileSelect.tsx +2 -1
  85. package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +7 -0
  86. package/src/flow/models/utils/displayValueUtils.ts +57 -0
  87. package/src/utils/globalDeps.ts +8 -0
  88. package/src/utils/remotePlugins.ts +7 -27
@@ -171,6 +171,7 @@ export declare class ApplicationModel extends FlowModel {
171
171
  getRouter(): RouterComponentType;
172
172
  render(): React.JSX.Element;
173
173
  renderMaintaining(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
174
+ renderMaintainingDialog(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
174
175
  renderError(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
175
176
  renderContent(): React.JSX.Element;
176
177
  }
@@ -17,6 +17,7 @@ export type PluginData = {
17
17
  packageName: string;
18
18
  version: string;
19
19
  url: string;
20
+ clientV2Url?: string;
20
21
  type: 'local' | 'upload' | 'npm';
21
22
  };
22
23
  export declare class PluginManager<TApp extends BaseApplication<any> = BaseApplication<any>> {
@@ -0,0 +1,49 @@
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 React from 'react';
10
+ export interface DrawerFormLayoutProps {
11
+ /** Header title rendered next to the close (X) button. */
12
+ title: React.ReactNode;
13
+ /** Form body — typically a `<Form>` wrapping `<Form.Item>` fields. */
14
+ children: React.ReactNode;
15
+ /**
16
+ * Called before the drawer is closed by either the Cancel button or the
17
+ * header's X icon. Use for "discard changes" confirmations.
18
+ */
19
+ onCancel?: () => void | Promise<void>;
20
+ /**
21
+ * Called when the Submit button is clicked. Caller owns validation + the
22
+ * actual API call; the drawer is closed automatically when `onSubmit`
23
+ * resolves. Throw from `onSubmit` to keep the drawer open (e.g. on a
24
+ * validation error).
25
+ */
26
+ onSubmit?: () => void | Promise<void>;
27
+ /** Drives the Submit button's loading state. */
28
+ submitting?: boolean;
29
+ /** Override the Submit button label. Defaults to "Submit". */
30
+ submitText?: React.ReactNode;
31
+ /** Override the Cancel button label. Defaults to "Cancel". */
32
+ cancelText?: React.ReactNode;
33
+ /**
34
+ * Full override of the footer content. When provided, the default
35
+ * Cancel + Submit buttons are replaced. Useful for forms that need
36
+ * extra actions (e.g. Preview, Save draft).
37
+ */
38
+ footer?: React.ReactNode;
39
+ }
40
+ /**
41
+ * Standard layout for drawer-hosted forms: a close-icon + title header on
42
+ * top, the caller-provided form body in the middle, and a Cancel + Submit
43
+ * footer at the bottom. Wraps `useFlowView()`'s `Header` / `Footer` slots
44
+ * so the drawer chrome stays consistent across plugins.
45
+ *
46
+ * Callers own the `<Form>` instance, validation, and the actual API call.
47
+ * This component only handles the chrome and the close behaviour.
48
+ */
49
+ export declare function DrawerFormLayout(props: DrawerFormLayoutProps): React.JSX.Element;
@@ -0,0 +1,42 @@
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
+ /**
12
+ * Convert a stored value like `"{{ $env.foo.bar }}"` back into the
13
+ * `[$env, foo, bar]` path used by the variable picker.
14
+ */
15
+ export declare function parseEnvPath(value?: string): string[] | undefined;
16
+ /**
17
+ * Format a meta tree node back into a `"{{ $env.x.y }}"` server-compatible
18
+ * expression. Used as the `formatPathToValue` converter so the picker output
19
+ * survives a round trip through the API.
20
+ */
21
+ export declare function formatEnvPath(meta?: MetaTreeNode): string;
22
+ export interface EnvVariableInputProps {
23
+ value?: string;
24
+ onChange?: (value: string) => void;
25
+ addonBefore?: React.ReactNode;
26
+ disabled?: boolean;
27
+ /**
28
+ * When true, plain (non-variable) values are masked via `Input.Password`
29
+ * so secret credentials are not displayed verbatim. Variable expressions
30
+ * remain editable through the variable picker even in password mode.
31
+ */
32
+ password?: boolean;
33
+ placeholder?: string;
34
+ }
35
+ /**
36
+ * Generic input component for fields that accept either a literal value or a
37
+ * `{{ $env.X }}` reference. The `$env` namespace is wired through the
38
+ * environment-variables plugin's `flowEngine.context.defineProperty('$env', ...)`
39
+ * registration; this component is the single consumption point and degrades
40
+ * gracefully to a plain text input when no env variables are defined.
41
+ */
42
+ export declare function EnvVariableInput(props: EnvVariableInputProps): React.JSX.Element;
@@ -0,0 +1,27 @@
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 React from 'react';
10
+ export interface FileSizeInputProps {
11
+ value?: number;
12
+ onChange?: (value?: number) => void;
13
+ disabled?: boolean;
14
+ /** Minimum byte size. Empty / below-min input snaps to this on blur. Defaults to 1. */
15
+ min?: number;
16
+ /** Maximum byte size. Defaults to `Number.POSITIVE_INFINITY`. */
17
+ max?: number;
18
+ /** Default byte size used to derive the initial unit shown when the field is empty. Defaults to 20 MB. */
19
+ defaultValue?: number;
20
+ }
21
+ /**
22
+ * Byte-valued size input paired with a unit selector (Byte / KB / MB / GB).
23
+ * The persisted value is always normalized to bytes; the displayed number is
24
+ * derived from the picked unit. Useful for fields like file-size limits or
25
+ * memory quotas where the natural input unit varies by magnitude.
26
+ */
27
+ export declare function FileSizeInput(props: FileSizeInputProps): React.JSX.Element;
@@ -0,0 +1,33 @@
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 interface FormRegistryEntry {
10
+ name: string;
11
+ }
12
+ export interface FormRegistry<T extends FormRegistryEntry> {
13
+ readonly namespace: string;
14
+ register(entry: T): void;
15
+ unregister(name: string): boolean;
16
+ get(name: string): T | undefined;
17
+ has(name: string): boolean;
18
+ list(): T[];
19
+ }
20
+ /**
21
+ * Create an isolated, namespaced registry of form-like entries.
22
+ *
23
+ * Each call returns a fresh registry instance backed by its own closure-scoped
24
+ * `Map`, so plugins do not share state across namespaces. Plugins that need an
25
+ * extension point for form-shaped registrations (e.g. storage configuration
26
+ * forms, data-source connection forms) can build their own typed registry on
27
+ * top of this primitive instead of re-implementing the same boilerplate.
28
+ *
29
+ * Re-registering the same `name` overwrites the previous entry and emits a
30
+ * console warning. This is intentional so HMR / hot reload works without
31
+ * throwing, while still surfacing unintended duplicates during development.
32
+ */
33
+ export declare function createFormRegistry<T extends FormRegistryEntry>(namespace: string): FormRegistry<T>;
@@ -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
+ export * from './createFormRegistry';
10
+ export * from './DrawerFormLayout';
11
+ export * from './EnvVariableInput';
12
+ export * from './FileSizeInput';
13
+ export * from './JsonTextArea';
@@ -8,6 +8,6 @@
8
8
  */
9
9
  export * from './AppComponents';
10
10
  export * from './BlankComponent';
11
+ export * from './form';
11
12
  export * from './Icon';
12
- export * from './form/JsonTextArea';
13
13
  export * from './RouterContextCleaner';
@@ -16,6 +16,7 @@ type CollectionFieldLike = {
16
16
  title?: unknown;
17
17
  type?: unknown;
18
18
  interface?: unknown;
19
+ uiSchema?: unknown;
19
20
  targetKey?: unknown;
20
21
  targetCollectionTitleFieldName?: unknown;
21
22
  targetCollection?: any;
@@ -19,5 +19,10 @@ type Option = {
19
19
  } & Record<string, any>;
20
20
  export declare function translateOptions(options: Option[], t: (s: string) => string): Option[];
21
21
  export declare function enumToOptions(uiEnum: UiSchemaEnumItem[] | undefined, t: (s: string) => string): Option[] | undefined;
22
+ export declare function normalizeSelectRenderValue(value: unknown, props?: Record<string, any>): unknown;
23
+ export declare function getSelectedEnumLabels(value: any, fallbackOptions?: Option[]): Array<{
24
+ value: any;
25
+ label: any;
26
+ }>;
22
27
  export declare function ensureOptionsFromUiSchemaEnumIfAbsent(model: FlowModel, collectionField: CollectionField): boolean;
23
28
  export {};
@@ -13,5 +13,10 @@ export declare const getAssociationTargetResourceSettings: (ctx: FlowModelContex
13
13
  dataSourceKey: any;
14
14
  collectionName: any;
15
15
  };
16
+ export declare const getAssociationSelectorContextInputArgs: (ctx: FlowModelContext | any) => {
17
+ collectionField: any;
18
+ sourceId: any;
19
+ associatedRecords: any;
20
+ };
16
21
  export declare const applyDisassociateAction: (ctx: FlowModelContext | any) => Promise<void>;
17
22
  export declare const applyAssociateAction: (ctx: FlowModelContext | any, selectedRows: any[]) => Promise<void>;
@@ -20,6 +20,8 @@ export declare class FilterFormBlockModel extends FilterBlockModel<{
20
20
  */
21
21
  autoTriggerFilter: boolean;
22
22
  private removeTargetBlockListener?;
23
+ private initialDefaultsPromise?;
24
+ private initialRefreshHandledTargetIds;
23
25
  get form(): any;
24
26
  get title(): string;
25
27
  useHooksBeforeRender(): void;
@@ -29,6 +31,8 @@ export declare class FilterFormBlockModel extends FilterBlockModel<{
29
31
  onMount(): void;
30
32
  onUnmount(): void;
31
33
  private applyDefaultsAndInitialFilter;
34
+ prepareInitialFilterValues(): Promise<boolean>;
35
+ markInitialTargetRefreshHandled(targetId: string): void;
32
36
  private ensureFilterItemsBeforeRender;
33
37
  applyFormDefaultValues(options?: {
34
38
  force?: boolean;
@@ -17,6 +17,9 @@ type FilterConfig = {
17
17
  /** 筛选操作符,每个条件的操作符可以不一样 */
18
18
  operator?: string;
19
19
  };
20
+ export type RefreshTargetsByFilterOptions = {
21
+ excludeTargetIds?: Set<string> | string[];
22
+ };
20
23
  export type ConnectFieldsConfig = {
21
24
  targets: {
22
25
  /** 数据区块或者图表区块的 model uid */
@@ -32,6 +35,7 @@ export declare class FilterManager {
32
35
  saveFilterConfigs(): Promise<void>;
33
36
  getFilterConfigs(): FilterConfig[];
34
37
  getConnectFieldsConfig(filterModelUid: string): ConnectFieldsConfig | undefined;
38
+ prepareFiltersForTarget(targetId: string): Promise<Set<any>>;
35
39
  saveConnectFieldsConfig(filterModelUid: string, config: ConnectFieldsConfig): Promise<void>;
36
40
  /**
37
41
  * 添加筛选配置
@@ -136,6 +140,6 @@ export declare class FilterManager {
136
140
  * await filterManager.refreshTargetsByFilter(['filter-1', 'filter-2']);
137
141
  * ```
138
142
  */
139
- refreshTargetsByFilter(filterId: string | string[]): Promise<void>;
143
+ refreshTargetsByFilter(filterId: string | string[], options?: RefreshTargetsByFilterOptions): Promise<void>;
140
144
  }
141
145
  export {};
@@ -13,6 +13,7 @@ export interface LegacyValueExtractor {
13
13
  export interface LegacyClearer {
14
14
  (model: any): void;
15
15
  }
16
+ export declare function hasPersistedAssignRulesValue(model: any, flowKey: string, stepKey: string): boolean;
16
17
  export declare function createLegacyValueExtractor(flowKeys: string[]): LegacyValueExtractor;
17
18
  export declare function createLegacyClearer(flowKeys: string[]): LegacyClearer;
18
19
  export declare function collectLegacyDefaultValueRules(formModel: any, extractor: LegacyValueExtractor): FieldAssignRuleItem[];
@@ -7,6 +7,14 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { TableBlockModel } from './TableBlockModel';
10
+ export declare function getAssociationSelectForeignKeyFilter(collectionField: any): {
11
+ [x: number]: {
12
+ $is: any;
13
+ };
14
+ };
15
+ export declare function getAssociationSelectAssociatedRecordsFilter(collection: any, associatedRecords?: any[]): {
16
+ [x: string]: any[];
17
+ };
10
18
  export declare class TableSelectModel extends TableBlockModel {
11
19
  static scene: import("../../base/BlockModel").BlockSceneType;
12
20
  rowSelectionProps: any;
@@ -10,5 +10,11 @@ import React from 'react';
10
10
  import { ClickableFieldModel } from './ClickableFieldModel';
11
11
  export declare class DisplayEnumFieldModel extends ClickableFieldModel {
12
12
  isEmpty(value: any): boolean;
13
+ private isEmptyEnumValue;
13
14
  renderComponent(value: any): React.JSX.Element[];
15
+ /**
16
+ * Keep array values for multipleSelect/checkboxGroup.
17
+ * ClickableFieldModel will normalize arrays to joined strings, which breaks option label mapping.
18
+ */
19
+ renderInDisplayStyle(value: any, record?: any, isToMany?: any, wrap?: any): React.JSX.Element;
14
20
  }
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { CollectionField } from '@nocobase/flow-engine';
10
- import { FieldModel } from '../base/FieldModel';
10
+ import { FieldModel } from '../base';
11
11
  export declare class DisplayTitleFieldModel extends FieldModel {
12
12
  get collectionField(): CollectionField;
13
13
  renderComponent(value: any): any;
@@ -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
+ export declare function hasDisplayValue(value: any): boolean;
10
+ export declare function normalizeDisplayValue(value: any, options?: {
11
+ collectionField?: any;
12
+ }): any;
@@ -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 const getStrength: (val: any) => 0 | 100 | 80 | 60 | 40 | 20;
9
+ export declare const getStrength: (val: any) => 0 | 20 | 100 | 80 | 60 | 40;