Skip to content

Commit 3f64867

Browse files
author
issayah
committed
BInputGroup script setup conversion
1 parent 3cf4d09 commit 3f64867

File tree

5 files changed

+70
-79
lines changed

5 files changed

+70
-79
lines changed
Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable vue/no-v-html */
1+
<!-- eslint-disable vue/no-v-html -->
22
<template>
33
<component :is="tag" :id="id" class="input-group" :class="classes" role="group">
44
<slot name="prepend">
@@ -19,38 +19,31 @@
1919
</component>
2020
</template>
2121

22-
<script lang="ts">
23-
import {InputSize} from '../../types'
24-
import {computed, defineComponent, PropType} from 'vue'
22+
<script setup lang="ts">
23+
import type {InputSize} from '@/types'
24+
import {computed} from 'vue'
2525
26-
export default defineComponent({
27-
name: 'BInputGroup',
28-
props: {
29-
append: {type: String, required: false},
30-
appendHtml: {type: String, required: false},
31-
id: {type: String, required: false},
32-
prepend: {type: String, required: false},
33-
prependHtml: {type: String, required: false},
34-
size: {type: String as PropType<InputSize>, required: false},
35-
tag: {type: String, default: 'div'},
36-
},
37-
setup(props) {
38-
const classes = computed(() => ({
39-
'input-group-sm': props.size === 'sm',
40-
'input-group-lg': props.size === 'lg',
41-
}))
26+
interface BInputGroupProps {
27+
append?: string
28+
appendHtml?: string
29+
id?: string
30+
prepend?: string
31+
prependHtml?: string
32+
size?: InputSize
33+
tag?: string
34+
}
4235
43-
const hasAppend = computed(() => props.append || props.appendHtml)
44-
const hasPrepend = computed(() => props.prepend || props.prependHtml)
45-
const showAppendHtml = computed(() => !!props.appendHtml)
46-
const showPrependHtml = computed(() => !!props.prependHtml)
47-
return {
48-
classes,
49-
hasAppend,
50-
hasPrepend,
51-
showAppendHtml,
52-
showPrependHtml,
53-
}
54-
},
36+
const props = withDefaults(defineProps<BInputGroupProps>(), {
37+
tag: 'div',
5538
})
39+
40+
const classes = computed(() => ({
41+
'input-group-sm': props.size === 'sm',
42+
'input-group-lg': props.size === 'lg',
43+
}))
44+
45+
const hasAppend = computed<boolean>(() => !!props.append || !!props.appendHtml)
46+
const hasPrepend = computed<boolean>(() => !!props.prepend || !!props.prependHtml)
47+
const showAppendHtml = computed<boolean>(() => !!props.appendHtml)
48+
const showPrependHtml = computed<boolean>(() => !!props.prependHtml)
5649
</script>

src/components/BInputGroup/BInputGroupAddon.vue

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,25 @@
77
</component>
88
</template>
99

10-
<script lang="ts">
11-
import {computed, defineComponent} from 'vue'
10+
<script setup lang="ts">
11+
// import type {BInputGroupAddonProps} from '@/types/components'
12+
import {computed} from 'vue'
1213
import BInputGroupText from './BInputGroupText.vue'
1314
14-
export default defineComponent({
15-
name: 'BInputGroupAddon',
16-
components: {BInputGroupText},
17-
props: {
18-
append: {type: Boolean, default: false},
19-
id: {type: String, required: false},
20-
isText: {type: Boolean, default: false},
21-
tag: {type: String, default: 'div'},
22-
},
23-
setup(props) {
24-
const computedClasses = computed(() => ({
25-
'input-group-append': props.append,
26-
'input-group-prepend': !props.append,
27-
}))
15+
interface BInputGroupAddonProps {
16+
append?: boolean
17+
id?: string
18+
isText?: boolean
19+
tag?: string
20+
}
2821
29-
return {
30-
computedClasses,
31-
}
32-
},
22+
const props = withDefaults(defineProps<BInputGroupAddonProps>(), {
23+
append: false,
24+
tag: 'div',
3325
})
26+
27+
const computedClasses = computed(() => ({
28+
'input-group-append': props.append,
29+
'input-group-prepend': !props.append,
30+
}))
3431
</script>

src/components/BInputGroup/BInputGroupAppend.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
</b-input-group-addon>
55
</template>
66

7-
<script lang="ts">
8-
import {defineComponent} from 'vue'
7+
<script setup lang="ts">
8+
// import type {BInputGroupAppendProps} from '@/types/components'
99
import BInputGroupAddon from './BInputGroupAddon.vue'
1010
11-
export default defineComponent({
12-
name: 'BInputGroupAppend',
13-
components: {BInputGroupAddon},
14-
props: {
15-
id: {type: String, required: false},
16-
isText: {type: Boolean, default: false},
17-
tag: {type: String, default: 'div'},
18-
},
11+
interface BInputGroupAppendProps {
12+
id?: string
13+
isText?: boolean
14+
tag?: string
15+
}
16+
17+
withDefaults(defineProps<BInputGroupAppendProps>(), {
18+
tag: 'div',
1919
})
2020
</script>

src/components/BInputGroup/BInputGroupPrepend.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
</b-input-group-addon>
55
</template>
66

7-
<script lang="ts">
8-
import {defineComponent} from 'vue'
7+
<script setup lang="ts">
8+
// import type {BInputGroupPrependProps} from '@/types/components'
99
import BInputGroupAddon from './BInputGroupAddon.vue'
1010
11-
export default defineComponent({
12-
name: 'BInputGroupPrepend',
13-
components: {BInputGroupAddon},
14-
props: {
15-
id: {type: String, required: false},
16-
isText: {type: Boolean, default: false},
17-
tag: {type: String, default: 'div'},
18-
},
11+
interface BInputGroupPrependProps {
12+
id?: string
13+
isText?: boolean
14+
tag?: string
15+
}
16+
17+
withDefaults(defineProps<BInputGroupPrependProps>(), {
18+
tag: 'div',
1919
})
2020
</script>

src/components/BInputGroup/BInputGroupText.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
</component>
55
</template>
66

7-
<script lang="ts">
8-
import {defineComponent} from 'vue'
7+
<script setup lang="ts">
8+
// import type {BInputGroupTextProps} from '@/types/components'
99
10-
export default defineComponent({
11-
name: 'BInputGroupText',
12-
props: {
13-
tag: {type: String, default: 'div'},
14-
},
10+
interface BInputGroupTextProps {
11+
tag?: string
12+
}
13+
14+
withDefaults(defineProps<BInputGroupTextProps>(), {
15+
tag: 'div',
1516
})
1617
</script>

0 commit comments

Comments
 (0)