{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-z-index/index.ts"],"sourcesContent":["import { computed, getCurrentInstance, inject, ref, unref } from 'vue'\nimport { debugWarn, isClient, isNumber } from '@element-plus/utils'\n\nimport type { InjectionKey, Ref } from 'vue'\n\nexport interface ElZIndexInjectionContext {\n current: number\n}\n\nconst initial: ElZIndexInjectionContext = {\n current: 0,\n}\n\nconst zIndex = ref(0)\n\nexport const defaultInitialZIndex = 2000\n\n// For SSR\nexport const ZINDEX_INJECTION_KEY: InjectionKey =\n Symbol('elZIndexContextKey')\n\nexport const zIndexContextKey: InjectionKey> =\n Symbol('zIndexContextKey')\n\nexport const useZIndex = (zIndexOverrides?: Ref) => {\n const increasingInjection = getCurrentInstance()\n ? inject(ZINDEX_INJECTION_KEY, initial)\n : initial\n\n const zIndexInjection =\n zIndexOverrides ||\n (getCurrentInstance() ? inject(zIndexContextKey, undefined) : undefined)\n\n const initialZIndex = computed(() => {\n const zIndexFromInjection = unref(zIndexInjection)\n return isNumber(zIndexFromInjection)\n ? zIndexFromInjection\n : defaultInitialZIndex\n })\n\n const currentZIndex = computed(() => initialZIndex.value + zIndex.value)\n\n const nextZIndex = () => {\n increasingInjection.current++\n zIndex.value = increasingInjection.current\n return currentZIndex.value\n }\n\n if (!isClient && !inject(ZINDEX_INJECTION_KEY)) {\n debugWarn(\n 'ZIndexInjection',\n `Looks like you are using server rendering, you must provide a z-index provider to ensure the hydration process to be succeed\nusage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`\n )\n }\n\n return {\n initialZIndex,\n currentZIndex,\n nextZIndex,\n }\n}\n\nexport type UseZIndexReturn = ReturnType\n"],"names":["ref","getCurrentInstance","inject","computed","unref","isNumber","isClient","debugWarn"],"mappings":";;;;;;;;;;AAEA,MAAM,OAAO,GAAG;AAChB,EAAE,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AACF,MAAM,MAAM,GAAGA,OAAG,CAAC,CAAC,CAAC,CAAC;AACV,MAAC,oBAA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