@gitlab/ui 49.0.1 → 49.0.3

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 (128) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/base/accordion/accordion.js +2 -8
  3. package/dist/components/base/accordion/accordion_item.js +0 -14
  4. package/dist/components/base/alert/alert.js +4 -22
  5. package/dist/components/base/avatar/avatar.js +0 -7
  6. package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -2
  7. package/dist/components/base/avatars_inline/avatars_inline.js +2 -10
  8. package/dist/components/base/badge/badge.js +0 -8
  9. package/dist/components/base/banner/banner.js +0 -10
  10. package/dist/components/base/breadcrumb/breadcrumb.js +0 -12
  11. package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -2
  12. package/dist/components/base/broadcast_message/broadcast_message.js +0 -3
  13. package/dist/components/base/button/button.js +0 -11
  14. package/dist/components/base/card/card.js +1 -2
  15. package/dist/components/base/datepicker/datepicker.js +7 -42
  16. package/dist/components/base/daterange_picker/daterange_picker.js +0 -23
  17. package/dist/components/base/drawer/drawer.js +0 -13
  18. package/dist/components/base/dropdown/dropdown.js +3 -17
  19. package/dist/components/base/dropdown/dropdown_item.js +2 -8
  20. package/dist/components/base/filtered_search/common_story_options.js +1 -2
  21. package/dist/components/base/filtered_search/filtered_search.js +9 -61
  22. package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -6
  23. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -16
  24. package/dist/components/base/filtered_search/filtered_search_term.js +0 -9
  25. package/dist/components/base/filtered_search/filtered_search_token.js +10 -49
  26. package/dist/components/base/filtered_search/filtered_search_token_segment.js +3 -56
  27. package/dist/components/base/filtered_search/filtered_search_utils.js +7 -24
  28. package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -2
  29. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -4
  30. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -10
  31. package/dist/components/base/form/form_checkbox_tree/models/node.js +1 -10
  32. package/dist/components/base/form/form_checkbox_tree/models/tree.js +16 -37
  33. package/dist/components/base/form/form_combobox/form_combobox.js +2 -36
  34. package/dist/components/base/form/form_group/form_group.js +2 -7
  35. package/dist/components/base/form/form_input/form_input.js +2 -8
  36. package/dist/components/base/form/form_input_group/form_input_group.js +0 -5
  37. package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -8
  38. package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -2
  39. package/dist/components/base/form/form_select/form_select.js +0 -3
  40. package/dist/components/base/form/form_textarea/form_textarea.js +2 -7
  41. package/dist/components/base/icon/icon.js +4 -14
  42. package/dist/components/base/infinite_scroll/infinite_scroll.js +7 -21
  43. package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -9
  44. package/dist/components/base/label/label.js +0 -12
  45. package/dist/components/base/loading_icon/loading_icon.js +7 -10
  46. package/dist/components/base/markdown/markdown.js +1 -0
  47. package/dist/components/base/modal/modal.js +7 -27
  48. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -25
  49. package/dist/components/base/new_dropdowns/constants.js +4 -2
  50. package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -63
  51. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -2
  52. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -5
  53. package/dist/components/base/new_dropdowns/listbox/utils.js +0 -7
  54. package/dist/components/base/paginated_list/paginated_list.js +0 -15
  55. package/dist/components/base/pagination/pagination.js +14 -72
  56. package/dist/components/base/path/path.js +0 -29
  57. package/dist/components/base/popover/popover.js +0 -5
  58. package/dist/components/base/search_box_by_click/search_box_by_click.js +1 -26
  59. package/dist/components/base/search_box_by_type/search_box_by_type.js +2 -12
  60. package/dist/components/base/segmented_control/segmented_control.js +0 -10
  61. package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -19
  62. package/dist/components/base/skeleton_loading/skeleton_loading.js +0 -3
  63. package/dist/components/base/sorting/sorting.js +1 -9
  64. package/dist/components/base/sorting/sorting_item.js +4 -6
  65. package/dist/components/base/table/table.js +0 -4
  66. package/dist/components/base/tabs/tab/tab.js +2 -6
  67. package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -21
  68. package/dist/components/base/tabs/tabs/tabs.js +8 -33
  69. package/dist/components/base/toast/toast.js +4 -15
  70. package/dist/components/base/toggle/toggle.js +0 -18
  71. package/dist/components/base/token/token.js +0 -4
  72. package/dist/components/base/token_selector/token_container.js +0 -24
  73. package/dist/components/base/token_selector/token_selector.js +10 -61
  74. package/dist/components/base/token_selector/token_selector_dropdown.js +4 -32
  75. package/dist/components/charts/area/area.js +8 -32
  76. package/dist/components/charts/bar/bar.js +7 -19
  77. package/dist/components/charts/chart/chart.js +1 -22
  78. package/dist/components/charts/column/column.js +8 -18
  79. package/dist/components/charts/discrete_scatter/discrete_scatter.js +2 -13
  80. package/dist/components/charts/gauge/gauge.js +0 -15
  81. package/dist/components/charts/heatmap/heatmap.js +3 -16
  82. package/dist/components/charts/legend/legend.js +2 -24
  83. package/dist/components/charts/line/line.js +8 -34
  84. package/dist/components/charts/series_label/series_label.js +0 -12
  85. package/dist/components/charts/single_stat/single_stat.js +0 -8
  86. package/dist/components/charts/sparkline/sparkline.js +1 -16
  87. package/dist/components/charts/stacked_column/stacked_column.js +8 -26
  88. package/dist/components/charts/tooltip/tooltip.js +0 -6
  89. package/dist/components/mixins/button_mixin.js +0 -1
  90. package/dist/components/mixins/safe_link_mixin.js +0 -1
  91. package/dist/components/mixins/toolbox_mixin.js +0 -1
  92. package/dist/components/mixins/tooltip_mixin.js +1 -2
  93. package/dist/components/regions/empty_state/empty_state.js +0 -12
  94. package/dist/components/utilities/animated_number/animated_number.js +0 -16
  95. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -3
  96. package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -7
  97. package/dist/components/utilities/intersperse/intersperse.js +3 -9
  98. package/dist/components/utilities/sprintf/sprintf.js +9 -23
  99. package/dist/components/utilities/truncate/truncate.js +0 -10
  100. package/dist/config.js +3 -4
  101. package/dist/directives/hover_load/hover_load.js +2 -8
  102. package/dist/directives/outside/get_event_like_time_stamp.js +4 -2
  103. package/dist/directives/outside/outside.js +5 -20
  104. package/dist/directives/resize_observer/resize_observer.js +0 -10
  105. package/dist/directives/safe_html/safe_html.js +5 -6
  106. package/dist/directives/safe_link/mock_data.js +1 -1
  107. package/dist/directives/safe_link/safe_link.js +0 -13
  108. package/dist/utils/breakpoints.js +0 -3
  109. package/dist/utils/charts/config.js +29 -42
  110. package/dist/utils/charts/constants.js +8 -8
  111. package/dist/utils/charts/mock_data.js +2 -2
  112. package/dist/utils/charts/story_config.js +1 -1
  113. package/dist/utils/charts/theme.js +1 -3
  114. package/dist/utils/charts/utils.js +2 -6
  115. package/dist/utils/constants.js +10 -7
  116. package/dist/utils/data_utils.js +5 -4
  117. package/dist/utils/datetime_utility.js +4 -4
  118. package/dist/utils/number_utils.js +7 -11
  119. package/dist/utils/stories_utils.js +1 -1
  120. package/dist/utils/story_decorators/container.js +0 -1
  121. package/dist/utils/string_utils.js +0 -14
  122. package/dist/utils/test_utils.js +3 -2
  123. package/dist/utils/use_fake_date.js +0 -4
  124. package/dist/utils/use_mock_intersection_observer.js +4 -19
  125. package/dist/utils/utils.js +5 -14
  126. package/package.json +3 -3
  127. package/src/components/base/pagination/pagination.vue +2 -2
  128. package/src/components/base/toast/toast.js +1 -0
@@ -30,7 +30,6 @@ var script = {
30
30
  required: false,
31
31
  default: 'Clear'
32
32
  },
33
-
34
33
  /**
35
34
  * If provided and true, disables the input and controls
36
35
  */
@@ -39,7 +38,6 @@ var script = {
39
38
  required: false,
40
39
  default: false
41
40
  },
42
-
43
41
  /**
44
42
  * Puts search box into loading state, rendering spinner
45
43
  */
@@ -48,7 +46,6 @@ var script = {
48
46
  required: false,
49
47
  default: false
50
48
  },
51
-
52
49
  /**
53
50
  * Container for tooltip. Valid values: DOM node, selector string or `false` for default
54
51
  */
@@ -65,41 +62,34 @@ var script = {
65
62
  placeholder: 'Search',
66
63
  ...this.$attrs
67
64
  };
68
-
69
65
  if (!attributes['aria-label']) {
70
66
  attributes['aria-label'] = attributes.placeholder;
71
67
  }
72
-
73
68
  return attributes;
74
69
  },
75
-
76
70
  hasValue() {
77
71
  return Boolean(this.value.length);
78
72
  },
79
-
80
73
  inputListeners() {
81
- return { ...this.$listeners,
74
+ return {
75
+ ...this.$listeners,
82
76
  input: value => {
83
77
  this.$emit('input', value);
84
78
  }
85
79
  };
86
80
  },
87
-
88
81
  showClearButton() {
89
82
  return this.hasValue && !this.disabled;
90
83
  }
91
-
92
84
  },
93
85
  methods: {
94
86
  clearInput() {
95
87
  this.$emit('input', '');
96
88
  this.focusInput();
97
89
  },
98
-
99
90
  focusInput() {
100
91
  this.$refs.input.$el.focus();
101
92
  }
102
-
103
93
  }
104
94
  };
105
95
 
@@ -25,35 +25,28 @@ var script = {
25
25
  enabledOptions() {
26
26
  return this.options.filter(option => !option.disabled);
27
27
  }
28
-
29
28
  },
30
29
  watch: {
31
30
  checked: {
32
31
  handler(newValue, oldValue) {
33
32
  this.checkValue(newValue, oldValue);
34
33
  }
35
-
36
34
  },
37
35
  options: {
38
36
  handler() {
39
37
  this.checkValue(this.checked);
40
38
  }
41
-
42
39
  }
43
40
  },
44
-
45
41
  created() {
46
42
  this.checkValue(this.checked);
47
43
  },
48
-
49
44
  methods: {
50
45
  checkValue(newValue) {
51
46
  let oldValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
52
-
53
47
  if (!this.isValidValue(newValue)) {
54
48
  // eslint-disable-next-line no-console
55
49
  console.warn(genericErrorMessage);
56
-
57
50
  if (this.enabledOptions.length) {
58
51
  const suggestion = oldValue && this.isValidValue(oldValue) ? oldValue : this.enabledOptions[0].value;
59
52
  /**
@@ -61,12 +54,10 @@ var script = {
61
54
  * @event input
62
55
  * @argument checked The selected option
63
56
  */
64
-
65
57
  this.$emit('input', suggestion);
66
58
  }
67
59
  }
68
60
  },
69
-
70
61
  isValidValue(val) {
71
62
  return this.enabledOptions.some(_ref => {
72
63
  let {
@@ -75,7 +66,6 @@ var script = {
75
66
  return value === val;
76
67
  });
77
68
  }
78
-
79
69
  }
80
70
  };
81
71
 
@@ -21,7 +21,6 @@ var script = {
21
21
  default: null,
22
22
  required: false
23
23
  },
24
-
25
24
  /**
26
25
  * It will be set in the viewbox attr in the <svg />. Defaults to 130 when skeleton is passed via the slot.
27
26
  * Defaults to the combined height of the lines when default skeleton is used
@@ -31,7 +30,6 @@ var script = {
31
30
  default: null,
32
31
  required: false
33
32
  },
34
-
35
33
  /**
36
34
  * Aspect ratio option of <svg/>
37
35
  */
@@ -40,7 +38,6 @@ var script = {
40
38
  default: 'xMidYMid meet',
41
39
  required: false
42
40
  },
43
-
44
41
  /**
45
42
  * Required if you're using <base url="/" /> in your <head />. Defaults to an empty string.
46
43
  * This prop is common used as: <gl-skeleton-loader :base-url="$route.fullPath" /> which will fill the SVG attribute with the relative path.
@@ -50,7 +47,6 @@ var script = {
50
47
  default: '',
51
48
  required: false
52
49
  },
53
-
54
50
  /**
55
51
  * Defaults to unique id
56
52
  */
@@ -59,7 +55,6 @@ var script = {
59
55
  default: () => uid(),
60
56
  required: false
61
57
  },
62
-
63
58
  /**
64
59
  * Number of lines to show when using the default skeleton
65
60
  */
@@ -68,7 +63,6 @@ var script = {
68
63
  default: 3,
69
64
  required: false
70
65
  },
71
-
72
66
  /**
73
67
  * If the default skeleton lines should all be the same width
74
68
  */
@@ -78,41 +72,31 @@ var script = {
78
72
  required: false
79
73
  }
80
74
  },
81
-
82
75
  render(createElement, _ref) {
83
76
  let {
84
77
  props,
85
78
  slots
86
79
  } = _ref;
87
-
88
80
  const slotIsSet = () => slots().default;
89
-
90
81
  const propValueOrDefault = (name, defaultValue) => props[name] !== null ? props[name] : defaultValue;
91
-
92
82
  const width = () => {
93
83
  if (slotIsSet()) {
94
84
  return propValueOrDefault('width', DEFAULT_SVG_WIDTH);
95
85
  }
96
-
97
86
  return propValueOrDefault('width', DEFAULT_LINE_MAX_WIDTH);
98
87
  };
99
-
100
88
  const height = () => {
101
89
  if (slotIsSet()) {
102
90
  return propValueOrDefault('height', DEFAULT_SVG_HEIGHT);
103
91
  }
104
-
105
92
  return propValueOrDefault('height', props.lines * DEFAULT_LINE_HEIGHT + (props.lines - 1) * DEFAULT_LINE_SPACING);
106
93
  };
107
-
108
94
  const lineWidth = index => {
109
95
  if (props.equalWidthLines) {
110
96
  return '100%';
111
97
  }
112
-
113
98
  return `${DEFAULT_LINE_WIDTH_PERCENTAGES[index % DEFAULT_LINE_WIDTH_PERCENTAGES.length]}%`;
114
99
  };
115
-
116
100
  const svg = createElement('svg', {
117
101
  class: {
118
102
  'gl-skeleton-loader': true,
@@ -187,11 +171,9 @@ var script = {
187
171
  repeatCount: 'indefinite'
188
172
  }
189
173
  })])])])]);
190
-
191
174
  if (slotIsSet()) {
192
175
  return svg;
193
176
  }
194
-
195
177
  return createElement('div', {
196
178
  class: 'gl-skeleton-loader-default-container gl-max-w-full',
197
179
  style: {
@@ -200,7 +182,6 @@ var script = {
200
182
  }
201
183
  }, [svg]);
202
184
  }
203
-
204
185
  };
205
186
 
206
187
  /* script */
@@ -9,18 +9,15 @@ var script = {
9
9
  type: Number,
10
10
  required: false,
11
11
  default: 3,
12
-
13
12
  validator(value) {
14
13
  return value > 0 && value < 4;
15
14
  }
16
-
17
15
  }
18
16
  },
19
17
  computed: {
20
18
  lineClasses() {
21
19
  return new Array(this.lines).fill().map((_, i) => `skeleton-line-${i + 1}`);
22
20
  }
23
-
24
21
  }
25
22
  };
26
23
 
@@ -23,7 +23,6 @@ var script = {
23
23
  required: false,
24
24
  default: ''
25
25
  },
26
-
27
26
  /**
28
27
  * Determines the current sort order icon displayed.
29
28
  */
@@ -32,7 +31,6 @@ var script = {
32
31
  required: false,
33
32
  default: false
34
33
  },
35
-
36
34
  /**
37
35
  * The text of the tool tip for the sort direction toggle button.
38
36
  */
@@ -41,7 +39,6 @@ var script = {
41
39
  required: false,
42
40
  default: 'Sort direction'
43
41
  },
44
-
45
42
  /**
46
43
  * Additional class(es) to apply to the root element of the GlDropdown.
47
44
  */
@@ -50,7 +47,6 @@ var script = {
50
47
  required: false,
51
48
  default: ''
52
49
  },
53
-
54
50
  /**
55
51
  * Additional class(es) to apply to the dropdown toggle.
56
52
  */
@@ -59,7 +55,6 @@ var script = {
59
55
  required: false,
60
56
  default: ''
61
57
  },
62
-
63
58
  /**
64
59
  * Additional class(es) to apply to the sort direction toggle button.
65
60
  */
@@ -73,15 +68,14 @@ var script = {
73
68
  localSortDirection() {
74
69
  return this.isAscending ? 'sort-lowest' : 'sort-highest';
75
70
  },
76
-
77
71
  sortDirectionAriaLabel() {
78
72
  return this.isAscending ? 'Sorting Direction: Ascending' : 'Sorting Direction: Descending';
79
73
  }
80
-
81
74
  },
82
75
  methods: {
83
76
  toggleSortDirection() {
84
77
  const newDirection = !this.isAscending;
78
+
85
79
  /**
86
80
  * Emitted when the sort direction button is clicked.
87
81
  *
@@ -90,10 +84,8 @@ var script = {
90
84
  *
91
85
  * @property {boolean} isAscending
92
86
  */
93
-
94
87
  this.$emit('sortDirectionChange', newDirection);
95
88
  }
96
-
97
89
  }
98
90
  };
99
91
 
@@ -25,7 +25,6 @@ var script = {
25
25
  default: false,
26
26
  required: false
27
27
  },
28
-
29
28
  /**
30
29
  * If given, makes the item a link pointing to the given value. Otherwise,
31
30
  * the item is a button.
@@ -36,7 +35,6 @@ var script = {
36
35
  required: false
37
36
  }
38
37
  },
39
-
40
38
  /**
41
39
  * The content of the item.
42
40
  * @slot default
@@ -56,19 +54,19 @@ var script = {
56
54
  ariaLabel: 'Selected'
57
55
  }
58
56
  });
59
- return createElement(GlDropdownItem, { ...data,
60
- attrs: { ...props
57
+ return createElement(GlDropdownItem, {
58
+ ...data,
59
+ attrs: {
60
+ ...props
61
61
  },
62
62
  scopedSlots: {
63
63
  default: () => {
64
64
  var _scopedSlots$default;
65
-
66
65
  return [icon, (_scopedSlots$default = scopedSlots.default) === null || _scopedSlots$default === void 0 ? void 0 : _scopedSlots$default.call(scopedSlots)];
67
66
  }
68
67
  }
69
68
  });
70
69
  }
71
-
72
70
  };
73
71
 
74
72
  /* script */
@@ -4,7 +4,6 @@ import { tableFullProps, tableFullSlots, glTableLiteWarning } from './constants'
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
6
6
  //
7
-
8
7
  const shouldUseFullTable = _ref => {
9
8
  let {
10
9
  $attrs,
@@ -12,13 +11,11 @@ const shouldUseFullTable = _ref => {
12
11
  } = _ref;
13
12
  return tableFullProps.some(prop => $attrs[prop] !== undefined) || tableFullSlots.some(slot => $scopedSlots[slot] !== undefined);
14
13
  };
15
-
16
14
  var script = {
17
15
  components: {
18
16
  BTable
19
17
  },
20
18
  inheritAttrs: false,
21
-
22
19
  mounted() {
23
20
  // logWarning will call isDev before logging any message
24
21
  // this additional call to isDev is being made to exit the condition early when run in production
@@ -26,7 +23,6 @@ var script = {
26
23
  logWarning(glTableLiteWarning);
27
24
  }
28
25
  }
29
-
30
26
  };
31
27
 
32
28
  /* script */
@@ -15,7 +15,6 @@ var script = {
15
15
  required: false,
16
16
  default: ''
17
17
  },
18
-
19
18
  /**
20
19
  * Query string parameter value to use when `gl-tabs` `sync-active-tab-with-query-params` prop is set to `true`.
21
20
  */
@@ -30,20 +29,17 @@ var script = {
30
29
  const {
31
30
  titleLinkClass
32
31
  } = this;
33
-
34
32
  if (_isArray(titleLinkClass)) {
35
33
  return [...titleLinkClass, DEFAULT_TAB_TITLE_LINK_CLASS];
36
34
  }
37
-
38
35
  if (_isPlainObject(titleLinkClass)) {
39
- return { ...titleLinkClass,
36
+ return {
37
+ ...titleLinkClass,
40
38
  [DEFAULT_TAB_TITLE_LINK_CLASS]: true
41
39
  };
42
40
  }
43
-
44
41
  return `${titleLinkClass} ${DEFAULT_TAB_TITLE_LINK_CLASS}`.trim();
45
42
  }
46
-
47
43
  }
48
44
  };
49
45
 
@@ -15,7 +15,6 @@ var script = {
15
15
  GlResizeObserverDirective
16
16
  },
17
17
  inheritAttrs: false,
18
-
19
18
  data() {
20
19
  return {
21
20
  width: 0,
@@ -25,40 +24,31 @@ var script = {
25
24
  navScrollWidth: 0
26
25
  };
27
26
  },
28
-
29
27
  computed: {
30
28
  navClass() {
31
29
  const attrsNavClass = this.$attrs.navClass;
32
-
33
30
  if (!attrsNavClass) {
34
31
  return [NAV_CLASS];
35
32
  }
36
-
37
33
  if (_isArray(attrsNavClass)) {
38
34
  return [NAV_CLASS, ...attrsNavClass];
39
35
  }
40
-
41
36
  return [NAV_CLASS, attrsNavClass];
42
37
  },
43
-
44
38
  displayScrollLeft() {
45
39
  // if we have scrolled && there's overflow
46
40
  return this.scrollLeft && this.width < this.navScrollWidth;
47
41
  },
48
-
49
42
  displayScrollRight() {
50
43
  // if there's more overflow to the right
51
44
  return this.scrollLeft + this.width < this.navScrollWidth;
52
45
  },
53
-
54
46
  passthroughAttrs() {
55
47
  return Object.keys(this.$attrs).filter(key => !key.startsWith('action')).reduce((acc, key) => Object.assign(acc, {
56
48
  [key]: this.$attrs[key]
57
49
  }), {});
58
50
  }
59
-
60
51
  },
61
-
62
52
  mounted() {
63
53
  this.$nextTick(() => {
64
54
  this.navScrollWidth = this.getScrollWidth();
@@ -68,18 +58,15 @@ var script = {
68
58
  }, 100);
69
59
  this.getNavContainer().addEventListener('scroll', this.handleNavScroll);
70
60
  },
71
-
72
61
  beforeDestroy() {
73
62
  this.getNavContainer().removeEventListener('scroll', this.handleNavScroll);
74
63
  },
75
-
76
64
  updated() {
77
65
  // Whenever tabs are added or removed we need to recalculate the reactive scrollWidth
78
66
  this.$nextTick(() => {
79
67
  this.navScrollWidth = this.getScrollWidth();
80
68
  });
81
69
  },
82
-
83
70
  methods: {
84
71
  handleResize(_ref) {
85
72
  let {
@@ -90,17 +77,14 @@ var script = {
90
77
  this.width = width;
91
78
  this.navScrollWidth = this.getScrollWidth();
92
79
  },
93
-
94
80
  scrollTabsLeft() {
95
81
  const scrollTo = this.scrollLeft - this.width;
96
82
  this.scrollTabs(Math.max(scrollTo, 0));
97
83
  },
98
-
99
84
  scrollTabsRight() {
100
85
  const scrollTo = this.scrollLeft + this.width;
101
86
  this.scrollTabs(Math.min(scrollTo, this.getScrollWidth() - this.width));
102
87
  },
103
-
104
88
  scrollTabs(scrollTo) {
105
89
  this.getNavContainer().scrollTo({
106
90
  left: scrollTo,
@@ -108,19 +92,14 @@ var script = {
108
92
  });
109
93
  this.scrollLeft = scrollTo;
110
94
  },
111
-
112
95
  getScrollWidth() {
113
96
  var _this$getNavContainer;
114
-
115
97
  return ((_this$getNavContainer = this.getNavContainer()) === null || _this$getNavContainer === void 0 ? void 0 : _this$getNavContainer.scrollWidth) || 0;
116
98
  },
117
-
118
99
  getNavContainer() {
119
100
  var _this$$el;
120
-
121
101
  return (_this$$el = this.$el) === null || _this$$el === void 0 ? void 0 : _this$$el.querySelector(`.${NAV_CLASS}`);
122
102
  }
123
-
124
103
  },
125
104
  NAV_CLASS
126
105
  };
@@ -4,9 +4,7 @@ import GlButton from '../../button/button';
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
6
6
  //
7
-
8
7
  const validatorHelper = obj => Object.keys(obj).every(val => val === 'text' || val === 'attributes');
9
-
10
8
  var script = {
11
9
  components: {
12
10
  BTabs,
@@ -47,7 +45,6 @@ var script = {
47
45
  required: false,
48
46
  default: false
49
47
  },
50
-
51
48
  /**
52
49
  * Sync active tab with query string parameters. Allows for deep linking into specific tabs.
53
50
  */
@@ -56,7 +53,6 @@ var script = {
56
53
  required: false,
57
54
  default: false
58
55
  },
59
-
60
56
  /**
61
57
  * Name to use for query string parameter.
62
58
  */
@@ -71,24 +67,21 @@ var script = {
71
67
  default: 0
72
68
  }
73
69
  },
74
-
75
70
  data() {
76
71
  return {
77
72
  activeTabIndex: 0
78
73
  };
79
74
  },
80
-
81
75
  computed: {
82
76
  hasActions() {
83
77
  return [this.actionPrimary, this.actionSecondary, this.actionTertiary].some(Boolean);
84
78
  },
85
-
86
79
  listeners() {
87
- return { ...this.$listeners,
80
+ return {
81
+ ...this.$listeners,
88
82
  input: this.handleInput
89
83
  };
90
84
  }
91
-
92
85
  },
93
86
  watch: {
94
87
  value: {
@@ -97,49 +90,40 @@ var script = {
97
90
  this.activeTabIndex = newValue;
98
91
  }
99
92
  },
100
-
101
93
  immediate: true
102
94
  }
103
95
  },
104
-
105
96
  mounted() {
106
97
  if (this.syncActiveTabWithQueryParams) {
107
98
  this.syncActiveTabFromQueryParams();
108
99
  window.addEventListener('popstate', this.syncActiveTabFromQueryParams);
109
- } // Because we are manually binding `value` attribute to `b-tabs` the `input`
100
+ }
101
+
102
+ // Because we are manually binding `value` attribute to `b-tabs` the `input`
110
103
  // event is no longer automatically fired when the component is mounted.
111
104
  // To maintain parity with original `b-tabs` functionality
112
105
  // we manually fire the `input` event when the component is mounted.
113
-
114
-
115
106
  this.$emit('input', this.activeTabIndex);
116
107
  },
117
-
118
108
  destroyed() {
119
109
  window.removeEventListener('popstate', this.syncActiveTabFromQueryParams);
120
110
  },
121
-
122
111
  methods: {
123
112
  buttonBinding(prop, name) {
124
113
  if (!prop.attributes) {
125
114
  return tabsButtonDefaults[name];
126
115
  }
127
-
128
116
  return prop.attributes;
129
117
  },
130
-
131
118
  primary() {
132
119
  this.$emit('primary');
133
120
  },
134
-
135
121
  secondary() {
136
122
  this.$emit('secondary');
137
123
  },
138
-
139
124
  tertiary() {
140
125
  this.$emit('tertiary');
141
126
  },
142
-
143
127
  /**
144
128
  * When the query parameter is updated, update the active tab to match.
145
129
  */
@@ -148,14 +132,12 @@ var script = {
148
132
  const tabIndexToActivate = this.getTabs().findIndex((tab, tabIndex) => this.getTabQueryParamValue(tabIndex) === queryParamValue);
149
133
  this.activeTabIndex = tabIndexToActivate !== -1 ? tabIndexToActivate : 0;
150
134
  },
151
-
152
135
  /**
153
136
  * Returns a list of all <b-tab> instances associated with this tab control.
154
137
  */
155
138
  getTabs() {
156
139
  return this.$refs.bTabs.getTabs();
157
140
  },
158
-
159
141
  /**
160
142
  * Get the value of the query param as defined by the `queryParamName` prop.
161
143
  */
@@ -163,31 +145,27 @@ var script = {
163
145
  const searchParams = new URLSearchParams(window.location.search);
164
146
  return searchParams.get(this.queryParamName);
165
147
  },
166
-
167
148
  /**
168
149
  * Set the value of the query param as defined by the `queryParamName` prop.
169
150
  * This method does nothing if the query param is already up to date.
170
151
  */
171
152
  setQueryParamValueIfNecessary(tabIndex) {
172
153
  const currentQueryParamValue = this.getQueryParamValue();
173
- const newQueryParamValue = this.getTabQueryParamValue(tabIndex); // If the current query parameter is already up-to-date,
174
- // avoid creating a duplicate history entry.
154
+ const newQueryParamValue = this.getTabQueryParamValue(tabIndex);
175
155
 
156
+ // If the current query parameter is already up-to-date,
157
+ // avoid creating a duplicate history entry.
176
158
  if (tabIndex === 0 && !currentQueryParamValue || tabIndex !== 0 && currentQueryParamValue === newQueryParamValue) {
177
159
  return;
178
160
  }
179
-
180
161
  const searchParams = new URLSearchParams(window.location.search);
181
-
182
162
  if (tabIndex === 0) {
183
163
  searchParams.delete(this.queryParamName);
184
164
  } else {
185
165
  searchParams.set(this.queryParamName, newQueryParamValue);
186
166
  }
187
-
188
167
  window.history.pushState({}, '', `${window.location.pathname}?${searchParams.toString()}`);
189
168
  },
190
-
191
169
  /**
192
170
  * Returns the query param value for a tab.
193
171
  * Defaults to the tab index unless the `query-param-value` attribute is set.
@@ -196,19 +174,16 @@ var script = {
196
174
  const tab = this.getTabs()[tabIndex];
197
175
  return (tab === null || tab === void 0 ? void 0 : tab.$attrs['query-param-value']) || tabIndex.toString();
198
176
  },
199
-
200
177
  /**
201
178
  * Event handler for `input` event.
202
179
  */
203
180
  handleInput(tabIndex) {
204
181
  this.$emit('input', tabIndex);
205
182
  this.activeTabIndex = tabIndex;
206
-
207
183
  if (this.syncActiveTabWithQueryParams) {
208
184
  this.setQueryParamValueIfNecessary(tabIndex);
209
185
  }
210
186
  }
211
-
212
187
  }
213
188
  };
214
189