index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  2. const require_types = require("../../utils/types.js");
  3. const require_error = require("../../utils/error.js");
  4. let vue = require("vue");
  5. let _vueuse_core = require("@vueuse/core");
  6. //#region ../../packages/hooks/use-z-index/index.ts
  7. const initial = { current: 0 };
  8. const zIndex = (0, vue.ref)(0);
  9. const defaultInitialZIndex = 2e3;
  10. const ZINDEX_INJECTION_KEY = Symbol("elZIndexContextKey");
  11. const zIndexContextKey = Symbol("zIndexContextKey");
  12. const useZIndex = (zIndexOverrides) => {
  13. const increasingInjection = (0, vue.getCurrentInstance)() ? (0, vue.inject)(ZINDEX_INJECTION_KEY, initial) : initial;
  14. const zIndexInjection = zIndexOverrides || ((0, vue.getCurrentInstance)() ? (0, vue.inject)(zIndexContextKey, void 0) : void 0);
  15. const initialZIndex = (0, vue.computed)(() => {
  16. const zIndexFromInjection = (0, vue.unref)(zIndexInjection);
  17. return require_types.isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
  18. });
  19. const currentZIndex = (0, vue.computed)(() => initialZIndex.value + zIndex.value);
  20. const nextZIndex = () => {
  21. increasingInjection.current++;
  22. zIndex.value = increasingInjection.current;
  23. return currentZIndex.value;
  24. };
  25. 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
  26. usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
  27. return {
  28. initialZIndex,
  29. currentZIndex,
  30. nextZIndex
  31. };
  32. };
  33. //#endregion
  34. exports.ZINDEX_INJECTION_KEY = ZINDEX_INJECTION_KEY;
  35. exports.defaultInitialZIndex = defaultInitialZIndex;
  36. exports.useZIndex = useZIndex;
  37. exports.zIndexContextKey = zIndexContextKey;
  38. //# sourceMappingURL=index.js.map