@hz_yujin/vue-smart-table 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.
@@ -0,0 +1,20 @@
1
+ import { SmartColumnSchema } from '../ProSmartTable/column-schema';
2
+ import { ProColumnEditorProps } from './types';
3
+ declare const _default: import('vue').DefineComponent<ProColumnEditorProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
4
+ "update:modelValue": (value: boolean) => any;
5
+ save: (columns: SmartColumnSchema[]) => any;
6
+ restore: () => any;
7
+ cancel: () => any;
8
+ }, string, import('vue').PublicProps, Readonly<ProColumnEditorProps> & Readonly<{
9
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
10
+ onSave?: ((columns: SmartColumnSchema[]) => any) | undefined;
11
+ onRestore?: (() => any) | undefined;
12
+ onCancel?: (() => any) | undefined;
13
+ }>, {
14
+ modelValue: boolean;
15
+ columns: SmartColumnSchema[];
16
+ defaultColumns: SmartColumnSchema[];
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
18
+ listRef: HTMLDivElement;
19
+ }, any>;
20
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as ProColumnEditor } from './ProColumnEditor.vue';
2
+ export type { ProColumnEditorProps, ProColumnEditorEmits } from './types';
@@ -0,0 +1,14 @@
1
+ import { SmartColumnSchema } from '../ProSmartTable/column-schema';
2
+ export interface ProColumnEditorProps {
3
+ modelValue?: boolean;
4
+ columns?: SmartColumnSchema[];
5
+ /** 恢复默认时使用的原始列 */
6
+ defaultColumns?: SmartColumnSchema[];
7
+ }
8
+ export interface ProColumnEditorEmits {
9
+ (e: 'update:modelValue', value: boolean): void;
10
+ (e: 'save', columns: SmartColumnSchema[]): void;
11
+ /** 确认恢复默认:父级应持久化空配置(如 DB columns_json = [])并应用默认列 */
12
+ (e: 'restore'): void;
13
+ (e: 'cancel'): void;
14
+ }
@@ -0,0 +1,114 @@
1
+ import { TableInstance } from 'element-plus';
2
+ import { SmartColumnSchema } from './column-schema';
3
+ import { ProSmartTablePagination, ProSmartTableProps, ProSmartTableSkeletonConfig } from './types';
4
+ declare function __VLS_template(): {
5
+ attrs: Partial<{}>;
6
+ slots: Partial<Record<`col-${string}`, (_: any) => any>> & Partial<Record<`form-${string}`, (_: {
7
+ model: Record<string, unknown>;
8
+ column: {
9
+ id: string;
10
+ prop: string;
11
+ label: string;
12
+ minWidth?: number | undefined;
13
+ width?: number | string | undefined;
14
+ sortable?: boolean | "custom" | undefined;
15
+ searchable?: boolean | undefined;
16
+ formable?: boolean | undefined;
17
+ required?: boolean | undefined;
18
+ formType?: import('./column-schema').SmartFormControlType | undefined;
19
+ formOptions?: {
20
+ label: string;
21
+ value: string | number | boolean;
22
+ disabled?: boolean | undefined;
23
+ children?: /*elided*/ any[] | undefined;
24
+ }[] | undefined;
25
+ searchPlaceholder?: string | undefined;
26
+ fixed?: boolean | "left" | "right" | undefined;
27
+ visible?: boolean | undefined;
28
+ source?: import('./column-schema').SmartColumnSource | undefined;
29
+ deletable?: boolean | undefined;
30
+ columnProps?: Record<string, unknown> | undefined;
31
+ formProps?: Record<string, unknown> | undefined;
32
+ };
33
+ value: unknown;
34
+ mode: "create" | "edit";
35
+ }) => any>> & {
36
+ 'toolbar-left'?(_: {}): any;
37
+ 'toolbar-right'?(_: {}): any;
38
+ skeleton?(_: {}): any;
39
+ default?(_: {}): any;
40
+ pagination?(_: {}): any;
41
+ 'form-extra'?(_: {
42
+ model: Record<string, unknown>;
43
+ mode: "create" | "edit";
44
+ visible: boolean;
45
+ }): any;
46
+ };
47
+ refs: {
48
+ tableRef: unknown;
49
+ formRef: unknown;
50
+ };
51
+ rootEl: any;
52
+ };
53
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
54
+ declare const __VLS_component: import('vue').DefineComponent<ProSmartTableProps, {
55
+ tableRef: TableInstance | null;
56
+ openColumnEditor: () => void;
57
+ openCreate: () => void;
58
+ openEdit: (row: Record<string, unknown>) => void;
59
+ getSearchModel: () => Record<string, unknown>;
60
+ getColumns: () => SmartColumnSchema[];
61
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
62
+ search: (...args: any[]) => void;
63
+ reset: (...args: any[]) => void;
64
+ update: (...args: any[]) => void;
65
+ "update:columns": (...args: any[]) => void;
66
+ create: (...args: any[]) => void;
67
+ "columns-change": (...args: any[]) => void;
68
+ "columns-reset": (...args: any[]) => void;
69
+ "page-change": (...args: any[]) => void;
70
+ "update:pagination": (...args: any[]) => void;
71
+ refresh: (...args: any[]) => void;
72
+ "sort-change": (...args: any[]) => void;
73
+ }, string, import('vue').PublicProps, Readonly<ProSmartTableProps> & Readonly<{
74
+ onSearch?: ((...args: any[]) => any) | undefined;
75
+ onReset?: ((...args: any[]) => any) | undefined;
76
+ onUpdate?: ((...args: any[]) => any) | undefined;
77
+ "onUpdate:columns"?: ((...args: any[]) => any) | undefined;
78
+ onCreate?: ((...args: any[]) => any) | undefined;
79
+ "onColumns-change"?: ((...args: any[]) => any) | undefined;
80
+ "onColumns-reset"?: ((...args: any[]) => any) | undefined;
81
+ "onPage-change"?: ((...args: any[]) => any) | undefined;
82
+ "onUpdate:pagination"?: ((...args: any[]) => any) | undefined;
83
+ onRefresh?: ((...args: any[]) => any) | undefined;
84
+ "onSort-change"?: ((...args: any[]) => any) | undefined;
85
+ }>, {
86
+ columns: SmartColumnSchema[];
87
+ data: Record<string, unknown>[];
88
+ showToolbar: boolean;
89
+ showColumnEditor: boolean;
90
+ showRefresh: boolean;
91
+ showCreate: boolean;
92
+ showSeq: boolean;
93
+ seqWidth: number | string;
94
+ showSelection: boolean;
95
+ showSearch: boolean;
96
+ searchCollapsible: boolean;
97
+ searchCollapseVisibleCount: number;
98
+ searchDefaultExpanded: boolean;
99
+ formTitle: string;
100
+ formWidth: number | string;
101
+ loading: boolean;
102
+ skeleton: boolean | ProSmartTableSkeletonConfig;
103
+ pagination: false | ProSmartTablePagination;
104
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
105
+ tableRef: unknown;
106
+ formRef: unknown;
107
+ }, any>;
108
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
109
+ export default _default;
110
+ type __VLS_WithTemplateSlots<T, S> = T & {
111
+ new (): {
112
+ $slots: S;
113
+ };
114
+ };
@@ -0,0 +1,26 @@
1
+ type __VLS_Props = {
2
+ rows?: number;
3
+ animated?: boolean;
4
+ columns?: number;
5
+ };
6
+ declare function __VLS_template(): {
7
+ attrs: Partial<{}>;
8
+ slots: {
9
+ default?(_: {}): any;
10
+ };
11
+ refs: {};
12
+ rootEl: HTMLDivElement;
13
+ };
14
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
+ columns: number;
17
+ rows: number;
18
+ animated: boolean;
19
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
20
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
21
+ export default _default;
22
+ type __VLS_WithTemplateSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,12 @@
1
+ import { SmartColumnSchema } from './column-schema';
2
+ type __VLS_Props = {
3
+ modelValue: unknown;
4
+ column: SmartColumnSchema;
5
+ mode?: 'search' | 'form';
6
+ };
7
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
8
+ "update:modelValue": (value: unknown) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ "onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
11
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
+ export default _default;
@@ -0,0 +1,35 @@
1
+ import { SmartColumnSchema } from './column-schema';
2
+ type __VLS_Props = {
3
+ columns: SmartColumnSchema[];
4
+ modelValue: Record<string, unknown>;
5
+ collapsible?: boolean;
6
+ /** 收起时展示前 N 个字段,默认 3 */
7
+ collapseVisibleCount?: number;
8
+ defaultExpanded?: boolean;
9
+ searchText?: string;
10
+ resetText?: string;
11
+ expandText?: string;
12
+ collapseText?: string;
13
+ /** 持久化展开状态的 storage key */
14
+ persistKey?: string;
15
+ };
16
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
17
+ "update:modelValue": (value: Record<string, unknown>) => any;
18
+ search: (value: Record<string, unknown>) => any;
19
+ reset: (value: Record<string, unknown>) => any;
20
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
22
+ onSearch?: ((value: Record<string, unknown>) => any) | undefined;
23
+ onReset?: ((value: Record<string, unknown>) => any) | undefined;
24
+ }>, {
25
+ collapsible: boolean;
26
+ collapseVisibleCount: number;
27
+ defaultExpanded: boolean;
28
+ searchText: string;
29
+ resetText: string;
30
+ expandText: string;
31
+ collapseText: string;
32
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
33
+ fieldsRef: HTMLDivElement;
34
+ }, HTMLElement>;
35
+ export default _default;
@@ -0,0 +1,56 @@
1
+ /** 表单 / 查询控件类型 */
2
+ export type SmartFormControlType = 'input' | 'password' | 'textarea' | 'number' | 'select' | 'select-multiple' | 'radio' | 'checkbox' | 'checkbox-group' | 'switch' | 'date' | 'datetime' | 'daterange' | 'date-range' | 'datetimerange' | 'datetime-range' | 'time' | 'timerange' | 'time-range' | 'month' | 'year' | 'week' | 'cascader' | 'tree-select' | 'autocomplete' | 'rate' | 'slider' | 'color';
3
+ export declare const SMART_FORM_CONTROL_OPTIONS: {
4
+ label: string;
5
+ value: SmartFormControlType;
6
+ }[];
7
+ /** 列来源:固定(业务预置)/ 自定义(列管理新增) */
8
+ export type SmartColumnSource = 'fixed' | 'custom';
9
+ export interface SmartSelectOption {
10
+ label: string;
11
+ value: string | number | boolean;
12
+ disabled?: boolean;
13
+ children?: SmartSelectOption[];
14
+ }
15
+ export interface SmartColumnSchema {
16
+ /** 稳定唯一 id(拖拽 / 删除 / 持久化) */
17
+ id: string;
18
+ /** 对应 el-table-column 的 prop / 数据字段 */
19
+ prop: string;
20
+ /** 列标题 */
21
+ label: string;
22
+ minWidth?: number;
23
+ width?: number | string;
24
+ /** 是否可排序 */
25
+ sortable?: boolean | 'custom';
26
+ /** 是否作为查询条件 */
27
+ searchable?: boolean;
28
+ /** 是否出现在新增/编辑表单 */
29
+ formable?: boolean;
30
+ /** 表单是否必填(仅 formable 时有效) */
31
+ required?: boolean;
32
+ /** 表单控件类型 */
33
+ formType?: SmartFormControlType;
34
+ /** select / radio / cascader 等选项 */
35
+ formOptions?: SmartSelectOption[];
36
+ /** 查询占位符 */
37
+ searchPlaceholder?: string;
38
+ /** 固定列 */
39
+ fixed?: boolean | 'left' | 'right';
40
+ /** 是否在表格中显示 */
41
+ visible?: boolean;
42
+ /** 列来源 */
43
+ source?: SmartColumnSource;
44
+ /** 是否允许删除(固定列默认不可删) */
45
+ deletable?: boolean;
46
+ /** 透传给 el-table-column 的额外属性 */
47
+ columnProps?: Record<string, unknown>;
48
+ /** 表单项额外属性 */
49
+ formProps?: Record<string, unknown>;
50
+ }
51
+ export declare function createColumnId(prefix?: string): string;
52
+ export declare function normalizeColumn(col: SmartColumnSchema): SmartColumnSchema;
53
+ export declare function cloneColumns(columns: SmartColumnSchema[]): SmartColumnSchema[];
54
+ export declare function createEmptyColumn(partial?: Partial<SmartColumnSchema>): SmartColumnSchema;
55
+ /** 统一别名,便于渲染分支判断 */
56
+ export declare function resolveFormControlType(type?: SmartFormControlType): SmartFormControlType;
@@ -0,0 +1,3 @@
1
+ export { default as ProSmartTable } from './ProSmartTable.vue';
2
+ export type { ProSmartTableProps, ProSmartTableEmits, ProSmartTableExpose, ProSmartTablePagination, ProSmartTablePageChangePayload, ProSmartTableSkeletonConfig, SmartColumnSchema, SmartFormControlType, SmartColumnSource, SmartSelectOption, } from './types';
3
+ export { SMART_FORM_CONTROL_OPTIONS, createColumnId, normalizeColumn, cloneColumns, createEmptyColumn, resolveFormControlType, } from './column-schema';
@@ -0,0 +1,112 @@
1
+ import { TableInstance } from 'element-plus';
2
+ import { SmartColumnSchema } from './column-schema';
3
+ export type { SmartColumnSchema, SmartFormControlType, SmartColumnSource, SmartSelectOption } from './column-schema';
4
+ export interface ProSmartTablePagination {
5
+ currentPage?: number;
6
+ pageSize?: number;
7
+ total?: number;
8
+ pageSizes?: number[];
9
+ /** 默认 total, sizes, prev, pager, next, jumper */
10
+ layout?: string;
11
+ background?: boolean;
12
+ /**
13
+ * 分页尺寸,默认 small(与 vue-base-table 一致)
14
+ * @deprecated 请使用 size
15
+ */
16
+ small?: boolean;
17
+ size?: 'large' | 'default' | 'small';
18
+ pagerCount?: number;
19
+ /**
20
+ * local:前端按 page 切片 data(未传 total 时默认)
21
+ * remote:data 即为当前页,需传 total
22
+ */
23
+ mode?: 'local' | 'remote';
24
+ }
25
+ export interface ProSmartTablePageChangePayload {
26
+ currentPage: number;
27
+ pageSize: number;
28
+ }
29
+ export interface ProSmartTableSkeletonConfig {
30
+ /** 骨架行数,默认取 pagination.pageSize(上限 10),否则 5 */
31
+ rows?: number;
32
+ /** 是否开启动画,默认 true */
33
+ animated?: boolean;
34
+ /**
35
+ * 仅无数据时用骨架;有数据刷新时仍用转圈
36
+ * @default true
37
+ */
38
+ onlyEmpty?: boolean;
39
+ }
40
+ export interface ProSmartTableProps {
41
+ /** 表格数据 */
42
+ data?: Record<string, unknown>[];
43
+ /** 列 schema(驱动表格 / 查询 / 表单) */
44
+ columns?: SmartColumnSchema[];
45
+ /** 是否展示工具栏(新增 / 编辑列) */
46
+ showToolbar?: boolean;
47
+ /** 是否展示「编辑列」入口 */
48
+ showColumnEditor?: boolean;
49
+ /** 是否展示刷新按钮,默认 true */
50
+ showRefresh?: boolean;
51
+ /** 是否展示「新增」按钮 */
52
+ showCreate?: boolean;
53
+ /** 是否展示序号列,默认 true */
54
+ showSeq?: boolean;
55
+ /** 序号列宽度,默认 60 */
56
+ seqWidth?: number | string;
57
+ /** 是否展示多选列,默认 false */
58
+ showSelection?: boolean;
59
+ /** 是否展示查询区 */
60
+ showSearch?: boolean;
61
+ /** 查询区是否可收起展开,默认 true */
62
+ searchCollapsible?: boolean;
63
+ /** 收起时展示的查询字段数,默认 3 */
64
+ searchCollapseVisibleCount?: number;
65
+ /** 查询区默认是否展开,默认 false */
66
+ searchDefaultExpanded?: boolean;
67
+ /** 本地持久化 key;有值时保存列配置到 localStorage */
68
+ persistKey?: string;
69
+ /** 新增/编辑弹框标题前缀 */
70
+ formTitle?: string;
71
+ /** 新增/编辑弹框宽度,默认 45% */
72
+ formWidth?: number | string;
73
+ /** 加载中(骨架 / 转圈) */
74
+ loading?: boolean;
75
+ /**
76
+ * 骨架屏:默认开启;`false` 关闭;对象可配 rows / animated / onlyEmpty
77
+ * @default true
78
+ */
79
+ skeleton?: boolean | ProSmartTableSkeletonConfig;
80
+ /**
81
+ * 分页:传 `false` 关闭;默认开启(共 N 条 / 条每页 / 页码 / 前往)
82
+ */
83
+ pagination?: false | ProSmartTablePagination;
84
+ }
85
+ export interface ProSmartTableEmits {
86
+ (e: 'update:columns', columns: SmartColumnSchema[]): void;
87
+ (e: 'search', model: Record<string, unknown>): void;
88
+ (e: 'reset'): void;
89
+ (e: 'create', model: Record<string, unknown>): void;
90
+ (e: 'update', model: Record<string, unknown>): void;
91
+ (e: 'columns-change', columns: SmartColumnSchema[]): void;
92
+ /** 列管理「恢复默认」:业务侧应将持久化配置清空(如 DB 存 []) */
93
+ (e: 'columns-reset'): void;
94
+ (e: 'page-change', payload: ProSmartTablePageChangePayload): void;
95
+ (e: 'update:pagination', pagination: ProSmartTablePagination): void;
96
+ (e: 'refresh'): void;
97
+ /** 透传 el-table;远程排序请配合 sortable:'custom' 或 remote 分页 */
98
+ (e: 'sort-change', payload: {
99
+ column: unknown;
100
+ prop: string;
101
+ order: 'ascending' | 'descending' | null;
102
+ }): void;
103
+ }
104
+ export interface ProSmartTableExpose {
105
+ /** 底层 el-table 实例 */
106
+ tableRef: TableInstance | null;
107
+ openColumnEditor: () => void;
108
+ openCreate: () => void;
109
+ openEdit: (row: Record<string, unknown>) => void;
110
+ getSearchModel: () => Record<string, unknown>;
111
+ getColumns: () => SmartColumnSchema[];
112
+ }
@@ -0,0 +1,7 @@
1
+ export type { ProSmartTableProps, ProSmartTableEmits, ProSmartTableExpose, ProSmartTablePagination, ProSmartTablePageChangePayload, ProSmartTableSkeletonConfig, SmartColumnSchema, SmartFormControlType, SmartColumnSource, SmartSelectOption, } from './components/ProSmartTable';
2
+ export { ProSmartTable, SMART_FORM_CONTROL_OPTIONS, createColumnId, normalizeColumn, cloneColumns, createEmptyColumn, resolveFormControlType, } from './components/ProSmartTable';
3
+ export type { ProColumnEditorProps, ProColumnEditorEmits, } from './components/ProColumnEditor';
4
+ export { ProColumnEditor } from './components/ProColumnEditor';
5
+ export type { VueSmartTableOptions } from './plugin';
6
+ export { VueSmartTable } from './plugin';
7
+ export { default } from './plugin';
@@ -0,0 +1,8 @@
1
+ import { Plugin } from 'vue';
2
+ export interface VueSmartTableOptions {
3
+ /** 全局组件名前缀,默认无前缀 */
4
+ prefix?: string;
5
+ }
6
+ declare const VueSmartTable: Plugin<VueSmartTableOptions>;
7
+ export { VueSmartTable };
8
+ export default VueSmartTable;
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@hz_yujin/vue-smart-table",
3
+ "version": "0.1.2",
4
+ "description": "Vue 3 ProSmartTable:基于 el-table 全量透传,列 schema 驱动查询 / 表单 / 列管理抽屉",
5
+ "type": "module",
6
+ "keywords": [
7
+ "vue",
8
+ "vue3",
9
+ "table",
10
+ "el-table",
11
+ "component",
12
+ "typescript",
13
+ "element-plus",
14
+ "pro-smart-table",
15
+ "crud"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "license": "MIT",
21
+ "author": "hz_yujin",
22
+ "homepage": "https://www.npmjs.com/package/@hz_yujin/vue-smart-table",
23
+ "bugs": {
24
+ "url": "https://www.npmjs.com/package/@hz_yujin/vue-smart-table"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "LICENSE",
29
+ "README.md",
30
+ "CHANGELOG.md"
31
+ ],
32
+ "main": "./dist/index.js",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./style.css": "./dist/index.css",
42
+ "./package.json": "./package.json"
43
+ },
44
+ "sideEffects": [
45
+ "**/*.css",
46
+ "**/*.vue"
47
+ ],
48
+ "scripts": {
49
+ "build": "vue-tsc -b && vite build",
50
+ "prepublishOnly": "pnpm run build"
51
+ },
52
+ "peerDependencies": {
53
+ "@element-plus/icons-vue": "^2.3.0",
54
+ "element-plus": "^2.9.0",
55
+ "vue": "^3.5.0"
56
+ },
57
+ "devDependencies": {
58
+ "@element-plus/icons-vue": "^2.3.2",
59
+ "@types/node": "^24.13.3",
60
+ "@vitejs/plugin-vue": "^6.0.7",
61
+ "@vue/tsconfig": "^0.9.1",
62
+ "element-plus": "^2.14.2",
63
+ "typescript": "~6.0.2",
64
+ "vite": "^8.1.1",
65
+ "vite-plugin-dts": "^4.5.4",
66
+ "vue": "^3.5.39",
67
+ "vue-tsc": "^3.3.5"
68
+ }
69
+ }