@gitlab/ui 115.9.0 → 115.9.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.
- package/dist/components/base/avatar_link/avatar_link.js +1 -1
- package/dist/components/base/avatars_inline/avatars_inline.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/package.json +10 -10
- package/src/components/base/avatar_link/avatar_link.vue +1 -1
- package/src/components/base/avatars_inline/avatars_inline.vue +1 -1
- package/src/components/base/markdown/markdown_typescale_demo.html +41 -71
- package/src/scss/variables.scss +1 -1
- package/src/components/base/accordion/accordion.md +0 -3
- package/src/components/base/accordion/accordion_item.md +0 -3
- package/src/components/base/alert/alert.md +0 -35
- package/src/components/base/animated_icon/animated_icon.md +0 -4
- package/src/components/base/avatar/avatar.md +0 -1
- package/src/components/base/avatar_labeled/avatar_labeled.md +0 -20
- package/src/components/base/avatar_link/avatar_link.md +0 -33
- package/src/components/base/avatars_inline/avatars_inline.md +0 -38
- package/src/components/base/badge/badge.md +0 -30
- package/src/components/base/banner/banner.md +0 -35
- package/src/components/base/breadcrumb/breadcrumb.md +0 -52
- package/src/components/base/broadcast_message/broadcast_message.md +0 -25
- package/src/components/base/button/button.md +0 -119
- package/src/components/base/button_group/button_group.md +0 -44
- package/src/components/base/card/card.md +0 -4
- package/src/components/base/collapse/collapse.md +0 -64
- package/src/components/base/datepicker/datepicker.md +0 -8
- package/src/components/base/daterange_picker/daterange_picker.md +0 -32
- package/src/components/base/drawer/drawer.md +0 -17
- package/src/components/base/dropdown/dropdown.md +0 -72
- package/src/components/base/dropdown/dropdown_item.md +0 -2
- package/src/components/base/dropdown/dropdown_section_header.md +0 -7
- package/src/components/base/dropdown/dropdown_text.md +0 -7
- package/src/components/base/filtered_search/filtered_search.md +0 -76
- package/src/components/base/filtered_search/filtered_search_suggestion.md +0 -15
- package/src/components/base/filtered_search/filtered_search_suggestion_list.md +0 -13
- package/src/components/base/filtered_search/filtered_search_term.md +0 -7
- package/src/components/base/filtered_search/filtered_search_token.md +0 -23
- package/src/components/base/filtered_search/filtered_search_token_segment.md +0 -14
- package/src/components/base/form/form_checkbox/form_checkbox.md +0 -6
- package/src/components/base/form/form_input/form_input.md +0 -306
- package/src/components/base/form/form_radio/form_radio.md +0 -23
- package/src/components/base/form/form_radio_group/form_radio_group.md +0 -63
- package/src/components/base/form/form_select/form_select.md +0 -1
- package/src/components/base/form/form_textarea/form_textarea.md +0 -3
- package/src/components/base/icon/icon.md +0 -27
- package/src/components/base/infinite_scroll/infinite_scroll.md +0 -104
- package/src/components/base/keyset_pagination/keyset_pagination.md +0 -49
- package/src/components/base/label/label.md +0 -15
- package/src/components/base/link/link.md +0 -187
- package/src/components/base/loading_icon/loading_icon.md +0 -3
- package/src/components/base/modal/modal.md +0 -30
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.md +0 -184
- package/src/components/base/new_dropdowns/listbox/listbox.md +0 -195
- package/src/components/base/pagination/pagination.md +0 -45
- package/src/components/base/path/path.md +0 -41
- package/src/components/base/progress_bar/progress_bar.md +0 -25
- package/src/components/base/search_box_by_click/search_box_by_click.md +0 -1
- package/src/components/base/search_box_by_type/search_box_by_type.md +0 -1
- package/src/components/base/segmented_control/segmented_control.md +0 -26
- package/src/components/base/skeleton_loader/skeleton_loader.md +0 -70
- package/src/components/base/sorting/sorting.md +0 -80
- package/src/components/base/table/table.md +0 -71
- package/src/components/base/table_lite/table_lite.md +0 -68
- package/src/components/base/tabs/tabs/tabs.md +0 -80
- package/src/components/base/toast/toast.md +0 -48
- package/src/components/base/toggle/toggle.md +0 -4
- package/src/components/base/token/token.md +0 -12
- package/src/components/base/tooltip/tooltip.md +0 -52
- package/src/scss/typescale/typeface_demo.html +0 -70
- package/src/scss/typescale/typescale.md +0 -81
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
General user input to be used in forms. Create various type inputs such as:
|
|
2
|
-
`text`, `password`, `number`, `url`, `email`, `search`, `range`, `date`
|
|
3
|
-
and more.
|
|
4
|
-
|
|
5
|
-
```html
|
|
6
|
-
<template>
|
|
7
|
-
<gl-form-input v-model="text" placeholder="Enter your name"></gl-form-input>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
export default {
|
|
12
|
-
data() {
|
|
13
|
-
return {
|
|
14
|
-
text: ''
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
</script>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Input type
|
|
22
|
-
|
|
23
|
-
`<gl-form-input>` defaults to a `text` input, but you can set the `type` prop
|
|
24
|
-
to one of the supported native browser HTML5 types: `text`, `password`,
|
|
25
|
-
`email`, `number`, `url`, `tel`, `search`, `date`, `datetime`
|
|
26
|
-
`datetime-local`, `month`, `week`, `time`, `range`, or `color`.
|
|
27
|
-
|
|
28
|
-
If the `type` prop is set to an input type that is not supported (see above),
|
|
29
|
-
a `text` input will be rendered.
|
|
30
|
-
|
|
31
|
-
**Caveats with input types:**
|
|
32
|
-
|
|
33
|
-
- Not all browsers support all input types, nor do some types render in the same format across
|
|
34
|
-
browser types/versions. Refer to [Can I use](https://caniuse.com/?search=input).
|
|
35
|
-
- Browsers that do not support a particular type will fall back to a `text` input type
|
|
36
|
-
(even though the rendered `type` attribute markup shows the requested type).
|
|
37
|
-
- No testing is performed to see if the requested input type is supported by the browser.
|
|
38
|
-
- Chrome lost support for `datetime` in version 26, Opera in version 15, and Safari in iOS 7.
|
|
39
|
-
Instead of using `datetime`, since support should be deprecated, use `date` and
|
|
40
|
-
`time` as two separate inputs.
|
|
41
|
-
- `date` and `time` inputs are native browser types, and are not a custom date/time picker.
|
|
42
|
-
- For date and time style inputs, where supported, the displayed value in the GUI may be
|
|
43
|
-
different than what is returned by its value (i.e. ordering of year-month-date).
|
|
44
|
-
- Regardless of input type, the value is **always** returned as a string representation.
|
|
45
|
-
- `v-model.lazy` is not supported by `<b-form-input>` (nor any custom Vue component).
|
|
46
|
-
Use the `lazy` prop instead.
|
|
47
|
-
- `v-model` modifiers `.number` and `.trim` can cause unexpected cursor jumps when
|
|
48
|
-
the user is typing (this is a Vue issue with `v-model` on custom components).
|
|
49
|
-
_Avoid using these modifiers_. Use the `number` or `trim` props instead.
|
|
50
|
-
- Older version of Firefox may not support `readonly` for `range` type inputs.
|
|
51
|
-
- Input types that do not support `min`, `max` and `step` (i.e. `text`, `password`,
|
|
52
|
-
`tel`, `email`, `url`, etc.) will silently ignore these values
|
|
53
|
-
(although they will still be rendered on the input markup) if values are provided.
|
|
54
|
-
|
|
55
|
-
**Caveats with predictive text entry and IME composition entry:**
|
|
56
|
-
|
|
57
|
-
- When using predictive text auto-suggested words, the `v-model` will no update until
|
|
58
|
-
the auto-suggested word is selected (or a space is typed). If an auto suggested word
|
|
59
|
-
is not selected, the v-model will update with the current _displayed text_ of the input
|
|
60
|
-
when the input is blurred.
|
|
61
|
-
- When using IME composition (ie. Chinese, Japanese, etc.), the `v-model` will not update
|
|
62
|
-
until the IME composition is completed.
|
|
63
|
-
|
|
64
|
-
### Range type input
|
|
65
|
-
|
|
66
|
-
Inputs with type `range` render using Bootstrap v4's `.custom-range` class. The track
|
|
67
|
-
(the background) and thumb (the value) are both styled to appear the same across browsers.
|
|
68
|
-
|
|
69
|
-
Range inputs have implicit values for `min` and `max` of `0` and `100` respectively.
|
|
70
|
-
You may specify new values for those using the `min` and `max` props.
|
|
71
|
-
|
|
72
|
-
By default, range inputs "snap" to integer values. To change this, you can specify a `step` value.
|
|
73
|
-
In the example below, we double the number of steps by using step="0.5".
|
|
74
|
-
|
|
75
|
-
```html
|
|
76
|
-
<template>
|
|
77
|
-
<gl-form-input id="range-2" v-model="value" type="range" min="0" max="5" step="0.5"></gl-form-input>
|
|
78
|
-
</template>
|
|
79
|
-
|
|
80
|
-
<script>
|
|
81
|
-
export default {
|
|
82
|
-
data() {
|
|
83
|
-
return {
|
|
84
|
-
value: '2'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
</script>
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Note:** Range inputs (as do all input types) return their value as a string.
|
|
92
|
-
You may need to convert the value to a native number by using `Number(value)`,
|
|
93
|
-
`parseInt(value, 10)`, `parseFloat(value)`, or use the `number` prop.
|
|
94
|
-
|
|
95
|
-
## Contextual states
|
|
96
|
-
|
|
97
|
-
Generally speaking, you'll want to use a particular state for specific types of feedback:
|
|
98
|
-
|
|
99
|
-
- `false` (denotes invalid state) is great for when there's a blocking or required field.
|
|
100
|
-
A user must fill in this field properly to submit the form.
|
|
101
|
-
- `true` (denotes valid state) is ideal for situations when you have per-field validation
|
|
102
|
-
throughout a form and want to encourage a user through the rest of the fields.
|
|
103
|
-
- `null` Displays no validation state (neither valid nor invalid)
|
|
104
|
-
|
|
105
|
-
To apply one of the contextual state icons on `<gl-form-input>`, set the `state` prop to
|
|
106
|
-
`false` (for invalid), `true` (for valid), or `null` (no validation state).
|
|
107
|
-
|
|
108
|
-
> **Tip:** Use the [`<gl-form-group>`](?path=/docs/base-form-form-group--docs) component to
|
|
109
|
-
> automatically generate markup for an input with label, validation message, and help text block.
|
|
110
|
-
|
|
111
|
-
### ARIA `aria-invalid` attribute
|
|
112
|
-
|
|
113
|
-
Specifically for assistive technologies, invalid form controls can also be assigned
|
|
114
|
-
an `aria-invalid="true"` attribute.
|
|
115
|
-
|
|
116
|
-
When `<gl-form-input>` has an invalid contextual state (i.e. state is `false`) you
|
|
117
|
-
may also want to set the `<gl-form-input>` prop `aria-invalid` to `true`, or to
|
|
118
|
-
one of the supported values:
|
|
119
|
-
|
|
120
|
-
- `false`: Convey no errors detected (default)
|
|
121
|
-
- `true` (or `'true'`): Convey that the value has failed validation.
|
|
122
|
-
- `'grammar'` Convey that a grammatical error has been detected.
|
|
123
|
-
- `'spelling'` Convey that a spelling error has been detected.
|
|
124
|
-
|
|
125
|
-
If `aria-invalid` is not explicitly set and `state` is set to `false`, then the `aria-invalid`
|
|
126
|
-
attribute on the input will automatically be set to `'true'`;
|
|
127
|
-
|
|
128
|
-
## Formatter support
|
|
129
|
-
|
|
130
|
-
`<gl-form-input>` optionally supports formatting by passing a function reference to
|
|
131
|
-
the `formatter` prop.
|
|
132
|
-
|
|
133
|
-
Formatting (when a formatter function is supplied) occurs when the control's native
|
|
134
|
-
`input` and `change` events fire. You can use the boolean prop `lazy-formatter` to
|
|
135
|
-
restrict the formatter function to being called on the control's native `blur` event.
|
|
136
|
-
|
|
137
|
-
The `formatter` function receives two arguments: the raw `value` of the input element,
|
|
138
|
-
and the native `event` object that triggered the format (if available).
|
|
139
|
-
|
|
140
|
-
The `formatter` function should return the formatted value as a _string_.
|
|
141
|
-
|
|
142
|
-
Formatting does not occur if a `formatter` is not provided.
|
|
143
|
-
|
|
144
|
-
```html
|
|
145
|
-
<template>
|
|
146
|
-
<div>
|
|
147
|
-
<gl-form-group
|
|
148
|
-
label="Text input with formatter (on input)"
|
|
149
|
-
label-for="input-formatter"
|
|
150
|
-
description="We will convert your name to lowercase instantly"
|
|
151
|
-
class="mb-0"
|
|
152
|
-
>
|
|
153
|
-
<gl-form-input
|
|
154
|
-
id="input-formatter"
|
|
155
|
-
v-model="text1"
|
|
156
|
-
placeholder="Enter your name"
|
|
157
|
-
:formatter="formatter"
|
|
158
|
-
></gl-form-input>
|
|
159
|
-
</gl-form-group>
|
|
160
|
-
<p><b>Value:</b> {{ text1 }}</p>
|
|
161
|
-
|
|
162
|
-
<gl-form-group
|
|
163
|
-
label="Text input with lazy formatter (on blur)"
|
|
164
|
-
label-for="input-lazy"
|
|
165
|
-
description="This one is a little lazy!"
|
|
166
|
-
class="mb-0"
|
|
167
|
-
>
|
|
168
|
-
<gl-form-input
|
|
169
|
-
id="input-lazy"
|
|
170
|
-
v-model="text2"
|
|
171
|
-
placeholder="Enter your name"
|
|
172
|
-
lazy-formatter
|
|
173
|
-
:formatter="formatter"
|
|
174
|
-
></gl-form-input>
|
|
175
|
-
</gl-form-group>
|
|
176
|
-
<p class="mb-0"><b>Value:</b> {{ text2 }}</p>
|
|
177
|
-
</div>
|
|
178
|
-
</template>
|
|
179
|
-
|
|
180
|
-
<script>
|
|
181
|
-
export default {
|
|
182
|
-
data() {
|
|
183
|
-
return {
|
|
184
|
-
text1: '',
|
|
185
|
-
text2: ''
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
methods: {
|
|
189
|
-
formatter(value) {
|
|
190
|
-
return value.toLowerCase()
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
</script>
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Note:** When using a non-text-like input (i.e. `color`, `range`, `date`, `number`, `email` etc.),
|
|
198
|
-
ensure that your formatter function returns the value in the expected format
|
|
199
|
-
(`date` -> '2000-06-01', `color` -> '#ff0000', etc.) for the input type.
|
|
200
|
-
The formatter **must** return the value as a _string_.
|
|
201
|
-
|
|
202
|
-
**Note:** With non-lazy formatting, if the cursor is not at the end of the input value,
|
|
203
|
-
the cursor may jump to the end _after_ a character is typed. You can use the provided event
|
|
204
|
-
object and the `event.target` to access the native input's selection methods and properties
|
|
205
|
-
to control where the insertion point is.
|
|
206
|
-
|
|
207
|
-
## Readonly plain text
|
|
208
|
-
|
|
209
|
-
If you want to have `<gl-form-input readonly>` elements in your form styled as plain text,
|
|
210
|
-
set the `plaintext` prop (no need to set `readonly`) to remove the default form field
|
|
211
|
-
styling and preserve the correct margin and padding.
|
|
212
|
-
|
|
213
|
-
The `plaintext` option is not supported by input types `color` or `range`.
|
|
214
|
-
|
|
215
|
-
## Disabled mousewheel events on numeric-like inputs
|
|
216
|
-
|
|
217
|
-
On some browsers, scrolling the mousewheel while a numeric-like input is focused will
|
|
218
|
-
increment or decrement the input's value. Therefore, mousewheel events are disabled on
|
|
219
|
-
focus numeric type inputs.
|
|
220
|
-
|
|
221
|
-
## `v-model` modifiers
|
|
222
|
-
|
|
223
|
-
Vue does not officially support `.lazy`, `.trim`, and `.number` modifiers on the `v-model`
|
|
224
|
-
of custom component based inputs, and may generate a bad user experience.
|
|
225
|
-
Avoid using Vue's native modifiers.
|
|
226
|
-
|
|
227
|
-
To get around this, `<gl-form-input>` has three boolean props `trim`, `number`,
|
|
228
|
-
and `lazy` which emulate the native Vue `v-model` modifiers `.trim` and `.number`
|
|
229
|
-
and `.lazy` respectively. The `lazy` prop will update the v-model on `change`/`blur` events.
|
|
230
|
-
|
|
231
|
-
**Notes:**
|
|
232
|
-
|
|
233
|
-
- The `number` prop takes precedence over the `trim` prop
|
|
234
|
-
(i.e. `trim` will have no effect when `number` is set).
|
|
235
|
-
- When using the `number` prop, and if the value can be parsed as a number (via `parseFloat`)
|
|
236
|
-
it will return a value of type `Number` to the `v-model`, otherwise the original input value
|
|
237
|
-
is returned as type `String`. This is the same behaviour as the native `.number` modifier.
|
|
238
|
-
- The `trim` and `number` modifier props do not affect the value returned by the
|
|
239
|
-
`input` or `change` events. These events will always return the string value of the
|
|
240
|
-
content of `<textarea>` after optional formatting (which may not match the value returned
|
|
241
|
-
via the `v-model` `update` event, which handles the modifiers).
|
|
242
|
-
|
|
243
|
-
## Debounce support
|
|
244
|
-
|
|
245
|
-
As an alternative to the `lazy` modifier prop, `<gl-form-input>` optionally supports debouncing
|
|
246
|
-
user input, updating the `v-model` after a period of idle time from when the last character
|
|
247
|
-
was entered by the user (or a `change` event occurs). If the user enters a new character
|
|
248
|
-
(or deletes characters) before the idle timeout expires, the timeout is re-started.
|
|
249
|
-
|
|
250
|
-
To enable debouncing, set the prop `debounce` to any integer greater than zero.
|
|
251
|
-
The value is specified in milliseconds. Setting `debounce` to `0` will disable debouncing.
|
|
252
|
-
|
|
253
|
-
Note: debouncing will _not_ occur if the `lazy` prop is set.
|
|
254
|
-
|
|
255
|
-
## Autofocus
|
|
256
|
-
|
|
257
|
-
When the `autofocus` prop is set, the input will be auto-focused when it is inserted
|
|
258
|
-
(i.e. **mounted**) into the document, or re-activated when inside a Vue `<keep-alive>` component.
|
|
259
|
-
Note that this prop **does not** set the `autofocus` attribute on the input,
|
|
260
|
-
nor can it tell when the input becomes visible.
|
|
261
|
-
|
|
262
|
-
## Native and custom events
|
|
263
|
-
|
|
264
|
-
All native events (other than the custom `input` and `change` events) are supported,
|
|
265
|
-
without the need for the `.native` modifier.
|
|
266
|
-
|
|
267
|
-
The custom `update` and `change` events receive a single argument of the current `value`
|
|
268
|
-
(after any formatting has been applied), and are triggered by user interaction.
|
|
269
|
-
|
|
270
|
-
The custom `input` event is passed the input value, and is emitted whenever the
|
|
271
|
-
`v-model` needs updating (it is emitted before `update`, `change`. and `blur` as needed).
|
|
272
|
-
|
|
273
|
-
You can always access the native `input` and `change` events by using the `.native` modifier.
|
|
274
|
-
|
|
275
|
-
## Exposed input properties and methods
|
|
276
|
-
|
|
277
|
-
`<gl-form-input>` exposes several of the native input element's properties and methods
|
|
278
|
-
on the component reference (i.e. assign a `ref` to your `<gl-form-input ref="foo" ...>`
|
|
279
|
-
and use `this.$refs['foo'].propertyName` or `this.$refs['foo'].methodName(...)`).
|
|
280
|
-
|
|
281
|
-
### Input properties
|
|
282
|
-
|
|
283
|
-
| Property | Notes |
|
|
284
|
-
| --------------------- | ---------- |
|
|
285
|
-
| `.selectionStart` | Read/Write |
|
|
286
|
-
| `.selectionEnd` | Read/Write |
|
|
287
|
-
| `.selectionDirection` | Read/Write |
|
|
288
|
-
| `.validity` | Read only |
|
|
289
|
-
| `.validationMessage` | Read only |
|
|
290
|
-
| `.willValidate` | Read only |
|
|
291
|
-
|
|
292
|
-
### Input methods
|
|
293
|
-
|
|
294
|
-
| Method | Notes |
|
|
295
|
-
| ---------------------- | --------------------------------- |
|
|
296
|
-
| `.focus()` | Focus the input |
|
|
297
|
-
| `.blur()` | Remove focus from the input |
|
|
298
|
-
| `.select()` | Selects all text within the input |
|
|
299
|
-
| `.setSelectionRange()` | |
|
|
300
|
-
| `.setRangeText()` | |
|
|
301
|
-
| `.setCustomValidity()` | |
|
|
302
|
-
| `.checkValidity()` | |
|
|
303
|
-
| `.reportValidity()` | |
|
|
304
|
-
|
|
305
|
-
Refer to <https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement> for more
|
|
306
|
-
information on these methods and properties. Support will vary based on input type.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
`GlFormRadio` components can be used directly, or via a `GlFormRadioGroup`.
|
|
2
|
-
|
|
3
|
-
Below is an example which demonstrates the direct approach. For examples using
|
|
4
|
-
`GlFormRadioGroup`, see the documentation for that component.
|
|
5
|
-
|
|
6
|
-
```html
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
data() {
|
|
10
|
-
return {
|
|
11
|
-
selected: 'yes',
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<template>
|
|
18
|
-
<div>
|
|
19
|
-
<gl-form-radio v-model="selected" value="yes">Yes</gl-form-radio>
|
|
20
|
-
<gl-form-radio v-model="selected" value="no">No</gl-form-radio>
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
```
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
The `GlFormRadioGroup` component provides an alternative and sometimes more
|
|
2
|
-
compact way of setting up a group of `GlFormRadio` components.
|
|
3
|
-
|
|
4
|
-
## Usage
|
|
5
|
-
|
|
6
|
-
`GlFormRadioGroup` can be used in a few ways to build a group of `GlFormRadio`
|
|
7
|
-
components: implicitly, explicitly, or a mix of both.
|
|
8
|
-
|
|
9
|
-
Below is an example which demonstrates all three approaches, written such that
|
|
10
|
-
all of them produce the same visual result.
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<script>
|
|
14
|
-
export default {
|
|
15
|
-
data() {
|
|
16
|
-
return {
|
|
17
|
-
selected: 'one',
|
|
18
|
-
options: [
|
|
19
|
-
{
|
|
20
|
-
value: 'one',
|
|
21
|
-
text: 'One',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
value: 'two',
|
|
25
|
-
text: 'Two',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
value: 'three',
|
|
29
|
-
text: 'Three',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<template>
|
|
38
|
-
<div>
|
|
39
|
-
<!-- Implicit -->
|
|
40
|
-
<gl-form-radio-group v-model="selected" :options="options" name="implicit" />
|
|
41
|
-
|
|
42
|
-
<!-- Explicit -->
|
|
43
|
-
<gl-form-radio-group v-model="selected" name="explicit">
|
|
44
|
-
<gl-form-radio value="one">One</gl-form-radio>
|
|
45
|
-
<gl-form-radio value="two">Two</gl-form-radio>
|
|
46
|
-
<gl-form-radio value="three">Three</gl-form-radio>
|
|
47
|
-
</gl-form-radio-group>
|
|
48
|
-
|
|
49
|
-
<!-- Mixed -->
|
|
50
|
-
<gl-form-radio-group v-model="selected" :options="[options[1]]" name="mixed">
|
|
51
|
-
<template #first>
|
|
52
|
-
<gl-form-radio value="one">One</gl-form-radio>
|
|
53
|
-
</template>
|
|
54
|
-
<gl-form-radio value="three">Three</gl-form-radio>
|
|
55
|
-
</gl-form-radio-group>
|
|
56
|
-
</div>
|
|
57
|
-
</template>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Stacked
|
|
61
|
-
|
|
62
|
-
By default, the GitLab Design guide mandates the `<gl-form-radio-group>` be `stacked` by default and
|
|
63
|
-
is non-changeable at this time.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Form select component used to select from group of options in a form.
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
## Usage
|
|
2
|
-
|
|
3
|
-
The Icon component can be used to render any svg within the @gitlab/svgs icon sprites.
|
|
4
|
-
|
|
5
|
-
### Accessibility
|
|
6
|
-
|
|
7
|
-
`gl-icon` icons are hidden from screen readers by default, as usages of icons are commonly decorative.
|
|
8
|
-
|
|
9
|
-
If the icon is not decorative, add an `aria-label` attribute to `gl-icon` to give it an accessible name.
|
|
10
|
-
This label is read out by screen readers.
|
|
11
|
-
|
|
12
|
-
If the icon is clickable, use `gl-button` instead of `gl-icon` because a clickable element should
|
|
13
|
-
semantically be a button.
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<!-- icon, which is hidden from screen readers by default -->
|
|
17
|
-
<gl-icon name="rocket" />
|
|
18
|
-
|
|
19
|
-
<!-- icon, which has an accessible name "Confidential issue" that is read out by screen readers -->
|
|
20
|
-
<gl-icon name="eye-slash" :aria-label="__('Confidential issue')" />
|
|
21
|
-
|
|
22
|
-
<!-- clickable icon, which is borderless and padding-less -->
|
|
23
|
-
<gl-button icon="close" category="tertiary" class="!gl-p-0" aria-label="Close" />
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
For more information about icons within GitLab, visit the
|
|
27
|
-
[GitLab accessibility guidelines](https://docs.gitlab.com/ee/development/fe_guide/accessibility#icons).
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
## Usage
|
|
2
|
-
|
|
3
|
-
The infinite scroll component wraps around a results list and emits a message
|
|
4
|
-
(`bottomReached`) when the bottom of the viewport is reached, which should trigger
|
|
5
|
-
a re-fetching. The `gl-infinite-scroll` component expects its parent component to
|
|
6
|
-
manage the re-fetching.
|
|
7
|
-
|
|
8
|
-
Additionally it emits a `topReached` message when the top of the viewport is reached, which
|
|
9
|
-
can be useful to load items on top of the available data. If only `topReached` is present, the
|
|
10
|
-
viewport will be scrolled to the bottom the first time this component is mounted.
|
|
11
|
-
|
|
12
|
-
## Public methods
|
|
13
|
-
|
|
14
|
-
Useful public methods you can call via `$refs`:
|
|
15
|
-
|
|
16
|
-
- `.scrollUp()`: Scrolls to the top of the container.
|
|
17
|
-
- `.scrollDown()`: Scrolls to the bottom of the container.
|
|
18
|
-
- `.scrollTo({ top, behavior })`: Scrolls to a number of pixels
|
|
19
|
-
along the Y axis of the container. The scrolling behavior can also be specified,
|
|
20
|
-
as per MDN spec (<https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo>)
|
|
21
|
-
|
|
22
|
-
## Implementation Example
|
|
23
|
-
|
|
24
|
-
This is how a full implementation would look like with paginated results from GitLab's
|
|
25
|
-
`projects` API.
|
|
26
|
-
|
|
27
|
-
In the component's state, initialize a `pageInfo` object:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
pageInfo: {
|
|
31
|
-
currentPage: 0,
|
|
32
|
-
nextPage: 0,
|
|
33
|
-
totalPages: 0,
|
|
34
|
-
totalResults: 0,
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
When fetching for the first time, set the state with the header
|
|
39
|
-
information in the mutations:
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
Vue.set(state.pageInfo, 'currentPage', parseInt(headers['X-Page'], 10));
|
|
43
|
-
Vue.set(state.pageInfo, 'nextPage', parseInt(headers['X-Next-Page'], 10));
|
|
44
|
-
Vue.set(state.pageInfo, 'totalPages', parseInt(headers['X-Total-Pages'], 10));
|
|
45
|
-
Vue.set(state.pageInfo, 'totalResults', parseInt(headers['X-Total'], 10));
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
_Note: There is a function you can use for parsing integers in headers in
|
|
49
|
-
GitLab called `parseIntPagination` in `common/utils.js`_
|
|
50
|
-
|
|
51
|
-
Every time `bottomReached` happens, update the state in your mutations:
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
state.searchResults = state.searchResults.concat(results.data);
|
|
55
|
-
Vue.set(state.pageInfo, 'nextPage', parseInt(headers['X-Next-Page'],10));
|
|
56
|
-
Vue.set(state.pageInfo, 'totalPages', parseInt(headers['X-Total-Pages'],10));
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Use the state to fetch the next page in the actions. In this case, the `Projects`
|
|
60
|
-
API allows us to send in a `page` parameter to fetch a certain page from the
|
|
61
|
-
list of results.
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
export const fetchNextPage = ({ state, dispatch }) => {
|
|
65
|
-
if(state.pageInfo.currentPage < state.pageInfo.totalPages) {
|
|
66
|
-
Api.projects(searchQuery, { page: state.pageInfo.nextPage })
|
|
67
|
-
...
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```html
|
|
73
|
-
<script>
|
|
74
|
-
exportDefault {
|
|
75
|
-
components: {
|
|
76
|
-
GlInfiniteScroll,
|
|
77
|
-
},
|
|
78
|
-
computed: {
|
|
79
|
-
...mapState([
|
|
80
|
-
'pageInfo',
|
|
81
|
-
'searchResults',
|
|
82
|
-
]),
|
|
83
|
-
},
|
|
84
|
-
methods: {
|
|
85
|
-
...mapActions([
|
|
86
|
-
'fetchNextPage',
|
|
87
|
-
]),
|
|
88
|
-
bottomReached() {
|
|
89
|
-
this.fetchNextPage();
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
}
|
|
93
|
-
</script>
|
|
94
|
-
<template>
|
|
95
|
-
<gl-infinite-scroll
|
|
96
|
-
@bottomReached="bottomReached"
|
|
97
|
-
:max-list-height="400"
|
|
98
|
-
:fetched-items="searchResults.length"
|
|
99
|
-
:total-items="totalResults"
|
|
100
|
-
>
|
|
101
|
-
...Results in a list, another component, etc ....
|
|
102
|
-
</gl-infinite-scroll>
|
|
103
|
-
</template>
|
|
104
|
-
```
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
Pagination is used to help users parse a large number of items on a page,
|
|
2
|
-
whenever there are too many results to show at once. Pagination breaks up
|
|
3
|
-
results into several pages with controls for navigating forward and backward, or
|
|
4
|
-
to a specific page.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
The simplest way to use `GlKeysetPagination` with a paginated GraphQL response
|
|
9
|
-
is to `v-bind` to the
|
|
10
|
-
[`PageInfo`](https://docs.gitlab.com/ee/api/graphql/reference/#pageinfo) type
|
|
11
|
-
returned by the endpoint:
|
|
12
|
-
|
|
13
|
-
```html
|
|
14
|
-
<gl-keyset-pagination v-bind="pageInfo" />
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
This is possible because the default field names of the `PageInfo` type align
|
|
18
|
-
with the `props` of this component.
|
|
19
|
-
|
|
20
|
-
## Dos and don'ts
|
|
21
|
-
|
|
22
|
-
**✅ Do** provide the `prevText` and `nextText` props with translatable strings.
|
|
23
|
-
The default strings ("Prev" and "Next") are hardcoded in this component and
|
|
24
|
-
can't be translated.
|
|
25
|
-
|
|
26
|
-
Example:
|
|
27
|
-
|
|
28
|
-
```html
|
|
29
|
-
<gl-keyset-pagination v-bind="pageInfo" :prev-text="__('Prev')" :next-text="__('Next')" />
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**✅ Do** use this component for paginating GraphQL requests[^1] (or any
|
|
33
|
-
endpoint that uses keyset pagination).
|
|
34
|
-
|
|
35
|
-
**❌ Don't** use this component for paginating REST requests[^1] (or any
|
|
36
|
-
endpoint that uses offset pagination).
|
|
37
|
-
|
|
38
|
-
For offset pagination, use the [`GlPagination`
|
|
39
|
-
component](/?path=/story/base-pagination--default) instead.
|
|
40
|
-
|
|
41
|
-
For more information on the difference between offset and keyset pagination see
|
|
42
|
-
[our documentation on GraphQL
|
|
43
|
-
pagination](https://docs.gitlab.com/ee/development/graphql_guide/pagination.html).
|
|
44
|
-
|
|
45
|
-
[^1]: There's no intrinsic reason why GraphQL endpoints can't support offset pagination (in fact, [the official documentation](https://graphql.org/learn/pagination/#pagination-and-edges) shows an example offset pagination implementation) or why REST endpoints can't support keyset pagination. This is simply how we've chosen to implement our REST and GraphQL endpoints at GitLab.
|
|
46
|
-
|
|
47
|
-
## Pajamas reference
|
|
48
|
-
|
|
49
|
-
<https://design.gitlab.com/components/pagination>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Labels are editable objects that allow users to manually categorize other objects, like issues,
|
|
2
|
-
merge requests, and epics. They have a name, description, and a customizable background color.
|
|
3
|
-
They provide a quick way to recognize which categories the labeled object belongs to.
|
|
4
|
-
|
|
5
|
-
## Using the component
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
<gl-label
|
|
9
|
-
background-color="#D9C2EE"
|
|
10
|
-
title="Label content"
|
|
11
|
-
description="Some content"
|
|
12
|
-
tooltipPlacement="top"
|
|
13
|
-
target="http://some.url"
|
|
14
|
-
/>
|
|
15
|
-
```
|