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

Commit 002b75a

Browse files
committed
feat\!: remove deprecated dark props. Use useColorMode composable or directive
feat: number props can now accept string | number for more versatility refactor: remove v-bind and v-on declarations where approprate -- declare them in template and remove computedAttrs syntax refactor: place static classes in templates, and not in computedClasses feat\!: standardize class props. ig labelClasses => labelClass... In addition, they have type any instead of the sometimes mix of Object or String refactor: use useStateClass where appropriate
1 parent a85b10b commit 002b75a

Some content is hidden

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

44 files changed

+359
-458
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
:horizontal="horizontal"
1212
:visible="visible"
1313
:is-nav="isNav"
14-
v-on="events"
14+
@show="$emit('show', $event)"
15+
@shown="emit('shown', $event)"
16+
@hide="emit('hide', $event)"
17+
@hidden="emit('hidden', $event)"
18+
@hide-prevented="emit('hide-prevented')"
19+
@show-prevented="emit('show-prevented')"
1520
>
1621
<template #header="{visible: toggleVisible, toggle: slotToggle}">
1722
<component :is="headerTag" :id="`${computedId}-heading`" class="accordion-header">
@@ -88,15 +93,6 @@ defineSlots<{
8893
title?: (props: Record<string, never>) => any
8994
}>()
9095
91-
const events = {
92-
'show': (e: BvTriggerableEvent) => emit('show', e),
93-
'shown': (e: BvTriggerableEvent) => emit('shown', e),
94-
'hide': (e: BvTriggerableEvent) => emit('hide', e),
95-
'hidden': (e: BvTriggerableEvent) => emit('hidden', e),
96-
'hide-prevented': () => emit('hide-prevented'),
97-
'show-prevented': () => emit('show-prevented'),
98-
}
99-
10096
const modelValue = useVModel(props, 'modelValue', emit, {passive: true})
10197
10298
const parentData = inject(accordionInjectionKey, null)

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type {Booleanish, ButtonType, ButtonVariant, ColorVariant} from '../../ty
3131
import {computed, onBeforeUnmount, ref, useSlots, watch, watchEffect} from 'vue'
3232
import {useBooleanish, useCountdown} from '../../composables'
3333
import {isEmptySlot} from '../../utils'
34-
import {useElementHover, useVModel} from '@vueuse/core'
34+
import {useElementHover, useToNumber, useVModel} from '@vueuse/core'
3535
3636
const props = withDefaults(
3737
defineProps<{
@@ -44,7 +44,7 @@ const props = withDefaults(
4444
variant?: ColorVariant | null
4545
closeContent?: string
4646
immediate?: Booleanish
47-
interval?: number
47+
interval?: number | string
4848
showOnPause?: Booleanish
4949
}>(),
5050
{
@@ -87,6 +87,7 @@ const fadeBoolean = useBooleanish(() => props.fade)
8787
const immediateBoolean = useBooleanish(() => props.immediate)
8888
const showOnPauseBoolean = useBooleanish(() => props.showOnPause)
8989
const noHoverPauseBoolean = useBooleanish(() => props.noHoverPause)
90+
const intervalNumber = useToNumber(() => props.interval)
9091
9192
const hasCloseSlot = computed(() => !isEmptySlot(slots.close))
9293
@@ -107,7 +108,7 @@ const {
107108
stop,
108109
isPaused,
109110
value: remainingMs,
110-
} = useCountdown(countdownLength, () => props.interval, {
111+
} = useCountdown(countdownLength, intervalNumber, {
111112
immediate: typeof modelValue.value === 'number' && immediateBoolean.value,
112113
})
113114
@@ -122,7 +123,9 @@ const closeAttrs = computed(() => ({
122123
type: 'button' as ButtonType,
123124
}))
124125
125-
watchEffect(() => emit('close-countdown', remainingMs.value))
126+
watchEffect(() => {
127+
emit('close-countdown', remainingMs.value)
128+
})
126129
127130
const closeClicked = (): void => {
128131
if (typeof modelValue.value === 'boolean') {

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
class="b-avatar"
55
:class="computedClasses"
66
:style="computedStyle"
7-
v-bind="computedAttrs"
7+
v-bind="computedLinkProps"
8+
:type="buttonBoolean && !computedLink ? props.buttonType : undefined"
9+
:disabled="disabledBoolean || null"
810
@click="clicked"
911
>
1012
<span v-if="hasDefaultSlot" class="b-avatar-custom">
@@ -26,16 +28,21 @@
2628
<script setup lang="ts">
2729
import {avatarGroupInjectionKey, isEmptySlot, isLink, isNumeric, pick, toFloat} from '../../utils'
2830
import {computed, type CSSProperties, inject, type StyleValue, useSlots} from 'vue'
29-
import type {Booleanish, ButtonType, ColorVariant, Size, TextColorVariant} from '../../types'
31+
import type {
32+
BLinkProps,
33+
Booleanish,
34+
ButtonType,
35+
ColorVariant,
36+
Size,
37+
TextColorVariant,
38+
} from '../../types'
3039
import {useBooleanish} from '../../composables'
3140
import BLink from '../BLink/BLink.vue'
32-
import type {BLinkProps} from '../../types/BLinkProps'
3341
3442
const props = withDefaults(
3543
defineProps<
3644
{
3745
alt?: string
38-
ariaLabel?: string
3946
badge?: boolean | string
4047
badgeLeft?: Booleanish
4148
badgeOffset?: string
@@ -55,7 +62,6 @@ const props = withDefaults(
5562
} & Omit<BLinkProps, 'event' | 'routerTag'>
5663
>(),
5764
{
58-
ariaLabel: undefined,
5965
badgeOffset: undefined,
6066
icon: undefined,
6167
size: undefined,
@@ -138,12 +144,8 @@ const computedVariant = computed<ColorVariant | null>(
138144
139145
const computedRounded = computed<string | boolean>(() => parentData?.rounded.value ?? props.rounded)
140146
141-
const computedAttrs = computed(() => ({
142-
'type': buttonBoolean.value && !computedLink.value ? props.buttonType : undefined,
143-
'aria-label': props.ariaLabel || null,
144-
'disabled': disabledBoolean.value || null,
145-
// Link props
146-
...(computedLink.value
147+
const computedLinkProps = computed(() =>
148+
computedLink.value
147149
? pick(props, [
148150
'active',
149151
'activeClass',
@@ -163,8 +165,8 @@ const computedAttrs = computed(() => ({
163165
'underlineOpacity',
164166
'underlineOpacityHover',
165167
])
166-
: {}),
167-
}))
168+
: {}
169+
)
168170
169171
const badgeClasses = computed(() => ({
170172
[`bg-${props.badgeVariant}`]: props.badgeVariant !== null,
@@ -249,7 +251,9 @@ const clicked = (e: MouseEvent): void => {
249251
if (!disabledBoolean.value && (computedLink.value || buttonBoolean.value)) emit('click', e)
250252
}
251253
252-
const onImgError = (e: Event): void => emit('img-error', e)
254+
const onImgError = (e: Event) => {
255+
emit('img-error', e)
256+
}
253257
</script>
254258

255259
<script lang="ts">

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<script setup lang="ts">
1010
import {computed, provide, readonly, type StyleValue, toRef} from 'vue'
1111
import type {Booleanish, ColorVariant, Size} from '../../types'
12-
import {avatarGroupInjectionKey, isNumeric, toFloat} from '../../utils'
12+
import {avatarGroupInjectionKey} from '../../utils'
1313
import {useBooleanish} from '../../composables'
1414
import {computeSize} from './BAvatar.vue'
15+
import {useToNumber} from '@vueuse/shared'
1516
1617
const props = withDefaults(
1718
defineProps<{
@@ -40,19 +41,15 @@ defineSlots<{
4041
const squareBoolean = useBooleanish(() => props.square)
4142
4243
const computedSize = computed<string | null>(() => computeSize(props.size))
44+
const overlapNumber = useToNumber(() => props.overlap)
4345
44-
const overlapScale = computed<number>(
45-
() => Math.min(Math.max(computeOverlap(props.overlap), 0), 1) / 2
46-
)
46+
const overlapScale = computed<number>(() => Math.min(Math.max(overlapNumber.value, 0), 1) / 2)
4747
4848
const paddingStyle = computed<StyleValue>(() => {
4949
const value = computedSize.value ? `calc(${computedSize.value} * ${overlapScale.value})` : null
5050
return value ? {paddingLeft: value, paddingRight: value} : {}
5151
})
5252
53-
const computeOverlap = (value: any): number =>
54-
typeof value === 'string' && isNumeric(value) ? toFloat(value, 0) : value || 0
55-
5653
provide(avatarGroupInjectionKey, {
5754
overlapScale,
5855
size: readonly(toRef(props, 'size')),

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import {isLink, pick} from '../../utils'
99
import {useBooleanish} from '../../composables'
1010
import {computed} from 'vue'
11-
import type {Booleanish} from '../../types'
11+
import type {BLinkProps, Booleanish} from '../../types'
1212
import BLink from '../BLink/BLink.vue'
13-
import type {BLinkProps} from '../../types/BLinkProps'
1413
1514
defineSlots<{
1615
// eslint-disable-next-line @typescript-eslint/no-explicit-any

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {pick} from '../../utils'
1818
import {useBooleanish} from '../../composables'
1919
import {computed} from 'vue'
2020
import BLink from '../BLink/BLink.vue'
21-
import type {BLinkProps} from '../../types/BLinkProps'
21+
import type {BLinkProps} from '../../types'
2222
2323
defineSlots<{
2424
// eslint-disable-next-line @typescript-eslint/no-explicit-any

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

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33
:is="computedTag"
44
class="btn"
55
:class="computedClasses"
6-
v-bind="computedAttrs"
6+
:aria-disabled="nonStandardTag ? disabledBoolean : null"
7+
:aria-pressed="isToggle ? pressedBoolean : null"
8+
:autocomplete="isToggle ? 'off' : null"
9+
:disabled="isButton ? disabledBoolean : null"
10+
:href="props.href"
11+
:rel="computedLink ? props.rel : null"
12+
:role="nonStandardTag || computedLink ? 'button' : null"
13+
:target="computedLink ? props.target : null"
14+
:type="isButton ? props.type : null"
15+
:to="!isButton ? props.to : null"
16+
:append="computedLink ? props.append : null"
17+
:active-class="isBLink ? activeClass : null"
18+
:event="isBLink ? event : null"
19+
:replace="isBLink ? replace : null"
20+
:router-component-name="isBLink ? routerComponentName : null"
21+
:router-tag="isBLink ? routerTag : null"
722
@click="clicked"
823
>
924
<div
@@ -28,11 +43,10 @@
2843
import {computed} from 'vue'
2944
import BSpinner from '../BSpinner.vue'
3045
import {useBooleanish} from '../../composables'
31-
import type {Booleanish, ButtonType, ButtonVariant, Size} from '../../types'
46+
import type {BLinkProps, Booleanish, ButtonType, ButtonVariant, Size} from '../../types'
3247
import {isLink} from '../../utils'
3348
import BLink from '../BLink/BLink.vue'
3449
import {useVModel} from '@vueuse/core'
35-
import type {BLinkProps} from '../../types/BLinkProps'
3650
3751
defineSlots<{
3852
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -129,25 +143,6 @@ const computedClasses = computed(() => [
129143
},
130144
])
131145
132-
const computedAttrs = computed(() => ({
133-
'aria-disabled': nonStandardTag.value ? disabledBoolean.value : null,
134-
'aria-pressed': isToggle.value ? pressedBoolean.value : null,
135-
'autocomplete': isToggle.value ? 'off' : null,
136-
'disabled': isButton.value ? disabledBoolean.value : null,
137-
'href': props.href,
138-
'rel': computedLink.value ? props.rel : null,
139-
'role': nonStandardTag.value || computedLink.value ? 'button' : null,
140-
'target': computedLink.value ? props.target : null,
141-
'type': isButton.value ? props.type : null,
142-
'to': !isButton.value ? props.to : null,
143-
'append': computedLink.value ? props.append : null,
144-
'activeClass': isBLink.value ? props.activeClass : null,
145-
'event': isBLink.value ? props.event : null,
146-
'replace': isBLink.value ? props.replace : null,
147-
'routerComponentName': isBLink.value ? props.routerComponentName : null,
148-
'routerTag': isBLink.value ? props.routerTag : null,
149-
}))
150-
151146
const computedTag = computed<string | typeof BLink>(() =>
152147
isBLink.value ? BLink : props.href ? 'a' : props.tag
153148
)

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

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,30 @@
55
</slot>
66
<BCardHeader
77
v-if="header || hasHeaderSlot || headerHtml"
8-
v-bind="headerAttrs"
8+
:bg-variant="headerBgVariant"
9+
:border-variant="headerBorderVariant"
10+
:html="headerHtml"
11+
:tag="headerTag"
12+
:text-variant="headerTextVariant"
913
:class="headerClass"
1014
>
1115
<slot name="header">
1216
{{ header }}
1317
</slot>
1418
</BCardHeader>
15-
<BCardBody v-if="!noBodyBoolean" v-bind="bodyAttrs" :class="bodyClass">
19+
<BCardBody
20+
v-if="!noBodyBoolean"
21+
:overlay="overlay"
22+
:body-bg-variant="bodyBgVariant"
23+
:body-tag="bodyTag"
24+
:body-text-variant="bodyTextVariant"
25+
:subtitle="subtitle"
26+
:subtitle-tag="subtitleTag"
27+
:subtitle-text-variant="subtitleTextVariant"
28+
:title="title"
29+
:title-tag="titleTag"
30+
:class="bodyClass"
31+
>
1632
<slot>
1733
{{ bodyText }}
1834
</slot>
@@ -22,7 +38,11 @@
2238
</slot>
2339
<BCardFooter
2440
v-if="footer || hasFooterSlot || footerHtml"
25-
v-bind="footerAttrs"
41+
:bg-variant="footerBgVariant"
42+
:border-variant="footerBorderVariant"
43+
:html="footerHtml"
44+
:tag="footerTag"
45+
:text-variant="footerTextVariant"
2646
:class="footerClass"
2747
>
2848
<slot name="footer">
@@ -166,34 +186,6 @@ const computedClasses = computed(() => ({
166186
'flex-row-reverse': imgEndBoolean.value,
167187
}))
168188
169-
const headerAttrs = computed(() => ({
170-
bgVariant: props.headerBgVariant,
171-
borderVariant: props.headerBorderVariant,
172-
html: props.headerHtml,
173-
tag: props.headerTag,
174-
textVariant: props.headerTextVariant,
175-
}))
176-
177-
const bodyAttrs = computed(() => ({
178-
overlay: props.overlay,
179-
bodyBgVariant: props.bodyBgVariant,
180-
bodyTag: props.bodyTag,
181-
bodyTextVariant: props.bodyTextVariant,
182-
subtitle: props.subtitle,
183-
subtitleTag: props.subtitleTag,
184-
subtitleTextVariant: props.subtitleTextVariant,
185-
title: props.title,
186-
titleTag: props.titleTag,
187-
}))
188-
189-
const footerAttrs = computed(() => ({
190-
bgVariant: props.footerBgVariant,
191-
borderVariant: props.footerBorderVariant,
192-
html: props.footerHtml,
193-
tag: props.footerTag,
194-
textVariant: props.footerTextVariant,
195-
}))
196-
197189
const imgAttr = computed(() => ({
198190
src: props.imgSrc,
199191
alt: props.imgAlt,

packages/bootstrap-vue-next/src/components/BCard/BCardGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ const cardTypeClass = computed(() =>
3434
deckBoolean.value ? 'card-deck' : columnsBoolean.value ? 'card-columns' : 'card-group'
3535
)
3636
37-
const computedClasses = computed(() => [cardTypeClass.value])
37+
const computedClasses = computed(() => cardTypeClass.value)
3838
</script>

0 commit comments

Comments
 (0)