@teammodlr/ui-kit 2.1.0 → 2.1.1

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.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -7,7 +7,7 @@
7
7
  :enter-from-class="fade.enterFrom"
8
8
  :leave-to-class="fade.leaveTo"
9
9
  >
10
- <div v-show="isOpen" :class="style.background" :style="{zIndex: zIndex}" @click="closeOutside">
10
+ <div v-show="isOpen" :class="style.background" :style="{zIndex: zIndex}" @mousedown="closeOutside">
11
11
  <Transition
12
12
  type="animation"
13
13
  :enter-active-class="modalScale.enterActive"
@@ -46,11 +46,10 @@
46
46
  import type {PropType} from "vue";
47
47
  import type {Size} from "../../types/props";
48
48
  import {defineComponent, ref, computed, watch, nextTick} from 'vue';
49
- import {useFocusTrap} from '@vueuse/integrations/useFocusTrap'
50
49
  import * as style from './style';
51
50
  import { modalScale, fade } from "../../styles/transitions.css";
52
51
  import {useZIndex} from "../../composables/useZIndex";
53
- import { useMagicKeys, watchOnce } from "@vueuse/core";
52
+ import { useEventListener, useMagicKeys } from "@vueuse/core";
54
53
 
55
54
  export default defineComponent({
56
55
  name: "MModal",
@@ -81,6 +80,8 @@ export default defineComponent({
81
80
  const isOpen = ref(false);
82
81
  const target = ref();
83
82
  const zIndex = ref(props.zIndex ?? nextZIndex());
83
+
84
+ const clickInside = ref(false);
84
85
  // const {hasFocus, activate, deactivate} = useFocusTrap(target, {
85
86
  // immediate: true,
86
87
  // escapeDeactivates: false,
@@ -102,8 +103,11 @@ export default defineComponent({
102
103
  ];
103
104
  });
104
105
 
106
+ useEventListener(target, 'mousedown', handleMouseDown);
107
+ useEventListener(document, 'mouseup', handleMouseUp);
108
+
105
109
  const closeOutside = () => {
106
- if (props.canClickOutside) {
110
+ if (props.canClickOutside && !clickInside.value) {
107
111
  close();
108
112
  }
109
113
  };
@@ -122,6 +126,18 @@ export default defineComponent({
122
126
  isOpen.value = true;
123
127
  };
124
128
 
129
+ function handleMouseUp(event: MouseEvent) {
130
+ nextTick(() => {
131
+ if (clickInside.value) {
132
+ clickInside.value = false;
133
+ }
134
+ });
135
+ }
136
+
137
+ function handleMouseDown(event: MouseEvent) {
138
+ clickInside.value = true;
139
+ }
140
+
125
141
  function ownerScrollbarOpen() {
126
142
  let ownerWindow = window;
127
143
  let documentElement = ownerWindow.document.documentElement;
@@ -161,6 +177,8 @@ export default defineComponent({
161
177
  return {
162
178
  close,
163
179
  closeOutside,
180
+ handleMouseUp,
181
+ handleMouseDown,
164
182
  open,
165
183
  target,
166
184
  style,