@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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [83.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v82.1.0...v83.0.0) (2024-06-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **DuoChat:** add propmpt abort functionality ([3792308](https://gitlab.com/gitlab-org/gitlab-ui/commit/3792308a7c086e9e3588a0793be10d41473f473f))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **DuoChat:** This commit adds an abort button to the
|
|
12
|
+
DuoChat textarea, it also introduces the
|
|
13
|
+
chat-abort event that can be caught
|
|
14
|
+
by the client.
|
|
15
|
+
|
|
16
|
+
# [82.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v82.0.1...v82.1.0) (2024-06-20)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* **CSS:** include design token CSS custom properties in gitlab_ui.scss ([1a8db73](https://gitlab.com/gitlab-org/gitlab-ui/commit/1a8db73bde228ef91ee86660515c180984bdeebf))
|
|
22
|
+
|
|
1
23
|
## [82.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v82.0.0...v82.0.1) (2024-06-19)
|
|
2
24
|
|
|
3
25
|
|
|
@@ -27,6 +27,7 @@ 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: "May provide inappropriate responses not representative of GitLab's views. Do not input personal data.",
|
|
31
32
|
CHAT_DEFAULT_PREDEFINED_PROMPTS: ['How do I change my password in GitLab?', 'How do I fork a project?', 'How do I clone a repository?', 'How do I create a template?']
|
|
32
33
|
};
|
|
@@ -179,7 +180,8 @@ var script = {
|
|
|
179
180
|
isHidden: false,
|
|
180
181
|
prompt: '',
|
|
181
182
|
scrolledToBottom: true,
|
|
182
|
-
activeCommandIndex: 0
|
|
183
|
+
activeCommandIndex: 0,
|
|
184
|
+
displaySubmitButton: true
|
|
183
185
|
};
|
|
184
186
|
},
|
|
185
187
|
computed: {
|
|
@@ -202,7 +204,8 @@ var script = {
|
|
|
202
204
|
}, [[]]);
|
|
203
205
|
},
|
|
204
206
|
lastMessage() {
|
|
205
|
-
|
|
207
|
+
var _this$messages2;
|
|
208
|
+
return (_this$messages2 = this.messages) === null || _this$messages2 === void 0 ? void 0 : _this$messages2[this.messages.length - 1];
|
|
206
209
|
},
|
|
207
210
|
resetDisabled() {
|
|
208
211
|
var _this$lastMessage;
|
|
@@ -211,9 +214,6 @@ var script = {
|
|
|
211
214
|
}
|
|
212
215
|
return ((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : _this$lastMessage.content) === CHAT_RESET_MESSAGE;
|
|
213
216
|
},
|
|
214
|
-
submitDisabled() {
|
|
215
|
-
return this.isLoading || this.isStreaming;
|
|
216
|
-
},
|
|
217
217
|
isStreaming() {
|
|
218
218
|
var _this$lastMessage2, _this$lastMessage2$ch, _this$lastMessage3, _this$lastMessage4;
|
|
219
219
|
return Boolean(((_this$lastMessage2 = this.lastMessage) === null || _this$lastMessage2 === void 0 ? void 0 : (_this$lastMessage2$ch = _this$lastMessage2.chunks) === null || _this$lastMessage2$ch === void 0 ? void 0 : _this$lastMessage2$ch.length) > 0 && !((_this$lastMessage3 = this.lastMessage) !== null && _this$lastMessage3 !== void 0 && _this$lastMessage3.content) || typeof ((_this$lastMessage4 = this.lastMessage) === null || _this$lastMessage4 === void 0 ? void 0 : _this$lastMessage4.chunkId) === 'number');
|
|
@@ -237,9 +237,17 @@ var script = {
|
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
239
|
watch: {
|
|
240
|
-
isLoading() {
|
|
240
|
+
isLoading(newVal) {
|
|
241
|
+
if (!newVal && !this.isStreaming) {
|
|
242
|
+
this.displaySubmitButton = true; // Re-enable submit button when loading stops
|
|
243
|
+
}
|
|
241
244
|
this.isHidden = false;
|
|
242
245
|
this.scrollToBottom();
|
|
246
|
+
},
|
|
247
|
+
isStreaming(newVal) {
|
|
248
|
+
if (!newVal && !this.isLoading) {
|
|
249
|
+
this.displaySubmitButton = true; // Re-enable submit button when streaming stops
|
|
250
|
+
}
|
|
243
251
|
}
|
|
244
252
|
},
|
|
245
253
|
created() {
|
|
@@ -256,8 +264,17 @@ var script = {
|
|
|
256
264
|
*/
|
|
257
265
|
this.$emit('chat-hidden');
|
|
258
266
|
},
|
|
267
|
+
cancelPrompt() {
|
|
268
|
+
/**
|
|
269
|
+
* Emitted when user clicks the stop button in the textarea
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
this.displaySubmitButton = true;
|
|
273
|
+
this.$emit('chat-cancel');
|
|
274
|
+
this.setPromptAndFocus();
|
|
275
|
+
},
|
|
259
276
|
sendChatPrompt() {
|
|
260
|
-
if (this.
|
|
277
|
+
if (!this.displaySubmitButton) {
|
|
261
278
|
return;
|
|
262
279
|
}
|
|
263
280
|
if (this.prompt) {
|
|
@@ -270,6 +287,7 @@ var script = {
|
|
|
270
287
|
* @param {String} prompt The user prompt to send.
|
|
271
288
|
*/
|
|
272
289
|
this.$emit('send-chat-prompt', this.prompt.trim());
|
|
290
|
+
this.displaySubmitButton = false;
|
|
273
291
|
this.setPromptAndFocus();
|
|
274
292
|
}
|
|
275
293
|
},
|
|
@@ -364,7 +382,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
364
382
|
{
|
|
365
383
|
'gl-h-full': !_vm.hasMessages,
|
|
366
384
|
'force-scroll-bar': _vm.hasMessages,
|
|
367
|
-
} ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"show-delimiter":index > 0},on:{"track-feedback":_vm.onTrackFeedback}})}),_vm._v(" "),(!_vm.hasMessages && !_vm.isLoading)?[_c('gl-empty-state',{key:"empty-state",staticClass:"gl-flex-grow gl-justify-content-center",attrs:{"svg-path":_vm.$options.emptySvg,"svg-height":145,"title":_vm.emptyStateTitle,"description":_vm.emptyStateDescription}}),_vm._v(" "),_c('gl-duo-chat-predefined-prompts',{key:"predefined-prompts",attrs:{"prompts":_vm.predefinedPrompts},on:{"click":_vm.sendPredefinedPrompt}})]:_vm._e(),_vm._v(" "),(_vm.isLoading)?_c('gl-duo-chat-loader',{key:"loader",attrs:{"tool-name":_vm.toolName}}):_vm._e(),_vm._v(" "),_c('div',{key:"anchor",ref:"anchor",staticClass:"scroll-anchor"})],2)],1),_vm._v(" "),(_vm.isChatAvailable)?_c('footer',{staticClass:"duo-chat-drawer-footer duo-chat-drawer-footer-sticky gl-p-5 gl-border-t gl-bg-gray-10",class:{ 'duo-chat-drawer-body-scrim-on-footer': !_vm.scrolledToBottom },attrs:{"data-testid":"chat-footer"}},[_c('gl-form',{attrs:{"data-testid":"chat-prompt-form"},on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.sendChatPrompt.apply(null, arguments)}}},[_c('gl-form-input-group',{scopedSlots:_vm._u([{key:"append",fn:function(){return [_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"paper-airplane","category":"primary","variant":"confirm","type":"submit","data-testid":"chat-prompt-submit-button","aria-label":_vm.$options.i18n.CHAT_SUBMIT_LABEL,"
|
|
385
|
+
} ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"show-delimiter":index > 0},on:{"track-feedback":_vm.onTrackFeedback}})}),_vm._v(" "),(!_vm.hasMessages && !_vm.isLoading)?[_c('gl-empty-state',{key:"empty-state",staticClass:"gl-flex-grow gl-justify-content-center",attrs:{"svg-path":_vm.$options.emptySvg,"svg-height":145,"title":_vm.emptyStateTitle,"description":_vm.emptyStateDescription}}),_vm._v(" "),_c('gl-duo-chat-predefined-prompts',{key:"predefined-prompts",attrs:{"prompts":_vm.predefinedPrompts},on:{"click":_vm.sendPredefinedPrompt}})]:_vm._e(),_vm._v(" "),(_vm.isLoading)?_c('gl-duo-chat-loader',{key:"loader",attrs:{"tool-name":_vm.toolName}}):_vm._e(),_vm._v(" "),_c('div',{key:"anchor",ref:"anchor",staticClass:"scroll-anchor"})],2)],1),_vm._v(" "),(_vm.isChatAvailable)?_c('footer',{staticClass:"duo-chat-drawer-footer duo-chat-drawer-footer-sticky gl-p-5 gl-border-t gl-bg-gray-10",class:{ 'duo-chat-drawer-body-scrim-on-footer': !_vm.scrolledToBottom },attrs:{"data-testid":"chat-footer"}},[_c('gl-form',{attrs:{"data-testid":"chat-prompt-form"},on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.sendChatPrompt.apply(null, arguments)}}},[_c('gl-form-input-group',{scopedSlots:_vm._u([{key:"append",fn:function(){return [(_vm.displaySubmitButton)?_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"paper-airplane","category":"primary","variant":"confirm","type":"submit","data-testid":"chat-prompt-submit-button","aria-label":_vm.$options.i18n.CHAT_SUBMIT_LABEL}}):_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"stop","category":"primary","variant":"default","data-testid":"chat-prompt-cancel-button","aria-label":_vm.$options.i18n.CHAT_CANCEL_LABEL},on:{"click":_vm.cancelPrompt}})]},proxy:true}],null,false,2711323372)},[_c('div',{staticClass:"duo-chat-input gl-flex-grow-1 gl-vertical-align-top gl-max-w-full gl-min-h-8 gl-inset-border-1-gray-400 gl-rounded-base gl-bg-white",attrs:{"data-value":_vm.prompt}},[(_vm.shouldShowSlashCommands)?_c('gl-card',{ref:"commands",staticClass:"slash-commands !gl-absolute gl-translate-y-n100 gl-list-style-none gl-pl-0 gl-w-full gl-shadow-md",attrs:{"body-class":"gl-p-2!"}},_vm._l((_vm.filteredSlashCommands),function(command,index){return _c('gl-dropdown-item',{key:command.name,class:{ 'active-command': index === _vm.activeCommandIndex },on:{"click":function($event){return _vm.selectSlashCommand(index)}},nativeOn:{"mouseenter":function($event){_vm.activeCommandIndex = index;}}},[_c('span',{staticClass:"gl-display-flex gl-justify-content-space-between"},[_c('span',{staticClass:"gl-display-block"},[_vm._v(_vm._s(command.name))]),_vm._v(" "),_c('small',{staticClass:"gl-text-gray-500 gl-font-style-italic gl-text-right gl-pl-3"},[_vm._v(_vm._s(command.description))])])])}),1):_vm._e(),_vm._v(" "),_c('gl-form-textarea',{ref:"prompt",staticClass:"gl-absolute gl-h-full! gl-py-4! gl-bg-transparent! gl-rounded-top-right-none gl-rounded-bottom-right-none gl-shadow-none!",class:{ 'gl-text-truncate': !_vm.prompt },attrs:{"data-testid":"chat-prompt-input","placeholder":_vm.inputPlaceholder,"autofocus":""},nativeOn:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }$event.preventDefault();},"keyup":function($event){return _vm.onInputKeyup.apply(null, arguments)}},model:{value:(_vm.prompt),callback:function ($$v) {_vm.prompt=$$v;},expression:"prompt"}})],1)]),_vm._v(" "),_c('gl-form-text',{staticClass:"gl-text-gray-400 gl-line-height-20 gl-mt-3",attrs:{"data-testid":"chat-legal-disclaimer"}},[_vm._v(_vm._s(_vm.$options.i18n.CHAT_LEGAL_DISCLAIMER))])],1)],1):_vm._e()]):_vm._e()};
|
|
368
386
|
var __vue_staticRenderFns__ = [];
|
|
369
387
|
|
|
370
388
|
/* style */
|
|
@@ -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
|
|
|
@@ -11,17 +9,11 @@ const callbacks = new Map();
|
|
|
11
9
|
let listening = false;
|
|
12
10
|
let lastMousedown = null;
|
|
13
11
|
const globalListener = event => {
|
|
14
|
-
callbacks.forEach((
|
|
15
|
-
let {
|
|
16
|
-
bindTimeStamp,
|
|
17
|
-
callback
|
|
18
|
-
} = _ref;
|
|
12
|
+
callbacks.forEach((callback, element) => {
|
|
19
13
|
const originalEvent = lastMousedown || event;
|
|
20
14
|
if (
|
|
21
15
|
// Ignore events that aren't targeted outside the element
|
|
22
|
-
element.contains(originalEvent.target)
|
|
23
|
-
// Only consider events triggered after the directive was bound
|
|
24
|
-
event.timeStamp <= bindTimeStamp) {
|
|
16
|
+
element.contains(originalEvent.target)) {
|
|
25
17
|
return;
|
|
26
18
|
}
|
|
27
19
|
try {
|
|
@@ -47,6 +39,9 @@ const startListening = () => {
|
|
|
47
39
|
return;
|
|
48
40
|
}
|
|
49
41
|
document.addEventListener('mousedown', onMousedown);
|
|
42
|
+
// Added { capture: true } to prevent the behavior discussed in https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1686#note_412545027
|
|
43
|
+
// Ensures the event listener handles the event in the capturing phase, avoiding issues encountered previously.
|
|
44
|
+
// 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
|
|
50
45
|
document.addEventListener('click', globalListener, {
|
|
51
46
|
capture: true
|
|
52
47
|
});
|
|
@@ -61,11 +56,11 @@ const stopListening = () => {
|
|
|
61
56
|
document.removeEventListener('click', globalListener);
|
|
62
57
|
listening = false;
|
|
63
58
|
};
|
|
64
|
-
const bind = (el,
|
|
59
|
+
const bind = (el, _ref) => {
|
|
65
60
|
let {
|
|
66
61
|
value,
|
|
67
62
|
arg = 'click'
|
|
68
|
-
} =
|
|
63
|
+
} = _ref;
|
|
69
64
|
if (typeof value !== 'function') {
|
|
70
65
|
throw new Error(`[GlOutsideDirective] Value must be a function; got ${typeof value}!`);
|
|
71
66
|
}
|
|
@@ -87,10 +82,7 @@ const bind = (el, _ref2) => {
|
|
|
87
82
|
if (!listening) {
|
|
88
83
|
startListening();
|
|
89
84
|
}
|
|
90
|
-
callbacks.set(el,
|
|
91
|
-
bindTimeStamp: getEventLikeTimeStamp(),
|
|
92
|
-
callback: value
|
|
93
|
-
});
|
|
85
|
+
callbacks.set(el, value);
|
|
94
86
|
};
|
|
95
87
|
const unbind = el => {
|
|
96
88
|
callbacks.delete(el);
|