@gitlab/ui 82.0.1 → 83.0.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 +22 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +26 -8
- package/dist/directives/outside/outside.js +9 -17
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +4 -2
- package/src/components/experimental/duo/chat/duo_chat.vue +34 -7
- 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "83.0.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
"test:integration:server": "NODE_ENV=test start-test storybook:run http-get://${STORYBOOK_HOST:-localhost}:9001/iframe.html",
|
|
50
50
|
"test:unit": "NODE_ENV=test jest",
|
|
51
51
|
"test:unit:watch": "yarn test:unit --watch",
|
|
52
|
+
"test:unit:coverage": "yarn test:unit --coverage",
|
|
52
53
|
"test:unit:debug": "NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
|
|
53
54
|
"test:unit-vue3": "VUE_VERSION=3 NODE_ENV=test jest",
|
|
54
55
|
"test:unit-vue3:watch": "VUE_VERSION=3 yarn test:unit --watch",
|
|
56
|
+
"test:unit-vue3:coverage": "VUE_VERSION=3 yarn test:unit --coverage",
|
|
55
57
|
"test:unit-vue3:debug": "VUE_VERSION=3 NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
|
|
56
58
|
"test:visual": "./bin/run-visual-tests.sh 'test-storybook --browsers firefox --verbose --url http://localhost:9001'",
|
|
57
59
|
"test:visual:update": "./bin/run-visual-tests.sh 'test-storybook -u --browsers firefox --verbose --url http://localhost:9001'",
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
"@gitlab/eslint-plugin": "19.5.0",
|
|
109
111
|
"@gitlab/fonts": "^1.3.0",
|
|
110
112
|
"@gitlab/stylelint-config": "6.1.0",
|
|
111
|
-
"@gitlab/svgs": "3.
|
|
113
|
+
"@gitlab/svgs": "3.103.0",
|
|
112
114
|
"@jest/test-sequencer": "^29.7.0",
|
|
113
115
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
114
116
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
@@ -27,6 +27,7 @@ export const i18n = {
|
|
|
27
27
|
CHAT_PROMPT_PLACEHOLDER_DEFAULT: 'GitLab Duo Chat',
|
|
28
28
|
CHAT_PROMPT_PLACEHOLDER_WITH_COMMANDS: 'Type "/" for slash commands',
|
|
29
29
|
CHAT_SUBMIT_LABEL: 'Send chat message.',
|
|
30
|
+
CHAT_CANCEL_LABEL: 'Cancel',
|
|
30
31
|
CHAT_LEGAL_DISCLAIMER:
|
|
31
32
|
"May provide inappropriate responses not representative of GitLab's views. Do not input personal data.",
|
|
32
33
|
CHAT_DEFAULT_PREDEFINED_PROMPTS: [
|
|
@@ -188,6 +189,7 @@ export default {
|
|
|
188
189
|
prompt: '',
|
|
189
190
|
scrolledToBottom: true,
|
|
190
191
|
activeCommandIndex: 0,
|
|
192
|
+
displaySubmitButton: true,
|
|
191
193
|
};
|
|
192
194
|
},
|
|
193
195
|
computed: {
|
|
@@ -213,7 +215,7 @@ export default {
|
|
|
213
215
|
);
|
|
214
216
|
},
|
|
215
217
|
lastMessage() {
|
|
216
|
-
return this.messages[this.messages.length - 1];
|
|
218
|
+
return this.messages?.[this.messages.length - 1];
|
|
217
219
|
},
|
|
218
220
|
resetDisabled() {
|
|
219
221
|
if (this.isLoading || !this.hasMessages) {
|
|
@@ -221,9 +223,6 @@ export default {
|
|
|
221
223
|
}
|
|
222
224
|
return this.lastMessage?.content === CHAT_RESET_MESSAGE;
|
|
223
225
|
},
|
|
224
|
-
submitDisabled() {
|
|
225
|
-
return this.isLoading || this.isStreaming;
|
|
226
|
-
},
|
|
227
226
|
isStreaming() {
|
|
228
227
|
return Boolean(
|
|
229
228
|
(this.lastMessage?.chunks?.length > 0 && !this.lastMessage?.content) ||
|
|
@@ -256,10 +255,18 @@ export default {
|
|
|
256
255
|
},
|
|
257
256
|
},
|
|
258
257
|
watch: {
|
|
259
|
-
isLoading() {
|
|
258
|
+
isLoading(newVal) {
|
|
259
|
+
if (!newVal && !this.isStreaming) {
|
|
260
|
+
this.displaySubmitButton = true; // Re-enable submit button when loading stops
|
|
261
|
+
}
|
|
260
262
|
this.isHidden = false;
|
|
261
263
|
this.scrollToBottom();
|
|
262
264
|
},
|
|
265
|
+
isStreaming(newVal) {
|
|
266
|
+
if (!newVal && !this.isLoading) {
|
|
267
|
+
this.displaySubmitButton = true; // Re-enable submit button when streaming stops
|
|
268
|
+
}
|
|
269
|
+
},
|
|
263
270
|
},
|
|
264
271
|
created() {
|
|
265
272
|
this.handleScrollingTrottled = throttle(this.handleScrolling, 200); // Assume a 200ms throttle for example
|
|
@@ -275,8 +282,17 @@ export default {
|
|
|
275
282
|
*/
|
|
276
283
|
this.$emit('chat-hidden');
|
|
277
284
|
},
|
|
285
|
+
cancelPrompt() {
|
|
286
|
+
/**
|
|
287
|
+
* Emitted when user clicks the stop button in the textarea
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
this.displaySubmitButton = true;
|
|
291
|
+
this.$emit('chat-cancel');
|
|
292
|
+
this.setPromptAndFocus();
|
|
293
|
+
},
|
|
278
294
|
sendChatPrompt() {
|
|
279
|
-
if (this.
|
|
295
|
+
if (!this.displaySubmitButton) {
|
|
280
296
|
return;
|
|
281
297
|
}
|
|
282
298
|
if (this.prompt) {
|
|
@@ -289,6 +305,7 @@ export default {
|
|
|
289
305
|
* @param {String} prompt The user prompt to send.
|
|
290
306
|
*/
|
|
291
307
|
this.$emit('send-chat-prompt', this.prompt.trim());
|
|
308
|
+
this.displaySubmitButton = false;
|
|
292
309
|
this.setPromptAndFocus();
|
|
293
310
|
}
|
|
294
311
|
},
|
|
@@ -517,6 +534,7 @@ export default {
|
|
|
517
534
|
</div>
|
|
518
535
|
<template #append>
|
|
519
536
|
<gl-button
|
|
537
|
+
v-if="displaySubmitButton"
|
|
520
538
|
icon="paper-airplane"
|
|
521
539
|
category="primary"
|
|
522
540
|
variant="confirm"
|
|
@@ -524,7 +542,16 @@ export default {
|
|
|
524
542
|
type="submit"
|
|
525
543
|
data-testid="chat-prompt-submit-button"
|
|
526
544
|
:aria-label="$options.i18n.CHAT_SUBMIT_LABEL"
|
|
527
|
-
|
|
545
|
+
/>
|
|
546
|
+
<gl-button
|
|
547
|
+
v-else
|
|
548
|
+
icon="stop"
|
|
549
|
+
category="primary"
|
|
550
|
+
variant="default"
|
|
551
|
+
class="!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!"
|
|
552
|
+
data-testid="chat-prompt-cancel-button"
|
|
553
|
+
:aria-label="$options.i18n.CHAT_CANCEL_LABEL"
|
|
554
|
+
@click="cancelPrompt"
|
|
528
555
|
/>
|
|
529
556
|
</template>
|
|
530
557
|
</gl-form-input-group>
|
|
@@ -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();
|