@gitlab/ui 72.11.1 → 72.12.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 (223) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/tokens/css/tokens.css +1 -1
  3. package/dist/tokens/css/tokens.dark.css +1 -1
  4. package/dist/tokens/js/tokens.dark.js +1 -1
  5. package/dist/tokens/js/tokens.js +1 -1
  6. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  7. package/dist/tokens/scss/_tokens.scss +1 -1
  8. package/package.json +1 -1
  9. package/src/internal/color_contrast/color_contrast.md +8 -0
  10. package/src/internal/color_contrast/color_contrast.spec.js +34 -0
  11. package/src/internal/color_contrast/color_contrast.stories.js +41 -0
  12. package/src/internal/color_contrast/color_contrast.vue +52 -0
  13. package/src/tokens/color.dark.tokens.stories.js +36 -22
  14. package/src/tokens/color.data_viz.dark.tokens.stories.js +13 -30
  15. package/src/tokens/color.data_viz.tokens.stories.js +13 -30
  16. package/src/tokens/color.theme.dark.tokens.stories.js +15 -30
  17. package/src/tokens/color.theme.tokens.stories.js +15 -30
  18. package/src/tokens/color.tokens.stories.js +36 -22
  19. package/src/tokens/color.transparency.tokens.stories.js +9 -12
  20. package/src/tokens/common_story_options.js +22 -80
  21. package/src/utils/constants.js +25 -0
  22. package/src/utils/utils.js +21 -1
  23. package/dist/charts.js +0 -14
  24. package/dist/components/base/accordion/accordion.js +0 -73
  25. package/dist/components/base/accordion/accordion_item.js +0 -133
  26. package/dist/components/base/alert/alert.js +0 -222
  27. package/dist/components/base/avatar/avatar.js +0 -160
  28. package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -107
  29. package/dist/components/base/avatar_link/avatar_link.js +0 -47
  30. package/dist/components/base/avatars_inline/avatars_inline.js +0 -119
  31. package/dist/components/base/badge/badge.js +0 -105
  32. package/dist/components/base/banner/banner.js +0 -139
  33. package/dist/components/base/breadcrumb/breadcrumb.js +0 -122
  34. package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -73
  35. package/dist/components/base/broadcast_message/broadcast_message.js +0 -112
  36. package/dist/components/base/broadcast_message/constants.js +0 -5
  37. package/dist/components/base/button/button.js +0 -151
  38. package/dist/components/base/button_group/button_group.js +0 -47
  39. package/dist/components/base/card/card.js +0 -71
  40. package/dist/components/base/carousel/carousel.js +0 -48
  41. package/dist/components/base/carousel/carousel_slide.js +0 -47
  42. package/dist/components/base/collapse/collapse.js +0 -59
  43. package/dist/components/base/datepicker/datepicker.js +0 -386
  44. package/dist/components/base/daterange_picker/daterange_picker.js +0 -288
  45. package/dist/components/base/drawer/drawer.js +0 -127
  46. package/dist/components/base/dropdown/dropdown.js +0 -261
  47. package/dist/components/base/dropdown/dropdown_divider.js +0 -48
  48. package/dist/components/base/dropdown/dropdown_form.js +0 -48
  49. package/dist/components/base/dropdown/dropdown_item.js +0 -131
  50. package/dist/components/base/dropdown/dropdown_section_header.js +0 -48
  51. package/dist/components/base/dropdown/dropdown_text.js +0 -48
  52. package/dist/components/base/filtered_search/common_story_options.js +0 -14
  53. package/dist/components/base/filtered_search/filtered_search.js +0 -388
  54. package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -89
  55. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -138
  56. package/dist/components/base/filtered_search/filtered_search_term.js +0 -203
  57. package/dist/components/base/filtered_search/filtered_search_token.js +0 -384
  58. package/dist/components/base/filtered_search/filtered_search_token_segment.js +0 -420
  59. package/dist/components/base/filtered_search/filtered_search_utils.js +0 -242
  60. package/dist/components/base/form/form.js +0 -49
  61. package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -78
  62. package/dist/components/base/form/form_checkbox/form_checkbox_group.js +0 -60
  63. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -79
  64. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -138
  65. package/dist/components/base/form/form_checkbox_tree/models/constants.js +0 -12
  66. package/dist/components/base/form/form_checkbox_tree/models/node.js +0 -51
  67. package/dist/components/base/form/form_checkbox_tree/models/tree.js +0 -199
  68. package/dist/components/base/form/form_combobox/constants.js +0 -55
  69. package/dist/components/base/form/form_combobox/form_combobox.js +0 -230
  70. package/dist/components/base/form/form_date/form_date.js +0 -143
  71. package/dist/components/base/form/form_fields/form_field_validator.js +0 -93
  72. package/dist/components/base/form/form_fields/form_fields.js +0 -214
  73. package/dist/components/base/form/form_fields/mappers.js +0 -13
  74. package/dist/components/base/form/form_fields/validators.js +0 -48
  75. package/dist/components/base/form/form_group/form_group.js +0 -97
  76. package/dist/components/base/form/form_input/form_input.js +0 -121
  77. package/dist/components/base/form/form_input_group/form_input_group.js +0 -108
  78. package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -41
  79. package/dist/components/base/form/form_radio/form_radio.js +0 -65
  80. package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -78
  81. package/dist/components/base/form/form_select/constants.js +0 -12
  82. package/dist/components/base/form/form_select/form_select.js +0 -82
  83. package/dist/components/base/form/form_text/form_text.js +0 -38
  84. package/dist/components/base/form/form_textarea/form_textarea.js +0 -112
  85. package/dist/components/base/form/input_group_text/input_group_text.js +0 -48
  86. package/dist/components/base/icon/icon.js +0 -111
  87. package/dist/components/base/infinite_scroll/infinite_scroll.js +0 -197
  88. package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -151
  89. package/dist/components/base/label/label.js +0 -163
  90. package/dist/components/base/link/link.js +0 -50
  91. package/dist/components/base/loading_icon/loading_icon.js +0 -111
  92. package/dist/components/base/markdown/markdown.js +0 -52
  93. package/dist/components/base/modal/modal.js +0 -204
  94. package/dist/components/base/nav/nav.js +0 -48
  95. package/dist/components/base/nav/nav_item.js +0 -48
  96. package/dist/components/base/nav/nav_item_dropdown.js +0 -62
  97. package/dist/components/base/navbar/navbar.js +0 -48
  98. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -453
  99. package/dist/components/base/new_dropdowns/base_dropdown/constants.js +0 -4
  100. package/dist/components/base/new_dropdowns/constants.js +0 -21
  101. package/dist/components/base/new_dropdowns/disclosure/constants.js +0 -8
  102. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +0 -370
  103. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +0 -110
  104. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +0 -143
  105. package/dist/components/base/new_dropdowns/disclosure/mock_data.js +0 -147
  106. package/dist/components/base/new_dropdowns/disclosure/utils.js +0 -39
  107. package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -767
  108. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -58
  109. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -91
  110. package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +0 -93
  111. package/dist/components/base/new_dropdowns/listbox/mock_data.js +0 -118
  112. package/dist/components/base/new_dropdowns/listbox/utils.js +0 -34
  113. package/dist/components/base/paginated_list/paginated_list.js +0 -180
  114. package/dist/components/base/pagination/pagination.js +0 -399
  115. package/dist/components/base/path/data.js +0 -34
  116. package/dist/components/base/path/path.js +0 -189
  117. package/dist/components/base/popover/popover.js +0 -110
  118. package/dist/components/base/progress_bar/progress_bar.js +0 -48
  119. package/dist/components/base/search_box_by_click/search_box_by_click.js +0 -235
  120. package/dist/components/base/search_box_by_type/search_box_by_type.js +0 -167
  121. package/dist/components/base/segmented_control/segmented_control.js +0 -109
  122. package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -224
  123. package/dist/components/base/sorting/sorting.js +0 -171
  124. package/dist/components/base/sorting/sorting_item.js +0 -109
  125. package/dist/components/base/table/constants.js +0 -5
  126. package/dist/components/base/table/table.js +0 -89
  127. package/dist/components/base/table_lite/table_lite.js +0 -72
  128. package/dist/components/base/tabs/constants.js +0 -3
  129. package/dist/components/base/tabs/tab/tab.js +0 -83
  130. package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -143
  131. package/dist/components/base/tabs/tabs/tabs.js +0 -224
  132. package/dist/components/base/toast/toast.js +0 -82
  133. package/dist/components/base/toggle/toggle.js +0 -180
  134. package/dist/components/base/token/token.js +0 -85
  135. package/dist/components/base/token_selector/helpers.js +0 -5
  136. package/dist/components/base/token_selector/token_container.js +0 -165
  137. package/dist/components/base/token_selector/token_selector.js +0 -403
  138. package/dist/components/base/token_selector/token_selector_dropdown.js +0 -199
  139. package/dist/components/base/tooltip/tooltip.js +0 -55
  140. package/dist/components/charts/area/area.js +0 -311
  141. package/dist/components/charts/bar/bar.js +0 -253
  142. package/dist/components/charts/chart/chart.js +0 -215
  143. package/dist/components/charts/column/column.js +0 -226
  144. package/dist/components/charts/discrete_scatter/discrete_scatter.js +0 -203
  145. package/dist/components/charts/gauge/gauge.js +0 -208
  146. package/dist/components/charts/heatmap/heatmap.js +0 -295
  147. package/dist/components/charts/heatmap/index.js +0 -2
  148. package/dist/components/charts/legend/legend.js +0 -228
  149. package/dist/components/charts/line/line.js +0 -308
  150. package/dist/components/charts/series_label/series_label.js +0 -100
  151. package/dist/components/charts/single_stat/single_stat.js +0 -152
  152. package/dist/components/charts/sparkline/sparkline.js +0 -261
  153. package/dist/components/charts/stacked_column/stacked_column.js +0 -335
  154. package/dist/components/charts/tooltip/tooltip.js +0 -251
  155. package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -83
  156. package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -100
  157. package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -35
  158. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -115
  159. package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -104
  160. package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -64
  161. package/dist/components/experimental/duo/chat/constants.js +0 -23
  162. package/dist/components/experimental/duo/chat/duo_chat.js +0 -359
  163. package/dist/components/experimental/duo/chat/mock_data.js +0 -83
  164. package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -94
  165. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -124
  166. package/dist/components/experimental/experiment_badge/constants.js +0 -4
  167. package/dist/components/experimental/experiment_badge/experiment_badge.js +0 -107
  168. package/dist/components/mixins/button_mixin.js +0 -11
  169. package/dist/components/mixins/safe_link_mixin.js +0 -30
  170. package/dist/components/mixins/tooltip_mixin.js +0 -21
  171. package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +0 -53
  172. package/dist/components/regions/empty_state/empty_state.js +0 -154
  173. package/dist/components/shared_components/charts/tooltip_default_format.js +0 -53
  174. package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +0 -64
  175. package/dist/components/shared_components/close_button/close_button.js +0 -54
  176. package/dist/components/utilities/animated_number/animated_number.js +0 -131
  177. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -75
  178. package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -88
  179. package/dist/components/utilities/intersperse/intersperse.js +0 -86
  180. package/dist/components/utilities/sprintf/sprintf.js +0 -172
  181. package/dist/components/utilities/truncate/constants.js +0 -7
  182. package/dist/components/utilities/truncate/truncate.js +0 -111
  183. package/dist/components/utilities/truncate_text/constants.js +0 -7
  184. package/dist/components/utilities/truncate_text/truncate_text.js +0 -146
  185. package/dist/config.js +0 -86
  186. package/dist/directives/collapse_toggle.js +0 -1
  187. package/dist/directives/hover_load/hover_load.js +0 -45
  188. package/dist/directives/modal.js +0 -1
  189. package/dist/directives/outside/get_event_like_time_stamp.js +0 -33
  190. package/dist/directives/outside/outside.js +0 -106
  191. package/dist/directives/resize_observer/resize_observer.js +0 -51
  192. package/dist/directives/safe_html/constants.js +0 -6
  193. package/dist/directives/safe_html/safe_html.js +0 -39
  194. package/dist/directives/safe_link/mock_data.js +0 -10
  195. package/dist/directives/safe_link/safe_link.js +0 -65
  196. package/dist/directives/tooltip.js +0 -1
  197. package/dist/index.css +0 -7
  198. package/dist/index.css.map +0 -1
  199. package/dist/index.js +0 -105
  200. package/dist/tokens/common_story_options.js +0 -109
  201. package/dist/utils/breakpoints.js +0 -20
  202. package/dist/utils/charts/config.js +0 -556
  203. package/dist/utils/charts/constants.js +0 -63
  204. package/dist/utils/charts/mock_data.js +0 -211
  205. package/dist/utils/charts/story_config.js +0 -42
  206. package/dist/utils/charts/theme.js +0 -192
  207. package/dist/utils/charts/utils.js +0 -54
  208. package/dist/utils/constants.js +0 -270
  209. package/dist/utils/data_utils.js +0 -21
  210. package/dist/utils/datetime_utility.js +0 -61
  211. package/dist/utils/i18n.js +0 -15
  212. package/dist/utils/is_slot_empty.js +0 -38
  213. package/dist/utils/number_utils.js +0 -124
  214. package/dist/utils/stories_constants.js +0 -29
  215. package/dist/utils/stories_utils.js +0 -13
  216. package/dist/utils/story_decorators/container.js +0 -16
  217. package/dist/utils/string_utils.js +0 -69
  218. package/dist/utils/svgs/svg_paths.js +0 -7
  219. package/dist/utils/test_utils.js +0 -33
  220. package/dist/utils/use_fake_date.js +0 -29
  221. package/dist/utils/use_mock_intersection_observer.js +0 -108
  222. package/dist/utils/utils.js +0 -177
  223. package/dist/utils.js +0 -5
@@ -1,228 +0,0 @@
1
- import * as echarts from 'echarts';
2
- import { GRAY_200 } from '../../../../dist/tokens/js/tokens';
3
- import { defaultFontSize } from '../../../utils/charts/config';
4
- import { LEGEND_AVERAGE_TEXT, LEGEND_CURRENT_TEXT, LEGEND_MIN_TEXT, LEGEND_MAX_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
5
- import { engineeringNotation, average } from '../../../utils/number_utils';
6
- import GlTruncate from '../../utilities/truncate/truncate';
7
- import GlChartSeriesLabel from '../series_label/series_label';
8
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
9
-
10
- //
11
- var script = {
12
- name: 'GlChartLegend',
13
- components: {
14
- GlChartSeriesLabel,
15
- GlTruncate
16
- },
17
- props: {
18
- chart: {
19
- type: Object,
20
- required: true,
21
- validator(chart) {
22
- return Object.is(chart, echarts.getInstanceByDom(chart.getDom()));
23
- }
24
- },
25
- seriesInfo: {
26
- type: Array,
27
- required: true,
28
- validator(seriesInfo) {
29
- return seriesInfo.every(series => series.type && series.name && series.color);
30
- }
31
- },
32
- textStyle: {
33
- type: Object,
34
- required: false,
35
- default: () => ({})
36
- },
37
- /**
38
- * Text for data average (overridden by prop if needed for internationalization)
39
- */
40
- averageText: {
41
- type: String,
42
- required: false,
43
- default: LEGEND_AVERAGE_TEXT
44
- },
45
- currentText: {
46
- type: String,
47
- required: false,
48
- default: LEGEND_CURRENT_TEXT
49
- },
50
- minText: {
51
- type: String,
52
- required: false,
53
- default: LEGEND_MIN_TEXT
54
- },
55
- /**
56
- * Text for max amount (overridden by prop if needed for internationalization)
57
- */
58
- maxText: {
59
- type: String,
60
- required: false,
61
- default: LEGEND_MAX_TEXT
62
- },
63
- /**
64
- * Sets the display layout
65
- */
66
- layout: {
67
- type: String,
68
- required: false,
69
- default: LEGEND_LAYOUT_INLINE,
70
- validator(layout) {
71
- return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
72
- }
73
- }
74
- },
75
- data() {
76
- return {
77
- disabledSeries: {},
78
- lastActiveSeriesLabel: null
79
- };
80
- },
81
- computed: {
82
- fontStyle() {
83
- return {
84
- fontFamily: this.textStyle.fontFamily || 'sans-serif',
85
- fontSize: `${this.textStyle.fontSize || defaultFontSize}px`
86
- };
87
- },
88
- hasOneSeriesElement() {
89
- return this.seriesInfo.length === 1;
90
- }
91
- },
92
- created() {
93
- this.chart.on('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
94
- },
95
- beforeDestroy() {
96
- this.chart.off('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
97
- },
98
- methods: {
99
- sanitizeSeriesData(seriesData) {
100
- var _seriesData$filter;
101
- return (_seriesData$filter = seriesData === null || seriesData === void 0 ? void 0 : seriesData.filter(d => !Number.isNaN(d))) !== null && _seriesData$filter !== void 0 ? _seriesData$filter : [];
102
- },
103
- seriesAverage(seriesData) {
104
- const sanitized = this.sanitizeSeriesData(seriesData);
105
- return engineeringNotation(average(...sanitized));
106
- },
107
- seriesMax(seriesData) {
108
- const sanitized = this.sanitizeSeriesData(seriesData);
109
- return engineeringNotation(Math.max(...sanitized));
110
- },
111
- seriesMin(seriesData) {
112
- const sanitized = this.sanitizeSeriesData(seriesData);
113
- return engineeringNotation(Math.min(...sanitized));
114
- },
115
- seriesLast(seriesData) {
116
- const sanitized = this.sanitizeSeriesData(seriesData);
117
- return engineeringNotation(sanitized[sanitized.length - 1]);
118
- },
119
- seriesNameIsLong(seriesName) {
120
- return seriesName.length > 120;
121
- },
122
- handleClick(_ref, key) {
123
- let {
124
- name,
125
- disabled
126
- } = _ref;
127
- if (this.hasOneSeriesElement || this.isToggleDisabled(name, disabled)) return;
128
- this.chart.dispatchAction({
129
- type: 'legendToggleSelect',
130
- name
131
- });
132
- this.disabledSeries = {
133
- ...this.disabledSeries,
134
- [key]: !this.disabledSeries[key]
135
- };
136
- },
137
- handleMouseEnter(name) {
138
- this.chart.dispatchAction({
139
- type: 'highlight',
140
- seriesName: name
141
- });
142
- },
143
- handleMouseLeave(name) {
144
- this.chart.dispatchAction({
145
- type: 'downplay',
146
- seriesName: name
147
- });
148
- },
149
- getColor(color, key) {
150
- return this.disabledSeries[key] ? GRAY_200 : color;
151
- },
152
- suppressLastActiveSeriesLabelToggle(_ref2) {
153
- let {
154
- selected
155
- } = _ref2;
156
- const selectedSeriesLabels = Object.entries(selected).filter(_ref3 => {
157
- let [, isSelected] = _ref3;
158
- return Boolean(isSelected);
159
- });
160
- this.lastActiveSeriesLabel = null;
161
- if (selectedSeriesLabels.length === 1) {
162
- const [lastActiveSeriesLabelName] = selectedSeriesLabels[0];
163
- this.lastActiveSeriesLabel = lastActiveSeriesLabelName;
164
- }
165
- },
166
- /**
167
- * Disables toggling legend if it is the last active one or if its data series
168
- * has a disabled property set to true
169
- * @param {String} name Series name
170
- * @param {Boolean} isDisabled Value of the series element's disabled property
171
- * @returns {boolean}
172
- */
173
- isToggleDisabled(name, isDisabled) {
174
- return name === this.lastActiveSeriesLabel || isDisabled;
175
- }
176
- },
177
- legendLayoutTypes: {
178
- LEGEND_LAYOUT_INLINE,
179
- LEGEND_LAYOUT_TABLE
180
- }
181
- };
182
-
183
- /* script */
184
- const __vue_script__ = script;
185
-
186
- /* template */
187
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-legend",attrs:{"data-testid":"gl-chart-legend"}},[(_vm.layout === _vm.$options.legendLayoutTypes.LEGEND_LAYOUT_INLINE)?[_c('div',{staticClass:"gl-legend-inline"},_vm._l((_vm.seriesInfo),function(series,key){return _c('div',{key:key,staticClass:"gl-legend-inline-series",class:{
188
- 'text-muted': _vm.disabledSeries[key],
189
- 'w-100': _vm.seriesNameIsLong(series.name),
190
- 'gl-hover-cursor-not-allowed!':
191
- _vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),
192
- },style:(_vm.fontStyle),attrs:{"aria-disabled":_vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),"role":"button"},on:{"click":function($event){return _vm.handleClick(series, key)},"mouseenter":function($event){return _vm.handleMouseEnter(series.name)},"mouseleave":function($event){return _vm.handleMouseLeave(series.name)}}},[_c('gl-chart-series-label',{staticClass:"gl-legend-inline-series-label",class:{ 'w-75': _vm.seriesNameIsLong(series.name) },attrs:{"color":_vm.getColor(series.color, key),"type":series.type}},[_c('gl-truncate',{staticClass:"gl-font-weight-bold",attrs:{"text":series.name}})],1),_vm._v(" "),(series.data && series.data.length)?_c('span',{class:{ 'gl-white-space-nowrap': _vm.seriesNameIsLong(series.name) }},[_vm._v("\n "+_vm._s(_vm.averageText)+": "+_vm._s(_vm.seriesAverage(series.data))+" · "+_vm._s(_vm.maxText)+":\n "+_vm._s(_vm.seriesMax(series.data))+"\n ")]):_vm._e()],1)}),0)]:_vm._e(),_vm._v(" "),(_vm.layout === _vm.$options.legendLayoutTypes.LEGEND_LAYOUT_TABLE)?[_c('div',{staticClass:"gl-legend-tabular",style:(_vm.fontStyle)},[_c('header',{staticClass:"gl-legend-tabular-header"},[_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.minText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.maxText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.averageText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.currentText))])]),_vm._v(" "),_c('section',{staticClass:"gl-legend-tabular-body"},_vm._l((_vm.seriesInfo),function(series,key){return _c('div',{key:key,staticClass:"gl-legend-tabular-row",class:{
193
- 'text-muted': _vm.disabledSeries[key],
194
- 'gl-hover-cursor-not-allowed!':
195
- _vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),
196
- },style:(_vm.fontStyle),attrs:{"aria-disabled":_vm.isToggleDisabled(series.name, series.disabled),"role":"button"},on:{"click":function($event){return _vm.handleClick(series, key)},"mouseenter":function($event){return _vm.handleMouseEnter(series.name)},"mouseleave":function($event){return _vm.handleMouseLeave(series.name)}}},[_c('div',{staticClass:"gl-legend-tabular-title-cell"},[_c('gl-chart-series-label',{style:(_vm.fontStyle),attrs:{"color":_vm.getColor(series.color, key),"type":series.type}},[_c('gl-truncate',{staticClass:"gl-font-weight-bold",attrs:{"text":series.name}})],1)],1),_vm._v(" "),(_vm.sanitizeSeriesData(series.data).length)?[_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesMin(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesMax(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesAverage(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesLast(series.data)))])]:[_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")])]],2)}),0)])]:_vm._e()],2)};
197
- var __vue_staticRenderFns__ = [];
198
-
199
- /* style */
200
- const __vue_inject_styles__ = undefined;
201
- /* scoped */
202
- const __vue_scope_id__ = undefined;
203
- /* module identifier */
204
- const __vue_module_identifier__ = undefined;
205
- /* functional template */
206
- const __vue_is_functional_template__ = false;
207
- /* style inject */
208
-
209
- /* style inject SSR */
210
-
211
- /* style inject shadow dom */
212
-
213
-
214
-
215
- const __vue_component__ = __vue_normalize__(
216
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
217
- __vue_inject_styles__,
218
- __vue_script__,
219
- __vue_scope_id__,
220
- __vue_is_functional_template__,
221
- __vue_module_identifier__,
222
- false,
223
- undefined,
224
- undefined,
225
- undefined
226
- );
227
-
228
- export default __vue_component__;
@@ -1,308 +0,0 @@
1
- import merge from 'lodash/merge';
2
- import { GRAY_200 } from '../../../../dist/tokens/js/tokens';
3
- import { symbolSize, lineStyle, getThresholdConfig, generateAnnotationSeries, defaultChartOptions, dataZoomAdjustments, mergeSeriesToOptions, mergeAnnotationAxisToOptions, grid } from '../../../utils/charts/config';
4
- import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
5
- import { colorFromDefaultPalette } from '../../../utils/charts/theme';
6
- import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
7
- import Chart from '../chart/chart';
8
- import ChartLegend from '../legend/legend';
9
- import ChartTooltip from '../tooltip/tooltip';
10
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
11
-
12
- //
13
- var script = {
14
- name: 'GlLineChart',
15
- components: {
16
- Chart,
17
- ChartLegend,
18
- ChartTooltip
19
- },
20
- inheritAttrs: false,
21
- props: {
22
- data: {
23
- type: Array,
24
- required: true
25
- },
26
- option: {
27
- type: Object,
28
- required: false,
29
- default: () => ({})
30
- },
31
- thresholds: {
32
- type: Array,
33
- required: false,
34
- default: () => []
35
- },
36
- annotations: {
37
- type: Array,
38
- required: false,
39
- default: () => []
40
- },
41
- includeLegendAvgMax: {
42
- type: Boolean,
43
- required: false,
44
- default: true
45
- },
46
- /**
47
- * Callback called when showing or refreshing a tooltip.
48
- * **Deprecated:** Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
49
- *
50
- * @deprecated Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
51
- */
52
- formatTooltipText: {
53
- type: Function,
54
- required: false,
55
- default: null
56
- },
57
- legendAverageText: {
58
- type: String,
59
- required: false,
60
- default: LEGEND_AVERAGE_TEXT
61
- },
62
- legendMaxText: {
63
- type: String,
64
- required: false,
65
- default: LEGEND_MAX_TEXT
66
- },
67
- legendMinText: {
68
- type: String,
69
- required: false,
70
- default: LEGEND_MIN_TEXT
71
- },
72
- legendCurrentText: {
73
- type: String,
74
- required: false,
75
- default: LEGEND_CURRENT_TEXT
76
- },
77
- legendLayout: {
78
- type: String,
79
- required: false,
80
- default: LEGEND_LAYOUT_INLINE,
81
- validator(layout) {
82
- return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
83
- }
84
- },
85
- showLegend: {
86
- type: Boolean,
87
- required: false,
88
- default: true
89
- },
90
- /**
91
- * Sets the chart's height in pixels. Set to `"auto"` to use the height of the container.
92
- */
93
- height: {
94
- type: [Number, String],
95
- required: false,
96
- default: null
97
- }
98
- },
99
- data() {
100
- // Part of the tooltip related data can be
101
- // moved into the tooltip component.
102
- // Tracking that progress in
103
- // https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
104
- return {
105
- chart: null,
106
- showAnnotationsTooltip: false,
107
- annotationsTooltipTitle: '',
108
- annotationsTooltipContent: '',
109
- annotationsTooltipPosition: {
110
- left: '0',
111
- top: '0'
112
- }
113
- };
114
- },
115
- computed: {
116
- series() {
117
- const dataSeries = this.data.map((series, index) => {
118
- const defaultColor = colorFromDefaultPalette(index);
119
- const getColor = type => {
120
- var _series$type$color, _series$type;
121
- return (_series$type$color = (_series$type = series[type]) === null || _series$type === void 0 ? void 0 : _series$type.color) !== null && _series$type$color !== void 0 ? _series$type$color : defaultColor;
122
- };
123
- return merge({
124
- showSymbol: true,
125
- lineStyle: {
126
- color: getColor('lineStyle')
127
- },
128
- itemStyle: {
129
- color: getColor('itemStyle')
130
- }
131
- }, symbolSize, lineStyle, series, getThresholdConfig(this.thresholds));
132
- });
133
- // if annotation series exists, append it
134
- // along with data series
135
- if (this.annotationSeries) {
136
- return [...dataSeries, this.annotationSeries];
137
- }
138
- return dataSeries;
139
- },
140
- annotationSeries() {
141
- return generateAnnotationSeries(this.annotations);
142
- },
143
- options() {
144
- const defaultLineChartOptions = {
145
- xAxis: {
146
- axisPointer: {
147
- show: true,
148
- label: {
149
- formatter: this.formatTooltipText
150
- }
151
- },
152
- axisTick: {
153
- alignWithLabel: true,
154
- show: true,
155
- lineStyle: {
156
- color: GRAY_200
157
- }
158
- }
159
- },
160
- legend: {
161
- show: false
162
- }
163
- };
164
- const mergedOptions = merge({}, defaultChartOptions, defaultLineChartOptions, this.option, dataZoomAdjustments(this.option.dataZoom));
165
- // All chart options can be merged but series
166
- // needs to be handled specially
167
- return mergeSeriesToOptions(mergeAnnotationAxisToOptions(mergedOptions, this.hasAnnotations), this.series);
168
- },
169
- /**
170
- * Annotations currently are passed as series options in monitoring dashboard.
171
- * Once https://gitlab.com/gitlab-org/gitlab/-/issues/213390 is closed,
172
- * annotations will be passed as props and not as series options.
173
- *
174
- * For backward compatibility, we're having to check for both.
175
- */
176
- hasAnnotations() {
177
- return this.annotations.length !== 0 || seriesHasAnnotations(this.option.series);
178
- },
179
- shouldShowAnnotationsTooltip() {
180
- return this.chart && this.hasAnnotations;
181
- },
182
- compiledOptions() {
183
- return this.chart ? this.chart.getOption() : null;
184
- },
185
- legendStyle() {
186
- return {
187
- paddingLeft: `${grid.left}px`
188
- };
189
- },
190
- hasLegend() {
191
- return this.compiledOptions && this.showLegend;
192
- },
193
- seriesInfo() {
194
- return this.compiledOptions.series.reduce((acc, series, index) => {
195
- if (series.type === 'line') {
196
- acc.push({
197
- name: series.name,
198
- type: series.lineStyle.type,
199
- color: series.lineStyle.color || colorFromDefaultPalette(index),
200
- data: this.includeLegendAvgMax ? series.data.map(data => data[1]) : undefined
201
- });
202
- }
203
- return acc;
204
- }, []);
205
- },
206
- autoHeight() {
207
- return this.height === 'auto';
208
- }
209
- },
210
- beforeDestroy() {
211
- this.chart.off('mouseout', this.onChartDataPointMouseOut);
212
- this.chart.off('mouseover', this.onChartDataPointMouseOver);
213
- },
214
- methods: {
215
- defaultAnnotationTooltipText(params) {
216
- var _params$data$tooltipD;
217
- return {
218
- title: params.data.xAxis,
219
- content: (_params$data$tooltipD = params.data.tooltipData) === null || _params$data$tooltipD === void 0 ? void 0 : _params$data$tooltipD.content
220
- };
221
- },
222
- onCreated(chart) {
223
- // eCharts inbuild mouse events
224
- // https://echarts.apache.org/en/api.html#events.Mouse%20events
225
- // is used to attach listeners to markPoints. These listeners
226
- // are currently used for annotation arrows at the bottom of the chart.
227
-
228
- // Because data points and annotations arrows are in different
229
- // sections of the charts with their own mouseovers and mouseouts,
230
- // there shouldn't be an overlapping situation where both tooltips
231
- // are visible.
232
-
233
- if (this.hasAnnotations) {
234
- chart.on('mouseout', this.onChartDataPointMouseOut);
235
- chart.on('mouseover', this.onChartDataPointMouseOver);
236
- }
237
- this.chart = chart;
238
- this.$emit('created', chart);
239
- },
240
- onChartDataPointMouseOut() {
241
- this.showAnnotationsTooltip = false;
242
- },
243
- /**
244
- * Check if the hovered data point is an annotation
245
- * point to show the annotation tooltip.
246
- */
247
- onChartDataPointMouseOver(params) {
248
- if (isDataPointAnnotation(params)) {
249
- const {
250
- event
251
- } = params;
252
- const toolTipFormatter = this.formatAnnotationsTooltipText || this.defaultAnnotationTooltipText;
253
- const {
254
- title = '',
255
- content = ''
256
- } = toolTipFormatter(params);
257
- this.showAnnotationsTooltip = true;
258
- this.annotationsTooltipTitle = title;
259
- this.annotationsTooltipContent = content;
260
- this.annotationsTooltipPosition = {
261
- left: `${event.event.zrX}px`,
262
- top: `${event.event.zrY}px`
263
- };
264
- }
265
- }
266
- },
267
- HEIGHT_AUTO_CLASSES
268
- };
269
-
270
- /* script */
271
- const __vue_script__ = script;
272
-
273
- /* template */
274
- var __vue_render__ = function () {
275
- var _obj;
276
- var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"position-relative",class:( _obj = {}, _obj[_vm.$options.HEIGHT_AUTO_CLASSES] = _vm.autoHeight, _obj )},[_c('chart',_vm._g(_vm._b({class:{ 'gl-flex-grow-1': _vm.autoHeight },attrs:{"height":_vm.height,"options":_vm.options},on:{"created":_vm.onCreated}},'chart',_vm.$attrs,false),_vm.$listeners)),_vm._v(" "),(_vm.shouldShowAnnotationsTooltip)?_c('chart-tooltip',{ref:"annotationsTooltip",attrs:{"id":"annotationsTooltip","show":_vm.showAnnotationsTooltip,"chart":_vm.chart,"top":_vm.annotationsTooltipPosition.top,"left":_vm.annotationsTooltipPosition.left,"placement":"bottom"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipTitle))])]},proxy:true}],null,false,1889294429)},[_vm._v(" "),_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipContent))])]):_vm._e(),_vm._v(" "),(_vm.chart)?_c('chart-tooltip',{ref:"dataTooltip",attrs:{"chart":_vm.chart,"use-default-tooltip-formatter":!_vm.formatTooltipText},scopedSlots:_vm._u([(_vm.$scopedSlots['tooltip-title'])?{key:"title",fn:function(scope){return [_vm._t("tooltip-title",null,null,scope)]}}:null,(_vm.$scopedSlots['tooltip-content'])?{key:"default",fn:function(scope){return [_vm._t("tooltip-content",null,null,scope)]}}:null,(_vm.$scopedSlots['tooltip-value'])?{key:"tooltip-value",fn:function(scope){return [_vm._t("tooltip-value",null,null,scope)]}}:null],null,true)}):_vm._e(),_vm._v(" "),(_vm.hasLegend)?_c('chart-legend',{style:(_vm.legendStyle),attrs:{"chart":_vm.chart,"series-info":_vm.seriesInfo,"text-style":_vm.compiledOptions.textStyle,"min-text":_vm.legendMinText,"max-text":_vm.legendMaxText,"average-text":_vm.legendAverageText,"current-text":_vm.legendCurrentText,"layout":_vm.legendLayout}}):_vm._e()],1)};
277
- var __vue_staticRenderFns__ = [];
278
-
279
- /* style */
280
- const __vue_inject_styles__ = undefined;
281
- /* scoped */
282
- const __vue_scope_id__ = undefined;
283
- /* module identifier */
284
- const __vue_module_identifier__ = undefined;
285
- /* functional template */
286
- const __vue_is_functional_template__ = false;
287
- /* style inject */
288
-
289
- /* style inject SSR */
290
-
291
- /* style inject shadow dom */
292
-
293
-
294
-
295
- const __vue_component__ = __vue_normalize__(
296
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
297
- __vue_inject_styles__,
298
- __vue_script__,
299
- __vue_scope_id__,
300
- __vue_is_functional_template__,
301
- __vue_module_identifier__,
302
- false,
303
- undefined,
304
- undefined,
305
- undefined
306
- );
307
-
308
- export default __vue_component__;
@@ -1,100 +0,0 @@
1
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
-
3
- const makePathRect = (startX, startY, width, height) => `M${startX},${startY}H${startX + width}V${startY + height}H${startX}Z`;
4
- var script = {
5
- name: 'GlChartSeriesLabel',
6
- props: {
7
- color: {
8
- type: String,
9
- required: true
10
- },
11
- type: {
12
- type: String,
13
- required: false,
14
- default: 'solid'
15
- }
16
- },
17
- data() {
18
- return {
19
- labelLineHeight: 0
20
- };
21
- },
22
- computed: {
23
- pathContent() {
24
- const width = this.$options.svgWidth;
25
- const height = this.$options.svgHeight;
26
- if (this.type === 'dashed') {
27
- const dashWidth = Math.ceil(width / 3);
28
- const firstDash = makePathRect(0, 0, dashWidth, height);
29
- const secondDash = makePathRect(width - dashWidth, 0, dashWidth, height);
30
- return `${firstDash}${secondDash}`;
31
- }
32
- return makePathRect(0, 0, width, height);
33
- },
34
- svgStyles() {
35
- return {
36
- fill: this.color,
37
- transform: `translateY(${this.formatPixelDimension(this.svgYTranslationValue)})`,
38
- width: 'auto'
39
- };
40
- },
41
- svgYTranslationValue() {
42
- const value = this.labelLineHeight / 2 - this.$options.svgHeight / 2;
43
- return Math.round(value) || 0;
44
- }
45
- },
46
- mounted() {
47
- if (getComputedStyle && this.$refs.label) {
48
- const computedStyle = getComputedStyle(this.$refs.label);
49
- const lineHeight = computedStyle['line-height'].match(/(\d+)px/);
50
- if (lineHeight !== null) {
51
- this.labelLineHeight = parseFloat(lineHeight[1]);
52
- }
53
- }
54
- },
55
- methods: {
56
- formatPixelDimension(dimension) {
57
- return `${dimension}px`;
58
- }
59
- },
60
- svgWidth: 16,
61
- svgHeight: 4
62
- };
63
-
64
- /* script */
65
- const __vue_script__ = script;
66
-
67
- /* template */
68
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-series-label-container"},[(_vm.color.length)?_c('div',{staticClass:"gl-series-label-color"},[_c('svg',{style:(_vm.svgStyles),attrs:{"width":_vm.formatPixelDimension(_vm.$options.svgWidth),"height":_vm.formatPixelDimension(_vm.$options.svgHeight)}},[_c('path',{attrs:{"d":_vm.pathContent}})])]):_vm._e(),_vm._v(" "),_c('div',{ref:"label",staticClass:"gl-series-label-text"},[_vm._t("default")],2)])};
69
- var __vue_staticRenderFns__ = [];
70
-
71
- /* style */
72
- const __vue_inject_styles__ = undefined;
73
- /* scoped */
74
- const __vue_scope_id__ = undefined;
75
- /* module identifier */
76
- const __vue_module_identifier__ = undefined;
77
- /* functional template */
78
- const __vue_is_functional_template__ = false;
79
- /* style inject */
80
-
81
- /* style inject SSR */
82
-
83
- /* style inject shadow dom */
84
-
85
-
86
-
87
- const __vue_component__ = __vue_normalize__(
88
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
89
- __vue_inject_styles__,
90
- __vue_script__,
91
- __vue_scope_id__,
92
- __vue_is_functional_template__,
93
- __vue_module_identifier__,
94
- false,
95
- undefined,
96
- undefined,
97
- undefined
98
- );
99
-
100
- export default __vue_component__;