gi-component 0.0.6 → 0.0.8
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/gi.css +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.es.js +42 -41
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +10 -3
- package/packages/components/button/index.ts +4 -4
- package/packages/components/button/src/button.vue +32 -32
- package/packages/components/button/src/type.ts +2 -2
- package/packages/components/card/index.ts +4 -4
- package/packages/components/card/src/card.vue +21 -21
- package/packages/components/card/src/type.ts +9 -9
- package/packages/components/dialog/index.ts +5 -5
- package/packages/components/dialog/src/dialog.ts +33 -33
- package/packages/components/dialog/src/dialog.vue +34 -32
- package/packages/components/dialog/src/type.ts +13 -13
- package/packages/components/edit-table/index.ts +4 -4
- package/packages/components/edit-table/src/edit-table.vue +49 -49
- package/packages/components/edit-table/src/type.ts +42 -62
- package/packages/components/form/index.ts +4 -4
- package/packages/components/form/src/form.vue +98 -98
- package/packages/components/form/src/type.ts +74 -88
- package/packages/components/grid/index.ts +6 -6
- package/packages/components/grid/src/context.ts +17 -17
- package/packages/components/grid/src/grid-item.vue +40 -40
- package/packages/components/grid/src/grid.vue +38 -38
- package/packages/components/grid/src/hook/use-index.ts +24 -24
- package/packages/components/grid/src/hook/use-responsive-state.ts +26 -26
- package/packages/components/grid/src/hook/use-responsive-value.ts +24 -24
- package/packages/components/grid/src/interface.ts +32 -32
- package/packages/components/grid/src/utils/global-config.ts +3 -3
- package/packages/components/grid/src/utils/index.ts +25 -25
- package/packages/components/grid/src/utils/is.ts +2 -2
- package/packages/components/grid/src/utils/responsive-observe.ts +53 -53
- package/packages/components/input-group/index.ts +4 -4
- package/packages/components/input-group/src/input-group.vue +2 -2
- package/packages/components/input-search/index.ts +4 -4
- package/packages/components/input-search/src/input-search.vue +15 -15
- package/packages/components/input-search/src/type.ts +4 -4
- package/packages/components/page-layout/index.ts +4 -4
- package/packages/components/page-layout/src/page-layout.vue +25 -25
- package/packages/components/page-layout/src/split-button.vue +22 -22
- package/packages/components/page-layout/src/type.ts +9 -9
- package/packages/components/table/index.ts +4 -4
- package/packages/components/table/src/TableColumn.vue +10 -10
- package/packages/components/table/src/table.vue +14 -14
- package/packages/components/table/src/type.ts +8 -16
- package/packages/components/tabs/index.ts +4 -4
- package/packages/components/tabs/src/tabs.vue +26 -36
- package/packages/components/tabs/src/type.ts +9 -9
- package/packages/hooks/index.ts +2 -2
- package/packages/hooks/useBemClass.ts +7 -7
- package/packages/hooks/useTable.ts +6 -7
- package/packages/index.ts +44 -44
- package/packages/styles/index.scss +6 -0
- package/packages/types/tool.ts +14 -0
- package/packages/utils/createSelectDialog.ts +28 -27
- package/packages/utils/index.ts +1 -1
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
38
|
<script lang="ts" setup>
|
|
39
|
-
import type { PageLayoutProps } from './type'
|
|
40
|
-
import { computed, ref, useSlots } from 'vue'
|
|
41
|
-
import { useBemClass } from '../../../hooks'
|
|
42
|
-
import SplitButton from './split-button.vue'
|
|
39
|
+
import type { PageLayoutProps } from './type'
|
|
40
|
+
import { computed, ref, useSlots } from 'vue'
|
|
41
|
+
import { useBemClass } from '../../../hooks'
|
|
42
|
+
import SplitButton from './split-button.vue'
|
|
43
43
|
|
|
44
44
|
const props = withDefaults(defineProps<PageLayoutProps>(), {
|
|
45
45
|
size: 270,
|
|
@@ -49,43 +49,43 @@ const props = withDefaults(defineProps<PageLayoutProps>(), {
|
|
|
49
49
|
headerStyle: () => ({}),
|
|
50
50
|
toolStyle: () => ({}),
|
|
51
51
|
bodyStyle: () => ({})
|
|
52
|
-
})
|
|
52
|
+
})
|
|
53
53
|
|
|
54
54
|
defineSlots<{
|
|
55
|
-
header: () => void
|
|
56
|
-
left: () => void
|
|
57
|
-
tool: () => void
|
|
58
|
-
default: () => void
|
|
59
|
-
}>()
|
|
55
|
+
header: () => void
|
|
56
|
+
left: () => void
|
|
57
|
+
tool: () => void
|
|
58
|
+
default: () => void
|
|
59
|
+
}>()
|
|
60
60
|
|
|
61
|
-
const slots = useSlots()
|
|
62
|
-
const { b } = useBemClass()
|
|
63
|
-
const size = ref(props.size)
|
|
64
|
-
const collapsing = ref(false)
|
|
61
|
+
const slots = useSlots()
|
|
62
|
+
const { b } = useBemClass()
|
|
63
|
+
const size = ref(props.size)
|
|
64
|
+
const collapsing = ref(false)
|
|
65
65
|
|
|
66
66
|
const getClass = computed(() => {
|
|
67
|
-
const arr: string[] = [b('page-layout')]
|
|
67
|
+
const arr: string[] = [b('page-layout')]
|
|
68
68
|
if (props.bordered) {
|
|
69
|
-
arr.push(b('page-layout--bordered'))
|
|
69
|
+
arr.push(b('page-layout--bordered'))
|
|
70
70
|
}
|
|
71
71
|
if (slots.header) {
|
|
72
|
-
arr.push(b('page-layout--has-header'))
|
|
72
|
+
arr.push(b('page-layout--has-header'))
|
|
73
73
|
}
|
|
74
74
|
if (slots.tool) {
|
|
75
|
-
arr.push(b('page-layout--has-tool'))
|
|
75
|
+
arr.push(b('page-layout--has-tool'))
|
|
76
76
|
}
|
|
77
77
|
if (collapsing.value) {
|
|
78
|
-
arr.push(b('page-layout--collapsing'))
|
|
78
|
+
arr.push(b('page-layout--collapsing'))
|
|
79
79
|
}
|
|
80
|
-
return arr.join(' ')
|
|
81
|
-
})
|
|
80
|
+
return arr.join(' ')
|
|
81
|
+
})
|
|
82
82
|
|
|
83
83
|
function handleClick() {
|
|
84
|
-
collapsing.value = true
|
|
84
|
+
collapsing.value = true
|
|
85
85
|
setTimeout(() => {
|
|
86
|
-
collapsing.value = false
|
|
87
|
-
}, 300)
|
|
88
|
-
size.value = Number(size.value) > 30 ? 0 : props.size
|
|
86
|
+
collapsing.value = false
|
|
87
|
+
}, 300)
|
|
88
|
+
size.value = Number(size.value) > 30 ? 0 : props.size
|
|
89
89
|
}
|
|
90
90
|
</script>
|
|
91
91
|
|
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue'
|
|
12
|
-
import { computed } from 'vue'
|
|
13
|
-
import { useBemClass } from '../../../hooks'
|
|
11
|
+
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue'
|
|
12
|
+
import { computed } from 'vue'
|
|
13
|
+
import { useBemClass } from '../../../hooks'
|
|
14
14
|
|
|
15
15
|
/** 按钮类型 */
|
|
16
|
-
type ButtonType = 'default' | 'circle'
|
|
16
|
+
type ButtonType = 'default' | 'circle'
|
|
17
17
|
|
|
18
18
|
/** 组件属性定义 */
|
|
19
19
|
interface Props {
|
|
20
20
|
/** 是否折叠状态 */
|
|
21
|
-
collapsed?: boolean
|
|
21
|
+
collapsed?: boolean
|
|
22
22
|
/** 按钮类型 */
|
|
23
|
-
type?: ButtonType
|
|
23
|
+
type?: ButtonType
|
|
24
24
|
/** 图标大小 */
|
|
25
|
-
iconSize?: number
|
|
25
|
+
iconSize?: number
|
|
26
26
|
/** 是否禁用 */
|
|
27
|
-
disabled?: boolean
|
|
27
|
+
disabled?: boolean
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** 组件事件定义 */
|
|
31
31
|
interface Emits {
|
|
32
|
-
(e: 'click'): void
|
|
33
|
-
(e: 'update:collapsed', value: boolean): void
|
|
32
|
+
(e: 'click'): void
|
|
33
|
+
(e: 'update:collapsed', value: boolean): void
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -38,29 +38,29 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
38
38
|
type: 'circle',
|
|
39
39
|
iconSize: 10,
|
|
40
40
|
disabled: false
|
|
41
|
-
})
|
|
41
|
+
})
|
|
42
42
|
|
|
43
|
-
const emit = defineEmits<Emits>()
|
|
44
|
-
const { b } = useBemClass()
|
|
43
|
+
const emit = defineEmits<Emits>()
|
|
44
|
+
const { b } = useBemClass()
|
|
45
45
|
|
|
46
46
|
/** 计算按钮类名 */
|
|
47
47
|
const getClass = computed(() => {
|
|
48
|
-
const arr: string[] = [b('split-button'), b(`split-button--${props.type}`)]
|
|
48
|
+
const arr: string[] = [b('split-button'), b(`split-button--${props.type}`)]
|
|
49
49
|
if (props.collapsed) {
|
|
50
|
-
arr.push(b('split-button--collapsed'))
|
|
50
|
+
arr.push(b('split-button--collapsed'))
|
|
51
51
|
}
|
|
52
52
|
if (props.disabled) {
|
|
53
|
-
arr.push(b('split-button--disabled'))
|
|
53
|
+
arr.push(b('split-button--disabled'))
|
|
54
54
|
}
|
|
55
|
-
return arr.join(' ')
|
|
56
|
-
})
|
|
55
|
+
return arr.join(' ')
|
|
56
|
+
})
|
|
57
57
|
|
|
58
58
|
/** 处理点击事件 */
|
|
59
59
|
const handleClick = () => {
|
|
60
|
-
if (props.disabled) return
|
|
61
|
-
emit('click')
|
|
62
|
-
emit('update:collapsed', !props.collapsed)
|
|
63
|
-
}
|
|
60
|
+
if (props.disabled) return
|
|
61
|
+
emit('click')
|
|
62
|
+
emit('update:collapsed', !props.collapsed)
|
|
63
|
+
}
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
66
|
<style lang="scss" scoped>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { SplitterPanelProps } from 'element-plus'
|
|
2
|
-
import type { CSSProperties } from 'vue'
|
|
1
|
+
import type { SplitterPanelProps } from 'element-plus'
|
|
2
|
+
import type { CSSProperties } from 'vue'
|
|
3
3
|
|
|
4
4
|
export interface PageLayoutProps {
|
|
5
|
-
size?: SplitterPanelProps['size']
|
|
6
|
-
bordered?: boolean
|
|
7
|
-
collapse?: boolean
|
|
8
|
-
leftStyle?: CSSProperties
|
|
9
|
-
headerStyle?: CSSProperties
|
|
10
|
-
toolStyle?: CSSProperties
|
|
11
|
-
bodyStyle?: CSSProperties
|
|
5
|
+
size?: SplitterPanelProps['size']
|
|
6
|
+
bordered?: boolean
|
|
7
|
+
collapse?: boolean
|
|
8
|
+
leftStyle?: CSSProperties
|
|
9
|
+
headerStyle?: CSSProperties
|
|
10
|
+
toolStyle?: CSSProperties
|
|
11
|
+
bodyStyle?: CSSProperties
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Table from './src/table.vue'
|
|
1
|
+
import Table from './src/table.vue'
|
|
2
2
|
|
|
3
|
-
export type TableInstance = InstanceType<typeof Table
|
|
4
|
-
export * from './src/type'
|
|
5
|
-
export default Table
|
|
3
|
+
export type TableInstance = InstanceType<typeof Table>
|
|
4
|
+
export * from './src/type'
|
|
5
|
+
export default Table
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-table-column v-bind="columnProps">
|
|
3
3
|
<!-- 处理render函数 -->
|
|
4
|
-
<template v-if="column.render"
|
|
4
|
+
<template v-if="column.render" #default="scope">
|
|
5
5
|
<template v-if="typeof column.render(scope) === 'string'">{{ column.render(scope) }}</template>
|
|
6
|
-
<component
|
|
6
|
+
<component :is="column.render(scope)" v-else />
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<!-- 处理插槽内容 -->
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script lang="ts" setup>
|
|
27
|
-
import type { TableColumnItem } from './type'
|
|
28
|
-
import { computed } from 'vue'
|
|
29
|
-
import TableColumn from './TableColumn.vue'
|
|
27
|
+
import type { TableColumnItem } from './type'
|
|
28
|
+
import { computed } from 'vue'
|
|
29
|
+
import TableColumn from './TableColumn.vue'
|
|
30
30
|
|
|
31
31
|
const props = defineProps<{
|
|
32
|
-
column: TableColumnItem
|
|
33
|
-
}>()
|
|
32
|
+
column: TableColumnItem
|
|
33
|
+
}>()
|
|
34
34
|
|
|
35
35
|
// 计算el-table-column需要的属性
|
|
36
36
|
const columnProps = computed(() => {
|
|
37
|
-
const { slotName, render, children, ...restProps } = props.column
|
|
38
|
-
return restProps
|
|
39
|
-
})
|
|
37
|
+
const { slotName, render, children, ...restProps } = props.column
|
|
38
|
+
return restProps
|
|
39
|
+
})
|
|
40
40
|
</script>
|
|
41
41
|
|
|
42
42
|
<style scoped></style>
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script lang="ts" setup>
|
|
21
|
-
import type { TableProps } from './type'
|
|
22
|
-
import { computed, useAttrs, useTemplateRef } from 'vue'
|
|
23
|
-
import { useBemClass } from '../../../hooks'
|
|
24
|
-
import TableColumn from './TableColumn.vue'
|
|
21
|
+
import type { TableProps } from './type'
|
|
22
|
+
import { computed, useAttrs, useTemplateRef } from 'vue'
|
|
23
|
+
import { useBemClass } from '../../../hooks'
|
|
24
|
+
import TableColumn from './TableColumn.vue'
|
|
25
25
|
|
|
26
26
|
const props = withDefaults(defineProps<TableProps>(), {
|
|
27
27
|
columns: () => [],
|
|
28
28
|
pagination: () => ({})
|
|
29
|
-
})
|
|
29
|
+
})
|
|
30
30
|
|
|
31
|
-
const attrs = useAttrs()
|
|
32
|
-
const { b } = useBemClass()
|
|
33
|
-
const tableRef = useTemplateRef('tableRef')
|
|
31
|
+
const attrs = useAttrs()
|
|
32
|
+
const { b } = useBemClass()
|
|
33
|
+
const tableRef = useTemplateRef('tableRef')
|
|
34
34
|
|
|
35
35
|
const tableProps = computed(() => {
|
|
36
36
|
return {
|
|
@@ -38,8 +38,8 @@ const tableProps = computed(() => {
|
|
|
38
38
|
...props,
|
|
39
39
|
columns: undefined,
|
|
40
40
|
pagination: undefined
|
|
41
|
-
}
|
|
42
|
-
})
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
43
|
|
|
44
44
|
const paginationProps = computed(() => {
|
|
45
45
|
return {
|
|
@@ -47,17 +47,17 @@ const paginationProps = computed(() => {
|
|
|
47
47
|
layout: 'prev, pager, next, sizes, total',
|
|
48
48
|
pageSizes: [10, 20, 50, 100],
|
|
49
49
|
...props.pagination
|
|
50
|
-
}
|
|
51
|
-
})
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
52
|
|
|
53
53
|
function handleSizeChange(size: number) {
|
|
54
54
|
// @ts-ignore
|
|
55
|
-
props.pagination.pageSize = size
|
|
55
|
+
props.pagination.pageSize = size
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function handleCurrentChange(page: number) {
|
|
59
59
|
// @ts-ignore
|
|
60
|
-
props.pagination.currentPage = page
|
|
60
|
+
props.pagination.currentPage = page
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
defineExpose({
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
PaginationProps,
|
|
4
|
-
TableColumnCtx,
|
|
5
|
-
TableColumnInstance,
|
|
6
|
-
} from 'element-plus';
|
|
7
|
-
import type { ExtractPropTypes, VNode } from 'vue';
|
|
1
|
+
import type { TableProps as ElTableProps, PaginationProps, TableColumnInstance } from 'element-plus'
|
|
2
|
+
import type { ExtractPropTypes, VNode } from 'vue'
|
|
8
3
|
|
|
9
4
|
type DefaultRow = Record<PropertyKey, any>
|
|
10
5
|
export interface TableColumnItem<T extends DefaultRow = DefaultRow> extends Omit<TableColumnInstance['$props'], never> {
|
|
11
|
-
slotName?: string
|
|
12
|
-
children?: TableColumnItem[]
|
|
13
|
-
render?: (scope: { $index: number
|
|
6
|
+
slotName?: string
|
|
7
|
+
children?: TableColumnItem[]
|
|
8
|
+
render?: (scope: { $index: number, cellIndex: number, column: TableColumnItem<T>, row: T }) => VNode | VNode[] | string
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
export interface TableProps
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> {
|
|
20
|
-
columns?: TableColumnItem[];
|
|
21
|
-
pagination?: Partial<PaginationProps>;
|
|
11
|
+
export interface TableProps extends ExtractPropTypes<ElTableProps<Record<string | number | symbol, any>>> {
|
|
12
|
+
columns?: TableColumnItem[]
|
|
13
|
+
pagination?: Partial<PaginationProps>
|
|
22
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Tabs from './src/tabs.vue'
|
|
1
|
+
import Tabs from './src/tabs.vue'
|
|
2
2
|
|
|
3
|
-
export type TabsInstance = InstanceType<typeof Tabs
|
|
4
|
-
export * from './src/type'
|
|
5
|
-
export default Tabs
|
|
3
|
+
export type TabsInstance = InstanceType<typeof Tabs>
|
|
4
|
+
export * from './src/type'
|
|
5
|
+
export default Tabs
|
|
@@ -2,19 +2,9 @@
|
|
|
2
2
|
<div :class="getClass">
|
|
3
3
|
<div :class="b('tabs__default')">
|
|
4
4
|
<slot>
|
|
5
|
-
<el-tabs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:stretch="props.stretch"
|
|
9
|
-
@tab-click="(p, e) => emits('tabClick', p, e)"
|
|
10
|
-
@tab-change="emits('tabChange', $event)"
|
|
11
|
-
>
|
|
12
|
-
<el-tab-pane
|
|
13
|
-
v-for="item in props.options"
|
|
14
|
-
:key="item.name"
|
|
15
|
-
:name="item.name"
|
|
16
|
-
:disabled="item?.disabled"
|
|
17
|
-
>
|
|
5
|
+
<el-tabs v-model="model" :type="props.type" :stretch="props.stretch"
|
|
6
|
+
@tab-click="(p, e) => emits('tabClick', p, e)" @tab-change="emits('tabChange', $event as any)">
|
|
7
|
+
<el-tab-pane v-for="item in props.options" :key="item.name" :name="item.name" :disabled="item?.disabled">
|
|
18
8
|
<template #label>
|
|
19
9
|
<slot name="label" :data="item">{{ item.label }}</slot>
|
|
20
10
|
</template>
|
|
@@ -29,42 +19,42 @@
|
|
|
29
19
|
</template>
|
|
30
20
|
|
|
31
21
|
<script setup lang="ts">
|
|
32
|
-
import type { TabsProps as ElTabsProps, TabsPaneContext } from 'element-plus'
|
|
33
|
-
import type { TabsOptionItem, TabsProps } from './type.ts'
|
|
34
|
-
import { computed, useSlots } from 'vue'
|
|
35
|
-
import { useBemClass } from '../../../hooks'
|
|
22
|
+
import type { TabsProps as ElTabsProps, TabsPaneContext } from 'element-plus'
|
|
23
|
+
import type { TabsOptionItem, TabsProps } from './type.ts'
|
|
24
|
+
import { computed, useSlots } from 'vue'
|
|
25
|
+
import { useBemClass } from '../../../hooks'
|
|
36
26
|
|
|
37
|
-
const model = defineModel<ElTabsProps['modelValue']>()
|
|
27
|
+
const model = defineModel<ElTabsProps['modelValue']>()
|
|
38
28
|
|
|
39
29
|
const props = withDefaults(defineProps<TabsProps>(), {
|
|
40
30
|
type: '',
|
|
41
31
|
options: () => [],
|
|
42
32
|
size: 'medium',
|
|
43
33
|
inner: false
|
|
44
|
-
})
|
|
34
|
+
})
|
|
45
35
|
|
|
46
36
|
const emits = defineEmits<{
|
|
47
|
-
(e: 'tabClick', pane: TabsPaneContext, ev: Event): void
|
|
48
|
-
(e: 'tabChange', value: string): void
|
|
49
|
-
}>()
|
|
37
|
+
(e: 'tabClick', pane: TabsPaneContext, ev: Event): void
|
|
38
|
+
(e: 'tabChange', value: string): void
|
|
39
|
+
}>()
|
|
50
40
|
|
|
51
41
|
defineSlots<{
|
|
52
|
-
default: () => void
|
|
53
|
-
extra: () => void
|
|
54
|
-
label: (e: { data: TabsOptionItem }) => void
|
|
55
|
-
}>()
|
|
42
|
+
default: () => void
|
|
43
|
+
extra: () => void
|
|
44
|
+
label: (e: { data: TabsOptionItem }) => void
|
|
45
|
+
}>()
|
|
56
46
|
|
|
57
|
-
const slots = useSlots()
|
|
58
|
-
const { b } = useBemClass()
|
|
47
|
+
const slots = useSlots()
|
|
48
|
+
const { b } = useBemClass()
|
|
59
49
|
|
|
60
50
|
const getClass = computed(() => {
|
|
61
|
-
const arr: string[] = [b('tabs')]
|
|
62
|
-
arr.push(b(`tabs--${props.size}`))
|
|
51
|
+
const arr: string[] = [b('tabs')]
|
|
52
|
+
arr.push(b(`tabs--${props.size}`))
|
|
63
53
|
if (props.inner) {
|
|
64
|
-
arr.push(b('tabs--inner'))
|
|
54
|
+
arr.push(b('tabs--inner'))
|
|
65
55
|
}
|
|
66
|
-
return arr.join(' ')
|
|
67
|
-
})
|
|
56
|
+
return arr.join(' ')
|
|
57
|
+
})
|
|
68
58
|
</script>
|
|
69
59
|
|
|
70
60
|
<style lang="scss" scoped>
|
|
@@ -113,7 +103,7 @@ const getClass = computed(() => {
|
|
|
113
103
|
}
|
|
114
104
|
|
|
115
105
|
:deep(.el-tabs--card) {
|
|
116
|
-
|
|
106
|
+
>.el-tabs__header {
|
|
117
107
|
border-bottom: none;
|
|
118
108
|
}
|
|
119
109
|
}
|
|
@@ -121,11 +111,11 @@ const getClass = computed(() => {
|
|
|
121
111
|
:deep(.el-tabs--border-card) {
|
|
122
112
|
border-bottom: none;
|
|
123
113
|
|
|
124
|
-
|
|
114
|
+
>.el-tabs__content {
|
|
125
115
|
display: none;
|
|
126
116
|
}
|
|
127
117
|
|
|
128
|
-
|
|
118
|
+
>.el-tabs__header {
|
|
129
119
|
border-bottom: none;
|
|
130
120
|
}
|
|
131
121
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { TabsProps as ElTabsProps } from 'element-plus'
|
|
1
|
+
import type { TabsProps as ElTabsProps } from 'element-plus'
|
|
2
2
|
|
|
3
3
|
export type TabsOptionItem = {
|
|
4
|
-
label: string
|
|
5
|
-
name: string
|
|
6
|
-
disabled?: boolean
|
|
7
|
-
}
|
|
4
|
+
label: string
|
|
5
|
+
name: string
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
export interface TabsProps
|
|
10
10
|
extends Partial<Pick<ElTabsProps, 'type' | 'stretch'>> {
|
|
11
|
-
type?: ElTabsProps['type']
|
|
12
|
-
options?: TabsOptionItem[]
|
|
13
|
-
size?: 'small' | 'medium'
|
|
14
|
-
inner?: boolean
|
|
11
|
+
type?: ElTabsProps['type']
|
|
12
|
+
options?: TabsOptionItem[]
|
|
13
|
+
size?: 'small' | 'medium'
|
|
14
|
+
inner?: boolean // 内嵌模式
|
|
15
15
|
}
|
package/packages/hooks/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useBemClass'
|
|
2
|
-
export * from './useTable'
|
|
1
|
+
export * from './useBemClass'
|
|
2
|
+
export * from './useTable'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getCurrentInstance } from 'vue'
|
|
1
|
+
import { getCurrentInstance } from 'vue'
|
|
2
2
|
|
|
3
3
|
export function useBemClass() {
|
|
4
|
-
const instance = getCurrentInstance()
|
|
5
|
-
const configPrefix
|
|
6
|
-
instance?.appContext.config.globalProperties.$config?.prefix || 'gi'
|
|
7
|
-
const prefix = configPrefix.toLowerCase()
|
|
8
|
-
const b = (name: string = '') => `${prefix}-${name ? `${name}` : ''}
|
|
4
|
+
const instance = getCurrentInstance()
|
|
5
|
+
const configPrefix
|
|
6
|
+
= instance?.appContext.config.globalProperties.$config?.prefix || 'gi'
|
|
7
|
+
const prefix = configPrefix.toLowerCase()
|
|
8
|
+
const b = (name: string = '') => `${prefix}-${name ? `${name}` : ''}`
|
|
9
9
|
|
|
10
|
-
return { b }
|
|
10
|
+
return { b }
|
|
11
11
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { reactive, ref, getCurrentInstance, type Ref } from 'vue'
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import { reactive, ref } from 'vue'
|
|
4
3
|
|
|
5
4
|
interface Options<T, U> {
|
|
6
5
|
onSuccess?: () => void
|
|
@@ -20,7 +19,7 @@ interface PageResult<T> {
|
|
|
20
19
|
total: number
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export interface UseTablePaginationParams { page: number
|
|
22
|
+
export interface UseTablePaginationParams { page: number, size: number }
|
|
24
23
|
|
|
25
24
|
export interface UseTableApi<T> {
|
|
26
25
|
(params: UseTablePaginationParams): Promise<ApiResult<PageResult<T[]>>> | Promise<ApiResult<T[]>>
|
|
@@ -46,7 +45,7 @@ export function useTable<T extends U, U = T>(api: UseTableApi<T>, options: Optio
|
|
|
46
45
|
onSizeChange: (size: number) => {
|
|
47
46
|
pagination.pageSize = size
|
|
48
47
|
getTableData()
|
|
49
|
-
}
|
|
48
|
+
}
|
|
50
49
|
})
|
|
51
50
|
|
|
52
51
|
function setTotal(total: number) {
|
|
@@ -93,6 +92,6 @@ export function useTable<T extends U, U = T>(api: UseTableApi<T>, options: Optio
|
|
|
93
92
|
/** 搜索 */
|
|
94
93
|
search,
|
|
95
94
|
/** 刷新 */
|
|
96
|
-
refresh
|
|
95
|
+
refresh
|
|
97
96
|
}
|
|
98
|
-
}
|
|
97
|
+
}
|
package/packages/index.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
1
|
+
import type { App } from 'vue'
|
|
2
2
|
|
|
3
|
-
import Button from './components/button'
|
|
4
|
-
import Card from './components/card'
|
|
5
|
-
import Dialog from './components/dialog'
|
|
6
|
-
import EditTable from './components/edit-table'
|
|
7
|
-
import Form from './components/form'
|
|
8
|
-
import GridItem from './components/grid/src/grid-item.vue'
|
|
9
|
-
import Grid from './components/grid/src/grid.vue'
|
|
10
|
-
import InputGroup from './components/input-group'
|
|
11
|
-
import InputSearch from './components/input-search'
|
|
12
|
-
import PageLayout from './components/page-layout'
|
|
13
|
-
import Table from './components/table'
|
|
14
|
-
import Tabs from './components/tabs'
|
|
15
|
-
import './styles/index.scss'
|
|
3
|
+
import Button from './components/button'
|
|
4
|
+
import Card from './components/card'
|
|
5
|
+
import Dialog from './components/dialog'
|
|
6
|
+
import EditTable from './components/edit-table'
|
|
7
|
+
import Form from './components/form'
|
|
8
|
+
import GridItem from './components/grid/src/grid-item.vue'
|
|
9
|
+
import Grid from './components/grid/src/grid.vue'
|
|
10
|
+
import InputGroup from './components/input-group'
|
|
11
|
+
import InputSearch from './components/input-search'
|
|
12
|
+
import PageLayout from './components/page-layout'
|
|
13
|
+
import Table from './components/table'
|
|
14
|
+
import Tabs from './components/tabs'
|
|
15
|
+
import './styles/index.scss'
|
|
16
16
|
|
|
17
|
-
export * from './components/dialog'
|
|
18
|
-
export * from './components/edit-table'
|
|
19
|
-
export * from './components/form'
|
|
20
|
-
export * from './components/table'
|
|
21
|
-
export * from './components/tabs'
|
|
22
|
-
export * from './hooks'
|
|
23
|
-
export * from './utils'
|
|
17
|
+
export * from './components/dialog'
|
|
18
|
+
export * from './components/edit-table'
|
|
19
|
+
export * from './components/form'
|
|
20
|
+
export * from './components/table'
|
|
21
|
+
export * from './components/tabs'
|
|
22
|
+
export * from './hooks'
|
|
23
|
+
export * from './utils'
|
|
24
24
|
|
|
25
25
|
const components = {
|
|
26
26
|
Button,
|
|
@@ -35,49 +35,49 @@ const components = {
|
|
|
35
35
|
Dialog,
|
|
36
36
|
EditTable,
|
|
37
37
|
Table
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
// 导出Gi前缀的组件并添加明确类型注解
|
|
41
|
-
export const GiButton: typeof Button = Button
|
|
42
|
-
export const GiCard: typeof Card = Card
|
|
43
|
-
export const GiTabs: typeof Tabs = Tabs
|
|
44
|
-
export const GiInputGroup: typeof InputGroup = InputGroup
|
|
45
|
-
export const GiInputSearch: typeof InputSearch = InputSearch
|
|
46
|
-
export const GiGrid: typeof Grid = Grid
|
|
47
|
-
export const GiGridItem: typeof GridItem = GridItem
|
|
48
|
-
export const GiForm: typeof Form = Form
|
|
49
|
-
export const GiPageLayout: typeof PageLayout = PageLayout
|
|
50
|
-
export const GiDialog: typeof Dialog = Dialog
|
|
51
|
-
export const GiEditTable: typeof EditTable = EditTable
|
|
52
|
-
export const GiTable: typeof Table = Table
|
|
41
|
+
export const GiButton: typeof Button = Button
|
|
42
|
+
export const GiCard: typeof Card = Card
|
|
43
|
+
export const GiTabs: typeof Tabs = Tabs
|
|
44
|
+
export const GiInputGroup: typeof InputGroup = InputGroup
|
|
45
|
+
export const GiInputSearch: typeof InputSearch = InputSearch
|
|
46
|
+
export const GiGrid: typeof Grid = Grid
|
|
47
|
+
export const GiGridItem: typeof GridItem = GridItem
|
|
48
|
+
export const GiForm: typeof Form = Form
|
|
49
|
+
export const GiPageLayout: typeof PageLayout = PageLayout
|
|
50
|
+
export const GiDialog: typeof Dialog = Dialog
|
|
51
|
+
export const GiEditTable: typeof EditTable = EditTable
|
|
52
|
+
export const GiTable: typeof Table = Table
|
|
53
53
|
|
|
54
54
|
function capitalizeWord(word: string) {
|
|
55
55
|
// 检查输入是否为字符串且不为空
|
|
56
56
|
if (typeof word !== 'string' || word.length === 0) {
|
|
57
|
-
return word
|
|
57
|
+
return word
|
|
58
58
|
}
|
|
59
59
|
// 首字母大写,其余字母小写
|
|
60
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
60
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// 全局默认配置
|
|
64
64
|
export interface Config {
|
|
65
|
-
prefix?: string
|
|
65
|
+
prefix?: string // 组件前缀
|
|
66
66
|
/** 输入框是否可清除 */
|
|
67
|
-
clearable?: boolean
|
|
67
|
+
clearable?: boolean
|
|
68
68
|
/** 字典请求方法 */
|
|
69
|
-
dictRequest?: () => Promise<any
|
|
69
|
+
dictRequest?: () => Promise<any>
|
|
70
70
|
/** 格式化响应数据, 用于useTable */
|
|
71
71
|
// formatResponse?: (data: any) => any;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export default {
|
|
75
75
|
install(app: App, options?: Config) {
|
|
76
|
-
const prefix = options?.prefix || 'Gi'
|
|
76
|
+
const prefix = options?.prefix || 'Gi'
|
|
77
77
|
Object.entries(components).forEach(([name, component]) => {
|
|
78
|
-
app.component(`${capitalizeWord(prefix)}${name}`, component)
|
|
79
|
-
})
|
|
78
|
+
app.component(`${capitalizeWord(prefix)}${name}`, component)
|
|
79
|
+
})
|
|
80
80
|
// 将配置保存到全局属性
|
|
81
|
-
app.config.globalProperties.$config = options
|
|
81
|
+
app.config.globalProperties.$config = options
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|