@gitlab/ui 36.7.1 → 37.2.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 (121) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/base/alert/alert.js +1 -11
  3. package/dist/components/base/card/card.js +1 -1
  4. package/dist/components/base/drawer/drawer.documentation.js +1 -1
  5. package/dist/components/base/form/form_input_group/form_input_group.documentation.js +2 -26
  6. package/dist/components/base/form/form_input_group/form_input_group.js +7 -0
  7. package/dist/components/base/loading_icon/loading_icon.js +1 -1
  8. package/dist/components/base/pagination/pagination.js +23 -2
  9. package/dist/components/base/path/data.js +2 -1
  10. package/dist/components/base/path/path.js +14 -7
  11. package/dist/components/base/tabs/tab/tab.js +4 -0
  12. package/dist/components/base/tabs/tabs/tabs.documentation.js +2 -14
  13. package/dist/components/base/tabs/tabs/tabs.js +8 -0
  14. package/dist/components/charts/area/area.documentation.js +1 -7
  15. package/dist/components/charts/legend/legend.js +12 -0
  16. package/dist/components/charts/line/line.documentation.js +2 -5
  17. package/dist/index.css +2 -2
  18. package/dist/index.css.map +1 -1
  19. package/dist/utils/stories_utils.js +13 -1
  20. package/documentation/components_documentation.js +0 -2
  21. package/documentation/documented_stories.js +6 -0
  22. package/package.json +2 -2
  23. package/src/components/base/accordion/accordion.stories.js +2 -1
  24. package/src/components/base/alert/alert.scss +0 -38
  25. package/src/components/base/alert/alert.spec.js +0 -1
  26. package/src/components/base/alert/alert.stories.js +0 -8
  27. package/src/components/base/alert/alert.vue +30 -41
  28. package/src/components/base/badge/badge.stories.js +4 -24
  29. package/src/components/base/card/card.vue +2 -2
  30. package/src/components/base/daterange_picker/daterange_picker.stories.js +10 -35
  31. package/src/components/base/drawer/drawer.documentation.js +1 -1
  32. package/src/components/base/form/form_input_group/form_input_group.documentation.js +0 -28
  33. package/src/components/base/form/form_input_group/form_input_group.md +0 -4
  34. package/src/components/base/form/form_input_group/form_input_group.stories.js +84 -62
  35. package/src/components/base/form/form_input_group/form_input_group.vue +9 -0
  36. package/src/components/base/icon/icon.stories.js +2 -5
  37. package/src/components/base/loading_icon/loading_icon.vue +1 -1
  38. package/src/components/base/pagination/pagination.spec.js +12 -2
  39. package/src/components/base/pagination/pagination.vue +23 -6
  40. package/src/components/base/path/__snapshots__/path.spec.js.snap +6 -0
  41. package/src/components/base/path/data.js +1 -0
  42. package/src/components/base/path/path.scss +6 -1
  43. package/src/components/base/path/path.spec.js +20 -0
  44. package/src/components/base/path/path.vue +18 -7
  45. package/src/components/base/tabs/tab/tab.vue +4 -0
  46. package/src/components/base/tabs/tabs/tabs.documentation.js +0 -12
  47. package/src/components/base/tabs/tabs/tabs.md +2 -7
  48. package/src/components/base/tabs/tabs/tabs.stories.js +219 -161
  49. package/src/components/base/tabs/tabs/tabs.vue +6 -0
  50. package/src/components/base/toggle/toggle.stories.js +2 -3
  51. package/src/components/charts/area/area.documentation.js +0 -5
  52. package/src/components/charts/area/area.stories.js +127 -127
  53. package/src/components/charts/bar/bar.stories.js +8 -5
  54. package/src/components/charts/heatmap/heatmap.stories.js +13 -16
  55. package/src/components/charts/legend/legend.stories.js +22 -15
  56. package/src/components/charts/legend/legend.vue +9 -0
  57. package/src/components/charts/line/line.documentation.js +0 -2
  58. package/src/components/charts/line/line.md +0 -2
  59. package/src/components/charts/line/line.stories.js +124 -113
  60. package/src/utils/stories_utils.js +6 -0
  61. package/src/utils/stories_utils.spec.js +18 -0
  62. package/dist/components/base/form/form_input_group/examples/form_input_group.basic.example.js +0 -38
  63. package/dist/components/base/form/form_input_group/examples/form_input_group.predefined_options.example.js +0 -54
  64. package/dist/components/base/form/form_input_group/examples/form_input_group.predefined_reactive.example.js +0 -55
  65. package/dist/components/base/form/form_input_group/examples/form_input_group.reactive.example.js +0 -48
  66. package/dist/components/base/form/form_input_group/examples/index.js +0 -27
  67. package/dist/components/base/tabs/tab/examples/index.js +0 -13
  68. package/dist/components/base/tabs/tab/examples/tab.basic.example.js +0 -38
  69. package/dist/components/base/tabs/tab/tab.documentation.js +0 -18
  70. package/dist/components/base/tabs/tabs/examples/index.js +0 -60
  71. package/dist/components/base/tabs/tabs/examples/tabs.basic.example.js +0 -38
  72. package/dist/components/base/tabs/tabs/examples/tabs.contentless_tab.example.js +0 -38
  73. package/dist/components/base/tabs/tabs/examples/tabs.counterbadges.example.js +0 -38
  74. package/dist/components/base/tabs/tabs/examples/tabs.custom_title.example.js +0 -38
  75. package/dist/components/base/tabs/tabs/examples/tabs.disabled.example.js +0 -38
  76. package/dist/components/base/tabs/tabs/examples/tabs.justified.example.js +0 -38
  77. package/dist/components/base/tabs/tabs/examples/tabs.no_tabs.example.js +0 -38
  78. package/dist/components/base/tabs/tabs/examples/tabs.scrollable.example.js +0 -47
  79. package/dist/components/base/tabs/tabs/examples/tabs.styles_only.example.js +0 -38
  80. package/dist/components/charts/area/examples/area.basic.example.js +0 -45
  81. package/dist/components/charts/area/examples/area.basic_plus.example.js +0 -53
  82. package/dist/components/charts/area/examples/index.js +0 -19
  83. package/dist/components/charts/legend/examples/index.js +0 -22
  84. package/dist/components/charts/legend/examples/legend.basic.example.js +0 -93
  85. package/dist/components/charts/legend/examples/legend.toggled.example.js +0 -100
  86. package/dist/components/charts/legend/legend.documentation.js +0 -21
  87. package/dist/components/charts/line/examples/index.js +0 -19
  88. package/dist/components/charts/line/examples/line.basic.example.js +0 -45
  89. package/dist/components/charts/line/examples/line.series.example.js +0 -53
  90. package/src/components/base/form/form_input_group/examples/form_input_group.basic.example.vue +0 -10
  91. package/src/components/base/form/form_input_group/examples/form_input_group.predefined_options.example.vue +0 -25
  92. package/src/components/base/form/form_input_group/examples/form_input_group.predefined_reactive.example.vue +0 -32
  93. package/src/components/base/form/form_input_group/examples/form_input_group.reactive.example.vue +0 -25
  94. package/src/components/base/form/form_input_group/examples/index.js +0 -32
  95. package/src/components/base/tabs/tab/examples/index.js +0 -15
  96. package/src/components/base/tabs/tab/examples/tab.basic.example.vue +0 -5
  97. package/src/components/base/tabs/tab/tab.documentation.js +0 -16
  98. package/src/components/base/tabs/tab/tab.md +0 -3
  99. package/src/components/base/tabs/tab/tab.stories.js +0 -12
  100. package/src/components/base/tabs/tabs/examples/index.js +0 -72
  101. package/src/components/base/tabs/tabs/examples/tabs.basic.example.vue +0 -6
  102. package/src/components/base/tabs/tabs/examples/tabs.contentless_tab.example.vue +0 -17
  103. package/src/components/base/tabs/tabs/examples/tabs.counterbadges.example.vue +0 -28
  104. package/src/components/base/tabs/tabs/examples/tabs.custom_title.example.vue +0 -9
  105. package/src/components/base/tabs/tabs/examples/tabs.disabled.example.vue +0 -7
  106. package/src/components/base/tabs/tabs/examples/tabs.justified.example.vue +0 -6
  107. package/src/components/base/tabs/tabs/examples/tabs.no_tabs.example.vue +0 -8
  108. package/src/components/base/tabs/tabs/examples/tabs.scrollable.example.vue +0 -20
  109. package/src/components/base/tabs/tabs/examples/tabs.styles_only.example.vue +0 -22
  110. package/src/components/charts/area/area.md +0 -1
  111. package/src/components/charts/area/examples/area.basic.example.vue +0 -14
  112. package/src/components/charts/area/examples/area.basic_plus.example.vue +0 -25
  113. package/src/components/charts/area/examples/index.js +0 -22
  114. package/src/components/charts/legend/examples/index.js +0 -27
  115. package/src/components/charts/legend/examples/legend.basic.example.vue +0 -55
  116. package/src/components/charts/legend/examples/legend.toggled.example.vue +0 -60
  117. package/src/components/charts/legend/legend.documentation.js +0 -19
  118. package/src/components/charts/legend/legend.md +0 -0
  119. package/src/components/charts/line/examples/index.js +0 -22
  120. package/src/components/charts/line/examples/line.basic.example.vue +0 -14
  121. package/src/components/charts/line/examples/line.series.example.vue +0 -25
@@ -9,5 +9,17 @@ const SERIES_NAME = {
9
9
  [SERIES_NAME_LONG]: 'Series name long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt interdum sapien ut blandit. Nulla fermentum nisi id euismod vulputate. END',
10
10
  [SERIES_NAME_LONG_WITHOUT_SPACES]: 'Series_name_long._Lorem_ipsum_dolor_sit_amet,_consectetur_adipiscing_elit._Sed_tincidunt_interdum_sapien_ut_blandit._Nulla_fermentum_nisi_id_euismod_vulputate._END'
11
11
  };
12
+ /**
13
+ * Builds the parameters object disable one or multiple controls.
14
+ */
15
+
16
+ const disableControls = function () {
17
+ let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
18
+ return Object.fromEntries(controls.map(control => [control, {
19
+ control: {
20
+ disable: true
21
+ }
22
+ }]));
23
+ };
12
24
 
13
- export { SERIES_NAME, SERIES_NAME_LONG, SERIES_NAME_LONG_WITHOUT_SPACES, SERIES_NAME_SHORT };
25
+ export { SERIES_NAME, SERIES_NAME_LONG, SERIES_NAME_LONG_WITHOUT_SPACES, SERIES_NAME_SHORT, disableControls };
@@ -16,7 +16,6 @@ export { default as GlNavbarDocumentation } from '../src/components/base/navbar/
16
16
  export { default as GlIntersectionObserverDocumentation } from '../src/components/utilities/intersection_observer/intersection_observer.documentation';
17
17
  export { default as GlChartDocumentation } from '../src/components/charts/chart/chart.documentation';
18
18
  export { default as GlAreaChartDocumentation } from '../src/components/charts/area/area.documentation';
19
- export { default as GlChartLegendDocumentation } from '../src/components/charts/legend/legend.documentation';
20
19
  export { default as GlLineChartDocumentation } from '../src/components/charts/line/line.documentation';
21
20
  export { default as GlSparklineChartDocumentation } from '../src/components/charts/sparkline/sparkline.documentation';
22
21
  export { default as GlChartSeriesLabelDocumentation } from '../src/components/charts/series_label/series_label.documentation';
@@ -64,7 +63,6 @@ export { default as GlTableDocumentation } from '../src/components/base/table/ta
64
63
  export { default as GlBreadcrumbDocumentation } from '../src/components/base/breadcrumb/breadcrumb.documentation';
65
64
  export { default as GlHeatmapDocumentation } from '../src/components/charts/heatmap/heatmap.documentation';
66
65
  export { default as GlTabsDocumentation } from '../src/components/base/tabs/tabs/tabs.documentation';
67
- export { default as GlTabDocumentation } from '../src/components/base/tabs/tab/tab.documentation';
68
66
  export { default as GlButtonGroupDocumentation } from '../src/components/base/button_group/button_group.documentation';
69
67
  export { default as GlFormCheckboxDocumentation } from '../src/components/base/form/form_checkbox/form_checkbox.documentation';
70
68
  export { default as GlLabelDocumentation } from '../src/components/base/label/label.documentation';
@@ -102,6 +102,7 @@ export const setupStorybookReadme = () =>
102
102
  'GlFormInput',
103
103
  'GlSegmentedControl',
104
104
  'GlAvatar',
105
+ 'GlChartLegend',
105
106
  'GlAvatarLink',
106
107
  'GlPagination',
107
108
  'GlSkeletonLoader',
@@ -117,6 +118,8 @@ export const setupStorybookReadme = () =>
117
118
  'GlKeysetPagination',
118
119
  'GlForm',
119
120
  'GlTable',
121
+ 'GlTab',
122
+ 'GlTabs',
120
123
  'GlToast',
121
124
  'GlPaginatedList',
122
125
  'GlIntersectionObserver',
@@ -132,6 +135,9 @@ export const setupStorybookReadme = () =>
132
135
  'GlHeatmap',
133
136
  'GlFormRadioGroup',
134
137
  'GlChartSeriesLabel',
138
+ 'GlAreaChart',
139
+ 'GlLineChart',
140
+ 'GlFormInputGroup',
135
141
  ],
136
142
  components: {
137
143
  GlComponentDocumentation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "36.7.1",
3
+ "version": "37.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -85,7 +85,7 @@
85
85
  "@babel/preset-env": "^7.10.2",
86
86
  "@gitlab/eslint-plugin": "10.0.2",
87
87
  "@gitlab/stylelint-config": "4.0.0",
88
- "@gitlab/svgs": "2.5.0",
88
+ "@gitlab/svgs": "2.6.0",
89
89
  "@rollup/plugin-commonjs": "^11.1.0",
90
90
  "@rollup/plugin-node-resolve": "^7.1.3",
91
91
  "@rollup/plugin-replace": "^2.3.2",
@@ -1,3 +1,4 @@
1
+ import { disableControls } from '../../../utils/stories_utils';
1
2
  import readme from './accordion.md';
2
3
  import GlAccordion from './accordion.vue';
3
4
  import GlAccordionItem from './accordion_item.vue';
@@ -63,6 +64,6 @@ export default {
63
64
  options: [1, 2, 3, 4, 5, 6],
64
65
  },
65
66
  },
66
- autoCollapse: { control: { disable: true } },
67
+ ...disableControls(['autoCollapse']),
67
68
  },
68
69
  };
@@ -85,44 +85,6 @@
85
85
  @include gl-right-4;
86
86
  }
87
87
 
88
- .gl-alert-max-content {
89
- @include gl-display-flex;
90
- @include gl-justify-content-center;
91
- @include gl-p-5;
92
-
93
- .gl-alert-icon {
94
- @include gl-static;
95
- @include gl-mr-5;
96
- @include gl-flex-shrink-0;
97
- }
98
-
99
- .gl-dismiss-btn {
100
- @include gl-static;
101
- @include gl-align-self-start;
102
- @include gl-ml-4;
103
- // The negative margins optically align the × with the title text and right padding
104
- margin-top: -$gl-spacing-scale-2;
105
- margin-right: -$gl-spacing-scale-2;
106
- order: 3;
107
- }
108
-
109
- .gl-alert-container {
110
- @include gl-relative;
111
- @include gl-display-flex;
112
- @include gl-justify-content-space-between;
113
- @include gl-flex-grow-1;
114
- @include gl-mx-auto;
115
- }
116
-
117
- .gl-alert-content {
118
- @include gl-flex-grow-1;
119
- }
120
- }
121
-
122
- .gl-alert-layout-limited .gl-alert-container {
123
- @include gl-layout-w-limited;
124
- }
125
-
126
88
  .gl-alert-danger {
127
89
  @include gl-bg-red-50;
128
90
 
@@ -154,7 +154,6 @@ describe('Alert component', () => {
154
154
  describe('top-level classes', () => {
155
155
  describe.each`
156
156
  prop | cssClass | presentIf
157
- ${'contained'} | ${'gl-alert-max-content'} | ${true}
158
157
  ${'sticky'} | ${'gl-alert-sticky'} | ${true}
159
158
  ${'dismissible'} | ${'gl-alert-not-dismissible'} | ${false}
160
159
  `('$cssClass', ({ prop, cssClass, presentIf }) => {
@@ -12,7 +12,6 @@ const template = `
12
12
  :secondary-button-text="secondaryButtonText"
13
13
  :primary-button-link="primaryButtonLink"
14
14
  :secondary-button-link="secondaryButtonLink"
15
- :contained="contained"
16
15
  :sticky="sticky"
17
16
  >{{ message }}</gl-alert>`;
18
17
 
@@ -27,7 +26,6 @@ const generateProps = ({
27
26
  primaryButtonLink = defaultValue('primaryButtonLink'),
28
27
  secondaryButtonText = defaultValue('secondaryButtonText'),
29
28
  secondaryButtonLink = defaultValue('secondaryButtonLink'),
30
- contained = defaultValue('contained'),
31
29
  sticky = defaultValue('sticky'),
32
30
  } = {}) => ({
33
31
  title,
@@ -39,7 +37,6 @@ const generateProps = ({
39
37
  primaryButtonLink,
40
38
  secondaryButtonText,
41
39
  secondaryButtonLink,
42
- contained,
43
40
  sticky,
44
41
  });
45
42
 
@@ -118,11 +115,6 @@ Variants.parameters = {
118
115
  storyshots: { disable: true },
119
116
  };
120
117
 
121
- export const Contained = Template.bind({});
122
- Contained.args = generateProps({
123
- contained: true,
124
- });
125
-
126
118
  export const Sticky = () => ({
127
119
  components: { GlAlert },
128
120
  variants: alertVariantOptions,
@@ -74,14 +74,6 @@ export default {
74
74
  required: false,
75
75
  default: '',
76
76
  },
77
- /**
78
- * Contained alerts have their content's width limited.
79
- */
80
- contained: {
81
- type: Boolean,
82
- required: false,
83
- default: false,
84
- },
85
77
  sticky: {
86
78
  type: Boolean,
87
79
  required: false,
@@ -171,48 +163,45 @@ export default {
171
163
  <div
172
164
  :class="[
173
165
  'gl-alert',
174
- { 'gl-alert-max-content gl-alert-layout-limited': contained },
175
166
  { 'gl-alert-sticky': sticky },
176
167
  { 'gl-alert-not-dismissible': !dismissible },
177
168
  variantClass,
178
169
  ]"
179
170
  >
180
- <div class="gl-alert-container">
181
- <gl-icon
182
- :name="iconName"
183
- :class="{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !title }"
184
- />
171
+ <gl-icon
172
+ :name="iconName"
173
+ :class="{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !title }"
174
+ />
185
175
 
186
- <close-button
187
- v-if="dismissible"
188
- ref="dismiss"
189
- class="gl-dismiss-btn"
190
- :label="dismissLabel"
191
- @click="onDismiss"
192
- />
176
+ <close-button
177
+ v-if="dismissible"
178
+ ref="dismiss"
179
+ class="gl-dismiss-btn"
180
+ :label="dismissLabel"
181
+ @click="onDismiss"
182
+ />
193
183
 
194
- <div class="gl-alert-content" role="alert">
195
- <h4 v-if="title" class="gl-alert-title">{{ title }}</h4>
184
+ <div class="gl-alert-content" role="alert">
185
+ <h4 v-if="title" class="gl-alert-title">{{ title }}</h4>
196
186
 
197
- <div class="gl-alert-body">
198
- <!-- @slot The alert message to display. -->
199
- <slot></slot>
200
- </div>
187
+ <div class="gl-alert-body">
188
+ <!-- @slot The alert message to display. -->
189
+ <slot></slot>
190
+ </div>
201
191
 
202
- <div v-if="shouldRenderActions" class="gl-alert-actions">
203
- <!-- @slot If the primary/secondary action buttons aren't flexible enough, place arbitrary content here. -->
204
- <slot name="actions">
205
- <gl-button
206
- v-for="(actionButton, index) in actionButtons"
207
- :key="index"
208
- class="gl-alert-action"
209
- v-bind="actionButton.attrs"
210
- v-on="actionButton.listeners"
211
- >
212
- {{ actionButton.text }}
213
- </gl-button>
214
- </slot>
215
- </div>
192
+ <div v-if="shouldRenderActions" class="gl-alert-actions">
193
+ <!-- @slot If the primary/secondary action buttons aren't flexible enough, place arbitrary content here. -->
194
+ <slot name="actions">
195
+ <gl-button
196
+ v-for="(actionButton, index) in actionButtons"
197
+ :key="index"
198
+ class="gl-alert-action"
199
+ v-bind="actionButton.attrs"
200
+ v-on="actionButton.listeners"
201
+ >
202
+ {{ actionButton.text }}
203
+ </gl-button>
204
+ </slot>
216
205
  </div>
217
206
  </div>
218
207
  </div>
@@ -1,6 +1,7 @@
1
1
  import iconSpriteInfo from '@gitlab/svgs/dist/icons.json';
2
2
  import { GlBadge } from '../../../index';
3
3
  import { badgeSizeOptions, badgeVariantOptions } from '../../../utils/constants';
4
+ import { disableControls } from '../../../utils/stories_utils';
4
5
  import readme from './badge.md';
5
6
 
6
7
  const template = `
@@ -61,14 +62,7 @@ export const Variants = (args, { argTypes }) => ({
61
62
  Variants.args = generateProps({
62
63
  variant: badgeVariantOptions.warning,
63
64
  });
64
- Variants.argTypes = {
65
- content: {
66
- control: { disable: true },
67
- },
68
- variant: {
69
- control: { disable: true },
70
- },
71
- };
65
+ Variants.argTypes = disableControls(['content', 'variant']);
72
66
 
73
67
  export const Actionable = (args, { argTypes }) => ({
74
68
  components: { GlBadge },
@@ -95,14 +89,7 @@ Actionable.args = generateProps({
95
89
  Actionable.parameters = {
96
90
  storyshots: { disable: true },
97
91
  };
98
- Actionable.argTypes = {
99
- content: {
100
- control: { disable: true },
101
- },
102
- variant: {
103
- control: { disable: true },
104
- },
105
- };
92
+ Actionable.argTypes = disableControls(['content', 'variant']);
106
93
 
107
94
  export const Sizes = (args, { argTypes }) => ({
108
95
  components: { GlBadge },
@@ -125,14 +112,7 @@ export const Sizes = (args, { argTypes }) => ({
125
112
  Sizes.args = generateProps({
126
113
  variant: badgeVariantOptions.danger,
127
114
  });
128
- Sizes.argTypes = {
129
- content: {
130
- control: { disable: true },
131
- },
132
- size: {
133
- control: { disable: true },
134
- },
135
- };
115
+ Sizes.argTypes = disableControls(['content', 'size']);
136
116
 
137
117
  export const BadgeIcon = (args, { argTypes }) => ({
138
118
  components: { GlBadge },
@@ -31,7 +31,7 @@ export default {
31
31
 
32
32
  <template>
33
33
  <div class="gl-card">
34
- <div v-if="this.$slots.header" class="gl-card-header" :class="headerClass">
34
+ <div v-if="$slots.header" class="gl-card-header" :class="headerClass">
35
35
  <!-- @slot The card's header content. -->
36
36
  <slot name="header"></slot>
37
37
  </div>
@@ -39,7 +39,7 @@ export default {
39
39
  <!-- @slot The card's main content. -->
40
40
  <slot></slot>
41
41
  </div>
42
- <div v-if="this.$slots.footer" class="gl-card-footer" :class="footerClass">
42
+ <div v-if="$slots.footer" class="gl-card-footer" :class="footerClass">
43
43
  <!-- @slot The card's footer content. -->
44
44
  <slot name="footer"></slot>
45
45
  </div>
@@ -1,3 +1,4 @@
1
+ import { disableControls } from '../../../utils/stories_utils';
1
2
  import readme from './daterange_picker.md';
2
3
  import GlDaterangePicker from './daterange_picker.vue';
3
4
 
@@ -121,31 +122,15 @@ export default {
121
122
  },
122
123
  },
123
124
  argTypes: {
124
- i18n: {
125
- control: {
126
- disable: true,
127
- },
128
- },
129
- startPickerTarget: {
130
- control: {
131
- disable: true,
132
- },
133
- },
134
- startPickerContainer: {
135
- control: {
136
- disable: true,
137
- },
138
- },
139
- endPickerTarget: {
140
- control: {
141
- disable: true,
142
- },
143
- },
144
- endPickerContainer: {
145
- control: {
146
- disable: true,
147
- },
148
- },
125
+ ...disableControls([
126
+ 'i18n',
127
+ 'startPickerTarget',
128
+ 'startPickerContainer',
129
+ 'endPickerTarget',
130
+ 'endPickerContainer',
131
+ 'defaultStartDate',
132
+ 'defaultEndDate',
133
+ ]),
149
134
  defaultMinDate: {
150
135
  control: {
151
136
  type: 'date',
@@ -156,15 +141,5 @@ export default {
156
141
  type: 'date',
157
142
  },
158
143
  },
159
- defaultStartDate: {
160
- control: {
161
- disable: true,
162
- },
163
- },
164
- defaultEndDate: {
165
- control: {
166
- disable: true,
167
- },
168
- },
169
144
  },
170
145
  };
@@ -1,6 +1,6 @@
1
1
  import description from './drawer.md';
2
2
 
3
3
  export default {
4
- followsDesignSystem: false,
4
+ followsDesignSystem: true,
5
5
  description,
6
6
  };
@@ -1,34 +1,6 @@
1
- import examples from './examples';
2
1
  import description from './form_input_group.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: false,
6
5
  description,
7
- examples,
8
- bootstrapComponent: 'b-form-input',
9
- propsInfo: {
10
- 'select-on-click': {
11
- type: Boolean,
12
- additionalInfo: 'Automatically selects the content of the input field on click',
13
- },
14
- 'predefined-options': {
15
- type: Array,
16
- additionalInfo:
17
- 'Array of options. Each option should have `name` and `value` information: {name: "Foo", value: "Bar"})',
18
- },
19
- },
20
- slots: [
21
- {
22
- name: 'default',
23
- description: 'Allows replacement of default input field.',
24
- },
25
- {
26
- name: 'prepend',
27
- description: 'Is rendered in front of the input field.',
28
- },
29
- {
30
- name: 'append',
31
- description: 'Is rendered after the input field.',
32
- },
33
- ],
34
6
  };
@@ -1,7 +1,3 @@
1
- # Form Group Input
2
-
3
- <!-- STORY -->
4
-
5
1
  The `GlFormInputGroup` component allows one to build more advanced text
6
2
  input fields than generic `GlFormInput` when one needs that flexibility.
7
3
  Basic usage of the component:
@@ -1,73 +1,95 @@
1
- import { withKnobs, boolean, object, text } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
3
1
  import { GlFormInputGroup, GlInputGroupText } from '../../../../index';
2
+ import { disableControls } from '../../../../utils/stories_utils';
4
3
  import readme from './form_input_group.md';
5
4
 
6
- const components = {
7
- GlFormInputGroup,
8
- GlInputGroupText,
9
- };
10
- const predefinedOptions = [
11
- { name: 'Embed', value: 'https://embed.com' },
12
- { name: 'Share', value: 'https://share.org' },
13
- ];
5
+ const template = `
6
+ <gl-form-input-group
7
+ :readonly="readonly"
8
+ :select-on-click="selectOnClick"
9
+ :predefined-options="predefinedOptions"
10
+ :label="label"
11
+ :inputClass="inputClass">
12
+ <template #prepend v-if="prepend">
13
+ <gl-input-group-text>{{prepend}}</gl-input-group-text>
14
+ </template>
15
+ <template #append v-if="append">
16
+ <gl-input-group-text>{{append}}</gl-input-group-text>
17
+ </template>
18
+ </gl-form-input-group>
19
+ `;
14
20
 
15
- documentedStoriesOf('base/form/form-input-group', readme)
16
- .addDecorator(withKnobs)
17
- .add('default', () => ({
18
- components,
19
- props: {
20
- prepend: {
21
- default: text('Prepend text', 'Username'),
22
- },
23
- append: {
24
- default: text('Append text', 'Add'),
25
- },
26
- readonly: {
27
- default: boolean('Readonly', false),
28
- },
29
- select: {
30
- default: boolean('Select text on click', false),
21
+ const defaultValue = (prop) => GlFormInputGroup.props[prop].default;
22
+
23
+ const generateProps = ({
24
+ prepend = 'Username',
25
+ append = 'Add',
26
+ readonly = false,
27
+ selectOnClick = false,
28
+ predefinedOptions = defaultValue('predefinedOptions')(),
29
+ label = '',
30
+ inputClass = '',
31
+ } = {}) => ({
32
+ prepend,
33
+ append,
34
+ readonly,
35
+ selectOnClick,
36
+ predefinedOptions,
37
+ label,
38
+ inputClass,
39
+ });
40
+
41
+ const Template = (args, { argTypes }) => ({
42
+ components: { GlFormInputGroup, GlInputGroupText },
43
+ props: Object.keys(argTypes),
44
+ template,
45
+ });
46
+
47
+ export const Default = Template.bind({});
48
+ Default.args = generateProps();
49
+
50
+ export const PredefinedOptions = Template.bind({});
51
+ PredefinedOptions.args = generateProps({
52
+ prepend: '',
53
+ predefinedOptions: [
54
+ { name: 'Embed', value: 'https://embed.com' },
55
+ { name: 'Share', value: 'https://share.org' },
56
+ ],
57
+ });
58
+
59
+ export default {
60
+ title: 'base/form/form-input-group',
61
+ component: GlFormInputGroup,
62
+ knobs: { disabled: true },
63
+ parameters: {
64
+ bootstrapComponent: 'b-form-input',
65
+ docs: {
66
+ description: {
67
+ component: readme,
31
68
  },
32
69
  },
33
- template: `
34
- <gl-form-input-group :readonly="readonly" :select-on-click="select">
35
- <template #prepend v-if="prepend">
36
- <gl-input-group-text>{{prepend}}</gl-input-group-text>
37
- </template>
38
- <template #append v-if="append">
39
- <gl-input-group-text>{{append}}</gl-input-group-text>
40
- </template>
41
- </gl-form-input-group>
42
- `,
43
- }))
44
- .add('with predefined options', () => ({
45
- components,
46
- props: {
47
- prepend: {
48
- default: text('Prepend text', ''),
70
+ knobs: { disabled: true },
71
+ },
72
+ argTypes: {
73
+ ...disableControls(['value']),
74
+ prepend: {
75
+ control: {
76
+ type: 'text',
49
77
  },
50
- append: {
51
- default: text('Append text', 'Add'),
52
- },
53
- readonly: {
54
- default: boolean('Readonly', false),
78
+ },
79
+ append: {
80
+ control: {
81
+ type: 'text',
55
82
  },
56
- select: {
57
- default: boolean('Select text on click', false),
83
+ },
84
+ inputClass: {
85
+ control: {
86
+ type: 'text',
58
87
  },
59
- options: {
60
- default: object('Predefined options', predefinedOptions),
88
+ },
89
+ label: {
90
+ control: {
91
+ type: 'text',
61
92
  },
62
93
  },
63
- template: `
64
- <gl-form-input-group :readonly="readonly" :select-on-click="select" :predefined-options="options">
65
- <template #prepend v-if="prepend">
66
- <gl-input-group-text>{{prepend}}</gl-input-group-text>
67
- </template>
68
- <template #append v-if="append">
69
- <gl-input-group-text>{{append}}</gl-input-group-text>
70
- </template>
71
- </gl-form-input-group>
72
- `,
73
- }));
94
+ },
95
+ };
@@ -16,11 +16,17 @@ export default {
16
16
  },
17
17
  mixins: [InputGroupMixin],
18
18
  props: {
19
+ /**
20
+ * Automatically selects the content of the input field on click.
21
+ */
19
22
  selectOnClick: {
20
23
  type: Boolean,
21
24
  required: false,
22
25
  default: false,
23
26
  },
27
+ /**
28
+ * Array of options. Each option should have `name` and `value` information: {name: "Foo", value: "Bar"})
29
+ */
24
30
  predefinedOptions: {
25
31
  type: Array,
26
32
  required: false,
@@ -61,6 +67,7 @@ export default {
61
67
  <div>
62
68
  <b-input-group>
63
69
  <b-input-group-prepend v-if="activeOption || $scopedSlots.prepend">
70
+ <!-- @slot Is rendered in front of the input field. -->
64
71
  <slot name="prepend"></slot>
65
72
  <gl-dropdown v-if="activeOption" :text="activeOption">
66
73
  <gl-dropdown-item
@@ -74,6 +81,7 @@ export default {
74
81
  </gl-dropdown-item>
75
82
  </gl-dropdown>
76
83
  </b-input-group-prepend>
84
+ <!-- @slot Allows replacement of default input field. -->
77
85
  <slot>
78
86
  <b-form-input
79
87
  ref="input"
@@ -86,6 +94,7 @@ export default {
86
94
  />
87
95
  </slot>
88
96
  <b-input-group-append v-if="$scopedSlots.append">
97
+ <!-- @slot Is rendered after the input field. -->
89
98
  <slot name="append"></slot>
90
99
  </b-input-group-append>
91
100
  </b-input-group>