@aspire-ui/element-component-pro 1.0.0
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 +203 -0
- package/dist/ProForm/FormActions.vue.d.ts +98 -0
- package/dist/ProForm/ProForm.vue.d.ts +223 -0
- package/dist/ProForm/ProFormItem.vue.d.ts +39 -0
- package/dist/ProForm/index.d.ts +7 -0
- package/dist/ProForm/useForm.d.ts +28 -0
- package/dist/element-component-pro.es.js +444 -0
- package/dist/element-component-pro.es.js.map +1 -0
- package/dist/element-component-pro.umd.js +3 -0
- package/dist/element-component-pro.umd.js.map +1 -0
- package/dist/index.d.ts +769 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +178 -0
- package/package.json +49 -0
- package/src/ProForm/FormActions.vue +76 -0
- package/src/ProForm/ProForm.vue +423 -0
- package/src/ProForm/ProFormItem.vue +250 -0
- package/src/ProForm/index.ts +6 -0
- package/src/ProForm/useForm.ts +114 -0
- package/src/index.ts +32 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/types/index.ts +179 -0
- package/src/vite-env.d.ts +1 -0
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ecp-pro-form-item__help-icon[data-v-0e0e5ebb]{margin-left:4px;color:#909399;cursor:help;font-size:14px}.ecp-pro-form-item__help-icon[data-v-0e0e5ebb]:hover{color:#409eff}.ecp-pro-form-item__help-item[data-v-0e0e5ebb]{margin-bottom:4px}.ecp-pro-form-item__help-item[data-v-0e0e5ebb]:last-child{margin-bottom:0}.ecp-pro-form-item__select[data-v-0e0e5ebb]{display:block}.ecp-form-actions[data-v-489c88d2]{text-align:right}.ecp-form-actions__advance[data-v-489c88d2]{margin-right:8px}.el-icon-d-arrow-left.up[data-v-489c88d2]{transform:rotate(90deg)}.el-icon-d-arrow-left.down[data-v-489c88d2]{transform:rotate(-90deg)}.ecp-pro-form[data-v-d75b0fb1]{padding:16px;position:relative}.ecp-pro-form__advance[data-v-d75b0fb1]{margin-bottom:16px}.ecp-pro-form_col[data-v-d75b0fb1]{position:relative;float:right}.el-icon-d-arrow-left.up[data-v-d75b0fb1]{transform:rotate(90deg)}.el-icon-d-arrow-left.down[data-v-d75b0fb1]{transform:rotate(-90deg)}.ecp-form-actions__advance[data-v-d75b0fb1]{position:absolute;bottom:0;left:50%;transform:translate(-50%,-50%)}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** ProTable 列配置 */
|
|
4
|
+
export interface ProColumn {
|
|
5
|
+
/** 列标题 */
|
|
6
|
+
title: string;
|
|
7
|
+
/** 数据字段名 */
|
|
8
|
+
dataIndex: string;
|
|
9
|
+
/** 列宽度 */
|
|
10
|
+
width?: number | string;
|
|
11
|
+
/** 最小宽度 */
|
|
12
|
+
minWidth?: number | string;
|
|
13
|
+
/** 固定列 */
|
|
14
|
+
fixed?: 'left' | 'right';
|
|
15
|
+
/** 是否可排序 */
|
|
16
|
+
sortable?: boolean;
|
|
17
|
+
/** 对齐方式 */
|
|
18
|
+
align?: 'left' | 'center' | 'right';
|
|
19
|
+
/** 是否可调整宽度 */
|
|
20
|
+
resizable?: boolean;
|
|
21
|
+
/** 是否隐藏 */
|
|
22
|
+
hideInTable?: boolean;
|
|
23
|
+
/** 值类型 */
|
|
24
|
+
valueType?: 'text' | 'date' | 'dateTime' | 'option' | 'select' | 'index';
|
|
25
|
+
/** 枚举值映射 */
|
|
26
|
+
valueEnum?: Record<string | number, {
|
|
27
|
+
text: string;
|
|
28
|
+
status?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** 自定义渲染 */
|
|
31
|
+
customRender?: (params: {
|
|
32
|
+
text: unknown;
|
|
33
|
+
record: Record<string, unknown>;
|
|
34
|
+
index: number;
|
|
35
|
+
}) => VNode | string;
|
|
36
|
+
/** 表单项配置(用于搜索) */
|
|
37
|
+
fieldProps?: Record<string, unknown>;
|
|
38
|
+
/** 表单项占位符 */
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
}
|
|
41
|
+
/** ProTable 工具栏配置 */
|
|
42
|
+
export interface ProTableToolBarConfig {
|
|
43
|
+
/** 是否显示刷新按钮 */
|
|
44
|
+
reload?: boolean;
|
|
45
|
+
/** 是否显示密度切换 */
|
|
46
|
+
density?: boolean;
|
|
47
|
+
/** 是否显示列设置 */
|
|
48
|
+
columnSetting?: boolean;
|
|
49
|
+
/** 是否显示全屏 */
|
|
50
|
+
fullScreen?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** 栅格配置 */
|
|
53
|
+
export interface ColEx {
|
|
54
|
+
span?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
pull?: number;
|
|
57
|
+
push?: number;
|
|
58
|
+
xs?: number;
|
|
59
|
+
sm?: number;
|
|
60
|
+
md?: number;
|
|
61
|
+
lg?: number;
|
|
62
|
+
xl?: number;
|
|
63
|
+
}
|
|
64
|
+
/** Render 回调参数 */
|
|
65
|
+
export interface RenderCallbackParams {
|
|
66
|
+
schema: ProFormSchema;
|
|
67
|
+
values: Record<string, unknown>;
|
|
68
|
+
model: Record<string, unknown>;
|
|
69
|
+
field: string;
|
|
70
|
+
}
|
|
71
|
+
/** 滚动到字段的配置 */
|
|
72
|
+
export interface ScrollToFieldOptions {
|
|
73
|
+
/** 滚动行为 */
|
|
74
|
+
behavior?: ScrollBehavior;
|
|
75
|
+
/** 块级对齐 */
|
|
76
|
+
block?: ScrollLogicalPosition;
|
|
77
|
+
/** 行内对齐 */
|
|
78
|
+
inline?: ScrollLogicalPosition;
|
|
79
|
+
}
|
|
80
|
+
/** 表单操作类型(参考 Vben Admin FormActionType) */
|
|
81
|
+
export interface FormActionType {
|
|
82
|
+
getFieldsValue: () => Record<string, unknown>;
|
|
83
|
+
setFieldsValue: (values: Record<string, unknown>) => Promise<void>;
|
|
84
|
+
resetFields: () => Promise<void>;
|
|
85
|
+
validate: (nameList?: string[]) => Promise<unknown>;
|
|
86
|
+
validateFields: (nameList?: string[]) => Promise<unknown>;
|
|
87
|
+
submit: () => Promise<void>;
|
|
88
|
+
scrollToField: (name: string, options?: ScrollToFieldOptions) => Promise<void>;
|
|
89
|
+
clearValidate: (name?: string | string[]) => void;
|
|
90
|
+
updateSchema: (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) => Promise<void>;
|
|
91
|
+
appendSchemaByField: (schema: ProFormSchema, prefixField?: string, first?: boolean) => Promise<void>;
|
|
92
|
+
removeSchemaByField: (field: string | string[]) => Promise<void>;
|
|
93
|
+
setProps: (props: Partial<ProFormProps>) => Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** 时间字段映射 [表单字段, [开始字段, 结束字段], 格式?] */
|
|
96
|
+
export type FieldMapToTime = [string, [string, string], string?];
|
|
97
|
+
/** 表单事件监听器 */
|
|
98
|
+
export type FormListeners = Record<string, ((...args: unknown[]) => unknown) | ((...args: unknown[]) => unknown)[]>;
|
|
99
|
+
/** ProForm Props */
|
|
100
|
+
export interface ProFormProps {
|
|
101
|
+
schemas?: ProFormSchema[];
|
|
102
|
+
initialValues?: Record<string, unknown>;
|
|
103
|
+
labelWidth?: string;
|
|
104
|
+
labelPosition?: 'left' | 'right' | 'top';
|
|
105
|
+
gutter?: number;
|
|
106
|
+
size?: 'medium' | 'small' | 'large';
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
baseColProps?: ColEx;
|
|
109
|
+
showSubmitButton?: boolean;
|
|
110
|
+
showResetButton?: boolean;
|
|
111
|
+
submitButtonText?: string;
|
|
112
|
+
resetButtonText?: string;
|
|
113
|
+
submitButtonIcon?: string;
|
|
114
|
+
resetButtonIcon?: string;
|
|
115
|
+
actionColOptions?: ColEx;
|
|
116
|
+
showAdvancedButton?: boolean;
|
|
117
|
+
autoAdvancedLine?: number;
|
|
118
|
+
alwaysShowLines?: number;
|
|
119
|
+
submitFunc?: () => Promise<void>;
|
|
120
|
+
resetFunc?: () => Promise<void>;
|
|
121
|
+
fieldMapToTime?: FieldMapToTime[];
|
|
122
|
+
/** 透传给 el-form 的事件监听器 */
|
|
123
|
+
formListeners?: FormListeners;
|
|
124
|
+
}
|
|
125
|
+
/** ProForm 表单项配置 */
|
|
126
|
+
export interface ProFormSchema {
|
|
127
|
+
/** 字段名 */
|
|
128
|
+
field: string;
|
|
129
|
+
/** 标签 */
|
|
130
|
+
label: string;
|
|
131
|
+
/** 组件类型 */
|
|
132
|
+
component?: 'input' | 'select' | 'date-picker' | 'date-range' | 'input-number' | 'switch' | 'cascader' | 'checkbox' | 'radio';
|
|
133
|
+
/** 组件属性,支持函数 */
|
|
134
|
+
componentProps?: Record<string, unknown> | ((params: RenderCallbackParams & {
|
|
135
|
+
formActionType?: FormActionType;
|
|
136
|
+
}) => Record<string, unknown>);
|
|
137
|
+
/** 占位符 */
|
|
138
|
+
placeholder?: string;
|
|
139
|
+
/** 默认值 */
|
|
140
|
+
defaultValue?: unknown;
|
|
141
|
+
/** 是否必填 */
|
|
142
|
+
required?: boolean;
|
|
143
|
+
/** 校验规则 */
|
|
144
|
+
rules?: Array<Record<string, unknown>>;
|
|
145
|
+
/** 栅格占位 */
|
|
146
|
+
colProps?: ColEx;
|
|
147
|
+
/** 是否隐藏(静态) */
|
|
148
|
+
hidden?: boolean;
|
|
149
|
+
/** 自定义渲染(替代 component) */
|
|
150
|
+
render?: (params: RenderCallbackParams) => VNode | VNode[] | string;
|
|
151
|
+
/** 自定义 slot 名称,对应父组件的具名插槽 */
|
|
152
|
+
slot?: string;
|
|
153
|
+
/** 动态显示,css 控制,不删除 dom */
|
|
154
|
+
show?: boolean | ((params: RenderCallbackParams) => boolean);
|
|
155
|
+
/** 动态显示,js 控制,会删除 dom */
|
|
156
|
+
ifShow?: boolean | ((params: RenderCallbackParams) => boolean);
|
|
157
|
+
/** 动态禁用 */
|
|
158
|
+
dynamicDisabled?: boolean | ((params: RenderCallbackParams) => boolean);
|
|
159
|
+
/** 动态校验规则 */
|
|
160
|
+
dynamicRules?: Array<Record<string, unknown>> | ((params: RenderCallbackParams) => Array<Record<string, unknown>>);
|
|
161
|
+
/** 依赖字段 */
|
|
162
|
+
dependencies?: string[];
|
|
163
|
+
/** 标签右侧温馨提示,支持 string 或 string[] */
|
|
164
|
+
helpMessage?: string | string[];
|
|
165
|
+
/** 温馨提示组件的 props */
|
|
166
|
+
helpComponentProps?: Record<string, unknown>;
|
|
167
|
+
}
|
|
168
|
+
/** ProDescriptions 描述项配置 */
|
|
169
|
+
export interface ProDescriptionsSchema {
|
|
170
|
+
/** 标签 */
|
|
171
|
+
label: string;
|
|
172
|
+
/** 数据字段 */
|
|
173
|
+
dataIndex: string;
|
|
174
|
+
/** 自定义渲染 */
|
|
175
|
+
render?: (value: unknown, record?: Record<string, unknown>) => VNode | string;
|
|
176
|
+
/** 栅格占位 */
|
|
177
|
+
span?: number;
|
|
178
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aspire-ui/element-component-pro",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Element UI 二次封装组件库,基于 Vue 2.7 + TypeScript + setup 语法糖,实现 VbenAdmin 风格的 Pro 组件",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/element-component-pro.umd.js",
|
|
7
|
+
"module": "./dist/element-component-pro.es.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/element-component-pro.es.js",
|
|
12
|
+
"require": "./dist/element-component-pro.umd.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "vite",
|
|
23
|
+
"build": "vite build",
|
|
24
|
+
"preview": "vite preview"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vue": "^2.7.0",
|
|
28
|
+
"element-ui": "^2.15.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@vitejs/plugin-vue2": "^2.3.1",
|
|
32
|
+
"vue-router": "^3.6.5",
|
|
33
|
+
"element-ui": "^2.15.14",
|
|
34
|
+
"typescript": "^5.3.0",
|
|
35
|
+
"vite": "^4.5.0",
|
|
36
|
+
"vite-plugin-dts": "^3.7.0",
|
|
37
|
+
"vue": "^2.7.16",
|
|
38
|
+
"vue-tsc": "^1.8.27"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"vue",
|
|
42
|
+
"element-ui",
|
|
43
|
+
"component-library",
|
|
44
|
+
"pro-table",
|
|
45
|
+
"pro-form",
|
|
46
|
+
"vben-admin"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT"
|
|
49
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ecp-form-actions">
|
|
3
|
+
<slot name="submitBefore" />
|
|
4
|
+
<el-button v-if="showSubmitButton" type="primary" :icon="submitButtonIcon" :loading="submitLoading"
|
|
5
|
+
@click="$emit('submit')">
|
|
6
|
+
{{ submitButtonText }}
|
|
7
|
+
</el-button>
|
|
8
|
+
<slot name="resetBefore" />
|
|
9
|
+
<el-button v-if="showResetButton" :icon="resetButtonIcon" @click="$emit('reset')">
|
|
10
|
+
{{ resetButtonText }}
|
|
11
|
+
</el-button>
|
|
12
|
+
<slot name="actions" />
|
|
13
|
+
<!-- <el-button v-if="showAdvancedButton && hasMoreFields" type="text" class="ecp-form-actions__advance"
|
|
14
|
+
@click="$emit('toggle')">
|
|
15
|
+
<i class="el-icon-d-arrow-left" :class="collapsed ? 'down' : 'up'" />
|
|
16
|
+
{{ collapsed ? '展开' : '收起' }}
|
|
17
|
+
</el-button> -->
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import type { ColEx } from '../types'
|
|
23
|
+
|
|
24
|
+
withDefaults(
|
|
25
|
+
defineProps<{
|
|
26
|
+
showActionButtonGroup?: boolean
|
|
27
|
+
showSubmitButton?: boolean
|
|
28
|
+
showResetButton?: boolean
|
|
29
|
+
submitButtonText?: string
|
|
30
|
+
resetButtonText?: string
|
|
31
|
+
submitButtonIcon?: string
|
|
32
|
+
resetButtonIcon?: string
|
|
33
|
+
submitLoading?: boolean
|
|
34
|
+
showAdvancedButton?: boolean
|
|
35
|
+
hasMoreFields?: boolean
|
|
36
|
+
collapsed?: boolean
|
|
37
|
+
actionColOptions?: ColEx
|
|
38
|
+
}>(),
|
|
39
|
+
{
|
|
40
|
+
showActionButtonGroup: true,
|
|
41
|
+
showSubmitButton: true,
|
|
42
|
+
showResetButton: true,
|
|
43
|
+
submitButtonText: '提交',
|
|
44
|
+
resetButtonText: '重置',
|
|
45
|
+
submitButtonIcon: 'el-icon-search',
|
|
46
|
+
resetButtonIcon: 'el-icon-refresh-left',
|
|
47
|
+
submitLoading: false,
|
|
48
|
+
showAdvancedButton: false,
|
|
49
|
+
hasMoreFields: false,
|
|
50
|
+
collapsed: true,
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
defineEmits<{
|
|
55
|
+
(e: 'submit'): void
|
|
56
|
+
(e: 'reset'): void
|
|
57
|
+
(e: 'toggle'): void
|
|
58
|
+
}>()
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<style scoped>
|
|
62
|
+
/* .ecp-form-actions {
|
|
63
|
+
} */
|
|
64
|
+
.ecp-form-actions {
|
|
65
|
+
text-align: right;
|
|
66
|
+
}
|
|
67
|
+
.ecp-form-actions__advance {
|
|
68
|
+
margin-right: 8px;
|
|
69
|
+
}
|
|
70
|
+
.el-icon-d-arrow-left.up {
|
|
71
|
+
transform:rotate(90deg);
|
|
72
|
+
}
|
|
73
|
+
.el-icon-d-arrow-left.down {
|
|
74
|
+
transform:rotate(-90deg);
|
|
75
|
+
}
|
|
76
|
+
</style>
|