@gitlab/ui 38.0.1 → 38.2.1

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 (140) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -1
  3. package/dist/components/base/breadcrumb/breadcrumb.js +10 -5
  4. package/dist/components/base/{filtered_search/examples/filtered_search.single_unique.example.js → breadcrumb/breadcrumb_item.js} +32 -28
  5. package/dist/components/base/dropdown/dropdown.documentation.js +1 -5
  6. package/dist/components/base/dropdown/dropdown_item.documentation.js +2 -3
  7. package/dist/components/base/filtered_search/filtered_search.documentation.js +2 -66
  8. package/dist/components/base/filtered_search/filtered_search.js +51 -20
  9. package/dist/components/base/filtered_search/filtered_search_suggestion.documentation.js +2 -8
  10. package/dist/components/base/filtered_search/filtered_search_suggestion.js +5 -1
  11. package/dist/components/base/filtered_search/filtered_search_suggestion_list.documentation.js +2 -7
  12. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +4 -0
  13. package/dist/components/base/filtered_search/filtered_search_term.documentation.js +2 -44
  14. package/dist/components/base/filtered_search/filtered_search_term.js +37 -0
  15. package/dist/components/base/filtered_search/filtered_search_token.documentation.js +2 -31
  16. package/dist/components/base/filtered_search/filtered_search_token.js +80 -23
  17. package/dist/components/base/filtered_search/filtered_search_token_segment.documentation.js +2 -46
  18. package/dist/components/base/filtered_search/filtered_search_token_segment.js +48 -0
  19. package/dist/components/base/filtered_search/filtered_search_utils.js +42 -9
  20. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.documentation.js +2 -27
  21. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +16 -1
  22. package/dist/components/charts/series_label/series_label.js +6 -1
  23. package/dist/index.css +1 -1
  24. package/dist/index.css.map +1 -1
  25. package/dist/utils/use_mock_intersection_observer.js +2 -2
  26. package/documentation/components_documentation.js +0 -4
  27. package/documentation/documented_stories.js +10 -1
  28. package/package.json +11 -9
  29. package/src/components/base/avatar_link/avatar_link.stories.js +2 -2
  30. package/src/components/base/breadcrumb/breadcrumb.spec.js +24 -10
  31. package/src/components/base/breadcrumb/breadcrumb.vue +11 -6
  32. package/src/components/base/breadcrumb/breadcrumb_item.spec.js +45 -0
  33. package/src/components/base/breadcrumb/breadcrumb_item.vue +43 -0
  34. package/src/components/base/dropdown/dropdown.documentation.js +0 -3
  35. package/src/components/base/dropdown/dropdown.md +7 -2
  36. package/src/components/base/dropdown/dropdown.stories.js +487 -439
  37. package/src/components/base/dropdown/dropdown_item.documentation.js +0 -1
  38. package/src/components/base/dropdown/dropdown_item.md +0 -6
  39. package/src/components/base/dropdown/dropdown_item.stories.js +107 -35
  40. package/src/components/base/filtered_search/filtered_search.documentation.js +0 -76
  41. package/src/components/base/filtered_search/filtered_search.md +3 -4
  42. package/src/components/base/filtered_search/filtered_search.spec.js +37 -12
  43. package/src/components/base/filtered_search/filtered_search.stories.js +260 -17
  44. package/src/components/base/filtered_search/filtered_search.vue +57 -14
  45. package/src/components/base/filtered_search/filtered_search_suggestion.documentation.js +0 -6
  46. package/src/components/base/filtered_search/filtered_search_suggestion.md +1 -7
  47. package/src/components/base/filtered_search/filtered_search_suggestion.stories.js +26 -18
  48. package/src/components/base/filtered_search/filtered_search_suggestion.vue +6 -0
  49. package/src/components/base/filtered_search/filtered_search_suggestion_list.documentation.js +0 -5
  50. package/src/components/base/filtered_search/filtered_search_suggestion_list.md +1 -7
  51. package/src/components/base/filtered_search/filtered_search_suggestion_list.stories.js +33 -25
  52. package/src/components/base/filtered_search/filtered_search_suggestion_list.vue +5 -0
  53. package/src/components/base/filtered_search/filtered_search_term.documentation.js +0 -41
  54. package/src/components/base/filtered_search/filtered_search_term.md +0 -2
  55. package/src/components/base/filtered_search/filtered_search_term.stories.js +33 -26
  56. package/src/components/base/filtered_search/filtered_search_term.vue +54 -0
  57. package/src/components/base/filtered_search/filtered_search_token.documentation.js +0 -26
  58. package/src/components/base/filtered_search/filtered_search_token.md +1 -3
  59. package/src/components/base/filtered_search/filtered_search_token.spec.js +31 -1
  60. package/src/components/base/filtered_search/filtered_search_token.stories.js +137 -132
  61. package/src/components/base/filtered_search/filtered_search_token.vue +93 -21
  62. package/src/components/base/filtered_search/filtered_search_token_segment.documentation.js +0 -43
  63. package/src/components/base/filtered_search/filtered_search_token_segment.md +0 -2
  64. package/src/components/base/filtered_search/filtered_search_token_segment.stories.js +86 -79
  65. package/src/components/base/filtered_search/filtered_search_token_segment.vue +42 -0
  66. package/src/components/base/filtered_search/filtered_search_utils.js +38 -5
  67. package/src/components/base/form/form.stories.js +2 -0
  68. package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.documentation.js +0 -26
  69. package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.md +0 -4
  70. package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.stories.js +123 -92
  71. package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.vue +13 -1
  72. package/src/components/base/form/form_radio/form_radio.spec.js +21 -8
  73. package/src/components/base/form/form_radio_group/form_radio_group.stories.js +2 -1
  74. package/src/components/base/markdown/markdown.scss +21 -0
  75. package/src/components/base/markdown/markdown_typescale_demo.html +17 -6
  76. package/src/components/base/navbar/navbar.stories.js +2 -1
  77. package/src/components/base/skeleton_loader/skeleton_loader.stories.js +67 -21
  78. package/src/components/base/tabs/tabs/tabs.stories.js +2 -2
  79. package/src/components/charts/series_label/series_label.stories.js +6 -3
  80. package/src/components/charts/series_label/series_label.vue +3 -0
  81. package/src/scss/typescale/typescale.md +0 -2
  82. package/src/scss/typescale/typescale.stories.js +17 -4
  83. package/src/utils/use_mock_intersection_observer.js +3 -3
  84. package/dist/components/base/dropdown/dropdown_divider.documentation.js +0 -8
  85. package/dist/components/base/dropdown/dropdown_form.documentation.js +0 -17
  86. package/dist/components/base/dropdown/dropdown_section_header.documentation.js +0 -8
  87. package/dist/components/base/dropdown/dropdown_text.documentation.js +0 -8
  88. package/dist/components/base/dropdown/examples/dropdown.default.example.js +0 -38
  89. package/dist/components/base/dropdown/examples/dropdown.links.example.js +0 -38
  90. package/dist/components/base/dropdown/examples/dropdown.with_avatar_and_secondary_text.example.js +0 -38
  91. package/dist/components/base/dropdown/examples/dropdown.with_checked_items.example.js +0 -38
  92. package/dist/components/base/dropdown/examples/dropdown.with_clear_all.example.js +0 -38
  93. package/dist/components/base/dropdown/examples/dropdown.with_divider.example.js +0 -38
  94. package/dist/components/base/dropdown/examples/dropdown.with_form.example.js +0 -38
  95. package/dist/components/base/dropdown/examples/dropdown.with_header.example.js +0 -38
  96. package/dist/components/base/dropdown/examples/dropdown.with_highlighted_items.example.js +0 -38
  97. package/dist/components/base/dropdown/examples/dropdown.with_icons.example.js +0 -38
  98. package/dist/components/base/dropdown/examples/dropdown.with_right_align.example.js +0 -38
  99. package/dist/components/base/dropdown/examples/dropdown.with_search.example.js +0 -67
  100. package/dist/components/base/dropdown/examples/dropdown.with_section_headers.example.js +0 -38
  101. package/dist/components/base/dropdown/examples/index.js +0 -85
  102. package/dist/components/base/filtered_search/examples/filtered_search.default.example.js +0 -422
  103. package/dist/components/base/filtered_search/examples/filtered_search.friendly.example.js +0 -423
  104. package/dist/components/base/filtered_search/examples/filtered_search.history.example.js +0 -91
  105. package/dist/components/base/filtered_search/examples/filtered_search.multi_select.example.js +0 -196
  106. package/dist/components/base/filtered_search/examples/index.js +0 -32
  107. package/dist/components/base/form/form_checkbox_tree/examples/form_checkbox_tree.basic.example.js +0 -103
  108. package/dist/components/base/form/form_checkbox_tree/examples/index.js +0 -13
  109. package/src/components/base/dropdown/dropdown_divider.documentation.js +0 -6
  110. package/src/components/base/dropdown/dropdown_divider.md +0 -7
  111. package/src/components/base/dropdown/dropdown_divider.stories.js +0 -16
  112. package/src/components/base/dropdown/dropdown_form.documentation.js +0 -9
  113. package/src/components/base/dropdown/dropdown_form.md +0 -4
  114. package/src/components/base/dropdown/dropdown_form.stories.js +0 -17
  115. package/src/components/base/dropdown/dropdown_section_header.documentation.js +0 -6
  116. package/src/components/base/dropdown/dropdown_section_header.stories.js +0 -17
  117. package/src/components/base/dropdown/dropdown_text.documentation.js +0 -6
  118. package/src/components/base/dropdown/dropdown_text.stories.js +0 -16
  119. package/src/components/base/dropdown/examples/dropdown.default.example.vue +0 -7
  120. package/src/components/base/dropdown/examples/dropdown.links.example.vue +0 -7
  121. package/src/components/base/dropdown/examples/dropdown.with_avatar_and_secondary_text.example.vue +0 -7
  122. package/src/components/base/dropdown/examples/dropdown.with_checked_items.example.vue +0 -6
  123. package/src/components/base/dropdown/examples/dropdown.with_clear_all.example.vue +0 -7
  124. package/src/components/base/dropdown/examples/dropdown.with_divider.example.vue +0 -9
  125. package/src/components/base/dropdown/examples/dropdown.with_form.example.vue +0 -10
  126. package/src/components/base/dropdown/examples/dropdown.with_header.example.vue +0 -7
  127. package/src/components/base/dropdown/examples/dropdown.with_highlighted_items.example.vue +0 -9
  128. package/src/components/base/dropdown/examples/dropdown.with_icons.example.vue +0 -43
  129. package/src/components/base/dropdown/examples/dropdown.with_right_align.example.vue +0 -7
  130. package/src/components/base/dropdown/examples/dropdown.with_search.example.vue +0 -38
  131. package/src/components/base/dropdown/examples/dropdown.with_section_headers.example.vue +0 -10
  132. package/src/components/base/dropdown/examples/index.js +0 -99
  133. package/src/components/base/filtered_search/examples/filtered_search.default.example.vue +0 -298
  134. package/src/components/base/filtered_search/examples/filtered_search.friendly.example.vue +0 -300
  135. package/src/components/base/filtered_search/examples/filtered_search.history.example.vue +0 -50
  136. package/src/components/base/filtered_search/examples/filtered_search.multi_select.example.vue +0 -132
  137. package/src/components/base/filtered_search/examples/filtered_search.single_unique.example.vue +0 -31
  138. package/src/components/base/filtered_search/examples/index.js +0 -38
  139. package/src/components/base/form/form_checkbox_tree/examples/form_checkbox_tree.basic.example.vue +0 -77
  140. package/src/components/base/form/form_checkbox_tree/examples/index.js +0 -15
@@ -1,5 +1,4 @@
1
- import { withKnobs, select, boolean, text as textKnob } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
1
+ import iconSpriteInfo from '@gitlab/svgs/dist/icons.json';
3
2
  import {
4
3
  GlAvatar,
5
4
  GlIcon,
@@ -34,112 +33,60 @@ function addClass(component) {
34
33
  component.$el.querySelectorAll('.btn').forEach((el) => el.classList.add('gl-button'));
35
34
  }
36
35
 
37
- function generateProps({
38
- category = GlDropdown.props.category.default,
39
- variant = GlDropdown.props.variant.default,
40
- size = GlDropdown.props.size.default,
41
- block = false,
42
- icon = '',
43
- text = '',
44
- textSrOnly = false,
45
- loading = false,
46
- headerText = '',
47
- hideHeaderBorder = true,
48
- showClearAll = false,
49
- clearAllText = '',
50
- clearAllTextClass = '',
51
- showHighlightedItemsTitle = false,
52
- highlightedItemsTitle = '',
53
- highlightedItemsTitleClass = '',
54
- } = {}) {
55
- const props = {
56
- category: {
57
- type: String,
58
- default: select('category', buttonCategoryOptions, category),
59
- },
60
- variant: {
61
- type: String,
62
- default: select('variant', Object.values(dropdownVariantOptions), variant),
63
- },
64
- size: {
65
- type: String,
66
- default: select('size', buttonSizeOptions, size),
67
- },
68
- block: {
69
- type: Boolean,
70
- default: boolean('block', block),
71
- },
72
- disabled: {
73
- type: Boolean,
74
- default: boolean('disabled', false),
75
- },
76
- text: {
77
- type: String,
78
- default: textKnob('text', text),
79
- },
80
- textSrOnly: {
81
- type: Boolean,
82
- default: boolean('text sr-only', textSrOnly),
83
- },
84
- icon: {
85
- type: String,
86
- default: textKnob('icon svg name', icon),
87
- },
88
- split: {
89
- type: Boolean,
90
- default: boolean('split', false),
91
- },
92
- toggleClass: {
93
- type: String,
94
- default: textKnob('toggle class', ''),
95
- },
96
- loading: {
97
- type: Boolean,
98
- default: boolean('loading', loading),
99
- },
100
- headerText: {
101
- type: String,
102
- default: textKnob('header text', headerText),
103
- },
104
- hideHeaderBorder: {
105
- type: Boolean,
106
- default: boolean('no header border', hideHeaderBorder),
107
- },
108
- showClearAll: {
109
- type: Boolean,
110
- default: boolean('show clear all', showClearAll),
111
- },
112
- clearAllText: {
113
- type: String,
114
- default: textKnob('clear all text', clearAllText),
115
- },
116
- clearAllTextClass: {
117
- type: String,
118
- default: textKnob('clear all text class', clearAllTextClass),
119
- },
120
- showHighlightedItemsTitle: {
121
- type: Boolean,
122
- default: boolean('show highlighted items title', showHighlightedItemsTitle),
123
- },
124
- highlightedItemsTitle: {
125
- type: String,
126
- default: textKnob('highlighted items title', highlightedItemsTitle),
127
- },
128
- highlightedItemsTitleClass: {
129
- type: String,
130
- default: textKnob('highlighted items title class', highlightedItemsTitleClass),
131
- },
132
- right: {
133
- type: Boolean,
134
- default: boolean('right', false),
135
- },
136
- };
36
+ const defaultValue = (prop) => GlDropdown.props[prop].default;
137
37
 
138
- return props;
139
- }
38
+ const generateProps = ({
39
+ headerText = defaultValue('headerText'),
40
+ hideHeaderBorder = defaultValue('hideHeaderBorder'),
41
+ showClearAll = defaultValue('showClearAll'),
42
+ clearAllText = defaultValue('clearAllText'),
43
+ clearAllTextClass = defaultValue('clearAllTextClass'),
44
+ text = defaultValue('text'),
45
+ showHighlightedItemsTitle = defaultValue('showHighlightedItemsTitle'),
46
+ highlightedItemsTitle = defaultValue('highlightedItemsTitle'),
47
+ highlightedItemsTitleClass = defaultValue('highlightedItemsTitleClass'),
48
+ textSrOnly = defaultValue('textSrOnly'),
49
+ split = defaultValue('split'),
50
+ category = defaultValue('category'),
51
+ variant = defaultValue('variant'),
52
+ size = defaultValue('size'),
53
+ icon = defaultValue('icon'),
54
+ block = defaultValue('block'),
55
+ disabled = defaultValue('disabled'),
56
+ loading = defaultValue('loading'),
57
+ toggleClass = defaultValue('toggleClass'),
58
+ right = defaultValue('right'),
59
+ } = {}) => ({
60
+ headerText,
61
+ hideHeaderBorder,
62
+ showClearAll,
63
+ clearAllText,
64
+ clearAllTextClass,
65
+ text,
66
+ showHighlightedItemsTitle,
67
+ highlightedItemsTitle,
68
+ highlightedItemsTitleClass,
69
+ textSrOnly,
70
+ split,
71
+ category,
72
+ variant,
73
+ size,
74
+ icon,
75
+ block,
76
+ disabled,
77
+ loading,
78
+ toggleClass,
79
+ right,
80
+ });
81
+
82
+ const withContainer = (template, containerHeight = 150) => `
83
+ <div style="height: ${containerHeight}px;">
84
+ ${template}
85
+ </div>`;
140
86
 
141
- function wrap([template]) {
142
- return `
87
+ function wrap(template, containerHeight) {
88
+ return withContainer(
89
+ `
143
90
  <gl-dropdown
144
91
  ref="dropdown"
145
92
  :category="category"
@@ -164,350 +111,451 @@ function wrap([template]) {
164
111
  :right="right"
165
112
  >
166
113
  ${template}
167
- </gl-dropdown>`;
114
+ </gl-dropdown>`,
115
+ containerHeight
116
+ );
168
117
  }
169
118
 
170
119
  function clickDropdown(component) {
171
120
  component.$nextTick(() => component.$el.querySelector('.dropdown-toggle').click());
172
121
  }
173
122
 
174
- documentedStoriesOf('base/dropdown', readme)
175
- .addDecorator(withKnobs)
176
- .add('default', () => ({
177
- props: generateProps({ text: 'Some dropdown' }),
178
- components,
179
- template: wrap`
180
- <gl-dropdown-item>First item</gl-dropdown-item>
181
- <gl-dropdown-item>Second item</gl-dropdown-item>
182
- <gl-dropdown-item>Third item</gl-dropdown-item>
183
- <gl-dropdown-item>Fourth item</gl-dropdown-item>
184
- <gl-dropdown-item>Fifth item</gl-dropdown-item>
185
- <gl-dropdown-item>Sixth item</gl-dropdown-item>
186
- <gl-dropdown-item>Seventh item</gl-dropdown-item>
187
- <gl-dropdown-item>Eighth item</gl-dropdown-item>
188
- <gl-dropdown-item>Ninth item</gl-dropdown-item>
189
- <gl-dropdown-item>Tenth item</gl-dropdown-item>
190
- <gl-dropdown-item>Eleventh item</gl-dropdown-item>`,
191
- mounted() {
192
- clickDropdown(this);
193
- },
194
- updated() {
195
- addClass(this);
196
- },
197
- }))
198
- .add('secondary', () => ({
199
- props: generateProps({
200
- text: 'Some dropdown',
201
- category: buttonCategoryOptions.secondary,
202
- variant: dropdownVariantOptions.confirm,
203
- }),
204
- components,
205
- template: wrap`
206
- <gl-dropdown-item>First item</gl-dropdown-item>
207
- <gl-dropdown-item>Second item</gl-dropdown-item>
208
- <gl-dropdown-item>Third item</gl-dropdown-item>`,
209
- mounted() {
210
- clickDropdown(this);
211
- },
212
- updated() {
213
- addClass(this);
214
- },
215
- }))
216
- .add('with form', () => ({
217
- props: generateProps({ text: 'Some dropdown' }),
218
- components: { ...components, GlButton },
219
- template: wrap`
220
- <gl-dropdown-form class="gl-px-4">
221
- <gl-button>One</gl-button>
222
- <gl-button>Two</gl-button>
223
- <gl-button>Three</gl-button>
224
- </gl-dropdown-form>`,
225
- mounted() {
226
- clickDropdown(this);
227
- },
228
- }))
229
- .add('with divider', () => ({
230
- props: generateProps({ text: 'Some dropdown' }),
231
- components,
232
- template: wrap`
233
- <gl-dropdown-item>First item</gl-dropdown-item>
234
- <gl-dropdown-item>Second item</gl-dropdown-item>
235
- <gl-dropdown-divider />
236
- <gl-dropdown-item>Third item</gl-dropdown-item>
237
- <gl-dropdown-item>Fourth item</gl-dropdown-item>`,
238
- mounted() {
239
- clickDropdown(this);
240
- },
241
- updated() {
242
- addClass(this);
243
- },
244
- }))
245
- .add('with header and footer', () => ({
246
- props: generateProps({ text: 'Some dropdown', headerText: 'Header', hideHeaderBorder: true }),
247
- components: { ...components, GlSearchBoxByType },
248
- template: wrap`
249
- <template #header>
250
- <gl-search-box-by-type />
251
- </template>
252
- <gl-dropdown-item>First item</gl-dropdown-item>
253
- <gl-dropdown-item>Second item</gl-dropdown-item>
254
- <gl-dropdown-item>Third item</gl-dropdown-item>
255
- <gl-dropdown-item>Fourth item</gl-dropdown-item>
256
- <gl-dropdown-item>Fifth item</gl-dropdown-item>
257
- <gl-dropdown-item>Sixth item</gl-dropdown-item>
258
- <gl-dropdown-item>Seventh item</gl-dropdown-item>
259
- <gl-dropdown-item>Eigth item</gl-dropdown-item>
260
- <template #footer>
261
- <gl-dropdown-item>First footer item</gl-dropdown-item>
262
- <gl-dropdown-item>Second footer item</gl-dropdown-item>
263
- </template>`,
264
- mounted() {
265
- clickDropdown(this);
266
- },
267
- updated() {
268
- addClass(this);
269
- },
270
- }))
271
- .add('with section header', () => ({
272
- props: generateProps({ text: 'Some dropdown' }),
273
- components,
274
- template: wrap`
275
- <gl-dropdown-section-header>Header title</gl-dropdown-section-header>
276
- <gl-dropdown-item>First item</gl-dropdown-item>
277
- <gl-dropdown-item>Second item</gl-dropdown-item>
278
- <gl-dropdown-section-header>I am a really long header title which should wrap</gl-dropdown-section-header>
279
- <gl-dropdown-item>Third item</gl-dropdown-item>
280
- <gl-dropdown-item>Fourth item</gl-dropdown-item>`,
281
- mounted() {
282
- clickDropdown(this);
283
- },
284
- updated() {
285
- addClass(this);
286
- },
287
- }))
288
- .add('with checked items', () => ({
289
- props: generateProps({ text: 'Some dropdown' }),
290
- components,
291
- template: wrap`
292
- <gl-dropdown-item :is-check-item="true" :is-checked="true">Checked item</gl-dropdown-item>
293
- <gl-dropdown-item :is-check-item="true">Unchecked item</gl-dropdown-item>`,
294
- mounted() {
295
- clickDropdown(this);
296
- },
297
- updated() {
298
- addClass(this);
299
- },
300
- }))
301
- .add('with avatar and secondary text', () => ({
302
- props: generateProps({ text: 'Some dropdown' }),
303
- components,
304
- template: wrap`
305
- <gl-dropdown-item
306
- avatar-url="./img/avatar.png"
307
- secondary-text="@sytses"
308
- >
309
- Sid Sijbrandij
310
- </gl-dropdown-item>`,
311
- mounted() {
312
- clickDropdown(this);
313
- },
314
- updated() {
315
- addClass(this);
316
- },
317
- }))
318
- .add('with icons', () => ({
319
- props: generateProps({ text: 'Some dropdown' }),
320
- components,
321
- template: wrap`
322
- <gl-dropdown-item
323
- icon-color="info"
324
- icon-name="status_running"
325
- icon-right-name="retry"
326
- icon-right-aria-label="Retry"
327
- >
328
- Status running
329
- </gl-dropdown-item>
330
- <gl-dropdown-item
331
- icon-color="success"
332
- icon-name="status_success"
333
- icon-right-name="cancel"
334
- icon-right-aria-label="Cancel"
335
- >
336
- Status success
337
- </gl-dropdown-item>
338
- <gl-dropdown-item
339
- icon-color="warning"
340
- icon-name="status_warning"
341
- icon-right-name="cancel"
342
- icon-right-aria-label="Cancel"
343
- >
344
- Status warning
345
- </gl-dropdown-item>
346
- <gl-dropdown-item
347
- icon-color="danger"
348
- icon-name="status_failed"
349
- icon-right-name="cancel"
350
- icon-right-aria-label="Cancel"
351
- >
352
- Status failed
353
- </gl-dropdown-item>
354
- <gl-dropdown-item
355
- icon-name="status_manual"
356
- icon-right-name="cancel"
357
- icon-right-aria-label="Cancel"
358
- >
359
- Status manual
360
- </gl-dropdown-item>`,
361
- mounted() {
362
- clickDropdown(this);
363
- },
364
- updated() {
365
- addClass(this);
366
- },
367
- }))
368
- .add('full width', () => ({
369
- props: generateProps({ text: 'Some dropdown', block: true }),
370
- components,
371
- template: wrap`
372
- <gl-dropdown-item>First item</gl-dropdown-item>
373
- <gl-dropdown-item>Second item</gl-dropdown-item>
374
- <gl-dropdown-item>Last item</gl-dropdown-item>`,
375
- mounted() {
376
- clickDropdown(this);
377
- },
378
- updated() {
379
- addClass(this);
380
- },
381
- }))
382
- .add('with short text and wide width', () => ({
383
- props: generateProps(),
384
- components,
385
- template: `
386
- <gl-dropdown
387
- text="Some dropdown"
388
- :category="category"
389
- :variant="variant"
390
- :size="size"
391
- :block="block"
392
- :disabled="disabled"
393
- style="width: 300px;"
394
- >
395
- <gl-dropdown-item>First item</gl-dropdown-item>
396
- <gl-dropdown-item>Last item</gl-dropdown-item>
397
- </gl-dropdown>`,
398
- mounted() {
399
- clickDropdown(this);
400
- },
401
- updated() {
402
- addClass(this);
403
- },
404
- }))
405
- .add('with long text and narrow width', () => ({
406
- props: generateProps({ block: true }),
407
- components,
408
- template: `
409
- <gl-dropdown
410
- text="Truncated text dropdown"
411
- :category="category"
412
- :variant="variant"
413
- :size="size"
414
- :block="block"
415
- :disabled="disabled"
416
- style="width: 160px;"
417
- >
418
- <gl-dropdown-item>First item</gl-dropdown-item>
419
- <gl-dropdown-item>Last item</gl-dropdown-item>
420
- </gl-dropdown>`,
421
- mounted() {
422
- clickDropdown(this);
423
- },
424
- updated() {
425
- addClass(this);
426
- },
427
- }))
428
- .add('with item text that does not wrap', () => ({
429
- props: generateProps({ text: 'Some dropdown' }),
430
- components,
431
- template: wrap`
432
- <gl-dropdown-item icon-right-name="star" icon-right-aria-label="Some action">
433
- Normal item
434
- </gl-dropdown-item>
435
- <gl-dropdown-item icon-right-name="star" icon-right-aria-label="Some action">
436
- <div class="gl-text-truncate">ellipsis/should/truncate/this/item</div>
437
- </gl-dropdown-item>`,
438
- mounted() {
439
- clickDropdown(this);
440
- },
441
- updated() {
442
- addClass(this);
443
- },
444
- }))
445
- .add('icon only', () => ({
446
- props: generateProps({ icon: 'ellipsis_v', text: 'More actions', textSrOnly: true }),
447
- components,
448
- template: wrap`
123
+ export const Default = (_args, { argTypes }) => ({
124
+ props: Object.keys(argTypes),
125
+ components,
126
+ template: wrap(
127
+ `
128
+ <gl-dropdown-item>First item</gl-dropdown-item>
129
+ <gl-dropdown-item>Second item</gl-dropdown-item>
130
+ <gl-dropdown-item>Third item</gl-dropdown-item>
131
+ <gl-dropdown-item>Fourth item</gl-dropdown-item>
132
+ <gl-dropdown-item>Fifth item</gl-dropdown-item>
133
+ <gl-dropdown-item>Sixth item</gl-dropdown-item>
134
+ <gl-dropdown-item>Seventh item</gl-dropdown-item>
135
+ <gl-dropdown-item>Eighth item</gl-dropdown-item>
136
+ <gl-dropdown-item>Ninth item</gl-dropdown-item>
137
+ <gl-dropdown-item>Tenth item</gl-dropdown-item>
138
+ <gl-dropdown-item>Eleventh item</gl-dropdown-item>`,
139
+ 340
140
+ ),
141
+ mounted() {
142
+ clickDropdown(this);
143
+ },
144
+ updated() {
145
+ addClass(this);
146
+ },
147
+ });
148
+ Default.args = generateProps({ text: 'Some dropdown' });
149
+
150
+ export const Secondary = (_args, { argTypes }) => ({
151
+ props: Object.keys(argTypes),
152
+ components,
153
+ template: wrap(`
154
+ <gl-dropdown-item>First item</gl-dropdown-item>
155
+ <gl-dropdown-item>Second item</gl-dropdown-item>
156
+ <gl-dropdown-item>Third item</gl-dropdown-item>`),
157
+ mounted() {
158
+ clickDropdown(this);
159
+ },
160
+ updated() {
161
+ addClass(this);
162
+ },
163
+ });
164
+ Secondary.args = generateProps({
165
+ text: 'Some dropdown',
166
+ category: buttonCategoryOptions.secondary,
167
+ variant: dropdownVariantOptions.confirm,
168
+ });
169
+
170
+ export const WithForm = (_args, { argTypes }) => ({
171
+ props: Object.keys(argTypes),
172
+ components: { ...components, GlButton },
173
+ template: wrap(`
174
+ <gl-dropdown-form class="gl-px-4">
175
+ <gl-button>One</gl-button>
176
+ <gl-button>Two</gl-button>
177
+ <gl-button>Three</gl-button>
178
+ </gl-dropdown-form>`),
179
+ mounted() {
180
+ clickDropdown(this);
181
+ },
182
+ });
183
+ WithForm.args = generateProps({ text: 'Some dropdown' });
184
+
185
+ export const WithDivider = (args, { argTypes }) => ({
186
+ props: Object.keys(argTypes),
187
+ components,
188
+ template: wrap(
189
+ `
190
+ <gl-dropdown-item>First item</gl-dropdown-item>
191
+ <gl-dropdown-item>Second item</gl-dropdown-item>
192
+ <gl-dropdown-divider />
193
+ <gl-dropdown-item>Third item</gl-dropdown-item>
194
+ <gl-dropdown-item>Fourth item</gl-dropdown-item>`,
195
+ 200
196
+ ),
197
+ mounted() {
198
+ clickDropdown(this);
199
+ },
200
+ updated() {
201
+ addClass(this);
202
+ },
203
+ });
204
+ WithDivider.args = generateProps({ text: 'Some dropdown' });
205
+
206
+ export const WithHeaderAndFooter = (args, { argTypes }) => ({
207
+ props: Object.keys(argTypes),
208
+ components: { ...components, GlSearchBoxByType },
209
+ template: wrap(
210
+ `
211
+ <template #header>
212
+ <gl-search-box-by-type />
213
+ </template>
214
+ <gl-dropdown-item>First item</gl-dropdown-item>
215
+ <gl-dropdown-item>Second item</gl-dropdown-item>
216
+ <gl-dropdown-item>Third item</gl-dropdown-item>
217
+ <gl-dropdown-item>Fourth item</gl-dropdown-item>
218
+ <gl-dropdown-item>Fifth item</gl-dropdown-item>
219
+ <gl-dropdown-item>Sixth item</gl-dropdown-item>
220
+ <gl-dropdown-item>Seventh item</gl-dropdown-item>
221
+ <gl-dropdown-item>Eigth item</gl-dropdown-item>
222
+ <template #footer>
223
+ <gl-dropdown-item>First footer item</gl-dropdown-item>
224
+ <gl-dropdown-item>Second footer item</gl-dropdown-item>
225
+ </template>`,
226
+ 340
227
+ ),
228
+ mounted() {
229
+ clickDropdown(this);
230
+ },
231
+ updated() {
232
+ addClass(this);
233
+ },
234
+ });
235
+ WithHeaderAndFooter.args = generateProps({
236
+ text: 'Some dropdown',
237
+ headerText: 'Header',
238
+ hideHeaderBorder: true,
239
+ });
240
+
241
+ export const WithSectionHeader = (args, { argTypes }) => ({
242
+ props: Object.keys(argTypes),
243
+ components,
244
+ template: wrap(
245
+ `
246
+ <gl-dropdown-section-header>Header title</gl-dropdown-section-header>
247
+ <gl-dropdown-item>First item</gl-dropdown-item>
248
+ <gl-dropdown-item>Second item</gl-dropdown-item>
249
+ <gl-dropdown-section-header>I am a really long header title which should wrap</gl-dropdown-section-header>
250
+ <gl-dropdown-item>Third item</gl-dropdown-item>
251
+ <gl-dropdown-item>Fourth item</gl-dropdown-item>`,
252
+ 300
253
+ ),
254
+ mounted() {
255
+ clickDropdown(this);
256
+ },
257
+ updated() {
258
+ addClass(this);
259
+ },
260
+ });
261
+ WithSectionHeader.args = generateProps({ text: 'Some dropdown' });
262
+
263
+ export const WithCheckedItems = (args, { argTypes }) => ({
264
+ props: Object.keys(argTypes),
265
+ components,
266
+ template: wrap(`
267
+ <gl-dropdown-item :is-check-item="true" :is-checked="true">Checked item</gl-dropdown-item>
268
+ <gl-dropdown-item :is-check-item="true">Unchecked item</gl-dropdown-item>`),
269
+ mounted() {
270
+ clickDropdown(this);
271
+ },
272
+ updated() {
273
+ addClass(this);
274
+ },
275
+ });
276
+ WithCheckedItems.args = generateProps({ text: 'Some dropdown' });
277
+
278
+ export const WithAvatarAndSecondaryText = (args, { argTypes }) => ({
279
+ props: Object.keys(argTypes),
280
+ components,
281
+ template: wrap(`
282
+ <gl-dropdown-item
283
+ avatar-url="./img/avatar.png"
284
+ secondary-text="@sytses"
285
+ >
286
+ Sid Sijbrandij
287
+ </gl-dropdown-item>`),
288
+ mounted() {
289
+ clickDropdown(this);
290
+ },
291
+ updated() {
292
+ addClass(this);
293
+ },
294
+ });
295
+ WithAvatarAndSecondaryText.args = generateProps({ text: 'Some dropdown' });
296
+
297
+ export const WithIcons = (args, { argTypes }) => ({
298
+ props: Object.keys(argTypes),
299
+ components,
300
+ template: wrap(
301
+ `
302
+ <gl-dropdown-item
303
+ icon-color="info"
304
+ icon-name="status_running"
305
+ icon-right-name="retry"
306
+ icon-right-aria-label="Retry"
307
+ >
308
+ Status running
309
+ </gl-dropdown-item>
310
+ <gl-dropdown-item
311
+ icon-color="success"
312
+ icon-name="status_success"
313
+ icon-right-name="cancel"
314
+ icon-right-aria-label="Cancel"
315
+ >
316
+ Status success
317
+ </gl-dropdown-item>
318
+ <gl-dropdown-item
319
+ icon-color="warning"
320
+ icon-name="status_warning"
321
+ icon-right-name="cancel"
322
+ icon-right-aria-label="Cancel"
323
+ >
324
+ Status warning
325
+ </gl-dropdown-item>
326
+ <gl-dropdown-item
327
+ icon-color="danger"
328
+ icon-name="status_failed"
329
+ icon-right-name="cancel"
330
+ icon-right-aria-label="Cancel"
331
+ >
332
+ Status failed
333
+ </gl-dropdown-item>
334
+ <gl-dropdown-item
335
+ icon-name="status_manual"
336
+ icon-right-name="cancel"
337
+ icon-right-aria-label="Cancel"
338
+ >
339
+ Status manual
340
+ </gl-dropdown-item>`,
341
+ 200
342
+ ),
343
+ mounted() {
344
+ clickDropdown(this);
345
+ },
346
+ updated() {
347
+ addClass(this);
348
+ },
349
+ });
350
+ WithIcons.args = generateProps({ text: 'Some dropdown' });
351
+
352
+ export const FullWidth = (args, { argTypes }) => ({
353
+ props: Object.keys(argTypes),
354
+ components,
355
+ template: wrap(`
356
+ <gl-dropdown-item>First item</gl-dropdown-item>
357
+ <gl-dropdown-item>Second item</gl-dropdown-item>
358
+ <gl-dropdown-item>Last item</gl-dropdown-item>`),
359
+ mounted() {
360
+ clickDropdown(this);
361
+ },
362
+ updated() {
363
+ addClass(this);
364
+ },
365
+ });
366
+ FullWidth.args = generateProps({ text: 'Some dropdown', block: true });
367
+
368
+ export const WithShortTextAndWideWidth = (args, { argTypes }) => ({
369
+ props: Object.keys(argTypes),
370
+ components,
371
+ template: withContainer(`
372
+ <gl-dropdown
373
+ text="Some dropdown"
374
+ :category="category"
375
+ :variant="variant"
376
+ :size="size"
377
+ :block="block"
378
+ :disabled="disabled"
379
+ style="width: 300px;"
380
+ >
449
381
  <gl-dropdown-item>First item</gl-dropdown-item>
450
- <gl-dropdown-item>Second item</gl-dropdown-item>
451
- <gl-dropdown-item>Last item</gl-dropdown-item>`,
452
- mounted() {
453
- clickDropdown(this);
454
- },
455
- updated() {
456
- addClass(this);
457
- },
458
- }))
459
- .add('with loading state', () => ({
460
- props: generateProps({ text: 'Some dropdown', loading: true }),
461
- components,
462
- template: wrap`
382
+ <gl-dropdown-item>Last item</gl-dropdown-item>
383
+ </gl-dropdown>`),
384
+ mounted() {
385
+ clickDropdown(this);
386
+ },
387
+ updated() {
388
+ addClass(this);
389
+ },
390
+ });
391
+ WithShortTextAndWideWidth.args = generateProps();
392
+
393
+ export const WithLongTextAndNarrowWidth = (args, { argTypes }) => ({
394
+ props: Object.keys(argTypes),
395
+ components,
396
+ template: withContainer(`
397
+ <gl-dropdown
398
+ text="Truncated text dropdown"
399
+ :category="category"
400
+ :variant="variant"
401
+ :size="size"
402
+ :block="block"
403
+ :disabled="disabled"
404
+ style="width: 160px;"
405
+ >
463
406
  <gl-dropdown-item>First item</gl-dropdown-item>
464
- <gl-dropdown-item>Last item</gl-dropdown-item>`,
465
- mounted() {
466
- clickDropdown(this);
467
- },
468
- updated() {
469
- addClass(this);
470
- },
471
- }))
472
- .add('with clear all', () => ({
473
- props: generateProps({
474
- text: 'Some dropdown',
475
- showClearAll: true,
476
- clearAllText: 'Clear all',
477
- clearAllTextClass: 'gl-px-5',
478
- }),
479
- components,
480
- template: wrap`
407
+ <gl-dropdown-item>Last item</gl-dropdown-item>
408
+ </gl-dropdown>`),
409
+ mounted() {
410
+ clickDropdown(this);
411
+ },
412
+ updated() {
413
+ addClass(this);
414
+ },
415
+ });
416
+ WithLongTextAndNarrowWidth.args = generateProps({ block: true });
417
+
418
+ export const WithItemTextThatDoesNotWrap = (args, { argTypes }) => ({
419
+ props: Object.keys(argTypes),
420
+ components,
421
+ template: wrap(`
422
+ <gl-dropdown-item icon-right-name="star" icon-right-aria-label="Some action">
423
+ Normal item
424
+ </gl-dropdown-item>
425
+ <gl-dropdown-item icon-right-name="star" icon-right-aria-label="Some action">
426
+ <div class="gl-text-truncate">ellipsis/should/truncate/this/item</div>
427
+ </gl-dropdown-item>`),
428
+ mounted() {
429
+ clickDropdown(this);
430
+ },
431
+ updated() {
432
+ addClass(this);
433
+ },
434
+ });
435
+ WithItemTextThatDoesNotWrap.args = generateProps({ text: 'Some dropdown' });
436
+
437
+ export const IconOnly = (args, { argTypes }) => ({
438
+ props: Object.keys(argTypes),
439
+ components,
440
+ template: wrap(`
441
+ <gl-dropdown-item>First item</gl-dropdown-item>
442
+ <gl-dropdown-item>Second item</gl-dropdown-item>
443
+ <gl-dropdown-item>Last item</gl-dropdown-item>`),
444
+ mounted() {
445
+ clickDropdown(this);
446
+ },
447
+ updated() {
448
+ addClass(this);
449
+ },
450
+ });
451
+ IconOnly.args = generateProps({ icon: 'ellipsis_v', text: 'More actions', textSrOnly: true });
452
+
453
+ export const WithLoadingState = (args, { argTypes }) => ({
454
+ props: Object.keys(argTypes),
455
+ components,
456
+ template: wrap(`
457
+ <gl-dropdown-item>First item</gl-dropdown-item>
458
+ <gl-dropdown-item>Last item</gl-dropdown-item>`),
459
+ mounted() {
460
+ clickDropdown(this);
461
+ },
462
+ updated() {
463
+ addClass(this);
464
+ },
465
+ });
466
+ WithLoadingState.args = generateProps({ text: 'Some dropdown', loading: true });
467
+
468
+ export const WithClearAll = (args, { argTypes }) => ({
469
+ props: Object.keys(argTypes),
470
+ components,
471
+ template: wrap(`
472
+ <gl-dropdown-item :is-check-item="true" :is-checked="true">First item</gl-dropdown-item>
473
+ <gl-dropdown-item :is-check-item="true" :is-checked="true">Second item</gl-dropdown-item>
474
+ <gl-dropdown-item :is-check-item="true" :is-checked="true">Third item</gl-dropdown-item>`),
475
+ mounted() {
476
+ clickDropdown(this);
477
+ },
478
+ updated() {
479
+ addClass(this);
480
+ },
481
+ });
482
+ WithClearAll.args = generateProps({
483
+ text: 'Some dropdown',
484
+ showClearAll: true,
485
+ clearAllText: 'Clear all',
486
+ clearAllTextClass: 'gl-px-5',
487
+ });
488
+
489
+ export const WithHighlightedItems = (args, { argTypes }) => ({
490
+ props: Object.keys(argTypes),
491
+ components,
492
+ template: wrap(
493
+ `
494
+ <template #highlighted-items>
481
495
  <gl-dropdown-item :is-check-item="true" :is-checked="true">First item</gl-dropdown-item>
482
496
  <gl-dropdown-item :is-check-item="true" :is-checked="true">Second item</gl-dropdown-item>
483
- <gl-dropdown-item :is-check-item="true" :is-checked="true">Third item</gl-dropdown-item>`,
484
- mounted() {
485
- clickDropdown(this);
497
+ </template>
498
+ <gl-dropdown-item>Third item</gl-dropdown-item>
499
+ <gl-dropdown-item>Fourth item</gl-dropdown-item>
500
+ `,
501
+ 200
502
+ ),
503
+ mounted() {
504
+ clickDropdown(this);
505
+ },
506
+ updated() {
507
+ addClass(this);
508
+ },
509
+ });
510
+ WithHighlightedItems.args = generateProps({
511
+ text: 'Some dropdown',
512
+ showHighlightedItemsTitle: true,
513
+ highlightedItemsTitle: 'Highlights',
514
+ highlightedItemsTitleClass: 'gl-px-5',
515
+ });
516
+
517
+ export default {
518
+ title: 'base/dropdown',
519
+ component: GlDropdown,
520
+ subcomponents: {
521
+ GlDropdownDivider,
522
+ GlDropdownForm,
523
+ GlDropdownItem,
524
+ GlDropdownSectionHeader,
525
+ GlDropdownText,
526
+ },
527
+ parameters: {
528
+ bootstrapComponent: 'b-dropdown',
529
+ docs: {
530
+ description: {
531
+ component: readme,
532
+ },
533
+ },
534
+ },
535
+ argTypes: {
536
+ category: {
537
+ options: Object.keys(buttonCategoryOptions),
538
+ control: {
539
+ type: 'select',
540
+ },
486
541
  },
487
- updated() {
488
- addClass(this);
542
+ variant: {
543
+ options: Object.keys(dropdownVariantOptions),
544
+ control: {
545
+ type: 'select',
546
+ },
489
547
  },
490
- }))
491
- .add('with highlighted items', () => ({
492
- props: generateProps({
493
- text: 'Some dropdown',
494
- showHighlightedItemsTitle: true,
495
- highlightedItemsTitle: 'Highlights',
496
- highlightedItemsTitleClass: 'gl-px-5',
497
- }),
498
- components,
499
- template: wrap`
500
- <template #highlighted-items>
501
- <gl-dropdown-item :is-check-item="true" :is-checked="true">First item</gl-dropdown-item>
502
- <gl-dropdown-item :is-check-item="true" :is-checked="true">Second item</gl-dropdown-item>
503
- </template>
504
- <gl-dropdown-item>Third item</gl-dropdown-item>
505
- <gl-dropdown-item>Fourth item</gl-dropdown-item>
506
- `,
507
- mounted() {
508
- clickDropdown(this);
548
+ size: {
549
+ options: Object.keys(buttonSizeOptions),
550
+ control: {
551
+ type: 'select',
552
+ },
509
553
  },
510
- updated() {
511
- addClass(this);
554
+ icon: {
555
+ options: iconSpriteInfo.icons,
556
+ control: {
557
+ type: 'select',
558
+ },
512
559
  },
513
- }));
560
+ },
561
+ };