@nocobase/client-v2 2.3.0-alpha.1 → 3.0.0-alpha.2

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/acl/ACLProvider.d.ts +10 -0
  2. package/es/authRedirect.d.ts +5 -0
  3. package/es/components/AttachmentUpload.d.ts +51 -0
  4. package/es/components/form/ScanInput/useCodeScanner.d.ts +2 -2
  5. package/es/components/index.d.ts +1 -0
  6. package/es/flow/actions/linkageRules.d.ts +1 -0
  7. package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
  8. package/es/flow/components/FlowRoute.d.ts +2 -2
  9. package/es/flow/internal/registerDeviceTypeContext.d.ts +10 -0
  10. package/es/flow/models/base/ActionModelCore.d.ts +4 -2
  11. package/es/flow/models/base/BlockGridModel.d.ts +3 -0
  12. package/es/flow/models/blocks/table/TableColumnModel.d.ts +1 -0
  13. package/es/flow/models/fields/DateTimeFieldModel/dateLimit.d.ts +15 -7
  14. package/es/index.d.ts +4 -1
  15. package/es/index.mjs +139 -125
  16. package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
  17. package/es/nocobase-buildin-plugin/index.d.ts +9 -0
  18. package/es/settings-app/SettingsApplication.d.ts +18 -0
  19. package/es/settings-app/SettingsBrand.d.ts +16 -0
  20. package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
  21. package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
  22. package/es/settings-app/SettingsGroupNav.d.ts +17 -0
  23. package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
  24. package/es/settings-app/SettingsRouterManager.d.ts +15 -0
  25. package/es/settings-app/SettingsSearch.d.ts +17 -0
  26. package/es/settings-app/SettingsShell.d.ts +10 -0
  27. package/es/settings-app/isSettingsApp.d.ts +18 -0
  28. package/es/settings-app/runtimePaths.d.ts +18 -0
  29. package/es/settings-app/settingsDocumentPath.d.ts +14 -0
  30. package/es/settings-app/settingsTheme.d.ts +87 -0
  31. package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
  32. package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
  33. package/es/settings-center/groups.d.ts +66 -0
  34. package/es/settings-center/useSettingsGroups.d.ts +36 -0
  35. package/es/settings-center/useSettingsSearch.d.ts +35 -0
  36. package/es/settings-center/utils.d.ts +24 -0
  37. package/es/theme/index.d.ts +1 -0
  38. package/es/theme/itemActive.d.ts +24 -0
  39. package/es/theme/type.d.ts +9 -0
  40. package/lib/index.js +141 -127
  41. package/lib/locale/languageCodes.js +1 -0
  42. package/package.json +8 -7
  43. package/src/__tests__/authRedirect.test.ts +137 -0
  44. package/src/__tests__/browserChecker.test.ts +124 -6
  45. package/src/__tests__/mockSettingsApplication.ts +29 -0
  46. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +51 -10
  47. package/src/__tests__/plugin-manager.test.tsx +7 -6
  48. package/src/__tests__/settings-application.test.ts +164 -0
  49. package/src/__tests__/settings-auth-routes.test.ts +71 -0
  50. package/src/__tests__/settings-center.test.tsx +38 -37
  51. package/src/__tests__/settings-layout-root.test.tsx +260 -0
  52. package/src/__tests__/settings-runtime-paths.test.ts +99 -0
  53. package/src/__tests__/settings-shell.test.tsx +200 -0
  54. package/src/acl/ACLProvider.tsx +21 -0
  55. package/src/authRedirect.ts +72 -3
  56. package/src/components/AttachmentUpload.tsx +275 -0
  57. package/src/components/form/ScanInput/CodeScanner.tsx +61 -34
  58. package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +101 -0
  59. package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +114 -18
  60. package/src/components/form/ScanInput/useCodeScanner.ts +166 -23
  61. package/src/components/index.ts +1 -0
  62. package/src/flow/__tests__/FlowRoute.test.tsx +126 -8
  63. package/src/flow/__tests__/PluginFlowEngine.test.ts +58 -0
  64. package/src/flow/actions/__tests__/actionLinkageRules.forkProps.test.ts +314 -0
  65. package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +102 -0
  66. package/src/flow/actions/linkageRules.tsx +26 -6
  67. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -56
  68. package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
  69. package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
  70. package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +77 -13
  71. package/src/flow/common/Markdown/style.ts +4 -0
  72. package/src/flow/components/BlockItemCard.tsx +2 -2
  73. package/src/flow/components/FlowRoute.tsx +71 -29
  74. package/src/flow/index.ts +2 -0
  75. package/src/flow/internal/registerDeviceTypeContext.ts +39 -0
  76. package/src/flow/models/base/ActionModelCore.tsx +11 -2
  77. package/src/flow/models/base/BlockGridModel.tsx +26 -0
  78. package/src/flow/models/base/CollectionBlockModel.tsx +6 -2
  79. package/src/flow/models/base/PageModel/PageTabModel.tsx +67 -17
  80. package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +509 -12
  81. package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +49 -0
  82. package/src/flow/models/base/__tests__/BlockGridModel.selectSceneActivation.test.ts +124 -0
  83. package/src/flow/models/base/__tests__/CollectionBlockModel.addAppends.test.ts +41 -0
  84. package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +27 -3
  85. package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +32 -4
  86. package/src/flow/models/blocks/js-block/JSBlock.tsx +1 -1
  87. package/src/flow/models/blocks/table/TableBlockModel.tsx +3 -1
  88. package/src/flow/models/blocks/table/TableColumnModel.tsx +30 -1
  89. package/src/flow/models/blocks/table/__tests__/TableBlockModel.quickEditRefresh.test.ts +12 -0
  90. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +33 -0
  91. package/src/flow/models/fields/DateTimeFieldModel/__tests__/DateTimeNoTzFieldModel.dateLimit.test.tsx +149 -0
  92. package/src/flow/models/fields/DateTimeFieldModel/dateLimit.ts +149 -113
  93. package/src/flow/models/fields/JsonFieldModel.tsx +31 -8
  94. package/src/flow/models/fields/__tests__/JsonFieldModel.test.ts +82 -0
  95. package/src/flow/models/topbar/TopbarActionModel.tsx +52 -180
  96. package/src/flow/utils/dataScopeFormValueClear.ts +4 -3
  97. package/src/index.ts +10 -1
  98. package/src/locale/languageCodes.ts +1 -0
  99. package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
  100. package/src/nocobase-buildin-plugin/index.tsx +99 -71
  101. package/src/settings-app/SettingsApplication.ts +31 -0
  102. package/src/settings-app/SettingsBrand.tsx +108 -0
  103. package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
  104. package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
  105. package/src/settings-app/SettingsGroupNav.tsx +124 -0
  106. package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
  107. package/src/settings-app/SettingsRouterManager.ts +92 -0
  108. package/src/settings-app/SettingsSearch.tsx +238 -0
  109. package/src/settings-app/SettingsShell.tsx +167 -0
  110. package/src/settings-app/isSettingsApp.ts +21 -0
  111. package/src/settings-app/runtimePaths.ts +104 -0
  112. package/src/settings-app/settingsDocumentPath.ts +66 -0
  113. package/src/settings-app/settingsTheme.ts +301 -0
  114. package/src/settings-app/useSettingsThemeConfig.ts +100 -0
  115. package/src/settings-center/AdminSettingsLayout.tsx +122 -141
  116. package/src/settings-center/SystemSettingsPage.tsx +4 -170
  117. package/src/settings-center/groups.ts +108 -0
  118. package/src/settings-center/useSettingsGroups.ts +105 -0
  119. package/src/settings-center/useSettingsSearch.ts +173 -0
  120. package/src/settings-center/utils.tsx +50 -1
  121. package/src/theme/index.tsx +1 -0
  122. package/src/theme/itemActive.ts +31 -0
  123. 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
  */
@@ -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
  };
@@ -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;
@@ -15,7 +15,6 @@ type UseCodeScannerOptions = {
15
15
  enabled: boolean;
16
16
  elementId: string;
17
17
  formatsToSupport?: CodeFormatsToSupport;
18
- scanBoxSize?: ScannerSize;
19
18
  onScannerSizeChanged?: (size: ScannerSize) => void;
20
19
  onScanSuccess: (text: string) => void;
21
20
  onScanFailure?: () => void;
@@ -26,7 +25,8 @@ export declare function getCodeScanBoxSize(width: number, height: number): {
26
25
  width: number;
27
26
  height: number;
28
27
  };
29
- export declare function useCodeScanner({ enabled, elementId, formatsToSupport, scanBoxSize, onScannerSizeChanged, onScanSuccess, onScanFailure, onCameraStartFailure, }: UseCodeScannerOptions): {
28
+ export declare function scanQrVideoFrame(video: HTMLVideoElement, canvas: HTMLCanvasElement): string;
29
+ export declare function useCodeScanner({ enabled, elementId, formatsToSupport, onScannerSizeChanged, onScanSuccess, onScanFailure, onCameraStartFailure, }: UseCodeScannerOptions): {
30
30
  startScanFile: (file: File) => Promise<void>;
31
31
  };
32
32
  export {};
@@ -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';
@@ -7,6 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { FlowContext, FlowModel } from '@nocobase/flow-engine';
10
+ export declare function updateLinkageRules<T>(rules: T[], updater: (nextRules: T[]) => void): T[];
10
11
  export declare const linkageSetBlockProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
11
12
  export declare const linkageSetActionProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
12
13
  export declare const linkageSetMenuItemProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
@@ -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>>;
@@ -19,8 +19,8 @@ export type FlowRouteProps = {
19
19
  /**
20
20
  * 管理后台动态页面路由组件。
21
21
  *
22
- * 负责读取当前路由页面 UID,补充运行时设备变量,
23
- * 并把页面生命周期桥接到 AdminLayout host model。
22
+ * 负责读取当前路由页面 UID,并把页面生命周期桥接到 AdminLayout host model。
23
+ * 设备变量通常由 PluginFlowEngine 共享初始化提供;独立渲染时会在挂载后补充注册。
24
24
  *
25
25
  * @example
26
26
  * ```tsx
@@ -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 type { FlowEngine } from '@nocobase/flow-engine';
10
+ export declare const registerDeviceTypeContext: (flowEngine: FlowEngine) => void;
@@ -6,7 +6,8 @@
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 { DefaultStructure, FlowModel } from '@nocobase/flow-engine';
9
+ import { FlowModel } from '@nocobase/flow-engine';
10
+ import type { DefaultStructure, FlowModelOptions } from '@nocobase/flow-engine';
10
11
  import type { ButtonProps } from 'antd/es/button';
11
12
  import React from 'react';
12
13
  export declare function ActionWithoutPermission(props: any): React.JSX.Element;
@@ -41,7 +42,8 @@ export declare class ActionModel<T extends DefaultStructure = DefaultStructure>
41
42
  static _getScene(): any[];
42
43
  static _isScene(scene: ActionSceneType): boolean;
43
44
  getAclActionName(): any;
44
- onInit(options: any): void;
45
+ onInit(options: FlowModelOptions<T>): void;
46
+ serialize(): Record<string, any>;
45
47
  getInputArgs(): Record<string, any>;
46
48
  onClick(event: any): void;
47
49
  getTitle(): string;
@@ -11,8 +11,11 @@ import React from 'react';
11
11
  import { FilterManager } from '../blocks/filter-manager/FilterManager';
12
12
  import { GridModel } from './GridModel';
13
13
  export declare class BlockGridModel extends GridModel {
14
+ private viewActivatedListener?;
14
15
  dragOverlayConfig: DragOverlayConfig;
15
16
  onInit(options: any): void;
17
+ onMount(): void;
18
+ protected onUnmount(): void;
16
19
  get subModelBaseClasses(): string[];
17
20
  get filterManager(): FilterManager;
18
21
  get addBlockItems(): SubModelItemsType | undefined;
@@ -23,6 +23,7 @@ export declare class TableColumnModel extends DisplayItemModel {
23
23
  afterAddAsSubModel(): Promise<void>;
24
24
  renderHiddenInConfig(): React.ReactNode | undefined;
25
25
  static defineChildren(ctx: FlowModelContext): any;
26
+ canQuickEdit(record: Record<string, unknown>): boolean;
26
27
  getColumnProps(): TableColumnProps & {
27
28
  sortField?: string;
28
29
  };
@@ -6,15 +6,23 @@
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 { Dayjs } from 'dayjs';
9
10
  type DateLimitProps = {
10
- _minDate?: any;
11
- _maxDate?: any;
12
- currentForm?: any;
11
+ _minDate?: unknown;
12
+ _maxDate?: unknown;
13
+ currentForm?: unknown;
13
14
  };
15
+ type DisabledTimeConfig = {
16
+ disabledHours: () => number[];
17
+ disabledMinutes: (selectedHour: number) => number[];
18
+ disabledSeconds: (selectedHour: number, selectedMinute: number) => number[];
19
+ };
20
+ type DisabledDate = (current: Dayjs) => boolean;
21
+ type DisabledTime = (current: Dayjs | null) => DisabledTimeConfig;
14
22
  export declare function useDateLimit(props: DateLimitProps): {
15
- minDate: any;
16
- maxDate: any;
17
- disabledDate: any;
18
- disabledTime: any;
23
+ minDate: Dayjs;
24
+ maxDate: Dayjs;
25
+ disabledDate: DisabledDate;
26
+ disabledTime: DisabledTime;
19
27
  };
20
28
  export {};
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, 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';
@@ -46,3 +47,5 @@ export { DEFAULT_DATA_SOURCE_KEY, IconPicker, isTitleField, isTitleFieldInterfac
46
47
  export type { NocoBaseDesktopRoute } from './flow-compat';
47
48
  export * from './utils/markdownSanitize';
48
49
  export { default as AntdAppProvider } from './theme/AntdAppProvider';
50
+ export { isSettingsApp } from './settings-app/isSettingsApp';
51
+ export { MINIMAL_THEME_UID, useSettingsThemeConfig } from './settings-app/useSettingsThemeConfig';