You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
887 B
28 lines
887 B
|
2 years ago
|
import { ref, inject, computed, unref } from 'vue';
|
||
|
|
import '../../utils/index.mjs';
|
||
|
|
import { isNumber } from '../../utils/types.mjs';
|
||
|
|
|
||
|
|
const zIndex = ref(0);
|
||
|
|
const defaultInitialZIndex = 2e3;
|
||
|
|
const zIndexContextKey = Symbol("zIndexContextKey");
|
||
|
|
const useZIndex = (zIndexOverrides) => {
|
||
|
|
const zIndexInjection = zIndexOverrides || inject(zIndexContextKey, void 0);
|
||
|
|
const initialZIndex = computed(() => {
|
||
|
|
const zIndexFromInjection = unref(zIndexInjection);
|
||
|
|
return isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
|
||
|
|
});
|
||
|
|
const currentZIndex = computed(() => initialZIndex.value + zIndex.value);
|
||
|
|
const nextZIndex = () => {
|
||
|
|
zIndex.value++;
|
||
|
|
return currentZIndex.value;
|
||
|
|
};
|
||
|
|
return {
|
||
|
|
initialZIndex,
|
||
|
|
currentZIndex,
|
||
|
|
nextZIndex
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
export { defaultInitialZIndex, useZIndex, zIndexContextKey };
|
||
|
|
//# sourceMappingURL=index.mjs.map
|