bw-pro-table 0.0.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/dist/bw-pro-table.css +2 -0
  4. package/dist/bw-pro-table.js +6414 -0
  5. package/dist/bw-pro-table.umd.cjs +62 -0
  6. package/dist/types/BwProTable.vue.d.ts +61 -0
  7. package/dist/types/BwProTableAdvancedFilter.vue.d.ts +17 -0
  8. package/dist/types/BwProTableBatchEditModal.vue.d.ts +23 -0
  9. package/dist/types/BwProTableColumnSearch.vue.d.ts +14 -0
  10. package/dist/types/BwProTableColumnSetting.vue.d.ts +14 -0
  11. package/dist/types/BwProTableContextMenu.vue.d.ts +20 -0
  12. package/dist/types/BwProTableCore.vue.d.ts +38 -0
  13. package/dist/types/BwProTableSearch.vue.d.ts +33 -0
  14. package/dist/types/BwProTableToolbar.vue.d.ts +84 -0
  15. package/dist/types/composables/index.d.ts +25 -0
  16. package/dist/types/composables/useBwKeyboard.d.ts +44 -0
  17. package/dist/types/composables/useBwPermission.d.ts +50 -0
  18. package/dist/types/composables/useBwRowEdit.d.ts +83 -0
  19. package/dist/types/composables/useBwRowSelection.d.ts +42 -0
  20. package/dist/types/composables/useColumnHeaderSearch.d.ts +28 -0
  21. package/dist/types/composables/useContextMenu.d.ts +54 -0
  22. package/dist/types/composables/useDragSort.d.ts +36 -0
  23. package/dist/types/composables/useExportExcel.d.ts +35 -0
  24. package/dist/types/composables/useImportExcel.d.ts +45 -0
  25. package/dist/types/composables/useLocale.d.ts +14 -0
  26. package/dist/types/composables/usePersistence.d.ts +60 -0
  27. package/dist/types/composables/useQueryParams.d.ts +38 -0
  28. package/dist/types/composables/useTableView.d.ts +36 -0
  29. package/dist/types/constants.d.ts +60 -0
  30. package/dist/types/drag-icon.vue.d.ts +14 -0
  31. package/dist/types/index.d.ts +20 -0
  32. package/dist/types/injection-keys.d.ts +59 -0
  33. package/dist/types/locales/en-US.d.ts +166 -0
  34. package/dist/types/locales/zh-CN.d.ts +6 -0
  35. package/dist/types/renderers/action-renderer.d.ts +6 -0
  36. package/dist/types/renderers/avatar-renderer.d.ts +6 -0
  37. package/dist/types/renderers/boolean-renderer.d.ts +6 -0
  38. package/dist/types/renderers/currency-renderer.d.ts +6 -0
  39. package/dist/types/renderers/date-renderer.d.ts +6 -0
  40. package/dist/types/renderers/image-renderer.d.ts +6 -0
  41. package/dist/types/renderers/index-renderer.d.ts +6 -0
  42. package/dist/types/renderers/index.d.ts +27 -0
  43. package/dist/types/renderers/link-renderer.d.ts +6 -0
  44. package/dist/types/renderers/number-renderer.d.ts +6 -0
  45. package/dist/types/renderers/progress-renderer.d.ts +6 -0
  46. package/dist/types/renderers/registry.d.ts +41 -0
  47. package/dist/types/renderers/tag-enum-renderer.d.ts +6 -0
  48. package/dist/types/renderers/text-renderer.d.ts +6 -0
  49. package/dist/types/types.d.ts +567 -0
  50. package/locales/en-US.ts +177 -0
  51. package/locales/zh-CN.ts +193 -0
  52. package/package.json +99 -0
@@ -0,0 +1,38 @@
1
+ import type { ProColumnsType } from './types';
2
+ interface Props {
3
+ columns: ProColumnsType;
4
+ /** 行 key 属性名(与 ant-design-vue Table rowKey 语义一致,默认 'id') */
5
+ rowKey?: string;
6
+ loading?: boolean;
7
+ errorMessage?: string;
8
+ pagination?: false | Record<string, any>;
9
+ onRetry?: () => void | Promise<void>;
10
+ }
11
+ declare var __VLS_24: string, __VLS_25: any, __VLS_28: any, __VLS_36: {
12
+ column: any;
13
+ };
14
+ type __VLS_Slots = {} & {
15
+ [K in NonNullable<typeof __VLS_24>]?: (props: typeof __VLS_25) => any;
16
+ } & {
17
+ bodyCell?: (props: typeof __VLS_28) => any;
18
+ } & {
19
+ headerCell?: (props: typeof __VLS_36) => any;
20
+ };
21
+ declare const __VLS_base: import("vue").DefineComponent<Props, {
22
+ retry: () => void;
23
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
+ retry: () => any;
25
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
26
+ onRetry?: (() => any) | undefined;
27
+ }>, {
28
+ columns: ProColumnsType;
29
+ rowKey: string;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,33 @@
1
+ import type { ProColumnsType } from './types';
2
+ interface Props {
3
+ columns: ProColumnsType;
4
+ searchConfig?: {
5
+ labelWidth?: number;
6
+ defaultCollapsed?: boolean;
7
+ resetText?: string;
8
+ searchText?: string;
9
+ collapsedCount?: number;
10
+ };
11
+ }
12
+ /** 暴露给父组件:仅清空表单 UI,不触发事件 */
13
+ declare function resetForm(): void;
14
+ declare const __VLS_export: import("vue").DefineComponent<Props, {
15
+ resetForm: typeof resetForm;
16
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ search: (params: Record<string, any>) => any;
18
+ reset: () => any;
19
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
20
+ onSearch?: ((params: Record<string, any>) => any) | undefined;
21
+ onReset?: (() => any) | undefined;
22
+ }>, {
23
+ columns: ProColumnsType;
24
+ searchConfig: {
25
+ labelWidth?: number;
26
+ defaultCollapsed?: boolean;
27
+ resetText?: string;
28
+ searchText?: string;
29
+ collapsedCount?: number;
30
+ };
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
@@ -0,0 +1,84 @@
1
+ import type { ProColumnsType, PersistedColumnState } from './types';
2
+ interface Props {
3
+ title?: string;
4
+ loading?: boolean;
5
+ hasFilters?: boolean;
6
+ bordered?: boolean;
7
+ striped?: boolean;
8
+ /** 当前表格密度尺寸 */
9
+ size?: 'small' | 'middle' | 'default';
10
+ toolbarConfig?: {
11
+ bordered?: boolean;
12
+ striped?: boolean;
13
+ refresh?: boolean;
14
+ density?: boolean;
15
+ fullscreen?: boolean;
16
+ columnSetting?: boolean;
17
+ export?: boolean;
18
+ clearFilter?: boolean;
19
+ import?: boolean;
20
+ viewManager?: boolean;
21
+ };
22
+ /** 列定义(透传给列设置面板) */
23
+ columns?: ProColumnsType;
24
+ /** 当前持久化的列状态(透传给列设置面板) */
25
+ columnState?: PersistedColumnState[];
26
+ /** 全屏状态(由父组件传入,控制图标切换) */
27
+ isFullscreen?: boolean;
28
+ /** 选中数量(跨页模式下为全量数,普通模式下为当前页数) */
29
+ selectionCount?: number;
30
+ /** 是否启用跨页选择 */
31
+ hasCrossPageSelection?: boolean;
32
+ }
33
+ declare var __VLS_1: {};
34
+ type __VLS_Slots = {} & {
35
+ extra?: (props: typeof __VLS_1) => any;
36
+ };
37
+ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
38
+ export: () => any;
39
+ refresh: () => any;
40
+ "clear-filter": () => any;
41
+ "clear-selection": () => any;
42
+ "density-change": (size: "default" | "small" | "middle") => any;
43
+ "column-setting": () => any;
44
+ "column-change": (columns: PersistedColumnState[]) => any;
45
+ "column-reset": () => any;
46
+ "toggle-bordered": () => any;
47
+ "toggle-striped": () => any;
48
+ fullscreen: () => any;
49
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
50
+ onExport?: (() => any) | undefined;
51
+ onRefresh?: (() => any) | undefined;
52
+ "onClear-filter"?: (() => any) | undefined;
53
+ "onClear-selection"?: (() => any) | undefined;
54
+ "onDensity-change"?: ((size: "default" | "small" | "middle") => any) | undefined;
55
+ "onColumn-setting"?: (() => any) | undefined;
56
+ "onColumn-change"?: ((columns: PersistedColumnState[]) => any) | undefined;
57
+ "onColumn-reset"?: (() => any) | undefined;
58
+ "onToggle-bordered"?: (() => any) | undefined;
59
+ "onToggle-striped"?: (() => any) | undefined;
60
+ onFullscreen?: (() => any) | undefined;
61
+ }>, {
62
+ size: "small" | "middle" | "default";
63
+ toolbarConfig: {
64
+ bordered?: boolean;
65
+ striped?: boolean;
66
+ refresh?: boolean;
67
+ density?: boolean;
68
+ fullscreen?: boolean;
69
+ columnSetting?: boolean;
70
+ export?: boolean;
71
+ clearFilter?: boolean;
72
+ import?: boolean;
73
+ viewManager?: boolean;
74
+ };
75
+ isFullscreen: boolean;
76
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
77
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
78
+ declare const _default: typeof __VLS_export;
79
+ export default _default;
80
+ type __VLS_WithSlots<T, S> = T & {
81
+ new (): {
82
+ $slots: S;
83
+ };
84
+ };
@@ -0,0 +1,25 @@
1
+ export { useQueryParams } from './useQueryParams';
2
+ export type { UseQueryParamsOptions, UseQueryParamsReturn } from './useQueryParams';
3
+ export { useBwRowEdit } from './useBwRowEdit';
4
+ export type { UseBwRowEditOptions, UseBwRowEditReturn } from './useBwRowEdit';
5
+ export { useBwRowSelection } from './useBwRowSelection';
6
+ export type { UseBwRowSelectionOptions, UseBwRowSelectionReturn } from './useBwRowSelection';
7
+ export { useExportExcel } from './useExportExcel';
8
+ export type { UseExportExcelOptions, UseExportExcelReturn } from './useExportExcel';
9
+ export { useImportExcel } from './useImportExcel';
10
+ export type { UseImportExcelOptions, UseImportExcelReturn } from './useImportExcel';
11
+ export { usePersistence } from './usePersistence';
12
+ export type { UsePersistenceOptions, UsePersistenceReturn } from './usePersistence';
13
+ export { useContextMenu } from './useContextMenu';
14
+ export type { UseContextMenuOptions, UseContextMenuReturn, ContextMenuState } from './useContextMenu';
15
+ export { useDragSort } from './useDragSort';
16
+ export type { UseDragSortOptions, UseDragSortReturn } from './useDragSort';
17
+ export { useBwKeyboard } from './useBwKeyboard';
18
+ export type { UseBwKeyboardOptions, UseBwKeyboardReturn } from './useBwKeyboard';
19
+ export { useTableView } from './useTableView';
20
+ export type { UseTableViewOptions, UseTableViewReturn } from './useTableView';
21
+ export { useBwPermission } from './useBwPermission';
22
+ export type { UseBwPermissionOptions, UseBwPermissionReturn, MaskType } from './useBwPermission';
23
+ export { useColumnHeaderSearch } from './useColumnHeaderSearch';
24
+ export type { UseColumnHeaderSearchOptions, UseColumnHeaderSearchReturn } from './useColumnHeaderSearch';
25
+ export { useLocale, mergeLocale, BW_PRO_TABLE_LOCALE_KEY } from './useLocale';
@@ -0,0 +1,44 @@
1
+ import { type Ref } from 'vue';
2
+ export interface UseBwKeyboardOptions {
3
+ /** 数据源长度 */
4
+ dataLength: Ref<number> | number;
5
+ /** 列数量 */
6
+ columnCount?: number;
7
+ }
8
+ export interface FocusedCell {
9
+ rowIndex: number;
10
+ colIndex: number;
11
+ }
12
+ export interface UseBwKeyboardReturn {
13
+ /** 当前聚焦单元格 */
14
+ focusedCell: Ref<FocusedCell | null>;
15
+ /** 粘贴的文本值 */
16
+ copiedValue: Ref<string | null>;
17
+ /** 键盘事件处理 */
18
+ onKeydown: (e: KeyboardEvent, context?: {
19
+ rowIndex: number;
20
+ colIndex: number;
21
+ }) => void;
22
+ /** 聚焦单元格 */
23
+ focusCell: (rowIndex: number, colIndex: number) => void;
24
+ /** 清除焦点 */
25
+ clearFocus: () => void;
26
+ /** 当前是否处于编辑态(Enter 键行为切换:保存 vs 进入行编辑) */
27
+ editable: Ref<boolean>;
28
+ /** 进入单元格编辑回调 (rowIndex, colIndex) */
29
+ onEditCell: Ref<((rowIndex: number, colIndex: number) => void) | null>;
30
+ /** 保存当前编辑回调 (rowIndex, colIndex) */
31
+ onSaveEdit: Ref<((rowIndex: number, colIndex: number) => void) | null>;
32
+ /** 取消当前编辑回调 */
33
+ onCancelEdit: Ref<(() => void) | null>;
34
+ /** 删除行回调 (rowIndex) */
35
+ onDeleteCell: Ref<((rowIndex: number) => void) | null>;
36
+ /** Enter 键在非编辑态时的行操作回调 (rowIndex) */
37
+ onEnterRow: Ref<((rowIndex: number) => void) | null>;
38
+ }
39
+ /**
40
+ * useBwKeyboard — 键盘操作 composable
41
+ *
42
+ * 支持方向键导航、Tab切换、Enter/Escape编辑、Ctrl+C/V 复制粘贴。
43
+ */
44
+ export declare function useBwKeyboard(options: UseBwKeyboardOptions): UseBwKeyboardReturn;
@@ -0,0 +1,50 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { ProColumnsType } from '../types';
3
+ export interface UseBwPermissionOptions {
4
+ /** 列定义 */
5
+ columns: Ref<ProColumnsType> | ComputedRef<ProColumnsType>;
6
+ /**
7
+ * 当前用户的权限列表(不传则所有列/操作均视为有权限)
8
+ *
9
+ * @example
10
+ * // 从 Pinia store 传入:
11
+ * const userStore = useUserStore();
12
+ * useBwPermission({ columns, permissions: computed(() => userStore.role?.permissions ?? []) });
13
+ */
14
+ permissions?: Ref<{
15
+ name: string;
16
+ }[]> | ComputedRef<{
17
+ name: string;
18
+ }[]>;
19
+ }
20
+ export interface UseBwPermissionReturn {
21
+ /** 过滤后的列(仅显示有权限的列) */
22
+ authorizedColumns: ComputedRef<ProColumnsType>;
23
+ /** 检查操作是否有权限 */
24
+ hasActionPermission: (authority?: string | string[]) => boolean;
25
+ /** 检查列是否有权限 */
26
+ hasColumnPermission: (column: any) => boolean;
27
+ /** 数据脱敏 */
28
+ maskValue: (value: string, type?: MaskType) => string;
29
+ }
30
+ /** 脱敏类型 */
31
+ export type MaskType = 'phone' | 'email' | 'idcard' | 'bankcard' | 'name';
32
+ /**
33
+ * useBwPermission — 权限控制 composable
34
+ *
35
+ * 不依赖项目特定 Store,通过 permissions 参数注入权限列表。
36
+ * 支持列权限过滤、操作权限检查、数据脱敏。
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { useBwPermission } from '@/components/bw-pro-table';
41
+ * import { useUserStore } from '@/store/user';
42
+ *
43
+ * const userStore = useUserStore();
44
+ * const { authorizedColumns } = useBwPermission({
45
+ * columns,
46
+ * permissions: computed(() => userStore.role?.permissions ?? []),
47
+ * });
48
+ * ```
49
+ */
50
+ export declare function useBwPermission(options: UseBwPermissionOptions): UseBwPermissionReturn;
@@ -0,0 +1,83 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { EditConfig, ProColumnsType } from '../types';
3
+ export interface UseBwRowEditOptions<RecordType = any> {
4
+ /** 全量数据源 */
5
+ dataSource: Ref<RecordType[]>;
6
+ /** 列定义 */
7
+ columns: Ref<ProColumnsType<RecordType>> | ComputedRef<ProColumnsType<RecordType>>;
8
+ /** 行 key 属性名 */
9
+ rowKey?: string;
10
+ /** 编辑配置 */
11
+ editConfig?: Ref<EditConfig<RecordType> | undefined>;
12
+ /** 保存回调 */
13
+ onSave?: (record: RecordType, isNew: boolean) => Promise<void>;
14
+ /** 删除回调 */
15
+ onDelete?: (keys: (string | number)[]) => Promise<void>;
16
+ }
17
+ export interface UseBwRowEditReturn<RecordType = any> {
18
+ /** 当前处于编辑态的行 keys */
19
+ editingKeys: Ref<Set<string | number>>;
20
+ /** cellEditing — key -> field set(单元格编辑模式) */
21
+ cellEditing: Ref<Map<string | number, Set<string>>>;
22
+ /** 是否为行编辑模式 */
23
+ isRowEditing: (key: string | number) => boolean;
24
+ /** 是否为单元格编辑模式 */
25
+ isCellEditing: (key: string | number, field: string) => boolean;
26
+ /** 获取编辑中的草稿值 */
27
+ getDraftValue: (key: string | number, field: string) => any;
28
+ /** 设置草稿值 */
29
+ setDraftValue: (key: string | number, field: string, value: any) => void;
30
+ /** 进入单元格编辑 */
31
+ startCellEdit: (key: string | number, field: string) => void;
32
+ /** 进入行编辑 */
33
+ startRowEdit: (key: string | number) => void;
34
+ /** 新增空行 */
35
+ addRow: (position?: 'top' | 'bottom') => void;
36
+ /** 克隆行 */
37
+ cloneRow: (key: string | number) => void;
38
+ /** 保存编辑 */
39
+ saveEdit: (key: string | number) => Promise<boolean>;
40
+ /** 取消编辑 */
41
+ cancelEdit: (key: string | number) => void;
42
+ /** 删除行 */
43
+ deleteRow: (key: string | number) => Promise<void>;
44
+ /** 批量删除 */
45
+ deleteRows: (keys: (string | number)[]) => Promise<void>;
46
+ /** 校验指定行 */
47
+ validateRow: (key: string | number) => Promise<{
48
+ valid: boolean;
49
+ errors: Record<string, string>;
50
+ }>;
51
+ /** 获取字段校验错误 */
52
+ getFieldError: (key: string | number, field: string) => string | undefined;
53
+ /** 撤销 */
54
+ undo: () => void;
55
+ /** 重做 */
56
+ redo: () => void;
57
+ /** 是否有可撤销操作 */
58
+ canUndo: ComputedRef<boolean>;
59
+ /** 是否有可重做操作 */
60
+ canRedo: ComputedRef<boolean>;
61
+ /** 批量编辑选中行 */
62
+ batchEdit: (keys: (string | number)[], field: string, value: any) => Promise<void>;
63
+ /** 批量编辑弹窗状态 */
64
+ batchEditVisible: Ref<boolean>;
65
+ /** 打开批量编辑弹窗 */
66
+ openBatchEdit: () => void;
67
+ /** 关闭批量编辑弹窗 */
68
+ closeBatchEdit: () => void;
69
+ /** 是否有未保存的新增行 */
70
+ hasUncommittedNew: ComputedRef<boolean>;
71
+ }
72
+ /**
73
+ * useBwRowEdit — 行内编辑 composable
74
+ *
75
+ * 支持:
76
+ * - 单元格编辑 / 整行编辑两种模式
77
+ * - 草稿数据管理(draftData Map)
78
+ * - 表单校验(formRules)
79
+ * - 撤销/重做(Command Pattern)
80
+ * - 批量编辑弹窗
81
+ * - Ctrl+S 保存 / Escape 取消
82
+ */
83
+ export declare function useBwRowEdit<RecordType extends Record<string, any> = any>(options: UseBwRowEditOptions<RecordType>): UseBwRowEditReturn<RecordType>;
@@ -0,0 +1,42 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { TableRowSelection } from 'ant-design-vue/es/table/interface';
3
+ export interface UseBwRowSelectionOptions<RecordType = any> {
4
+ /** 全量数据源 */
5
+ dataSource: Ref<RecordType[]> | ComputedRef<RecordType[]>;
6
+ /** 行 key 属性名 */
7
+ rowKey?: string;
8
+ /** 最大选中数量 */
9
+ maxSelect?: number;
10
+ /** 选中类型 */
11
+ type?: 'checkbox' | 'radio';
12
+ }
13
+ export interface UseBwRowSelectionReturn<RecordType = any> {
14
+ /** 选中的 keys */
15
+ selectedRowKeys: Ref<(string | number)[]>;
16
+ /** 选中的行数据 */
17
+ selectedRows: Ref<RecordType[]>;
18
+ /** 行选择配置(可直接传给 a-table rowSelection) */
19
+ rowSelection: ComputedRef<TableRowSelection<RecordType>>;
20
+ /** 是否有选中项 */
21
+ hasSelection: ComputedRef<boolean>;
22
+ /** 选中数量 */
23
+ selectionCount: ComputedRef<number>;
24
+ /** 是否全选 */
25
+ isAllSelected: ComputedRef<boolean>;
26
+ /** 全选/取消全选 */
27
+ toggleSelectAll: () => void;
28
+ /** 清除选中 */
29
+ clearSelection: () => void;
30
+ /** 设置选中 */
31
+ setSelected: (keys: (string | number)[], rows?: RecordType[]) => void;
32
+ }
33
+ /**
34
+ * useBwRowSelection — 行选择 composable
35
+ *
36
+ * 支持:
37
+ * - 多选/单选
38
+ * - 跨页保留选中(preserveSelectedRowKeys)
39
+ * - 选中上限限制
40
+ * - 批量操作栏状态
41
+ */
42
+ export declare function useBwRowSelection<RecordType extends Record<string, any> = any>(options: UseBwRowSelectionOptions<RecordType>): UseBwRowSelectionReturn<RecordType>;
@@ -0,0 +1,28 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { ProColumnsType, FilterValue } from '../types';
3
+ export interface UseColumnHeaderSearchOptions<RecordType = any> {
4
+ /** 列定义 */
5
+ columns: Ref<ProColumnsType<RecordType>> | ComputedRef<ProColumnsType<RecordType>>;
6
+ }
7
+ export interface UseColumnHeaderSearchReturn {
8
+ /** 列筛选值 */
9
+ columnFilters: Ref<Record<string, FilterValue | null>>;
10
+ /** 更新列筛选 */
11
+ setColumnFilter: (field: string, value: FilterValue | null) => void;
12
+ /** 清除所有列筛选 */
13
+ clearAllFilters: () => void;
14
+ /** 获取活跃筛选标签 */
15
+ activeFilterTags: ComputedRef<{
16
+ field: string;
17
+ label: string;
18
+ value: any;
19
+ }[]>;
20
+ /** 移除指定筛选 */
21
+ removeFilterTag: (field: string) => void;
22
+ }
23
+ /**
24
+ * useColumnHeaderSearch — 列头搜索 composable
25
+ *
26
+ * 管理列筛选状态、筛选标签显示、一键清除。
27
+ */
28
+ export declare function useColumnHeaderSearch<RecordType extends Record<string, any> = any>(options: UseColumnHeaderSearchOptions<RecordType>): UseColumnHeaderSearchReturn;
@@ -0,0 +1,54 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { ContextMenuItem, ContextMenuType, ContextMenuConfig, ProColumnsType } from '../types';
3
+ export interface ContextMenuState {
4
+ /** 是否可见 */
5
+ visible: boolean;
6
+ /** 菜单类型 */
7
+ type: ContextMenuType;
8
+ /** 菜单位置 */
9
+ x: number;
10
+ y: number;
11
+ /** 当前行数据 */
12
+ record?: any;
13
+ /** 当前行 key */
14
+ rowKey?: string | number;
15
+ /** 当前字段名 */
16
+ field?: string;
17
+ /** 当前列配置 */
18
+ column?: any;
19
+ /** 菜单项 */
20
+ items: ContextMenuItem[];
21
+ }
22
+ export interface UseContextMenuOptions {
23
+ /** 右键菜单配置 */
24
+ config?: ContextMenuConfig;
25
+ /** 列定义(用于生成表头菜单默认项) */
26
+ columns?: Ref<ProColumnsType> | ComputedRef<ProColumnsType>;
27
+ }
28
+ export interface UseContextMenuReturn {
29
+ /** 菜单状态 */
30
+ menuState: Ref<ContextMenuState>;
31
+ /** 显示行右键菜单 */
32
+ showRowMenu: (e: MouseEvent, record: any, rowKey: string | number) => void;
33
+ /** 显示单元格右键菜单 */
34
+ showCellMenu: (e: MouseEvent, record: any, rowKey: string | number, field: string, value: any) => void;
35
+ /** 显示表头右键菜单 */
36
+ showHeaderMenu: (e: MouseEvent, column: any, field: string) => void;
37
+ /** 隐藏菜单 */
38
+ hideMenu: () => void;
39
+ /** 菜单点击处理 */
40
+ onMenuClick: (key: string, handler?: (ctx: any) => void) => void;
41
+ /** 内置菜单项处理 */
42
+ handleBuiltinAction: (key: string) => void;
43
+ }
44
+ /**
45
+ * useContextMenu — 右键菜单状态管理 composable
46
+ *
47
+ * 支持三种上下文菜单:
48
+ * - 行右键菜单(customRow onContextmenu)
49
+ * - 单元格右键菜单(customCell onContextmenu)
50
+ * - 表头右键菜单(customHeaderCell onContextmenu)
51
+ *
52
+ * 菜单定位使用 event.clientX/Y(fixed 定位)。
53
+ */
54
+ export declare function useContextMenu(options?: UseContextMenuOptions): UseContextMenuReturn;
@@ -0,0 +1,36 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ import type { DragConfig, ProColumnsType } from '../types';
3
+ export interface UseDragSortOptions<RecordType = any> {
4
+ /** 数据源 */
5
+ dataSource: Ref<RecordType[]>;
6
+ /** 列定义 */
7
+ columns?: Ref<ProColumnsType<RecordType>> | ComputedRef<ProColumnsType<RecordType>>;
8
+ /** 拖拽配置 */
9
+ dragConfig?: Ref<DragConfig | undefined>;
10
+ /** 拖拽结束回调 */
11
+ onRowDragEnd?: (fromIndex: number, toIndex: number) => void;
12
+ }
13
+ export interface UseDragSortReturn {
14
+ /** 是否正在拖拽 */
15
+ dragging: Ref<boolean>;
16
+ /** 拖拽状态 */
17
+ dragState: Ref<{
18
+ fromIndex: number;
19
+ toIndex: number;
20
+ } | null>;
21
+ /** 行拖拽开始 */
22
+ onRowDragStart: (index: number) => void;
23
+ /** 行拖拽结束 */
24
+ onRowDragEnd: (toIndex: number) => void;
25
+ /** 交换行位置 */
26
+ swapRows: (fromIndex: number, toIndex: number) => void;
27
+ /** 列拖拽排序 */
28
+ reorderColumns: (fromIndex: number, toIndex: number) => void;
29
+ }
30
+ /**
31
+ * useDragSort — 拖拽排序 composable
32
+ *
33
+ * 支持行拖拽排序和列拖拽排序。
34
+ * 使用本地状态管理拖拽过程,不依赖 sortablejs 运行时(需在组件层集成)。
35
+ */
36
+ export declare function useDragSort<RecordType extends Record<string, any> = any>(options: UseDragSortOptions<RecordType>): UseDragSortReturn;
@@ -0,0 +1,35 @@
1
+ import { type Ref } from 'vue';
2
+ import type { ProColumnsType, ExportConfig } from '../types';
3
+ export interface UseExportExcelOptions<RecordType = any> {
4
+ /** 列定义 */
5
+ columns: Ref<ProColumnsType<RecordType>>;
6
+ /** 数据源 */
7
+ dataSource: Ref<readonly RecordType[]>;
8
+ /** 导出配置 */
9
+ exportConfig?: ExportConfig;
10
+ }
11
+ export interface UseExportExcelReturn {
12
+ /** 导出 Excel */
13
+ exportExcel: () => Promise<void>;
14
+ /** 导出 CSV */
15
+ exportCsv: () => void;
16
+ /** 导出选中行 */
17
+ exportSelected: (selectedRows: any[]) => Promise<void>;
18
+ /** 导出自定义列弹窗 */
19
+ showColumnSelect: Ref<boolean>;
20
+ /** 是否正在导出 */
21
+ exporting: Ref<boolean>;
22
+ /** 导出进度 */
23
+ exportProgress: Ref<number>;
24
+ }
25
+ /**
26
+ * useExportExcel — 导出 composable
27
+ *
28
+ * 使用 xlsx (SheetJS) 生成 Excel 文件。
29
+ * 支持:
30
+ * - 导出 Excel / CSV
31
+ * - 导出选中行
32
+ * - 分片导出(大数据量 + 进度条)
33
+ * - 自定义列选择导出
34
+ */
35
+ export declare function useExportExcel<RecordType extends Record<string, any> = any>(options: UseExportExcelOptions<RecordType>): UseExportExcelReturn;
@@ -0,0 +1,45 @@
1
+ import { type Ref } from 'vue';
2
+ import type { ImportConfig } from '../types';
3
+ export interface UseImportExcelOptions {
4
+ /** 导入配置 */
5
+ importConfig?: ImportConfig;
6
+ }
7
+ export interface UseImportExcelReturn {
8
+ /** 是否正在导入 */
9
+ importing: Ref<boolean>;
10
+ /** 预览数据 */
11
+ previewData: Ref<any[]>;
12
+ /** 预览列头 */
13
+ previewColumns: Ref<string[]>;
14
+ /** 是否显示预览 */
15
+ showPreview: Ref<boolean>;
16
+ /** 列映射 */
17
+ columnMapping: Ref<Record<string, string>>;
18
+ /** 校验错误 */
19
+ validateErrors: Ref<string[]>;
20
+ /** 打开文件选择 */
21
+ openFileDialog: () => void;
22
+ /** 处理文件 */
23
+ handleFile: (file: File) => Promise<void>;
24
+ /** 确认导入 */
25
+ confirmImport: () => Promise<void>;
26
+ /** 取消 */
27
+ cancel: () => void;
28
+ /** 下载模板 */
29
+ downloadTemplate: (columns: {
30
+ title: string;
31
+ dataIndex: string;
32
+ }[]) => Promise<void>;
33
+ }
34
+ /**
35
+ * useImportExcel — Excel 导入 composable
36
+ *
37
+ * 使用 FileReader + xlsx 解析 Excel 文件。
38
+ * 支持:
39
+ * - 预览解析数据
40
+ * - 列映射配置
41
+ * - 数据校验
42
+ * - 导入提交
43
+ * - 模板下载
44
+ */
45
+ export declare function useImportExcel(options?: UseImportExcelOptions): UseImportExcelReturn;
@@ -0,0 +1,14 @@
1
+ import type { InjectionKey, ComputedRef } from 'vue';
2
+ import type { BwProTableLocale } from '../types';
3
+ /** 注入 Key */
4
+ export declare const BW_PRO_TABLE_LOCALE_KEY: InjectionKey<ComputedRef<BwProTableLocale>>;
5
+ /**
6
+ * 在 setup 中获取当前生效的语言包。
7
+ * 必须在 BwProTable 子树内调用(即通过 provide 已提供 locale),否则回退到默认 zh-CN。
8
+ */
9
+ export declare function useLocale(): ComputedRef<BwProTableLocale>;
10
+ /**
11
+ * 深度合并自定义 locale 到默认 zh-CN。
12
+ * 外部传入 Partial<BwProTableLocale>,内部补全缺失字段。
13
+ */
14
+ export declare function mergeLocale(custom?: Partial<BwProTableLocale>): BwProTableLocale;