gi-component 0.0.36 → 0.0.38
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/dist/components/descriptions/index.d.ts +4 -0
- package/dist/components/descriptions/src/descriptions.vue.d.ts +23 -0
- package/dist/components/descriptions/src/type.d.ts +20 -0
- package/dist/components/dialog/src/dialog.vue.d.ts +1 -1
- package/dist/components/form/src/type.d.ts +1 -0
- package/dist/components/table/src/table.d.ts +4 -0
- package/dist/components/table/src/table.vue.d.ts +4 -0
- package/dist/gi.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +124 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/tool.d.ts +1 -1
- package/package.json +72 -72
- package/packages/components/button/src/button.vue +60 -60
- package/packages/components/flex/index.ts +5 -0
- package/packages/components/flex/src/flex.vue +72 -0
- package/packages/components/flex/src/type.ts +14 -0
- package/packages/components/table/index.ts +5 -5
- package/packages/components.d.ts +31 -30
- package/packages/index.ts +106 -103
- package/packages/types/tool.ts +4 -4
package/packages/index.ts
CHANGED
|
@@ -1,103 +1,106 @@
|
|
|
1
|
-
import type { App, Component } from 'vue'
|
|
2
|
-
|
|
3
|
-
import Button from './components/button'
|
|
4
|
-
import Card from './components/card'
|
|
5
|
-
import DialogComponent, { Dialog as DialogFunction } from './components/dialog'
|
|
6
|
-
import Dot from './components/dot'
|
|
7
|
-
import Drawer from './components/drawer'
|
|
8
|
-
import EditTable from './components/edit-table'
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import './
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export * from './components/
|
|
25
|
-
export * from './components/
|
|
26
|
-
export * from './components/
|
|
27
|
-
export * from './components/
|
|
28
|
-
export * from './components/
|
|
29
|
-
export * from './
|
|
30
|
-
export * from './
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export const
|
|
54
|
-
export const
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
export const
|
|
58
|
-
export const
|
|
59
|
-
export const
|
|
60
|
-
export const
|
|
61
|
-
export const
|
|
62
|
-
export const
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
import type { App, Component } from 'vue'
|
|
2
|
+
|
|
3
|
+
import Button from './components/button'
|
|
4
|
+
import Card from './components/card'
|
|
5
|
+
import DialogComponent, { Dialog as DialogFunction } from './components/dialog'
|
|
6
|
+
import Dot from './components/dot'
|
|
7
|
+
import Drawer from './components/drawer'
|
|
8
|
+
import EditTable from './components/edit-table'
|
|
9
|
+
import Flex from './components/flex'
|
|
10
|
+
import Form from './components/form'
|
|
11
|
+
import GridItem from './components/grid/src/grid-item.vue'
|
|
12
|
+
import Grid from './components/grid/src/grid.vue'
|
|
13
|
+
import InputGroup from './components/input-group'
|
|
14
|
+
import InputSearch from './components/input-search'
|
|
15
|
+
import PageLayout from './components/page-layout'
|
|
16
|
+
import Table from './components/table'
|
|
17
|
+
import Tabs from './components/tabs'
|
|
18
|
+
import TreeTransfer from './components/tree-transfer'
|
|
19
|
+
import './styles/index.scss'
|
|
20
|
+
|
|
21
|
+
// 防止打包时 tree-shake 掉 Dialog.info/success/warning/error(内部只用到 Dialog.open)
|
|
22
|
+
void [DialogFunction.info, DialogFunction.success, DialogFunction.warning, DialogFunction.error]
|
|
23
|
+
|
|
24
|
+
export * from './components/dialog'
|
|
25
|
+
export * from './components/drawer'
|
|
26
|
+
export * from './components/edit-table'
|
|
27
|
+
export * from './components/form'
|
|
28
|
+
export * from './components/table'
|
|
29
|
+
export * from './components/tabs'
|
|
30
|
+
export * from './hooks'
|
|
31
|
+
export * from './utils'
|
|
32
|
+
|
|
33
|
+
const components = {
|
|
34
|
+
Button,
|
|
35
|
+
Card,
|
|
36
|
+
Drawer,
|
|
37
|
+
Dot,
|
|
38
|
+
Tabs,
|
|
39
|
+
InputGroup,
|
|
40
|
+
InputSearch,
|
|
41
|
+
Flex,
|
|
42
|
+
Grid,
|
|
43
|
+
GridItem,
|
|
44
|
+
Form,
|
|
45
|
+
PageLayout,
|
|
46
|
+
Dialog: DialogComponent,
|
|
47
|
+
EditTable,
|
|
48
|
+
Table,
|
|
49
|
+
TreeTransfer
|
|
50
|
+
} as unknown as Record<string, Component>
|
|
51
|
+
|
|
52
|
+
// 导出Gi前缀的组件并添加明确类型注解
|
|
53
|
+
export const GiButton: typeof Button = Button
|
|
54
|
+
export const GiCard: typeof Card = Card
|
|
55
|
+
export const GiDrawer: typeof Drawer = Drawer
|
|
56
|
+
export const GiDot: typeof Dot = Dot
|
|
57
|
+
export const GiTabs: typeof Tabs = Tabs
|
|
58
|
+
export const GiInputGroup: typeof InputGroup = InputGroup
|
|
59
|
+
export const GiInputSearch: typeof InputSearch = InputSearch
|
|
60
|
+
export const GiFlex: typeof Flex = Flex
|
|
61
|
+
export const GiGrid: typeof Grid = Grid
|
|
62
|
+
export const GiGridItem: typeof GridItem = GridItem
|
|
63
|
+
export const GiForm: typeof Form = Form
|
|
64
|
+
export const GiPageLayout: typeof PageLayout = PageLayout
|
|
65
|
+
export const GiDialog: typeof DialogComponent = DialogComponent
|
|
66
|
+
export const GiEditTable: typeof EditTable = EditTable
|
|
67
|
+
export const GiTable: typeof Table = Table
|
|
68
|
+
export const GiTreeTransfer: typeof TreeTransfer = TreeTransfer
|
|
69
|
+
|
|
70
|
+
function capitalizeWord(word: string) {
|
|
71
|
+
// 检查输入是否为字符串且不为空
|
|
72
|
+
if (typeof word !== 'string' || word.length === 0) {
|
|
73
|
+
return word
|
|
74
|
+
}
|
|
75
|
+
// 首字母大写,其余字母小写
|
|
76
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 定义字典数据类型
|
|
80
|
+
export interface DictItem {
|
|
81
|
+
label: string
|
|
82
|
+
value: string | number
|
|
83
|
+
[key: string]: any // 允许扩展其他属性
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 全局默认配置
|
|
87
|
+
export interface Config {
|
|
88
|
+
prefix?: string // 组件前缀
|
|
89
|
+
/** 输入框是否可清除 */
|
|
90
|
+
clearable?: boolean
|
|
91
|
+
/** 字典请求方法 */
|
|
92
|
+
dictRequest?: (code: string) => Promise<DictItem[]>
|
|
93
|
+
/** 格式化响应数据, 用于useTable */
|
|
94
|
+
// formatResponse?: (data: any) => any;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
install(app: App, options?: Config) {
|
|
99
|
+
const prefix = options?.prefix || 'Gi'
|
|
100
|
+
Object.entries(components).forEach(([name, component]) => {
|
|
101
|
+
app.component(`${capitalizeWord(prefix)}${name}`, component)
|
|
102
|
+
})
|
|
103
|
+
// 将配置保存到全局属性
|
|
104
|
+
app.config.globalProperties.$config = options
|
|
105
|
+
}
|
|
106
|
+
}
|
package/packages/types/tool.ts
CHANGED
|
@@ -4,11 +4,11 @@ type AllKeys<T> = T extends any ? keyof T : never
|
|
|
4
4
|
// 辅助类型:获取属性在所有类型中的联合类型
|
|
5
5
|
type UnionType<T, K extends PropertyKey> = T extends any
|
|
6
6
|
? K extends keyof T
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
? T[K]
|
|
8
|
+
: never
|
|
9
9
|
: never
|
|
10
10
|
|
|
11
11
|
// 合并多个类型,同名属性转为联合类型
|
|
12
12
|
export type MergeMultiple<T extends any[]> = {
|
|
13
|
-
[K in AllKeys<T[number]>]
|
|
14
|
-
}
|
|
13
|
+
[K in AllKeys<T[number]>]?: UnionType<T[number], K>
|
|
14
|
+
}
|