@gitlab/ui 66.29.0 → 66.30.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,10 @@
1
+ # [66.30.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.29.0...v66.30.0) (2023-10-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDuoChatConversation:** added component ([68017ef](https://gitlab.com/gitlab-org/gitlab-ui/commit/68017ef7707a5984e41fb93d2fd25cd53ab5e323))
7
+
1
8
  # [66.29.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.28.0...v66.29.0) (2023-10-12)
2
9
 
3
10
 
@@ -0,0 +1,81 @@
1
+ import GlDuoChatMessage from '../duo_chat_message/duo_chat_message';
2
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
+
4
+ const i18n = {
5
+ CONVERSATION_NEW_CHAT: 'New chat'
6
+ };
7
+ const isMessage = item => Boolean(item) && (item === null || item === void 0 ? void 0 : item.role);
8
+ const itemsValidator = items => items.every(isMessage);
9
+ var script = {
10
+ name: 'GlDuoChatConversation',
11
+ components: {
12
+ GlDuoChatMessage
13
+ },
14
+ props: {
15
+ /**
16
+ * Messages to display
17
+ */
18
+ messages: {
19
+ type: Array,
20
+ required: false,
21
+ default: () => [],
22
+ validator: itemsValidator
23
+ },
24
+ /**
25
+ * Whether to show the delimiter before this conversation
26
+ */
27
+ showDelimiter: {
28
+ type: Boolean,
29
+ required: false,
30
+ default: true
31
+ }
32
+ },
33
+ methods: {
34
+ onTrackFeedback(event) {
35
+ /**
36
+ * Notify listeners about the feedback form submission on a response message.
37
+ * @param {*} event An event, containing the feedback choices and the extended feedback text.
38
+ */
39
+ this.$emit('track-feedback', event);
40
+ }
41
+ },
42
+ i18n
43
+ };
44
+
45
+ /* script */
46
+ const __vue_script__ = script;
47
+
48
+ /* template */
49
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-display-flex gl-flex-direction-column gl-justify-content-end"},[(_vm.showDelimiter)?_c('div',{staticClass:"gl-my-5 gl-display-flex gl-align-items-center gl-text-gray-500 gl-gap-4",attrs:{"data-testid":"conversation-delimiter"}},[_c('hr',{staticClass:"gl-flex-grow-1"}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.$options.i18n.CONVERSATION_NEW_CHAT))]),_vm._v(" "),_c('hr',{staticClass:"gl-flex-grow-1"})]):_vm._e(),_vm._v(" "),_vm._l((_vm.messages),function(msg,index){return _c('gl-duo-chat-message',{key:((msg.role) + "-" + index),attrs:{"message":msg},on:{"track-feedback":_vm.onTrackFeedback}})})],2)};
50
+ var __vue_staticRenderFns__ = [];
51
+
52
+ /* style */
53
+ const __vue_inject_styles__ = undefined;
54
+ /* scoped */
55
+ const __vue_scope_id__ = undefined;
56
+ /* module identifier */
57
+ const __vue_module_identifier__ = undefined;
58
+ /* functional template */
59
+ const __vue_is_functional_template__ = false;
60
+ /* style inject */
61
+
62
+ /* style inject SSR */
63
+
64
+ /* style inject shadow dom */
65
+
66
+
67
+
68
+ const __vue_component__ = __vue_normalize__(
69
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
70
+ __vue_inject_styles__,
71
+ __vue_script__,
72
+ __vue_scope_id__,
73
+ __vue_is_functional_template__,
74
+ __vue_module_identifier__,
75
+ false,
76
+ undefined,
77
+ undefined,
78
+ undefined
79
+ );
80
+
81
+ export default __vue_component__;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 12 Oct 2023 07:48:44 GMT
3
+ * Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 12 Oct 2023 07:48:44 GMT
3
+ * Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 12 Oct 2023 07:48:45 GMT
3
+ * Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#fff";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 12 Oct 2023 07:48:44 GMT
3
+ * Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#000";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Thu, 12 Oct 2023 07:48:45 GMT
3
+ // Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
 
5
5
  $red-950: #fff4f3;
6
6
  $red-900: #fcf1ef;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Thu, 12 Oct 2023 07:48:44 GMT
3
+ // Generated on Thu, 12 Oct 2023 16:02:49 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "66.29.0",
3
+ "version": "66.30.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -94,7 +94,7 @@
94
94
  "@gitlab/eslint-plugin": "19.0.0",
95
95
  "@gitlab/fonts": "^1.2.0",
96
96
  "@gitlab/stylelint-config": "5.0.0",
97
- "@gitlab/svgs": "3.65.0",
97
+ "@gitlab/svgs": "3.66.0",
98
98
  "@rollup/plugin-commonjs": "^11.1.0",
99
99
  "@rollup/plugin-node-resolve": "^7.1.3",
100
100
  "@rollup/plugin-replace": "^2.3.2",
@@ -0,0 +1,8 @@
1
+ A component that lists messages in a conversation, and presents an optional delimiter to
2
+ mark the beginning of the conversation.
3
+
4
+ ## Usage
5
+
6
+ ```html
7
+ <gl-duo-chat-conversation :messages="messages" :show-delimeter="showDelimiter" />
8
+ ```
@@ -0,0 +1,46 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import { MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE } from '../../mock_data';
3
+ import GlDuoChatMessage from '../duo_chat_message/duo_chat_message.vue';
4
+ import GlDuoChatConversation from './duo_chat_conversation.vue';
5
+
6
+ describe('GlDuoChatConversation', () => {
7
+ let wrapper;
8
+
9
+ const findChatMessages = () => wrapper.findAllComponents(GlDuoChatMessage);
10
+ const findDelimiter = () => wrapper.find('[data-testid="conversation-delimiter"]');
11
+ const createComponent = ({ propsData = {} } = {}) => {
12
+ wrapper = shallowMount(GlDuoChatConversation, {
13
+ propsData,
14
+ });
15
+ };
16
+
17
+ describe('rendering', () => {
18
+ const messages = [MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE];
19
+
20
+ describe('default state', () => {
21
+ beforeEach(() => {
22
+ createComponent();
23
+ });
24
+
25
+ it('does not render messages by default', () => {
26
+ expect(findChatMessages().length).toBe(0);
27
+ });
28
+
29
+ it('does render the delimiter', () => {
30
+ expect(findDelimiter().exists()).toBe(true);
31
+ });
32
+ });
33
+
34
+ it('renders messages when messages are passed', () => {
35
+ createComponent({
36
+ propsData: { messages },
37
+ });
38
+ expect(findChatMessages().length).toBe(2);
39
+ });
40
+
41
+ it('does not render delimiter when showDelimiter = false', () => {
42
+ createComponent({ propsData: { messages, showDelimiter: false } });
43
+ expect(findDelimiter().exists()).toBe(false);
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,59 @@
1
+ import { MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE } from '../../mock_data';
2
+ import GlDuoChatConversation from './duo_chat_conversation.vue';
3
+ import readme from './duo_chat_conversation.md';
4
+
5
+ const defaultValue = (prop) => GlDuoChatConversation.props[prop].default;
6
+ const renderMarkdown = (content) => content;
7
+ const renderGFM = () => {};
8
+
9
+ const generateProps = ({ messages = [], showDelimiter = defaultValue('showDelimiter') } = {}) => ({
10
+ messages,
11
+ showDelimiter,
12
+ });
13
+
14
+ const Template = (args, { argTypes }) => ({
15
+ components: { GlDuoChatConversation },
16
+ props: Object.keys(argTypes),
17
+ provide: {
18
+ renderGFM,
19
+ renderMarkdown,
20
+ },
21
+ template: `
22
+ <gl-duo-chat-conversation :messages="messages" :show-delimiter="showDelimiter" />
23
+ `,
24
+ });
25
+
26
+ export const Default = Template.bind({});
27
+ Default.args = generateProps({
28
+ messages: [MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE],
29
+ });
30
+
31
+ export const MultipleConversations = (args, { argTypes }) => ({
32
+ components: { GlDuoChatConversation },
33
+ props: Object.keys(argTypes),
34
+ provide: {
35
+ renderGFM,
36
+ renderMarkdown,
37
+ },
38
+ template: `
39
+ <div>
40
+ <gl-duo-chat-conversation :messages="messages" :show-delimiter="false" />
41
+ <gl-duo-chat-conversation :messages="messages" :show-delimiter="true" />
42
+ </div>
43
+ `,
44
+ });
45
+ MultipleConversations.args = generateProps({
46
+ messages: [MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE],
47
+ });
48
+
49
+ export default {
50
+ title: 'experimental/duo/chat/duo-chat-conversation',
51
+ component: GlDuoChatConversation,
52
+ parameters: {
53
+ docs: {
54
+ description: {
55
+ component: readme,
56
+ },
57
+ },
58
+ },
59
+ };
@@ -0,0 +1,67 @@
1
+ <script>
2
+ import GlDuoChatMessage from '../duo_chat_message/duo_chat_message.vue';
3
+
4
+ const i18n = {
5
+ CONVERSATION_NEW_CHAT: 'New chat',
6
+ };
7
+
8
+ const isMessage = (item) => Boolean(item) && item?.role;
9
+
10
+ const itemsValidator = (items) => items.every(isMessage);
11
+
12
+ export default {
13
+ name: 'GlDuoChatConversation',
14
+ components: {
15
+ GlDuoChatMessage,
16
+ },
17
+ props: {
18
+ /**
19
+ * Messages to display
20
+ */
21
+ messages: {
22
+ type: Array,
23
+ required: false,
24
+ default: () => [],
25
+ validator: itemsValidator,
26
+ },
27
+ /**
28
+ * Whether to show the delimiter before this conversation
29
+ */
30
+ showDelimiter: {
31
+ type: Boolean,
32
+ required: false,
33
+ default: true,
34
+ },
35
+ },
36
+ methods: {
37
+ onTrackFeedback(event) {
38
+ /**
39
+ * Notify listeners about the feedback form submission on a response message.
40
+ * @param {*} event An event, containing the feedback choices and the extended feedback text.
41
+ */
42
+ this.$emit('track-feedback', event);
43
+ },
44
+ },
45
+ i18n,
46
+ };
47
+ </script>
48
+ <template>
49
+ <div class="gl-display-flex gl-flex-direction-column gl-justify-content-end">
50
+ <div
51
+ v-if="showDelimiter"
52
+ class="gl-my-5 gl-display-flex gl-align-items-center gl-text-gray-500 gl-gap-4"
53
+ data-testid="conversation-delimiter"
54
+ >
55
+ <hr class="gl-flex-grow-1" />
56
+ <span>{{ $options.i18n.CONVERSATION_NEW_CHAT }}</span>
57
+ <hr class="gl-flex-grow-1" />
58
+ </div>
59
+
60
+ <gl-duo-chat-message
61
+ v-for="(msg, index) in messages"
62
+ :key="`${msg.role}-${index}`"
63
+ :message="msg"
64
+ @track-feedback="onTrackFeedback"
65
+ />
66
+ </div>
67
+ </template>