1e1a945f670eadf8ecd236bc3fce9ce95dccaff03c99fe51dc68b9c9062f8a5e1a4eda236981f13c4b1b72b24f5a38352b2ec8f51e0659d178ec071766f272 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const initial = {
  7. current: 0
  8. };
  9. const zIndex = 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 = vue.getCurrentInstance() ? vue.inject(ZINDEX_INJECTION_KEY, initial) : initial;
  15. const zIndexInjection = zIndexOverrides || (vue.getCurrentInstance() ? vue.inject(zIndexContextKey, void 0) : void 0);
  16. const initialZIndex = vue.computed(() => {
  17. const zIndexFromInjection = vue.unref(zIndexInjection);
  18. return types.isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
  19. });
  20. const currentZIndex = vue.computed(() => initialZIndex.value + zIndex.value);
  21. const nextZIndex = () => {
  22. increasingInjection.current++;
  23. zIndex.value = increasingInjection.current;
  24. return currentZIndex.value;
  25. };
  26. if (!core.isClient && !vue.inject(ZINDEX_INJECTION_KEY)) ;
  27. return {
  28. initialZIndex,
  29. currentZIndex,
  30. nextZIndex
  31. };
  32. };
  33. exports.ZINDEX_INJECTION_KEY = ZINDEX_INJECTION_KEY;
  34. exports.defaultInitialZIndex = defaultInitialZIndex;
  35. exports.useZIndex = useZIndex;
  36. exports.zIndexContextKey = zIndexContextKey;
  37. //# sourceMappingURL=index.js.map