@gitlab/ui 66.25.0 → 66.26.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/charts/legend/legend.js +1 -1
  3. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +128 -0
  4. package/dist/components/experimental/duo/chat/mock_data.js +41 -3
  5. package/dist/index.css +2 -2
  6. package/dist/index.css.map +1 -1
  7. package/dist/tokens/css/tokens.css +1 -1
  8. package/dist/tokens/css/tokens.dark.css +1 -1
  9. package/dist/tokens/js/tokens.dark.js +1 -1
  10. package/dist/tokens/js/tokens.js +1 -1
  11. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  12. package/dist/tokens/scss/_tokens.scss +1 -1
  13. package/dist/utils/charts/constants.js +1 -1
  14. package/package.json +15 -15
  15. package/src/components/charts/legend/legend.scss +34 -19
  16. package/src/components/charts/legend/legend.stories.js +41 -4
  17. package/src/components/charts/legend/legend.vue +1 -1
  18. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.md +60 -0
  19. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +18 -0
  20. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.spec.js +381 -0
  21. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.stories.js +45 -0
  22. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +107 -0
  23. package/src/components/experimental/duo/chat/mock_data.js +45 -2
  24. package/src/scss/components.scss +1 -0
  25. package/src/utils/charts/constants.js +2 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 05 Oct 2023 10:55:11 GMT
3
+ * Generated on Tue, 10 Oct 2023 19:49:13 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 05 Oct 2023 10:55:11 GMT
3
+ * Generated on Tue, 10 Oct 2023 19:49:14 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 05 Oct 2023 10:55:11 GMT
3
+ * Generated on Tue, 10 Oct 2023 19:49:14 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, 05 Oct 2023 10:55:11 GMT
3
+ * Generated on Tue, 10 Oct 2023 19:49:13 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, 05 Oct 2023 10:55:11 GMT
3
+ // Generated on Tue, 10 Oct 2023 19:49:14 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, 05 Oct 2023 10:55:11 GMT
3
+ // Generated on Tue, 10 Oct 2023 19:49:14 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
@@ -65,7 +65,7 @@ const CHART_TYPE_BAR = 'bar';
65
65
  const CHART_TYPE_LINE = 'line';
66
66
 
67
67
  // Constants for height "auto"
68
- const HEIGHT_AUTO_CLASSES = 'gl-display-flex gl-flex-direction-column gl-h-full';
68
+ const HEIGHT_AUTO_CLASSES = 'gl-chart-h-auto gl-display-flex gl-flex-direction-column gl-h-full';
69
69
  const HEIGHT_AUTO_HORIZONTAL_LAYOUT_CLASSES = 'gl-display-flex gl-h-full';
70
70
 
71
71
  export { ANNOTATIONS_COMPONENT_TYPE, ANNOTATIONS_SERIES_NAME, ANNOTATION_TOOLTIP_TOP_OFFSET, CHART_TYPE_BAR, CHART_TYPE_LINE, DATA_TOOLTIP_LEFT_OFFSET, HEIGHT_AUTO_CLASSES, HEIGHT_AUTO_HORIZONTAL_LAYOUT_CLASSES, LEGEND_AVERAGE_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, TOOLTIP_LEFT_OFFSET, arrowSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "66.25.0",
3
+ "version": "66.26.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -98,18 +98,18 @@
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",
101
- "@storybook/addon-a11y": "7.4.5",
102
- "@storybook/addon-docs": "7.4.5",
103
- "@storybook/addon-essentials": "7.4.5",
104
- "@storybook/addon-storyshots": "7.4.5",
105
- "@storybook/addon-storyshots-puppeteer": "7.4.5",
106
- "@storybook/addon-viewport": "7.4.5",
107
- "@storybook/builder-webpack5": "7.4.5",
108
- "@storybook/theming": "7.4.5",
109
- "@storybook/vue": "7.4.5",
110
- "@storybook/vue-webpack5": "7.4.5",
111
- "@storybook/vue3": "7.4.5",
112
- "@storybook/vue3-webpack5": "7.4.5",
101
+ "@storybook/addon-a11y": "7.4.6",
102
+ "@storybook/addon-docs": "7.4.6",
103
+ "@storybook/addon-essentials": "7.4.6",
104
+ "@storybook/addon-storyshots": "7.4.6",
105
+ "@storybook/addon-storyshots-puppeteer": "7.4.6",
106
+ "@storybook/addon-viewport": "7.4.6",
107
+ "@storybook/builder-webpack5": "7.4.6",
108
+ "@storybook/theming": "7.4.6",
109
+ "@storybook/vue": "7.4.6",
110
+ "@storybook/vue-webpack5": "7.4.6",
111
+ "@storybook/vue3": "7.4.6",
112
+ "@storybook/vue3-webpack5": "7.4.6",
113
113
  "@vue/compat": "^3.2.40",
114
114
  "@vue/compiler-sfc": "^3.2.40",
115
115
  "@vue/test-utils": "1.3.0",
@@ -126,7 +126,7 @@
126
126
  "cypress-axe": "^1.4.0",
127
127
  "dompurify": "^3.0.0",
128
128
  "emoji-regex": "^10.0.0",
129
- "eslint": "8.50.0",
129
+ "eslint": "8.51.0",
130
130
  "eslint-import-resolver-jest": "3.0.2",
131
131
  "eslint-plugin-cypress": "2.15.1",
132
132
  "eslint-plugin-storybook": "0.6.14",
@@ -160,7 +160,7 @@
160
160
  "sass-loader": "^10.2.0",
161
161
  "sass-true": "^6.1.0",
162
162
  "start-server-and-test": "^1.10.6",
163
- "storybook": "7.4.5",
163
+ "storybook": "7.4.6",
164
164
  "storybook-dark-mode": "3.0.1",
165
165
  "style-dictionary": "^3.8.0",
166
166
  "stylelint": "15.10.2",
@@ -1,8 +1,37 @@
1
+ // shorter height by half a line, so table body is cut off,
2
+ // suggesting there's more to scroll
3
+ $legend-body-h: $gl-spacing-scale-13 - $gl-spacing-scale-4;
4
+
5
+ .gl-legend {
6
+ @include gl-relative;
7
+ }
8
+
9
+ .gl-chart-h-auto {
10
+ .gl-legend-inline {
11
+ // match the height of gl-legend-tabular (header + body)
12
+ max-height: $gl-line-height-24 + $legend-body-h;
13
+ @include gl-overflow-auto;
14
+ }
15
+ }
16
+
17
+ .gl-legend-tabular,
18
+ .gl-chart-h-auto .gl-legend-inline {
19
+ &::after {
20
+ background-image: linear-gradient(to bottom, $transparent-rgba, $white);
21
+ @include gl-bottom-0;
22
+ @include gl-content-empty;
23
+ @include gl-display-block;
24
+ @include gl-h-4;
25
+ @include gl-absolute;
26
+ @include gl-w-full;
27
+ }
28
+ }
29
+
1
30
  .gl-legend-inline {
2
- @include gl-display-flex;
3
- @include gl-flex-wrap;
4
- @include gl-flex-shrink-0;
5
- @include gl-text-gray-900;
31
+ @include gl-display-flex;
32
+ @include gl-flex-wrap;
33
+ @include gl-flex-shrink-0;
34
+ @include gl-text-gray-900;
6
35
 
7
36
  .gl-legend-inline-series {
8
37
  @include gl-display-flex;
@@ -23,18 +52,6 @@
23
52
  }
24
53
 
25
54
  .gl-legend-tabular {
26
- @include gl-relative;
27
-
28
- &::after {
29
- background-image: linear-gradient(to bottom, $transparent-rgba, $white);
30
- @include gl-bottom-0;
31
- @include gl-content-empty;
32
- @include gl-display-block;
33
- @include gl-h-4;
34
- @include gl-absolute;
35
- @include gl-w-full;
36
- }
37
-
38
55
  .gl-legend-tabular-header {
39
56
  @include gl-display-flex;
40
57
  @include gl-justify-content-end;
@@ -56,9 +73,7 @@
56
73
  }
57
74
 
58
75
  .gl-legend-tabular-body {
59
- // shorter height by half a line, so table body is cut off,
60
- // suggesting there's more to scroll
61
- height: $gl-spacing-scale-13 - $gl-spacing-scale-4;
76
+ height: $legend-body-h;
62
77
  @include gl-overflow-y-auto;
63
78
 
64
79
  > *:nth-child(odd) {
@@ -1,5 +1,5 @@
1
1
  import { GlChart, GlChartLegend } from '../../../charts';
2
- import { LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
2
+ import { HEIGHT_AUTO_CLASSES, LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
3
3
  import { generateSeriesData } from '../../../utils/charts/story_config';
4
4
  import {
5
5
  SERIES_NAME_SHORT,
@@ -43,13 +43,14 @@ const generateSeriesInfo = (amount, nameType) => {
43
43
  }));
44
44
  };
45
45
 
46
- const generateTemplate = (type) => {
46
+ const generateTemplate = (type, wrapperAttrs = {}, chartAttrs = {}) => {
47
47
  const layoutTypeAttribute =
48
48
  type === LEGEND_LAYOUT_TABLE ? `:layout="'${LEGEND_LAYOUT_TABLE}'"` : '';
49
49
 
50
- return `<div>
50
+ return `<div v-bind='${JSON.stringify(wrapperAttrs)}'>
51
51
  <gl-chart
52
52
  :options="$options.options"
53
+ v-bind='${JSON.stringify(chartAttrs)}'
53
54
  @created="onCreated"
54
55
  />
55
56
  <gl-chart-legend
@@ -93,7 +94,7 @@ const getStoryOptions = (seriesLength, seriesNameType, legendLayoutType) => {
93
94
  ...baseStoryOptions,
94
95
  options: generateOptions(seriesLength, seriesNameType),
95
96
  seriesInfo: generateSeriesInfo(seriesLength, seriesNameType),
96
- template: legendLayoutType ? generateTemplate(legendLayoutType) : generateTemplate(),
97
+ template: generateTemplate(legendLayoutType),
97
98
  };
98
99
  };
99
100
 
@@ -110,6 +111,24 @@ export const DefaultWithLongSeriesNames = () => getStoryOptions(10, SERIES_NAME_
110
111
  export const DefaultWithLongSeriesNamesAndNoSpaces = () =>
111
112
  getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES);
112
113
 
114
+ export const DefaultWithOverflowingFixedContainerHeight = () => {
115
+ const storyOptions = getStoryOptions(50, SERIES_NAME_LONG_WITHOUT_SPACES, null);
116
+
117
+ storyOptions.template = generateTemplate(
118
+ null,
119
+ {
120
+ class: HEIGHT_AUTO_CLASSES, // line, area, heatmap etc charts all have these classes on the wrapper element in auto height mode
121
+ style: 'height: 400px; overflow: hidden; outline: 1px solid red;', // Simulate being inside a dashboard panel with fixed height and no overflow
122
+ },
123
+ {
124
+ height: 'auto',
125
+ class: 'gl-flex-grow-1', // line, area, heatmap etc charts all have gl-flex-grow-1 on the <gl-chart> element in auto height mode
126
+ }
127
+ );
128
+
129
+ return storyOptions;
130
+ };
131
+
113
132
  export const WithTabularLayout = () => getStoryOptions(10, SERIES_NAME_SHORT, LEGEND_LAYOUT_TABLE);
114
133
  export const WithTabularLayoutAndDisabledLegendItem = () => {
115
134
  const storyOptions = getStoryOptions(10, SERIES_NAME_SHORT, LEGEND_LAYOUT_TABLE);
@@ -123,6 +142,24 @@ export const WithTabularLayoutAndLongSeriesNames = () =>
123
142
  export const WithTabularLayoutAndLongSeriesNamesWithNoSpaces = () =>
124
143
  getStoryOptions(10, SERIES_NAME_LONG_WITHOUT_SPACES, LEGEND_LAYOUT_TABLE);
125
144
 
145
+ export const WithTabularOverflowingFixedContainerHeight = () => {
146
+ const storyOptions = getStoryOptions(50, SERIES_NAME_LONG_WITHOUT_SPACES, LEGEND_LAYOUT_TABLE);
147
+
148
+ storyOptions.template = generateTemplate(
149
+ LEGEND_LAYOUT_TABLE,
150
+ {
151
+ class: HEIGHT_AUTO_CLASSES, // line, area, heatmap etc charts all have these classes on the wrapper element in auto height mode
152
+ style: 'height: 400px; overflow: hidden; outline: 1px solid red;', // Simulate being inside a dashboard panel with fixed height and no overflow
153
+ },
154
+ {
155
+ height: 'auto',
156
+ class: 'gl-flex-grow-1', // line, area, heatmap etc charts all have gl-flex-grow-1 on the <gl-chart> element in auto height mode
157
+ }
158
+ );
159
+
160
+ return storyOptions;
161
+ };
162
+
126
163
  export default {
127
164
  title: 'charts/chart-legend',
128
165
  component: GlChartLegend,
@@ -172,7 +172,7 @@ export default {
172
172
  </script>
173
173
 
174
174
  <template>
175
- <div data-testid="gl-chart-legend">
175
+ <div class="gl-legend" data-testid="gl-chart-legend">
176
176
  <template v-if="layout === $options.legendLayoutTypes.LEGEND_LAYOUT_INLINE">
177
177
  <div class="gl-legend-inline">
178
178
  <div
@@ -0,0 +1,60 @@
1
+ The component represents a Duo Chat message.
2
+
3
+ ## Usage
4
+
5
+ ```html
6
+ <gl-duo-chat-message :message="message" />
7
+ ```
8
+
9
+ ## Pretty rendering message content
10
+
11
+ There are two ways of pretty-rendering a message's content in the component:
12
+
13
+ - dependency injection, providing functions to convert raw markdown into HTML,
14
+ - sending `contentHtml` prop as part of the `message` property,
15
+
16
+ ### Injecting functions
17
+
18
+ To inject the `renderMarkdown` function, which converts raw markdown into proper HTML,
19
+ the component relies on [dependency injection, using `provide`/`inject` options](https://docs.gitlab.com/ee/development/fe_guide/vue.html#provide-and-inject).
20
+ The component expects a reference to a function, converting raw markdown into HTML
21
+ to be _provided_ by a consumer.
22
+ [The example implementation](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/notes/utils.js#L22-24)
23
+
24
+ ### `contentHtml`
25
+
26
+ This approach is self-explanatory and is used when raw markdown can be converted to HTML on the server
27
+ before the message is returned to the client. Here's an example of a message's structure where markdown
28
+ has been generated on the server and sent down in the `contentHtml` property:
29
+
30
+ ```javascript
31
+ {
32
+ content: '_Duo Chat message_ coming from AI',
33
+ contentHtml: '<p><em>Duo Chat message</em> coming from AI</p>',
34
+ role: 'assistant',
35
+ ...
36
+ }
37
+ ```
38
+
39
+ ## GitLab Flavored Markdown (GLFM)
40
+
41
+ In most cases, it's not enough to just convert raw markdown into HTML. Messages also require the
42
+ markup to support [GitLab Flavored Markdown (GLFM)](https://docs.gitlab.com/ee/user/markdown.html).
43
+ For this, the component relies on another dependency injection (in addition to `renderMarkdown`)
44
+ expecting a reference to the `renderGFM` function, decorating an HTML element with GLFM to be
45
+ _provided_ by a consumer.
46
+ [The example implementation](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/behaviors/markdown/render_gfm.js#L19-52)
47
+
48
+ ## The underlying use of the `GlDuoUserFeedback` component
49
+
50
+ The component integrates the [`GlDuoUserFeedback`](/story/experimental-duo-user-feedback--default)
51
+ component to track user feedback on the AI-generated responses. Note that the `GlDuoChatMessage`
52
+ component renders the default state of `GlDuoUserFeedback` component, not allowing to override
53
+ the slots in that underlying component.
54
+
55
+ ### Tracking User Feedback for a response
56
+
57
+ The component emits the `track-feedback` event, a proxy of the `feedback` event emitted by
58
+ the `GlDuoUserFeedback` component. Please refer to
59
+ [the documentation on that component](/story/experimental-duo-user-feedback--docs#listening-to-the-feedback-form-submission)
60
+ when processing feedback from users.
@@ -0,0 +1,18 @@
1
+ .duo-chat-message {
2
+ max-width: 90%;
3
+
4
+ code {
5
+ @include gl-bg-gray-100;
6
+ }
7
+
8
+ pre code {
9
+ @include gl-font-sm;
10
+ @include gl-line-height-1;
11
+ @include gl-bg-transparent;
12
+ white-space: inherit;
13
+ }
14
+
15
+ p:last-of-type {
16
+ @include gl-mb-0;
17
+ }
18
+ }