@gitlab/ui 67.0.0 → 67.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "67.0.0",
3
+ "version": "67.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -94,7 +94,7 @@
94
94
  "@gitlab/eslint-plugin": "19.2.0",
95
95
  "@gitlab/fonts": "^1.3.0",
96
96
  "@gitlab/stylelint-config": "5.0.1",
97
- "@gitlab/svgs": "3.66.0",
97
+ "@gitlab/svgs": "3.68.0",
98
98
  "@rollup/plugin-commonjs": "^11.1.0",
99
99
  "@rollup/plugin-node-resolve": "^7.1.3",
100
100
  "@rollup/plugin-replace": "^2.3.2",
@@ -122,7 +122,7 @@
122
122
  "babel-loader": "^8.0.5",
123
123
  "babel-plugin-require-context-hook": "^1.0.0",
124
124
  "bootstrap": "4.6.2",
125
- "cypress": "13.3.2",
125
+ "cypress": "13.3.3",
126
126
  "cypress-axe": "^1.4.0",
127
127
  "dompurify": "^3.0.0",
128
128
  "emoji-regex": "^10.0.0",
@@ -9,12 +9,14 @@ const callbacks = new Map();
9
9
  * Is a global listener already set up?
10
10
  */
11
11
  let listening = false;
12
+ let lastMousedown = null;
12
13
 
13
14
  const globalListener = (event) => {
14
15
  callbacks.forEach(({ bindTimeStamp, callback }, element) => {
16
+ const originalEvent = lastMousedown || event;
15
17
  if (
16
18
  // Ignore events that aren't targeted outside the element
17
- element.contains(event.target) ||
19
+ element.contains(originalEvent.target) ||
18
20
  // Only consider events triggered after the directive was bound
19
21
  event.timeStamp <= bindTimeStamp
20
22
  ) {
@@ -30,6 +32,14 @@ const globalListener = (event) => {
30
32
  }
31
33
  }
32
34
  });
35
+ lastMousedown = null;
36
+ };
37
+
38
+ // We need to listen for mouse events because text selection fires click event only when selection ends.
39
+ // This means that the click event target could differ from the element where it originally started.
40
+ // As example: if we use mouse events we could guarantee that selecting text within a dropdown won't close it.
41
+ const onMousedown = (event) => {
42
+ lastMousedown = event;
33
43
  };
34
44
 
35
45
  const startListening = () => {
@@ -37,8 +47,10 @@ const startListening = () => {
37
47
  return;
38
48
  }
39
49
 
50
+ document.addEventListener('mousedown', onMousedown);
40
51
  document.addEventListener('click', globalListener, { capture: true });
41
52
  listening = true;
53
+ lastMousedown = null;
42
54
  };
43
55
 
44
56
  const stopListening = () => {
@@ -46,6 +58,7 @@ const stopListening = () => {
46
58
  return;
47
59
  }
48
60
 
61
+ document.removeEventListener('mousedown', onMousedown);
49
62
  document.removeEventListener('click', globalListener);
50
63
  listening = false;
51
64
  };
@@ -126,35 +126,14 @@ describe('outside directive', () => {
126
126
  expect(document.addEventListener).not.toHaveBeenCalled();
127
127
  });
128
128
 
129
- it('attaches the global listener on first initialisation', async () => {
130
- await createComponent();
131
-
132
- expect(document.addEventListener.mock.calls).toEqual([
133
- ['click', expect.any(Function), { capture: true }],
134
- ]);
135
- });
136
-
137
129
  it('detaches the global listener when last binding is removed', async () => {
138
130
  await createComponent();
139
131
 
140
132
  wrapper.destroy();
141
133
 
142
- expect(document.removeEventListener.mock.calls).toEqual([['click', expect.any(Function)]]);
143
- });
144
-
145
- it('only binds once, even with multiple instances', async () => {
146
- await createComponent({
147
- template: `
148
- <div>
149
- <div v-outside="onClick"></div>
150
- <div v-outside="onClick"></div>
151
- </div>
152
- `,
153
- });
134
+ document.body.dispatchEvent(new MouseEvent('click'));
154
135
 
155
- expect(document.addEventListener.mock.calls).toEqual([
156
- ['click', expect.any(Function), { capture: true }],
157
- ]);
136
+ expect(onClick).not.toHaveBeenCalled();
158
137
  });
159
138
 
160
139
  it('only unbinds once there are no instances', async () => {
@@ -173,12 +152,16 @@ describe('outside directive', () => {
173
152
  wrapper.setData({ instances: 1 });
174
153
  await wrapper.vm.$nextTick();
175
154
 
176
- expect(document.removeEventListener).not.toHaveBeenCalled();
155
+ document.body.dispatchEvent(new MouseEvent('click'));
156
+
157
+ expect(onClick).toHaveBeenCalledTimes(1);
177
158
 
178
159
  wrapper.setData({ instances: 0 });
179
160
  await wrapper.vm.$nextTick();
180
161
 
181
- expect(document.removeEventListener.mock.calls).toEqual([['click', expect.any(Function)]]);
162
+ document.body.dispatchEvent(new MouseEvent('click'));
163
+
164
+ expect(onClick).toHaveBeenCalledTimes(1);
182
165
  });
183
166
  });
184
167
 
@@ -341,4 +324,15 @@ describe('outside directive', () => {
341
324
  expect(global.console.error.mock.calls).toEqual([[thrownError]]);
342
325
  });
343
326
  });
327
+
328
+ describe('mousedown before click', () => {
329
+ it('respects mousedown event before click', async () => {
330
+ await createComponent();
331
+
332
+ find('inside').trigger('mousedown');
333
+ find('outside').trigger('click');
334
+
335
+ expect(onClick).not.toHaveBeenCalled();
336
+ });
337
+ });
344
338
  });
@@ -2448,6 +2448,14 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
2448
2448
  color: $black-normal !important;
2449
2449
  }
2450
2450
 
2451
+ .gl-text-gray-100 {
2452
+ color: $gray-100;
2453
+ }
2454
+
2455
+ .gl-text-gray-100\! {
2456
+ color: $gray-100 !important;
2457
+ }
2458
+
2451
2459
  .gl-text-gray-200 {
2452
2460
  color: $gray-200;
2453
2461
  }
@@ -41,6 +41,10 @@
41
41
  color: $black-normal;
42
42
  }
43
43
 
44
+ @mixin gl-text-gray-100 {
45
+ color: $gray-100;
46
+ }
47
+
44
48
  @mixin gl-text-gray-200 {
45
49
  color: $gray-200;
46
50
  }