daisy-ui-kit 5.0.10 → 5.0.11
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/app/components/Badge.vue +55 -64
- package/app/components/Button.vue +121 -133
- package/app/components/Card.vue +32 -41
- package/app/components/Countdown.vue +10 -13
- package/app/components/DaisyLink.vue +32 -45
- package/app/components/Fieldset.vue +15 -17
- package/app/components/Flex.vue +73 -75
- package/app/components/FlexItem.vue +45 -51
- package/app/components/Indicator.vue +10 -17
- package/app/components/IndicatorItem.vue +28 -35
- package/app/components/Navbar.vue +12 -11
- package/app/components/NavbarCenter.vue +11 -10
- package/app/components/NavbarEnd.vue +11 -10
- package/app/components/NavbarStart.vue +11 -10
- package/app/components/SkeletonText.vue +11 -10
- package/app/components/Stack.vue +25 -27
- package/app/components/Tab.vue +47 -46
- package/app/components/Text.vue +175 -172
- package/package.json +1 -1
package/app/components/Flex.vue
CHANGED
|
@@ -1,89 +1,87 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
inheritAttrs: false,
|
|
4
|
-
})
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, h } from 'vue'
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
is: { type: [String, Object], default: 'div' },
|
|
8
|
+
join: Boolean,
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
// https://tailwindcss.com/docs/flex
|
|
11
|
+
flex: Boolean,
|
|
12
|
+
flex1: Boolean,
|
|
13
|
+
flexAuto: Boolean,
|
|
14
|
+
flexInitial: Boolean,
|
|
15
|
+
none: Boolean,
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
// justify
|
|
18
|
+
justify: String as () => 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly',
|
|
19
|
+
justifyStart: Boolean,
|
|
20
|
+
justifyEnd: Boolean,
|
|
21
|
+
justifyCenter: Boolean,
|
|
22
|
+
justifyBetween: Boolean,
|
|
23
|
+
justifyAround: Boolean,
|
|
24
|
+
justifyEvenly: Boolean,
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
// align
|
|
27
|
+
items: String as () => 'start' | 'end' | 'center' | 'baseline' | 'stretch',
|
|
28
|
+
itemsStart: Boolean,
|
|
29
|
+
itemsEnd: Boolean,
|
|
30
|
+
itemsCenter: Boolean,
|
|
31
|
+
itemsBaseline: Boolean,
|
|
32
|
+
itemsStretch: Boolean,
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
grow: Boolean,
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
// https://tailwindcss.com/docs/flex-direction
|
|
37
|
+
direction: String as () => 'row' | 'col' | 'row-reverse' | 'col-reverse',
|
|
38
|
+
row: Boolean,
|
|
39
|
+
col: Boolean,
|
|
40
|
+
reverse: Boolean,
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
42
|
+
// https://tailwindcss.com/docs/flex-wrap
|
|
43
|
+
wrap: Boolean,
|
|
44
|
+
nowrap: Boolean,
|
|
45
|
+
wrapReverse: Boolean,
|
|
46
|
+
},
|
|
47
|
+
setup(props, { slots, attrs }) {
|
|
48
|
+
const classes = computed(() => [
|
|
49
|
+
'flex',
|
|
50
|
+
{
|
|
51
|
+
'join-item': props.join,
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class="flex"
|
|
54
|
-
:class="{
|
|
55
|
-
'join-item': props.join,
|
|
53
|
+
'flex-1': props.flex1,
|
|
54
|
+
'flex-auto': props.flexAuto,
|
|
55
|
+
'flex-initial': props.flexInitial,
|
|
56
|
+
'flex-none': props.none,
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
'justify-start': props.justifyStart,
|
|
59
|
+
'justify-end': props.justifyEnd,
|
|
60
|
+
'justify-center': props.justifyCenter,
|
|
61
|
+
'justify-between': props.justifyBetween,
|
|
62
|
+
'justify-around': props.justifyAround,
|
|
63
|
+
'justify-evenly': props.justifyEvenly,
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
'justify-evenly': props.justifyEvenly,
|
|
65
|
+
'items-start': props.itemsStart,
|
|
66
|
+
'items-end': props.itemsEnd,
|
|
67
|
+
'items-center': props.itemsCenter,
|
|
68
|
+
'items-baseline': props.itemsBaseline,
|
|
69
|
+
'items-stretch': props.itemsStretch,
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
'items-end': props.itemsEnd,
|
|
71
|
-
'items-center': props.itemsCenter,
|
|
72
|
-
'items-baseline': props.itemsBaseline,
|
|
73
|
-
'items-stretch': props.itemsStretch,
|
|
71
|
+
'flex-grow': props.grow,
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
'flex-row': props.direction === 'row' || props.row,
|
|
74
|
+
'flex-col': props.direction === 'col' || props.col,
|
|
75
|
+
'flex-row-reverse': props.direction === 'row-reverse' || (props.row && props.reverse),
|
|
76
|
+
'flex-col-reverse': props.direction === 'col-reverse' || (props.col && props.reverse),
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
'flex-wrap': props.wrap,
|
|
79
|
+
'flex-wrap-reverse': props.wrapReverse,
|
|
80
|
+
'flex-nowrap': props.nowrap,
|
|
81
|
+
},
|
|
82
|
+
])
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
>
|
|
87
|
-
<slot />
|
|
88
|
-
</component>
|
|
89
|
-
</template>
|
|
84
|
+
return () => h(props.is as any, { ...attrs, class: classes.value }, slots.default?.())
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
</script>
|
|
@@ -1,62 +1,56 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { computed } from 'vue'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, h } from 'vue'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
is
|
|
7
|
-
join
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'div' },
|
|
7
|
+
join: Boolean,
|
|
8
8
|
|
|
9
9
|
// https://tailwindcss.com/docs/flex
|
|
10
|
-
flex
|
|
11
|
-
flex1
|
|
12
|
-
flexAuto
|
|
13
|
-
flexInitial
|
|
14
|
-
none
|
|
10
|
+
flex: { type: Boolean, default: false },
|
|
11
|
+
flex1: Boolean,
|
|
12
|
+
flexAuto: Boolean,
|
|
13
|
+
flexInitial: Boolean,
|
|
14
|
+
none: Boolean,
|
|
15
15
|
|
|
16
|
-
grow
|
|
16
|
+
grow: Boolean,
|
|
17
17
|
|
|
18
18
|
// https://tailwindcss.com/docs/flex-direction
|
|
19
|
-
direction
|
|
20
|
-
row
|
|
21
|
-
col
|
|
22
|
-
reverse
|
|
19
|
+
direction: String as () => 'row' | 'col' | 'row-reverse' | 'col-reverse',
|
|
20
|
+
row: Boolean,
|
|
21
|
+
col: Boolean,
|
|
22
|
+
reverse: Boolean,
|
|
23
23
|
|
|
24
24
|
// https://tailwindcss.com/docs/flex-wrap
|
|
25
|
-
wrap
|
|
26
|
-
nowrap
|
|
27
|
-
wrapReverse
|
|
28
|
-
}
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
wrap: Boolean,
|
|
26
|
+
nowrap: Boolean,
|
|
27
|
+
wrapReverse: Boolean,
|
|
28
|
+
},
|
|
29
|
+
setup(props, { slots }) {
|
|
30
|
+
const classes = computed(() => [
|
|
31
|
+
'flex',
|
|
32
|
+
{
|
|
33
|
+
'join-item': props.join,
|
|
34
|
+
|
|
35
|
+
'flex-1': props.flex1,
|
|
36
|
+
'flex-auto': props.flexAuto,
|
|
37
|
+
'flex-initial': props.flexInitial,
|
|
38
|
+
'flex-none': props.none,
|
|
39
|
+
|
|
40
|
+
'flex-grow': props.grow,
|
|
41
|
+
|
|
42
|
+
'flex-row': props.direction === 'row' || props.row,
|
|
43
|
+
'flex-col': props.direction === 'col' || props.col,
|
|
44
|
+
'flex-row-reverse': props.direction === 'row-reverse' || (props.row && props.reverse),
|
|
45
|
+
'flex-col-reverse': props.direction === 'col-reverse' || (props.col && props.reverse),
|
|
46
|
+
|
|
47
|
+
'flex-wrap': props.wrap,
|
|
48
|
+
'flex-wrap-reverse': props.wrapReverse,
|
|
49
|
+
'flex-nowrap': props.nowrap,
|
|
50
|
+
},
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
return () => h(props.is as any, { class: classes.value }, slots.default?.())
|
|
32
54
|
},
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
const classes = computed(() => {
|
|
36
|
-
return {
|
|
37
|
-
'join-item': props.join,
|
|
38
|
-
|
|
39
|
-
'flex-1': props.flex1,
|
|
40
|
-
'flex-auto': props.flexAuto,
|
|
41
|
-
'flex-initial': props.flexInitial,
|
|
42
|
-
'flex-none': props.none,
|
|
43
|
-
|
|
44
|
-
'flex-grow': props.grow,
|
|
45
|
-
|
|
46
|
-
'flex-row': props.direction === 'row' || props.row,
|
|
47
|
-
'flex-col': props.direction === 'col' || props.col,
|
|
48
|
-
'flex-row-reverse': props.direction === 'row-reverse' || (props.row && props.reverse),
|
|
49
|
-
'flex-col-reverse': props.direction === 'col-reverse' || (props.col && props.reverse),
|
|
50
|
-
|
|
51
|
-
'flex-wrap': props.wrap,
|
|
52
|
-
'flex-wrap-reverse': props.wrapReverse,
|
|
53
|
-
'flex-nowrap': props.nowrap,
|
|
54
|
-
}
|
|
55
55
|
})
|
|
56
56
|
</script>
|
|
57
|
-
|
|
58
|
-
<template>
|
|
59
|
-
<component :is="is" class="flex" :class="classes">
|
|
60
|
-
<slot />
|
|
61
|
-
</component>
|
|
62
|
-
</template>
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
inheritAttrs: false,
|
|
4
|
-
})
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
is: 'div',
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
is: { type: [String, Object], default: 'div' },
|
|
12
8
|
},
|
|
13
|
-
)
|
|
9
|
+
setup(props, { slots, attrs }) {
|
|
10
|
+
return () => h(props.is as any, { ...attrs, class: 'indicator' }, slots.default?.())
|
|
11
|
+
},
|
|
12
|
+
})
|
|
14
13
|
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<component :is="is" v-bind="$attrs" class="indicator">
|
|
18
|
-
<slot />
|
|
19
|
-
</component>
|
|
20
|
-
</template>
|
|
@@ -1,43 +1,36 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { computed } from 'vue'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, h } from 'vue'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
5
|
inheritAttrs: false,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(
|
|
9
|
-
defineProps<{
|
|
10
|
-
is?: string
|
|
6
|
+
props: {
|
|
7
|
+
is: { type: [String, Object], default: 'div' },
|
|
11
8
|
|
|
12
|
-
align
|
|
13
|
-
start
|
|
14
|
-
center
|
|
15
|
-
end
|
|
9
|
+
align: String as () => 'start' | 'center' | 'end',
|
|
10
|
+
start: Boolean,
|
|
11
|
+
center: Boolean,
|
|
12
|
+
end: Boolean,
|
|
16
13
|
|
|
17
|
-
vAlign
|
|
18
|
-
top
|
|
19
|
-
middle
|
|
20
|
-
bottom
|
|
21
|
-
}>(),
|
|
22
|
-
{
|
|
23
|
-
is: 'div',
|
|
14
|
+
vAlign: String as () => 'top' | 'middle' | 'bottom',
|
|
15
|
+
top: Boolean,
|
|
16
|
+
middle: Boolean,
|
|
17
|
+
bottom: Boolean,
|
|
24
18
|
},
|
|
25
|
-
)
|
|
26
|
-
const classes = computed(() =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
setup(props, { slots, attrs }) {
|
|
20
|
+
const classes = computed(() => [
|
|
21
|
+
'indicator-item',
|
|
22
|
+
{
|
|
23
|
+
'indicator-start': props.start || props.align === 'start',
|
|
24
|
+
'indicator-center': props.center || props.align === 'center',
|
|
25
|
+
'indicator-end': props.end || props.align === 'end',
|
|
26
|
+
|
|
27
|
+
'indicator-top': props.top || props.vAlign === 'top',
|
|
28
|
+
'indicator-middle': props.middle || props.vAlign === 'middle',
|
|
29
|
+
'indicator-bottom': props.bottom || props.vAlign === 'bottom',
|
|
30
|
+
},
|
|
31
|
+
])
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'indicator-bottom': props.bottom || props.vAlign === 'bottom',
|
|
35
|
-
}
|
|
33
|
+
return () => h(props.is as any, { ...attrs, class: classes.value }, slots.default?.())
|
|
34
|
+
},
|
|
36
35
|
})
|
|
37
36
|
</script>
|
|
38
|
-
|
|
39
|
-
<template>
|
|
40
|
-
<component :is="is" v-bind="$attrs" class="indicator-item" :class="classes">
|
|
41
|
-
<slot />
|
|
42
|
-
</component>
|
|
43
|
-
</template>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
is?: any
|
|
4
|
-
glass?: boolean
|
|
5
|
-
}>()
|
|
6
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'div' },
|
|
7
|
+
glass: { type: Boolean, default: false },
|
|
8
|
+
},
|
|
9
|
+
setup(props, { slots }) {
|
|
10
|
+
return () => h(props.is as any, { class: ['navbar', { glass: props.glass }] }, slots.default?.())
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
</script>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
is?: any
|
|
4
|
-
}>()
|
|
5
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'div' },
|
|
7
|
+
},
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
return () => h(props.is as any, { class: 'navbar-center' }, slots.default?.())
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
</script>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
is?: any
|
|
4
|
-
}>()
|
|
5
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'div' },
|
|
7
|
+
},
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
return () => h(props.is as any, { class: 'navbar-end' }, slots.default?.())
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
</script>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
is?: any
|
|
4
|
-
}>()
|
|
5
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'div' },
|
|
7
|
+
},
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
return () => h(props.is as any, { class: 'navbar-start' }, slots.default?.())
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
</script>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
is?: any
|
|
4
|
-
}>()
|
|
5
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
is: { type: [String, Object], default: 'span' },
|
|
7
|
+
},
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
return () => h(props.is as any, { class: 'skeleton skeleton-text' }, slots.default?.())
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
</script>
|
package/app/components/Stack.vue
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, h } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
3
5
|
inheritAttrs: false,
|
|
4
|
-
|
|
6
|
+
props: {
|
|
7
|
+
is: { type: [String, Object], default: 'div' },
|
|
8
|
+
direction: String as () => 'top' | 'end' | 'bottom' | 'start',
|
|
9
|
+
top: Boolean,
|
|
10
|
+
end: Boolean,
|
|
11
|
+
bottom: Boolean,
|
|
12
|
+
start: Boolean,
|
|
13
|
+
},
|
|
14
|
+
setup(props, { slots, attrs }) {
|
|
15
|
+
const classes = computed(() => [
|
|
16
|
+
'stack',
|
|
17
|
+
{
|
|
18
|
+
'stack-top': props.top || props.direction === 'top',
|
|
19
|
+
'stack-end': props.end || props.direction === 'end',
|
|
20
|
+
'stack-bottom': props.bottom || props.direction === 'bottom',
|
|
21
|
+
'stack-start': props.start || props.direction === 'start',
|
|
22
|
+
},
|
|
23
|
+
])
|
|
5
24
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
top?: boolean
|
|
10
|
-
end?: boolean
|
|
11
|
-
bottom?: boolean
|
|
12
|
-
start?: boolean
|
|
13
|
-
}>()
|
|
25
|
+
return () => h(props.is as any, { ...attrs, class: classes.value }, slots.default?.())
|
|
26
|
+
},
|
|
27
|
+
})
|
|
14
28
|
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<component
|
|
18
|
-
:is="is"
|
|
19
|
-
v-bind="$attrs"
|
|
20
|
-
class="stack"
|
|
21
|
-
:class="{
|
|
22
|
-
'stack-top': top || direction === 'top',
|
|
23
|
-
'stack-end': end || direction === 'end',
|
|
24
|
-
'stack-bottom': bottom || direction === 'bottom',
|
|
25
|
-
'stack-start': start || direction === 'start',
|
|
26
|
-
}"
|
|
27
|
-
>
|
|
28
|
-
<slot />
|
|
29
|
-
</component>
|
|
30
|
-
</template>
|
package/app/components/Tab.vue
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { computed,
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, h, inject } from 'vue'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default defineComponent({
|
|
5
5
|
inheritAttrs: false,
|
|
6
|
-
|
|
6
|
+
props: {
|
|
7
|
+
is: { type: [String, Object], default: 'label' },
|
|
8
|
+
name: String,
|
|
9
|
+
active: Boolean,
|
|
10
|
+
disabled: Boolean,
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots, attrs }) {
|
|
13
|
+
const tabManager: any = inject('tabManager')
|
|
14
|
+
if (!tabManager.currentTab.value) {
|
|
15
|
+
tabManager.currentTab.value = props.name
|
|
16
|
+
}
|
|
7
17
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
active?: boolean
|
|
16
|
-
disabled?: boolean
|
|
17
|
-
}>()
|
|
18
|
+
const classes = computed(() => [
|
|
19
|
+
'tab',
|
|
20
|
+
{
|
|
21
|
+
'tab-active': props.active || tabManager.currentTab.value === props.name,
|
|
22
|
+
'tab-disabled': props.disabled,
|
|
23
|
+
},
|
|
24
|
+
])
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
return () =>
|
|
27
|
+
h(
|
|
28
|
+
props.is as any,
|
|
29
|
+
{
|
|
30
|
+
...attrs,
|
|
31
|
+
class: classes.value,
|
|
32
|
+
onKeypress: (e: KeyboardEvent) => {
|
|
33
|
+
if (e.key === 'Enter') {
|
|
34
|
+
tabManager.currentTab.value = props.name
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
h('input', {
|
|
40
|
+
type: 'radio',
|
|
41
|
+
name: tabManager.name,
|
|
42
|
+
value: props.name,
|
|
43
|
+
checked: tabManager.currentTab.value === props.name,
|
|
44
|
+
onChange: () => {
|
|
45
|
+
tabManager.currentTab.value = props.name
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
...(slots.default ? slots.default() : [h('span', props.name)]),
|
|
49
|
+
],
|
|
50
|
+
)
|
|
51
|
+
},
|
|
22
52
|
})
|
|
23
|
-
|
|
24
|
-
const tabManager: any = inject('tabManager')
|
|
25
|
-
if (!tabManager.currentTab.value) {
|
|
26
|
-
tabManager.currentTab.value = name
|
|
27
|
-
}
|
|
28
53
|
</script>
|
|
29
|
-
|
|
30
|
-
<template>
|
|
31
|
-
<component
|
|
32
|
-
:is="resolvedComponent"
|
|
33
|
-
v-bind="$attrs"
|
|
34
|
-
class="tab"
|
|
35
|
-
:class="{
|
|
36
|
-
'tab-active': props.active || tabManager.currentTab.value === name,
|
|
37
|
-
'tab-disabled': props.disabled,
|
|
38
|
-
}"
|
|
39
|
-
@keypress.enter="() => (tabManager.currentTab.value = name)"
|
|
40
|
-
>
|
|
41
|
-
<input
|
|
42
|
-
type="radio"
|
|
43
|
-
:name="tabManager.name"
|
|
44
|
-
:value="name"
|
|
45
|
-
:checked="tabManager.currentTab.value === name"
|
|
46
|
-
@change="() => (tabManager.currentTab.value = name)"
|
|
47
|
-
/>
|
|
48
|
-
|
|
49
|
-
<slot v-if="$slots.default" />
|
|
50
|
-
<span v-else>{{ name }}</span>
|
|
51
|
-
</component>
|
|
52
|
-
</template>
|