gi-component 0.0.38 → 0.0.40
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/src/descriptions.vue.d.ts +10 -13
- package/dist/components/descriptions/src/type.d.ts +42 -16
- package/dist/components/flex/index.d.ts +4 -0
- package/dist/components/flex/src/flex.vue.d.ts +24 -0
- package/dist/components/flex/src/type.d.ts +14 -0
- package/dist/components/tag/index.d.ts +4 -0
- package/dist/components/tag/src/tag.vue.d.ts +30 -0
- package/dist/components/tag/src/type.d.ts +13 -0
- package/dist/gi.css +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +307 -124
- 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 +1 -1
- package/packages/components/descriptions/index.ts +5 -0
- package/packages/components/descriptions/src/descriptions.vue +72 -0
- package/packages/components/descriptions/src/type.ts +44 -0
- package/packages/components/tag/index.ts +5 -0
- package/packages/components/tag/src/tag.vue +342 -0
- package/packages/components/tag/src/type.ts +36 -0
- package/packages/components.d.ts +33 -31
- package/packages/index.ts +8 -0
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ElDescriptions :border="border" :column="column" :direction="direction" :size="size" :title="title" :extra="extra">
|
|
3
|
+
<template v-if="$slots.title" #title>
|
|
4
|
+
<slot name="title" />
|
|
5
|
+
</template>
|
|
6
|
+
<template v-if="$slots.extra" #extra>
|
|
7
|
+
<slot name="extra" />
|
|
8
|
+
</template>
|
|
9
|
+
<template v-if="useColumns">
|
|
10
|
+
<ElDescriptionsItem v-for="(col, idx) in columns" :key="col.value ?? idx"
|
|
11
|
+
:label="typeof col.label === 'string' ? col.label : ''" :span="col.span ?? 1" :width="col.width"
|
|
12
|
+
:min-width="col.minWidth" :align="col.align ?? 'left'" :label-align="col.labelAlign" :class-name="col.className"
|
|
13
|
+
:label-class-name="col.labelClassName">
|
|
14
|
+
<template v-if="typeof col.label === 'function'" #label>
|
|
15
|
+
<NodeRenderer :get-node="() => (col.label as (c: DescriptionsColumnItem) => any)(col)" />
|
|
16
|
+
</template>
|
|
17
|
+
<slot v-if="hasColumnSlot(col.value)" :name="col.value" :value="getFieldValue(col)" :data="data" :column="col" />
|
|
18
|
+
<NodeRenderer v-else-if="col.render && data" :get-node="() => col.render!({ value: getFieldValue(col), data, column: col })" />
|
|
19
|
+
<span v-else>{{ getFieldValue(col) }}</span>
|
|
20
|
+
</ElDescriptionsItem>
|
|
21
|
+
</template>
|
|
22
|
+
<template v-else>
|
|
23
|
+
<slot />
|
|
24
|
+
</template>
|
|
25
|
+
</ElDescriptions>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import type { DescriptionsColumnItem, DescriptionsProps } from './type'
|
|
30
|
+
import { ElDescriptions, ElDescriptionsItem } from 'element-plus'
|
|
31
|
+
import { computed, defineComponent, useSlots } from 'vue'
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<DescriptionsProps>(), {
|
|
34
|
+
columns: () => [],
|
|
35
|
+
data: () => ({}),
|
|
36
|
+
border: false,
|
|
37
|
+
column: 3,
|
|
38
|
+
direction: 'horizontal',
|
|
39
|
+
size: 'default',
|
|
40
|
+
title: '',
|
|
41
|
+
extra: ''
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
defineSlots<{
|
|
45
|
+
default?: () => any
|
|
46
|
+
title?: () => any
|
|
47
|
+
extra?: () => any
|
|
48
|
+
}>()
|
|
49
|
+
|
|
50
|
+
const NodeRenderer = defineComponent({
|
|
51
|
+
name: 'NodeRenderer',
|
|
52
|
+
props: {
|
|
53
|
+
getNode: { type: Function, required: true }
|
|
54
|
+
},
|
|
55
|
+
setup(props: { getNode: () => any }) {
|
|
56
|
+
return () => props.getNode()
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const slots = useSlots()
|
|
61
|
+
const useColumns = computed(() => (props.columns?.length ?? 0) > 0)
|
|
62
|
+
|
|
63
|
+
function hasColumnSlot(name: string | undefined): boolean {
|
|
64
|
+
return !!name && !!(slots as Record<string, unknown>)[name]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getFieldValue(col: DescriptionsColumnItem) {
|
|
68
|
+
if (!props.data || col.value === undefined || col.value === null)
|
|
69
|
+
return ''
|
|
70
|
+
return props.data[col.value]
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VNode } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** 描述列表列配置(对应 data 的字段与展示) */
|
|
4
|
+
export interface DescriptionsColumnItem {
|
|
5
|
+
/** 对应 data 的字段名 */
|
|
6
|
+
value?: string
|
|
7
|
+
/** 标签文本,或返回 VNode 的函数 */
|
|
8
|
+
label?: string | ((columnItem: DescriptionsColumnItem) => VNode)
|
|
9
|
+
/** 列的数量(占据几列) */
|
|
10
|
+
span?: number
|
|
11
|
+
/** 列宽度(如无 border,宽度包含标签与内容) */
|
|
12
|
+
width?: string | number
|
|
13
|
+
/** 列最小宽度,剩余宽度按比例分配给设置了 minWidth 的列 */
|
|
14
|
+
minWidth?: string | number
|
|
15
|
+
/** 列内容对齐方式 */
|
|
16
|
+
align?: 'left' | 'center' | 'right'
|
|
17
|
+
/** 列标签对齐方式(无 border 时用 align) */
|
|
18
|
+
labelAlign?: 'left' | 'center' | 'right'
|
|
19
|
+
/** 列内容自定义类名 */
|
|
20
|
+
className?: string
|
|
21
|
+
/** 列标签自定义类名 */
|
|
22
|
+
labelClassName?: string
|
|
23
|
+
/** 自定义渲染内容:({ value, data, column }) => VNode */
|
|
24
|
+
render?: (params: { value: any; data: Record<string, any>; column: DescriptionsColumnItem }) => VNode
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface DescriptionsProps {
|
|
28
|
+
/** 描述列表配置项,与 data 配合使用 */
|
|
29
|
+
columns?: DescriptionsColumnItem[]
|
|
30
|
+
/** 详情数据(与 columns 配合,按 value 取字段) */
|
|
31
|
+
data?: Record<string, any>
|
|
32
|
+
/** 是否带边框 */
|
|
33
|
+
border?: boolean
|
|
34
|
+
/** 一行 Descriptions Item 的数量 */
|
|
35
|
+
column?: number
|
|
36
|
+
/** 排列方向 */
|
|
37
|
+
direction?: 'vertical' | 'horizontal'
|
|
38
|
+
/** 列表尺寸 */
|
|
39
|
+
size?: 'large' | 'default' | 'small'
|
|
40
|
+
/** 标题文本,显示在左上方,也可用 title 插槽 */
|
|
41
|
+
title?: string
|
|
42
|
+
/** 操作区,显示在右上方,也可用 extra 插槽 */
|
|
43
|
+
extra?: string
|
|
44
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span :class="className" :style="tagStyle" @click="handleClick">
|
|
3
|
+
<span v-if="hasIcon" :class="b('tag__icon')">
|
|
4
|
+
<slot name="icon">
|
|
5
|
+
<ElIcon v-if="icon">
|
|
6
|
+
<component :is="icon" />
|
|
7
|
+
</ElIcon>
|
|
8
|
+
</slot>
|
|
9
|
+
</span>
|
|
10
|
+
<slot />
|
|
11
|
+
<span v-if="closable" class="gi-tag-close-btn" @click="handleClose">
|
|
12
|
+
<ElIcon class="close-icon">
|
|
13
|
+
<Close />
|
|
14
|
+
</ElIcon>
|
|
15
|
+
</span>
|
|
16
|
+
</span>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import type { CSSProperties } from 'vue'
|
|
21
|
+
import type { TagProps, TagThemeColor } from './type'
|
|
22
|
+
import { Close } from '@element-plus/icons-vue'
|
|
23
|
+
import { ElIcon } from 'element-plus'
|
|
24
|
+
import { computed, useSlots } from 'vue'
|
|
25
|
+
import { useBemClass } from '../../../hooks'
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<TagProps>(), {
|
|
28
|
+
type: 'light',
|
|
29
|
+
color: 'primary',
|
|
30
|
+
size: 'default',
|
|
31
|
+
closable: false
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
click: []
|
|
36
|
+
close: []
|
|
37
|
+
}>()
|
|
38
|
+
|
|
39
|
+
defineSlots<{
|
|
40
|
+
default?: () => unknown
|
|
41
|
+
icon?: () => unknown
|
|
42
|
+
}>()
|
|
43
|
+
|
|
44
|
+
const slots = useSlots()
|
|
45
|
+
const hasIcon = computed(() => Boolean(slots.icon) || Boolean(props.icon))
|
|
46
|
+
|
|
47
|
+
const SEMANTIC_THEME_COLORS: readonly TagThemeColor[] = [
|
|
48
|
+
'primary',
|
|
49
|
+
'success',
|
|
50
|
+
'warning',
|
|
51
|
+
'danger',
|
|
52
|
+
'info'
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
function isSemanticThemeColor(value: string): value is TagThemeColor {
|
|
56
|
+
return (SEMANTIC_THEME_COLORS as readonly string[]).includes(value)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { b } = useBemClass()
|
|
60
|
+
|
|
61
|
+
const BASE_COLORS = {
|
|
62
|
+
red: '#FF0000',
|
|
63
|
+
orangered: '#f77234',
|
|
64
|
+
orange: '#ff7d00',
|
|
65
|
+
gold: '#f7ba1e',
|
|
66
|
+
lime: '#9fdb1d',
|
|
67
|
+
green: '#00b42a',
|
|
68
|
+
cyan: '#14c9c9',
|
|
69
|
+
blue: '#3491fa',
|
|
70
|
+
purple: '#722ed1',
|
|
71
|
+
pink: '#f5319d',
|
|
72
|
+
gray: '#86909c'
|
|
73
|
+
} as const
|
|
74
|
+
|
|
75
|
+
type PresetColorKey = keyof typeof BASE_COLORS
|
|
76
|
+
|
|
77
|
+
function resolveColorToken(input: string): string {
|
|
78
|
+
return BASE_COLORS[input as PresetColorKey] || input
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hexToRgb(hex: string): { r: number, g: number, b: number } {
|
|
82
|
+
const body = hex.startsWith('#') ? hex.slice(1) : hex
|
|
83
|
+
const full = body.length === 3
|
|
84
|
+
? body.split('').map((c) => c + c).join('')
|
|
85
|
+
: body
|
|
86
|
+
return {
|
|
87
|
+
r: Number.parseInt(full.slice(0, 2), 16),
|
|
88
|
+
g: Number.parseInt(full.slice(2, 4), 16),
|
|
89
|
+
b: Number.parseInt(full.slice(4, 6), 16)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function stylesForType(
|
|
94
|
+
type: NonNullable<TagProps['type']>,
|
|
95
|
+
color: string,
|
|
96
|
+
rgb: { r: number, g: number, b: number }
|
|
97
|
+
): CSSProperties {
|
|
98
|
+
const { r, g, b } = rgb
|
|
99
|
+
const bgTint = `rgba(${r}, ${g}, ${b}, 0.1)`
|
|
100
|
+
const borderTint = `rgba(${r}, ${g}, ${b}, 0.2)`
|
|
101
|
+
/** 与主题色标签一致:悬停时白字 + 实心色底 */
|
|
102
|
+
const closeHoverVars = {
|
|
103
|
+
'--tag-close-hover-color': '#fff',
|
|
104
|
+
'--tag-close-hover-bg-color': color
|
|
105
|
+
} as CSSProperties
|
|
106
|
+
|
|
107
|
+
switch (type) {
|
|
108
|
+
case 'dark':
|
|
109
|
+
return {
|
|
110
|
+
'color': '#fff',
|
|
111
|
+
'backgroundColor': color,
|
|
112
|
+
'--tag-close-hover-color': color,
|
|
113
|
+
'--tag-close-hover-bg-color': 'rgba(255, 255, 255, 0.9)'
|
|
114
|
+
} as CSSProperties
|
|
115
|
+
case 'outline':
|
|
116
|
+
return {
|
|
117
|
+
color,
|
|
118
|
+
backgroundColor: 'transparent',
|
|
119
|
+
borderColor: color,
|
|
120
|
+
...closeHoverVars
|
|
121
|
+
}
|
|
122
|
+
case 'light-outline':
|
|
123
|
+
return {
|
|
124
|
+
color,
|
|
125
|
+
backgroundColor: bgTint,
|
|
126
|
+
borderColor: borderTint,
|
|
127
|
+
...closeHoverVars
|
|
128
|
+
}
|
|
129
|
+
case 'light':
|
|
130
|
+
default:
|
|
131
|
+
return {
|
|
132
|
+
color,
|
|
133
|
+
backgroundColor: bgTint,
|
|
134
|
+
...closeHoverVars
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const className = computed(() => {
|
|
140
|
+
const c = props.color
|
|
141
|
+
return [
|
|
142
|
+
b('tag'),
|
|
143
|
+
props.type && b(`tag__type--${props.type}`),
|
|
144
|
+
props.size && b(`tag__size--${props.size}`),
|
|
145
|
+
c && isSemanticThemeColor(c) && b(`tag__color--${c}`)
|
|
146
|
+
].filter(Boolean).join(' ')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const tagStyle = computed((): CSSProperties => {
|
|
150
|
+
const raw = props.color
|
|
151
|
+
if (!raw || isSemanticThemeColor(raw))
|
|
152
|
+
return {}
|
|
153
|
+
const color = resolveColorToken(raw)
|
|
154
|
+
return stylesForType(props.type ?? 'light', color, hexToRgb(color))
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
function handleClick() {
|
|
158
|
+
emit('click')
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function handleClose(event: MouseEvent) {
|
|
162
|
+
event.stopPropagation()
|
|
163
|
+
emit('close')
|
|
164
|
+
}
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<style scoped lang="scss">
|
|
168
|
+
@use '../../../styles/var.scss' as a;
|
|
169
|
+
|
|
170
|
+
$theme-colors: primary, success, warning, danger, info;
|
|
171
|
+
|
|
172
|
+
$tag-size-small-height: 20px;
|
|
173
|
+
$tag-size-default-height: 22px;
|
|
174
|
+
$tag-size-large-height: 24px;
|
|
175
|
+
|
|
176
|
+
$tag-size-small-padding: 0 6px;
|
|
177
|
+
$tag-size-default-padding: 0 8px;
|
|
178
|
+
$tag-size-large-padding: 0 10px;
|
|
179
|
+
|
|
180
|
+
.#{a.$prefix}-tag {
|
|
181
|
+
box-sizing: border-box;
|
|
182
|
+
display: inline-flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
justify-content: center;
|
|
185
|
+
font-size: 12px;
|
|
186
|
+
line-height: 1;
|
|
187
|
+
white-space: nowrap;
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
border-radius: 3px;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.#{a.$prefix}-tag__icon {
|
|
193
|
+
display: inline-flex;
|
|
194
|
+
flex-shrink: 0;
|
|
195
|
+
align-items: center;
|
|
196
|
+
margin-right: 4px;
|
|
197
|
+
line-height: 0;
|
|
198
|
+
color: inherit;
|
|
199
|
+
|
|
200
|
+
:deep(.el-icon),
|
|
201
|
+
:deep(svg) {
|
|
202
|
+
width: 11px;
|
|
203
|
+
height: 11px;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.#{a.$prefix}-tag-close-btn {
|
|
208
|
+
position: relative;
|
|
209
|
+
box-sizing: border-box;
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
width: 15px;
|
|
214
|
+
height: 15px;
|
|
215
|
+
margin-left: 4px;
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
background-color: transparent;
|
|
218
|
+
border-radius: 50%;
|
|
219
|
+
transition: background-color 0.1s cubic-bezier(0, 0, 1, 1);
|
|
220
|
+
|
|
221
|
+
.close-icon {
|
|
222
|
+
z-index: 9;
|
|
223
|
+
width: 11px;
|
|
224
|
+
height: 11px;
|
|
225
|
+
color: inherit;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* 主题色写在 .gi-tag__color--* 上,自定义色写在内联 style;统一用变量驱动悬停 */
|
|
229
|
+
&:hover {
|
|
230
|
+
color: var(--tag-close-hover-color);
|
|
231
|
+
background-color: var(--tag-close-hover-bg-color);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.#{a.$prefix}-tag__size--small {
|
|
236
|
+
height: $tag-size-small-height;
|
|
237
|
+
padding: $tag-size-small-padding;
|
|
238
|
+
|
|
239
|
+
.#{a.$prefix}-tag__icon {
|
|
240
|
+
:deep(.el-icon),
|
|
241
|
+
:deep(svg) {
|
|
242
|
+
width: 10px;
|
|
243
|
+
height: 10px;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.#{a.$prefix}-tag-close-btn {
|
|
248
|
+
width: 14px;
|
|
249
|
+
height: 14px;
|
|
250
|
+
|
|
251
|
+
.close-icon {
|
|
252
|
+
width: 10px;
|
|
253
|
+
height: 10px;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.#{a.$prefix}-tag__size--default {
|
|
259
|
+
height: $tag-size-default-height;
|
|
260
|
+
padding: $tag-size-default-padding;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.#{a.$prefix}-tag__size--large {
|
|
264
|
+
height: $tag-size-large-height;
|
|
265
|
+
padding: $tag-size-large-padding;
|
|
266
|
+
|
|
267
|
+
.#{a.$prefix}-tag__icon {
|
|
268
|
+
:deep(.el-icon),
|
|
269
|
+
:deep(svg) {
|
|
270
|
+
width: 12px;
|
|
271
|
+
height: 12px;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.#{a.$prefix}-tag-close-btn {
|
|
276
|
+
width: 16px;
|
|
277
|
+
height: 16px;
|
|
278
|
+
|
|
279
|
+
.close-icon {
|
|
280
|
+
width: 12px;
|
|
281
|
+
height: 12px;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.#{a.$prefix}-tag__type--light {
|
|
287
|
+
@each $s in $theme-colors {
|
|
288
|
+
&.#{a.$prefix}-tag__color--#{$s} {
|
|
289
|
+
color: var(--el-color-#{$s});
|
|
290
|
+
background-color: var(--el-color-#{$s}-light-9);
|
|
291
|
+
|
|
292
|
+
--tag-close-hover-color: #fff;
|
|
293
|
+
--tag-close-hover-bg-color: var(--el-color-#{$s});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.#{a.$prefix}-tag__type--dark {
|
|
299
|
+
color: #fff;
|
|
300
|
+
|
|
301
|
+
@each $s in $theme-colors {
|
|
302
|
+
&.#{a.$prefix}-tag__color--#{$s} {
|
|
303
|
+
background-color: var(--el-color-#{$s});
|
|
304
|
+
|
|
305
|
+
--tag-close-hover-color: var(--el-color-#{$s});
|
|
306
|
+
--tag-close-hover-bg-color: rgb(255 255 255 / 90%);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.#{a.$prefix}-tag__type--outline {
|
|
312
|
+
background: transparent;
|
|
313
|
+
border-style: solid;
|
|
314
|
+
border-width: 1px;
|
|
315
|
+
|
|
316
|
+
@each $s in $theme-colors {
|
|
317
|
+
&.#{a.$prefix}-tag__color--#{$s} {
|
|
318
|
+
color: var(--el-color-#{$s});
|
|
319
|
+
border-color: var(--el-color-#{$s});
|
|
320
|
+
|
|
321
|
+
--tag-close-hover-color: #fff;
|
|
322
|
+
--tag-close-hover-bg-color: var(--el-color-#{$s});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.#{a.$prefix}-tag__type--light-outline {
|
|
328
|
+
border-style: solid;
|
|
329
|
+
border-width: 1px;
|
|
330
|
+
|
|
331
|
+
@each $s in $theme-colors {
|
|
332
|
+
&.#{a.$prefix}-tag__color--#{$s} {
|
|
333
|
+
color: var(--el-color-#{$s});
|
|
334
|
+
background-color: var(--el-color-#{$s}-light-9);
|
|
335
|
+
border-color: var(--el-color-#{$s}-light-5);
|
|
336
|
+
|
|
337
|
+
--tag-close-hover-color: #fff;
|
|
338
|
+
--tag-close-hover-bg-color: var(--el-color-#{$s});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Component } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** 与 Element Plus 语义色一致的主题色(走 CSS 变量,非内联色值) */
|
|
4
|
+
export type TagThemeColor = 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
5
|
+
|
|
6
|
+
/** 内置调色板色名(映射为固定十六进制) */
|
|
7
|
+
export type TagPaletteColor =
|
|
8
|
+
| 'red'
|
|
9
|
+
| 'orangered'
|
|
10
|
+
| 'orange'
|
|
11
|
+
| 'gold'
|
|
12
|
+
| 'lime'
|
|
13
|
+
| 'green'
|
|
14
|
+
| 'cyan'
|
|
15
|
+
| 'blue'
|
|
16
|
+
| 'purple'
|
|
17
|
+
| 'pink'
|
|
18
|
+
| 'gray'
|
|
19
|
+
|
|
20
|
+
/** 组件属性定义 */
|
|
21
|
+
export interface TagProps {
|
|
22
|
+
/** 标签类型 */
|
|
23
|
+
type?: 'dark' | 'light' | 'outline' | 'light-outline'
|
|
24
|
+
/**
|
|
25
|
+
* 颜色:主题色名(primary / success 等,使用 Element 色板)、调色板预设名(red / blue 等)或任意 CSS 颜色字符串(如十六进制)
|
|
26
|
+
*/
|
|
27
|
+
color?: TagThemeColor | TagPaletteColor | string
|
|
28
|
+
/** 标签尺寸 */
|
|
29
|
+
size?: 'small' | 'default' | 'large'
|
|
30
|
+
/**
|
|
31
|
+
* 左侧图标组件(如 `@element-plus/icons-vue` 图标);与 `#icon` 插槽同时存在时以插槽为准
|
|
32
|
+
*/
|
|
33
|
+
icon?: Component
|
|
34
|
+
/** 是否可关闭 */
|
|
35
|
+
closable?: boolean
|
|
36
|
+
}
|
package/packages/components.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
// Generated by unplugin-vue-components
|
|
4
|
-
// Read more: https://github.com/vuejs/core/pull/3399
|
|
5
|
-
// biome-ignore lint: disable
|
|
6
|
-
export {}
|
|
7
|
-
|
|
8
|
-
/* prettier-ignore */
|
|
9
|
-
declare module 'vue' {
|
|
10
|
-
export interface GlobalComponents {
|
|
11
|
-
GiButton: typeof import('./components/button/src/button.vue')['default']
|
|
12
|
-
GiCard: typeof import('./components/card/src/card.vue')['default']
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
// Generated by unplugin-vue-components
|
|
4
|
+
// Read more: https://github.com/vuejs/core/pull/3399
|
|
5
|
+
// biome-ignore lint: disable
|
|
6
|
+
export {}
|
|
7
|
+
|
|
8
|
+
/* prettier-ignore */
|
|
9
|
+
declare module 'vue' {
|
|
10
|
+
export interface GlobalComponents {
|
|
11
|
+
GiButton: typeof import('./components/button/src/button.vue')['default']
|
|
12
|
+
GiCard: typeof import('./components/card/src/card.vue')['default']
|
|
13
|
+
GiDescriptions: typeof import('./components/descriptions/src/descriptions.vue')['default']
|
|
14
|
+
GiDialog: typeof import('./components/dialog/src/dialog.vue')['default']
|
|
15
|
+
GiDialogContent: typeof import('./components/dialog/src/dialog-content.vue')['default']
|
|
16
|
+
GiDot: typeof import('./components/dot/src/dot.vue')['default']
|
|
17
|
+
GiDrawer: typeof import('./components/drawer/src/drawer.vue')['default']
|
|
18
|
+
GiEditTable: typeof import('./components/edit-table/src/edit-table.vue')['default']
|
|
19
|
+
GiFlex: typeof import('./components/flex/src/flex.vue')['default']
|
|
20
|
+
GiForm: typeof import('./components/form/src/form.vue')['default']
|
|
21
|
+
GiGrid: typeof import('./components/grid/src/grid.vue')['default']
|
|
22
|
+
GiGridItem: typeof import('./components/grid/src/grid-item.vue')['default']
|
|
23
|
+
GiInputGroup: typeof import('./components/input-group/src/input-group.vue')['default']
|
|
24
|
+
GiInputSearch: typeof import('./components/input-search/src/input-search.vue')['default']
|
|
25
|
+
GiPageLayout: typeof import('./components/page-layout/src/page-layout.vue')['default']
|
|
26
|
+
GiSplitButton: typeof import('./components/page-layout/src/split-button.vue')['default']
|
|
27
|
+
GiTable: typeof import('./components/table/src/table.vue')['default']
|
|
28
|
+
GiTableColumn: typeof import('./components/table/src/TableColumn.vue')['default']
|
|
29
|
+
GiTabs: typeof import('./components/tabs/src/tabs.vue')['default']
|
|
30
|
+
GiTag: typeof import('./components/tag/src/tag.vue')['default']
|
|
31
|
+
GiTreeTransfer: typeof import('./components/tree-transfer/src/tree-transfer.vue')['default']
|
|
32
|
+
}
|
|
33
|
+
}
|
package/packages/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { App, Component } from 'vue'
|
|
|
2
2
|
|
|
3
3
|
import Button from './components/button'
|
|
4
4
|
import Card from './components/card'
|
|
5
|
+
import Descriptions from './components/descriptions'
|
|
5
6
|
import DialogComponent, { Dialog as DialogFunction } from './components/dialog'
|
|
6
7
|
import Dot from './components/dot'
|
|
7
8
|
import Drawer from './components/drawer'
|
|
@@ -15,24 +16,28 @@ import InputSearch from './components/input-search'
|
|
|
15
16
|
import PageLayout from './components/page-layout'
|
|
16
17
|
import Table from './components/table'
|
|
17
18
|
import Tabs from './components/tabs'
|
|
19
|
+
import Tag from './components/tag'
|
|
18
20
|
import TreeTransfer from './components/tree-transfer'
|
|
19
21
|
import './styles/index.scss'
|
|
20
22
|
|
|
21
23
|
// 防止打包时 tree-shake 掉 Dialog.info/success/warning/error(内部只用到 Dialog.open)
|
|
22
24
|
void [DialogFunction.info, DialogFunction.success, DialogFunction.warning, DialogFunction.error]
|
|
23
25
|
|
|
26
|
+
export * from './components/descriptions'
|
|
24
27
|
export * from './components/dialog'
|
|
25
28
|
export * from './components/drawer'
|
|
26
29
|
export * from './components/edit-table'
|
|
27
30
|
export * from './components/form'
|
|
28
31
|
export * from './components/table'
|
|
29
32
|
export * from './components/tabs'
|
|
33
|
+
export * from './components/tag'
|
|
30
34
|
export * from './hooks'
|
|
31
35
|
export * from './utils'
|
|
32
36
|
|
|
33
37
|
const components = {
|
|
34
38
|
Button,
|
|
35
39
|
Card,
|
|
40
|
+
Descriptions,
|
|
36
41
|
Drawer,
|
|
37
42
|
Dot,
|
|
38
43
|
Tabs,
|
|
@@ -46,12 +51,14 @@ const components = {
|
|
|
46
51
|
Dialog: DialogComponent,
|
|
47
52
|
EditTable,
|
|
48
53
|
Table,
|
|
54
|
+
Tag,
|
|
49
55
|
TreeTransfer
|
|
50
56
|
} as unknown as Record<string, Component>
|
|
51
57
|
|
|
52
58
|
// 导出Gi前缀的组件并添加明确类型注解
|
|
53
59
|
export const GiButton: typeof Button = Button
|
|
54
60
|
export const GiCard: typeof Card = Card
|
|
61
|
+
export const GiDescriptions: typeof Descriptions = Descriptions
|
|
55
62
|
export const GiDrawer: typeof Drawer = Drawer
|
|
56
63
|
export const GiDot: typeof Dot = Dot
|
|
57
64
|
export const GiTabs: typeof Tabs = Tabs
|
|
@@ -65,6 +72,7 @@ export const GiPageLayout: typeof PageLayout = PageLayout
|
|
|
65
72
|
export const GiDialog: typeof DialogComponent = DialogComponent
|
|
66
73
|
export const GiEditTable: typeof EditTable = EditTable
|
|
67
74
|
export const GiTable: typeof Table = Table
|
|
75
|
+
export const GiTag: typeof Tag = Tag
|
|
68
76
|
export const GiTreeTransfer: typeof TreeTransfer = TreeTransfer
|
|
69
77
|
|
|
70
78
|
function capitalizeWord(word: string) {
|