Skip to content

Commit 75cf264

Browse files
authored
refactor: tabs & card (#4732)
* refactor: tabs * refactor: tabs * fix: tabs hotreload error * refactor: rename useRef * feat: add leftExtra rightExtra * refactor: tabs * test: update tabs test * refactor: card * doc: update tabs demo * refactor: add card style * style: update vue dep
1 parent 022a3ce commit 75cf264

Some content is hidden

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

88 files changed

+3744
-3267
lines changed

components/_util/hooks/useRef.ts

-17
This file was deleted.

components/_util/hooks/useRefs.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Ref, ComponentPublicInstance } from 'vue';
2+
import { onBeforeUpdate, ref } from 'vue';
3+
import type { Key } from '../type';
4+
5+
type RefType = HTMLElement | ComponentPublicInstance;
6+
export type RefsValue = Map<Key, RefType>;
7+
type UseRef = [(key: Key) => (el: RefType) => void, Ref<RefsValue>];
8+
const useRefs = (): UseRef => {
9+
const refs = ref<RefsValue>(new Map());
10+
11+
const setRef = (key: Key) => (el: RefType) => {
12+
refs.value.set(key, el);
13+
};
14+
onBeforeUpdate(() => {
15+
refs.value = new Map();
16+
});
17+
return [setRef, refs];
18+
};
19+
20+
export default useRefs;

components/_util/hooks/useState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Ref } from 'vue';
22
import { ref } from 'vue';
33

44
export default function useState<T, R = Ref<T>>(
5-
defaultStateValue: T | (() => T),
5+
defaultStateValue?: T | (() => T),
66
): [R, (val: T) => void] {
77
const initValue: T =
88
typeof defaultStateValue === 'function' ? (defaultStateValue as any)() : defaultStateValue;

0 commit comments

Comments
 (0)