@gitlab/ui 38.10.2 → 39.0.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.
- package/CHANGELOG.md +36 -0
- package/dist/components/base/alert/alert.js +1 -1
- package/dist/components/base/filtered_search/filtered_search.js +18 -2
- package/dist/components/base/filtered_search/filtered_search_term.js +6 -1
- package/dist/components/base/filtered_search/filtered_search_token.js +32 -4
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +36 -16
- package/dist/components/base/form/form_textarea/form_textarea.js +2 -62
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utils/constants.js +1 -5
- package/package.json +9 -9
- package/src/components/base/alert/alert.vue +8 -8
- package/src/components/base/filtered_search/__snapshots__/filtered_search_term.spec.js.snap +4 -4
- package/src/components/base/filtered_search/filtered_search.stories.js +8 -1
- package/src/components/base/filtered_search/filtered_search.vue +19 -0
- package/src/components/base/filtered_search/filtered_search_term.spec.js +1 -0
- package/src/components/base/filtered_search/filtered_search_term.vue +11 -1
- package/src/components/base/filtered_search/filtered_search_token.spec.js +1 -0
- package/src/components/base/filtered_search/filtered_search_token.vue +41 -1
- package/src/components/base/filtered_search/filtered_search_token_segment.spec.js +2 -2
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +33 -12
- package/src/components/base/form/form_checkbox/form_checkbox.scss +4 -2
- package/src/components/base/form/form_textarea/form_textarea.spec.js +8 -115
- package/src/components/base/form/form_textarea/form_textarea.stories.js +0 -21
- package/src/components/base/form/form_textarea/form_textarea.vue +8 -73
- package/src/utils/constants.js +0 -5
package/dist/utils/constants.js
CHANGED
|
@@ -251,9 +251,5 @@ const loadingIconSizes = {
|
|
|
251
251
|
'lg (32x32)': 'lg',
|
|
252
252
|
'xl (64x64)': 'xl'
|
|
253
253
|
};
|
|
254
|
-
const textareaCountOptions = {
|
|
255
|
-
max: 'max',
|
|
256
|
-
recommended: 'recommended'
|
|
257
|
-
};
|
|
258
254
|
|
|
259
|
-
export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, sizeOptions, sizeOptionsWithNoDefault, tabsButtonDefaults, targetOptions,
|
|
255
|
+
export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, sizeOptions, sizeOptionsWithNoDefault, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "39.0.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -92,15 +92,15 @@
|
|
|
92
92
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
93
93
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
94
94
|
"@rollup/plugin-replace": "^2.3.2",
|
|
95
|
-
"@storybook/addon-a11y": "6.4.
|
|
96
|
-
"@storybook/addon-docs": "6.4.
|
|
97
|
-
"@storybook/addon-essentials": "6.4.
|
|
95
|
+
"@storybook/addon-a11y": "6.4.22",
|
|
96
|
+
"@storybook/addon-docs": "6.4.22",
|
|
97
|
+
"@storybook/addon-essentials": "6.4.22",
|
|
98
98
|
"@storybook/addon-knobs": "6.4.0",
|
|
99
|
-
"@storybook/addon-storyshots": "6.4.
|
|
100
|
-
"@storybook/addon-storyshots-puppeteer": "6.4.
|
|
101
|
-
"@storybook/addon-viewport": "6.4.
|
|
102
|
-
"@storybook/theming": "6.4.
|
|
103
|
-
"@storybook/vue": "6.4.
|
|
99
|
+
"@storybook/addon-storyshots": "6.4.22",
|
|
100
|
+
"@storybook/addon-storyshots-puppeteer": "6.4.22",
|
|
101
|
+
"@storybook/addon-viewport": "6.4.22",
|
|
102
|
+
"@storybook/theming": "6.4.22",
|
|
103
|
+
"@storybook/vue": "6.4.22",
|
|
104
104
|
"@vue/test-utils": "1.3.0",
|
|
105
105
|
"autoprefixer": "^9.7.6",
|
|
106
106
|
"babel-jest": "^26.6.3",
|
|
@@ -173,14 +173,6 @@ export default {
|
|
|
173
173
|
:class="{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !title }"
|
|
174
174
|
/>
|
|
175
175
|
|
|
176
|
-
<close-button
|
|
177
|
-
v-if="dismissible"
|
|
178
|
-
ref="dismiss"
|
|
179
|
-
class="gl-dismiss-btn"
|
|
180
|
-
:label="dismissLabel"
|
|
181
|
-
@click="onDismiss"
|
|
182
|
-
/>
|
|
183
|
-
|
|
184
176
|
<div class="gl-alert-content" role="alert">
|
|
185
177
|
<h4 v-if="title" class="gl-alert-title">{{ title }}</h4>
|
|
186
178
|
|
|
@@ -204,5 +196,13 @@ export default {
|
|
|
204
196
|
</slot>
|
|
205
197
|
</div>
|
|
206
198
|
</div>
|
|
199
|
+
|
|
200
|
+
<close-button
|
|
201
|
+
v-if="dismissible"
|
|
202
|
+
ref="dismiss"
|
|
203
|
+
class="gl-dismiss-btn"
|
|
204
|
+
:label="dismissLabel"
|
|
205
|
+
@click="onDismiss"
|
|
206
|
+
/>
|
|
207
207
|
</div>
|
|
208
208
|
</template>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`Filtered search term renders input with value in active mode 1`] = `
|
|
4
|
-
<div class="gl-h-auto gl-filtered-search-term">
|
|
5
|
-
<div active="true" value="test-value" class="gl-filtered-search-term-token">test-value</div>
|
|
4
|
+
<div data-testid="filtered-search-term" class="gl-h-auto gl-filtered-search-term">
|
|
5
|
+
<div active="true" cursor-position="end" value="test-value" class="gl-filtered-search-term-token">test-value</div>
|
|
6
6
|
</div>
|
|
7
7
|
`;
|
|
8
8
|
|
|
9
9
|
exports[`Filtered search term renders value in inactive mode 1`] = `
|
|
10
|
-
<div class="gl-h-auto gl-filtered-search-term">
|
|
11
|
-
<div value="test-value" class="gl-filtered-search-term-token">test-value</div>
|
|
10
|
+
<div data-testid="filtered-search-term" class="gl-h-auto gl-filtered-search-term">
|
|
11
|
+
<div cursor-position="end" value="test-value" class="gl-filtered-search-term-token">test-value</div>
|
|
12
12
|
</div>
|
|
13
13
|
`;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
GlIcon,
|
|
10
10
|
GlToken,
|
|
11
11
|
GlAvatar,
|
|
12
|
+
GlDropdownDivider,
|
|
12
13
|
} from '../../../index';
|
|
13
14
|
import { setStoryTimeout } from '../../../utils/test_utils';
|
|
14
15
|
import { makeContainer } from '../../../utils/story_decorators/container';
|
|
@@ -178,7 +179,13 @@ const MilestoneToken = {
|
|
|
178
179
|
|
|
179
180
|
const LabelToken = {
|
|
180
181
|
name: 'LabelToken',
|
|
181
|
-
components: {
|
|
182
|
+
components: {
|
|
183
|
+
GlFilteredSearchToken,
|
|
184
|
+
GlFilteredSearchSuggestion,
|
|
185
|
+
GlLoadingIcon,
|
|
186
|
+
GlToken,
|
|
187
|
+
GlDropdownDivider,
|
|
188
|
+
},
|
|
182
189
|
props: ['value', 'active'],
|
|
183
190
|
inheritAttrs: false,
|
|
184
191
|
data() {
|
|
@@ -119,6 +119,7 @@ export default {
|
|
|
119
119
|
tokens: initialState(),
|
|
120
120
|
activeTokenIdx: null,
|
|
121
121
|
suggestionsStyle: {},
|
|
122
|
+
intendedCursorPosition: 'end',
|
|
122
123
|
};
|
|
123
124
|
},
|
|
124
125
|
computed: {
|
|
@@ -210,6 +211,20 @@ export default {
|
|
|
210
211
|
this.activeTokenIdx = idx;
|
|
211
212
|
},
|
|
212
213
|
|
|
214
|
+
activatePreviousToken() {
|
|
215
|
+
if (this.activeTokenIdx > 0) {
|
|
216
|
+
this.activeTokenIdx -= 1;
|
|
217
|
+
this.intendedCursorPosition = 'end';
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
activateNextToken() {
|
|
222
|
+
if (this.activeTokenIdx < this.value.length) {
|
|
223
|
+
this.activeTokenIdx += 1;
|
|
224
|
+
this.intendedCursorPosition = 'start';
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
213
228
|
alignSuggestions(ref) {
|
|
214
229
|
const offsetRef = ref.getBoundingClientRect().left;
|
|
215
230
|
const offsetMenu = this.$el.getBoundingClientRect().left;
|
|
@@ -218,6 +233,7 @@ export default {
|
|
|
218
233
|
},
|
|
219
234
|
|
|
220
235
|
deactivate(token) {
|
|
236
|
+
this.intendedCursorPosition = 'end';
|
|
221
237
|
const tokenIdx = this.tokens.indexOf(token);
|
|
222
238
|
if (tokenIdx === -1 || this.activeTokenIdx !== tokenIdx) {
|
|
223
239
|
return;
|
|
@@ -341,6 +357,7 @@ export default {
|
|
|
341
357
|
v-model="token.value"
|
|
342
358
|
:config="getTokenEntry(token.type)"
|
|
343
359
|
:active="activeTokenIdx === idx"
|
|
360
|
+
:cursor-position="intendedCursorPosition"
|
|
344
361
|
:available-tokens="currentAvailableTokens"
|
|
345
362
|
:current-value="tokens"
|
|
346
363
|
:index="idx"
|
|
@@ -359,6 +376,8 @@ export default {
|
|
|
359
376
|
@complete="completeToken"
|
|
360
377
|
@submit="submit"
|
|
361
378
|
@split="createTokens(idx, $event)"
|
|
379
|
+
@previous="activatePreviousToken"
|
|
380
|
+
@next="activateNextToken"
|
|
362
381
|
/>
|
|
363
382
|
</template>
|
|
364
383
|
</div>
|
|
@@ -63,6 +63,11 @@ export default {
|
|
|
63
63
|
required: false,
|
|
64
64
|
default: () => [],
|
|
65
65
|
},
|
|
66
|
+
cursorPosition: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: true,
|
|
69
|
+
validator: (value) => ['start', 'end'].includes(value),
|
|
70
|
+
},
|
|
66
71
|
},
|
|
67
72
|
computed: {
|
|
68
73
|
suggestedTokens() {
|
|
@@ -101,7 +106,7 @@ export default {
|
|
|
101
106
|
</script>
|
|
102
107
|
|
|
103
108
|
<template>
|
|
104
|
-
<div class="gl-h-auto gl-filtered-search-term">
|
|
109
|
+
<div class="gl-h-auto gl-filtered-search-term" data-testid="filtered-search-term">
|
|
105
110
|
<!--
|
|
106
111
|
Emitted when this term token is clicked.
|
|
107
112
|
@event activate
|
|
@@ -125,9 +130,11 @@ export default {
|
|
|
125
130
|
@property {array} newTokens Token configurations
|
|
126
131
|
-->
|
|
127
132
|
<gl-filtered-search-token-segment
|
|
133
|
+
ref="segment"
|
|
128
134
|
v-model="internalValue"
|
|
129
135
|
class="gl-filtered-search-term-token"
|
|
130
136
|
:active="active"
|
|
137
|
+
:cursor-position="cursorPosition"
|
|
131
138
|
:class="{ 'gl-w-full': placeholder }"
|
|
132
139
|
:search-input-attributes="searchInputAttributes"
|
|
133
140
|
:is-last-token="isLastToken"
|
|
@@ -138,6 +145,8 @@ export default {
|
|
|
138
145
|
@backspace="onBackspace"
|
|
139
146
|
@submit="$emit('submit')"
|
|
140
147
|
@split="$emit('split', $event)"
|
|
148
|
+
@previous="$emit('previous')"
|
|
149
|
+
@next="$emit('next')"
|
|
141
150
|
>
|
|
142
151
|
<template #suggestions>
|
|
143
152
|
<gl-filtered-search-suggestion
|
|
@@ -156,6 +165,7 @@ export default {
|
|
|
156
165
|
class="gl-filtered-search-term-input"
|
|
157
166
|
:placeholder="placeholder"
|
|
158
167
|
:aria-label="placeholder"
|
|
168
|
+
data-testid="filtered-search-term-input"
|
|
159
169
|
/>
|
|
160
170
|
<template v-else>{{ value.data }}</template>
|
|
161
171
|
</template>
|
|
@@ -65,11 +65,17 @@ export default {
|
|
|
65
65
|
required: false,
|
|
66
66
|
default: false,
|
|
67
67
|
},
|
|
68
|
+
cursorPosition: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: true,
|
|
71
|
+
validator: (value) => ['start', 'end'].includes(value),
|
|
72
|
+
},
|
|
68
73
|
},
|
|
69
74
|
data() {
|
|
70
75
|
return {
|
|
71
76
|
activeSegment: null,
|
|
72
77
|
tokenValue: cloneDeep(this.value),
|
|
78
|
+
intendedCursorPosition: this.cursorPosition,
|
|
73
79
|
};
|
|
74
80
|
},
|
|
75
81
|
|
|
@@ -127,6 +133,7 @@ export default {
|
|
|
127
133
|
immediate: true,
|
|
128
134
|
handler(newValue) {
|
|
129
135
|
if (newValue) {
|
|
136
|
+
this.intendedCursorPosition = this.cursorPosition;
|
|
130
137
|
if (!this.activeSegment) {
|
|
131
138
|
this.activateSegment(this.tokenValue.data !== '' ? SEGMENT_DATA : SEGMENT_OPERATOR);
|
|
132
139
|
}
|
|
@@ -239,6 +246,26 @@ export default {
|
|
|
239
246
|
this.activateSegment(this.$options.segments.SEGMENT_DATA);
|
|
240
247
|
},
|
|
241
248
|
|
|
249
|
+
activatePreviousOperatorSegment() {
|
|
250
|
+
this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
|
|
251
|
+
this.intendedCursorPosition = 'end';
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
activatePreviousTitleSegment() {
|
|
255
|
+
this.activateSegment(this.$options.segments.SEGMENT_TITLE);
|
|
256
|
+
this.intendedCursorPosition = 'end';
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
activateNextDataSegment() {
|
|
260
|
+
this.activateDataSegment();
|
|
261
|
+
this.intendedCursorPosition = 'start';
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
activateNextOperatorSegment() {
|
|
265
|
+
this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
|
|
266
|
+
this.intendedCursorPosition = 'start';
|
|
267
|
+
},
|
|
268
|
+
|
|
242
269
|
handleComplete() {
|
|
243
270
|
if (this.config.multiSelect) {
|
|
244
271
|
this.$emit('input', { ...this.tokenValue, data: this.multiSelectValues.join(COMMA) });
|
|
@@ -263,7 +290,11 @@ export default {
|
|
|
263
290
|
</script>
|
|
264
291
|
|
|
265
292
|
<template>
|
|
266
|
-
<div
|
|
293
|
+
<div
|
|
294
|
+
class="gl-filtered-search-token"
|
|
295
|
+
:class="{ 'gl-filtered-search-token-active': active }"
|
|
296
|
+
data-testid="filtered-search-token"
|
|
297
|
+
>
|
|
267
298
|
<!--
|
|
268
299
|
Emitted when the token is submitted.
|
|
269
300
|
@event submit
|
|
@@ -272,12 +303,15 @@ export default {
|
|
|
272
303
|
key="title-segment"
|
|
273
304
|
:value="config.title"
|
|
274
305
|
:active="isSegmentActive($options.segments.SEGMENT_TITLE)"
|
|
306
|
+
:cursor-position="intendedCursorPosition"
|
|
275
307
|
:options="availableTokensWithSelf"
|
|
276
308
|
@activate="activateSegment($options.segments.SEGMENT_TITLE)"
|
|
277
309
|
@deactivate="$emit('deactivate')"
|
|
278
310
|
@complete="replaceToken"
|
|
279
311
|
@backspace="$emit('destroy')"
|
|
280
312
|
@submit="$emit('submit')"
|
|
313
|
+
@previous="$emit('previous')"
|
|
314
|
+
@next="activateNextOperatorSegment"
|
|
281
315
|
>
|
|
282
316
|
<template #view="{ inputValue }">
|
|
283
317
|
<gl-token
|
|
@@ -292,6 +326,7 @@ export default {
|
|
|
292
326
|
key="operator-segment"
|
|
293
327
|
v-model="tokenValue.operator"
|
|
294
328
|
:active="isSegmentActive($options.segments.SEGMENT_OPERATOR)"
|
|
329
|
+
:cursor-position="intendedCursorPosition"
|
|
295
330
|
:options="operators"
|
|
296
331
|
:custom-input-keydown-handler="handleOperatorKeydown"
|
|
297
332
|
view-only
|
|
@@ -299,6 +334,8 @@ export default {
|
|
|
299
334
|
@backspace="replaceWithTermIfEmpty"
|
|
300
335
|
@complete="activateSegment($options.segments.SEGMENT_DATA)"
|
|
301
336
|
@deactivate="$emit('deactivate')"
|
|
337
|
+
@previous="activatePreviousTitleSegment"
|
|
338
|
+
@next="activateNextDataSegment"
|
|
302
339
|
>
|
|
303
340
|
<template #view>
|
|
304
341
|
<gl-token
|
|
@@ -333,6 +370,7 @@ export default {
|
|
|
333
370
|
key="data-segment"
|
|
334
371
|
v-model="tokenValue.data"
|
|
335
372
|
:active="isSegmentActive($options.segments.SEGMENT_DATA)"
|
|
373
|
+
:cursor-position="intendedCursorPosition"
|
|
336
374
|
:multi-select="config.multiSelect"
|
|
337
375
|
:options="config.options"
|
|
338
376
|
option-text-field="title"
|
|
@@ -343,6 +381,8 @@ export default {
|
|
|
343
381
|
@submit="$emit('submit')"
|
|
344
382
|
@deactivate="$emit('deactivate')"
|
|
345
383
|
@split="$emit('split', $event)"
|
|
384
|
+
@previous="activatePreviousOperatorSegment"
|
|
385
|
+
@next="$emit('next')"
|
|
346
386
|
>
|
|
347
387
|
<template #suggestions>
|
|
348
388
|
<!-- @slot The suggestions (implemented with GlFilteredSearchSuggestion). -->
|
|
@@ -35,7 +35,7 @@ describe('Filtered search token segment', () => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
wrapper = shallowMount(GlFilteredSearchTokenSegment, {
|
|
38
|
-
propsData: props,
|
|
38
|
+
propsData: { ...props, cursorPosition: 'end' },
|
|
39
39
|
provide: {
|
|
40
40
|
portalName: 'fakePortal',
|
|
41
41
|
alignSuggestions: alignSuggestionsMock,
|
|
@@ -64,7 +64,7 @@ describe('Filtered search token segment', () => {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
wrapper = shallowMount(fakeParent, {
|
|
67
|
-
propsData: otherProps,
|
|
67
|
+
propsData: { ...otherProps, cursorPosition: 'end' },
|
|
68
68
|
stubs: { GlFilteredSearchTokenSegment },
|
|
69
69
|
});
|
|
70
70
|
};
|
|
@@ -77,6 +77,11 @@ export default {
|
|
|
77
77
|
required: false,
|
|
78
78
|
default: () => [],
|
|
79
79
|
},
|
|
80
|
+
cursorPosition: {
|
|
81
|
+
type: String,
|
|
82
|
+
required: true,
|
|
83
|
+
validator: (value) => ['start', 'end'].includes(value),
|
|
84
|
+
},
|
|
80
85
|
},
|
|
81
86
|
|
|
82
87
|
data() {
|
|
@@ -198,6 +203,9 @@ export default {
|
|
|
198
203
|
input.focus();
|
|
199
204
|
input.scrollIntoView({ block: 'nearest', inline: 'end' });
|
|
200
205
|
this.alignSuggestions(input);
|
|
206
|
+
if (this.cursorPosition === 'start') {
|
|
207
|
+
input?.setSelectionRange(0, 0);
|
|
208
|
+
}
|
|
201
209
|
}
|
|
202
210
|
});
|
|
203
211
|
},
|
|
@@ -230,20 +238,31 @@ export default {
|
|
|
230
238
|
|
|
231
239
|
handleInputKeydown(e) {
|
|
232
240
|
const { key } = e;
|
|
233
|
-
const { suggestions } = this.$refs;
|
|
241
|
+
const { suggestions, input } = this.$refs;
|
|
234
242
|
const suggestedValue = suggestions?.getValue();
|
|
235
|
-
if (key === 'Backspace') {
|
|
236
|
-
if (this.inputValue === '') {
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
/**
|
|
239
|
-
* Emitted when Backspace is pressed and the value is empty
|
|
240
|
-
*/
|
|
241
|
-
this.$emit('backspace');
|
|
242
|
-
}
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
243
|
|
|
246
244
|
const handlers = {
|
|
245
|
+
ArrowLeft: () => {
|
|
246
|
+
if (input.selectionStart === 0) {
|
|
247
|
+
e.preventDefault();
|
|
248
|
+
this.$emit('previous');
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
ArrowRight: () => {
|
|
252
|
+
if (input.selectionEnd === this.inputValue.length) {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
this.$emit('next');
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
Backspace: () => {
|
|
258
|
+
if (this.inputValue === '') {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
/**
|
|
261
|
+
* Emitted when Backspace is pressed and the value is empty
|
|
262
|
+
*/
|
|
263
|
+
this.$emit('backspace');
|
|
264
|
+
}
|
|
265
|
+
},
|
|
247
266
|
Enter: () => {
|
|
248
267
|
e.preventDefault();
|
|
249
268
|
if (suggestedValue != null) {
|
|
@@ -311,7 +330,9 @@ export default {
|
|
|
311
330
|
<div
|
|
312
331
|
v-bind="containerAttributes"
|
|
313
332
|
class="gl-filtered-search-token-segment"
|
|
314
|
-
:class="{
|
|
333
|
+
:class="{
|
|
334
|
+
'gl-filtered-search-token-segment-active': active,
|
|
335
|
+
}"
|
|
315
336
|
data-testid="filtered-search-token-segment"
|
|
316
337
|
@mousedown.left="emitIfInactive"
|
|
317
338
|
>
|
|
@@ -43,9 +43,11 @@
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.form-check-input:disabled,
|
|
46
|
-
.form-check-input:disabled ~ .form-check-label
|
|
46
|
+
.form-check-input:disabled ~ .form-check-label,
|
|
47
|
+
.custom-control-input:disabled,
|
|
48
|
+
.custom-control-input:disabled ~ .custom-control-label {
|
|
47
49
|
@include gl-cursor-not-allowed;
|
|
48
|
-
@include gl-text-gray-
|
|
50
|
+
@include gl-text-gray-400;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
&.custom-control {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
|
-
import { textareaCountOptions } from '../../../../utils/constants';
|
|
3
2
|
import GlFormTextarea from './form_textarea.vue';
|
|
4
3
|
|
|
5
4
|
const modelEvent = GlFormTextarea.model.event;
|
|
@@ -7,13 +6,11 @@ const newValue = 'foo';
|
|
|
7
6
|
|
|
8
7
|
describe('GlFormTextArea', () => {
|
|
9
8
|
let wrapper;
|
|
10
|
-
let textarea;
|
|
11
9
|
|
|
12
10
|
const createComponent = (propsData = {}) => {
|
|
13
11
|
wrapper = mount(GlFormTextarea, {
|
|
14
12
|
propsData,
|
|
15
13
|
});
|
|
16
|
-
textarea = wrapper.find('textarea');
|
|
17
14
|
};
|
|
18
15
|
|
|
19
16
|
describe('v-model', () => {
|
|
@@ -23,7 +20,7 @@ describe('GlFormTextArea', () => {
|
|
|
23
20
|
});
|
|
24
21
|
|
|
25
22
|
it(`sets the textarea's value`, () => {
|
|
26
|
-
expect(
|
|
23
|
+
expect(wrapper.element.value).toBe('initial');
|
|
27
24
|
});
|
|
28
25
|
|
|
29
26
|
describe('when the value prop changes', () => {
|
|
@@ -33,7 +30,7 @@ describe('GlFormTextArea', () => {
|
|
|
33
30
|
});
|
|
34
31
|
|
|
35
32
|
it(`updates the textarea's value`, () => {
|
|
36
|
-
expect(
|
|
33
|
+
expect(wrapper.element.value).toBe(newValue);
|
|
37
34
|
});
|
|
38
35
|
});
|
|
39
36
|
});
|
|
@@ -42,7 +39,7 @@ describe('GlFormTextArea', () => {
|
|
|
42
39
|
beforeEach(() => {
|
|
43
40
|
createComponent();
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
wrapper.setValue(newValue);
|
|
46
43
|
});
|
|
47
44
|
|
|
48
45
|
it('synchronously emits update event', () => {
|
|
@@ -62,7 +59,7 @@ describe('GlFormTextArea', () => {
|
|
|
62
59
|
|
|
63
60
|
createComponent({ debounce });
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
wrapper.setValue(newValue);
|
|
66
63
|
});
|
|
67
64
|
|
|
68
65
|
it('synchronously emits an update event', () => {
|
|
@@ -85,7 +82,7 @@ describe('GlFormTextArea', () => {
|
|
|
85
82
|
beforeEach(() => {
|
|
86
83
|
createComponent({ lazy: true });
|
|
87
84
|
|
|
88
|
-
|
|
85
|
+
wrapper.setValue(newValue);
|
|
89
86
|
});
|
|
90
87
|
|
|
91
88
|
it('synchronously emits an update event', () => {
|
|
@@ -95,7 +92,7 @@ describe('GlFormTextArea', () => {
|
|
|
95
92
|
it.each(['change', 'blur'])('updates model after %s event', (event) => {
|
|
96
93
|
expect(wrapper.emitted(modelEvent)).toBe(undefined);
|
|
97
94
|
|
|
98
|
-
|
|
95
|
+
wrapper.trigger(event);
|
|
99
96
|
|
|
100
97
|
expect(wrapper.emitted(modelEvent)).toEqual([[newValue]]);
|
|
101
98
|
});
|
|
@@ -105,7 +102,7 @@ describe('GlFormTextArea', () => {
|
|
|
105
102
|
it('should be false by default', () => {
|
|
106
103
|
createComponent({});
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
wrapper.trigger('keyup.enter', {
|
|
109
106
|
metaKey: true,
|
|
110
107
|
});
|
|
111
108
|
|
|
@@ -115,115 +112,11 @@ describe('GlFormTextArea', () => {
|
|
|
115
112
|
it('should emit submit when cmd+enter is pressed', async () => {
|
|
116
113
|
createComponent({ submitOnEnter: true });
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
wrapper.trigger('keyup.enter', {
|
|
119
116
|
metaKey: true,
|
|
120
117
|
});
|
|
121
118
|
|
|
122
119
|
expect(wrapper.emitted().submit).toEqual([[]]);
|
|
123
120
|
});
|
|
124
121
|
});
|
|
125
|
-
|
|
126
|
-
describe('count', () => {
|
|
127
|
-
it('should be 0 by default', () => {
|
|
128
|
-
createComponent({
|
|
129
|
-
characterCountText: '%{count} characters left',
|
|
130
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(wrapper.text()).not.toContain('characters left');
|
|
134
|
-
expect(wrapper.text()).not.toContain('characters over limit');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should display the remaining characters when a count is provided', () => {
|
|
138
|
-
createComponent({
|
|
139
|
-
count: 400,
|
|
140
|
-
characterCountText: '%{count} characters left',
|
|
141
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(wrapper.text()).toContain('400 characters left');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should display the difference between the limit and the length of the value', () => {
|
|
148
|
-
const value = 'hello';
|
|
149
|
-
|
|
150
|
-
createComponent({
|
|
151
|
-
value,
|
|
152
|
-
count: 400,
|
|
153
|
-
characterCountText: '%{count} characters left',
|
|
154
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const { length } = value;
|
|
158
|
-
|
|
159
|
-
expect(wrapper.text()).toContain(`${400 - length} characters left`);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('should display the over limit text once over the limit', () => {
|
|
163
|
-
const value = 'hello';
|
|
164
|
-
const count = 4;
|
|
165
|
-
|
|
166
|
-
createComponent({
|
|
167
|
-
value,
|
|
168
|
-
count,
|
|
169
|
-
characterCountText: '%{count} characters left',
|
|
170
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const diff = Math.abs(count - value.length);
|
|
174
|
-
|
|
175
|
-
expect(wrapper.text()).toContain(`${diff} characters over limit`);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('max', () => {
|
|
179
|
-
it('should display the text as grey when up to the limit', () => {
|
|
180
|
-
const value = 'hello';
|
|
181
|
-
const count = 5;
|
|
182
|
-
|
|
183
|
-
createComponent({
|
|
184
|
-
value,
|
|
185
|
-
count,
|
|
186
|
-
characterCountText: '%{count} characters left',
|
|
187
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const small = wrapper.find('small');
|
|
191
|
-
|
|
192
|
-
expect(small.classes()).toContain('gl-text-gray-500');
|
|
193
|
-
});
|
|
194
|
-
it('should display the text as danger when over the limit', () => {
|
|
195
|
-
const value = 'hello';
|
|
196
|
-
const count = 4;
|
|
197
|
-
|
|
198
|
-
createComponent({
|
|
199
|
-
value,
|
|
200
|
-
count,
|
|
201
|
-
characterCountText: '%{count} characters left',
|
|
202
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const small = wrapper.find('small');
|
|
206
|
-
|
|
207
|
-
expect(small.classes()).toContain('gl-text-red-500');
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
describe('recommended', () => {
|
|
211
|
-
it('should display the text as gray when over the limit', () => {
|
|
212
|
-
const value = 'hello';
|
|
213
|
-
const count = 4;
|
|
214
|
-
|
|
215
|
-
createComponent({
|
|
216
|
-
value,
|
|
217
|
-
count,
|
|
218
|
-
countType: textareaCountOptions.recommended,
|
|
219
|
-
characterCountText: '%{count} characters left',
|
|
220
|
-
characterCountOverLimitText: '%{count} characters over limit',
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const small = wrapper.find('small');
|
|
224
|
-
|
|
225
|
-
expect(small.classes()).toContain('gl-text-gray-500');
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
122
|
});
|