@teammodlr/ui-kit 2.0.31 → 2.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammodlr/ui-kit",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -40,6 +40,7 @@ import {defineComponent, ref, computed, watch, nextTick} from 'vue';
40
40
  import {useFocusTrap} from '@vueuse/integrations/useFocusTrap'
41
41
  import * as style from './style';
42
42
  import {useZIndex} from "../../composables/useZIndex";
43
+ import { useMagicKeys, watchOnce } from "@vueuse/core";
43
44
 
44
45
  export default defineComponent({
45
46
  name: "MModal",
@@ -72,6 +73,14 @@ export default defineComponent({
72
73
  allowOutsideClick: true
73
74
  });
74
75
 
76
+ const { escape } = useMagicKeys()
77
+
78
+ watch(escape, (v) => {
79
+ if (v && isOpen.value) {
80
+ close()
81
+ }
82
+ })
83
+
75
84
  const containerClasses = computed(() => {
76
85
  return [
77
86
  style.container,
@@ -79,7 +88,6 @@ export default defineComponent({
79
88
  ];
80
89
  });
81
90
 
82
-
83
91
  const closeOutside = () => {
84
92
  if (props.canClickOutside) {
85
93
  isOpen.value = false;
@@ -2,8 +2,8 @@
2
2
  <span
3
3
  v-bind="$attrs"
4
4
  style="display: inline-flex"
5
- @mouseenter="toggle"
6
- @mouseleave="toggle"
5
+ @mouseenter="show"
6
+ @mouseleave="hide"
7
7
  ref="wrapper"
8
8
  >
9
9
  <span ref="reference">
@@ -31,7 +31,7 @@
31
31
  </template>
32
32
 
33
33
  <script lang="ts">
34
- import { defineComponent, ref, toRef, type PropType, computed, watch } from 'vue';
34
+ import { defineComponent, ref, toRef, type PropType, computed, watch, onUnmounted } from 'vue';
35
35
  import { type Placement, placementWhileList, usePopper } from "../../composables/usePopper";
36
36
  import { fade } from "../../styles/transitions.css";
37
37
  import * as style from "./style";
@@ -132,12 +132,43 @@ export default defineComponent({
132
132
  }
133
133
  }
134
134
 
135
+ function show() {
136
+ if (timeout.value) {
137
+ clearTimeout(timeout.value);
138
+ }
139
+
140
+ if (props.delay) {
141
+ timeout.value = setTimeout(() => {
142
+ isOpen.value = true;
143
+ }, props.delay);
144
+ } else {
145
+ isOpen.value = true;
146
+ }
147
+ }
148
+
149
+ function hide() {
150
+ if (timeout.value) {
151
+ clearTimeout(timeout.value);
152
+ }
153
+
154
+ isOpen.value = false;
155
+ }
156
+
157
+ onUnmounted(() => {
158
+ isOpen.value = false;
159
+ if (timeout.value) {
160
+ clearTimeout(timeout.value);
161
+ }
162
+ timeout.value = null;
163
+ });
164
+
135
165
  return {
136
166
  reference,
137
167
  popper,
138
168
  transferTo,
139
169
  isOpen,
140
- toggle,
170
+ show,
171
+ hide,
141
172
  computedClasses,
142
173
  zIndex,
143
174
  style,