@gitlab/ui 54.4.1 → 55.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
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [55.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v54.4.1...v55.0.0) (2023-02-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlSearchBoxByType:** implemented component wide focusin focusout ([c202cde](https://gitlab.com/gitlab-org/gitlab-ui/commit/c202cde2374542c0b2b6608acc84f52390783e76))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **GlSearchBoxByType:** removes `clearButtonFocus`, `clearButtonBlur`, and
|
|
12
|
+
`clearButtonRelease` events.
|
|
13
|
+
|
|
1
14
|
## [54.4.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v54.4.0...v54.4.1) (2023-02-06)
|
|
2
15
|
|
|
3
16
|
|
|
@@ -78,9 +78,9 @@ var script = {
|
|
|
78
78
|
inputListeners() {
|
|
79
79
|
return {
|
|
80
80
|
...this.$listeners,
|
|
81
|
-
input:
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
input: this.onInput,
|
|
82
|
+
focusin: this.onFocusin,
|
|
83
|
+
focusout: this.onFocusout
|
|
84
84
|
};
|
|
85
85
|
},
|
|
86
86
|
showClearButton() {
|
|
@@ -88,21 +88,37 @@ var script = {
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
methods: {
|
|
91
|
+
isInputOrClearButton(element) {
|
|
92
|
+
var _this$$refs$input, _this$$refs$clearButt;
|
|
93
|
+
return element === ((_this$$refs$input = this.$refs.input) === null || _this$$refs$input === void 0 ? void 0 : _this$$refs$input.$el) || element === ((_this$$refs$clearButt = this.$refs.clearButton) === null || _this$$refs$clearButt === void 0 ? void 0 : _this$$refs$clearButt.$el);
|
|
94
|
+
},
|
|
91
95
|
clearInput() {
|
|
92
|
-
this
|
|
96
|
+
this.onInput('');
|
|
93
97
|
this.focusInput();
|
|
94
98
|
},
|
|
95
99
|
focusInput() {
|
|
96
100
|
this.$refs.input.$el.focus();
|
|
97
101
|
},
|
|
98
|
-
|
|
99
|
-
this.$emit('
|
|
102
|
+
onInput(value) {
|
|
103
|
+
this.$emit('input', value);
|
|
100
104
|
},
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
onFocusout(event) {
|
|
106
|
+
const {
|
|
107
|
+
relatedTarget
|
|
108
|
+
} = event;
|
|
109
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.$emit('focusout', event);
|
|
103
113
|
},
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
onFocusin(event) {
|
|
115
|
+
const {
|
|
116
|
+
relatedTarget
|
|
117
|
+
} = event;
|
|
118
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.$emit('focusin', event);
|
|
106
122
|
}
|
|
107
123
|
}
|
|
108
124
|
};
|
|
@@ -114,7 +130,7 @@ const __vue_script__ = script;
|
|
|
114
130
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-search-box-by-type"},[_c('gl-icon',{staticClass:"gl-search-box-by-type-search-icon",attrs:{"name":"search"}}),_vm._v(" "),_c('gl-form-input',_vm._g(_vm._b({ref:"input",class:{
|
|
115
131
|
'gl-search-box-by-type-input': !_vm.borderless,
|
|
116
132
|
'gl-search-box-by-type-input-borderless': _vm.borderless,
|
|
117
|
-
},attrs:{"value":_vm.value,"disabled":_vm.disabled}},'gl-form-input',_vm.inputAttributes,false),_vm.inputListeners)),_vm._v(" "),(_vm.isLoading || _vm.showClearButton)?_c('div',{staticClass:"gl-search-box-by-type-right-icons"},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"gl-search-box-by-type-loading-icon"}):_vm._e(),_vm._v(" "),(_vm.showClearButton)?_c('gl-clear-icon-button',{staticClass:"gl-search-box-by-type-clear gl-clear-icon-button",attrs:{"title":_vm.clearButtonTitle,"tooltip-container":_vm.tooltipContainer},on:{"click":function($event){$event.stopPropagation();return _vm.clearInput.apply(null, arguments)},"
|
|
133
|
+
},attrs:{"value":_vm.value,"disabled":_vm.disabled}},'gl-form-input',_vm.inputAttributes,false),_vm.inputListeners)),_vm._v(" "),(_vm.isLoading || _vm.showClearButton)?_c('div',{staticClass:"gl-search-box-by-type-right-icons"},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"gl-search-box-by-type-loading-icon"}):_vm._e(),_vm._v(" "),(_vm.showClearButton)?_c('gl-clear-icon-button',{ref:"clearButton",staticClass:"gl-search-box-by-type-clear gl-clear-icon-button",attrs:{"title":_vm.clearButtonTitle,"tooltip-container":_vm.tooltipContainer},on:{"click":function($event){$event.stopPropagation();return _vm.clearInput.apply(null, arguments)},"focusin":_vm.onFocusin,"focusout":_vm.onFocusout}}):_vm._e()],1):_vm._e()],1)};
|
|
118
134
|
var __vue_staticRenderFns__ = [];
|
|
119
135
|
|
|
120
136
|
/* style */
|
package/package.json
CHANGED
|
@@ -57,22 +57,30 @@ describe('search box by type component', () => {
|
|
|
57
57
|
expect(wrapper.emitted('input')).toEqual([['']]);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('emits
|
|
61
|
-
|
|
60
|
+
it('emits `focusin` event when focus inside the component', () => {
|
|
61
|
+
findInput().vm.$emit('focusin', { preventDefault: jest.fn() });
|
|
62
62
|
|
|
63
|
-
expect(wrapper.emitted('
|
|
63
|
+
expect(wrapper.emitted('focus')).toBe(undefined);
|
|
64
|
+
expect(wrapper.emitted('focusin')).toHaveLength(1);
|
|
64
65
|
});
|
|
66
|
+
it('emits `focusout` event when focus moves outside the component', () => {
|
|
67
|
+
findInput().vm.$emit('focusout', { preventDefault: jest.fn() });
|
|
68
|
+
expect(wrapper.emitted('blur')).toBe(undefined);
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
findClearIcon().vm.$emit('blur', { stopPropagation: jest.fn() });
|
|
68
|
-
|
|
69
|
-
expect(wrapper.emitted('clearButtonBlur')).toHaveLength(1);
|
|
70
|
+
expect(wrapper.emitted('focusout')).toHaveLength(1);
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
it('
|
|
73
|
-
|
|
73
|
+
it('does NOT emit `focusout` event when tabbing inside the component back and forth', () => {
|
|
74
|
+
findInput().vm.$emit('focusout', {
|
|
75
|
+
preventDefault: jest.fn(),
|
|
76
|
+
relatedTarget: wrapper.vm.$refs.input.$el,
|
|
77
|
+
});
|
|
78
|
+
findClearIcon().vm.$emit('focusout', {
|
|
79
|
+
preventDefault: jest.fn(),
|
|
80
|
+
relatedTarget: wrapper.vm.$refs.clearButton.$el,
|
|
81
|
+
});
|
|
74
82
|
|
|
75
|
-
expect(wrapper.emitted('
|
|
83
|
+
expect(wrapper.emitted('focusout')).toBe(undefined);
|
|
76
84
|
});
|
|
77
85
|
});
|
|
78
86
|
|
|
@@ -81,9 +81,9 @@ export default {
|
|
|
81
81
|
inputListeners() {
|
|
82
82
|
return {
|
|
83
83
|
...this.$listeners,
|
|
84
|
-
input:
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
input: this.onInput,
|
|
85
|
+
focusin: this.onFocusin,
|
|
86
|
+
focusout: this.onFocusout,
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
89
|
showClearButton() {
|
|
@@ -91,21 +91,36 @@ export default {
|
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
methods: {
|
|
94
|
+
isInputOrClearButton(element) {
|
|
95
|
+
return element === this.$refs.input?.$el || element === this.$refs.clearButton?.$el;
|
|
96
|
+
},
|
|
94
97
|
clearInput() {
|
|
95
|
-
this
|
|
98
|
+
this.onInput('');
|
|
96
99
|
this.focusInput();
|
|
97
100
|
},
|
|
98
101
|
focusInput() {
|
|
99
102
|
this.$refs.input.$el.focus();
|
|
100
103
|
},
|
|
101
|
-
|
|
102
|
-
this.$emit('
|
|
104
|
+
onInput(value) {
|
|
105
|
+
this.$emit('input', value);
|
|
103
106
|
},
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
onFocusout(event) {
|
|
108
|
+
const { relatedTarget } = event;
|
|
109
|
+
|
|
110
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.$emit('focusout', event);
|
|
106
115
|
},
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
onFocusin(event) {
|
|
117
|
+
const { relatedTarget } = event;
|
|
118
|
+
|
|
119
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.$emit('focusin', event);
|
|
109
124
|
},
|
|
110
125
|
},
|
|
111
126
|
};
|
|
@@ -129,13 +144,13 @@ export default {
|
|
|
129
144
|
<gl-loading-icon v-if="isLoading" class="gl-search-box-by-type-loading-icon" />
|
|
130
145
|
<gl-clear-icon-button
|
|
131
146
|
v-if="showClearButton"
|
|
147
|
+
ref="clearButton"
|
|
132
148
|
:title="clearButtonTitle"
|
|
133
149
|
:tooltip-container="tooltipContainer"
|
|
134
150
|
class="gl-search-box-by-type-clear gl-clear-icon-button"
|
|
135
151
|
@click.stop="clearInput"
|
|
136
|
-
@
|
|
137
|
-
@
|
|
138
|
-
@release="onClearButtonRelease"
|
|
152
|
+
@focusin="onFocusin"
|
|
153
|
+
@focusout="onFocusout"
|
|
139
154
|
/>
|
|
140
155
|
</div>
|
|
141
156
|
</div>
|