@gitlab/ui 68.6.0 → 68.8.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [68.8.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v68.7.0...v68.8.0) (2023-11-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlBanner:** Add gray background ([5103460](https://gitlab.com/gitlab-org/gitlab-ui/commit/5103460b8601edd25e1af69f38612cea0a847f1a))
7
+
8
+ # [68.7.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v68.6.0...v68.7.0) (2023-11-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlDuoChatMessage:** added copy-code button ([3133d60](https://gitlab.com/gitlab-org/gitlab-ui/commit/3133d60d6004db689b4315fcc034774a4b53dac0))
14
+
1
15
  # [68.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v68.5.0...v68.6.0) (2023-11-15)
2
16
 
3
17
 
@@ -109,7 +109,11 @@ var script = {
109
109
  const __vue_script__ = script;
110
110
 
111
111
  /* template */
112
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-card',{staticClass:"gl-pl-6 gl-pr-8 gl-py-6",class:{ 'gl-banner-introduction': _vm.isIntroducing, 'gl-border-none!': _vm.embedded },attrs:{"body-class":"gl-display-flex gl-p-0!"}},[(_vm.svgPath)?_c('div',{staticClass:"gl-banner-illustration"},[_c('img',{attrs:{"src":_vm.svgPath,"alt":""}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-banner-content"},[_c('h2',{staticClass:"gl-banner-title"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),_vm._t("default"),_vm._v(" "),_c('gl-button',_vm._b({attrs:{"variant":"confirm","category":"primary","data-testid":"gl-banner-primary-button","href":_vm.buttonLink},on:{"click":_vm.primaryButtonClicked}},'gl-button',_vm.buttonAttributes,false),[_vm._v(_vm._s(_vm.buttonText))]),_vm._v(" "),_vm._t("actions")],2),_vm._v(" "),_c('close-button',{staticClass:"gl-banner-close",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.handleClose}})],1)};
112
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-card',{staticClass:"gl-pl-6 gl-pr-8 gl-py-6",class:{
113
+ 'gl-banner-introduction': _vm.isIntroducing,
114
+ 'gl-border-none!': _vm.embedded,
115
+ 'gl-bg-gray-10!': !_vm.isIntroducing,
116
+ },attrs:{"body-class":"gl-display-flex gl-p-0!"}},[(_vm.svgPath)?_c('div',{staticClass:"gl-banner-illustration"},[_c('img',{attrs:{"src":_vm.svgPath,"alt":""}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-banner-content"},[_c('h2',{staticClass:"gl-banner-title"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),_vm._t("default"),_vm._v(" "),_c('gl-button',_vm._b({attrs:{"variant":"confirm","category":"primary","data-testid":"gl-banner-primary-button","href":_vm.buttonLink},on:{"click":_vm.primaryButtonClicked}},'gl-button',_vm.buttonAttributes,false),[_vm._v(_vm._s(_vm.buttonText))]),_vm._v(" "),_vm._t("actions")],2),_vm._v(" "),_c('close-button',{staticClass:"gl-banner-close",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.handleClose}})],1)};
113
117
  var __vue_staticRenderFns__ = [];
114
118
 
115
119
  /* style */
@@ -0,0 +1,35 @@
1
+ import iconsPath from '@gitlab/svgs/dist/icons.svg';
2
+
3
+ const createButton = () => {
4
+ const button = document.createElement('button');
5
+ button.type = 'button';
6
+ button.classList.add('btn', 'btn-default', 'btn-md', 'gl-button', 'btn-default-secondary', 'btn-icon');
7
+ button.dataset.title = 'Copy to clipboard';
8
+
9
+ // Create an SVG element with the correct namespace
10
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
11
+ svg.setAttribute('role', 'img');
12
+ svg.setAttribute('aria-hidden', 'true');
13
+ svg.classList.add('gl-button-icon', 'gl-icon', 's16');
14
+
15
+ // Create a 'use' element with the correct namespace
16
+ const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
17
+ use.setAttribute('href', `${iconsPath}#copy-to-clipboard`);
18
+ svg.appendChild(use);
19
+ button.appendChild(svg);
20
+ return button;
21
+ };
22
+ class CopyCodeElement extends HTMLElement {
23
+ constructor() {
24
+ super();
25
+ const btn = createButton();
26
+ const wrapper = this.parentNode;
27
+ this.appendChild(btn);
28
+ btn.addEventListener('click', async () => {
29
+ const textToCopy = wrapper.innerText;
30
+ await navigator.clipboard.writeText(textToCopy);
31
+ });
32
+ }
33
+ }
34
+
35
+ export { CopyCodeElement };
@@ -2,6 +2,7 @@ import GlDuoUserFeedback from '../../../user_feedback/user_feedback';
2
2
  import { SafeHtmlDirective } from '../../../../../../directives/safe_html/safe_html';
3
3
  import { MESSAGE_MODEL_ROLES } from '../../constants';
4
4
  import DocumentationSources from '../duo_chat_message_sources/duo_chat_message_sources';
5
+ import { CopyCodeElement } from './copy_code_element';
5
6
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
6
7
 
7
8
  const concatIndicesUntilEmpty = arr => {
@@ -65,6 +66,9 @@ var script = {
65
66
  * Is intentionally non-reactive
66
67
  */
67
68
  this.messageChunks = [];
69
+ if (!customElements.get('copy-code')) {
70
+ customElements.define('copy-code', CopyCodeElement);
71
+ }
68
72
  },
69
73
  mounted() {
70
74
  this.messageContent = this.content;