Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 60693b4

Browse files
committed
Revert "refactor: WIP script setup BLinkProps items"
This reverts commit e0a223f.
1 parent e0a223f commit 60693b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+651
-789
lines changed

packages/bootstrap-vue-next/src/components/BAccordion/BAccordion.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@ interface BAccordionProps {
1818
modelValue?: string
1919
}
2020
21-
interface BAccordionEmits {
22-
(e: 'update:modelValue', value: string): void
23-
}
24-
2521
const props = withDefaults(defineProps<BAccordionProps>(), {
2622
flush: false,
2723
free: false,
2824
id: undefined,
2925
modelValue: undefined,
3026
})
3127
32-
const emit = defineEmits<BAccordionEmits>()
28+
const emit = defineEmits<(e: 'update:modelValue', value: string) => void>()
3329
3430
defineSlots<{
3531
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/bootstrap-vue-next/src/components/BAccordion/BAccordionItem.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ interface BAccordionItemProps {
5858
isNav?: Booleanish
5959
}
6060
61-
interface BAccordionItemEmits {
62-
(e: 'show', value: BvTriggerableEvent): void
63-
(e: 'shown', value: BvTriggerableEvent): void
64-
(e: 'hide', value: BvTriggerableEvent): void
65-
(e: 'hidden', value: BvTriggerableEvent): void
66-
(e: 'hide-prevented'): void
67-
(e: 'show-prevented'): void
68-
(e: 'update:modelValue', value: boolean): void
69-
}
70-
7161
const props = withDefaults(defineProps<BAccordionItemProps>(), {
7262
headerTag: 'h2',
7363
id: undefined,
@@ -80,6 +70,16 @@ const props = withDefaults(defineProps<BAccordionItemProps>(), {
8070
visible: false,
8171
})
8272
73+
interface BAccordionItemEmits {
74+
(e: 'show', value: BvTriggerableEvent): void
75+
(e: 'shown', value: BvTriggerableEvent): void
76+
(e: 'hide', value: BvTriggerableEvent): void
77+
(e: 'hidden', value: BvTriggerableEvent): void
78+
(e: 'hide-prevented'): void
79+
(e: 'show-prevented'): void
80+
(e: 'update:modelValue', value: boolean): void
81+
}
82+
8383
const emit = defineEmits<BAccordionItemEmits>()
8484
8585
defineSlots<{

packages/bootstrap-vue-next/src/components/BAlert/BAlert.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ interface BAlertProps {
5353
showOnPause?: Booleanish
5454
}
5555
56-
interface BAlertEmits {
57-
(e: 'closed'): void
58-
(e: 'close-countdown', value: number): void
59-
(e: 'update:modelValue', value: boolean | number): void
60-
}
61-
6256
const props = withDefaults(defineProps<BAlertProps>(), {
6357
closeContent: undefined,
6458
closeVariant: 'secondary',
@@ -73,6 +67,12 @@ const props = withDefaults(defineProps<BAlertProps>(), {
7367
showOnPause: true,
7468
})
7569
70+
interface BAlertEmits {
71+
(e: 'closed'): void
72+
(e: 'close-countdown', value: number): void
73+
(e: 'update:modelValue', value: boolean | number): void
74+
}
75+
7676
const emit = defineEmits<BAlertEmits>()
7777
7878
defineSlots<{

packages/bootstrap-vue-next/src/components/BAvatar/BAvatar.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ interface BAvatarProps {
5050
variant?: ColorVariant | null
5151
}
5252
53-
interface BAvatarEmits {
54-
(e: 'click', value: MouseEvent): void
55-
(e: 'img-error', value: Event): void
56-
}
57-
5853
const props = withDefaults(defineProps<BAvatarProps>(), {
5954
ariaLabel: undefined,
6055
badgeOffset: undefined,
@@ -76,6 +71,11 @@ const props = withDefaults(defineProps<BAvatarProps>(), {
7671
variant: 'secondary',
7772
})
7873
74+
interface BAvatarEmits {
75+
(e: 'click', value: MouseEvent): void
76+
(e: 'img-error', value: Event): void
77+
}
78+
7979
const emit = defineEmits<BAvatarEmits>()
8080
8181
defineSlots<{

packages/bootstrap-vue-next/src/components/BBadge/BBadge.vue

Lines changed: 49 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,84 +4,62 @@
44
</component>
55
</template>
66

7-
<script setup lang="ts">
8-
import {isLink, pluckProps} from '../../utils'
7+
<script lang="ts">
8+
import {isLink, omit, pluckProps} from '../../utils'
99
import {useBooleanish} from '../../composables'
10-
import {computed} from 'vue'
10+
import {computed, defineComponent, type PropType, type SlotsType} from 'vue'
1111
import type {Booleanish, ColorVariant} from '../../types'
12-
import BLink, {type BLinkProps} from '../BLink/BLink.vue'
12+
import BLink, {BLINK_PROPS} from '../BLink/BLink.vue'
1313
14-
defineSlots<{
15-
default?: Record<string, never>
16-
}>()
14+
const linkProps = omit(BLINK_PROPS, ['event', 'routerTag'] as const)
1715
18-
interface BBadgeProps {
19-
pill?: Booleanish
20-
tag?: string
21-
textIndicator?: Booleanish
22-
dotIndicator?: Booleanish
23-
variant?: ColorVariant | null
24-
}
16+
export default defineComponent({
17+
slots: Object as SlotsType<{
18+
default?: Record<string, never>
19+
}>,
20+
components: {BLink},
21+
props: {
22+
...linkProps,
23+
pill: {type: [Boolean, String] as PropType<Booleanish>, default: false},
24+
tag: {type: String, default: 'span'},
25+
textIndicator: {type: [Boolean, String] as PropType<Booleanish>, default: false},
26+
dotIndicator: {type: [Boolean, String] as PropType<Booleanish>, default: false},
27+
variant: {type: String as PropType<ColorVariant | null>, default: 'secondary'},
28+
},
29+
setup(props) {
30+
const pillBoolean = useBooleanish(() => props.pill)
31+
const textIndicatorBoolean = useBooleanish(() => props.textIndicator)
32+
const dotIndicatorBoolean = useBooleanish(() => props.dotIndicator)
33+
const activeBoolean = useBooleanish(() => props.active)
34+
const disabledBoolean = useBooleanish(() => props.disabled)
2535
26-
const props = withDefaults(defineProps<BBadgeProps & Omit<BLinkProps, 'event' | 'routerTag'>>(), {
27-
pill: false,
28-
tag: 'span',
29-
textIndicator: false,
30-
dotIndicator: false,
31-
variant: 'secondary',
32-
// Link props
33-
active: undefined,
34-
activeClass: 'router-link-active',
35-
append: false,
36-
disabled: false,
37-
href: undefined,
38-
// noPrefetch: {type: [Boolean, String] as PropType<Booleanish>, default: false},
39-
// prefetch: {type: [Boolean, String] as PropType<Booleanish>, default: null},
40-
rel: undefined,
41-
replace: false,
42-
routerComponentName: 'router-link',
43-
target: '_self',
44-
to: undefined,
45-
// End link props
46-
})
47-
48-
const pillBoolean = useBooleanish(() => props.pill)
49-
const textIndicatorBoolean = useBooleanish(() => props.textIndicator)
50-
const dotIndicatorBoolean = useBooleanish(() => props.dotIndicator)
51-
const activeBoolean = useBooleanish(() => props.active)
52-
const disabledBoolean = useBooleanish(() => props.disabled)
36+
const computedLink = computed<boolean>(() => isLink(props))
5337
54-
const computedLink = computed<boolean>(() => isLink(props))
38+
const computedTag = computed<string | typeof BLink>(() =>
39+
computedLink.value ? BLink : props.tag
40+
)
5541
56-
const computedTag = computed<string | typeof BLink>(() => (computedLink.value ? BLink : props.tag))
42+
const computedClasses = computed(() => ({
43+
[`bg-${props.variant}`]: props.variant !== null,
44+
'active': activeBoolean.value,
45+
'disabled': disabledBoolean.value,
46+
'text-dark': props.variant !== null && ['warning', 'info', 'light'].includes(props.variant),
47+
'rounded-pill': pillBoolean.value,
48+
'position-absolute top-0 start-100 translate-middle':
49+
textIndicatorBoolean.value || dotIndicatorBoolean.value,
50+
'p-2 border border-light rounded-circle': dotIndicatorBoolean.value,
51+
'text-decoration-none': computedLink.value,
52+
}))
5753
58-
const computedClasses = computed(() => ({
59-
[`bg-${props.variant}`]: props.variant !== null,
60-
'active': activeBoolean.value,
61-
'disabled': disabledBoolean.value,
62-
'text-dark': props.variant !== null && ['warning', 'info', 'light'].includes(props.variant),
63-
'rounded-pill': pillBoolean.value,
64-
'position-absolute top-0 start-100 translate-middle':
65-
textIndicatorBoolean.value || dotIndicatorBoolean.value,
66-
'p-2 border border-light rounded-circle': dotIndicatorBoolean.value,
67-
'text-decoration-none': computedLink.value,
68-
}))
54+
const computedLinkProps = computed(() =>
55+
computedLink.value ? pluckProps(props, linkProps) : {}
56+
)
6957
70-
const computedLinkProps = computed(() =>
71-
computedLink.value
72-
? pluckProps(props, {
73-
active: true,
74-
activeClass: true,
75-
append: true,
76-
disabled: true,
77-
href: true,
78-
rel: true,
79-
replace: true,
80-
routerComponentName: true,
81-
target: true,
82-
to: true,
83-
variant: true,
84-
} as Record<keyof Omit<BLinkProps, 'event' | 'routerTag'>, true>)
85-
: {}
86-
)
58+
return {
59+
computedClasses,
60+
computedLinkProps,
61+
computedTag,
62+
}
63+
},
64+
})
8765
</script>

packages/bootstrap-vue-next/src/components/BBreadcrumb/BBreadcrumbItem.vue

Lines changed: 50 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -13,90 +13,64 @@
1313
</li>
1414
</template>
1515

16-
<script setup lang="ts">
17-
import {pluckProps} from '../../utils'
16+
<script lang="ts">
17+
import {omit, pluckProps} from '../../utils'
1818
import {useBooleanish} from '../../composables'
19-
import {computed} from 'vue'
20-
import BLink, {type BLinkProps} from '../BLink/BLink.vue'
19+
import {computed, defineComponent, type PropType, type SlotsType} from 'vue'
20+
import BLink, {BLINK_PROPS} from '../BLink/BLink.vue'
2121
import type {Booleanish} from '../../types'
2222
23-
defineSlots<{
24-
default?: Record<string, never>
25-
}>()
23+
const linkProps = omit(BLINK_PROPS, ['event', 'routerTag'] as const)
2624
27-
interface BBreadcrumbItemProps {
28-
active?: Booleanish
29-
ariaCurrent?: string
30-
disabled?: Booleanish
31-
text?: string
32-
}
25+
export default defineComponent({
26+
slots: Object as SlotsType<{
27+
default?: Record<string, never>
28+
}>,
29+
components: {BLink},
30+
props: {
31+
...linkProps,
32+
active: {type: [Boolean, String] as PropType<Booleanish>, default: false},
33+
ariaCurrent: {type: String, default: 'location'},
34+
disabled: {type: [Boolean, String] as PropType<Booleanish>, default: false},
35+
text: {type: String, default: undefined},
36+
},
37+
emits: ['click'],
38+
setup(props, {emit}) {
39+
const activeBoolean = useBooleanish(() => props.active)
40+
const disabledBoolean = useBooleanish(() => props.disabled)
3341
34-
interface BBreadcrumbItemEmits {
35-
(e: 'click', value: MouseEvent): void
36-
}
42+
const computedClasses = computed(() => ({
43+
active: activeBoolean.value,
44+
}))
3745
38-
const props = withDefaults(
39-
defineProps<BBreadcrumbItemProps & Omit<BLinkProps, 'event' | 'routerTag'>>(),
40-
{
41-
active: false,
42-
ariaCurrent: 'location',
43-
text: undefined,
44-
// Link props
45-
activeClass: 'router-link-active',
46-
append: false,
47-
disabled: false,
48-
event: 'click',
49-
href: undefined,
50-
// noPrefetch: {type: [Boolean, String] as PropType<Booleanish>, default: false},
51-
// prefetch: {type: [Boolean, String] as PropType<Booleanish>, default: null},
52-
rel: undefined,
53-
replace: false,
54-
routerComponentName: 'router-link',
55-
routerTag: 'a',
56-
target: '_self',
57-
to: undefined,
58-
variant: undefined,
59-
// End link props
60-
}
61-
)
46+
const computedTag = computed<'span' | typeof BLink>(() =>
47+
activeBoolean.value ? 'span' : BLink
48+
)
6249
63-
const emit = defineEmits<BBreadcrumbItemEmits>()
50+
const computedAriaCurrent = computed(() =>
51+
activeBoolean.value ? props.ariaCurrent : undefined
52+
)
6453
65-
const activeBoolean = useBooleanish(() => props.active)
66-
const disabledBoolean = useBooleanish(() => props.disabled)
54+
const computedLinkProps = computed(() =>
55+
computedTag.value !== 'span' ? pluckProps(props, linkProps) : {}
56+
)
6757
68-
const computedClasses = computed(() => ({
69-
active: activeBoolean.value,
70-
}))
58+
const clicked = (e: MouseEvent): void => {
59+
if (disabledBoolean.value || activeBoolean.value) {
60+
e.preventDefault()
61+
e.stopImmediatePropagation()
62+
return
63+
}
64+
if (!disabledBoolean.value) emit('click', e)
65+
}
7166
72-
const computedTag = computed<'span' | typeof BLink>(() => (activeBoolean.value ? 'span' : BLink))
73-
74-
const computedAriaCurrent = computed(() => (activeBoolean.value ? props.ariaCurrent : undefined))
75-
76-
const computedLinkProps = computed(() =>
77-
computedTag.value !== 'span'
78-
? pluckProps(props, {
79-
active: true,
80-
activeClass: true,
81-
append: true,
82-
disabled: true,
83-
href: true,
84-
rel: true,
85-
replace: true,
86-
routerComponentName: true,
87-
target: true,
88-
to: true,
89-
variant: true,
90-
} as Record<keyof Omit<BLinkProps, 'event' | 'routerTag'>, true>)
91-
: {}
92-
)
93-
94-
const clicked = (e: MouseEvent): void => {
95-
if (disabledBoolean.value || activeBoolean.value) {
96-
e.preventDefault()
97-
e.stopImmediatePropagation()
98-
return
99-
}
100-
if (!disabledBoolean.value) emit('click', e)
101-
}
67+
return {
68+
computedLinkProps,
69+
computedClasses,
70+
computedTag,
71+
computedAriaCurrent,
72+
clicked,
73+
}
74+
},
75+
})
10276
</script>

0 commit comments

Comments
 (0)