Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
47
VApp/node_modules/vuetify/lib/composables/stack.mjs
generated
vendored
Normal file
47
VApp/node_modules/vuetify/lib/composables/stack.mjs
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Composables
|
||||
import { useToggleScope } from "./toggleScope.mjs"; // Utilities
|
||||
import { computed, inject, onScopeDispose, provide, reactive, readonly, shallowRef, toRaw, watchEffect } from 'vue';
|
||||
import { getCurrentInstance } from "../util/index.mjs"; // Types
|
||||
const StackSymbol = Symbol.for('vuetify:stack');
|
||||
const globalStack = reactive([]);
|
||||
export function useStack(isActive, zIndex, disableGlobalStack) {
|
||||
const vm = getCurrentInstance('useStack');
|
||||
const createStackEntry = !disableGlobalStack;
|
||||
const parent = inject(StackSymbol, undefined);
|
||||
const stack = reactive({
|
||||
activeChildren: new Set()
|
||||
});
|
||||
provide(StackSymbol, stack);
|
||||
const _zIndex = shallowRef(+zIndex.value);
|
||||
useToggleScope(isActive, () => {
|
||||
const lastZIndex = globalStack.at(-1)?.[1];
|
||||
_zIndex.value = lastZIndex ? lastZIndex + 10 : +zIndex.value;
|
||||
if (createStackEntry) {
|
||||
globalStack.push([vm.uid, _zIndex.value]);
|
||||
}
|
||||
parent?.activeChildren.add(vm.uid);
|
||||
onScopeDispose(() => {
|
||||
if (createStackEntry) {
|
||||
const idx = toRaw(globalStack).findIndex(v => v[0] === vm.uid);
|
||||
globalStack.splice(idx, 1);
|
||||
}
|
||||
parent?.activeChildren.delete(vm.uid);
|
||||
});
|
||||
});
|
||||
const globalTop = shallowRef(true);
|
||||
if (createStackEntry) {
|
||||
watchEffect(() => {
|
||||
const _isTop = globalStack.at(-1)?.[0] === vm.uid;
|
||||
setTimeout(() => globalTop.value = _isTop);
|
||||
});
|
||||
}
|
||||
const localTop = computed(() => !stack.activeChildren.size);
|
||||
return {
|
||||
globalTop: readonly(globalTop),
|
||||
localTop,
|
||||
stackStyles: computed(() => ({
|
||||
zIndex: _zIndex.value
|
||||
}))
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=stack.mjs.map
|
Reference in New Issue
Block a user