init
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export * from "./public";
|
||||
export * from "./select";
|
||||
export * from "./form";
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
import { inject, computed, isRef, provide, reactive } from "vue";
|
||||
const LevelInjectionKey = Symbol("menuLevelKey");
|
||||
function provideLevel(level) {
|
||||
const computedLevel = computed(() => isRef(level) ? level.value : level);
|
||||
provide(LevelInjectionKey, reactive({
|
||||
level: computedLevel
|
||||
}));
|
||||
}
|
||||
function useLevel(props) {
|
||||
const { provideNextLevel } = props || {};
|
||||
const levelContext = inject(LevelInjectionKey);
|
||||
const level = computed(() => levelContext.level || 1);
|
||||
if (provideNextLevel) {
|
||||
const nextLevel = computed(() => level.value + 1);
|
||||
provideLevel(nextLevel);
|
||||
}
|
||||
return {
|
||||
level
|
||||
};
|
||||
}
|
||||
export { provideLevel as p, useLevel as u };
|
||||
Reference in New Issue
Block a user