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