@gitlab/ui 48.3.0 → 49.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 +19 -0
- package/dist/components/base/toggle/toggle.js +7 -3
- package/dist/directives/outside/outside.js +3 -1
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/listbox/listbox.stories.js +47 -2
- package/src/components/base/toggle/toggle.spec.js +5 -4
- package/src/components/base/toggle/toggle.vue +6 -3
- package/src/directives/outside/outside.js +1 -1
- package/src/directives/outside/outside.spec.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [49.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.3.1...v49.0.0) (2022-10-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlToggle:** Fix help text visibility ([1bd4137](https://gitlab.com/gitlab-org/gitlab-ui/commit/1bd4137fca78152966869b0b6781fe44c5f9a69e))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **GlToggle:** Hide help text when `labelPosition: left`
|
|
12
|
+
|
|
13
|
+
## [48.3.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.3.0...v48.3.1) (2022-10-24)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **OutsideDirective:** enable event capture ([c32381a](https://gitlab.com/gitlab-org/gitlab-ui/commit/c32381a3048895e747cc905df468319d8eff7a30))
|
|
19
|
+
|
|
1
20
|
# [48.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.2.0...v48.3.0) (2022-10-24)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -90,7 +90,7 @@ var script = {
|
|
|
90
90
|
computed: {
|
|
91
91
|
shouldRenderHelp() {
|
|
92
92
|
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
93
|
-
return Boolean(this.$slots.help || this.help);
|
|
93
|
+
return Boolean(this.$slots.help || this.help) && this.isVerticalLayout;
|
|
94
94
|
},
|
|
95
95
|
|
|
96
96
|
icon() {
|
|
@@ -103,6 +103,10 @@ var script = {
|
|
|
103
103
|
|
|
104
104
|
isChecked() {
|
|
105
105
|
return this.value ? 'true' : 'false';
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
isVerticalLayout() {
|
|
109
|
+
return this.labelPosition === 'top' || this.labelPosition === 'hidden';
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
},
|
|
@@ -133,8 +137,8 @@ const __vue_script__ = script;
|
|
|
133
137
|
|
|
134
138
|
/* template */
|
|
135
139
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-toggle-wrapper gl-display-flex gl-mb-0",class:{
|
|
136
|
-
'gl-flex-direction-column': _vm.
|
|
137
|
-
'gl-toggle-label-inline': _vm.
|
|
140
|
+
'gl-flex-direction-column': _vm.isVerticalLayout,
|
|
141
|
+
'gl-toggle-label-inline': !_vm.isVerticalLayout,
|
|
138
142
|
'is-disabled': _vm.disabled,
|
|
139
143
|
},attrs:{"data-testid":"toggle-wrapper"}},[_c('span',{staticClass:"gl-toggle-label gl-flex-shrink-0",class:{ 'gl-sr-only': _vm.labelPosition === 'hidden' },attrs:{"id":_vm.labelId,"data-testid":"toggle-label"}},[_vm._t("label",function(){return [_vm._v(_vm._s(_vm.label))]})],2),_vm._v(" "),(_vm.name)?_c('input',{attrs:{"name":_vm.name,"type":"hidden"},domProps:{"value":_vm.value}}):_vm._e(),_vm._v(" "),_c('button',{staticClass:"gl-flex-shrink-0",class:{
|
|
140
144
|
'gl-toggle': true,
|
package/package.json
CHANGED
|
@@ -249,7 +249,6 @@ const makeGroupedExample = (changes) => {
|
|
|
249
249
|
openListbox(this);
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
|
-
template: template(''),
|
|
253
252
|
...changes,
|
|
254
253
|
});
|
|
255
254
|
|
|
@@ -259,7 +258,53 @@ const makeGroupedExample = (changes) => {
|
|
|
259
258
|
return story;
|
|
260
259
|
};
|
|
261
260
|
|
|
262
|
-
export const Groups = makeGroupedExample(
|
|
261
|
+
export const Groups = makeGroupedExample({
|
|
262
|
+
template: template('', {
|
|
263
|
+
bindingOverrides: {
|
|
264
|
+
':toggle-text': 'customToggleText',
|
|
265
|
+
':items': 'computedItems',
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
data() {
|
|
269
|
+
return {
|
|
270
|
+
selected: ['v1.0'],
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
computed: {
|
|
274
|
+
customToggleText() {
|
|
275
|
+
return this.selected.length ? `${this.selected.length} refs selected` : 'Select refs';
|
|
276
|
+
},
|
|
277
|
+
computedItems() {
|
|
278
|
+
const isSelected = (option) => this.selected.includes(option.value);
|
|
279
|
+
const notSelected = (option) => !isSelected(option);
|
|
280
|
+
|
|
281
|
+
const selectedBranches = mockGroups[0].options.filter(isSelected);
|
|
282
|
+
const availableBranches = mockGroups[0].options.filter(notSelected);
|
|
283
|
+
const selectedTags = mockGroups[1].options.filter(isSelected);
|
|
284
|
+
const availableTags = mockGroups[1].options.filter(notSelected);
|
|
285
|
+
|
|
286
|
+
return [
|
|
287
|
+
{
|
|
288
|
+
text: 'Selected branches',
|
|
289
|
+
options: selectedBranches,
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
text: 'Selected tags',
|
|
293
|
+
options: selectedTags,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
text: 'Branches',
|
|
297
|
+
options: availableBranches,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
text: 'Tags',
|
|
301
|
+
options: availableTags,
|
|
302
|
+
},
|
|
303
|
+
].filter((group) => group.options.length);
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
Groups.args = generateProps({ multiple: true });
|
|
263
308
|
|
|
264
309
|
export const CustomGroupsAndItems = makeGroupedExample({
|
|
265
310
|
template: template(`
|
|
@@ -86,10 +86,11 @@ describe('toggle', () => {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
describe.each`
|
|
89
|
-
state
|
|
90
|
-
${'with help'}
|
|
91
|
-
${'with help in slot'}
|
|
92
|
-
${'without help'}
|
|
89
|
+
state | help | props | options | getAriaDescribedBy
|
|
90
|
+
${'with help'} | ${helpText} | ${{ help: helpText }} | ${undefined} | ${() => findHelpElement().attributes('id')}
|
|
91
|
+
${'with help in slot'} | ${helpText} | ${undefined} | ${{ slots: { help: helpText } }} | ${() => findHelpElement().attributes('id')}
|
|
92
|
+
${'without help'} | ${undefined} | ${undefined} | ${undefined} | ${() => undefined}
|
|
93
|
+
${'with help and labelPosition left'} | ${undefined} | ${{ help: helpText, labelPosition: toggleLabelPosition.left }} | ${undefined} | ${() => undefined}
|
|
93
94
|
`('$state', ({ help, props, options, getAriaDescribedBy }) => {
|
|
94
95
|
beforeEach(() => {
|
|
95
96
|
createWrapper(props, options);
|
|
@@ -83,7 +83,7 @@ export default {
|
|
|
83
83
|
computed: {
|
|
84
84
|
shouldRenderHelp() {
|
|
85
85
|
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
86
|
-
return Boolean(this.$slots.help || this.help);
|
|
86
|
+
return Boolean(this.$slots.help || this.help) && this.isVerticalLayout;
|
|
87
87
|
},
|
|
88
88
|
icon() {
|
|
89
89
|
return this.value ? 'mobile-issue-close' : 'close';
|
|
@@ -94,6 +94,9 @@ export default {
|
|
|
94
94
|
isChecked() {
|
|
95
95
|
return this.value ? 'true' : 'false';
|
|
96
96
|
},
|
|
97
|
+
isVerticalLayout() {
|
|
98
|
+
return this.labelPosition === 'top' || this.labelPosition === 'hidden';
|
|
99
|
+
},
|
|
97
100
|
},
|
|
98
101
|
|
|
99
102
|
beforeCreate() {
|
|
@@ -121,8 +124,8 @@ export default {
|
|
|
121
124
|
<div
|
|
122
125
|
class="gl-toggle-wrapper gl-display-flex gl-mb-0"
|
|
123
126
|
:class="{
|
|
124
|
-
'gl-flex-direction-column':
|
|
125
|
-
'gl-toggle-label-inline':
|
|
127
|
+
'gl-flex-direction-column': isVerticalLayout,
|
|
128
|
+
'gl-toggle-label-inline': !isVerticalLayout,
|
|
126
129
|
'is-disabled': disabled,
|
|
127
130
|
}"
|
|
128
131
|
data-testid="toggle-wrapper"
|
|
@@ -129,7 +129,9 @@ describe('outside directive', () => {
|
|
|
129
129
|
it('attaches the global listener on first initialisation', async () => {
|
|
130
130
|
await createComponent();
|
|
131
131
|
|
|
132
|
-
expect(document.addEventListener.mock.calls).toEqual([
|
|
132
|
+
expect(document.addEventListener.mock.calls).toEqual([
|
|
133
|
+
['click', expect.any(Function), { capture: true }],
|
|
134
|
+
]);
|
|
133
135
|
});
|
|
134
136
|
|
|
135
137
|
it('detaches the global listener when last binding is removed', async () => {
|
|
@@ -150,7 +152,9 @@ describe('outside directive', () => {
|
|
|
150
152
|
`,
|
|
151
153
|
});
|
|
152
154
|
|
|
153
|
-
expect(document.addEventListener.mock.calls).toEqual([
|
|
155
|
+
expect(document.addEventListener.mock.calls).toEqual([
|
|
156
|
+
['click', expect.any(Function), { capture: true }],
|
|
157
|
+
]);
|
|
154
158
|
});
|
|
155
159
|
|
|
156
160
|
it('only unbinds once there are no instances', async () => {
|