@gitlab/ui 43.17.0 → 43.18.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 (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/base/filtered_search/filtered_search.js +18 -5
  3. package/dist/components/base/filtered_search/filtered_search_term.js +6 -1
  4. package/dist/components/base/filtered_search/filtered_search_token.js +28 -8
  5. package/dist/components/base/filtered_search/filtered_search_token_segment.js +10 -4
  6. package/dist/index.css +1 -1
  7. package/dist/index.css.map +1 -1
  8. package/dist/utils/constants.js +2 -1
  9. package/package.json +12 -12
  10. package/src/components/base/button/button.spec.js +1 -1
  11. package/src/components/base/datepicker/datepicker.spec.js +1 -1
  12. package/src/components/base/dropdown/dropdown.spec.js +1 -1
  13. package/src/components/base/filtered_search/filtered_search.spec.js +53 -2
  14. package/src/components/base/filtered_search/filtered_search.stories.js +13 -2
  15. package/src/components/base/filtered_search/filtered_search.vue +24 -6
  16. package/src/components/base/filtered_search/filtered_search_term.spec.js +23 -3
  17. package/src/components/base/filtered_search/filtered_search_term.vue +8 -0
  18. package/src/components/base/filtered_search/filtered_search_token.scss +10 -8
  19. package/src/components/base/filtered_search/filtered_search_token.spec.js +74 -21
  20. package/src/components/base/filtered_search/filtered_search_token.vue +25 -4
  21. package/src/components/base/filtered_search/filtered_search_token_segment.spec.js +18 -0
  22. package/src/components/base/filtered_search/filtered_search_token_segment.vue +10 -3
  23. package/src/components/base/form/form_checkbox/form_checkbox.scss +1 -1
  24. package/src/components/base/form/form_checkbox/form_checkbox.stories.js +20 -8
  25. package/src/components/base/form/form_radio/form_radio.stories.js +30 -17
  26. package/src/components/base/link/link.spec.js +1 -1
  27. package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -1
  28. package/src/components/base/new_dropdowns/listbox/listbox.spec.js +4 -4
  29. package/src/components/base/new_dropdowns/listbox/listbox_item.spec.js +2 -2
  30. package/src/components/charts/area/area.spec.js +3 -3
  31. package/src/components/charts/line/line.spec.js +3 -3
  32. package/src/directives/outside/outside.spec.js +1 -1
  33. package/src/utils/constants.js +2 -0
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  import { last } from 'lodash';
3
3
  import { Portal } from 'portal-vue';
4
- import { COMMA } from '../../../utils/constants';
4
+ import { COMMA, LEFT_MOUSE_BUTTON } from '../../../utils/constants';
5
5
  import GlFilteredSearchSuggestion from './filtered_search_suggestion.vue';
6
6
  import GlFilteredSearchSuggestionList from './filtered_search_suggestion_list.vue';
7
7
  import { splitOnQuotes, wrapTokenInQuotes } from './filtered_search_utils';
@@ -83,6 +83,11 @@ export default {
83
83
  default: 'end',
84
84
  validator: (value) => ['start', 'end'].includes(value),
85
85
  },
86
+ viewOnly: {
87
+ type: Boolean,
88
+ required: false,
89
+ default: false,
90
+ },
86
91
  },
87
92
 
88
93
  data() {
@@ -181,7 +186,7 @@ export default {
181
186
 
182
187
  methods: {
183
188
  emitIfInactive(e) {
184
- if (!this.active) {
189
+ if (e.button === LEFT_MOUSE_BUTTON && !this.active) {
185
190
  /**
186
191
  * Emitted on mousedown event on the main component.
187
192
  */
@@ -334,9 +339,10 @@ export default {
334
339
  class="gl-filtered-search-token-segment"
335
340
  :class="{
336
341
  'gl-filtered-search-token-segment-active': active,
342
+ 'gl-cursor-text!': viewOnly,
337
343
  }"
338
344
  data-testid="filtered-search-token-segment"
339
- @mousedown.left="emitIfInactive"
345
+ v-on="viewOnly ? {} : { mousedown: emitIfInactive }"
340
346
  >
341
347
  <template v-if="active">
342
348
  <input
@@ -345,6 +351,7 @@ export default {
345
351
  v-model="inputValue"
346
352
  class="gl-filtered-search-token-segment-input"
347
353
  :aria-label="label"
354
+ :readonly="viewOnly"
348
355
  @keydown="handleInputKeydown"
349
356
  @blur="handleBlur"
350
357
  />
@@ -134,7 +134,7 @@
134
134
  }
135
135
 
136
136
  .custom-control-input:checked:disabled ~ .custom-control-label,
137
- .custom-control-input:indeterminate:disabled ~ .custom-control-label {
137
+ .custom-control-input[type='checkbox']:indeterminate:disabled ~ .custom-control-label {
138
138
  &::before {
139
139
  @include gl-bg-gray-100;
140
140
  @include gl-border-gray-100;
@@ -6,22 +6,34 @@ const components = {
6
6
  GlFormCheckboxGroup,
7
7
  };
8
8
 
9
+ const data = () => ({
10
+ selected: ['checked-option', 'checked-disabled-option'],
11
+ indeterminate: true,
12
+ });
13
+
9
14
  const template = `
10
- <gl-form-checkbox-group>
15
+ <div>
16
+ <gl-form-checkbox-group v-model="selected">
17
+ <gl-form-checkbox value="option">Option</gl-form-checkbox>
18
+ <gl-form-checkbox value="slot-option">
19
+ Slot option
20
+ <template #help> With help text </template>
21
+ </gl-form-checkbox>
22
+ <gl-form-checkbox value="checked-option">Checked option</gl-form-checkbox>
23
+ <gl-form-checkbox value="checked-disabled-option" :disabled="true">Checked disabled option</gl-form-checkbox>
24
+ <gl-form-checkbox value="disabled-option" :disabled="true">Disabled option</gl-form-checkbox>
11
25
  <template #first>
12
- <gl-form-checkbox value="Slot option">
13
- Slot option with help text
14
- <template #help>
15
- Help text
16
- </template>
17
- </gl-form-checkbox>
26
+ <gl-form-checkbox value="first">First</gl-form-checkbox>
18
27
  </template>
19
- <gl-form-checkbox value="Last option">Last option</gl-form-checkbox>
20
28
  </gl-form-checkbox-group>
29
+ <gl-form-checkbox value="indeterminate-option" :indeterminate="indeterminate">Indeterminate option</gl-form-checkbox>
30
+ <gl-form-checkbox value="indeterminate-disabled-option" :indeterminate="indeterminate" :disabled="true">Indeterminate disabled option</gl-form-checkbox>
31
+ </div>
21
32
  `;
22
33
 
23
34
  const Template = () => ({
24
35
  components,
36
+ data,
25
37
  template,
26
38
  });
27
39
 
@@ -2,31 +2,44 @@ import { GlFormRadio } from '../../../../index';
2
2
  import readme from './form_radio.md';
3
3
 
4
4
  const defaultOptions = [
5
- { value: 'Pizza', text: 'Pizza' },
6
- { value: 'Tacos', text: 'Tacos' },
7
- { value: 'Burger', text: 'Burger', disabled: true },
5
+ { value: 'Option', name: 'radio-group' },
6
+ { value: 'Slot option', name: 'radio-group', slot: 'With help text' },
7
+ { value: 'Checked option', name: 'radio-group' },
8
+ {
9
+ value: 'Checked disabled option',
10
+ disabled: true,
11
+ name: 'last-radio-group',
12
+ checked: 'Checked disabled option',
13
+ },
14
+ { value: 'Disabled option', disabled: true, name: 'radio-group' },
15
+ { value: 'Indeterminate option', name: 'indeterminate-radio-group' },
16
+ { value: 'Indeterminate disabled option', disabled: true, name: 'indeterminate-radio-group' },
8
17
  ];
9
18
 
10
- const generateProps = ({ name = 'radio-group-name', checked = defaultOptions[0].value } = {}) => ({
11
- name,
19
+ const template = `
20
+ <div>
21
+ <gl-form-radio
22
+ v-for="option in options"
23
+ :key="option.value"
24
+ :checked="option.checked || checked"
25
+ :disabled="option.disabled"
26
+ :name="option.name || name"
27
+ :value="option.value"
28
+ >
29
+ {{ option.value }}
30
+ <template v-if="option.slot" #help>{{ option.slot }}</template>
31
+ </gl-form-radio>
32
+ </div>
33
+ `;
34
+
35
+ const generateProps = ({ checked = 'Checked option' } = {}) => ({
12
36
  checked,
13
37
  });
14
38
 
15
39
  const Template = (args) => ({
16
40
  components: { GlFormRadio },
17
41
  props: Object.keys(args),
18
- template: `
19
- <div>
20
- <gl-form-radio
21
- v-for="option in options"
22
- :key="option.value"
23
- :checked="checked"
24
- :value="option.value"
25
- :disabled="option.disabled"
26
- :name="name"
27
- >{{ option.text }}</gl-form-radio>
28
- </div>
29
- `,
42
+ template,
30
43
  data() {
31
44
  return {
32
45
  options: defaultOptions,
@@ -64,7 +64,7 @@ describe('link component', () => {
64
64
 
65
65
  // GlSafeLinkDirective is actually responsible to handle the unsafe URLs
66
66
  // and GlLink uses this directive to make all the links secure by default
67
- it('should set href to blank ', () => {
67
+ it('should set href to blank', () => {
68
68
  createWrapper({
69
69
  propsData: {
70
70
  href: unsafeUrl,
@@ -135,7 +135,7 @@ describe('base dropdown', () => {
135
135
  buildWrapper();
136
136
  });
137
137
 
138
- it('should toggle menu visibility on toggle button click ', async () => {
138
+ it('should toggle menu visibility on toggle button click', async () => {
139
139
  const toggle = findDropdownToggle();
140
140
  const menu = findDropdownMenu();
141
141
 
@@ -52,7 +52,7 @@ describe('GlListbox', () => {
52
52
  });
53
53
 
54
54
  describe('ARIA attributes', () => {
55
- it('should provide `toggleId` to the base dropdown and reference it in`aria-labelledby` attribute of the list container` ', async () => {
55
+ it('should provide `toggleId` to the base dropdown and reference it in`aria-labelledby` attribute of the list container`', async () => {
56
56
  await buildWrapper();
57
57
  expect(findBaseDropdown().props('toggleId')).toBe(
58
58
  findListContainer().attributes('aria-labelledby')
@@ -70,7 +70,7 @@ describe('GlListbox', () => {
70
70
  });
71
71
  });
72
72
 
73
- it('should render items as selected when `selected` provided ', () => {
73
+ it('should render items as selected when `selected` provided', () => {
74
74
  expect(findListboxItems().at(1).props('isSelected')).toBe(true);
75
75
  expect(findListboxItems().at(2).props('isSelected')).toBe(true);
76
76
  });
@@ -106,7 +106,7 @@ describe('GlListbox', () => {
106
106
  expect(wrapper).toHaveLoggedVueErrors();
107
107
  });
108
108
 
109
- it('should render item as selected when `selected` provided ', () => {
109
+ it('should render item as selected when `selected` provided', () => {
110
110
  expect(findListboxItems().at(1).props('isSelected')).toBe(true);
111
111
  });
112
112
 
@@ -124,7 +124,7 @@ describe('GlListbox', () => {
124
124
  buildWrapper({ selected, items: mockGroups });
125
125
  });
126
126
 
127
- it('should render item as selected when `selected` provided ', () => {
127
+ it('should render item as selected when `selected` provided', () => {
128
128
  expect(findListboxItems().at(3).props('isSelected')).toBe(true);
129
129
  });
130
130
 
@@ -17,7 +17,7 @@ describe('GlListboxItem', () => {
17
17
  const findCheckIcon = () => findItem().findComponent(GLIcon);
18
18
 
19
19
  describe('toggleSelection', () => {
20
- describe('when selected ', () => {
20
+ describe('when selected', () => {
21
21
  beforeEach(() => {
22
22
  buildWrapper({ isSelected: true });
23
23
  });
@@ -48,7 +48,7 @@ describe('GlListboxItem', () => {
48
48
  });
49
49
  });
50
50
 
51
- describe('when not selected ', () => {
51
+ describe('when not selected', () => {
52
52
  beforeEach(() => {
53
53
  buildWrapper({ isSelected: false });
54
54
  });
@@ -46,7 +46,7 @@ describe('area component', () => {
46
46
  });
47
47
 
48
48
  describe('Annotations tooltips', () => {
49
- it('are hidden by default ', async () => {
49
+ it('are hidden by default', async () => {
50
50
  createShallowWrapper();
51
51
 
52
52
  await wrapper.vm.$nextTick();
@@ -54,7 +54,7 @@ describe('area component', () => {
54
54
  expect(findAnnotationsTooltip().exists()).toBe(false);
55
55
  });
56
56
 
57
- it('are displayed if passed via annotations props ', async () => {
57
+ it('are displayed if passed via annotations props', async () => {
58
58
  createShallowWrapper({
59
59
  annotations: [
60
60
  {
@@ -69,7 +69,7 @@ describe('area component', () => {
69
69
  expect(findAnnotationsTooltip().exists()).toBe(true);
70
70
  });
71
71
 
72
- it('are displayed if passed via option props ', async () => {
72
+ it('are displayed if passed via option props', async () => {
73
73
  createShallowWrapper({
74
74
  option: {
75
75
  series: [
@@ -45,7 +45,7 @@ describe('line component', () => {
45
45
  });
46
46
 
47
47
  describe('Annotations tooltips', () => {
48
- it('are hidden by default ', async () => {
48
+ it('are hidden by default', async () => {
49
49
  createShallowWrapper();
50
50
 
51
51
  await wrapper.vm.$nextTick();
@@ -53,7 +53,7 @@ describe('line component', () => {
53
53
  expect(findAnnotationsTooltip().exists()).toBe(false);
54
54
  });
55
55
 
56
- it('are displayed if passed via annotations props ', async () => {
56
+ it('are displayed if passed via annotations props', async () => {
57
57
  createShallowWrapper({
58
58
  annotations: [
59
59
  {
@@ -68,7 +68,7 @@ describe('line component', () => {
68
68
  expect(findAnnotationsTooltip().exists()).toBe(true);
69
69
  });
70
70
 
71
- it('are displayed if passed via option props ', async () => {
71
+ it('are displayed if passed via option props', async () => {
72
72
  createShallowWrapper({
73
73
  option: {
74
74
  series: [
@@ -252,7 +252,7 @@ describe('outside directive', () => {
252
252
  });
253
253
  });
254
254
 
255
- describe('click event fired before directive binding ', () => {
255
+ describe('click event fired before directive binding', () => {
256
256
  // This *attempts* to simulate something like the following situation:
257
257
  //
258
258
  // <button @click="show = true">Show</button>
@@ -8,6 +8,8 @@ function appendDefaultOption(options) {
8
8
 
9
9
  export const COMMA = ',';
10
10
 
11
+ export const LEFT_MOUSE_BUTTON = 0;
12
+
11
13
  export const glThemes = ['indigo', 'blue', 'light-blue', 'green', 'red', 'light-red'];
12
14
 
13
15
  export const variantOptions = {