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.

45 lines
1.7 KiB

1 month ago
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var types = require('../../utils/types.js');
  5. var core = require('@vueuse/core');
  6. var error = require('../../utils/error.js');
  7. const initial = {
  8. current: 0
  9. };
  10. const zIndex = vue.ref(0);
  11. const defaultInitialZIndex = 2e3;
  12. const ZINDEX_INJECTION_KEY = Symbol("elZIndexContextKey");
  13. const zIndexContextKey = Symbol("zIndexContextKey");
  14. const useZIndex = (zIndexOverrides) => {
  15. const increasingInjection = vue.getCurrentInstance() ? vue.inject(ZINDEX_INJECTION_KEY, initial) : initial;
  16. const zIndexInjection = zIndexOverrides || (vue.getCurrentInstance() ? vue.inject(zIndexContextKey, void 0) : void 0);
  17. const initialZIndex = vue.computed(() => {
  18. const zIndexFromInjection = vue.unref(zIndexInjection);
  19. return types.isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
  20. });
  21. const currentZIndex = vue.computed(() => initialZIndex.value + zIndex.value);
  22. const nextZIndex = () => {
  23. increasingInjection.current++;
  24. zIndex.value = increasingInjection.current;
  25. return currentZIndex.value;
  26. };
  27. if (!core.isClient && !vue.inject(ZINDEX_INJECTION_KEY)) {
  28. 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
  29. usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`);
  30. }
  31. return {
  32. initialZIndex,
  33. currentZIndex,
  34. nextZIndex
  35. };
  36. };
  37. exports.ZINDEX_INJECTION_KEY = ZINDEX_INJECTION_KEY;
  38. exports.defaultInitialZIndex = defaultInitialZIndex;
  39. exports.useZIndex = useZIndex;
  40. exports.zIndexContextKey = zIndexContextKey;
  41. //# sourceMappingURL=index.js.map