index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  2. const require_runtime = require('../../_virtual/_rolldown/runtime.js');
  3. const require_types = require('../../utils/types.js');
  4. const require_error = require('../../utils/error.js');
  5. let vue = require("vue");
  6. let _vueuse_core = require("@vueuse/core");
  7. //#region ../../packages/hooks/use-z-index/index.ts
  8. const initial = { current: 0 };
  9. const zIndex = (0, vue.ref)(0);
  10. const defaultInitialZIndex = 2e3;
  11. const ZINDEX_INJECTION_KEY = Symbol("elZIndexContextKey");
  12. const zIndexContextKey = Symbol("zIndexContextKey");
  13. const useZIndex = (zIndexOverrides) => {
  14. const increasingInjection = (0, vue.getCurrentInstance)() ? (0, vue.inject)(ZINDEX_INJECTION_KEY, initial) : initial;
  15. const zIndexInjection = zIndexOverrides || ((0, vue.getCurrentInstance)() ? (0, vue.inject)(zIndexContextKey, void 0) : void 0);
  16. const initialZIndex = (0, vue.computed)(() => {
  17. const zIndexFromInjection = (0, vue.unref)(zIndexInjection);
  18. return require_types.isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
  19. });
  20. const currentZIndex = (0, vue.computed)(() => initialZIndex.value + zIndex.value);
  21. const nextZIndex = () => {
  22. increasingInjection.current++;
  23. zIndex.value = increasingInjection.current;
  24. return currentZIndex.value;
  25. };
  26. if (!_vueuse_core.isClient && !(0, vue.inject)(ZINDEX_INJECTION_KEY)) require_error.debugWarn("ZIndexInjection", `Looks like you are using server rendering, you must provide a z-index provider to ensure the hydration process to be succeed
  27. usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
  28. return {
  29. initialZIndex,
  30. currentZIndex,
  31. nextZIndex
  32. };
  33. };
  34. //#endregion
  35. exports.ZINDEX_INJECTION_KEY = ZINDEX_INJECTION_KEY;
  36. exports.defaultInitialZIndex = defaultInitialZIndex;
  37. exports.useZIndex = useZIndex;
  38. exports.zIndexContextKey = zIndexContextKey;
  39. //# sourceMappingURL=index.js.map