Skip to content

Commit ab9efb0

Browse files
authored
Merge pull request #468 from Efficy/main
Fix: Missing exposed methods using script setup
2 parents 15af694 + 96123d4 commit ab9efb0

File tree

14 files changed

+38
-66
lines changed

14 files changed

+38
-66
lines changed

src/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,11 +2091,11 @@ export default defineComponent({
20912091
tag === tag.toLowerCase() && tag.length > 2 && tag.length < 6
20922092
20932093
function onTagState(valid: string[], invalid: string[], duplicate: string[]) {
2094-
// console.log({
2095-
// valid,
2096-
// invalid,
2097-
// duplicate,
2098-
// })
2094+
console.log({
2095+
valid,
2096+
invalid,
2097+
duplicate,
2098+
})
20992099
}
21002100
21012101
return {

src/components/BAvatar/BAvatar.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ const textClasses = computed<string>(() => {
148148
return `text-${textVariant}`
149149
})
150150
151-
const iconName = computed<string | undefined>(() => {
152-
// TODO this should work with any icon font, eg icon="fa fa-cogs"
153-
if (props.icon) return props.icon
154-
if (!props.text && !props.src) return 'person-fill'
155-
return undefined
156-
})
157-
158151
const badgeStyle = computed<StyleValue>(() => {
159152
const offset = props.badgeOffset || '0px'
160153
const fontSize =
@@ -200,7 +193,6 @@ const onImgError = (e: Event): void => emit('img-error', e)
200193
</script>
201194

202195
<script lang="ts">
203-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
204196
export const computeSize = (value: any): string | null => {
205197
const calcValue = isString(value) && isNumeric(value) ? toFloat(value, 0) : value
206198
return isNumber(calcValue) ? `${calcValue}px` : calcValue || null

src/components/BDropdown/BDropdown.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,8 @@ onMounted((): void => {
196196
},
197197
})
198198
})
199+
200+
defineExpose({
201+
hide,
202+
})
199203
</script>

src/components/BFormCheckbox/BFormCheckbox.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface BFormCheckboxProps {
6060
| Record<string, unknown>
6161
| number
6262
value?: Array<unknown> | Set<unknown> | boolean | string | Record<string, unknown> | number
63-
modelValue?: Array<unknown> | Set<unknown> | boolean
63+
modelValue?: Array<unknown> | Set<unknown> | boolean | string | Record<string, unknown> | number
6464
}
6565
6666
const props = withDefaults(defineProps<BFormCheckboxProps>(), {
@@ -93,14 +93,14 @@ const input = ref<HTMLElement>(null as unknown as HTMLElement)
9393
const isFocused = ref<boolean>(false)
9494
9595
const localValue = computed({
96-
get: () => {
96+
get: (): unknown[] | Set<unknown> | boolean | undefined => {
9797
if (props.uncheckedValue) {
9898
if (!Array.isArray(props.modelValue)) {
9999
return props.modelValue === props.value
100100
}
101101
return props.modelValue.indexOf(props.value) > -1
102102
}
103-
return props.modelValue
103+
return props.modelValue as unknown[] | Set<unknown> | boolean | undefined
104104
},
105105
set: (newValue: any) => {
106106
let emitValue = newValue

src/components/BFormRadio/form-radio.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ describe('form-radio', () => {
795795
expect(label.classes()).toContain('btn-secondary')
796796
await input.setValue(true)
797797
//await input.trigger('click')
798-
console.log(label.classes(), wrapper.vm.modelValue)
798+
//console.log(label.classes(), wrapper.vm.modelValue)
799799
expect(label.classes().length).toEqual(3)
800800
expect(label.classes()).toContain('active')
801801
expect(label.classes()).toContain('btn')

src/components/BFormSelect/BFormSelect.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ onActivated(handleAutofocus)
109109
// /lifecycle events
110110
111111
// computed
112+
// noinspection PointlessBooleanExpressionJS
112113
const classes = computed(() => ({
113114
'form-control': props.plain,
114115
[`form-control-${props.size}`]: props.size && props.plain,
@@ -126,14 +127,15 @@ const computedSelectSize = computed<number | undefined>(() => {
126127
})
127128
128129
const computedAriaInvalid = computed<'grammar' | 'spelling' | boolean | undefined>(() => {
129-
if (props.state === false) {
130-
return true
131-
}
132-
if (props.state === true) {
130+
// noinspection SuspiciousTypeOfGuard
131+
if (typeof props.state === 'boolean') {
132+
if (!props.state) {
133+
return true
134+
}
133135
return undefined
134136
}
135137
if (typeof props.ariaInvalid === 'boolean') {
136-
if (props.ariaInvalid === false) {
138+
if (!props.ariaInvalid) {
137139
return undefined
138140
}
139141
return props.ariaInvalid
@@ -169,4 +171,9 @@ const blur = () => {
169171
}
170172
}
171173
// /methods
174+
175+
defineExpose({
176+
blur,
177+
focus,
178+
})
172179
</script>

src/components/BFormSelect/form-select-option.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {mount} from '@vue/test-utils'
22
import BFormSelectOption from './BFormSelectOption.vue'
3-
import {describe, expect, it, vitest} from 'vitest'
3+
import {describe, expect, it} from 'vitest'
44

55
describe('form-select-option', () => {
66
it('has expected default structure', async () => {

src/components/BFormTags/form-tag.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {mount} from '@vue/test-utils'
22
import BFormTag from './BFormTag.vue'
3-
import {describe, expect, it, vitest} from 'vitest'
3+
import {describe, expect, it} from 'vitest'
44

55
describe('form-tag', () => {
66
it('has expected structure', async () => {

src/components/BLink/link.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {mount} from '@vue/test-utils'
2-
import {createContainer} from '../../../tests/utils'
2+
//import {createContainer} from '../../../tests/utils'
33
import BLink from './BLink.vue'
44
import {describe, expect, it, vitest} from 'vitest'
55

src/components/BListGroup/list-group-item.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@vue/test-utils'
22
import BListGroup from './BListGroup.vue'
33
import BListGroupItem from './BListGroupItem.vue'
4-
import {describe, expect, it, vitest} from 'vitest'
4+
import {describe, expect, it} from 'vitest'
55

66
describe('list-group > list-group-item', () => {
77
it('default should have tag div', async () => {

0 commit comments

Comments
 (0)