@nocobase/client-v2 2.1.0-beta.37 → 2.1.0-beta.38

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 (123) hide show
  1. package/es/Application.d.ts +1 -0
  2. package/es/BaseApplication.d.ts +3 -0
  3. package/es/RouterManager.d.ts +1 -0
  4. package/es/components/KeepAlive.d.ts +22 -0
  5. package/es/components/RouterBridge.d.ts +9 -0
  6. package/es/data-source/ExtendCollectionsProvider.d.ts +28 -2
  7. package/es/flow/FlowPage.d.ts +2 -1
  8. package/es/flow/admin-shell/AdminLayoutRouteCoordinator.d.ts +8 -40
  9. package/es/flow/admin-shell/BaseLayoutModel.d.ts +89 -0
  10. package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +74 -0
  11. package/es/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.d.ts +12 -0
  12. package/es/flow/admin-shell/admin-layout/AdminLayoutModel.d.ts +7 -92
  13. package/es/flow/admin-shell/admin-layout/index.d.ts +2 -0
  14. package/es/flow/admin-shell/useAdminLayoutRoutePage.d.ts +2 -2
  15. package/es/flow/admin-shell/useLayoutRoutePage.d.ts +23 -0
  16. package/es/flow/components/FlowRoute.d.ts +10 -1
  17. package/es/flow/index.d.ts +4 -0
  18. package/es/flow/models/base/PageModel/PageModel.d.ts +3 -1
  19. package/es/flow/models/blocks/form/FormActionGroupModel.d.ts +1 -0
  20. package/es/flow/models/blocks/table/TableBlockModel.d.ts +10 -0
  21. package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.d.ts +1 -1
  22. package/es/index.d.ts +1 -0
  23. package/es/index.mjs +484 -437
  24. package/es/layout-manager/LayoutContentRoute.d.ts +14 -0
  25. package/es/layout-manager/LayoutManager.d.ts +22 -0
  26. package/es/layout-manager/LayoutRoute.d.ts +14 -0
  27. package/es/layout-manager/index.d.ts +13 -0
  28. package/es/layout-manager/types.d.ts +20 -0
  29. package/es/layout-manager/utils.d.ts +14 -0
  30. package/es/settings-center/index.d.ts +1 -1
  31. package/es/settings-center/plugin-manager/BulkEnableButton.d.ts +15 -0
  32. package/es/settings-center/plugin-manager/PluginCard.d.ts +15 -0
  33. package/es/settings-center/plugin-manager/PluginDetail.d.ts +16 -0
  34. package/es/settings-center/{PluginManagerPage.d.ts → plugin-manager/index.d.ts} +1 -7
  35. package/es/settings-center/plugin-manager/types.d.ts +34 -0
  36. package/lib/index.js +484 -437
  37. package/package.json +8 -7
  38. package/src/Application.tsx +27 -12
  39. package/src/BaseApplication.tsx +6 -0
  40. package/src/PluginSettingsManager.ts +1 -1
  41. package/src/RouterManager.tsx +17 -1
  42. package/src/__tests__/PluginSettingsManager.test.ts +41 -2
  43. package/src/__tests__/app.test.tsx +8 -1
  44. package/src/__tests__/globalDeps.test.ts +1 -0
  45. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +45 -2
  46. package/src/__tests__/plugin-manager.test.tsx +177 -0
  47. package/src/__tests__/settings-center.test.tsx +24 -2
  48. package/src/components/KeepAlive.tsx +131 -0
  49. package/src/components/RouterBridge.tsx +28 -4
  50. package/src/components/__tests__/KeepAlive.test.tsx +63 -0
  51. package/src/components/__tests__/RouterBridge.test.tsx +27 -0
  52. package/src/data-source/ExtendCollectionsProvider.tsx +94 -20
  53. package/src/data-source/__tests__/ExtendCollectionsProvider.test.tsx +264 -0
  54. package/src/flow/FlowPage.tsx +35 -7
  55. package/src/flow/__tests__/FlowPage.test.tsx +79 -0
  56. package/src/flow/__tests__/FlowRoute.test.tsx +529 -2
  57. package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +191 -0
  58. package/src/flow/actions/__tests__/openView.subModelKey.test.tsx +33 -0
  59. package/src/flow/actions/aclCheck.tsx +4 -0
  60. package/src/flow/actions/aclCheckRefresh.tsx +4 -0
  61. package/src/flow/actions/dateTimeFormat.tsx +12 -8
  62. package/src/flow/actions/linkageRules.tsx +122 -0
  63. package/src/flow/actions/openView.tsx +28 -4
  64. package/src/flow/admin-shell/AdminLayoutRouteCoordinator.ts +11 -329
  65. package/src/flow/admin-shell/BaseLayoutModel.tsx +455 -0
  66. package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +502 -0
  67. package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +547 -3
  68. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +4 -4
  69. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +160 -0
  70. package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +0 -12
  71. package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +28 -201
  72. package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +11 -2
  73. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +1 -26
  74. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +149 -27
  75. package/src/flow/admin-shell/admin-layout/index.ts +2 -0
  76. package/src/flow/admin-shell/useAdminLayoutRoutePage.ts +10 -26
  77. package/src/flow/admin-shell/useLayoutRoutePage.ts +61 -0
  78. package/src/flow/components/AdminLayout.tsx +4 -154
  79. package/src/flow/components/FlowRoute.tsx +105 -15
  80. package/src/flow/index.ts +4 -0
  81. package/src/flow/models/base/ActionModel.tsx +8 -1
  82. package/src/flow/models/base/PageModel/PageModel.tsx +51 -18
  83. package/src/flow/models/base/PageModel/RootPageModel.tsx +6 -13
  84. package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +102 -1
  85. package/src/flow/models/base/RouteModel.tsx +1 -1
  86. package/src/flow/models/blocks/form/FormActionGroupModel.tsx +14 -0
  87. package/src/flow/models/blocks/form/FormItemModel.tsx +8 -1
  88. package/src/flow/models/blocks/form/__tests__/FormActionGroupModel.test.ts +46 -0
  89. package/src/flow/models/blocks/form/submitValues.ts +4 -1
  90. package/src/flow/models/blocks/table/TableBlockModel.tsx +118 -16
  91. package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +114 -0
  92. package/src/flow/models/fields/AssociationFieldModel/SubFormFieldModel.tsx +7 -1
  93. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +1 -1
  94. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +6 -5
  95. package/src/flow/models/fields/ClickableFieldModel.tsx +9 -1
  96. package/src/flow/models/fields/DisplayTimeFieldModel.tsx +1 -1
  97. package/src/flow/models/fields/TimeFieldModel.tsx +1 -1
  98. package/src/flow/models/fields/__tests__/TimeFieldModel.test.tsx +61 -0
  99. package/src/flow/models/fields/mobile-components/MobileDatePicker.tsx +19 -3
  100. package/src/flow/models/fields/mobile-components/__tests__/MobileDatePicker.test.tsx +94 -0
  101. package/src/flow/models/topbar/TopbarActionModel.tsx +1 -1
  102. package/src/flow/utils/__tests__/dateTimeFormat.test.ts +91 -0
  103. package/src/index.ts +1 -0
  104. package/src/layout-manager/LayoutContentRoute.tsx +90 -0
  105. package/src/layout-manager/LayoutManager.tsx +185 -0
  106. package/src/layout-manager/LayoutRoute.tsx +138 -0
  107. package/src/layout-manager/__tests__/LayoutManager.test.tsx +335 -0
  108. package/src/layout-manager/__tests__/LayoutRoute.test.tsx +473 -0
  109. package/src/layout-manager/index.ts +14 -0
  110. package/src/layout-manager/types.ts +22 -0
  111. package/src/layout-manager/utils.ts +37 -0
  112. package/src/nocobase-buildin-plugin/index.tsx +56 -48
  113. package/src/settings-center/index.ts +1 -1
  114. package/src/settings-center/plugin-manager/BulkEnableButton.tsx +111 -0
  115. package/src/settings-center/plugin-manager/PluginCard.tsx +270 -0
  116. package/src/settings-center/plugin-manager/PluginDetail.tsx +195 -0
  117. package/src/settings-center/plugin-manager/index.tsx +254 -0
  118. package/src/settings-center/plugin-manager/types.ts +35 -0
  119. package/src/settings-center/utils.tsx +8 -1
  120. package/src/theme/__tests__/globalStyles.test.ts +24 -0
  121. package/src/theme/globalStyles.ts +10 -0
  122. package/src/utils/globalDeps.ts +2 -0
  123. package/src/settings-center/PluginManagerPage.tsx +0 -162
@@ -28,6 +28,7 @@ export interface ApplicationOptions extends BaseApplicationOptions<PluginType> {
28
28
  }
29
29
  export declare class Application extends BaseApplication<ApplicationOptions, PluginManager, RouterManager, APIClient, PluginSettingsManager> {
30
30
  dataSourceManager: any;
31
+ hasLoadError: boolean;
31
32
  protected createApiClient(options: ApplicationOptions): APIClient;
32
33
  protected configureRuntimeAdapters(): void;
33
34
  protected createI18n(options: ApplicationOptions): i18next;
@@ -12,6 +12,7 @@ import type { i18n as i18next } from 'i18next';
12
12
  import React, { ReactElement, ReactNode } from 'react';
13
13
  import { AIManager } from './ai';
14
14
  import { SystemSettingsSource } from './flow/system-settings';
15
+ import { LayoutManager } from './layout-manager/LayoutManager';
15
16
  import type { PluginClass, PluginManager, PluginType } from './PluginManager';
16
17
  import { RouteRepository } from './RouteRepository';
17
18
  import type { ComponentTypeAndString, RenderableComponentType, RouterComponentType, RouterManager, RouterOptions } from './RouterManager';
@@ -71,6 +72,7 @@ export declare abstract class BaseApplication<TOptions extends BaseApplicationOp
71
72
  components: Record<string, AnyComponent>;
72
73
  pluginManager: TPluginManager;
73
74
  pluginSettingsManager: TPluginSettingsManager;
75
+ layoutManager: LayoutManager<this>;
74
76
  aiManager: AIManager;
75
77
  devDynamicImport?: DevDynamicImport;
76
78
  requirejs: RequireJS;
@@ -161,6 +163,7 @@ export declare abstract class BaseApplication<TOptions extends BaseApplicationOp
161
163
  protected abstract createRouterManager(options: TOptions): TRouterManager;
162
164
  protected abstract createPluginManager(options: TOptions): TPluginManager;
163
165
  protected abstract createPluginSettingsManager(options: TOptions): TPluginSettingsManager;
166
+ protected createLayoutManager(_options: TOptions): LayoutManager<this>;
164
167
  protected createWebSocketClient(options: TOptions): WebSocketClient;
165
168
  protected getDefaultComponents(): Record<string, AnyComponent>;
166
169
  abstract load(): Promise<void>;
@@ -34,6 +34,7 @@ export interface RouteType extends Omit<RouteObject, 'children' | 'Component'> {
34
34
  Component?: ComponentTypeAndString;
35
35
  componentLoader?: ComponentLoader;
36
36
  skipAuthCheck?: boolean;
37
+ authCheck?: boolean;
37
38
  }
38
39
  export type RenderComponentType = (Component: ComponentTypeAndString, props?: any) => React.ReactNode;
39
40
  export type RouterComponentType = React.FC<{
@@ -0,0 +1,22 @@
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, { FC } from 'react';
10
+ export declare const KeepAliveProvider: FC<{
11
+ active: boolean;
12
+ parentActive: boolean;
13
+ }>;
14
+ export declare const useKeepAlive: () => {
15
+ active: boolean;
16
+ };
17
+ interface KeepAliveProps {
18
+ uid: string;
19
+ children: (uid: string) => React.ReactNode;
20
+ }
21
+ export declare const KeepAlive: FC<KeepAliveProps>;
22
+ export {};
@@ -7,7 +7,16 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Application } from '../Application';
10
+ type LayoutMatchLike = {
11
+ id: string;
12
+ pathname: string;
13
+ };
14
+ type LayoutDefinitionLike = {
15
+ routeName: string;
16
+ };
17
+ export declare function findDeepestLayoutMatch(layouts?: LayoutDefinitionLike[], matches?: LayoutMatchLike[]): LayoutMatchLike;
10
18
  export declare function useRouterSync(app: Application): void;
11
19
  export declare function RouterBridge({ app }: {
12
20
  app: any;
13
21
  }): any;
22
+ export {};
@@ -13,12 +13,38 @@ export interface ExtendCollectionsProviderProps {
13
13
  dataSource?: string;
14
14
  /** Collections to surface for the lifetime of this provider's subtree. */
15
15
  collections: CollectionOptions[];
16
+ /**
17
+ * When `true`, re-sync the data source whenever the `collections` prop
18
+ * reference changes after mount: add entries newly present in the prop and
19
+ * remove entries no longer present (only those this provider registered).
20
+ * The diff runs in the same render as the prop change so children see the
21
+ * new state on their first render — at the cost of one observable mutation
22
+ * per change.
23
+ *
24
+ * Defaults to `false`. Most pages pass a stable (often module-level)
25
+ * `collections` list and don't need this; leaving it off avoids accidental
26
+ * re-registration when callers forget to memoize. Enable only when your
27
+ * collection list legitimately varies during the provider's lifetime.
28
+ */
29
+ syncOnChange?: boolean;
16
30
  children?: ReactNode;
17
31
  }
18
32
  /**
19
- * Mount-scoped collection injector. Adds the given `collections` to the target data source on mount and removes them on unmount. Survives mid-session reloads via `dataSource:loaded` events.
33
+ * Mount-scoped collection injector. Adds the given `collections` to the target
34
+ * data source on first render — synchronously, so children can read
35
+ * `getCollection(name)` on their own first render — and removes them on
36
+ * unmount. Survives mid-session data-source reloads via the
37
+ * `dataSource:loaded` event by re-registering only the names this provider
38
+ * owns.
20
39
  *
21
- * Use this for client-only collections — e.g. a `schema-only` server collection that isn't auto-published to the v2 data source, or a pure UI-side mirror — so downstream components (like `<CollectionFilter>`) can resolve the collection by name.
40
+ * Use this for client-only collections — e.g. a `schema-only` server
41
+ * collection that isn't auto-published to the v2 data source, or a pure
42
+ * UI-side mirror — so downstream components (like `<CollectionFilter>`) can
43
+ * resolve the collection by name.
44
+ *
45
+ * Default behavior is "static-at-mount": subsequent changes to the
46
+ * `collections` prop are ignored. Pass `syncOnChange` to opt into diffing on
47
+ * prop change.
22
48
  */
23
49
  export declare const ExtendCollectionsProvider: FC<ExtendCollectionsProviderProps>;
24
50
  export default ExtendCollectionsProvider;
@@ -6,7 +6,7 @@
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 type { FlowModel } from '@nocobase/flow-engine';
9
+ import type { FlowModel, FlowModelRendererProps } from '@nocobase/flow-engine';
10
10
  import React from 'react';
11
11
  import FlowRoute from './components/FlowRoute';
12
12
  type FlowPageProps = {
@@ -14,6 +14,7 @@ type FlowPageProps = {
14
14
  parentId?: string;
15
15
  onModelLoaded?: (uid: string, model: FlowModel) => void;
16
16
  defaultTabTitle?: string;
17
+ showFlowSettings?: FlowModelRendererProps['showFlowSettings'];
17
18
  };
18
19
  export declare const FlowPage: React.MemoExoticComponent<(props: FlowPageProps & Record<string, unknown>) => React.JSX.Element>;
19
20
  export declare const RemoteFlowModelRenderer: (props: any) => React.JSX.Element;
@@ -6,46 +6,14 @@
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 { FlowEngine, FlowModel, type ViewParam } from '@nocobase/flow-engine';
10
- export interface RoutePageMeta {
11
- active: boolean;
12
- refreshDesktopRoutes?: () => Promise<unknown>;
13
- layoutContentElement?: HTMLElement | null;
14
- }
15
- interface RouteLike {
16
- params?: {
17
- name?: string;
18
- };
19
- pathname?: string;
20
- }
9
+ import type { FlowEngine } from '@nocobase/flow-engine';
10
+ import { BaseLayoutRouteCoordinator, type BaseLayoutRouteCoordinatorOptions } from './BaseLayoutRouteCoordinator';
21
11
  /**
22
- * 管理 admin 场景下每个 page 的 v2 视图栈编排。
23
- * 该协调器只负责状态机和开关视图,不直接绑定 React 生命周期。
12
+ * Admin Layout 路由协调器。
13
+ *
14
+ * 该类保留旧导出路径,内部复用通用 BaseLayoutRouteCoordinator。
24
15
  */
25
- export declare class AdminLayoutRouteCoordinator {
26
- private readonly flowEngine;
27
- private readonly runtimes;
28
- private layoutContentElement;
29
- private setRuntimeActive;
30
- private getCurrentRouteByPageUid;
31
- constructor(flowEngine: FlowEngine);
32
- setLayoutContentElement(element: HTMLElement | null): void;
33
- registerPage(pageUid: string, meta: RoutePageMeta): FlowModel<import("@nocobase/flow-engine").DefaultStructure>;
34
- syncPageMeta(pageUid: string, meta: Partial<RoutePageMeta>): void;
35
- unregisterPage(pageUid: string): void;
36
- syncRoute(routeLike: RouteLike): void;
37
- cleanupPage(pageUid: string): void;
38
- destroy(): void;
39
- private syncRuntimeWithPathname;
40
- private shouldStepNavigate;
41
- private stepNavigate;
42
- private handleOpenViews;
43
- private openViews;
44
- private ensureRouteModelContext;
45
- private getOrCreateRouteModel;
16
+ export declare class AdminLayoutRouteCoordinator extends BaseLayoutRouteCoordinator {
17
+ constructor(flowEngine: FlowEngine, options?: BaseLayoutRouteCoordinatorOptions);
46
18
  }
47
- /**
48
- * 将 pathname 解析结果和 pageUid 对齐,便于测试里复用。
49
- */
50
- export declare function toViewStack(pathname: string): ViewParam[];
51
- export {};
19
+ export { toViewStack, type BaseLayoutRouteCoordinatorOptions, type RoutePageMeta } from './BaseLayoutRouteCoordinator';
@@ -0,0 +1,89 @@
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 FlowEngine, FlowModel, type ViewParam } from '@nocobase/flow-engine';
10
+ import { BaseLayoutRouteCoordinator, type BaseLayoutRouteCoordinatorOptions, type RoutePageMeta } from './BaseLayoutRouteCoordinator';
11
+ import type { LayoutDefinition } from '../../layout-manager/types';
12
+ export type BaseLayoutStructure = {
13
+ subModels?: Record<string, FlowModel[]>;
14
+ };
15
+ export type GetLayoutModelOptions<TModel extends FlowModel = BaseLayoutModel> = {
16
+ required?: boolean;
17
+ create?: boolean;
18
+ props?: any;
19
+ use?: new (...args: any[]) => TModel;
20
+ };
21
+ export type LayoutRouteMatch = {
22
+ type: 'root';
23
+ pathname: string;
24
+ basePathname: string;
25
+ relativePath: string;
26
+ } | {
27
+ type: 'page';
28
+ pathname: string;
29
+ basePathname: string;
30
+ relativePath: string;
31
+ pageUid: string;
32
+ tabUid?: string;
33
+ viewStack: ViewParam[];
34
+ } | {
35
+ type: 'notFound';
36
+ pathname: string;
37
+ basePathname: string;
38
+ relativePath: string;
39
+ };
40
+ export interface LayoutRouteLike {
41
+ id?: string;
42
+ name?: string;
43
+ pathname?: string;
44
+ params?: Record<string, string | undefined>;
45
+ layoutRouteName?: string;
46
+ layoutBasePathname?: string;
47
+ }
48
+ /**
49
+ * 通用 Layout 运行时模型。
50
+ *
51
+ * 该模型封装页面路由桥接、弹窗路由、page tab 路由、布局容器和移动端状态,
52
+ * Admin、Embed 等具体 Layout 只需要继承并实现各自的渲染和专属业务能力。
53
+ */
54
+ export declare class BaseLayoutModel<TStructure extends BaseLayoutStructure = BaseLayoutStructure> extends FlowModel<TStructure> {
55
+ isMobileLayout: boolean;
56
+ currentLayoutRoute: LayoutRouteMatch | null;
57
+ protected routeCoordinator?: BaseLayoutRouteCoordinator;
58
+ private activePageUid;
59
+ private layoutContentElement;
60
+ private readonly routePageMetaMap;
61
+ private contextBindingsActive;
62
+ constructor(options: any);
63
+ registerRoutePage(pageUid: string, meta: RoutePageMeta): import("..").RouteModel<import("@nocobase/flow-engine").DefaultStructure>;
64
+ updateRoutePage(pageUid: string, meta: Partial<RoutePageMeta>): void;
65
+ unregisterRoutePage(pageUid: string): void;
66
+ setLayoutContentElement(element: HTMLElement | null): void;
67
+ setIsMobileLayout(isMobileLayout: boolean): void;
68
+ getCurrentRouteByPageUid(pageUid: string): any;
69
+ get layout(): LayoutDefinition;
70
+ getCoordinator(): BaseLayoutRouteCoordinator;
71
+ protected createRouteCoordinator(): BaseLayoutRouteCoordinator;
72
+ protected getRouteCoordinatorOptions(): BaseLayoutRouteCoordinatorOptions;
73
+ protected getPageUidFromRoute(route: any): any;
74
+ isLayoutContentRoute(routeLike: LayoutRouteLike): boolean;
75
+ resolveLayoutRoute(routeLike: LayoutRouteLike): LayoutRouteMatch;
76
+ getPageUidFromLayoutRoute(match: LayoutRouteMatch | null | undefined): string;
77
+ syncLayoutRoute(routeLike: LayoutRouteLike): LayoutRouteMatch;
78
+ clearLayoutRoute(routeLike?: LayoutRouteLike): void;
79
+ protected onMount(): void;
80
+ protected onUnmount(): void;
81
+ private setupContextBindings;
82
+ private teardownRuntime;
83
+ private getCurrentRouteByActivePage;
84
+ private getCurrentCoordinatorRouteLike;
85
+ }
86
+ /**
87
+ * 按固定 UID 获取或创建 Layout host model。
88
+ */
89
+ export declare function getLayoutModel<TModel extends FlowModel = BaseLayoutModel>(flowEngine: FlowEngine, uid: string, options?: GetLayoutModelOptions<TModel>): TModel;
@@ -0,0 +1,74 @@
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 { FlowEngine, type FlowContext, type ViewParam } from '@nocobase/flow-engine';
10
+ import { RouteModel } from '../models/base/RouteModel';
11
+ import type { LayoutDefinition } from '../../layout-manager/types';
12
+ export interface RoutePageMeta {
13
+ active: boolean;
14
+ refreshDesktopRoutes?: () => Promise<unknown>;
15
+ layoutContentElement?: HTMLElement | null;
16
+ }
17
+ export interface BaseLayoutRouteCoordinatorOptions {
18
+ layout?: LayoutDefinition;
19
+ layoutContext?: FlowContext;
20
+ basePathname?: string;
21
+ }
22
+ interface RouteLike {
23
+ layoutRouteName?: string;
24
+ params?: {
25
+ name?: string;
26
+ };
27
+ pathname?: string;
28
+ pageUid?: string;
29
+ layoutBasePathname?: string;
30
+ layoutRoute?: {
31
+ type: string;
32
+ pageUid?: string;
33
+ basePathname?: string;
34
+ } | null;
35
+ }
36
+ /**
37
+ * 通用 Layout 路由协调器。
38
+ *
39
+ * 负责把当前路由路径解析为 v2 view stack,并驱动 RouteModel 上的弹窗、抽屉和 page tab 状态。
40
+ * Admin、Embed 等布局只需要提供当前 Layout 的基准路径,即可复用同一套 view 编排逻辑。
41
+ */
42
+ export declare class BaseLayoutRouteCoordinator {
43
+ protected readonly flowEngine: FlowEngine;
44
+ protected readonly layout: LayoutDefinition | undefined;
45
+ private readonly layoutContext?;
46
+ private basePathname;
47
+ private readonly runtimes;
48
+ private layoutContentElement;
49
+ constructor(flowEngine: FlowEngine, options?: BaseLayoutRouteCoordinatorOptions);
50
+ setLayoutContentElement(element: HTMLElement | null): void;
51
+ registerPage(pageUid: string, meta: RoutePageMeta): RouteModel<import("@nocobase/flow-engine").DefaultStructure>;
52
+ syncPageMeta(pageUid: string, meta: Partial<RoutePageMeta>): void;
53
+ unregisterPage(pageUid: string): void;
54
+ syncRoute(routeLike: RouteLike): void;
55
+ cleanupPage(pageUid: string): void;
56
+ destroy(): void;
57
+ protected getCurrentRouteByPageUid(pageUid: string): any;
58
+ private setRuntimeActive;
59
+ private notifyRuntimeActiveChange;
60
+ private syncRuntimeWithPathname;
61
+ private syncViewListVisibility;
62
+ private shouldStepNavigate;
63
+ private scheduleInitialDeepLinkReplay;
64
+ private stepNavigate;
65
+ private handleOpenViews;
66
+ private openViews;
67
+ private ensureRouteModelContext;
68
+ private getOrCreateRouteModel;
69
+ }
70
+ /**
71
+ * 将 pathname 解析结果和 pageUid 对齐,便于测试里复用。
72
+ */
73
+ export declare function toViewStack(pathname: string, options?: BaseLayoutRouteCoordinatorOptions): ViewParam[];
74
+ export {};
@@ -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 React, { type FC } from 'react';
10
+ export declare const AdminLayoutEntryGuard: FC<{
11
+ children: React.ReactNode;
12
+ }>;
@@ -7,22 +7,18 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { type FlowEngine, FlowModel } from '@nocobase/flow-engine';
10
+ import React from 'react';
10
11
  import type { NocoBaseDesktopRoute } from '../../../flow-compat';
11
- import { type RoutePageMeta } from '../AdminLayoutRouteCoordinator';
12
+ import { AdminLayoutRouteCoordinator } from '../AdminLayoutRouteCoordinator';
13
+ import { BaseLayoutModel, type BaseLayoutStructure, type GetLayoutModelOptions } from '../BaseLayoutModel';
12
14
  import { type AdminLayoutMenuItemModel } from './AdminLayoutMenuModels';
13
15
  import { type AdminLayoutMenuRouteOptions } from './AdminLayoutMenuUtils';
14
- import React from 'react';
15
- export type AdminLayoutStructure = {
16
+ export type AdminLayoutStructure = BaseLayoutStructure & {
16
17
  subModels: {
17
18
  menuItems?: AdminLayoutMenuItemModel[];
18
19
  };
19
20
  };
20
- type GetAdminLayoutModelOptions<TModel extends FlowModel = AdminLayoutModel> = {
21
- required?: boolean;
22
- create?: boolean;
23
- props?: any;
24
- use?: new (...args: any[]) => TModel;
25
- };
21
+ type GetAdminLayoutModelOptions<TModel extends FlowModel = AdminLayoutModel> = GetLayoutModelOptions<TModel>;
26
22
  /**
27
23
  * Admin Layout 的纯运行时 host model。
28
24
  *
@@ -35,14 +31,8 @@ type GetAdminLayoutModelOptions<TModel extends FlowModel = AdminLayoutModel> = {
35
31
  * model.syncMenuRoutes(routes);
36
32
  * ```
37
33
  */
38
- export declare class AdminLayoutModel extends FlowModel<AdminLayoutStructure> {
39
- isMobileLayout: boolean;
34
+ export declare class AdminLayoutModel extends BaseLayoutModel<AdminLayoutStructure> {
40
35
  menuRouteRefreshVersion: number;
41
- private routeCoordinator?;
42
- private routeDisposer?;
43
- private activePageUid;
44
- private layoutContentElement;
45
- private readonly routePageMetaMap;
46
36
  constructor(options: any);
47
37
  /**
48
38
  * 通知 Layout 重新生成 ProLayout 菜单路由。
@@ -50,29 +40,6 @@ export declare class AdminLayoutModel extends FlowModel<AdminLayoutStructure> {
50
40
  * @returns {void}
51
41
  */
52
42
  refreshMenuRouteTree(): void;
53
- /**
54
- * 注册页面运行时信息。
55
- *
56
- * @param {string} pageUid 页面 UID
57
- * @param {RoutePageMeta} meta 页面运行时元数据
58
- * @returns {FlowModel} 对应的页面模型
59
- */
60
- registerRoutePage(pageUid: string, meta: RoutePageMeta): FlowModel<import("@nocobase/flow-engine").DefaultStructure>;
61
- /**
62
- * 更新页面运行时信息。
63
- *
64
- * @param {string} pageUid 页面 UID
65
- * @param {Partial<RoutePageMeta>} meta 待更新的页面元数据
66
- * @returns {void}
67
- */
68
- updateRoutePage(pageUid: string, meta: Partial<RoutePageMeta>): void;
69
- /**
70
- * 注销页面运行时信息。
71
- *
72
- * @param {string} pageUid 页面 UID
73
- * @returns {void}
74
- */
75
- unregisterRoutePage(pageUid: string): void;
76
43
  /**
77
44
  * 使用当前可访问菜单路由刷新 Layout 菜单树。
78
45
  *
@@ -90,59 +57,7 @@ export declare class AdminLayoutModel extends FlowModel<AdminLayoutStructure> {
90
57
  path: string;
91
58
  children: import("./AdminLayoutMenuUtils").AdminLayoutMenuNode[];
92
59
  };
93
- /**
94
- * 设置布局内容容器元素。
95
- *
96
- * @param {HTMLElement | null} element 布局内容容器
97
- * @returns {void}
98
- */
99
- setLayoutContentElement(element: HTMLElement | null): void;
100
- /**
101
- * 设置是否为移动端布局。
102
- *
103
- * @param {boolean} isMobileLayout 是否为移动端布局
104
- * @returns {void}
105
- */
106
- setIsMobileLayout(isMobileLayout: boolean): void;
107
- protected onMount(): void;
108
- protected onUnmount(): void;
109
- /**
110
- * 安装运行时上下文属性。
111
- *
112
- * @returns {void}
113
- */
114
- private setupContextBindings;
115
- /**
116
- * 安装路由同步 reaction。
117
- *
118
- * @returns {void}
119
- */
120
- private setupRouteReaction;
121
- /**
122
- * 释放运行时状态。
123
- *
124
- * @returns {void}
125
- */
126
- private teardownRuntime;
127
- /**
128
- * 获取当前激活页面对应的路由对象。
129
- *
130
- * @returns {any} 当前激活页面对应的路由对象
131
- */
132
- private getCurrentRouteByActivePage;
133
- /**
134
- * 根据页面 UID 获取路由对象。
135
- *
136
- * @param {string} pageUid 页面 UID
137
- * @returns {any} 路由对象
138
- */
139
- private getCurrentRouteByPageUid;
140
- /**
141
- * 懒加载页面路由协调器。
142
- *
143
- * @returns {AdminLayoutRouteCoordinator} 路由协调器实例
144
- */
145
- private getCoordinator;
60
+ protected createRouteCoordinator(): AdminLayoutRouteCoordinator;
146
61
  render(): React.JSX.Element;
147
62
  }
148
63
  /**
@@ -8,6 +8,8 @@
8
8
  */
9
9
  export * from './AdminLayoutComponent';
10
10
  export * from './AdminLayoutModel';
11
+ export * from '../BaseLayoutModel';
12
+ export * from '../BaseLayoutRouteCoordinator';
11
13
  export * from './AdminLayoutSlotModels';
12
14
  export * from './AdminLayoutMenuModels';
13
15
  export * from './AdminLayoutMenuFlowUtils';
@@ -6,14 +6,14 @@
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
- /// <reference types="react" />
10
9
  import type { FlowEngine } from '@nocobase/flow-engine';
10
+ import type { RefObject } from 'react';
11
11
  import { type AdminLayoutModel } from './admin-layout/AdminLayoutModel';
12
12
  type UseAdminLayoutRoutePageOptions = {
13
13
  flowEngine: FlowEngine;
14
14
  pageUid: string;
15
15
  refreshDesktopRoutes?: () => Promise<unknown>;
16
- layoutContentRef: React.RefObject<HTMLDivElement>;
16
+ layoutContentRef: RefObject<HTMLDivElement>;
17
17
  };
18
18
  /**
19
19
  * 把 FlowRoute 页面的生命周期桥接到 AdminLayout host model。
@@ -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 { FlowEngine } from '@nocobase/flow-engine';
10
+ import { type RefObject } from 'react';
11
+ import type { BaseLayoutModel } from './BaseLayoutModel';
12
+ export type UseLayoutRoutePageOptions<TModel extends BaseLayoutModel = BaseLayoutModel> = {
13
+ flowEngine: FlowEngine;
14
+ pageUid: string;
15
+ active?: boolean;
16
+ refreshDesktopRoutes?: () => Promise<unknown>;
17
+ layoutContentRef: RefObject<HTMLElement>;
18
+ getLayoutModel: (flowEngine: FlowEngine) => TModel | undefined;
19
+ };
20
+ /**
21
+ * 把 FlowRoute 页面的生命周期桥接到指定 Layout host model。
22
+ */
23
+ export declare function useLayoutRoutePage<TModel extends BaseLayoutModel = BaseLayoutModel>(options: UseLayoutRoutePageOptions<TModel>): TModel;
@@ -6,7 +6,16 @@
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 { type FlowEngine } from '@nocobase/flow-engine';
9
10
  import React from 'react';
11
+ import { type BaseLayoutModel } from '../admin-shell/BaseLayoutModel';
12
+ export type LegacyPageBehavior = 'redirect' | 'notFound' | 'bridge';
13
+ export type FlowRouteProps = {
14
+ pageUid?: string;
15
+ active?: boolean;
16
+ getLayoutModel?: (flowEngine: FlowEngine) => BaseLayoutModel | undefined;
17
+ legacyPageBehavior?: LegacyPageBehavior;
18
+ };
10
19
  /**
11
20
  * 管理后台动态页面路由组件。
12
21
  *
@@ -22,7 +31,7 @@ import React from 'react';
22
31
  * @throws {Error} 当缺少 `route.params.name` 时抛出异常
23
32
  */
24
33
  declare const FlowRoute: {
25
- (): React.JSX.Element;
34
+ (props?: FlowRouteProps): React.JSX.Element;
26
35
  displayName: string;
27
36
  };
28
37
  export default FlowRoute;
@@ -23,7 +23,11 @@ export * from './utils';
23
23
  export * from './actions';
24
24
  export * from './system-settings';
25
25
  export * from './admin-shell/admin-layout';
26
+ export * from './admin-shell/BaseLayoutModel';
27
+ export * from './admin-shell/BaseLayoutRouteCoordinator';
26
28
  export * from './admin-shell/AdminLayoutRouteCoordinator';
29
+ export * from './admin-shell/useLayoutRoutePage';
30
+ export * from './admin-shell/useAdminLayoutRoutePage';
27
31
  export * from '../settings-center';
28
32
  export { openViewFlow } from './flows/openViewFlow';
29
33
  export { editMarkdownFlow } from './flows/editMarkdownFlow';
@@ -32,9 +32,11 @@ export declare class PageModel extends FlowModel<PageModelStructure> {
32
32
  private getEnableTabs;
33
33
  private getActiveTabKey;
34
34
  private scheduleActiveLifecycleRefresh;
35
+ activateCurrentTab(forceRefresh?: boolean): void;
36
+ deactivateCurrentTab(): void;
35
37
  onMount(): void;
36
38
  protected onUnmount(): void;
37
- invokeTabModelLifecycleMethod(tabActiveKey: string, method: 'onActive' | 'onInactive', forceRefresh?: boolean): void;
39
+ invokeTabModelLifecycleMethod(tabActiveKey: string | undefined, method: 'onActive' | 'onInactive', forceRefresh?: boolean): void;
38
40
  /**
39
41
  * Resolve configured document title template and update browser tab title.
40
42
  * Priority:
@@ -10,4 +10,5 @@ import { ActionGroupModel } from '../../base/ActionGroupModel';
10
10
  import { FormActionModel } from './FormActionModel';
11
11
  export declare class FormActionGroupModel extends ActionGroupModel {
12
12
  static baseClass: typeof FormActionModel;
13
+ static defineChildren(ctx: any): Promise<any[]>;
13
14
  }
@@ -61,8 +61,18 @@ export declare class TableBlockModel extends CollectionBlockModel<TableBlockMode
61
61
  cell: React.MemoExoticComponent<import("@formily/reactive-react").ReactFC<Omit<any, "ref">>>;
62
62
  };
63
63
  };
64
+ isRowSelectionEnabled(): boolean;
65
+ isShowIndexEnabled(): boolean;
66
+ getRecordIndex(record: Record<string, unknown>, index: number): string | number;
67
+ getLeftAuxiliaryColumn(): {
68
+ key: string;
69
+ width: number;
70
+ align: "center";
71
+ render: (_value: unknown, record: Record<string, unknown>, index: number) => React.JSX.Element;
72
+ };
64
73
  renderCell: (checked: any, record: any, index: any, originNode: any) => any;
65
74
  renderConfigureActions(): React.JSX.Element;
75
+ shouldRenderAction(action: ActionModel, isConfigMode: boolean): boolean;
66
76
  pagination(): import("antd").PaginationProps;
67
77
  renderComponent(): React.JSX.Element;
68
78
  }
@@ -8,7 +8,7 @@ export declare class SubTableFieldModel extends AssociationFieldModel {
8
8
  updateAssociation: boolean;
9
9
  setCurrentPage: any;
10
10
  currentPageSize: any;
11
- getCurrentValue: () => any[];
11
+ getCurrentValue(): any[];
12
12
  get collection(): any;
13
13
  getColumns(): any;
14
14
  render(): React.JSX.Element;
package/es/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export * from './WebSocketClient';
24
24
  export * from './RouterManager';
25
25
  export * from './PluginManager';
26
26
  export * from './PluginSettingsManager';
27
+ export * from './layout-manager';
27
28
  export * from './hooks';
28
29
  export { default as languageCodes } from './locale/languageCodes';
29
30
  export * from './nocobase-buildin-plugin';