@gitlab/ui 64.20.1 → 64.21.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,17 @@
1
+ # [64.21.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.20.1...v64.21.0) (2023-07-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlToggle:** Enable flex-grow-1 to ensure backwards compatibility ([dfd6554](https://gitlab.com/gitlab-org/gitlab-ui/commit/dfd655420bd8aef33a3af0d5ea3144ac59934ee0))
7
+ * **GlToggle:** Remove vertical padding if label is sr-only ([697a597](https://gitlab.com/gitlab-org/gitlab-ui/commit/697a5979ceae6f6e46c877c8baea58051741f732))
8
+ * **GlToggle:** Wrap long texts when using block-layout for toggle ([a487517](https://gitlab.com/gitlab-org/gitlab-ui/commit/a4875170a207018b605833b022d6fce6ca3803e4))
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlToggle:** Add a block level toggle ([0b73ddb](https://gitlab.com/gitlab-org/gitlab-ui/commit/0b73ddb0acfdad3d81501cb360e857de4089247e))
14
+
1
15
  ## [64.20.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.20.0...v64.20.1) (2023-07-13)
2
16
 
3
17
 
@@ -88,18 +88,40 @@ var script = {
88
88
  };
89
89
  },
90
90
  computed: {
91
+ layoutAllowsDescription() {
92
+ return this.isVerticalLayout || this.isBlockLayout;
93
+ },
91
94
  shouldRenderDescription() {
92
- // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
93
- return Boolean(this.$scopedSlots.description || this.description) && this.isVerticalLayout;
95
+ return Boolean(this.$scopedSlots.description || this.description) && this.layoutAllowsDescription;
96
+ },
97
+ labelIsSrOnly() {
98
+ return this.labelPosition === 'hidden';
99
+ },
100
+ layoutAllowsHelp() {
101
+ return this.isVerticalLayout || this.isBlockLayout;
94
102
  },
95
103
  shouldRenderHelp() {
96
- // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
97
- return Boolean(this.$slots.help || this.help) && this.isVerticalLayout;
104
+ return Boolean(this.$scopedSlots.help || this.help) && this.layoutAllowsHelp;
98
105
  },
99
- toggleClasses() {
100
- return [{
101
- 'gl-sr-only': this.labelPosition === 'hidden'
102
- }, this.shouldRenderDescription ? 'gl-mb-2' : 'gl-mb-3'];
106
+ labelContainerClasses() {
107
+ return {
108
+ 'gl-mb-3': this.isVerticalLayout && !this.labelIsSrOnly
109
+ };
110
+ },
111
+ labelClasses() {
112
+ if (this.labelIsSrOnly) return 'gl-sr-only';
113
+ return {
114
+ 'gl-mb-2': this.shouldRenderDescription,
115
+ 'gl-mb-3': !this.shouldRenderDescription && !this.isVerticalLayout
116
+ };
117
+ },
118
+ wrapperClasses() {
119
+ return {
120
+ 'gl-flex-direction-column': this.isVerticalLayout,
121
+ 'gl-toggle-label-inline': !this.isVerticalLayout,
122
+ 'is-disabled': this.disabled,
123
+ 'gl-toggle-label-position-block': this.isBlockLayout
124
+ };
103
125
  },
104
126
  icon() {
105
127
  return this.value ? 'mobile-issue-close' : 'close';
@@ -112,6 +134,9 @@ var script = {
112
134
  },
113
135
  isVerticalLayout() {
114
136
  return this.labelPosition === 'top' || this.labelPosition === 'hidden';
137
+ },
138
+ isBlockLayout() {
139
+ return this.labelPosition === 'block';
115
140
  }
116
141
  },
117
142
  beforeCreate() {
@@ -137,15 +162,11 @@ var script = {
137
162
  const __vue_script__ = script;
138
163
 
139
164
  /* template */
140
- 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:{
141
- 'gl-flex-direction-column': _vm.isVerticalLayout,
142
- 'gl-toggle-label-inline': !_vm.isVerticalLayout,
143
- 'is-disabled': _vm.disabled,
144
- },attrs:{"data-testid":"toggle-wrapper"}},[_c('span',{staticClass:"gl-toggle-label gl-flex-shrink-0",class:_vm.toggleClasses,attrs:{"id":_vm.labelId,"data-testid":"toggle-label"}},[_vm._t("label",function(){return [_vm._v(_vm._s(_vm.label))]})],2),_vm._v(" "),(_vm.shouldRenderDescription)?_c('span',{staticClass:"gl-description-label gl-mb-3",attrs:{"data-testid":"toggle-description"}},[_vm._t("description",function(){return [_vm._v(_vm._s(_vm.description))]})],2):_vm._e(),_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:{
145
- 'gl-toggle': true,
146
- 'is-checked': _vm.value,
147
- 'is-disabled': _vm.disabled,
148
- },attrs:{"role":"switch","aria-checked":_vm.isChecked,"aria-labelledby":_vm.labelId,"aria-describedby":_vm.helpId,"aria-disabled":_vm.disabled,"type":"button"},on:{"click":function($event){$event.preventDefault();return _vm.toggleFeature.apply(null, arguments)}}},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"toggle-loading",attrs:{"color":"light"}}):_c('span',{class:{ 'toggle-icon': true, disabled: _vm.disabled }},[_c('gl-icon',{attrs:{"name":_vm.icon,"size":16}})],1)],1),_vm._v(" "),(_vm.shouldRenderHelp)?_c('span',{staticClass:"gl-help-label",attrs:{"id":_vm.helpId,"data-testid":"toggle-help"}},[_vm._t("help",function(){return [_vm._v(_vm._s(_vm.help))]})],2):_vm._e()])};
165
+ 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 flex-grow-1",class:_vm.wrapperClasses,attrs:{"data-testid":"toggle-wrapper"}},[_c('span',{staticClass:"gl-toggle-label-container",class:_vm.labelContainerClasses},[_c('span',{staticClass:"gl-toggle-label",class:_vm.labelClasses,attrs:{"id":_vm.labelId,"data-testid":"toggle-label"}},[_vm._t("label",function(){return [_vm._v(_vm._s(_vm.label))]})],2),_vm._v(" "),(_vm.shouldRenderDescription)?_c('span',{staticClass:"gl-description-label",attrs:{"data-testid":"toggle-description"}},[_vm._t("description",function(){return [_vm._v(_vm._s(_vm.description))]})],2):_vm._e()]),_vm._v(" "),_c('span',{staticClass:"gl-toggle-switch-container"},[(_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:{
166
+ 'gl-toggle': true,
167
+ 'is-checked': _vm.value,
168
+ 'is-disabled': _vm.disabled,
169
+ },attrs:{"role":"switch","aria-checked":_vm.isChecked,"aria-labelledby":_vm.labelId,"aria-describedby":_vm.helpId,"aria-disabled":_vm.disabled,"type":"button"},on:{"click":function($event){$event.preventDefault();return _vm.toggleFeature.apply(null, arguments)}}},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"toggle-loading",attrs:{"color":"light"}}):_c('span',{class:{ 'toggle-icon': true, disabled: _vm.disabled }},[_c('gl-icon',{attrs:{"name":_vm.icon,"size":16}})],1)],1),_vm._v(" "),(_vm.shouldRenderHelp)?_c('span',{staticClass:"gl-help-label",attrs:{"id":_vm.helpId,"data-testid":"toggle-help"}},[_vm._t("help",function(){return [_vm._v(_vm._s(_vm.help))]})],2):_vm._e()])])};
149
170
  var __vue_staticRenderFns__ = [];
150
171
 
151
172
  /* style */