@nocobase/client-v2 2.3.0-beta.6 → 2.4.0-alpha.1

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 (90) hide show
  1. package/es/acl/ACLProvider.d.ts +10 -0
  2. package/es/acl/aclCheckReadiness.d.ts +11 -0
  3. package/es/authRedirect.d.ts +11 -2
  4. package/es/components/AttachmentUpload.d.ts +51 -0
  5. package/es/components/index.d.ts +1 -0
  6. package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
  7. package/es/index.d.ts +4 -1
  8. package/es/index.mjs +129 -118
  9. package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
  10. package/es/nocobase-buildin-plugin/index.d.ts +10 -0
  11. package/es/settings-app/SettingsApplication.d.ts +18 -0
  12. package/es/settings-app/SettingsBrand.d.ts +16 -0
  13. package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
  14. package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
  15. package/es/settings-app/SettingsGroupNav.d.ts +18 -0
  16. package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
  17. package/es/settings-app/SettingsRouterManager.d.ts +15 -0
  18. package/es/settings-app/SettingsSearch.d.ts +17 -0
  19. package/es/settings-app/SettingsShell.d.ts +10 -0
  20. package/es/settings-app/isSettingsApp.d.ts +18 -0
  21. package/es/settings-app/runtimePaths.d.ts +18 -0
  22. package/es/settings-app/settingsDocumentPath.d.ts +14 -0
  23. package/es/settings-app/settingsTheme.d.ts +87 -0
  24. package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
  25. package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
  26. package/es/settings-center/groups.d.ts +66 -0
  27. package/es/settings-center/useSettingsGroups.d.ts +36 -0
  28. package/es/settings-center/useSettingsSearch.d.ts +35 -0
  29. package/es/settings-center/utils.d.ts +24 -0
  30. package/es/theme/index.d.ts +1 -0
  31. package/es/theme/itemActive.d.ts +24 -0
  32. package/es/theme/type.d.ts +9 -0
  33. package/lib/index.js +157 -146
  34. package/package.json +7 -7
  35. package/src/__tests__/app.test.tsx +122 -3
  36. package/src/__tests__/authRedirect.test.ts +154 -0
  37. package/src/__tests__/browserChecker.test.ts +172 -6
  38. package/src/__tests__/mockSettingsApplication.ts +29 -0
  39. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +81 -8
  40. package/src/__tests__/plugin-manager.test.tsx +7 -6
  41. package/src/__tests__/settings-application.test.ts +164 -0
  42. package/src/__tests__/settings-auth-routes.test.ts +71 -0
  43. package/src/__tests__/settings-center.test.tsx +168 -130
  44. package/src/__tests__/settings-layout-root.test.tsx +600 -0
  45. package/src/__tests__/settings-runtime-paths.test.ts +99 -0
  46. package/src/__tests__/settings-search-shortcut.test.tsx +321 -0
  47. package/src/__tests__/settings-shell.test.tsx +261 -0
  48. package/src/acl/ACLProvider.tsx +53 -3
  49. package/src/acl/aclCheckReadiness.ts +44 -0
  50. package/src/authRedirect.ts +85 -8
  51. package/src/components/AppComponents.tsx +16 -7
  52. package/src/components/AttachmentUpload.tsx +275 -0
  53. package/src/components/index.ts +1 -0
  54. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -56
  55. package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
  56. package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
  57. package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +77 -13
  58. package/src/flow/internal/components/Markdown/DisplayMarkdown.tsx +14 -9
  59. package/src/flow/internal/components/Markdown/__tests__/DisplayMarkdown.test.tsx +46 -0
  60. package/src/flow/models/fields/DisplayHtmlFieldModel.tsx +2 -1
  61. package/src/flow/models/fields/RichTextFieldModel/__tests__/RichTextFieldModel.test.tsx +74 -0
  62. package/src/flow/models/fields/RichTextFieldModel/index.tsx +27 -6
  63. package/src/flow/models/topbar/TopbarActionModel.tsx +52 -180
  64. package/src/index.ts +11 -1
  65. package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
  66. package/src/nocobase-buildin-plugin/index.tsx +112 -71
  67. package/src/settings-app/SettingsApplication.ts +31 -0
  68. package/src/settings-app/SettingsBrand.tsx +108 -0
  69. package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
  70. package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
  71. package/src/settings-app/SettingsGroupNav.tsx +124 -0
  72. package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
  73. package/src/settings-app/SettingsRouterManager.ts +92 -0
  74. package/src/settings-app/SettingsSearch.tsx +343 -0
  75. package/src/settings-app/SettingsShell.tsx +184 -0
  76. package/src/settings-app/isSettingsApp.ts +21 -0
  77. package/src/settings-app/runtimePaths.ts +103 -0
  78. package/src/settings-app/settingsDocumentPath.ts +66 -0
  79. package/src/settings-app/settingsTheme.ts +369 -0
  80. package/src/settings-app/useSettingsThemeConfig.ts +100 -0
  81. package/src/settings-center/AdminSettingsLayout.tsx +154 -169
  82. package/src/settings-center/SystemSettingsPage.tsx +4 -170
  83. package/src/settings-center/__tests__/groups.test.ts +25 -0
  84. package/src/settings-center/groups.ts +108 -0
  85. package/src/settings-center/useSettingsGroups.ts +105 -0
  86. package/src/settings-center/useSettingsSearch.ts +173 -0
  87. package/src/settings-center/utils.tsx +50 -1
  88. package/src/theme/index.tsx +1 -0
  89. package/src/theme/itemActive.ts +31 -0
  90. package/src/theme/type.ts +10 -0
@@ -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>>;
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';