dydx-naive-ui-for-vue 0.1.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.
- package/README.md +75 -0
- package/dist/dydx-naive-ui-for-vue.css +2 -0
- package/dist/dydx-naive-ui-for-vue.js +1758 -0
- package/dist/dydx-naive-ui-for-vue.umd.cjs +1 -0
- package/dist/types/components/FormModal/index.d.ts +4 -0
- package/dist/types/components/FormModal/src/DydxFormDrawer.vue.d.ts +63 -0
- package/dist/types/components/FormModal/src/DydxFormModal.vue.d.ts +61 -0
- package/dist/types/components/FormModal/types.d.ts +27 -0
- package/dist/types/components/IconSelect/index.d.ts +3 -0
- package/dist/types/components/IconSelect/src/DydxIconSelect.vue.d.ts +20 -0
- package/dist/types/components/IconSelect/types.d.ts +9 -0
- package/dist/types/components/NaiveForm/index.d.ts +83 -0
- package/dist/types/components/NaiveForm/src/DydxNaiveForm.vue.d.ts +39 -0
- package/dist/types/components/NaiveForm/types/expose.d.ts +13 -0
- package/dist/types/components/NaiveForm/types/index.d.ts +3 -0
- package/dist/types/components/NaiveForm/types/props.d.ts +75 -0
- package/dist/types/components/NaiveForm/types/schema.d.ts +118 -0
- package/dist/types/components/NaiveForm/utils/component-map.d.ts +2 -0
- package/dist/types/components/NaiveForm/utils/path.d.ts +2 -0
- package/dist/types/components/NaiveTable/composables/index.d.ts +4 -0
- package/dist/types/components/NaiveTable/composables/useColumnRender.d.ts +24 -0
- package/dist/types/components/NaiveTable/composables/useColumns.d.ts +34 -0
- package/dist/types/components/NaiveTable/composables/usePagination.d.ts +23 -0
- package/dist/types/components/NaiveTable/composables/useTableActions.d.ts +15 -0
- package/dist/types/components/NaiveTable/index.d.ts +53 -0
- package/dist/types/components/NaiveTable/src/DydxNaiveTable.vue.d.ts +26 -0
- package/dist/types/components/NaiveTable/types/columns.d.ts +155 -0
- package/dist/types/components/NaiveTable/types/expose.d.ts +24 -0
- package/dist/types/components/NaiveTable/types/index.d.ts +3 -0
- package/dist/types/components/NaiveTable/types/props.d.ts +132 -0
- package/dist/types/components/NaiveUpload/index.d.ts +4 -0
- package/dist/types/components/NaiveUpload/src/DydxUpload.vue.d.ts +4568 -0
- package/dist/types/components/NaiveUpload/types.d.ts +43 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/vite.svg +1 -0
- package/dist/volar.d.ts +13 -0
- package/package.json +69 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Component, VNode } from 'vue';
|
|
2
|
+
import { FormItemRule, FormItemGiProps } from 'naive-ui';
|
|
3
|
+
import { DydxUploadProps } from '../../NaiveUpload';
|
|
4
|
+
import { DydxIconSelectProps } from '../../IconSelect';
|
|
5
|
+
import type * as NaiveUI from 'naive-ui';
|
|
6
|
+
export type DeepKeys<T> = T extends object ? {
|
|
7
|
+
[K in keyof T]-?: K extends string | number ? T[K] extends object ? `${K}` | `${K}.${DeepKeys<T[K]>}` : `${K}` : never;
|
|
8
|
+
}[keyof T] : never;
|
|
9
|
+
export type NativeFieldType = 'input' | 'input-number' | 'select' | 'date-picker' | 'time-picker' | 'switch' | 'slider' | 'radio-group' | 'checkbox-group' | 'cascader' | 'tree-select' | 'upload' | 'rate' | 'color-picker' | 'auto-complete' | 'dynamic-input' | 'dynamic-tags' | 'mention' | 'image-upload' | 'file-upload' | 'icon-select';
|
|
10
|
+
export interface ComponentPropsMap {
|
|
11
|
+
'input': NaiveUI.InputProps;
|
|
12
|
+
'input-number': NaiveUI.InputNumberProps;
|
|
13
|
+
'select': NaiveUI.SelectProps;
|
|
14
|
+
'date-picker': NaiveUI.DatePickerProps;
|
|
15
|
+
'time-picker': NaiveUI.TimePickerProps;
|
|
16
|
+
'switch': NaiveUI.SwitchProps;
|
|
17
|
+
'slider': NaiveUI.SliderProps;
|
|
18
|
+
'radio-group': NaiveUI.RadioGroupProps & {
|
|
19
|
+
options?: Array<Record<string, any>>;
|
|
20
|
+
labelField?: string;
|
|
21
|
+
valueField?: string;
|
|
22
|
+
};
|
|
23
|
+
'checkbox-group': NaiveUI.CheckboxGroupProps & {
|
|
24
|
+
options?: Array<Record<string, any>>;
|
|
25
|
+
labelField?: string;
|
|
26
|
+
valueField?: string;
|
|
27
|
+
};
|
|
28
|
+
'cascader': NaiveUI.CascaderProps;
|
|
29
|
+
'tree-select': NaiveUI.TreeSelectProps;
|
|
30
|
+
'upload': NaiveUI.UploadProps;
|
|
31
|
+
'rate': NaiveUI.RateProps;
|
|
32
|
+
'color-picker': NaiveUI.ColorPickerProps;
|
|
33
|
+
'auto-complete': NaiveUI.AutoCompleteProps;
|
|
34
|
+
'dynamic-input': NaiveUI.DynamicInputProps;
|
|
35
|
+
'dynamic-tags': NaiveUI.DynamicTagsProps;
|
|
36
|
+
'mention': NaiveUI.MentionProps;
|
|
37
|
+
'image-upload': DydxUploadProps;
|
|
38
|
+
'file-upload': DydxUploadProps;
|
|
39
|
+
'icon-select': DydxIconSelectProps;
|
|
40
|
+
}
|
|
41
|
+
export interface ResponsiveSpan {
|
|
42
|
+
/** 超小屏幕 (<640px) */
|
|
43
|
+
xs?: number;
|
|
44
|
+
/** 小屏幕 (≥640px) */
|
|
45
|
+
s?: number;
|
|
46
|
+
/** 中等屏幕 (≥1024px) */
|
|
47
|
+
m?: number;
|
|
48
|
+
/** 大屏幕 (≥1280px) */
|
|
49
|
+
l?: number;
|
|
50
|
+
/** 超大屏幕 (≥1536px) */
|
|
51
|
+
xl?: number;
|
|
52
|
+
/** 超超大屏幕 (≥1920px) */
|
|
53
|
+
xxl?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface BaseSchema<T extends Record<string, any>> {
|
|
56
|
+
label: string | (() => VNode);
|
|
57
|
+
name: DeepKeys<T>;
|
|
58
|
+
/**
|
|
59
|
+
* 该字段占据的列数
|
|
60
|
+
*
|
|
61
|
+
* 可以是固定数字或响应式对象,响应式断点:
|
|
62
|
+
* - xs: <640px (超小屏幕)
|
|
63
|
+
* - s: ≥640px (小屏幕)
|
|
64
|
+
* - m: ≥1024px (中等屏幕)
|
|
65
|
+
* - l: ≥1280px (大屏幕)
|
|
66
|
+
* - xl: ≥1536px (超大屏幕)
|
|
67
|
+
* - xxl: ≥1920px (超超大屏幕)
|
|
68
|
+
*/
|
|
69
|
+
span?: number | FormItemGiProps['span'] | ResponsiveSpan;
|
|
70
|
+
offset?: number;
|
|
71
|
+
hidden?: boolean | ((formData: T) => boolean);
|
|
72
|
+
disabled?: boolean | ((formData: T) => boolean);
|
|
73
|
+
noRequired?: boolean;
|
|
74
|
+
rule?: FormItemRule | FormItemRule[] | ((formData: T) => FormItemRule | FormItemRule[]);
|
|
75
|
+
formItemProps?: Partial<NaiveUI.FormItemProps>;
|
|
76
|
+
slot?: string;
|
|
77
|
+
}
|
|
78
|
+
export type NativeSchema<T extends Record<string, any>> = {
|
|
79
|
+
[K in NativeFieldType]: BaseSchema<T> & {
|
|
80
|
+
type?: K;
|
|
81
|
+
props?: ComponentPropsMap[K];
|
|
82
|
+
};
|
|
83
|
+
}[NativeFieldType];
|
|
84
|
+
export interface InputSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
85
|
+
type?: 'input';
|
|
86
|
+
props?: ComponentPropsMap['input'];
|
|
87
|
+
}
|
|
88
|
+
export interface SelectSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
89
|
+
type: 'select';
|
|
90
|
+
props?: ComponentPropsMap['select'];
|
|
91
|
+
}
|
|
92
|
+
export interface RadioGroupSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
93
|
+
type: 'radio-group';
|
|
94
|
+
props?: ComponentPropsMap['radio-group'];
|
|
95
|
+
}
|
|
96
|
+
export interface CheckboxGroupSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
97
|
+
type: 'checkbox-group';
|
|
98
|
+
props?: ComponentPropsMap['checkbox-group'];
|
|
99
|
+
}
|
|
100
|
+
export interface DatePickerSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
101
|
+
type: 'date-picker';
|
|
102
|
+
props?: ComponentPropsMap['date-picker'];
|
|
103
|
+
}
|
|
104
|
+
export interface InputNumberSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
105
|
+
type: 'input-number';
|
|
106
|
+
props?: ComponentPropsMap['input-number'];
|
|
107
|
+
}
|
|
108
|
+
export interface CustomSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
109
|
+
type: 'custom';
|
|
110
|
+
component: Component | string;
|
|
111
|
+
props?: Record<string, any>;
|
|
112
|
+
modelPropName?: string;
|
|
113
|
+
modelEventName?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface SlotSchema<T extends Record<string, any>> extends BaseSchema<T> {
|
|
116
|
+
type: 'slot';
|
|
117
|
+
}
|
|
118
|
+
export type FormSchema<T extends Record<string, any>> = InputSchema<T> | SelectSchema<T> | RadioGroupSchema<T> | CheckboxGroupSchema<T> | DatePickerSchema<T> | InputNumberSchema<T> | NativeSchema<T> | CustomSchema<T> | SlotSchema<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import { DydxTableColumn, TagOption, ImageColumnConfig, LinkColumnConfig, FileColumnConfig, IconColumnConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 根据列类型渲染内容
|
|
5
|
+
*/
|
|
6
|
+
export declare const renderColumnContent: <T>(value: any, row: T, column: DydxTableColumn<T>) => VNode | string;
|
|
7
|
+
/**
|
|
8
|
+
* 判断列是否需要自动渲染(有 columnType 且没有自定义 render)
|
|
9
|
+
*/
|
|
10
|
+
export declare const shouldAutoRender: <T>(column: DydxTableColumn<T>) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 列渲染 composable
|
|
13
|
+
*/
|
|
14
|
+
export declare function useColumnRender(): {
|
|
15
|
+
renderColumnContent: <T>(value: any, row: T, column: DydxTableColumn<T>) => VNode | string;
|
|
16
|
+
shouldAutoRender: <T>(column: DydxTableColumn<T>) => boolean;
|
|
17
|
+
renderText: (value: any) => VNode | string;
|
|
18
|
+
renderLink: (value: any, row: any, config?: LinkColumnConfig) => VNode | string;
|
|
19
|
+
renderImage: (value: any, config?: ImageColumnConfig) => VNode | string;
|
|
20
|
+
renderFile: (value: any, row: any, config?: FileColumnConfig) => VNode | string;
|
|
21
|
+
renderTag: (value: any, options?: TagOption[], labelField?: string, valueField?: string) => VNode | string;
|
|
22
|
+
renderTags: (value: any, options?: TagOption[], labelField?: string, valueField?: string) => VNode | string;
|
|
23
|
+
renderIcon: (value: any, config?: IconColumnConfig) => VNode | string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { DataTableColumn } from 'naive-ui';
|
|
3
|
+
import { DydxTableColumns, ActionColumnConfig, ActionEventParams } from '../types';
|
|
4
|
+
export interface ColumnSettingItem {
|
|
5
|
+
key: string;
|
|
6
|
+
title: string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
configurable: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface UseColumnsOptions<T> {
|
|
11
|
+
columns: DydxTableColumns<T>;
|
|
12
|
+
actionColumn?: ActionColumnConfig<T>;
|
|
13
|
+
onView?: (params: ActionEventParams<T>) => void;
|
|
14
|
+
onEdit?: (params: ActionEventParams<T>) => void;
|
|
15
|
+
onDelete?: (params: ActionEventParams<T>) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface UseColumnsReturn<T> {
|
|
18
|
+
/** 最终渲染的列配置 */
|
|
19
|
+
mergedColumns: ComputedRef<DataTableColumn<T>[]>;
|
|
20
|
+
/** 可配置的列列表(用于列设置) */
|
|
21
|
+
configurableColumns: ComputedRef<ColumnSettingItem[]>;
|
|
22
|
+
/** 当前可见的列 keys */
|
|
23
|
+
visibleColumnKeys: Ref<string[]>;
|
|
24
|
+
/** 设置可见列 */
|
|
25
|
+
setVisibleColumnKeys: (keys: string[]) => void;
|
|
26
|
+
/** 重置为默认可见列 */
|
|
27
|
+
resetColumnSetting: () => void;
|
|
28
|
+
/** 获取可见列 keys */
|
|
29
|
+
getVisibleColumnKeys: () => string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 列配置处理 composable
|
|
33
|
+
*/
|
|
34
|
+
export declare function useColumns<T>(options: UseColumnsOptions<T>): UseColumnsReturn<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { PaginationProps } from 'naive-ui';
|
|
3
|
+
import { TablePagination, PaginationFieldNames, PageChangeData } from '../types';
|
|
4
|
+
export interface UsePaginationOptions {
|
|
5
|
+
pagination?: false | TablePagination;
|
|
6
|
+
fieldNames?: PaginationFieldNames;
|
|
7
|
+
onUpdatePagination?: (pagination: TablePagination) => void;
|
|
8
|
+
onPageChange?: (data: PageChangeData) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface UsePaginationReturn {
|
|
11
|
+
/** 分页配置,用于传递给 DataTable */
|
|
12
|
+
paginationConfig: ComputedRef<false | PaginationProps>;
|
|
13
|
+
/** 处理页码变化 */
|
|
14
|
+
handlePageChange: (page: number) => void;
|
|
15
|
+
/** 处理每页条数变化 */
|
|
16
|
+
handlePageSizeChange: (pageSize: number) => void;
|
|
17
|
+
/** 获取合并后的字段名 */
|
|
18
|
+
getFieldNames: () => Required<PaginationFieldNames>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 分页逻辑 composable
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePagination(options: UsePaginationOptions): UsePaginationReturn;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import { ActionColumnConfig, ActionButton, ActionEventParams } from '../types';
|
|
3
|
+
export interface UseTableActionsOptions<T> extends ActionColumnConfig<T> {
|
|
4
|
+
onView?: (params: ActionEventParams<T>) => void;
|
|
5
|
+
onEdit?: (params: ActionEventParams<T>) => void;
|
|
6
|
+
onDelete?: (params: ActionEventParams<T>) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 操作按钮处理 composable
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTableActions<T>(options: UseTableActionsOptions<T>): {
|
|
12
|
+
renderActions: (row: T, index: number) => VNode;
|
|
13
|
+
isButtonVisible: (btn: ActionButton<T>, row: T, index: number) => boolean;
|
|
14
|
+
isButtonDisabled: (btn: ActionButton<T>, row: T, index: number) => boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { default as DydxNaiveTableVue } from './src/DydxNaiveTable.vue';
|
|
2
|
+
export declare const DydxNaiveTable: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
3
|
+
attrs: any;
|
|
4
|
+
slots: {
|
|
5
|
+
'add-icon'?(_: {}): any;
|
|
6
|
+
'toolbar-left'?(_: {}): any;
|
|
7
|
+
'toolbar-right'?(_: {}): any;
|
|
8
|
+
};
|
|
9
|
+
emit: ((evt: "view", params: import('./types').ActionEventParams<T>) => void) & ((evt: "delete", params: import('./types').ActionEventParams<T>) => void) & ((evt: "update:pagination", pagination: import('./types').TablePagination) => void) & ((evt: "pageChange", pagination: import('./types').PageChangeData) => void) & ((evt: "update:checkedRowKeys", keys: (string | number)[], rows: T[]) => void) & ((evt: "update:visibleColumns", keys: string[]) => void) & ((evt: "edit", params: import('./types').ActionEventParams<T>) => void);
|
|
10
|
+
}, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
11
|
+
props: {
|
|
12
|
+
readonly onView?: ((params: import('./types').ActionEventParams<T>) => any) | undefined;
|
|
13
|
+
readonly onEdit?: ((params: import('./types').ActionEventParams<T>) => any) | undefined;
|
|
14
|
+
readonly onDelete?: ((params: import('./types').ActionEventParams<T>) => any) | undefined;
|
|
15
|
+
readonly onPageChange?: ((pagination: import('./types').PageChangeData) => any) | undefined;
|
|
16
|
+
readonly "onUpdate:pagination"?: ((pagination: import('./types').TablePagination) => any) | undefined;
|
|
17
|
+
readonly "onUpdate:checkedRowKeys"?: ((keys: (string | number)[], rows: T[]) => any) | undefined;
|
|
18
|
+
readonly "onUpdate:visibleColumns"?: ((keys: string[]) => any) | undefined;
|
|
19
|
+
loading?: boolean | undefined;
|
|
20
|
+
checkedRowKeys?: (string | number)[] | undefined;
|
|
21
|
+
remote?: boolean | undefined;
|
|
22
|
+
data: T[];
|
|
23
|
+
columns: import('./types').DydxTableColumns<T>;
|
|
24
|
+
rowKey: keyof T | ((row: T) => string | number);
|
|
25
|
+
actionColumn?: import('./types').ActionColumnConfig<T> | undefined;
|
|
26
|
+
showAdd?: boolean | undefined;
|
|
27
|
+
addButtonText?: string | undefined;
|
|
28
|
+
onAdd?: (() => void) | undefined;
|
|
29
|
+
leftButtons?: import('./types').ToolbarButton[] | undefined;
|
|
30
|
+
showRefresh?: boolean | undefined;
|
|
31
|
+
onRefresh?: (() => void) | undefined;
|
|
32
|
+
showColumnSetting?: boolean | undefined;
|
|
33
|
+
rightButtons?: import('./types').ToolbarButton[] | undefined;
|
|
34
|
+
pagination?: (false | import('./types').TablePagination) | undefined;
|
|
35
|
+
paginationFieldNames?: import('./types').PaginationFieldNames | undefined;
|
|
36
|
+
} & import('vue').PublicProps;
|
|
37
|
+
expose(exposed: import('vue').ShallowUnwrapRef<import('./types').DydxNaiveTableExpose>): void;
|
|
38
|
+
attrs: any;
|
|
39
|
+
slots: {
|
|
40
|
+
'add-icon'?(_: {}): any;
|
|
41
|
+
'toolbar-left'?(_: {}): any;
|
|
42
|
+
'toolbar-right'?(_: {}): any;
|
|
43
|
+
};
|
|
44
|
+
emit: ((evt: "view", params: import('./types').ActionEventParams<T>) => void) & ((evt: "delete", params: import('./types').ActionEventParams<T>) => void) & ((evt: "update:pagination", pagination: import('./types').TablePagination) => void) & ((evt: "pageChange", pagination: import('./types').PageChangeData) => void) & ((evt: "update:checkedRowKeys", keys: (string | number)[], rows: T[]) => void) & ((evt: "update:visibleColumns", keys: string[]) => void) & ((evt: "edit", params: import('./types').ActionEventParams<T>) => void);
|
|
45
|
+
}>) => import('vue').VNode & {
|
|
46
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
47
|
+
};
|
|
48
|
+
export * from './types';
|
|
49
|
+
export { useColumns } from './composables/useColumns';
|
|
50
|
+
export { usePagination } from './composables/usePagination';
|
|
51
|
+
export { useTableActions } from './composables/useTableActions';
|
|
52
|
+
export { useColumnRender } from './composables/useColumnRender';
|
|
53
|
+
export default DydxNaiveTableVue;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DydxNaiveTableProps, DydxNaiveTableExpose, TablePagination, PageChangeData, ActionEventParams } from '../types';
|
|
2
|
+
declare const _default: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
|
+
readonly onView?: ((params: ActionEventParams<T>) => any) | undefined;
|
|
5
|
+
readonly onDelete?: ((params: ActionEventParams<T>) => any) | undefined;
|
|
6
|
+
readonly "onUpdate:pagination"?: ((pagination: TablePagination) => any) | undefined;
|
|
7
|
+
readonly onPageChange?: ((pagination: PageChangeData) => any) | undefined;
|
|
8
|
+
readonly "onUpdate:checkedRowKeys"?: ((keys: (string | number)[], rows: T[]) => any) | undefined;
|
|
9
|
+
readonly "onUpdate:visibleColumns"?: ((keys: string[]) => any) | undefined;
|
|
10
|
+
readonly onEdit?: ((params: ActionEventParams<T>) => any) | undefined;
|
|
11
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onView" | "onEdit" | "onDelete" | "onPageChange" | "onUpdate:pagination" | "onUpdate:checkedRowKeys" | "onUpdate:visibleColumns"> & DydxNaiveTableProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
12
|
+
expose(exposed: import('vue').ShallowUnwrapRef<DydxNaiveTableExpose>): void;
|
|
13
|
+
attrs: any;
|
|
14
|
+
slots: {
|
|
15
|
+
'add-icon'?(_: {}): any;
|
|
16
|
+
'toolbar-left'?(_: {}): any;
|
|
17
|
+
'toolbar-right'?(_: {}): any;
|
|
18
|
+
};
|
|
19
|
+
emit: ((evt: "view", params: ActionEventParams<T>) => void) & ((evt: "delete", params: ActionEventParams<T>) => void) & ((evt: "update:pagination", pagination: TablePagination) => void) & ((evt: "pageChange", pagination: PageChangeData) => void) & ((evt: "update:checkedRowKeys", keys: (string | number)[], rows: T[]) => void) & ((evt: "update:visibleColumns", keys: string[]) => void) & ((evt: "edit", params: ActionEventParams<T>) => void);
|
|
20
|
+
}>) => import('vue').VNode & {
|
|
21
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_PrettifyLocal<T> = {
|
|
25
|
+
[K in keyof T]: T[K];
|
|
26
|
+
} & {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { DataTableColumn, DataTableBaseColumn, DataTableSelectionColumn, DataTableExpandColumn, TagProps } from 'naive-ui';
|
|
2
|
+
import { VNodeChild } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* 列类型
|
|
5
|
+
* - text: 文本(默认)
|
|
6
|
+
* - link: 链接,点击新窗口打开
|
|
7
|
+
* - image: 图片,显示缩略图并支持预览
|
|
8
|
+
* - file: 文件,显示文件名并支持点击下载
|
|
9
|
+
* - tag: 标签,使用 NTag 组件显示
|
|
10
|
+
* - icon: 图标,显示 ionicons5 图标
|
|
11
|
+
*/
|
|
12
|
+
export type ColumnType = 'text' | 'link' | 'image' | 'file' | 'tag' | 'icon';
|
|
13
|
+
/**
|
|
14
|
+
* 图标列配置
|
|
15
|
+
*/
|
|
16
|
+
export interface IconColumnConfig {
|
|
17
|
+
/** 图标大小 */
|
|
18
|
+
size?: number;
|
|
19
|
+
/** 图标颜色 */
|
|
20
|
+
color?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 标签选项配置
|
|
24
|
+
* 继承 Naive UI TagProps,支持所有标签属性
|
|
25
|
+
*/
|
|
26
|
+
export interface TagOption extends Partial<Omit<TagProps, 'onClick'>> {
|
|
27
|
+
/** 匹配的值 */
|
|
28
|
+
value: string | number | boolean;
|
|
29
|
+
/** 显示的标签文字 */
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 图片列配置
|
|
34
|
+
*/
|
|
35
|
+
export interface ImageColumnConfig {
|
|
36
|
+
/** 图片宽度 */
|
|
37
|
+
width?: number | string;
|
|
38
|
+
/** 图片高度 */
|
|
39
|
+
height?: number | string;
|
|
40
|
+
/** 图片圆角 */
|
|
41
|
+
radius?: number | string;
|
|
42
|
+
/** 占位图 */
|
|
43
|
+
fallback?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 链接列配置
|
|
47
|
+
*/
|
|
48
|
+
export interface LinkColumnConfig {
|
|
49
|
+
/** 是否在新窗口打开,默认 true */
|
|
50
|
+
newWindow?: boolean;
|
|
51
|
+
/** 链接文字,不传则使用链接地址 */
|
|
52
|
+
text?: string | ((row: any) => string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 文件列配置
|
|
56
|
+
*/
|
|
57
|
+
export interface FileColumnConfig {
|
|
58
|
+
/** 自定义文件名提取函数 */
|
|
59
|
+
getFileName?: (url: string, row: any) => string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 自定义操作按钮配置
|
|
63
|
+
*/
|
|
64
|
+
export interface ActionButton<T = any> {
|
|
65
|
+
/** 按钮唯一标识 */
|
|
66
|
+
key: string;
|
|
67
|
+
/** 按钮文字 */
|
|
68
|
+
label: string;
|
|
69
|
+
/** 按钮类型 */
|
|
70
|
+
type?: 'primary' | 'info' | 'success' | 'warning' | 'error' | 'default';
|
|
71
|
+
/** 是否显示,支持函数动态判断 */
|
|
72
|
+
show?: boolean | ((row: T, index: number) => boolean);
|
|
73
|
+
/** 是否禁用,支持函数动态判断 */
|
|
74
|
+
disabled?: boolean | ((row: T, index: number) => boolean);
|
|
75
|
+
/** 确认弹窗文字,设置后点击会弹出确认框 */
|
|
76
|
+
confirm?: string | ((row: T) => string);
|
|
77
|
+
/** 点击回调 */
|
|
78
|
+
onClick?: (row: T, index: number) => void | Promise<void>;
|
|
79
|
+
/** 按钮图标 */
|
|
80
|
+
icon?: () => VNodeChild;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 内置按钮配置
|
|
84
|
+
*/
|
|
85
|
+
export interface BuiltinButtonConfig<T = any> {
|
|
86
|
+
/** 是否显示,支持函数动态判断 */
|
|
87
|
+
show?: boolean | ((row: T, index: number) => boolean);
|
|
88
|
+
/** 是否禁用,支持函数动态判断 */
|
|
89
|
+
disabled?: boolean | ((row: T, index: number) => boolean);
|
|
90
|
+
/** 按钮文字 */
|
|
91
|
+
label?: string;
|
|
92
|
+
/** 确认弹窗文字(仅删除按钮有效) */
|
|
93
|
+
confirm?: string | ((row: T) => string);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 操作列配置
|
|
97
|
+
*/
|
|
98
|
+
export interface ActionColumnConfig<T = any> {
|
|
99
|
+
/** 是否显示操作列,默认 true */
|
|
100
|
+
show?: boolean;
|
|
101
|
+
/** 列宽度 */
|
|
102
|
+
width?: number | string;
|
|
103
|
+
/** 最小列宽度 */
|
|
104
|
+
minWidth?: number | string;
|
|
105
|
+
/** 固定位置,默认 'right' */
|
|
106
|
+
fixed?: 'left' | 'right' | false;
|
|
107
|
+
/** 列标题,默认 '操作' */
|
|
108
|
+
title?: string;
|
|
109
|
+
/** 是否显示查看按钮,默认 true */
|
|
110
|
+
showView?: boolean;
|
|
111
|
+
/** 查看按钮配置 */
|
|
112
|
+
viewConfig?: BuiltinButtonConfig<T>;
|
|
113
|
+
/** 是否显示编辑按钮,默认 true */
|
|
114
|
+
showEdit?: boolean;
|
|
115
|
+
/** 编辑按钮配置 */
|
|
116
|
+
editConfig?: BuiltinButtonConfig<T>;
|
|
117
|
+
/** 是否显示删除按钮,默认 true */
|
|
118
|
+
showDelete?: boolean;
|
|
119
|
+
/** 删除按钮配置 */
|
|
120
|
+
deleteConfig?: BuiltinButtonConfig<T>;
|
|
121
|
+
/** 自定义操作按钮列表(显示在内置按钮后面) */
|
|
122
|
+
buttons?: ActionButton<T>[];
|
|
123
|
+
/** 最多显示几个按钮,超出折叠到"更多"下拉菜单 */
|
|
124
|
+
maxVisible?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 扩展列配置 - 完全兼容 Naive UI DataTableBaseColumn
|
|
128
|
+
*/
|
|
129
|
+
export interface DydxTableColumn<T = any> extends DataTableBaseColumn<T> {
|
|
130
|
+
/** 是否默认显示(用于列设置功能) */
|
|
131
|
+
defaultVisible?: boolean;
|
|
132
|
+
/** 是否可在列设置中控制显示/隐藏 */
|
|
133
|
+
configurable?: boolean;
|
|
134
|
+
/** 列类型,默认 'text' */
|
|
135
|
+
columnType?: ColumnType;
|
|
136
|
+
/** 标签选项配置,columnType 为 'tag' 时有效 */
|
|
137
|
+
tagOptions?: TagOption[];
|
|
138
|
+
/** 标签 label 字段名,默认 'label' */
|
|
139
|
+
tagLabelField?: string;
|
|
140
|
+
/** 标签 value 字段名,默认 'value' */
|
|
141
|
+
tagValueField?: string;
|
|
142
|
+
/** 图片配置,columnType 为 'image' 时有效 */
|
|
143
|
+
imageConfig?: ImageColumnConfig;
|
|
144
|
+
/** 链接配置,columnType 为 'link' 时有效 */
|
|
145
|
+
linkConfig?: LinkColumnConfig;
|
|
146
|
+
/** 文件配置,columnType 为 'file' 时有效 */
|
|
147
|
+
fileConfig?: FileColumnConfig;
|
|
148
|
+
/** 图标配置,columnType 为 'icon' 时有效 */
|
|
149
|
+
iconConfig?: IconColumnConfig;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 完整列类型 - 兼容原生 DataTableColumns
|
|
153
|
+
* 支持普通列、选择列、展开列
|
|
154
|
+
*/
|
|
155
|
+
export type DydxTableColumns<T = any> = (DydxTableColumn<T> | DataTableColumn<T> | DataTableSelectionColumn<T> | DataTableExpandColumn<T>)[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DataTableInst } from 'naive-ui';
|
|
2
|
+
/**
|
|
3
|
+
* DydxNaiveTable 组件暴露的方法和属性
|
|
4
|
+
*/
|
|
5
|
+
export interface DydxNaiveTableExpose {
|
|
6
|
+
/** 获取原生 DataTable 实例 */
|
|
7
|
+
getTableInstance: () => DataTableInst | null;
|
|
8
|
+
/** 清除所有选中 */
|
|
9
|
+
clearChecked: () => void;
|
|
10
|
+
/** 刷新表格(触发 onRefresh) */
|
|
11
|
+
refresh: () => void;
|
|
12
|
+
/** 获取当前可见列的 keys */
|
|
13
|
+
getVisibleColumnKeys: () => string[];
|
|
14
|
+
/** 设置可见列 */
|
|
15
|
+
setVisibleColumnKeys: (keys: string[]) => void;
|
|
16
|
+
/** 重置列设置为默认状态 */
|
|
17
|
+
resetColumnSetting: () => void;
|
|
18
|
+
/** 滚动到指定位置 */
|
|
19
|
+
scrollTo: (options: {
|
|
20
|
+
left?: number;
|
|
21
|
+
top?: number;
|
|
22
|
+
behavior?: ScrollBehavior;
|
|
23
|
+
}) => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ButtonProps, PaginationProps } from 'naive-ui';
|
|
2
|
+
import { VNodeChild } from 'vue';
|
|
3
|
+
import { DydxTableColumns, ActionColumnConfig } from './columns';
|
|
4
|
+
/**
|
|
5
|
+
* 工具栏按钮配置
|
|
6
|
+
*/
|
|
7
|
+
export interface ToolbarButton {
|
|
8
|
+
/** 按钮唯一标识 */
|
|
9
|
+
key: string;
|
|
10
|
+
/** 按钮文字 */
|
|
11
|
+
label: string;
|
|
12
|
+
/** 按钮类型 */
|
|
13
|
+
type?: ButtonProps['type'];
|
|
14
|
+
/** 按钮图标 */
|
|
15
|
+
icon?: () => VNodeChild;
|
|
16
|
+
/** 点击回调 */
|
|
17
|
+
onClick: () => void | Promise<void>;
|
|
18
|
+
/** 是否禁用 */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** 是否显示 */
|
|
21
|
+
show?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 分页字段映射配置
|
|
25
|
+
* 用于适配不同后端返回的字段名
|
|
26
|
+
*/
|
|
27
|
+
export interface PaginationFieldNames {
|
|
28
|
+
/** 页码字段名,默认 'page' */
|
|
29
|
+
page?: string;
|
|
30
|
+
/** 每页条数字段名,默认 'pageSize' */
|
|
31
|
+
pageSize?: string;
|
|
32
|
+
/** 总条数字段名,默认 'itemCount' */
|
|
33
|
+
itemCount?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 分页配置
|
|
37
|
+
* 支持自定义字段名,通过 fieldNames 配置
|
|
38
|
+
*/
|
|
39
|
+
export interface TablePagination {
|
|
40
|
+
/** 当前页码(或自定义字段名对应的值) */
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
/** 每页条数选项 */
|
|
43
|
+
pageSizes?: number[];
|
|
44
|
+
/** 是否显示每页条数选择器 */
|
|
45
|
+
showSizePicker?: boolean;
|
|
46
|
+
/** 是否显示快速跳转 */
|
|
47
|
+
showQuickJumper?: boolean;
|
|
48
|
+
/** 分页前缀 */
|
|
49
|
+
prefix?: PaginationProps['prefix'];
|
|
50
|
+
/** 分页后缀 */
|
|
51
|
+
suffix?: PaginationProps['suffix'];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 分页变化事件返回的数据
|
|
55
|
+
*/
|
|
56
|
+
export interface PageChangeData {
|
|
57
|
+
/** 当前页码(使用配置的字段名) */
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 操作按钮事件参数
|
|
62
|
+
*/
|
|
63
|
+
export interface ActionEventParams<T = any> {
|
|
64
|
+
/** 行数据 */
|
|
65
|
+
row: T;
|
|
66
|
+
/** 行索引 */
|
|
67
|
+
index: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 组件自定义扩展的 Props
|
|
71
|
+
*/
|
|
72
|
+
export interface DydxTableExtendProps<T extends Record<string, any> = Record<string, any>> {
|
|
73
|
+
/** 表格数据 */
|
|
74
|
+
data: T[];
|
|
75
|
+
/** 列配置 */
|
|
76
|
+
columns: DydxTableColumns<T>;
|
|
77
|
+
/** 行数据的唯一标识字段或函数 */
|
|
78
|
+
rowKey: keyof T | ((row: T) => string | number);
|
|
79
|
+
/** 操作列配置 */
|
|
80
|
+
actionColumn?: ActionColumnConfig<T>;
|
|
81
|
+
/** 是否显示新增按钮 */
|
|
82
|
+
showAdd?: boolean;
|
|
83
|
+
/** 新增按钮文字 */
|
|
84
|
+
addButtonText?: string;
|
|
85
|
+
/** 新增按钮点击回调 */
|
|
86
|
+
onAdd?: () => void;
|
|
87
|
+
/** 左侧自定义按钮列表 */
|
|
88
|
+
leftButtons?: ToolbarButton[];
|
|
89
|
+
/** 是否显示刷新按钮 */
|
|
90
|
+
showRefresh?: boolean;
|
|
91
|
+
/** 刷新按钮点击回调 */
|
|
92
|
+
onRefresh?: () => void;
|
|
93
|
+
/** 是否显示列设置 */
|
|
94
|
+
showColumnSetting?: boolean;
|
|
95
|
+
/** 右侧自定义按钮列表 */
|
|
96
|
+
rightButtons?: ToolbarButton[];
|
|
97
|
+
/** 分页配置,false 表示不显示分页,支持 v-model:pagination */
|
|
98
|
+
pagination?: false | TablePagination;
|
|
99
|
+
/** 分页字段映射,用于适配后端字段名 */
|
|
100
|
+
paginationFieldNames?: PaginationFieldNames;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* DydxNaiveTable 组件 Props
|
|
104
|
+
* 不再从 DataTableProps 继承,改为在组件中使用 v-bind="attrs" 透传
|
|
105
|
+
*/
|
|
106
|
+
export interface DydxNaiveTableProps<T extends Record<string, any> = Record<string, any>> extends DydxTableExtendProps<T> {
|
|
107
|
+
/** 加载状态 */
|
|
108
|
+
loading?: boolean;
|
|
109
|
+
/** 选中的行 keys */
|
|
110
|
+
checkedRowKeys?: (string | number)[];
|
|
111
|
+
/** 是否为远程数据源 */
|
|
112
|
+
remote?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* DydxNaiveTable 组件 Emits
|
|
116
|
+
*/
|
|
117
|
+
export interface DydxNaiveTableEmits<T = any> {
|
|
118
|
+
/** 分页数据变化(v-model:pagination) */
|
|
119
|
+
'update:pagination': [pagination: TablePagination];
|
|
120
|
+
/** 分页变化事件,返回完整分页数据 */
|
|
121
|
+
'pageChange': [pagination: PageChangeData];
|
|
122
|
+
/** 选中行变化 */
|
|
123
|
+
'update:checkedRowKeys': [keys: (string | number)[], rows: T[]];
|
|
124
|
+
/** 可见列变化 */
|
|
125
|
+
'update:visibleColumns': [keys: string[]];
|
|
126
|
+
/** 查看按钮点击 */
|
|
127
|
+
'view': [params: ActionEventParams<T>];
|
|
128
|
+
/** 编辑按钮点击 */
|
|
129
|
+
'edit': [params: ActionEventParams<T>];
|
|
130
|
+
/** 删除按钮点击 */
|
|
131
|
+
'delete': [params: ActionEventParams<T>];
|
|
132
|
+
}
|