@gitlab/ui 98.4.0 → 98.5.1

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,17 @@
1
+ ## [98.5.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v98.5.0...v98.5.1) (2024-10-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **Pagination:** Prevent clicks on prev and next links when disabled ([74b2a39](https://gitlab.com/gitlab-org/gitlab-ui/commit/74b2a396b41c6bb3adfb1dd39e95f8bbfc5fb890))
7
+
8
+ # [98.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v98.4.0...v98.5.0) (2024-10-25)
9
+
10
+
11
+ ### Features
12
+
13
+ * **DuoChatMessage:** add max height for code blocks in messages ([4493ca9](https://gitlab.com/gitlab-org/gitlab-ui/commit/4493ca9fca716aee2c4fb7b06abe0e90f60aa7e0))
14
+
1
15
  # [98.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v98.3.0...v98.4.0) (2024-10-24)
2
16
 
3
17
 
@@ -376,13 +376,13 @@ const __vue_script__ = script;
376
376
  var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isVisible)?_c('nav',{staticClass:"gl-pagination",attrs:{"aria-label":_vm.labelNav}},[_c('ul',{class:_vm.wrapperClasses},[_c('li',{class:{
377
377
  disabled: _vm.prevPageIsDisabled,
378
378
  'gl-flex-auto': _vm.isFillAlign,
379
- },attrs:{"aria-disabled":_vm.prevPageIsDisabled,"aria-hidden":_vm.prevPageIsDisabled,"data-testid":"gl-pagination-li"}},[_c(_vm.prevPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-pagination-item",attrs:{"data-testid":"gl-pagination-prev","aria-label":_vm.prevPageAriaLabel,"href":_vm.prevPageHref},on:{"click":function($event){return _vm.handlePrevious($event, _vm.value - 1)}}},[_vm._t("previous",function(){return [_c('gl-icon',{attrs:{"name":"chevron-left"}}),_vm._v(" "),_c('span',{staticClass:"gl-hidden sm:gl-block"},[_vm._v(_vm._s(_vm.prevText))])]},null,{ page: _vm.value - 1, disabled: _vm.prevPageIsDisabled })],2)],1),_vm._v(" "),_vm._l((_vm.visibleItems),function(item){return _c('li',{key:item.key,class:{
379
+ },attrs:{"aria-disabled":_vm.prevPageIsDisabled,"aria-hidden":_vm.prevPageIsDisabled,"data-testid":"gl-pagination-li"}},[_c(_vm.prevPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-pagination-item",attrs:{"data-testid":"gl-pagination-prev","aria-label":_vm.prevPageAriaLabel,"href":_vm.prevPageHref},on:{"click":function($event){!_vm.prevPageIsDisabled ? _vm.handlePrevious($event, _vm.value - 1) : null;}}},[_vm._t("previous",function(){return [_c('gl-icon',{attrs:{"name":"chevron-left"}}),_vm._v(" "),_c('span',{staticClass:"gl-hidden sm:gl-block"},[_vm._v(_vm._s(_vm.prevText))])]},null,{ page: _vm.value - 1, disabled: _vm.prevPageIsDisabled })],2)],1),_vm._v(" "),_vm._l((_vm.visibleItems),function(item){return _c('li',{key:item.key,class:{
380
380
  disabled: item.disabled,
381
381
  'gl-flex-auto': _vm.isFillAlign,
382
382
  },attrs:{"data-testid":"gl-pagination-li"}},[_c(item.component,_vm._g(_vm._b({tag:"component",staticClass:"gl-pagination-item",attrs:{"data-testid":"gl-pagination-item","size":"md","aria-disabled":item.disabled}},'component',item.attrs,false),item.listeners),[_vm._t(item.slot,function(){return [_vm._v(_vm._s(item.content))]},null,item.slotData)],2)],1)}),_vm._v(" "),_c('li',{class:{
383
383
  disabled: _vm.nextPageIsDisabled,
384
384
  'gl-flex-auto': _vm.isFillAlign,
385
- },attrs:{"aria-disabled":_vm.nextPageIsDisabled,"aria-hidden":_vm.nextPageIsDisabled,"data-testid":"gl-pagination-li"}},[_c(_vm.nextPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-pagination-item",attrs:{"data-testid":"gl-pagination-next","aria-label":_vm.nextPageAriaLabel,"href":_vm.nextPageHref},on:{"click":function($event){return _vm.handleNext($event, _vm.value + 1)}}},[_vm._t("next",function(){return [_c('span',{staticClass:"gl-hidden sm:gl-block"},[_vm._v(_vm._s(_vm.nextText))]),_vm._v(" "),_c('gl-icon',{attrs:{"name":"chevron-right"}})]},null,{ page: _vm.value + 1, disabled: _vm.nextPageIsDisabled })],2)],1)],2)]):_vm._e()};
385
+ },attrs:{"aria-disabled":_vm.nextPageIsDisabled,"aria-hidden":_vm.nextPageIsDisabled,"data-testid":"gl-pagination-li"}},[_c(_vm.nextPageIsDisabled ? 'span' : 'a',{tag:"component",staticClass:"gl-pagination-item",attrs:{"data-testid":"gl-pagination-next","aria-label":_vm.nextPageAriaLabel,"href":_vm.nextPageHref},on:{"click":function($event){!_vm.nextPageIsDisabled ? _vm.handleNext($event, _vm.value + 1) : null;}}},[_vm._t("next",function(){return [_c('span',{staticClass:"gl-hidden sm:gl-block"},[_vm._v(_vm._s(_vm.nextText))]),_vm._v(" "),_c('gl-icon',{attrs:{"name":"chevron-right"}})]},null,{ page: _vm.value + 1, disabled: _vm.nextPageIsDisabled })],2)],1)],2)]):_vm._e()};
386
386
  var __vue_staticRenderFns__ = [];
387
387
 
388
388
  /* style */
@@ -0,0 +1,5 @@
1
+ const DUO_CODE_SCRIM_TOP_CLASS = 'scrim-top';
2
+ const DUO_CODE_SCRIM_BOTTOM_CLASS = 'scrim-bottom';
3
+ const DUO_CODE_SCRIM_OFFSET = 16;
4
+
5
+ export { DUO_CODE_SCRIM_BOTTOM_CLASS, DUO_CODE_SCRIM_OFFSET, DUO_CODE_SCRIM_TOP_CLASS };
@@ -1,3 +1,4 @@
1
+ import throttle from 'lodash/throttle';
1
2
  import GlIcon from '../../../../../base/icon/icon';
2
3
  import GlLoadingIcon from '../../../../../base/loading_icon/loading_icon';
3
4
  import { GlTooltipDirective } from '../../../../../../directives/tooltip';
@@ -13,6 +14,7 @@ import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
13
14
  import { CopyCodeElement } from './copy_code_element';
14
15
  import { InsertCodeSnippetElement } from './insert_code_snippet_element';
15
16
  import { concatUntilEmpty } from './utils';
17
+ import { DUO_CODE_SCRIM_BOTTOM_CLASS, DUO_CODE_SCRIM_OFFSET, DUO_CODE_SCRIM_TOP_CLASS } from './constants';
16
18
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
17
19
 
18
20
  const i18n = {
@@ -195,6 +197,7 @@ var script = {
195
197
  if (!this.isChunk && this.$refs.content) {
196
198
  this.$nextTick(this.renderGFM(this.$refs.content));
197
199
  }
200
+ this.detectScrollableCodeBlocks();
198
201
  },
199
202
  logEvent(e) {
200
203
  this.$emit('track-feedback', {
@@ -218,6 +221,27 @@ var script = {
218
221
  messageId: this.message.id,
219
222
  contextItem
220
223
  });
224
+ },
225
+ detectScrollableCodeBlocks() {
226
+ const codeBlocks = document.querySelectorAll('.duo-chat-message pre');
227
+ codeBlocks.forEach(e => {
228
+ if (e.scrollHeight > e.offsetHeight) {
229
+ e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
230
+ e.addEventListener('scroll', throttle(() => this.toggleScrolling(e), 200));
231
+ }
232
+ });
233
+ },
234
+ toggleScrolling(e) {
235
+ if (e.scrollHeight - e.scrollTop <= e.offsetHeight + DUO_CODE_SCRIM_OFFSET) {
236
+ e.classList.remove(DUO_CODE_SCRIM_BOTTOM_CLASS);
237
+ } else {
238
+ e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
239
+ }
240
+ if (e.scrollTop > DUO_CODE_SCRIM_OFFSET) {
241
+ e.classList.add(DUO_CODE_SCRIM_TOP_CLASS);
242
+ } else {
243
+ e.classList.remove(DUO_CODE_SCRIM_TOP_CLASS);
244
+ }
221
245
  }
222
246
  }
223
247
  };