@nocobase/client-v2 2.3.0-beta.9 → 2.4.0-alpha.10

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 (117) hide show
  1. package/es/RouteRepository.d.ts +6 -0
  2. package/es/acl/ACLProvider.d.ts +10 -0
  3. package/es/acl/aclCheckReadiness.d.ts +11 -0
  4. package/es/authRedirect.d.ts +11 -2
  5. package/es/components/AttachmentUpload.d.ts +51 -0
  6. package/es/components/index.d.ts +1 -0
  7. package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
  8. package/es/flow/components/filter/VariableFilterItem.d.ts +10 -1
  9. package/es/flow/internal/utils/quickEditDataScope.d.ts +48 -0
  10. package/es/flow/internal/utils/quickEditViewContainer.d.ts +27 -0
  11. package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +1 -0
  12. package/es/index.d.ts +4 -1
  13. package/es/index.mjs +129 -118
  14. package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
  15. package/es/nocobase-buildin-plugin/index.d.ts +10 -0
  16. package/es/settings-app/SettingsApplication.d.ts +18 -0
  17. package/es/settings-app/SettingsBrand.d.ts +16 -0
  18. package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
  19. package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
  20. package/es/settings-app/SettingsGroupNav.d.ts +18 -0
  21. package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
  22. package/es/settings-app/SettingsRouterManager.d.ts +15 -0
  23. package/es/settings-app/SettingsSearch.d.ts +17 -0
  24. package/es/settings-app/SettingsShell.d.ts +10 -0
  25. package/es/settings-app/isSettingsApp.d.ts +18 -0
  26. package/es/settings-app/runtimePaths.d.ts +18 -0
  27. package/es/settings-app/settingsDocumentPath.d.ts +14 -0
  28. package/es/settings-app/settingsTheme.d.ts +87 -0
  29. package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
  30. package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
  31. package/es/settings-center/groups.d.ts +66 -0
  32. package/es/settings-center/useSettingsGroups.d.ts +36 -0
  33. package/es/settings-center/useSettingsSearch.d.ts +35 -0
  34. package/es/settings-center/utils.d.ts +24 -0
  35. package/es/theme/index.d.ts +1 -0
  36. package/es/theme/itemActive.d.ts +24 -0
  37. package/es/theme/type.d.ts +9 -0
  38. package/lib/index.js +133 -122
  39. package/package.json +7 -7
  40. package/src/BaseApplication.tsx +2 -0
  41. package/src/RouteRepository.ts +14 -0
  42. package/src/__tests__/RouteRepository.test.ts +51 -0
  43. package/src/__tests__/app.test.tsx +135 -3
  44. package/src/__tests__/authRedirect.test.ts +154 -0
  45. package/src/__tests__/browserChecker.test.ts +172 -6
  46. package/src/__tests__/mockSettingsApplication.ts +29 -0
  47. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +81 -8
  48. package/src/__tests__/plugin-manager.test.tsx +7 -6
  49. package/src/__tests__/settings-application.test.ts +164 -0
  50. package/src/__tests__/settings-auth-routes.test.ts +71 -0
  51. package/src/__tests__/settings-center.test.tsx +168 -130
  52. package/src/__tests__/settings-layout-root.test.tsx +600 -0
  53. package/src/__tests__/settings-runtime-paths.test.ts +99 -0
  54. package/src/__tests__/settings-search-shortcut.test.tsx +321 -0
  55. package/src/__tests__/settings-shell.test.tsx +261 -0
  56. package/src/acl/ACLProvider.tsx +53 -3
  57. package/src/acl/aclCheckReadiness.ts +44 -0
  58. package/src/authRedirect.ts +85 -8
  59. package/src/components/AppComponents.tsx +16 -7
  60. package/src/components/AttachmentUpload.tsx +275 -0
  61. package/src/components/index.ts +1 -0
  62. package/src/flow/actions/__tests__/validation.test.ts +48 -0
  63. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -56
  64. package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
  65. package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
  66. package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +104 -20
  67. package/src/flow/components/filter/VariableFilterItem.tsx +14 -4
  68. package/src/flow/components/filter/__tests__/VariableFilterItem.rightMetaTree.test.tsx +158 -0
  69. package/src/flow/internal/utils/__tests__/quickEditDataScope.test.ts +156 -0
  70. package/src/flow/internal/utils/__tests__/quickEditViewContainer.test.ts +52 -0
  71. package/src/flow/internal/utils/quickEditDataScope.tsx +177 -0
  72. package/src/flow/internal/utils/quickEditViewContainer.ts +46 -0
  73. package/src/flow/models/actions/JSItemActionModel.tsx +19 -3
  74. package/src/flow/models/actions/__tests__/JSItemActionModel.test.tsx +47 -1
  75. package/src/flow/models/blocks/form/QuickEditFormModel.tsx +45 -11
  76. package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +120 -0
  77. package/src/flow/models/blocks/js-block/JSBlock.tsx +5 -1
  78. package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +23 -1
  79. package/src/flow/models/blocks/table/TableColumnModel.tsx +31 -0
  80. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +64 -0
  81. package/src/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.tsx +7 -1
  82. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +4 -3
  83. package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +9 -0
  84. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +17 -10
  85. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +6 -1
  86. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableField.disabled.test.tsx +90 -0
  87. package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordSelectFieldModel.quickCreatePopup.test.tsx +183 -0
  88. package/src/flow/models/fields/SelectFieldModel.tsx +5 -0
  89. package/src/flow/models/fields/__tests__/SelectFieldModel.test.tsx +29 -1
  90. package/src/flow/models/topbar/TopbarActionModel.tsx +52 -180
  91. package/src/index.ts +11 -1
  92. package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
  93. package/src/nocobase-buildin-plugin/index.tsx +112 -71
  94. package/src/settings-app/SettingsApplication.ts +31 -0
  95. package/src/settings-app/SettingsBrand.tsx +108 -0
  96. package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
  97. package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
  98. package/src/settings-app/SettingsGroupNav.tsx +124 -0
  99. package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
  100. package/src/settings-app/SettingsRouterManager.ts +92 -0
  101. package/src/settings-app/SettingsSearch.tsx +343 -0
  102. package/src/settings-app/SettingsShell.tsx +184 -0
  103. package/src/settings-app/isSettingsApp.ts +21 -0
  104. package/src/settings-app/runtimePaths.ts +103 -0
  105. package/src/settings-app/settingsDocumentPath.ts +66 -0
  106. package/src/settings-app/settingsTheme.ts +369 -0
  107. package/src/settings-app/useSettingsThemeConfig.ts +100 -0
  108. package/src/settings-center/AdminSettingsLayout.tsx +154 -169
  109. package/src/settings-center/SystemSettingsPage.tsx +4 -170
  110. package/src/settings-center/__tests__/groups.test.ts +25 -0
  111. package/src/settings-center/groups.ts +108 -0
  112. package/src/settings-center/useSettingsGroups.ts +105 -0
  113. package/src/settings-center/useSettingsSearch.ts +173 -0
  114. package/src/settings-center/utils.tsx +50 -1
  115. package/src/theme/index.tsx +1 -0
  116. package/src/theme/itemActive.ts +31 -0
  117. package/src/theme/type.ts +10 -0
@@ -72,6 +72,12 @@ export declare class RouteRepository {
72
72
  * @returns 当前可访问的路由数组
73
73
  */
74
74
  ensureAccessibleLoaded(): Promise<any>;
75
+ /**
76
+ * 清空所有布局的路由缓存,并丢弃清空前发起的请求结果。
77
+ *
78
+ * 用于登录态失效(如退出登录)时,避免下一个用户沿用上一个用户的可访问路由。
79
+ */
80
+ clear(): void;
75
81
  /**
76
82
  * 订阅路由缓存变化,用于驱动 React 上下文刷新。
77
83
  *
@@ -43,6 +43,16 @@ export declare const ACLRolesCheckProvider: FC;
43
43
  * 返回原始 ACL provider 上下文。
44
44
  */
45
45
  export declare const useACLContext: () => ACLContextValue;
46
+ /**
47
+ * 读取当前角色的 snippets,且不要求调用方位于 `ACLRolesCheckProvider` 之内。
48
+ *
49
+ * 设置中心顶栏导航挂在 app 级 provider 上,位置比 `ACLRolesCheckProvider` 更外层,
50
+ * 这种情况下退回到 app context 上的 ACL observable store。
51
+ * 调用方需要用 `observer` 包裹,store 更新后才会重新渲染。
52
+ *
53
+ * @returns {string[]} 当前角色的 snippets
54
+ */
55
+ export declare const useACLSnippets: () => string[];
46
56
  /**
47
57
  * 触发当前角色权限重新检查。
48
58
  */
@@ -0,0 +1,11 @@
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 getACLCheckReady(app: object): boolean;
10
+ export declare function setACLCheckReady(app: object, ready: boolean): void;
11
+ export declare function useACLCheckReady(app: object): boolean;
@@ -8,6 +8,11 @@
8
8
  */
9
9
  import type { BaseApplication } from './BaseApplication';
10
10
  type AppLike = Pick<BaseApplication<any>, 'getPublicPath'> & {
11
+ name?: string;
12
+ pluginSettingsManager?: {
13
+ getRouteName?: (name: string) => string;
14
+ getRoutePath?: (name: string) => string;
15
+ };
11
16
  router?: {
12
17
  getBasename?: () => string | undefined;
13
18
  };
@@ -45,18 +50,22 @@ export declare function getCurrentV2RedirectPath(app: AppLike, locationLike: Loc
45
50
  *
46
51
  * @param app 当前 v2 应用实例
47
52
  * @param targetPath 登录后回跳地址
53
+ * @param options 可选的登录路由配置
48
54
  * @returns 指向 v2 登录页的 href
49
55
  */
50
- export declare function buildV2SigninHref(app: AppLike, targetPath: string): string;
56
+ export declare function buildV2SigninHref(app: AppLike, targetPath: string, options?: {
57
+ signInRoutePath?: string;
58
+ }): string;
51
59
  /**
52
60
  * 通过整页跳转进入 v2 登录页。
53
61
  *
54
62
  * @param app 当前 v2 应用实例
55
63
  * @param targetPath 登录后回跳地址
56
- * @param options 跳转选项
64
+ * @param options 跳转和登录路由选项
57
65
  */
58
66
  export declare function redirectToV2Signin(app: AppLike, targetPath: string, options?: {
59
67
  replace?: boolean;
68
+ signInRoutePath?: string;
60
69
  }): void;
61
70
  /**
62
71
  * 解析并校验服务端返回的 v2 登录页地址。
@@ -0,0 +1,51 @@
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 type UploadedAttachment = {
11
+ id?: number;
12
+ title?: string;
13
+ filename?: string;
14
+ url?: string;
15
+ };
16
+ export type AttachmentStorageRules = {
17
+ size?: number;
18
+ mimetype?: string | string[];
19
+ };
20
+ /**
21
+ * 读取默认附件存储的上传限制。
22
+ *
23
+ * 校验交给存储自身的配置(大小、mimetype),而不是在每个调用点各写一套硬编码规则。
24
+ *
25
+ * @returns {AttachmentStorageRules | null} 存储规则,取不到时为 null
26
+ */
27
+ export declare function useAttachmentStorageRules(): AttachmentStorageRules;
28
+ export type AttachmentUploadProps = {
29
+ value?: UploadedAttachment | null;
30
+ onChange?: (value: UploadedAttachment | null) => void;
31
+ /** 卡片尺寸;`fit` 对应 CSS object-fit */
32
+ preview?: {
33
+ width?: number;
34
+ height?: number;
35
+ fit?: 'contain' | 'cover';
36
+ };
37
+ /** 在存储规则之外再收窄可选文件类型,例如只收图片 */
38
+ accept?: string;
39
+ /** 上传卡片里 `+` 下方的文字 */
40
+ uploadText?: string;
41
+ disabled?: boolean;
42
+ };
43
+ /**
44
+ * 附件上传控件。
45
+ *
46
+ * 受控组件,值就是 `attachments:create` 返回的附件对象,可直接挂在 `Form.Item` 上。
47
+ * 外观沿用附件字段的原生形态:一张 picture-card,删除在卡片自身的悬浮操作里,不额外摆按钮。
48
+ * 上传前按默认存储的规则校验大小与 mimetype,与业务表单里的附件字段保持同一套限制。
49
+ */
50
+ export declare const AttachmentUpload: React.FC<AttachmentUploadProps>;
51
+ export default AttachmentUpload;
@@ -7,6 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export * from './AppComponents';
10
+ export * from './AttachmentUpload';
10
11
  export * from './BlankComponent';
11
12
  export * from './category-tabs';
12
13
  export * from './form/table/dnd';
@@ -0,0 +1,10 @@
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 declare const NocoBaseLogo: React.MemoExoticComponent<import("@formily/reactive-react").ReactFC<unknown>>;
@@ -27,7 +27,9 @@ export interface VariableFilterItemProps {
27
27
  rightAsVariable?: boolean;
28
28
  /**
29
29
  * 右侧 VariableInput 的 metaTree 提供器;
30
- * 默认使用整棵 ctx 的 metaTree:model.context.getPropertyMetaTree()
30
+ * 默认使用视图上下文的 metaTree:useFlowViewContext().getPropertyMetaTree()。
31
+ * 注意它取自视图上下文而非 `model.context`:当调用方传入的 model 与打开设置弹窗的模型不是同一个时,
32
+ * 右侧变量不会跟随 model 变化,需要显式传入本属性。
31
33
  */
32
34
  rightMetaTree?: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
33
35
  /**
@@ -36,6 +38,13 @@ export interface VariableFilterItemProps {
36
38
  rightVariableConverters?: Pick<Converters, 'resolvePathFromValue' | 'resolveValueFromPath'>;
37
39
  ignoreFieldNames?: string[];
38
40
  maxAssociationFieldDepth?: number;
41
+ /**
42
+ * 右侧变量树的关联层级上限,默认与 `maxAssociationFieldDepth` 一致。
43
+ * 传 `null` 表示不限制:右侧是变量树而非集合字段树,其深度可能已由调用方约束
44
+ * (例如工作流的变量树由触发器的「预加载关系数据」决定),此时再按左侧的层级上限裁剪
45
+ * 会让已配置好的深层变量选不到。
46
+ */
47
+ rightMaxAssociationFieldDepth?: number | null;
39
48
  }
40
49
  /**
41
50
  * 上下文筛选项组件
@@ -0,0 +1,48 @@
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 { FlowEngineContext, ModelConstructor } from '@nocobase/flow-engine';
10
+ import { CollectionField, FlowModel } from '@nocobase/flow-engine';
11
+ import React from 'react';
12
+ export declare const QUICK_EDIT_DATA_SCOPE_FLOW_KEY = "tableColumnSettings";
13
+ export declare const QUICK_EDIT_DATA_SCOPE_STEP_KEY = "quickEditDataScope";
14
+ export type DataScopeStepLocation = {
15
+ flowKey: string;
16
+ stepKey: string;
17
+ };
18
+ type DataScopeFilter = {
19
+ logic?: string;
20
+ items?: unknown[];
21
+ } | undefined;
22
+ /**
23
+ * Locate the flow and step that carry the shared `dataScope` action on a field model class. Both association editors
24
+ * currently keep it under `selectSettings`, but the lookup resolves it from the class instead of hard-coding that name,
25
+ * so an editor registered later is picked up without touching the quick edit path. Returns the first match.
26
+ */
27
+ export declare function findDataScopeStep(ModelClass: ModelConstructor | typeof FlowModel | undefined | null): DataScopeStepLocation | null;
28
+ /**
29
+ * Resolve the data scope step of the editor model that the quick edit popover builds for `collectionField`. Returns null
30
+ * when the field is not an association or when its default editor has no data scope step, which is what the column
31
+ * setting uses to decide whether to offer the item at all.
32
+ */
33
+ export declare function resolveQuickEditDataScopeStep(ctx: FlowEngineContext, collectionField: CollectionField): DataScopeStepLocation | null;
34
+ export declare function isEmptyDataScopeFilter(filter: DataScopeFilter): boolean;
35
+ /** Read the quick edit data scope filter stored on the table column that owns `sourceFieldModel`. */
36
+ export declare function getQuickEditDataScopeFilter(sourceFieldModel?: FlowModel): DataScopeFilter;
37
+ /**
38
+ * Context the filter builder is configured against. The setting lives on the table column, but the filter describes
39
+ * records of the association target, so `collection` points at the target collection to drive the left-hand field list.
40
+ * `record` is declared with meta only so that "Current record" is offered as a right-hand variable and describes the row
41
+ * being edited rather than whatever record an enclosing popup happens to supply; it has no value while configuring and
42
+ * resolves per row once the popover opens.
43
+ */
44
+ export declare function createQuickEditDataScopeContext(columnModel: FlowModel): Promise<import("@nocobase/flow-engine").FlowModelContext>;
45
+ export declare function QuickEditDataScopeInput(props: {
46
+ value?: Record<string, any>;
47
+ }): React.JSX.Element;
48
+ export {};
@@ -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
+ type QuickEditViewContainerLike = {
10
+ update?: (newConfig: {
11
+ preventClose?: boolean;
12
+ }) => unknown;
13
+ };
14
+ type QuickEditFieldModelLike = {
15
+ parent?: {
16
+ use?: string;
17
+ viewContainer?: QuickEditViewContainerLike;
18
+ } | null;
19
+ };
20
+ export declare function getQuickEditViewContainer(model: QuickEditFieldModelLike | undefined): QuickEditViewContainerLike;
21
+ /**
22
+ * Keeps the quick edit popover open while a nested dropdown (Select / Cascader) is open. The outside click that
23
+ * closes the dropdown would otherwise also close the popover and drop the unsaved edit. Releasing is deferred so the
24
+ * closing click itself never reaches the popover as a close request.
25
+ */
26
+ export declare function syncQuickEditPreventClose(model: QuickEditFieldModelLike | undefined, dropdownOpen: boolean): void;
27
+ export {};
@@ -37,6 +37,7 @@ export declare class QuickEditFormModel extends FlowModel {
37
37
  __onSubmitSuccess: any;
38
38
  _fieldProps: any;
39
39
  _onOk: any;
40
+ _dataScopeFilter: Record<string, any> | undefined;
40
41
  get form(): any;
41
42
  useHooksBeforeRender(): void;
42
43
  static open(options: {
package/es/index.d.ts CHANGED
@@ -27,7 +27,8 @@ export * from './PluginSettingsManager';
27
27
  export * from './layout-manager';
28
28
  export * from './hooks';
29
29
  export { default as languageCodes } from './locale/languageCodes';
30
- export * from './nocobase-buildin-plugin';
30
+ export { CurrentUserContext, NocoBaseBuildInPlugin, NocoBaseBuildInPluginV2, resolveUnauthenticatedSignInRoute, useCurrentRoles, useCurrentUserContext, } from './nocobase-buildin-plugin';
31
+ export type { CurrentRoleOption, CurrentUserState } from './nocobase-buildin-plugin';
31
32
  export { getRouteRuntimeVersion } from './utils/getRouteRuntimeVersion';
32
33
  export type { RouteRuntimeVersion } from './utils/getRouteRuntimeVersion';
33
34
  export * from './collection-field-interface/CollectionFieldInterface';
@@ -47,3 +48,5 @@ export type { NocoBaseDesktopRoute } from './flow-compat';
47
48
  export * from './utils/markdownSanitize';
48
49
  export * from './ui-operation';
49
50
  export { default as AntdAppProvider } from './theme/AntdAppProvider';
51
+ export { isSettingsApp } from './settings-app/isSettingsApp';
52
+ export { MINIMAL_THEME_UID, useSettingsThemeConfig } from './settings-app/useSettingsThemeConfig';