Skip to content

Commit 8190137

Browse files
authored
Merge pull request #751 from VividLemon/main
Various fixes and improvements
2 parents bef53c1 + 1f64a11 commit 8190137

File tree

113 files changed

+1899
-1644
lines changed

Some content is hidden

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

113 files changed

+1899
-1644
lines changed

apps/docs/docs/.vuepress/PluginComponentReference/client/components/component-doc.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
</div>
144144
</template>
145145
<script lang="ts">
146-
import {resolveComponent, defineComponent, computed, ComputedRef, ConcreteComponent, ref, Ref} from 'vue'
146+
import {resolveComponent, defineComponent, computed, ConcreteComponent, ref, Ref} from 'vue'
147147
import AnchoredHeading from './anchored-heading'
148148
import {hyphenate} from '../../../utils'
149149
// type definitions
@@ -191,15 +191,15 @@ export default defineComponent({
191191
props.component as string
192192
) as ConcreteComponent
193193
194-
const componentPropsMetaObj: ComputedRef<any> = computed(() => {
194+
const componentPropsMetaObj = computed(() => {
195195
return props.propsMeta.reduce((obj, propMeta) => {
196196
if (propMeta.prop) {
197197
obj[propMeta.prop] = propMeta
198198
}
199199
return obj
200200
}, {})
201201
})
202-
const githubURL: ComputedRef<string> = computed(() => {
202+
const githubURL = computed(() => {
203203
const name = component.name ?? component.__name ?? ''
204204
if (name.indexOf('{') !== -1) {
205205
// Example component (most likely an auto generated component)
@@ -213,14 +213,14 @@ export default defineComponent({
213213
214214
// component name kebab
215215
216-
const componentName: ComputedRef<string> = computed(() => {
216+
const componentName = computed(() => {
217217
return hyphenate(component.name ?? component.__name ?? '')
218218
})
219-
const tag: ComputedRef<string> = computed(() => {
219+
const tag = computed(() => {
220220
return `<${componentName.value}>`
221221
})
222222
223-
const propsItems: ComputedRef<any> = computed(() => {
223+
const propsItems = computed(() => {
224224
const props: any = component.props
225225
const propsMetaObj = componentPropsMetaObj
226226
return Object.keys(props)
@@ -280,7 +280,7 @@ export default defineComponent({
280280
})
281281
})
282282
283-
const propFields: ComputedRef<any> = computed(() => {
283+
const propFields = computed(() => {
284284
const sortable = propsItems.value.length >= SORT_THRESHOLD
285285
286286
// TODO define Type for propItems
@@ -296,7 +296,7 @@ export default defineComponent({
296296
]
297297
})
298298
299-
const emitsFields: ComputedRef<any> = computed(() => {
299+
const emitsFields = computed(() => {
300300
const sortable = component.emits?.length >= SORT_THRESHOLD
301301
return [
302302
{key: 'emit', label: 'Emit', sortable},
@@ -305,7 +305,7 @@ export default defineComponent({
305305
]
306306
})
307307
308-
const slotsFields: ComputedRef<any> = computed(() => {
308+
const slotsFields = computed(() => {
309309
const sortable = props.slots.length >= SORT_THRESHOLD
310310
const hasScopedSlots = props.slots.some(s => s.scope)
311311
return [
@@ -315,18 +315,18 @@ export default defineComponent({
315315
]
316316
})
317317
318-
const slotsItems: Ref<any[]> = ref(
318+
const slotsItems = ref(
319319
props.slots ? props.slots.map(slot => ({ ...slot as any})) : []
320320
)
321321
322322
323-
const vmodelItems: ComputedRef<any> = computed(() => {
323+
const vmodelItems = computed(() => {
324324
//TODO loop through props and emits to determine v-model
325325
// let match = VMODEL_REGEX.exec(myString);
326326
return []
327327
})
328328
329-
const vmodelFields: ComputedRef<any> = computed(() => {
329+
const vmodelFields = computed(() => {
330330
//TODO loop
331331
return []
332332
})

apps/docs/docs/.vuepress/components/DocReference.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
reference
55
</h2>
66

7-
<template v-for="component in reference.meta.components">
7+
<template v-for="(component, index) in reference.meta.components" :key="index">
88
<h3 :id="component.component" tabindex="-1">
99
<a class="header-anchor" :href="`#${component.component}`" aria-hidden="true">#</a>
1010
<code>&lt;{{ component.component }}&gt;</code>
@@ -25,7 +25,7 @@
2525
</tr>
2626
</thead>
2727
<tbody>
28-
<tr v-for="prop in component.props">
28+
<tr v-for="(prop, index) in component.props" :key="index">
2929
<td class="text-nowrap">
3030
<code>{{ prop.prop }}</code>
3131
</td>
@@ -60,7 +60,7 @@
6060
</tr>
6161
</thead>
6262
<tbody>
63-
<tr v-for="event in component.events">
63+
<tr v-for="(event, index) in component.events" :key="index">
6464
<td class="text-nowrap">
6565
<code>{{ event.event }}</code>
6666
</td>
@@ -83,7 +83,7 @@
8383
</tr>
8484
</thead>
8585
<tbody>
86-
<tr v-for="slot in component.slots">
86+
<tr v-for="(slot, index) in component.slots" :key="index">
8787
<td class="text-nowrap">
8888
<code>{{ slot.name }}</code>
8989
</td>

apps/docs/docs/components/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ BootstrapVue 3 components
44

55
<ClientOnly>
66
<b-list-group>
7-
<b-list-group-item v-for="(component, key) in componentList">
7+
<b-list-group-item v-for="(component, key) in componentList" :key="key">
88
<RouterLink :to="`./${key}.html`">{{component.name}}</RouterLink>
99
<b-badge v-if="component.status=='todo'" variant="warning" pill>TODO</b-badge>
1010
<b-badge v-else-if="component.status=='wip'" variant="warning" pill>WIP</b-badge>

apps/playground/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
"vue-router": "4.1.3"
1717
},
1818
"devDependencies": {
19-
"tsconfig": "workspace:*",
2019
"@vitejs/plugin-vue": "^3.0.0",
20+
"rollup-plugin-visualizer": "^5.7.1",
21+
"tsconfig": "workspace:*",
2122
"typescript": "^4.6.4",
2223
"vite": "^3.0.0",
2324
"vue-tsc": "^0.38.4"

apps/playground/src/components/Comps/TPagination.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const paginationPageNumber = ref(19)
125125
const paginationLimit = ref(8)
126126
const paginationPerPage = ref(2)
127127
const paginationRows = ref(40)
128-
const paginationDangerClasses = ref(['border-danger', 'border-5', 'border'])
128+
const paginationDangerClasses = ['border-danger', 'border-5', 'border']
129129
130130
const handlePaginationPageClick = (event: BvEvent, page: number) => {
131131
if (page === 7) {

packages/bootstrap-vue-3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@vue/test-utils": "^2.0.2",
4949
"bootstrap": "^5.2.0",
5050
"c8": "^7.12.0",
51+
"happy-dom": "^7.5.12",
5152
"jsdom": "^20.0.0",
5253
"rollup": "^2.78.1",
5354
"rollup-plugin-visualizer": "^5.7.1",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :id="computedId" class="accordion" :class="classes">
2+
<div :id="computedId" class="accordion" :class="computedClasses">
33
<slot />
44
</div>
55
</template>
@@ -27,12 +27,12 @@ const computedId = useId(toRef(props, 'id'), 'accordion')
2727
const flushBoolean = useBooleanish(toRef(props, 'flush'))
2828
const freeBoolean = useBooleanish(toRef(props, 'free'))
2929
30-
const classes = computed(() => ({
30+
const computedClasses = computed(() => ({
3131
'accordion-flush': flushBoolean.value,
3232
}))
3333
3434
if (!freeBoolean.value) {
35-
provide(injectionKey, computedId.value.toString())
35+
provide(injectionKey, computedId.value)
3636
}
3737
</script>
3838

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<b-collapse
1818
:id="computedId"
1919
class="accordion-collapse"
20-
:visible="visibleBoolean"
20+
:visible="visible"
2121
:accordion="parent"
2222
:aria-labelledby="`heading${computedId}`"
2323
>
@@ -45,8 +45,9 @@ interface BAccordionItemProps {
4545
4646
const props = withDefaults(defineProps<BAccordionItemProps>(), {visible: false})
4747
48-
const visibleBoolean = useBooleanish(toRef(props, 'visible'))
48+
const parent = inject<string>(injectionKey, '')
4949
5050
const computedId = useId(toRef(props, 'id'), 'accordion_item')
51-
const parent = inject(injectionKey, '')
51+
52+
const visibleBoolean = useBooleanish(toRef(props, 'visible'))
5253
</script>

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

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<div v-if="isAlertVisible" ref="element" class="alert" role="alert" :class="classes">
2+
<div v-if="isAlertVisible" ref="element" class="alert" role="alert" :class="computedClasses">
33
<slot />
44
<template v-if="dismissibleBoolean">
5-
<button v-if="$slots.close" type="button" data-bs-dismiss="alert" @click="closeClicked">
5+
<button v-if="hasCloseSlot" type="button" data-bs-dismiss="alert" @click="closeClicked">
66
<slot name="close" />
77
</button>
88
<b-close-button
@@ -18,9 +18,9 @@
1818
<script setup lang="ts">
1919
// import type {BAlertEmits, BAlertProps} from '../types/components'
2020
import type {Booleanish, ColorVariant} from '../types'
21-
import {computed, onBeforeUnmount, ref, toRef, watch} from 'vue'
21+
import {computed, onBeforeUnmount, ref, toRef, useSlots, watch} from 'vue'
2222
import {Alert} from 'bootstrap'
23-
import {toInteger} from '../utils'
23+
import {isEmptySlot, toInteger} from '../utils'
2424
import {useBooleanish} from '../composables'
2525
import BCloseButton from './BButton/BCloseButton.vue'
2626
@@ -56,19 +56,28 @@ interface BAlertEmits {
5656
5757
const emit = defineEmits<BAlertEmits>()
5858
59+
const slots = useSlots()
60+
61+
let _countDownTimeout: undefined | ReturnType<typeof setTimeout>
62+
5963
const element = ref<HTMLElement | null>(null)
6064
const instance = ref<Alert>()
61-
const classes = computed(() => ({
62-
[`alert-${props.variant}`]: !!props.variant,
63-
'show': !!props.modelValue,
64-
'alert-dismissible': dismissibleBoolean.value,
65-
// TODO it seems like fade is probably used here
66-
// It seems like the issue with trying to set fade is that when using transitions,
67-
// The element is null when it's trying to set the transition
68-
'fade': !!props.modelValue,
69-
}))
7065
71-
let _countDownTimeout: undefined | ReturnType<typeof setTimeout>
66+
const hasCloseSlot = computed<boolean>(() => !isEmptySlot(slots.close))
67+
68+
const isAlertVisible = computed<boolean>(() => !!props.modelValue || showBoolean.value)
69+
70+
const computedClasses = computed(() => [
71+
[`alert-${props.variant}`],
72+
{
73+
'show': !!props.modelValue,
74+
'alert-dismissible': dismissibleBoolean.value,
75+
// TODO it seems like fade is probably used here
76+
// It seems like the issue with trying to set fade is that when using transitions,
77+
// The element is null when it's trying to set the transition
78+
'fade': !!props.modelValue,
79+
},
80+
])
7281
7382
const parseCountDown = (value: boolean | number): number => {
7483
if (typeof value === 'boolean') {
@@ -79,20 +88,7 @@ const parseCountDown = (value: boolean | number): number => {
7988
return numberValue > 0 ? numberValue : 0
8089
}
8190
82-
const clearCountDownInterval = (): void => {
83-
if (_countDownTimeout === undefined) return
84-
clearTimeout(_countDownTimeout)
85-
_countDownTimeout = undefined
86-
}
87-
8891
const countDown = ref<number>(parseCountDown(props.modelValue))
89-
const isAlertVisible = computed<boolean>(() => !!props.modelValue || showBoolean.value)
90-
91-
onBeforeUnmount((): void => {
92-
clearCountDownInterval()
93-
instance.value?.dispose()
94-
instance.value = undefined
95-
})
9692
9793
const parsedModelValue = computed<boolean>(() => {
9894
if (props.modelValue === true) {
@@ -107,6 +103,12 @@ const parsedModelValue = computed<boolean>(() => {
107103
return !!props.modelValue
108104
})
109105
106+
const clearCountDownInterval = (): void => {
107+
if (_countDownTimeout === undefined) return
108+
clearTimeout(_countDownTimeout)
109+
_countDownTimeout = undefined
110+
}
111+
110112
const handleShowAndModelChanged = (): void => {
111113
countDown.value = parseCountDown(props.modelValue)
112114
if ((parsedModelValue.value || showBoolean.value) && !instance.value)
@@ -138,4 +140,10 @@ watch(countDown, (newValue) => {
138140
}, 1000)
139141
}
140142
})
143+
144+
onBeforeUnmount((): void => {
145+
clearCountDownInterval()
146+
instance.value?.dispose()
147+
instance.value = undefined
148+
})
141149
</script>

0 commit comments

Comments
 (0)