@gitlab/ui 85.2.1 → 85.2.2

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [85.2.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v85.2.1...v85.2.2) (2024-06-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **duochat:** Wait for another enter to send on IME ([ed2a1e7](https://gitlab.com/gitlab-org/gitlab-ui/commit/ed2a1e7694805a3e72e78b1e4e9a6feac7f22c8b))
7
+
1
8
  ## [85.2.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v85.2.0...v85.2.1) (2024-06-25)
2
9
 
3
10
 
@@ -186,7 +186,8 @@ var script = {
186
186
  prompt: '',
187
187
  scrolledToBottom: true,
188
188
  activeCommandIndex: 0,
189
- displaySubmitButton: true
189
+ displaySubmitButton: true,
190
+ compositionJustEnded: false
190
191
  };
191
192
  },
192
193
  computed: {
@@ -262,6 +263,9 @@ var script = {
262
263
  this.scrollToBottom();
263
264
  },
264
265
  methods: {
266
+ compositionEnd() {
267
+ this.compositionJustEnded = true;
268
+ },
265
269
  hideChat() {
266
270
  this.isHidden = true;
267
271
  /**
@@ -323,7 +327,7 @@ var script = {
323
327
  */
324
328
  this.$emit('track-feedback', event);
325
329
  },
326
- onInputKeyup(e) {
330
+ sendChatPromptOnEnter(e) {
327
331
  const {
328
332
  metaKey,
329
333
  ctrlKey,
@@ -331,21 +335,29 @@ var script = {
331
335
  shiftKey,
332
336
  isComposing
333
337
  } = e;
338
+ const isModifierKey = metaKey || ctrlKey || altKey || shiftKey;
339
+ return !(isModifierKey || isComposing || this.compositionJustEnded);
340
+ },
341
+ onInputKeyup(e) {
342
+ const {
343
+ key
344
+ } = e;
334
345
  if (this.shouldShowSlashCommands) {
335
346
  e.preventDefault();
336
- if (e.key === 'Enter') {
347
+ if (key === 'Enter') {
337
348
  this.selectSlashCommand(this.activeCommandIndex);
338
- } else if (e.key === 'ArrowUp') {
349
+ } else if (key === 'ArrowUp') {
339
350
  this.prevCommand();
340
- } else if (e.key === 'ArrowDown') {
351
+ } else if (key === 'ArrowDown') {
341
352
  this.nextCommand();
342
353
  } else {
343
354
  this.activeCommandIndex = 0;
344
355
  }
345
- } else if (e.key === 'Enter' && !isComposing && !(metaKey || ctrlKey || altKey || shiftKey)) {
356
+ } else if (key === 'Enter' && this.sendChatPromptOnEnter(e)) {
346
357
  e.preventDefault();
347
358
  this.sendChatPrompt();
348
359
  }
360
+ this.compositionJustEnded = false;
349
361
  },
350
362
  prevCommand() {
351
363
  this.activeCommandIndex -= 1;
@@ -390,7 +402,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
390
402
  {
391
403
  'gl-h-full': !_vm.hasMessages,
392
404
  'force-scroll-bar': _vm.hasMessages,
393
- } ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"canceled-request-ids":_vm.canceledRequestIds,"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()};
405
+ } ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"canceled-request-ids":_vm.canceledRequestIds,"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":""},on:{"compositionend":_vm.compositionEnd},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()};
394
406
  var __vue_staticRenderFns__ = [];
395
407
 
396
408
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "85.2.1",
3
+ "version": "85.2.2",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -195,6 +195,7 @@ export default {
195
195
  scrolledToBottom: true,
196
196
  activeCommandIndex: 0,
197
197
  displaySubmitButton: true,
198
+ compositionJustEnded: false,
198
199
  };
199
200
  },
200
201
  computed: {
@@ -280,6 +281,9 @@ export default {
280
281
  this.scrollToBottom();
281
282
  },
282
283
  methods: {
284
+ compositionEnd() {
285
+ this.compositionJustEnded = true;
286
+ },
283
287
  hideChat() {
284
288
  this.isHidden = true;
285
289
  /**
@@ -338,26 +342,34 @@ export default {
338
342
  */
339
343
  this.$emit('track-feedback', event);
340
344
  },
341
- onInputKeyup(e) {
345
+ sendChatPromptOnEnter(e) {
342
346
  const { metaKey, ctrlKey, altKey, shiftKey, isComposing } = e;
347
+ const isModifierKey = metaKey || ctrlKey || altKey || shiftKey;
348
+
349
+ return !(isModifierKey || isComposing || this.compositionJustEnded);
350
+ },
351
+ onInputKeyup(e) {
352
+ const { key } = e;
343
353
 
344
354
  if (this.shouldShowSlashCommands) {
345
355
  e.preventDefault();
346
356
 
347
- if (e.key === 'Enter') {
357
+ if (key === 'Enter') {
348
358
  this.selectSlashCommand(this.activeCommandIndex);
349
- } else if (e.key === 'ArrowUp') {
359
+ } else if (key === 'ArrowUp') {
350
360
  this.prevCommand();
351
- } else if (e.key === 'ArrowDown') {
361
+ } else if (key === 'ArrowDown') {
352
362
  this.nextCommand();
353
363
  } else {
354
364
  this.activeCommandIndex = 0;
355
365
  }
356
- } else if (e.key === 'Enter' && !isComposing && !(metaKey || ctrlKey || altKey || shiftKey)) {
366
+ } else if (key === 'Enter' && this.sendChatPromptOnEnter(e)) {
357
367
  e.preventDefault();
358
368
 
359
369
  this.sendChatPrompt();
360
370
  }
371
+
372
+ this.compositionJustEnded = false;
361
373
  },
362
374
  prevCommand() {
363
375
  this.activeCommandIndex -= 1;
@@ -540,6 +552,7 @@ export default {
540
552
  autofocus
541
553
  @keydown.enter.exact.native.prevent
542
554
  @keyup.native="onInputKeyup"
555
+ @compositionend="compositionEnd"
543
556
  />
544
557
  </div>
545
558
  <template #append>