@gitlab/ui 66.0.0 → 66.1.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.
@@ -249,7 +249,6 @@ const formInputSizes = {
249
249
  const toggleLabelPosition = {
250
250
  hidden: 'hidden',
251
251
  left: 'left',
252
- block: 'block',
253
252
  top: 'top'
254
253
  };
255
254
  const tooltipActionEvents = ['open', 'close', 'enable', 'disable'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "66.0.0",
3
+ "version": "66.1.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -86,13 +86,13 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "@arkweid/lefthook": "0.7.7",
89
- "@babel/core": "^7.22.10",
89
+ "@babel/core": "^7.22.11",
90
90
  "@babel/preset-env": "^7.22.10",
91
91
  "@babel/preset-react": "^7.22.5",
92
92
  "@gitlab/eslint-plugin": "19.0.0",
93
93
  "@gitlab/fonts": "^1.2.0",
94
94
  "@gitlab/stylelint-config": "5.0.0",
95
- "@gitlab/svgs": "3.59.0",
95
+ "@gitlab/svgs": "3.60.0",
96
96
  "@rollup/plugin-commonjs": "^11.1.0",
97
97
  "@rollup/plugin-node-resolve": "^7.1.3",
98
98
  "@rollup/plugin-replace": "^2.3.2",
@@ -120,18 +120,18 @@
120
120
  "babel-plugin-require-context-hook": "^1.0.0",
121
121
  "bootstrap": "4.6.2",
122
122
  "cypress": "12.17.4",
123
- "dompurify": "^2.4.7",
123
+ "dompurify": "^3.0.0",
124
124
  "emoji-regex": "^10.0.0",
125
- "eslint": "8.47.0",
125
+ "eslint": "8.48.0",
126
126
  "eslint-import-resolver-jest": "3.0.2",
127
127
  "eslint-plugin-cypress": "2.14.0",
128
128
  "eslint-plugin-storybook": "0.6.13",
129
129
  "glob": "^7.2.0",
130
130
  "identity-obj-proxy": "^3.0.0",
131
131
  "inquirer-select-directory": "^1.2.0",
132
- "jest": "^29.6.2",
133
- "jest-circus": "29.6.2",
134
- "jest-environment-jsdom": "29.6.2",
132
+ "jest": "^29.6.4",
133
+ "jest-circus": "29.6.4",
134
+ "jest-environment-jsdom": "29.6.4",
135
135
  "markdownlint-cli": "^0.29.0",
136
136
  "mockdate": "^2.0.5",
137
137
  "module-alias": "^2.2.2",
@@ -29,18 +29,18 @@
29
29
  .gl-toggle {
30
30
  @include gl-cursor-not-allowed;
31
31
  @include gl-bg-gray-200;
32
- }
33
32
 
34
- .toggle-icon > svg {
35
- @include gl-fill-gray-200;
33
+ .toggle-icon > svg {
34
+ @include gl-fill-gray-200;
35
+ }
36
36
  }
37
37
 
38
38
  .gl-toggle.is-checked {
39
39
  @include gl-bg-blue-200;
40
- }
41
40
 
42
- .toggle-icon > svg {
43
- @include gl-fill-blue-200;
41
+ .toggle-icon > svg {
42
+ @include gl-fill-blue-200;
43
+ }
44
44
  }
45
45
 
46
46
  .gl-toggle-label,
@@ -50,35 +50,6 @@
50
50
  }
51
51
  }
52
52
 
53
- .gl-toggle-label-container {
54
- @include gl-flex-shrink-0;
55
- @include gl-display-flex;
56
- @include gl-flex-direction-column;
57
- }
58
-
59
- .gl-toggle-switch-container {
60
- @include gl-display-flex;
61
- @include gl-flex-direction-column;
62
- }
63
-
64
- .gl-toggle-label-position-block {
65
- @include gl-justify-content-space-between;
66
- @include gl-align-items-center;
67
- @include gl-w-full;
68
- @include gl-gap-3;
69
-
70
- .gl-toggle-label-container {
71
- @include gl-gap-2;
72
- @include gl-flex-shrink-1;
73
- }
74
-
75
- .gl-toggle-switch-container {
76
- @include gl-align-items-flex-end;
77
- @include gl-gap-2;
78
- @include gl-flex-shrink-1;
79
- }
80
- }
81
-
82
53
  .gl-help-label {
83
54
  @include gl-mt-3;
84
55
  @include gl-text-gray-500;
@@ -138,43 +138,31 @@ describe('toggle', () => {
138
138
 
139
139
  describe('label position', () => {
140
140
  describe.each`
141
- state | labelPosition | hasGlSrOnlyClass | flexDirection | showsHelpText | showsDescription
142
- ${'top'} | ${toggleLabelPosition.top} | ${false} | ${'gl-flex-direction-column'} | ${true} | ${true}
143
- ${'left'} | ${toggleLabelPosition.left} | ${false} | ${'gl-toggle-label-inline'} | ${false} | ${false}
144
- ${'hidden'} | ${toggleLabelPosition.hidden} | ${true} | ${'gl-flex-direction-column'} | ${true} | ${true}
145
- ${'block'} | ${toggleLabelPosition.block} | ${false} | ${'gl-toggle-label-inline'} | ${true} | ${true}
146
- `(
147
- 'when $state',
148
- ({ labelPosition, hasGlSrOnlyClass, flexDirection, showsHelpText, showsDescription }) => {
149
- beforeEach(() => {
150
- createWrapper({ labelPosition, help: helpText, description: descriptionText });
151
- });
152
-
153
- it(`${flexDirection} class is added to the label`, () => {
154
- const cssClasses = wrapper.find('[data-testid="toggle-wrapper"]').classes();
155
-
156
- expect(cssClasses).toContain(flexDirection);
157
- });
158
-
159
- it(`${hasGlSrOnlyClass ? 'adds' : 'does not add'} 'gl-sr-only' class to the label`, () => {
160
- const cssClasses = wrapper.find('[data-testid="toggle-label"]').classes();
161
- return hasGlSrOnlyClass
162
- ? expect(cssClasses).toContain('gl-sr-only')
163
- : expect(cssClasses).not.toContain('gl-sr-only');
164
- });
165
-
166
- it('has accessible name for the button', () => {
167
- expect(findButton().attributes('aria-labelledby')).toBeDefined();
168
- });
169
-
170
- it(`${showsHelpText ? 'shows' : 'does not show'} the help text`, () => {
171
- expect(findHelpElement().exists()).toBe(showsHelpText);
172
- });
173
-
174
- it(`${showsDescription ? 'shows' : 'does not show'} the description`, () => {
175
- expect(findDescriptionElement().exists()).toBe(showsDescription);
176
- });
177
- }
178
- );
141
+ state | labelPosition | hasGlSrOnlyClass | flexDirection
142
+ ${'top'} | ${toggleLabelPosition.top} | ${false} | ${'gl-flex-direction-column'}
143
+ ${'left'} | ${toggleLabelPosition.left} | ${false} | ${'gl-toggle-label-inline'}
144
+ ${'hidden'} | ${toggleLabelPosition.hidden} | ${true} | ${'gl-flex-direction-column'}
145
+ `('when $state', ({ labelPosition, hasGlSrOnlyClass, flexDirection }) => {
146
+ beforeEach(() => {
147
+ createWrapper({ labelPosition });
148
+ });
149
+
150
+ it(`${flexDirection} class is added to the label`, () => {
151
+ const cssClasses = wrapper.find('[data-testid="toggle-wrapper"]').classes();
152
+
153
+ return expect(cssClasses).toContain(flexDirection);
154
+ });
155
+
156
+ it(`${hasGlSrOnlyClass ? 'adds' : 'does not add'} 'gl-sr-only' class to the label`, () => {
157
+ const cssClasses = wrapper.find('[data-testid="toggle-label"]').classes();
158
+ return hasGlSrOnlyClass
159
+ ? expect(cssClasses).toContain('gl-sr-only')
160
+ : expect(cssClasses).not.toContain('gl-sr-only');
161
+ });
162
+
163
+ it('has accessible name for the button', () => {
164
+ expect(findButton().attributes('aria-labelledby')).toBeDefined();
165
+ });
166
+ });
179
167
  });
180
168
  });
@@ -67,12 +67,6 @@ LabelPositionLeft.args = generateProps({
67
67
  labelPosition: 'left',
68
68
  });
69
69
 
70
- export const LabelPositionBlock = Template.bind({});
71
- LabelPositionBlock.args = generateProps({
72
- labelPosition: 'block',
73
- description: withDescription,
74
- });
75
-
76
70
  export default {
77
71
  title: 'base/toggle',
78
72
  component: GlToggle,
@@ -90,42 +90,19 @@ export default {
90
90
  };
91
91
  },
92
92
  computed: {
93
- layoutAllowsDescription() {
94
- return this.isVerticalLayout || this.isBlockLayout;
95
- },
96
93
  shouldRenderDescription() {
97
- return (
98
- Boolean(this.$scopedSlots.description || this.description) && this.layoutAllowsDescription
99
- );
100
- },
101
- labelIsSrOnly() {
102
- return this.labelPosition === 'hidden';
103
- },
104
- layoutAllowsHelp() {
105
- return this.isVerticalLayout || this.isBlockLayout;
94
+ // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
95
+ return Boolean(this.$scopedSlots.description || this.description) && this.isVerticalLayout;
106
96
  },
107
97
  shouldRenderHelp() {
108
- return Boolean(this.$scopedSlots.help || this.help) && this.layoutAllowsHelp;
109
- },
110
- labelContainerClasses() {
111
- return {
112
- 'gl-mb-3': this.isVerticalLayout && !this.labelIsSrOnly,
113
- };
114
- },
115
- labelClasses() {
116
- if (this.labelIsSrOnly) return 'gl-sr-only';
117
- return {
118
- 'gl-mb-2': this.shouldRenderDescription,
119
- 'gl-mb-3': !this.shouldRenderDescription && !this.isVerticalLayout,
120
- };
121
- },
122
- wrapperClasses() {
123
- return {
124
- 'gl-flex-direction-column': this.isVerticalLayout,
125
- 'gl-toggle-label-inline': !this.isVerticalLayout,
126
- 'is-disabled': this.disabled,
127
- 'gl-toggle-label-position-block': this.isBlockLayout,
128
- };
98
+ // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
99
+ return Boolean(this.$slots.help || this.help) && this.isVerticalLayout;
100
+ },
101
+ toggleClasses() {
102
+ return [
103
+ { 'gl-sr-only': this.labelPosition === 'hidden' },
104
+ this.shouldRenderDescription ? 'gl-mb-2' : 'gl-mb-3',
105
+ ];
129
106
  },
130
107
  icon() {
131
108
  return this.value ? 'mobile-issue-close' : 'close';
@@ -139,9 +116,6 @@ export default {
139
116
  isVerticalLayout() {
140
117
  return this.labelPosition === 'top' || this.labelPosition === 'hidden';
141
118
  },
142
- isBlockLayout() {
143
- return this.labelPosition === 'block';
144
- },
145
119
  },
146
120
 
147
121
  beforeCreate() {
@@ -167,50 +141,55 @@ export default {
167
141
 
168
142
  <template>
169
143
  <div
170
- class="gl-toggle-wrapper gl-display-flex gl-mb-0 flex-grow-1"
171
- :class="wrapperClasses"
144
+ class="gl-toggle-wrapper gl-display-flex gl-mb-0"
145
+ :class="{
146
+ 'gl-flex-direction-column': isVerticalLayout,
147
+ 'gl-toggle-label-inline': !isVerticalLayout,
148
+ 'is-disabled': disabled,
149
+ }"
172
150
  data-testid="toggle-wrapper"
173
151
  >
174
- <span :class="labelContainerClasses" class="gl-toggle-label-container">
175
- <span :id="labelId" :class="labelClasses" class="gl-toggle-label" data-testid="toggle-label">
176
- <!-- @slot The toggle's label. -->
177
- <slot name="label">{{ label }}</slot>
178
- </span>
179
- <span
180
- v-if="shouldRenderDescription"
181
- class="gl-description-label"
182
- data-testid="toggle-description"
183
- >
184
- <!-- @slot A description text to be shown below the label. -->
185
- <slot name="description">{{ description }}</slot>
186
- </span>
152
+ <span
153
+ :id="labelId"
154
+ :class="toggleClasses"
155
+ class="gl-toggle-label gl-flex-shrink-0"
156
+ data-testid="toggle-label"
157
+ >
158
+ <!-- @slot The toggle's label. -->
159
+ <slot name="label">{{ label }}</slot>
160
+ </span>
161
+ <span
162
+ v-if="shouldRenderDescription"
163
+ class="gl-description-label gl-mb-3"
164
+ data-testid="toggle-description"
165
+ >
166
+ <!-- @slot A description text to be shown below the label. -->
167
+ <slot name="description">{{ description }}</slot>
187
168
  </span>
188
- <span class="gl-toggle-switch-container">
189
- <input v-if="name" :name="name" :value="value" type="hidden" />
190
- <button
191
- role="switch"
192
- :aria-checked="isChecked"
193
- :aria-labelledby="labelId"
194
- :aria-describedby="helpId"
195
- :aria-disabled="disabled"
196
- :class="{
197
- 'gl-toggle': true,
198
- 'is-checked': value,
199
- 'is-disabled': disabled,
200
- }"
201
- class="gl-flex-shrink-0"
202
- type="button"
203
- @click.prevent="toggleFeature"
204
- >
205
- <gl-loading-icon v-if="isLoading" color="light" class="toggle-loading" />
206
- <span v-else :class="{ 'toggle-icon': true, disabled: disabled }">
207
- <gl-icon :name="icon" :size="16" />
208
- </span>
209
- </button>
210
- <span v-if="shouldRenderHelp" :id="helpId" class="gl-help-label" data-testid="toggle-help">
211
- <!-- @slot A help text to be shown below the toggle. -->
212
- <slot name="help">{{ help }}</slot>
169
+ <input v-if="name" :name="name" :value="value" type="hidden" />
170
+ <button
171
+ role="switch"
172
+ :aria-checked="isChecked"
173
+ :aria-labelledby="labelId"
174
+ :aria-describedby="helpId"
175
+ :aria-disabled="disabled"
176
+ :class="{
177
+ 'gl-toggle': true,
178
+ 'is-checked': value,
179
+ 'is-disabled': disabled,
180
+ }"
181
+ class="gl-flex-shrink-0"
182
+ type="button"
183
+ @click.prevent="toggleFeature"
184
+ >
185
+ <gl-loading-icon v-if="isLoading" color="light" class="toggle-loading" />
186
+ <span v-else :class="{ 'toggle-icon': true, disabled: disabled }">
187
+ <gl-icon :name="icon" :size="16" />
213
188
  </span>
189
+ </button>
190
+ <span v-if="shouldRenderHelp" :id="helpId" class="gl-help-label" data-testid="toggle-help">
191
+ <!-- @slot A help text to be shown below the toggle. -->
192
+ <slot name="help">{{ help }}</slot>
214
193
  </span>
215
194
  </div>
216
195
  </template>
@@ -3587,14 +3587,6 @@
3587
3587
  flex-shrink: 0 !important;
3588
3588
  }
3589
3589
 
3590
- .gl-flex-shrink-1 {
3591
- flex-shrink: 1;
3592
- }
3593
-
3594
- .gl-flex-shrink-1\! {
3595
- flex-shrink: 1 !important;
3596
- }
3597
-
3598
3590
  .gl-flex-grow-0 {
3599
3591
  flex-grow: 0;
3600
3592
  }
@@ -6395,24 +6387,48 @@
6395
6387
  .gl-mb-4\! {
6396
6388
  margin-bottom: $gl-spacing-scale-4 !important;
6397
6389
  }
6390
+ .gl-mb-n4 {
6391
+ margin-bottom: -$gl-spacing-scale-4;
6392
+ }
6393
+ .gl-mb-n4\! {
6394
+ margin-bottom: -$gl-spacing-scale-4 !important;
6395
+ }
6398
6396
  .gl-mb-5 {
6399
6397
  margin-bottom: $gl-spacing-scale-5;
6400
6398
  }
6401
6399
  .gl-mb-5\! {
6402
6400
  margin-bottom: $gl-spacing-scale-5 !important;
6403
6401
  }
6402
+ .gl-mb-n5 {
6403
+ margin-bottom: -$gl-spacing-scale-5;
6404
+ }
6405
+ .gl-mb-n5\! {
6406
+ margin-bottom: -$gl-spacing-scale-5 !important;
6407
+ }
6404
6408
  .gl-mb-6 {
6405
6409
  margin-bottom: $gl-spacing-scale-6;
6406
6410
  }
6407
6411
  .gl-mb-6\! {
6408
6412
  margin-bottom: $gl-spacing-scale-6 !important;
6409
6413
  }
6414
+ .gl-mb-n6 {
6415
+ margin-bottom: -$gl-spacing-scale-6;
6416
+ }
6417
+ .gl-mb-n6\! {
6418
+ margin-bottom: -$gl-spacing-scale-6 !important;
6419
+ }
6410
6420
  .gl-mb-7 {
6411
6421
  margin-bottom: $gl-spacing-scale-7;
6412
6422
  }
6413
6423
  .gl-mb-7\! {
6414
6424
  margin-bottom: $gl-spacing-scale-7 !important;
6415
6425
  }
6426
+ .gl-mb-n7 {
6427
+ margin-bottom: -$gl-spacing-scale-7;
6428
+ }
6429
+ .gl-mb-n7\! {
6430
+ margin-bottom: -$gl-spacing-scale-7 !important;
6431
+ }
6416
6432
  .gl-mb-8 {
6417
6433
  margin-bottom: $gl-spacing-scale-8;
6418
6434
  }
@@ -183,10 +183,6 @@
183
183
  flex-shrink: 0;
184
184
  }
185
185
 
186
- @mixin gl-flex-shrink-1 {
187
- flex-shrink: 1;
188
- }
189
-
190
186
  @mixin gl-flex-grow-0 {
191
187
  flex-grow: 0;
192
188
  }
@@ -559,18 +559,34 @@
559
559
  margin-bottom: $gl-spacing-scale-4;
560
560
  }
561
561
 
562
+ @mixin gl-mb-n4 {
563
+ margin-bottom: -$gl-spacing-scale-4;
564
+ }
565
+
562
566
  @mixin gl-mb-5 {
563
567
  margin-bottom: $gl-spacing-scale-5;
564
568
  }
565
569
 
570
+ @mixin gl-mb-n5 {
571
+ margin-bottom: -$gl-spacing-scale-5;
572
+ }
573
+
566
574
  @mixin gl-mb-6 {
567
575
  margin-bottom: $gl-spacing-scale-6;
568
576
  }
569
577
 
578
+ @mixin gl-mb-n6 {
579
+ margin-bottom: -$gl-spacing-scale-6;
580
+ }
581
+
570
582
  @mixin gl-mb-7 {
571
583
  margin-bottom: $gl-spacing-scale-7;
572
584
  }
573
585
 
586
+ @mixin gl-mb-n7 {
587
+ margin-bottom: -$gl-spacing-scale-7;
588
+ }
589
+
574
590
  @mixin gl-mb-8 {
575
591
  margin-bottom: $gl-spacing-scale-8;
576
592
  }
@@ -297,7 +297,6 @@ export const formInputSizes = {
297
297
  export const toggleLabelPosition = {
298
298
  hidden: 'hidden',
299
299
  left: 'left',
300
- block: 'block',
301
300
  top: 'top',
302
301
  };
303
302