@gitlab/ui 82.0.1 → 82.1.0
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/CHANGELOG.md +7 -0
- package/dist/directives/outside/outside.js +9 -17
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/src/directives/outside/outside.js +7 -11
- package/src/scss/gitlab_ui.scss +3 -0
- package/dist/directives/outside/get_event_like_time_stamp.js +0 -33
- package/src/directives/outside/LICENSE +0 -21
- package/src/directives/outside/get_event_like_time_stamp.js +0 -31
package/package.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { getEventLikeTimeStamp } from './get_event_like_time_stamp';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* Map<HTMLElement,
|
|
2
|
+
* Map<HTMLElement, Function>
|
|
5
3
|
*/
|
|
6
4
|
const callbacks = new Map();
|
|
7
5
|
|
|
@@ -12,13 +10,11 @@ let listening = false;
|
|
|
12
10
|
let lastMousedown = null;
|
|
13
11
|
|
|
14
12
|
const globalListener = (event) => {
|
|
15
|
-
callbacks.forEach((
|
|
13
|
+
callbacks.forEach((callback, element) => {
|
|
16
14
|
const originalEvent = lastMousedown || event;
|
|
17
15
|
if (
|
|
18
16
|
// Ignore events that aren't targeted outside the element
|
|
19
|
-
element.contains(originalEvent.target)
|
|
20
|
-
// Only consider events triggered after the directive was bound
|
|
21
|
-
event.timeStamp <= bindTimeStamp
|
|
17
|
+
element.contains(originalEvent.target)
|
|
22
18
|
) {
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
@@ -48,6 +44,9 @@ const startListening = () => {
|
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
document.addEventListener('mousedown', onMousedown);
|
|
47
|
+
// Added { capture: true } to prevent the behavior discussed in https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1686#note_412545027
|
|
48
|
+
// Ensures the event listener handles the event in the capturing phase, avoiding issues encountered previously.
|
|
49
|
+
// Cannot be tested with Jest or Cypress, but can be tested with Playwright in the future: https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/4272#note_1947425384
|
|
51
50
|
document.addEventListener('click', globalListener, { capture: true });
|
|
52
51
|
listening = true;
|
|
53
52
|
lastMousedown = null;
|
|
@@ -91,10 +90,7 @@ const bind = (el, { value, arg = 'click' }) => {
|
|
|
91
90
|
startListening();
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
callbacks.set(el,
|
|
95
|
-
bindTimeStamp: getEventLikeTimeStamp(),
|
|
96
|
-
callback: value,
|
|
97
|
-
});
|
|
93
|
+
callbacks.set(el, value);
|
|
98
94
|
};
|
|
99
95
|
|
|
100
96
|
const unbind = (el) => {
|
package/src/scss/gitlab_ui.scss
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is based on Vue's scheduler code:
|
|
3
|
-
* https://github.com/vuejs/vue/blob/v2.6.12/src/core/observer/scheduler.js#L44-L66
|
|
4
|
-
*
|
|
5
|
-
* See the LICENSE file in this directory.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
performance
|
|
10
|
-
} = window;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get a current timestamp that can be meaningfully compared to an event's
|
|
14
|
-
* `timeStamp` property.
|
|
15
|
-
*
|
|
16
|
-
* Event timestamps can be a DOMHighResTimeStamp (if supported), otherwise
|
|
17
|
-
* a DOMTimeStamp (used by jsdom and older browsers).
|
|
18
|
-
*
|
|
19
|
-
* This function will return a current timestamp of the same type used by the
|
|
20
|
-
* underlying environment when it creates DOM events.
|
|
21
|
-
*
|
|
22
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp for
|
|
23
|
-
* more details.
|
|
24
|
-
*
|
|
25
|
-
* @returns {number}
|
|
26
|
-
*/
|
|
27
|
-
const getEventLikeTimeStamp =
|
|
28
|
-
// If the event timestamp, although evaluated AFTER the Date.now(), is
|
|
29
|
-
// smaller, it means the event is using a hi-res timestamp, and we need to
|
|
30
|
-
// use the hi-res version for event listener timestamps as well.
|
|
31
|
-
typeof (performance === null || performance === void 0 ? void 0 : performance.now) === 'function' && Date.now() > document.createEvent('Event').timeStamp ? () => performance.now() : () => Date.now();
|
|
32
|
-
|
|
33
|
-
export { getEventLikeTimeStamp };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is based on Vue's scheduler code:
|
|
3
|
-
* https://github.com/vuejs/vue/blob/v2.6.12/src/core/observer/scheduler.js#L44-L66
|
|
4
|
-
*
|
|
5
|
-
* See the LICENSE file in this directory.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { performance } = window;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get a current timestamp that can be meaningfully compared to an event's
|
|
12
|
-
* `timeStamp` property.
|
|
13
|
-
*
|
|
14
|
-
* Event timestamps can be a DOMHighResTimeStamp (if supported), otherwise
|
|
15
|
-
* a DOMTimeStamp (used by jsdom and older browsers).
|
|
16
|
-
*
|
|
17
|
-
* This function will return a current timestamp of the same type used by the
|
|
18
|
-
* underlying environment when it creates DOM events.
|
|
19
|
-
*
|
|
20
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp for
|
|
21
|
-
* more details.
|
|
22
|
-
*
|
|
23
|
-
* @returns {number}
|
|
24
|
-
*/
|
|
25
|
-
export const getEventLikeTimeStamp =
|
|
26
|
-
// If the event timestamp, although evaluated AFTER the Date.now(), is
|
|
27
|
-
// smaller, it means the event is using a hi-res timestamp, and we need to
|
|
28
|
-
// use the hi-res version for event listener timestamps as well.
|
|
29
|
-
typeof performance?.now === 'function' && Date.now() > document.createEvent('Event').timeStamp
|
|
30
|
-
? () => performance.now()
|
|
31
|
-
: () => Date.now();
|