@nocobase/client-v2 2.1.0-beta.33 → 2.1.0-beta.34
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.
- package/es/APIClient.d.ts +16 -0
- package/es/Application.d.ts +2 -1
- package/es/authRedirect.d.ts +9 -16
- package/es/components/form/EnvVariableInput.d.ts +8 -6
- package/es/components/form/VariableInput.d.ts +73 -0
- package/es/components/form/index.d.ts +1 -0
- package/es/components/form/table/RowOverlayPreview.d.ts +27 -0
- package/es/components/form/table/SelectionCell.d.ts +36 -0
- package/es/components/form/table/Table.d.ts +82 -0
- package/es/components/form/table/constants.d.ts +15 -0
- package/es/components/form/table/dnd/SortableRow.d.ts +40 -0
- package/es/components/form/table/dnd/index.d.ts +9 -0
- package/es/components/form/table/index.d.ts +9 -0
- package/es/components/form/table/styles.d.ts +41 -0
- package/es/components/form/table/utils.d.ts +44 -0
- package/es/components/index.d.ts +2 -0
- package/es/flow/components/TextAreaWithContextSelector.d.ts +15 -0
- package/es/flow/models/blocks/table/dragSort/dragSortComponents.d.ts +1 -6
- package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +5 -1
- package/es/flow-compat/passwordUtils.d.ts +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.mjs +145 -78
- package/es/theme/globalStyles.d.ts +9 -0
- package/es/theme/index.d.ts +1 -0
- package/lib/index.js +161 -94
- package/package.json +8 -6
- package/src/APIClient.ts +68 -0
- package/src/Application.tsx +6 -2
- package/src/__tests__/authRedirect.test.ts +170 -64
- package/src/__tests__/globalDeps.test.ts +2 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +6 -6
- package/src/authRedirect.ts +23 -84
- package/src/components/form/EnvVariableInput.tsx +11 -46
- package/src/components/form/VariableInput.tsx +177 -0
- package/src/components/form/__tests__/EnvVariableInput.test.tsx +175 -0
- package/src/components/form/index.tsx +1 -0
- package/src/components/form/table/RowOverlayPreview.tsx +51 -0
- package/src/components/form/table/SelectionCell.tsx +72 -0
- package/src/components/form/table/Table.tsx +279 -0
- package/src/components/form/table/__tests__/Table.pagination.test.tsx +80 -0
- package/src/components/form/table/constants.ts +16 -0
- package/src/components/form/table/dnd/SortableRow.tsx +106 -0
- package/src/components/form/table/dnd/index.ts +10 -0
- package/src/components/form/table/index.tsx +13 -0
- package/src/components/form/table/styles.ts +110 -0
- package/src/components/form/table/utils.ts +75 -0
- package/src/components/index.ts +2 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +2 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +111 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +2 -1
- package/src/flow/components/TextAreaWithContextSelector.tsx +30 -6
- package/src/flow/components/code-editor/__tests__/useCodeRunner.test.tsx +81 -0
- package/src/flow/components/code-editor/hooks/useCodeRunner.ts +34 -2
- package/src/flow/models/blocks/table/dragSort/dragSortComponents.tsx +1 -81
- package/src/flow/models/fields/JSEditableFieldModel.tsx +107 -7
- package/src/flow/models/fields/__tests__/JSEditableFieldModel.test.tsx +97 -0
- package/src/index.ts +1 -0
- package/src/nocobase-buildin-plugin/index.tsx +4 -4
- package/src/theme/globalStyles.ts +21 -0
- package/src/theme/index.tsx +1 -0
- package/src/utils/globalDeps.ts +5 -1
|
@@ -0,0 +1,16 @@
|
|
|
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 { APIClient as APIClientSDK, type APIClientOptions } from '@nocobase/sdk';
|
|
10
|
+
export declare class APIClient extends APIClientSDK {
|
|
11
|
+
appName?: string;
|
|
12
|
+
constructor(options?: APIClientOptions);
|
|
13
|
+
getHostname(): string;
|
|
14
|
+
getHeaders(): {};
|
|
15
|
+
interceptors(): void;
|
|
16
|
+
}
|
package/es/Application.d.ts
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
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 {
|
|
9
|
+
import { type APIClientOptions } from '@nocobase/sdk';
|
|
10
10
|
import { type i18n as i18next } from 'i18next';
|
|
11
|
+
import { APIClient } from './APIClient';
|
|
11
12
|
import { BaseApplication, type BaseApplicationOptions } from './BaseApplication';
|
|
12
13
|
import type { PluginType } from './PluginManager';
|
|
13
14
|
import { PluginManager } from './PluginManager';
|
package/es/authRedirect.d.ts
CHANGED
|
@@ -17,15 +17,8 @@ type LocationLike = {
|
|
|
17
17
|
search?: string;
|
|
18
18
|
hash?: string;
|
|
19
19
|
};
|
|
20
|
+
export declare function getV2EffectiveBasePath(app: AppLike): string;
|
|
20
21
|
declare function getDefaultV2AdminRedirectPath(app: AppLike): string;
|
|
21
|
-
/**
|
|
22
|
-
* 将 v2 admin 路径转换为对应的 v1 admin 根相对路径。
|
|
23
|
-
*
|
|
24
|
-
* @param app 当前 v2 应用实例
|
|
25
|
-
* @param value 当前 v2 admin 路径或 location 对象
|
|
26
|
-
* @returns 对应的 v1 admin 根相对路径;若无法安全转换则返回 null
|
|
27
|
-
*/
|
|
28
|
-
export declare function convertV2AdminPathToLegacy(app: AppLike, value: string | LocationLike): string;
|
|
29
22
|
/**
|
|
30
23
|
* 将当前 v2 页面地址转换为根相对 redirect 路径。
|
|
31
24
|
*
|
|
@@ -35,29 +28,29 @@ export declare function convertV2AdminPathToLegacy(app: AppLike, value: string |
|
|
|
35
28
|
*/
|
|
36
29
|
export declare function getCurrentV2RedirectPath(app: AppLike, locationLike: LocationLike): string;
|
|
37
30
|
/**
|
|
38
|
-
* 构造跳转到
|
|
31
|
+
* 构造跳转到 v2 登录页的完整 href。
|
|
39
32
|
*
|
|
40
33
|
* @param app 当前 v2 应用实例
|
|
41
34
|
* @param targetPath 登录后回跳地址
|
|
42
|
-
* @returns 指向
|
|
35
|
+
* @returns 指向 v2 登录页的 href
|
|
43
36
|
*/
|
|
44
|
-
export declare function
|
|
37
|
+
export declare function buildV2SigninHref(app: AppLike, targetPath: string): string;
|
|
45
38
|
/**
|
|
46
|
-
* 通过整页跳转进入
|
|
39
|
+
* 通过整页跳转进入 v2 登录页。
|
|
47
40
|
*
|
|
48
41
|
* @param app 当前 v2 应用实例
|
|
49
42
|
* @param targetPath 登录后回跳地址
|
|
50
43
|
* @param options 跳转选项
|
|
51
44
|
*/
|
|
52
|
-
export declare function
|
|
45
|
+
export declare function redirectToV2Signin(app: AppLike, targetPath: string, options?: {
|
|
53
46
|
replace?: boolean;
|
|
54
47
|
}): void;
|
|
55
48
|
/**
|
|
56
|
-
* 解析并校验服务端返回的
|
|
49
|
+
* 解析并校验服务端返回的 v2 登录页地址。
|
|
57
50
|
*
|
|
58
51
|
* @param value 服务端返回的 redirect
|
|
59
52
|
* @param app 当前 v2 应用实例
|
|
60
|
-
* @returns 合法时返回完整同源 URL
|
|
53
|
+
* @returns 合法时返回完整同源 URL,否则返回 null
|
|
61
54
|
*/
|
|
62
|
-
export declare function
|
|
55
|
+
export declare function resolveV2SigninRedirect(value: string | undefined | null, app: AppLike): string;
|
|
63
56
|
export { getDefaultV2AdminRedirectPath };
|
|
@@ -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 {
|
|
9
|
+
import type { MetaTreeNode } from '@nocobase/flow-engine';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
/**
|
|
12
12
|
* Convert a stored value like `"{{ $env.foo.bar }}"` back into the
|
|
@@ -33,10 +33,12 @@ export interface EnvVariableInputProps {
|
|
|
33
33
|
placeholder?: string;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* Convenience wrapper around `VariableInput` constrained to the `$env`
|
|
37
|
+
* namespace, with optional password-input masking for plain values. Use for
|
|
38
|
+
* fields that accept either a literal credential or a `{{ $env.X }}`
|
|
39
|
+
* reference (S3 access keys, OAuth secrets, etc.). The `$env` tree is
|
|
40
|
+
* provided by the environment-variables plugin's
|
|
41
|
+
* `flowEngine.context.defineProperty('$env', ...)`; this component degrades
|
|
42
|
+
* gracefully to an empty picker when no env variables are defined.
|
|
41
43
|
*/
|
|
42
44
|
export declare function EnvVariableInput(props: EnvVariableInputProps): React.JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
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, type VariableHybridInputConverters } from '@nocobase/flow-engine';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export declare function parseVariablePath(value?: string): string[] | undefined;
|
|
12
|
+
export declare function formatVariablePath(meta?: MetaTreeNode): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the meta tree the variable picker should expose. Filters the global
|
|
15
|
+
* meta tree by `namespaces` (top-level property names like `'$env'`,
|
|
16
|
+
* `'$user'`), appends `extraNodes`, and eagerly resolves any lazy `children`
|
|
17
|
+
* thunks so labels render on first paint.
|
|
18
|
+
*
|
|
19
|
+
* Returns `[]` while loading or when no nodes survive the filter, mirroring
|
|
20
|
+
* the existing EnvVariableInput behavior so the picker still opens but offers
|
|
21
|
+
* nothing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useFilteredMetaTree(options: {
|
|
24
|
+
namespaces?: string[];
|
|
25
|
+
extraNodes?: MetaTreeNode[];
|
|
26
|
+
}): MetaTreeNode[];
|
|
27
|
+
export interface VariableInputProps {
|
|
28
|
+
value?: string;
|
|
29
|
+
onChange?: (value: string) => void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
addonBefore?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Restrict the picker to specific top-level meta tree namespaces (e.g.
|
|
35
|
+
* `['$env', '$user']`). When omitted, every registered top-level property is
|
|
36
|
+
* exposed. Filter happens at the picker level — the underlying regex used
|
|
37
|
+
* for pill rendering still matches any `{{ ... }}` expression so pre-existing
|
|
38
|
+
* out-of-scope values stay legible.
|
|
39
|
+
*/
|
|
40
|
+
namespaces?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Static leaves appended to the picker, after the namespace-filtered nodes.
|
|
43
|
+
* Use for ad-hoc local-only variables (e.g. `$resetLink`) that are not part
|
|
44
|
+
* of the global FlowContext registry.
|
|
45
|
+
*/
|
|
46
|
+
extraNodes?: MetaTreeNode[];
|
|
47
|
+
/**
|
|
48
|
+
* Override the converters used by the underlying `VariableHybridInput`.
|
|
49
|
+
* Mostly useful when the caller wants to constrain `formatPathToValue` to a
|
|
50
|
+
* specific namespace (see `EnvVariableInput` for that pattern).
|
|
51
|
+
*/
|
|
52
|
+
converters?: VariableHybridInputConverters;
|
|
53
|
+
className?: string;
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Inline (single-line) variable input. Renders the literal text and any
|
|
58
|
+
* `{{ ... }}` references as styled pills via `VariableHybridInput`. Use for
|
|
59
|
+
* fields like form input titles, email subject lines, or any place a single
|
|
60
|
+
* line of mixed literal+variable content is appropriate.
|
|
61
|
+
*/
|
|
62
|
+
export declare function VariableInput(props: VariableInputProps): React.JSX.Element;
|
|
63
|
+
export interface VariableTextAreaProps extends Omit<VariableInputProps, 'converters' | 'addonBefore'> {
|
|
64
|
+
rows?: number;
|
|
65
|
+
maxRows?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Multi-line variable input. Variables are inserted as raw `{{ ... }}` text at
|
|
69
|
+
* the caret rather than rendered as pills — use for email body templates and
|
|
70
|
+
* other free-form long-form text where literal display of variable expressions
|
|
71
|
+
* is desirable (the server expands them at render time).
|
|
72
|
+
*/
|
|
73
|
+
export declare function VariableTextArea(props: VariableTextAreaProps): 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
|
+
import type { RowSnapshot } from './utils';
|
|
11
|
+
/**
|
|
12
|
+
* Floating clone of the row being dragged, rendered inside a `<DragOverlay>`
|
|
13
|
+
* so it follows the cursor while the source row stays in place. We inject the
|
|
14
|
+
* snapshot's `outerHTML` straight into a mini `<table>` so every antd class
|
|
15
|
+
* (`ant-table-cell`, `ant-table-selection-column`, theme tokens, etc.) is
|
|
16
|
+
* preserved. A `<colgroup>` re-applies the measured cell widths so the clone
|
|
17
|
+
* lines up column-for-column with the source row; the wrapper's pinned
|
|
18
|
+
* `height` + table `height:100%` keeps vertical sizing consistent regardless
|
|
19
|
+
* of which antd table size variant the caller picked.
|
|
20
|
+
*
|
|
21
|
+
* The wrapper also carries `overlayCellStylesClassName` so the index numeric
|
|
22
|
+
* (`.nb-table-index`) is hidden while dragging — only the handle + checkbox
|
|
23
|
+
* are surfaced inside the floating clone.
|
|
24
|
+
*/
|
|
25
|
+
export declare function RowOverlayPreview(props: {
|
|
26
|
+
snapshot: RowSnapshot;
|
|
27
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 SelectionCellProps {
|
|
11
|
+
/** Whether the row is currently selected — drives the index/checkbox swap. */
|
|
12
|
+
checked: boolean;
|
|
13
|
+
/** Zero-based row index (within the current page). `TableIndex` displays it as `index + 1`. */
|
|
14
|
+
index: number;
|
|
15
|
+
/** Render the drag handle on the left gutter. Mutually exclusive with `showStandaloneHandle`. */
|
|
16
|
+
showHandle: boolean;
|
|
17
|
+
/** Render the row index numeric. When `false` only the antd checkbox is shown (default antd UX). */
|
|
18
|
+
showIndex: boolean;
|
|
19
|
+
/** The original antd checkbox node produced by `rowSelection.renderCell`. */
|
|
20
|
+
originalNode: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The body half of the rowSelection column. Renders, in order:
|
|
24
|
+
* 1. An absolute-positioned drag handle pinned to the left gutter (only
|
|
25
|
+
* when `showHandle` is true). The parent `<td>` must be
|
|
26
|
+
* `position: relative` for the handle to land inside the gutter —
|
|
27
|
+
* `selectionGutterClassName` in `styles.ts` adds that.
|
|
28
|
+
* 2. A `.nb-row-selection-cell` wrapper that contains both the row index
|
|
29
|
+
* and the checkbox. CSS in `indexSwapClassName` swaps which one is
|
|
30
|
+
* visible depending on hover / `checked` state.
|
|
31
|
+
*
|
|
32
|
+
* When `showIndex` is false we drop the swap entirely and render only the
|
|
33
|
+
* original antd checkbox — matches the default antd selection column UX for
|
|
34
|
+
* tables that don't want the index numeric.
|
|
35
|
+
*/
|
|
36
|
+
export declare function SelectionCell(props: SelectionCellProps): React.JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 TableProps as AntdTableProps } from 'antd';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { type RowKey } from './utils';
|
|
12
|
+
/**
|
|
13
|
+
* Default initial page size for `Table`. Exposed so consumers can seed their
|
|
14
|
+
* controlled `pageSize` state with the same value the component would use if
|
|
15
|
+
* they relied purely on the built-in pagination defaults.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_PAGE_SIZE = 50;
|
|
18
|
+
/**
|
|
19
|
+
* Default `pageSizeOptions` injected into the pagination config. Matches the
|
|
20
|
+
* v1 settings-page table so users see the same choices across versions.
|
|
21
|
+
* Consumers can override by passing their own `pageSizeOptions` in
|
|
22
|
+
* `pagination`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PAGE_SIZE_OPTIONS: readonly number[];
|
|
25
|
+
export interface TableProps<RecordType extends object = any> extends AntdTableProps<RecordType> {
|
|
26
|
+
/**
|
|
27
|
+
* Required so drag-sort, hover-swap and row identity work. Accepts the same
|
|
28
|
+
* shape as antd `Table.rowKey`. When passed as a function it gets the
|
|
29
|
+
* record + index and must return a serializable id.
|
|
30
|
+
*/
|
|
31
|
+
rowKey: RowKey<RecordType>;
|
|
32
|
+
/**
|
|
33
|
+
* Show row index (1, 2, 3, …) in the rowSelection column by default; hovering
|
|
34
|
+
* a row or selecting it reveals the checkbox in the same cell. Requires
|
|
35
|
+
* `rowSelection` — the index lives in the selection column. Defaults to
|
|
36
|
+
* `true`.
|
|
37
|
+
*/
|
|
38
|
+
showIndex?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Enable vertical drag-and-drop row reordering. When true, rows show a drag
|
|
41
|
+
* handle on the left and `onSortEnd` fires after each drop. Defaults to
|
|
42
|
+
* `false`; the rest of the table behaves like a plain antd Table.
|
|
43
|
+
*/
|
|
44
|
+
isDraggable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Called after a row is dropped onto another. Only used when `isDraggable`
|
|
47
|
+
* is true. The caller persists the move (e.g. `resource.move(...)`) and
|
|
48
|
+
* refreshes `dataSource` — this component does NOT mutate the data array.
|
|
49
|
+
*/
|
|
50
|
+
onSortEnd?: (from: RecordType, to: RecordType) => void | Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Hide the drag handle entirely while still keeping `isDraggable` on. Useful
|
|
53
|
+
* when the caller wants to embed `<SortHandle />` inside a custom column.
|
|
54
|
+
* Defaults to `true`.
|
|
55
|
+
*/
|
|
56
|
+
showSortHandle?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Override the width of the auto-inserted handle column when `rowSelection`
|
|
59
|
+
* is absent. When `rowSelection` is provided the handle is rendered inside
|
|
60
|
+
* the selection column instead, so this prop is ignored.
|
|
61
|
+
*/
|
|
62
|
+
sortHandleColumnWidth?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generic v2 settings-page table primitive. Built on antd's `Table` and adds:
|
|
66
|
+
*
|
|
67
|
+
* - Row-index ↔ checkbox swap inside the selection column (`showIndex`,
|
|
68
|
+
* on by default): index visible at rest, checkbox shows on hover or when
|
|
69
|
+
* selected. Both elements are absolutely positioned inside the cell so
|
|
70
|
+
* they share the same center anchor and never compete for layout space.
|
|
71
|
+
* - Optional vertical drag-and-drop reordering (`isDraggable`): handle is
|
|
72
|
+
* absolute-positioned in a 32px left gutter so the checkbox column stays
|
|
73
|
+
* visually centered. The drag overlay renders an `outerHTML` clone of the
|
|
74
|
+
* source `<tr>`; the index is suppressed inside the clone so the row
|
|
75
|
+
* being moved doesn't display a stale ordinal.
|
|
76
|
+
*
|
|
77
|
+
* Use this in place of antd `Table` for any settings-page list. When
|
|
78
|
+
* `isDraggable` is false the component is a thin pass-through to antd Table
|
|
79
|
+
* plus the index swap, so it is safe as the default table on any page.
|
|
80
|
+
*/
|
|
81
|
+
export declare function Table<RecordType extends object = any>(props: TableProps<RecordType>): React.JSX.Element;
|
|
82
|
+
export default Table;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Pixel reservation on the left side of the rowSelection column for the drag
|
|
11
|
+
* handle. Used by the runtime `selectionGutterClassName` (real table) and by
|
|
12
|
+
* the drag overlay `overlayCellStylesClassName` (floating clone) so both
|
|
13
|
+
* variants put the handle in the same gutter position.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SORT_HANDLE_GUTTER = 32;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities';
|
|
10
|
+
import type { DraggableAttributes } from '@dnd-kit/core';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
type DragSortRowContextValue = {
|
|
13
|
+
attributes?: DraggableAttributes;
|
|
14
|
+
listeners?: SyntheticListenerMap;
|
|
15
|
+
setActivatorNodeRef?: (node: HTMLElement | null) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const DragSortRowContext: React.Context<DragSortRowContextValue>;
|
|
18
|
+
/**
|
|
19
|
+
* Activator handle that initiates a row drag. Reads `attributes` / `listeners`
|
|
20
|
+
* / `setActivatorNodeRef` from the surrounding `DragSortRowContext` provided
|
|
21
|
+
* by `SortableRow`, so the handle can sit anywhere within the row's cells
|
|
22
|
+
* (typically a dedicated first column).
|
|
23
|
+
*/
|
|
24
|
+
export declare const SortHandle: React.FC<{
|
|
25
|
+
id?: string | number;
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Drop-in replacement for antd Table's `<tr>` body row that wires `useSortable`
|
|
30
|
+
* keyed by the `data-row-key` attribute antd injects. Pass via
|
|
31
|
+
* `Table.components.body.row` and wrap the `<tbody>` with `DndContext` +
|
|
32
|
+
* `SortableContext`. The `DragSortRowContext` it provides lets `SortHandle`
|
|
33
|
+
* be placed anywhere inside the row, not just on the row itself.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SortableRow: React.FC<{
|
|
36
|
+
rowIndex?: number;
|
|
37
|
+
className?: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
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 './SortableRow';
|
|
@@ -0,0 +1,9 @@
|
|
|
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 './Table';
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Reserve a `SORT_HANDLE_GUTTER`-wide gap on the left of the rowSelection
|
|
11
|
+
* column so the handle's `left:0` lands inside a `position:relative` cell.
|
|
12
|
+
* Padding is mirrored on both the header `<th>` and body `<td>` so the
|
|
13
|
+
* "select all" checkbox stays vertically aligned with body checkboxes.
|
|
14
|
+
*
|
|
15
|
+
* The class is a module-level constant — emotion's hash is stable across
|
|
16
|
+
* re-renders, so the caller doesn't need a `useMemo` to keep referential
|
|
17
|
+
* equality.
|
|
18
|
+
*/
|
|
19
|
+
export declare const selectionGutterClassName: string;
|
|
20
|
+
/**
|
|
21
|
+
* Index ↔ checkbox hover swap CSS. Both `.nb-table-index` and the antd
|
|
22
|
+
* checkbox (wrapped in `.nb-origin-node`) are absolutely positioned and
|
|
23
|
+
* centered inside `.nb-row-selection-cell`, so they share the same anchor
|
|
24
|
+
* without one displacing the other. `display: none/flex` flips so they never
|
|
25
|
+
* overlap mid-transition.
|
|
26
|
+
*/
|
|
27
|
+
export declare const indexSwapClassName: string;
|
|
28
|
+
/**
|
|
29
|
+
* Self-contained styles for the drag-overlay clone. The runtime
|
|
30
|
+
* `selectionGutterClassName` + `indexSwapClassName` are scoped to AntdTable's
|
|
31
|
+
* emotion hash, so they don't reach the cloned `<tr>` injected via
|
|
32
|
+
* `dangerouslySetInnerHTML`. This class replays the minimal subset that the
|
|
33
|
+
* clone needs:
|
|
34
|
+
* - selection column gutter + `position: relative` so the absolute handle
|
|
35
|
+
* lands correctly
|
|
36
|
+
* - hide the row index inside the overlay (drag preview shouldn't carry
|
|
37
|
+
* a stale ordinal)
|
|
38
|
+
* - force the checkbox (`.nb-origin-node`) absolute-centered and visible
|
|
39
|
+
* regardless of hover/checked state, so the selection cell isn't empty
|
|
40
|
+
*/
|
|
41
|
+
export declare const overlayCellStylesClassName: string;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 React from 'react';
|
|
10
|
+
/**
|
|
11
|
+
* Same shape as antd Table's `rowKey` prop — either a record key name or a
|
|
12
|
+
* function. Hoisted here so utilities and `Table.tsx` agree on the contract.
|
|
13
|
+
*/
|
|
14
|
+
export type RowKey<RecordType extends object> = (keyof RecordType & (string | number)) | ((record: RecordType, index?: number) => React.Key);
|
|
15
|
+
/**
|
|
16
|
+
* Read a stable row id off a record. Mirrors antd Table's rowKey resolution
|
|
17
|
+
* but normalises non-primitive ids to strings so `data-row-key` attributes
|
|
18
|
+
* and `useSortable({ id })` agree on equality.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readRowKey<RecordType extends object>(record: RecordType, rowKey: RowKey<RecordType>, index?: number): React.Key | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Pixel-perfect snapshot of a rendered `<tr>` for the drag overlay clone.
|
|
23
|
+
* Contains everything needed to rebuild a visually identical floating row
|
|
24
|
+
* without re-running antd's column layout pass.
|
|
25
|
+
*/
|
|
26
|
+
export type RowSnapshot = {
|
|
27
|
+
/** outerHTML of the source `<tr>`, captured at drag start. */
|
|
28
|
+
html: string;
|
|
29
|
+
/** Per-cell pixel widths (in DOM order) so the clone can fix them via `<col>`. */
|
|
30
|
+
cellWidths: number[];
|
|
31
|
+
/** Total row width — used as the wrapper width so the clone matches source horizontally. */
|
|
32
|
+
totalWidth: number;
|
|
33
|
+
/** Total row height — applied to the clone so cell padding matches the source row exactly. */
|
|
34
|
+
totalHeight: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Snapshot the source `<tr>` so the drag overlay can render a pixel-accurate
|
|
38
|
+
* floating clone. We can't reliably recompute the layout from `columns` alone
|
|
39
|
+
* — antd auto-sizes columns at runtime based on content + the surrounding
|
|
40
|
+
* container — so we read the rendered widths off the DOM at drag start. The
|
|
41
|
+
* row height is captured too because antd's cell padding rules are scoped to
|
|
42
|
+
* a selector chain we strip in the clone.
|
|
43
|
+
*/
|
|
44
|
+
export declare function snapshotSourceRow(rowKey: string): RowSnapshot | null;
|
package/es/components/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* 点击变量选择器后,将形如 {{ ctx.xxx.yyy }} 的变量插入到当前光标位置。
|
|
16
16
|
*/
|
|
17
17
|
import React from 'react';
|
|
18
|
+
import { type MetaTreeNode } from '@nocobase/flow-engine';
|
|
18
19
|
export interface TextAreaWithContextSelectorProps {
|
|
19
20
|
value?: string;
|
|
20
21
|
onChange?: (v: string) => void;
|
|
@@ -22,6 +23,20 @@ export interface TextAreaWithContextSelectorProps {
|
|
|
22
23
|
rows?: number;
|
|
23
24
|
maxRows?: number;
|
|
24
25
|
style?: React.CSSProperties;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Custom meta tree for the variable picker. Accepts an array, a sync getter,
|
|
29
|
+
* or an async getter — same shape as `FlowContextSelector`'s `metaTree`. If
|
|
30
|
+
* omitted, the full `ctx.getPropertyMetaTree()` is used (legacy default).
|
|
31
|
+
*/
|
|
32
|
+
metaTree?: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
|
|
33
|
+
/**
|
|
34
|
+
* Format a picked meta node into the string inserted at the caret. When
|
|
35
|
+
* omitted, the FlowContextSelector default (`{{ ctx.X.Y }}`) is used.
|
|
36
|
+
* Override to match a different storage convention — e.g. NocoBase server
|
|
37
|
+
* templates use `{{$X.Y}}` without the `ctx.` prefix.
|
|
38
|
+
*/
|
|
39
|
+
formatPathToValue?: (meta: MetaTreeNode) => string;
|
|
25
40
|
}
|
|
26
41
|
/**
|
|
27
42
|
* TextArea 与变量选择器的组合,紧凑排版,边框无缝拼接。
|
|
@@ -6,9 +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
|
-
|
|
10
|
-
export declare const SortHandle: React.FC<{
|
|
11
|
-
id: string | number;
|
|
12
|
-
style?: React.CSSProperties;
|
|
13
|
-
}>;
|
|
14
|
-
export declare const SortableRow: (props: any) => React.JSX.Element;
|
|
9
|
+
export { DragSortRowContext, SortHandle, SortableRow } from '../../../../../components/form/table/dnd/SortableRow';
|
|
@@ -9,5 +9,9 @@
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import type { TableBlockModel } from '../TableBlockModel';
|
|
11
11
|
export declare function useDragSortBodyWrapper(model: TableBlockModel, dataSourceRef: React.MutableRefObject<any>, getRowKeyFunc: (record: any) => string | number): (props: any) => React.JSX.Element;
|
|
12
|
-
export declare function useDragSortRowComponent(dragSort: boolean):
|
|
12
|
+
export declare function useDragSortRowComponent(dragSort: boolean): React.FC<{
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
rowIndex?: number;
|
|
15
|
+
className?: string;
|
|
16
|
+
}> | ((props: any) => React.JSX.Element);
|
|
13
17
|
export declare function initDragSortParams(model: TableBlockModel): void;
|
|
@@ -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 | 20 | 100 |
|
|
9
|
+
export declare const getStrength: (val: any) => 60 | 0 | 20 | 100 | 40 | 80;
|
package/es/index.d.ts
CHANGED