@gitlab/ui 107.7.1 → 108.0.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.
@@ -8,7 +8,7 @@ import GlFormInputGroup from '../form/form_input_group/form_input_group';
8
8
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
9
9
 
10
10
  var script = {
11
- name: 'GlSearchboxByClick',
11
+ name: 'GlSearchBoxByClick',
12
12
  components: {
13
13
  GlClearIconButton,
14
14
  GlButton,
@@ -6,7 +6,7 @@ import { translate } from '../../../utils/i18n';
6
6
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
7
7
 
8
8
  var script = {
9
- name: 'GlSearchboxByType',
9
+ name: 'GlSearchBoxByType',
10
10
  components: {
11
11
  GlClearIconButton,
12
12
  GlIcon,
@@ -1,4 +1,5 @@
1
1
  import { isVisible } from '../vendor/bootstrap-vue/src/utils/dom';
2
+ export { isVisible } from '../vendor/bootstrap-vue/src/utils/dom';
2
3
  import { COMMA, labelColorOptions, CONTRAST_LEVELS, focusableTags } from './constants';
3
4
 
4
5
  function debounceByAnimationFrame(fn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "107.7.1",
3
+ "version": "108.0.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -173,8 +173,8 @@
173
173
  "npm-run-all": "^4.1.5",
174
174
  "patch-package": "^8.0.0",
175
175
  "pikaday": "^1.8.0",
176
- "playwright": "^1.50.0",
177
- "playwright-core": "^1.50.0",
176
+ "playwright": "^1.50.1",
177
+ "playwright-core": "^1.50.1",
178
178
  "postcss": "8.4.28",
179
179
  "postcss-loader": "^7.0.2",
180
180
  "postcss-scss": "4.0.4",
@@ -1 +1,306 @@
1
- General user input to be used in forms.
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.