Skip to content

Commit 737d53a

Browse files
committed
Fixing building errors
1 parent ecce2e3 commit 737d53a

File tree

6 files changed

+40
-56
lines changed

6 files changed

+40
-56
lines changed

src/components/BFormGroup/BFormGroup.vue

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<script lang="ts">
2+
import useId from '@/composables/useId'
23
import {RX_SPACE_SPLIT} from '@/constants/regex'
34
import {arrayIncludes} from '@/utils/array'
45
import {cssEscape} from '@/utils/css-escape'
56
import {attemptFocus, getAttr, isVisible, removeAttr, select, selectAll, setAttr} from '@/utils/dom'
67
import {IS_BROWSER} from '@/utils/env'
8+
import getID from '@/utils/getID'
79
import {isBoolean} from '@/utils/inspect'
10+
import {normalizeSlot} from '@/utils/normalize-slot'
811
import {stringToInteger} from '@/utils/number'
912
import {suffixPropName} from '@/utils/props'
1013
import {computed, defineComponent, h, nextTick, onMounted, ref, watch} from 'vue'
11-
import useId from '@/composables/useId'
12-
import {normalizeSlot} from '@/utils/normalize-slot'
13-
import getID from '@/utils/getID'
1414
import BCol from '../BCol.vue'
15-
import BFormValidFeedback from '../BForm/BFormValidFeedback.vue'
1615
import BFormInvalidFeedback from '../BForm/BFormInvalidFeedback.vue'
1716
import BFormRow from '../BForm/BFormRow.vue'
1817
import BFormText from '../BForm/BFormText.vue'
18+
import BFormValidFeedback from '../BForm/BFormValidFeedback.vue'
1919
2020
const INPUTS = ['input', 'select', 'textarea']
2121
// Selector for finding first input in the form group
@@ -69,20 +69,18 @@ export default defineComponent({
6969
const ariaDescribedby: string | null = null as string | null
7070
const breakPoints = ['xs', 'sm', 'md', 'lg', 'xl']
7171
72-
const getAlignClasses = (props: any, prefix: string) => {
73-
const alignClasses = breakPoints.reduce((result: string[], breakpoint) => {
72+
const getAlignClasses = (props: any, prefix: string) =>
73+
breakPoints.reduce((result: string[], breakpoint) => {
7474
const propValue: string = props[suffixPropName(breakpoint, `${prefix}Align`)] || null
7575
if (propValue) {
7676
result.push(['text', breakpoint, propValue].filter((p) => p).join('-'))
7777
}
7878
7979
return result
8080
}, [])
81-
return alignClasses
82-
}
8381
84-
const getColProps = (props: any, prefix: string) => {
85-
const colProps: any = breakPoints.reduce((result: any, breakpoint: string) => {
82+
const getColProps = (props: any, prefix: string) =>
83+
breakPoints.reduce((result: any, breakpoint: string) => {
8684
let propValue = props[suffixPropName(breakpoint, `${prefix}Cols`)]
8785
// Handle case where the prop's value is an empty string,
8886
// which represents `true`
@@ -103,8 +101,6 @@ export default defineComponent({
103101
}
104102
return result
105103
}, {})
106-
return colProps
107-
}
108104
109105
const content = ref()
110106
@@ -277,7 +273,7 @@ export default defineComponent({
277273
let $invalidFeedback = null
278274
const invalidFeedbackContent =
279275
normalizeSlot(SLOT_NAME_INVALID_FEEDBACK, {}, slots) || this.invalidFeedback
280-
const invalidFeedbackId = invalidFeedbackContent ? getID('_BV_feedback_invalid_') : null
276+
const invalidFeedbackId = invalidFeedbackContent ? getID('_BV_feedback_invalid_') : undefined
281277
282278
if (invalidFeedbackContent) {
283279
$invalidFeedback = h(
@@ -287,7 +283,6 @@ export default defineComponent({
287283
id: invalidFeedbackId,
288284
state: props.state,
289285
tooltip: props.tooltip,
290-
tabindex: invalidFeedbackContent ? '-1' : null,
291286
},
292287
{default: () => invalidFeedbackContent}
293288
)
@@ -296,7 +291,7 @@ export default defineComponent({
296291
let $validFeedback = null
297292
const validFeedbackContent =
298293
normalizeSlot(SLOT_NAME_VALID_FEEDBACK, {}, slots) || this.validFeedback
299-
const validFeedbackId = validFeedbackContent ? getID('_BV_feedback_valid_') : null
294+
const validFeedbackId = validFeedbackContent ? getID('_BV_feedback_valid_') : undefined
300295
301296
if (validFeedbackContent) {
302297
$validFeedback = h(
@@ -306,7 +301,6 @@ export default defineComponent({
306301
id: validFeedbackId,
307302
state: props.state,
308303
tooltip: props.tooltip,
309-
tabindex: validFeedbackContent ? '-1' : null,
310304
},
311305
{default: () => validFeedbackContent}
312306
// validFeedbackContent
@@ -315,13 +309,12 @@ export default defineComponent({
315309
316310
let $description = null
317311
const descriptionContent = normalizeSlot(SLOT_NAME_DESCRIPTION, {}, slots) || this.description
318-
const descriptionId = descriptionContent ? getID('_BV_description_') : null
312+
const descriptionId = descriptionContent ? getID('_BV_description_') : undefined
319313
if (descriptionContent) {
320314
$description = h(
321315
BFormText,
322316
{
323317
id: descriptionId,
324-
tabindex: '-1',
325318
},
326319
{default: () => descriptionContent}
327320
)

src/components/BNavItemDropdown.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ interface BNavItemDropdownProps {
1818
text?: string
1919
size?: Size
2020
offset?: string
21-
autoClose?: string
21+
autoClose?: boolean | 'inside' | 'outside'
2222
dark?: boolean
2323
dropleft?: boolean
2424
dropright?: boolean
2525
dropup?: boolean
26-
right?: boolean | string
26+
right?: boolean
2727
left?: boolean | string
2828
offsetParent?: boolean
2929
split?: boolean
@@ -32,7 +32,7 @@ interface BNavItemDropdownProps {
3232
}
3333
3434
withDefaults(defineProps<BNavItemDropdownProps>(), {
35-
autoClose: 'true',
35+
autoClose: true,
3636
dark: false,
3737
dropleft: false,
3838
dropright: false,

src/components/BTable/BTable.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export default defineComponent({
4444
const computedFields = computed(() => itemHelper.normaliseFields(props.fields, props.items))
4545
4646
return () => {
47-
let theadTop: VNode | null
48-
theadTop = null
47+
let theadTop: VNode | null = null
4948
if (slots['thead-top']) {
50-
theadTop = slots['thead-top']()
49+
theadTop = slots['thead-top']() as unknown as VNode
5150
}
5251
5352
let theadSub: VNode | null
5453
theadSub = null
5554
if (slots['thead-sub']) {
55+
const slotReference = slots['thead-sub'] as unknown as (arg: object) => VNode
5656
theadSub = h(
5757
'tr',
5858
@@ -63,7 +63,7 @@ export default defineComponent({
6363
scope: 'col',
6464
class: [field.class, field.thClass, field.variant ? `table-${field.variant}` : ''],
6565
},
66-
slots['thead-sub']({items: computedFields.value, ...field})
66+
slotReference({items: computedFields.value, ...field}) as unknown as VNode
6767
)
6868
)
6969
)
@@ -75,7 +75,7 @@ export default defineComponent({
7575
'tr',
7676
computedFields.value.map((field) => {
7777
const slotName = `head(${field.key})`
78-
let thContent = field.label
78+
let thContent: any = field.label
7979
8080
if (slots[slotName]) {
8181
thContent = slots[slotName]?.({
@@ -110,15 +110,15 @@ export default defineComponent({
110110
},
111111
computedFields.value.map((field) => {
112112
const slotName = `cell(${field.key})`
113-
let tdContent = tr[field.key]
113+
let tdContent = tr[field.key] as unknown as VNode
114114
115115
if (slots[slotName]) {
116116
tdContent = slots[slotName]?.({
117117
value: tr[field.key],
118118
index,
119119
item: tr,
120120
items: props.items,
121-
})
121+
}) as unknown as VNode
122122
}
123123
124124
return h(

src/components/BToast/plugin.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
1+
import type {BootstrapVueOptions, ColorVariant, ContainerPosition} from '@/types'
2+
import getID from '@/utils/getID'
13
import {
24
App,
35
ComponentPublicInstance,
46
computed,
57
ComputedRef,
6-
getCurrentInstance,
7-
h,
88
inject,
99
isReactive,
10-
nextTick,
11-
onMounted,
12-
onUpdated,
1310
Plugin,
14-
provide,
1511
reactive,
16-
ref,
1712
Ref,
18-
render,
19-
resolveComponent,
20-
shallowReactive,
2113
VNode,
22-
watch,
23-
watchEffect,
2414
} from 'vue'
2515

26-
import type {BootstrapVueOptions, ColorVariant, ContainerPosition} from '@/types'
27-
import getID from '@/utils/getID'
28-
2916
export interface ToastContent {
3017
title?: string
3118
body?: string | VNode
@@ -88,7 +75,7 @@ export class ToastInstance {
8875
if (position) {
8976
return computed<Array<Toast>>(() =>
9077
this.vm.toasts.filter((toast) => {
91-
if (toast.options.pos == position && toast.options.value) {
78+
if (toast.options.pos === position && toast.options.value) {
9279
return toast
9380
}
9481
})
@@ -100,7 +87,7 @@ export class ToastInstance {
10087

10188
remove(...forDeletion: [string]): void {
10289
this.vm.toasts = this.vm.toasts.filter((item) => {
103-
if (!forDeletion.includes(item.options.id)) {
90+
if (item.options.id && !forDeletion.includes(item.options.id)) {
10491
return item
10592
}
10693
})
@@ -137,7 +124,9 @@ export class ToastInstance {
137124
return this.show(content, {variant: 'success', ...options})
138125
}
139126

140-
hide(): void {}
127+
hide(): void {
128+
//empty...
129+
}
141130
}
142131

143132
export class ToastController {
@@ -148,7 +137,7 @@ export class ToastController {
148137
this.vms = {}
149138
}
150139

151-
// Assume Root Vm if no paramters are passed
140+
// Assume Root Vm if no parameters are passed
152141
public getOrCreateViewModel(): ToastVM
153142
public getOrCreateViewModel(vm?: ToastVM): ToastVM
154143
public getOrCreateViewModel(vm?: any): ToastVM {
@@ -190,7 +179,7 @@ export class ToastController {
190179

191180
// default global inject key to fetch the controller
192181
const injectkey = Symbol()
193-
const rootkey = 'root'
182+
const rootkey = 'root' // TODO: I guess this variable is not used in any place...
194183

195184
const defaults = {
196185
container: undefined,
@@ -205,13 +194,12 @@ export function useToast(
205194
): ToastInstance | undefined
206195

207196
export function useToast(vm?: any, key: symbol = injectkey): ToastInstance | undefined {
208-
//lets get our controller to fetch the toast instance
197+
//let's get our controller to fetch the toast instance
209198
const controller = inject(key !== null ? key : injectkey) as ToastController
210199

211-
// not paramters passed, use root if defined
200+
// not parameters passed, use root if defined
212201
if (!vm) {
213-
const local_vm = new ToastInstance(controller.getOrCreateViewModel())
214-
return local_vm
202+
return new ToastInstance(controller.getOrCreateViewModel())
215203
}
216204

217205
// use toast generically

src/utils/bvEvent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export class BvEvent {
2222
}
2323

2424
// Merge defaults first, the eventInit, and the type last
25-
// so it can't be overwritten
25+
// so, it can't be overwritten
26+
// TODO: Find a better way to avoid the original error...
27+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
28+
// @ts-ignore
2629
assign(this, BvEvent.Defaults, this.constructor.Defaults, eventInit, {eventType})
2730

2831
// Freeze some props as readonly, but leave them enumerable

src/utils/normalize-slot.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import {VNode} from '@vue/runtime-core'
12
import {Slots} from 'vue'
23
import {isFunction} from './inspect'
34

4-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5-
export const normalizeSlot = (name: string, scope = {}, $slots: Slots = {}) => {
5+
export const normalizeSlot = (name: string, scope = {}, $slots: Slots = {}): VNode => {
66
// Ensure names is an array
77
const names = [name]
88
let slot
@@ -11,5 +11,5 @@ export const normalizeSlot = (name: string, scope = {}, $slots: Slots = {}) => {
1111
slot = $slots[name]
1212
}
1313
// Note: in Vue 3.x, slots have been unified. No more scoped slots and all slots are exposed as functions
14-
return slot && isFunction(slot) ? slot(scope) : slot
14+
return (slot && isFunction(slot) ? slot(scope) : slot) as unknown as VNode
1515
}

0 commit comments

Comments
 (0)