@gitlab/ui 115.8.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/components/charts/line/line.js +9 -1
- package/dist/components/charts/shared/tooltip/tooltip.js +116 -16
- 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/components/charts/line/line.vue +9 -0
- package/src/components/charts/shared/tooltip/tooltip.vue +115 -18
- 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,76 +0,0 @@
|
|
|
1
|
-
The filtered search component is responsible for managing search with possible filters.
|
|
2
|
-
|
|
3
|
-
## Usage
|
|
4
|
-
|
|
5
|
-
Each filter option (named token) requires a separate Vue component. `GlFilteredSearchToken` is an
|
|
6
|
-
example of such a token.
|
|
7
|
-
|
|
8
|
-
Prepare array of available token configurations with the following fields:
|
|
9
|
-
|
|
10
|
-
- `type`: unique identifier of token type
|
|
11
|
-
- `title`: human-readable title of the token
|
|
12
|
-
- `icon`: token icon
|
|
13
|
-
- `token`: (optional) the token Vue component to use (e.g. `AuthorToken`)
|
|
14
|
-
- `dataType`: (optional) identifier of type (for example "user") for this filter. Tokens
|
|
15
|
-
of the same type could be switched without losing their values
|
|
16
|
-
- `unique`: (optional) indicate this token could appear only once in the filter
|
|
17
|
-
- `disabled`: (optional) indicate this token should be hidden from the dropdown
|
|
18
|
-
- `operators`: (optional) an array of selectable operators.
|
|
19
|
-
Each array item is an object that must contain `value` and `description`, and optionally `default`
|
|
20
|
-
(e.g. `{ value: '=', description: 'is', default: 'true' }`)
|
|
21
|
-
- `multiSelect`: (optional) when `true`, the suggestions list becomes multi-select instead of single-select.
|
|
22
|
-
It is discouraged to use this together with `unique`, as `unique` is intended for single-select.
|
|
23
|
-
- `options`: (optional) an array of options which the user can pick after the
|
|
24
|
-
operator has been selected. The option object can have the following
|
|
25
|
-
properties defined: `value: string`, `icon: string`, `title: string`,
|
|
26
|
-
`component: Object` and `default: boolean`. If `component` is provided, it is
|
|
27
|
-
is used to render the option in the suggestions list.
|
|
28
|
-
- `optionComponent`: (optional) A component used to render the token option
|
|
29
|
-
itself when adding a new token or replacing an existing one
|
|
30
|
-
- any additional fields required to configure your component
|
|
31
|
-
|
|
32
|
-
Each token for filtered search is a Vue component with the following props:
|
|
33
|
-
|
|
34
|
-
- `value`: an object with a `data` property containing the current value, and optionally an
|
|
35
|
-
`operator` value containing the operator value
|
|
36
|
-
- `active`: indicates if the token is currently active. It's the token's responsibility
|
|
37
|
-
to render proper control for editing (for example input).
|
|
38
|
-
- `current-value`: current tokens of the filtered search.
|
|
39
|
-
- `index`: current token position in the filtered search.
|
|
40
|
-
- `config`: additional configuration, supplied in filtered search config for this token.
|
|
41
|
-
|
|
42
|
-
The token should emit the following events:
|
|
43
|
-
|
|
44
|
-
- `activate`: when the token requests activation (for example, when being clicked).
|
|
45
|
-
- `deactivate`: when token requests deactivation (for example due to losing blur on input).
|
|
46
|
-
- `destroy`: when token requests self-destruction (for instance for clicking "X" sign).
|
|
47
|
-
- `replace`: token requests its replacement with another token.
|
|
48
|
-
- `split`: token requests adding string values after the current token.
|
|
49
|
-
- `complete`: token indicates its editing is completed.
|
|
50
|
-
|
|
51
|
-
### Improve space handling
|
|
52
|
-
|
|
53
|
-
Set the `terms-as-tokens` prop to `true` to enable new term rendering and
|
|
54
|
-
interaction behavior. This makes it easier to input/edit free text tokens, and
|
|
55
|
-
removes the need for quoting values with spaces and other workarounds.
|
|
56
|
-
|
|
57
|
-
In future, this prop will be enabled by default and eventually removed. Opt in
|
|
58
|
-
to this earlier rather than later to ease migration.
|
|
59
|
-
|
|
60
|
-
## Examples
|
|
61
|
-
|
|
62
|
-
Define a list of available tokens:
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
const availableTokens = [
|
|
66
|
-
{ type: 'static', icon: 'label', title: 'static:token', token: staticToken },
|
|
67
|
-
{ type: 'dynamic', icon: 'rocket', title: 'dynamic:~token', token: dynamicToken },
|
|
68
|
-
];
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Pass the list of tokens to the search component. Optionally, you can use `v-model` to receive
|
|
72
|
-
realtime updates:
|
|
73
|
-
|
|
74
|
-
```html
|
|
75
|
-
<gl-filtered-search :available-tokens="tokens" v-model="value" terms-as-tokens />
|
|
76
|
-
```
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
The filtered search suggestion component is a wrapper around `GlDropdownItem`, which registers
|
|
2
|
-
suggestions in a top-level suggestion list:
|
|
3
|
-
|
|
4
|
-
```html
|
|
5
|
-
<gl-filtered-search-suggestion-list>
|
|
6
|
-
<gl-filtered-search-suggestion value="foo" key="foo-0">Example suggestion</gl-filtered-search-suggestion>
|
|
7
|
-
<gl-filtered-search-suggestion value="bar" key="bar-1">Example suggestion 2</gl-filtered-search-suggestion>
|
|
8
|
-
</gl-filtered-search-suggestion-list>
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
> NOTE: Provide a `key` to suggestions of the form `${value}-${index}` (or
|
|
12
|
-
> similar). While using the index in keys is usually frowned upon for
|
|
13
|
-
> performance reasons, the current implementation relies on all suggestions
|
|
14
|
-
> getting destroyed and recreated to keep rendering order in sync with
|
|
15
|
-
> <kbd>Up</kbd>/<kbd>Down</kbd> keyboard interaction.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
The filtered search suggestion list component is responsible for managing underlying suggestion instances.
|
|
2
|
-
You obtain the ref for this component and manage suggestion selection via the component public API:
|
|
3
|
-
|
|
4
|
-
- `getValue()` - Retrieves the current selected suggestion.
|
|
5
|
-
- `nextItem()` - Selects the next suggestion. If last suggestion was selected, selection is cleared.
|
|
6
|
-
- `prevItem()` - Selects the previous suggestion. If first suggestion was selected, selection is cleared.
|
|
7
|
-
|
|
8
|
-
```html
|
|
9
|
-
<gl-filtered-search-suggestion-list ref="suggestions">
|
|
10
|
-
<gl-filtered-search-suggestion value="foo">Example suggestion</gl-filtered-search-suggestion>
|
|
11
|
-
<gl-filtered-search-suggestion value="bar">Example suggestion 2</gl-filtered-search-suggestion>
|
|
12
|
-
</gl-filtered-search-suggestion-list>
|
|
13
|
-
```
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
The filtered search term is a component for managing "free input" in the filtered search component.
|
|
2
|
-
It is responsible for autocompleting available tokens and "converting" to a relevant
|
|
3
|
-
component when an autocomplete item is selected.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
This component is internal and is not intended to be used by `@gitlab/ui` users.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Filtered search token is a helper component, intended to
|
|
2
|
-
simplify the creation of filters tokens which consist of a title, operators
|
|
3
|
-
and an editable value with autocomplete. This component abstracts token management
|
|
4
|
-
logic and allows you to focus on implementing autocomplete or view logic.
|
|
5
|
-
|
|
6
|
-
This component is not intended to be used outside of the `GlFilteredSearch` component.
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
Make sure to pass `$listeners` to `gl-filtered-search-token`, or route events properly:
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<gl-filtered-search-token title="Confidential" :active="active" :value="value" v-on="$listeners">
|
|
14
|
-
<template #suggestions>
|
|
15
|
-
<gl-filtered-search-suggestion value="Yes"
|
|
16
|
-
><gl-icon name="eye-slash" :size="16" /> Yes</gl-filtered-search-suggestion
|
|
17
|
-
>
|
|
18
|
-
<gl-filtered-search-suggestion value="No"
|
|
19
|
-
><gl-icon name="eye" :size="16" /> No</gl-filtered-search-suggestion
|
|
20
|
-
>
|
|
21
|
-
</template>
|
|
22
|
-
</gl-filtered-search-token>
|
|
23
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
The filtered search token segment is a component for managing token input either via free typing
|
|
2
|
-
or by selecting item through dropdown list
|
|
3
|
-
|
|
4
|
-
## Usage
|
|
5
|
-
|
|
6
|
-
This component is internal and is not intended to be used by `@gitlab/ui` users.
|
|
7
|
-
|
|
8
|
-
## Internet Explorer 11
|
|
9
|
-
|
|
10
|
-
This component uses [`String.prototype.startsWith()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)
|
|
11
|
-
and [`String.prototype.endsWith()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
|
|
12
|
-
under the hood. Make sure those methods are polyfilled if you plan on using the component on IE11.
|
|
13
|
-
|
|
14
|
-
> NOTE: These methods are already polyfilled in GitLab: [`app/assets/javascripts/commons/polyfills.js#L15-16`](https://gitlab.com/gitlab-org/gitlab/blob/dc60dee6ed6234dda9f032195577cd8fad9646d8/app/assets/javascripts/commons/polyfills.js#L15-16)
|
|
@@ -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).
|