@elementplus-kit/uikit 1.0.0 → 1.0.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.
Files changed (37) hide show
  1. package/aaaindex.ts +55 -0
  2. package/components/config.ts +4 -0
  3. package/components/dialog/index.ts +5 -4
  4. package/components/dialog/src/index.ts +12 -4
  5. package/components/drawer/index.ts +3 -4
  6. package/components/drawer/src/index.ts +10 -3
  7. package/components/form/index.ts +4 -8
  8. package/components/form/src/FormItem.ts +3 -3
  9. package/components/form/src/index.ts +3 -2
  10. package/components/index.ts +41 -0
  11. package/components/pagination/index.ts +4 -5
  12. package/components/pagination/src/index.ts +10 -3
  13. package/components/search/index.ts +4 -56
  14. package/components/search/src/index-/346/272/220.vue +256 -0
  15. package/components/search/src/index.tsx +172 -0
  16. package/components/search/style/index.scss +93 -0
  17. package/components/table/index.ts +4 -7
  18. package/components/table/src/TableColumn.ts +116 -0
  19. package/components/table/src/index.ts +207 -8
  20. package/components/table/src/index2.ts +219 -0
  21. package/components/table/src/index3.ts +233 -0
  22. package/components/table2/index.ts +3 -4
  23. package/components/table2/src/index.ts +9 -202
  24. package/components/{table → table2}/src/types.ts +39 -39
  25. package/components//346/250/241/346/235/277/ttt.ts +3 -2
  26. package/components//346/250/241/346/235/277/ttt.vue +18 -0
  27. package/index.ts +2 -0
  28. package/package.json +17 -18
  29. package/aaaindex.js +0 -18
  30. package/components/index.js +0 -50
  31. /package/components/{table2 → table}/src/constants.ts +0 -0
  32. /package/components/{table2 → table}/src/tableaa.ts +0 -0
  33. /package/components/{table2 → table}/src/type.ts +0 -0
  34. /package/components/table/{style → type}/index.scss +0 -0
  35. /package/components/{table → table2}/src/config.ts +0 -0
  36. /package/components/{table → table2}/src/render.ts +0 -0
  37. /package/components/table2/{type → style}/index.scss +0 -0
package/aaaindex.ts ADDED
@@ -0,0 +1,55 @@
1
+ // // 引入封装好的组件
2
+ // // import kButton from "./k-button/index.vue";
3
+ // // 将来如果有其它组件,都可以写到这个数组里
4
+ // // const coms = [kButton];
5
+
6
+ // // 批量组件注册
7
+ // const install = function (Vue, options) {
8
+ // console.log("🚀 ~ install ~ Vue:", Vue);
9
+ // console.log("插件安装了 ", options);
10
+
11
+ // coms.forEach((com) => {
12
+ // console.log("🚀 ~ install ~ com:", com);
13
+ // Vue.component("k-button", com);
14
+ // });
15
+ // };
16
+
17
+ // import { capitalize } from "lodash-es";
18
+
19
+ // // import { prefix as basePrefix } from "./config.ts";
20
+ // // 将来如果有其它组件,都可以写到这个数组里
21
+ // // const coms = [CForm, CTable, CTable2, CPagination, CDialog, CDrawer, CSearch];
22
+
23
+ // // 批量组件注册
24
+ // const install = function (app, options = {}) {
25
+ // // 获取自定义前缀,默认使用组件原名称
26
+ // // let { prefix = "" } = options;
27
+ // // prefix = capitalize(prefix) || basePrefix;
28
+ // // // 循环注册
29
+ // // coms.forEach((item) => {
30
+ // // // 组件可能直接是组件对象,或者有com属性
31
+ // // const component = item.com || item;
32
+ // // const componentName = component.name || item.name;
33
+ // // if (componentName) {
34
+ // // // 生成注册名称:前缀 + 组件名
35
+ // // const registerName = prefix
36
+ // // ? `${prefix}${componentName.replace(/^[A-Z]/, (char) =>
37
+ // // char.toLowerCase()
38
+ // // )}`
39
+ // // : componentName;
40
+ // // // 注册组件
41
+ // // app.component(registerName, component);
42
+ // // }
43
+ // // });
44
+ // };
45
+
46
+ // // 创建插件对象,包含install方法
47
+ // const plugin = {
48
+ // install,
49
+ // };
50
+
51
+ // // 导出插件
52
+ // // export default plugin; // 这个方法以后再使用的时候可以被use调用
53
+ // // 为什么导出为install? 安装 Vue.js 插件。如果插件是一个对象,必须提供 install 方法。
54
+ // // 如果插件是一个函数,它会被作为install 方法。install 方法调用时,会将 Vue 作为参数传入。
55
+ // export default install; // 这个方法以后再使用的时候可以被use调用
@@ -0,0 +1,4 @@
1
+ // 组件配置
2
+ // 组件名称前缀 组件标识 class 前缀
3
+ import { capitalize } from "lodash-es";
4
+ export const prefix = capitalize("C"); // 首字母大写 其他字母小写
@@ -1,5 +1,6 @@
1
1
  import Dialog from "./src/index";
2
- // import './style/index.scss'
3
-
4
- export const CDialog = Dialog;
5
- export default { com: Dialog, name: "CDialog" };
2
+ export * from "./src/index";
3
+ // 把变量 Dialog 导出为 CDialog
4
+ // export { Dialog, Dialog as CDialog };
5
+ export { Dialog };
6
+ export default Dialog;
@@ -1,12 +1,20 @@
1
- import { ref, h, computed, toRefs, type ExtractPropTypes } from "vue";
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
2
9
  import { ElDialog } from "element-plus";
3
10
  import { defaultAttrs } from "./constants.ts";
4
-
11
+ import { prefix } from "../../config.ts";
5
12
  const propsAttrs = {};
6
13
 
7
14
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
8
15
 
9
- export default {
16
+ export default defineComponent({
17
+ name: `${prefix}Dialog`,
10
18
  // props: propsAttrs,
11
19
  // emits: eventList,
12
20
 
@@ -43,4 +51,4 @@ export default {
43
51
  // 返回渲染函数
44
52
  return () => render();
45
53
  },
46
- };
54
+ });
@@ -1,5 +1,4 @@
1
1
  import Drawer from "./src/index";
2
- // import './style/index.scss'
3
-
4
- export const CDrawer = Drawer;
5
- export default { com: Drawer, name: "CDrawer" };
2
+ export * from "./src/index";
3
+ export { Drawer };
4
+ export default Drawer;
@@ -1,4 +1,11 @@
1
- import { ref, h, computed, toRefs, type ExtractPropTypes } from "vue";
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
2
9
  import { ElDrawer } from "element-plus";
3
10
  import { defaultAttrs } from "./constants.ts";
4
11
 
@@ -6,7 +13,7 @@ const propsAttrs = {};
6
13
 
7
14
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
8
15
 
9
- export default {
16
+ export default defineComponent({
10
17
  // props: propsAttrs,
11
18
  // emits: eventList,
12
19
 
@@ -43,4 +50,4 @@ export default {
43
50
  // 返回渲染函数
44
51
  return () => render();
45
52
  },
46
- };
53
+ });
@@ -1,8 +1,4 @@
1
- import Form, { type PropsAttrs } from './src/index'
2
- import type { FormItemListItem } from './src/types'
3
- // import './style/index.scss'
4
-
5
- export const CForm = Form
6
- export default { com: Form, name: "CForm" };
7
-
8
- export type { PropsAttrs, FormItemListItem }
1
+ import Form from "./src/index";
2
+ export * from "./src/index";
3
+ export { Form };
4
+ export default Form;
@@ -1,4 +1,4 @@
1
- import { ref, h, toRefs, inject, type PropType } from "vue";
1
+ import { defineComponent, ref, h, toRefs, inject, type PropType } from "vue";
2
2
  import {
3
3
  ElFormItem,
4
4
  ElInput,
@@ -52,7 +52,7 @@ const propsAttrs = {
52
52
  optionsRef: { type: Object, default: () => {} },
53
53
  };
54
54
 
55
- export default {
55
+ export default defineComponent({
56
56
  props: propsAttrs,
57
57
  setup(props, { attrs: $attrs, emit, slots, expose }) {
58
58
  // 事件插槽透传
@@ -431,4 +431,4 @@ export default {
431
431
  // 返回表单类型
432
432
  return () => render();
433
433
  },
434
- };
434
+ });
@@ -1,4 +1,5 @@
1
1
  import {
2
+ defineComponent,
2
3
  ref,
3
4
  h,
4
5
  computed,
@@ -33,7 +34,7 @@ const propsAttrs = {
33
34
 
34
35
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
35
36
 
36
- export default {
37
+ export default defineComponent({
37
38
  props: propsAttrs,
38
39
  emits: [...getEmits()],
39
40
  setup(props: PropsAttrs, { attrs: $attrs, emit, slots, expose }) {
@@ -179,4 +180,4 @@ export default {
179
180
  // 返回渲染函数
180
181
  return () => renderForm();
181
182
  },
182
- };
183
+ });
@@ -0,0 +1,41 @@
1
+ // 表单
2
+ import Form from "./form/index.ts";
3
+ export * from "./form/index.ts";
4
+ export const CForm = Form;
5
+
6
+ // 表格
7
+ import Table from "./table/index.ts";
8
+ export * from "./table/index.ts";
9
+ export const CTable = Table;
10
+
11
+ // 表格2
12
+ import Table2 from "./table2/index.ts";
13
+ export * from "./table2/index.ts";
14
+ export const CTable2 = Table2;
15
+
16
+ // 分页
17
+ import Pagination from "./pagination/index.ts";
18
+ export * from "./pagination/index.ts";
19
+ export const CPagination = Pagination;
20
+
21
+ // 弹窗
22
+ import Dialog from "./dialog/index.ts";
23
+ export * from "./dialog/index.ts";
24
+ export const CDialog = Dialog;
25
+
26
+ // 抽屉
27
+ import Drawer from "./drawer/index.ts";
28
+ export * from "./drawer/index.ts";
29
+ export const CDrawer = Drawer;
30
+
31
+ // 搜索
32
+ // import Search from "./search/index.ts";
33
+ // export * from "./search/index.ts";
34
+ // export const CSearch = Search;
35
+ import Search from "./search/index.ts";
36
+ export * from "./search/index.ts";
37
+ export const CSearch = Search;
38
+ // 测试单个引入-----------------------------
39
+ // export * from "./dialog/index.ts"; // 弹窗
40
+ // export * from "./drawer/index.ts"; // 抽屉
41
+ // 测试单个引入-----------------------------
@@ -1,5 +1,4 @@
1
- import Pagination from './src/index'
2
- // import './style/index.scss'
3
-
4
- export const CPagination = Pagination
5
- export default { com: Pagination, name: "CPagination" };
1
+ import Pagination from "./src/index";
2
+ export * from "./src/index";
3
+ export { Pagination };
4
+ export default Pagination;
@@ -1,4 +1,11 @@
1
- import { ref, h, computed, toRefs, type ExtractPropTypes } from "vue";
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
2
9
  import { ElPagination } from "element-plus";
3
10
  import { get, has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
4
11
  import { defaultAttrs } from "./constants.ts";
@@ -7,7 +14,7 @@ const propsAttrs = {};
7
14
 
8
15
  export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
9
16
 
10
- export default {
17
+ export default defineComponent({
11
18
  // props: propsAttrs,
12
19
  // emits: eventList,
13
20
 
@@ -40,4 +47,4 @@ export default {
40
47
  // 返回渲染函数
41
48
  return () => render();
42
49
  },
43
- };
50
+ });
@@ -1,56 +1,4 @@
1
- import {
2
- ref,
3
- h,
4
- computed,
5
- toRefs,
6
- getCurrentInstance,
7
- provide,
8
- type ExtractPropTypes,
9
- type PropType,
10
- } from "vue";
11
- import { ElConfigProvider, ElForm, ElRow, ElCol } from "element-plus";
12
- import zhCn from "element-plus/es/locale/lang/zh-cn";
13
- import { get, has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
14
- import { CForm } from "@elementplus-kit/uikit";
15
- const propsAttrs = {
16
- // 表单数据
17
- model: { type: Object, default: () => ({}) },
18
- // 表单项
19
- formOptions: { type: Array, default: () => [] },
20
- };
21
-
22
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
23
-
24
- export default {
25
- props: propsAttrs,
26
- emits: [...getEmits()],
27
- setup(props: PropsAttrs, { attrs: $attrs, emit, slots, expose }) {
28
- const searchRef = ref();
29
-
30
- // 暴露方法
31
- expose({
32
- optionsRef,
33
- });
34
-
35
- // 解构props
36
- const { model, formOptions, readonly, gutter, col } = toRefs(props);
37
-
38
- // 渲染表单
39
- const renderForm = () => {
40
- return h(
41
- "div",
42
- {
43
- ref: searchRef,
44
- ...$attrs,
45
- class: 'c-search'
46
- },
47
- {
48
- 'div',
49
- }
50
- );
51
- };
52
-
53
- // 返回渲染函数
54
- return () => renderForm();
55
- },
56
- };
1
+ import Search from "./src/index.tsx";
2
+ export * from "./src/index.tsx";
3
+ export { Search };
4
+ export default Search;
@@ -0,0 +1,256 @@
1
+ <template>
2
+ <div class="c-search">
3
+ <div class="c-search-simple">
4
+ <div class="c-search-simple-form">
5
+ <c-form v-bind="getEvent(), getSlot('form')" inline :model="formData"
6
+ :formOptions="props.formOptions.filter((item, index) => index < showCount)" ref="formRef">
7
+ <template #[`c-search-button`]>
8
+ <slot name="active"></slot>
9
+ </template>
10
+ </c-form>
11
+ </div>
12
+ <div class="c-search-simple-btn">
13
+ <slot name="btn-left" />
14
+ <div class="c-search-simple-icon" @click="handleShow" v-if="showCount < props.formOptions.length"
15
+ :class="{ 'icon-rotate': showSearchForm }">
16
+ <el-icon class="c-search-icon">
17
+ <ArrowUpBold />
18
+ </el-icon>
19
+ </div>
20
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
21
+ <el-button type="primary" @click="handleReset">重置</el-button>
22
+ <slot name="btn-right" />
23
+ </div>
24
+ </div>
25
+ <!-- 下拉悬浮 -->
26
+ <transition name="search-form-transition">
27
+ <el-card class="c-search-form" v-if="showSearchForm && props.isDrawer">
28
+ <c-form v-bind="getEvent(), getSlot('form')"" inline :model="formData"
29
+ :formOptions="props.formOptions.filter((item, index) => index >= showCount)" ref="formRef">
30
+ </c-form>
31
+ <div style="text-align: right;">
32
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
33
+ <el-button type="primary" @click="handleClose">关闭</el-button>
34
+ </div>
35
+ </el-card>
36
+ </transition>
37
+ <c-drawer v-if="!props.isDrawer" title="搜索" v-model="showSearchForm" size="660px">
38
+ <c-form v-bind="getEvent(), getSlot('form')" :col="12" :model="formData"
39
+ :formOptions="props.formOptions.filter((item, index) => index >= showCount)" ref="formRef">
40
+ </c-form>
41
+ <div style="text-align: right;">
42
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
43
+ <el-button type="primary" @click="handleClose">关闭</el-button>
44
+ </div>
45
+ </c-drawer>
46
+ </div>
47
+ </template>
48
+ <script setup lang="ts">
49
+ import { ref, computed, useAttrs, useSlots, defineModel } from 'vue'
50
+ import { CForm, CDrawer } from '@elementplus-kit/uikit'
51
+ import { ArrowUpBold } from '@element-plus/icons-vue'
52
+ const props = defineProps({
53
+ formOptions: {
54
+ type: Array,
55
+ default: () => []
56
+ },
57
+ formItemButton: {
58
+ type: Object,
59
+ default: () => ({
60
+ label: '',
61
+ prop: 'c-button',
62
+ })
63
+ },
64
+ isDrawer: {
65
+ type: Boolean,
66
+ default: true
67
+ },
68
+ showCount: { // 显示简洁栏的个数
69
+ type: Number,
70
+ default: 3
71
+ }
72
+ })
73
+ const emit = defineEmits(['search', 'reset', 'close'])
74
+
75
+ const formData = defineModel()
76
+ const attr = useAttrs()
77
+ const slots = useSlots()
78
+
79
+ // 自己的 slot
80
+ const slotsMap = ['active']
81
+ // 解析 attr 中的事件
82
+ const getEvent = (name: string) => {
83
+ let obj = {}
84
+ Object.keys(attr).forEach(key => {
85
+ if (key.startsWith('on')) {
86
+ obj[key] = attr[key]
87
+ }
88
+ })
89
+ return obj
90
+ }
91
+
92
+ // 解析插槽
93
+ const getSlot = (type: 'form' | 'search') => {
94
+ let searchObj: any = {}
95
+ let formObj: any = {}
96
+ Object.keys(slots).forEach(key => {
97
+ if (slotsMap.includes(key)) {
98
+ searchObj[key] = slots[key]
99
+ } else {
100
+ formObj[key] = slots[key]
101
+ }
102
+ })
103
+ return type === 'search' ? formObj : searchObj
104
+ }
105
+
106
+ const handleSearch = () => {
107
+ emit('search')
108
+ showSearchForm.value = false
109
+ }
110
+
111
+ const handleReset = () => {
112
+ emit('reset')
113
+ }
114
+
115
+ const handleClose = () => {
116
+ showSearchForm.value = false
117
+ emit('close')
118
+ }
119
+ const showCountC = computed(() => {
120
+ return props.showCount
121
+ })
122
+
123
+ const showCount = ref(3) // 显示个数
124
+ const showSearchForm = ref(false) // 显示搜索表单
125
+ const handleShow = () => {
126
+ showSearchForm.value = !showSearchForm.value
127
+ }
128
+
129
+ // const formOptionsSimple = computed(() => {
130
+ // // 取3为简洁栏
131
+ // const l = props.formOptions?.slice(0, 3)
132
+ // l.push(props.formItemButton)
133
+ // formOptionsHidden.value = props.formOptions?.slice(3)
134
+ // return l
135
+ // })
136
+
137
+ // // const formOptionsSimple = ref([]) // 简洁栏
138
+ // // const formOptionsHidden = ref([]) // 隐藏栏
139
+
140
+ // 窗口大小变化时,调整搜索表单的宽度
141
+ // const handleResize = () => {
142
+ // if (window.innerWidth <= 768) {
143
+ // formOptions.value.forEach(item => {
144
+ // item.col = {
145
+ // span: 24
146
+ // }
147
+ // })
148
+ // } else {
149
+ // formOptions.value.forEach(item => {
150
+ // item.col = {
151
+ // span: 8
152
+ // }
153
+ // })
154
+ // }
155
+ // }
156
+ // window.addEventListener('resize', handleResize)
157
+ </script>
158
+ <style scoped lang="scss">
159
+ .search-btn {
160
+ margin-right: 20px;
161
+ margin-left: auto;
162
+ }
163
+
164
+ .c-search {
165
+ position: relative;
166
+ height: 50px;
167
+
168
+ .c-search-simple {
169
+ display: flex;
170
+ justify-content: space-between;
171
+ }
172
+
173
+ .c-search-simple-btn {
174
+ display: flex;
175
+ margin-left: auto;
176
+ }
177
+
178
+ .c-search-simple-icon {
179
+ display: flex;
180
+ justify-content: center;
181
+ align-items: center;
182
+ cursor: pointer;
183
+ height: 32px;
184
+ width: 32px;
185
+ margin-right: 10px;
186
+ border-radius: 4px;
187
+ background-color: #409eff;
188
+ transition: all 0.2s;
189
+
190
+ &:hover {
191
+ background-color: rgb(121, 187, 255);
192
+ }
193
+
194
+ &:active {
195
+ background-color: rgb(51, 126, 204);
196
+ }
197
+ }
198
+
199
+ .c-search-icon {
200
+ // 添加鼠标悬停效果
201
+ display: inline-block;
202
+ color: #fff;
203
+ transition: all 0.2s;
204
+
205
+ }
206
+
207
+ .icon-rotate {
208
+ background-color: rgb(51, 126, 204);
209
+
210
+ .c-search-icon {
211
+ transform: rotate(180deg);
212
+ }
213
+ }
214
+
215
+ .c-search-form {
216
+ width: 100%;
217
+ position: absolute;
218
+ top: 50px;
219
+ left: 0;
220
+ overflow: hidden;
221
+ z-index: 10;
222
+ background-color: #fff;
223
+ }
224
+ }
225
+
226
+ /* 下拉动画效果 */
227
+ .search-form-transition {
228
+
229
+ &-enter-active,
230
+ &-leave-active {
231
+ transition: all 0.3s ease;
232
+ /* 动画过渡时间和缓动函数 */
233
+ overflow: hidden;
234
+ max-height: 500px;
235
+ /* 确保足够大的最大高度以容纳内容 */
236
+ }
237
+
238
+ &-enter-from {
239
+ max-height: 0;
240
+ /* 入场开始时高度为0 */
241
+ opacity: 0;
242
+ /* 可以添加透明度效果增强视觉体验 */
243
+ padding-top: 0;
244
+ padding-bottom: 0;
245
+ }
246
+
247
+ &-leave-to {
248
+ max-height: 0;
249
+ /* 出场结束时高度为0 */
250
+ opacity: 0;
251
+ /* 可以添加透明度效果增强视觉体验 */
252
+ padding-top: 0;
253
+ padding-bottom: 0;
254
+ }
255
+ }
256
+ </style>