types: add ListInstance type (#9159)

This commit is contained in:
neverland
2021-07-31 11:29:48 +08:00
committed by GitHub
parent 32e77d71ab
commit 1c781113bd
5 changed files with 62 additions and 20 deletions
+25 -19
View File
@@ -6,6 +6,7 @@ import {
onUpdated,
onMounted,
defineComponent,
ExtractPropTypes,
} from 'vue';
// Utils
@@ -19,30 +20,35 @@ import { useTabStatus } from '../composables/use-tab-status';
// Components
import { Loading } from '../loading';
// Types
import type { ListExpose, ListDirection } from './types';
const [name, bem, t] = createNamespace('list');
export type ListDirection = 'up' | 'down';
const props = {
error: Boolean,
loading: Boolean,
finished: Boolean,
errorText: String,
loadingText: String,
finishedText: String,
immediateCheck: truthProp,
offset: {
type: [Number, String],
default: 300,
},
direction: {
type: String as PropType<ListDirection>,
default: 'down',
},
};
export type ListProps = ExtractPropTypes<typeof props>;
export default defineComponent({
name,
props: {
error: Boolean,
loading: Boolean,
finished: Boolean,
errorText: String,
loadingText: String,
finishedText: String,
immediateCheck: truthProp,
offset: {
type: [Number, String],
default: 300,
},
direction: {
type: String as PropType<ListDirection>,
default: 'down',
},
},
props,
emits: ['load', 'update:error', 'update:loading'],
@@ -157,7 +163,7 @@ export default defineComponent({
}
});
useExpose({ check });
useExpose<ListExpose>({ check });
useEventListener('scroll', check, { target: scrollParent });