@gitlab/ui 64.1.1 → 64.2.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 +7 -0
- package/dist/components/base/filtered_search/filtered_search_token.js +6 -1
- package/package.json +2 -2
- package/src/components/base/filtered_search/filtered_search_token.spec.js +15 -0
- package/src/components/base/filtered_search/filtered_search_token.stories.js +48 -0
- package/src/components/base/filtered_search/filtered_search_token.vue +6 -0
- package/src/scss/functions.scss +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [64.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.1.1...v64.2.0) (2023-06-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearchToken:** Pass input attributes to data segment ([e8dcc5f](https://gitlab.com/gitlab-org/gitlab-ui/commit/e8dcc5f8fb8ff4b6fa78f1e46b899a18990d39c8))
|
|
7
|
+
|
|
1
8
|
## [64.1.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.1.0...v64.1.1) (2023-06-01)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -81,6 +81,11 @@ var script = {
|
|
|
81
81
|
type: Boolean,
|
|
82
82
|
required: false,
|
|
83
83
|
default: false
|
|
84
|
+
},
|
|
85
|
+
dataSegmentInputAttributes: {
|
|
86
|
+
type: Object,
|
|
87
|
+
required: false,
|
|
88
|
+
default: () => ({})
|
|
84
89
|
}
|
|
85
90
|
},
|
|
86
91
|
data() {
|
|
@@ -322,7 +327,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
322
327
|
var inputValue = ref.inputValue;
|
|
323
328
|
return [_c('gl-token',{staticClass:"gl-filtered-search-token-type",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_TITLE),attrs:{"view-only":""}},[_vm._v("\n "+_vm._s(inputValue)+"\n ")])]}}])}),_vm._v(" "),_c('gl-filtered-search-token-segment',{key:"operator-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_OPERATOR),"cursor-position":_vm.intendedCursorPosition,"options":_vm.operators,"option-text-field":"value","custom-input-keydown-handler":_vm.handleOperatorKeydown,"view-only":_vm.viewOnly},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"backspace":_vm.replaceWithTermIfEmpty,"complete":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_DATA)},"deactivate":function($event){return _vm.$emit('deactivate')},"previous":_vm.activatePreviousTitleSegment,"next":_vm.activateNextDataSegment},scopedSlots:_vm._u([{key:"view",fn:function(){return [_c('gl-token',{staticClass:"gl-filtered-search-token-operator",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_OPERATOR),attrs:{"variant":"search-value","view-only":""}},[_vm._v("\n "+_vm._s(_vm.operatorDescription)+"\n ")])]},proxy:true},{key:"option",fn:function(ref){
|
|
324
329
|
var option = ref.option;
|
|
325
|
-
return [_c('div',{staticClass:"gl-display-flex"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.description : option.value)+"\n "),(option.description)?_c('span',{staticClass:"gl-filtered-search-token-operator-description"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.value : option.description)+"\n ")]):_vm._e()])]}}]),model:{value:(_vm.tokenValue.operator),callback:function ($$v) {_vm.$set(_vm.tokenValue, "operator", $$v);},expression:"tokenValue.operator"}}),_vm._v(" "),(_vm.hasDataOrDataSegmentIsCurrentlyActive)?_c('gl-filtered-search-token-segment',{key:"data-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_DATA),"cursor-position":_vm.intendedCursorPosition,"multi-select":_vm.config.multiSelect,"options":_vm.config.options,"view-only":_vm.viewOnly},on:{"activate":_vm.activateDataSegment,"backspace":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"complete":_vm.handleComplete,"select":function($event){return _vm.$emit('select', $event)},"submit":function($event){return _vm.$emit('submit')},"deactivate":function($event){return _vm.$emit('deactivate')},"split":function($event){return _vm.$emit('split', $event)},"previous":_vm.activatePreviousOperatorSegment,"next":function($event){return _vm.$emit('next')}},scopedSlots:_vm._u([{key:"suggestions",fn:function(){return [_vm._t("suggestions")]},proxy:true},{key:"view",fn:function(ref){
|
|
330
|
+
return [_c('div',{staticClass:"gl-display-flex"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.description : option.value)+"\n "),(option.description)?_c('span',{staticClass:"gl-filtered-search-token-operator-description"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.value : option.description)+"\n ")]):_vm._e()])]}}]),model:{value:(_vm.tokenValue.operator),callback:function ($$v) {_vm.$set(_vm.tokenValue, "operator", $$v);},expression:"tokenValue.operator"}}),_vm._v(" "),(_vm.hasDataOrDataSegmentIsCurrentlyActive)?_c('gl-filtered-search-token-segment',{key:"data-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_DATA),"cursor-position":_vm.intendedCursorPosition,"multi-select":_vm.config.multiSelect,"options":_vm.config.options,"view-only":_vm.viewOnly,"search-input-attributes":_vm.dataSegmentInputAttributes},on:{"activate":_vm.activateDataSegment,"backspace":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"complete":_vm.handleComplete,"select":function($event){return _vm.$emit('select', $event)},"submit":function($event){return _vm.$emit('submit')},"deactivate":function($event){return _vm.$emit('deactivate')},"split":function($event){return _vm.$emit('split', $event)},"previous":_vm.activatePreviousOperatorSegment,"next":function($event){return _vm.$emit('next')}},scopedSlots:_vm._u([{key:"suggestions",fn:function(){return [_vm._t("suggestions")]},proxy:true},{key:"view",fn:function(ref){
|
|
326
331
|
var inputValue = ref.inputValue;
|
|
327
332
|
return [_vm._t("view-token",function(){return [_c('gl-token',_vm._g({staticClass:"gl-filtered-search-token-data",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_DATA),attrs:{"variant":"search-value","view-only":_vm.viewOnly}},_vm.eventListeners),[_c('span',{staticClass:"gl-filtered-search-token-data-content"},[_vm._t("view",function(){return [_vm._v(_vm._s(inputValue))]},null,{ inputValue: inputValue })],2)])]},null,{
|
|
328
333
|
inputValue: inputValue,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "64.
|
|
3
|
+
"version": "64.2.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arkweid/lefthook": "0.7.7",
|
|
87
87
|
"@babel/core": "^7.22.1",
|
|
88
|
-
"@babel/preset-env": "^7.22.
|
|
88
|
+
"@babel/preset-env": "^7.22.4",
|
|
89
89
|
"@babel/preset-react": "^7.22.3",
|
|
90
90
|
"@gitlab/eslint-plugin": "19.0.0",
|
|
91
91
|
"@gitlab/fonts": "^1.2.0",
|
|
@@ -210,6 +210,21 @@ describe('Filtered search token', () => {
|
|
|
210
210
|
expect(wrapper.emitted().replace[0][0].value).toStrictEqual({ data: '' });
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
+
it('sets input attributes on data segment when provided', () => {
|
|
214
|
+
const dataSegmentInputAttributes = {
|
|
215
|
+
placeholder: 'YYYY-MM-DD',
|
|
216
|
+
id: 'this-id',
|
|
217
|
+
};
|
|
218
|
+
createComponent({
|
|
219
|
+
active: true,
|
|
220
|
+
dataSegmentInputAttributes,
|
|
221
|
+
value: { operator: '=', data: 'something' },
|
|
222
|
+
});
|
|
223
|
+
expect(findDataSegment().props().searchInputAttributes).toStrictEqual(
|
|
224
|
+
dataSegmentInputAttributes
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
213
228
|
describe('integration tests', () => {
|
|
214
229
|
beforeAll(() => {
|
|
215
230
|
if (!HTMLElement.prototype.scrollIntoView) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PortalVue from 'portal-vue';
|
|
2
2
|
import Vue from 'vue';
|
|
3
3
|
import GlIcon from '../icon/icon.vue';
|
|
4
|
+
import GlDatepicker from '../datepicker/datepicker.vue';
|
|
4
5
|
import { provide } from './common_story_options';
|
|
5
6
|
import GlFilteredSearchSuggestion from './filtered_search_suggestion.vue';
|
|
6
7
|
import readme from './filtered_search_token.md';
|
|
@@ -153,6 +154,53 @@ export const WithStaticOptions = (args, { argTypes }) => ({
|
|
|
153
154
|
});
|
|
154
155
|
WithStaticOptions.args = generateProps();
|
|
155
156
|
|
|
157
|
+
// eslint-disable-next-line no-unused-vars
|
|
158
|
+
export const WithDataSegmentInputAttributes = (args, { argTypes }) => ({
|
|
159
|
+
components: {
|
|
160
|
+
GlFilteredSearchToken,
|
|
161
|
+
GlDatepicker,
|
|
162
|
+
},
|
|
163
|
+
provide,
|
|
164
|
+
props: ['active'],
|
|
165
|
+
data() {
|
|
166
|
+
return {
|
|
167
|
+
value: { operator: '<', data: null },
|
|
168
|
+
config: {
|
|
169
|
+
title: 'Date',
|
|
170
|
+
operators: [
|
|
171
|
+
{ value: '<', description: 'before' },
|
|
172
|
+
{ value: '>', description: 'after' },
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
dataSegmentInputAttributes: {
|
|
176
|
+
placeholder: 'YYYY-MM-DD',
|
|
177
|
+
id: 'this-id',
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
mounted() {
|
|
182
|
+
this.$nextTick(() => {
|
|
183
|
+
document.activeElement.blur();
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
template: `
|
|
187
|
+
<div>
|
|
188
|
+
<div> {{ value }} </div>
|
|
189
|
+
<div class="gl-border-1 gl-border-solid gl-border-gray-200">
|
|
190
|
+
<gl-filtered-search-token
|
|
191
|
+
v-model="value"
|
|
192
|
+
class="gl-h-full"
|
|
193
|
+
:config="config"
|
|
194
|
+
:active="active"
|
|
195
|
+
:data-segment-input-attributes="dataSegmentInputAttributes"
|
|
196
|
+
/>
|
|
197
|
+
<gl-datepicker target='#this-id' />
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
`,
|
|
201
|
+
});
|
|
202
|
+
WithDataSegmentInputAttributes.args = generateProps();
|
|
203
|
+
|
|
156
204
|
export default {
|
|
157
205
|
title: 'base/filtered-search/token',
|
|
158
206
|
component: GlFilteredSearchToken,
|
|
@@ -78,6 +78,11 @@ export default {
|
|
|
78
78
|
required: false,
|
|
79
79
|
default: false,
|
|
80
80
|
},
|
|
81
|
+
dataSegmentInputAttributes: {
|
|
82
|
+
type: Object,
|
|
83
|
+
required: false,
|
|
84
|
+
default: () => ({}),
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
data() {
|
|
83
88
|
return {
|
|
@@ -405,6 +410,7 @@ export default {
|
|
|
405
410
|
:multi-select="config.multiSelect"
|
|
406
411
|
:options="config.options"
|
|
407
412
|
:view-only="viewOnly"
|
|
413
|
+
:search-input-attributes="dataSegmentInputAttributes"
|
|
408
414
|
@activate="activateDataSegment"
|
|
409
415
|
@backspace="activateSegment($options.segments.SEGMENT_OPERATOR)"
|
|
410
416
|
@complete="handleComplete"
|
package/src/scss/functions.scss
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
@return $value;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
$converted: $value / $font-size-base;
|
|
24
|
+
$converted: calc($value / $font-size-base);
|
|
25
25
|
|
|
26
26
|
@return strip-unit($converted) * 1rem;
|
|
27
27
|
}
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
$min-width: px-to-rem($min-width);
|
|
55
55
|
$max-width: px-to-rem($max-width);
|
|
56
56
|
|
|
57
|
-
$slope: ($max - $min) / ($max-width - $min-width);
|
|
57
|
+
$slope: calc(($max - $min) / ($max-width - $min-width));
|
|
58
58
|
$intersection: (-$min-width * $slope) + $min;
|
|
59
59
|
|
|
60
60
|
// Use calc() inside of clamp() function to work around SassC
|