@gitlab/ui 87.6.1 → 87.7.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,10 @@
1
+ # [87.7.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v87.6.1...v87.7.0) (2024-08-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add boolean flag for improvedHideHeuristics in Config ([1fa7037](https://gitlab.com/gitlab-org/gitlab-ui/commit/1fa703735f10a3cfa3539c3c7d5d7950a6c6257e))
7
+
1
8
  ## [87.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v87.6.0...v87.6.1) (2024-08-01)
2
9
 
3
10
 
@@ -1,6 +1,7 @@
1
1
  import clamp from 'lodash/clamp';
2
2
  import uniqueId from 'lodash/uniqueId';
3
3
  import { stopEvent, filterVisible } from '../../../../utils/utils';
4
+ import { glDropdownConfig } from '../../../../config';
4
5
  import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_FOCUS_CONTENT, POSITION_ABSOLUTE, POSITION_FIXED, HOME, END, ARROW_UP, ARROW_DOWN, ENTER, SPACE, GL_DROPDOWN_CONTENTS_CLASS } from '../constants';
5
6
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
6
7
  import GlBaseDropdown, { BASE_DROPDOWN_CLASS } from '../base_dropdown/base_dropdown';
@@ -215,7 +216,9 @@ var script = {
215
216
  improvedHideHeuristics: {
216
217
  type: Boolean,
217
218
  required: false,
218
- default: false
219
+ default() {
220
+ return Boolean(glDropdownConfig.useImprovedHideHeuristics);
221
+ }
219
222
  }
220
223
  },
221
224
  data() {
@@ -2,6 +2,7 @@ import clamp from 'lodash/clamp';
2
2
  import uniqueId from 'lodash/uniqueId';
3
3
  import isNil from 'lodash/isNil';
4
4
  import { stopEvent } from '../../../../utils/utils';
5
+ import { glDropdownConfig } from '../../../../config';
5
6
  import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, HOME, END, ARROW_UP, ARROW_DOWN } from '../constants';
6
7
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
7
8
  import GlButton from '../../button/button';
@@ -336,7 +337,9 @@ var script = {
336
337
  improvedHideHeuristics: {
337
338
  type: Boolean,
338
339
  required: false,
339
- default: false
340
+ default() {
341
+ return Boolean(glDropdownConfig.useImprovedHideHeuristics);
342
+ }
340
343
  }
341
344
  },
342
345
  data() {
package/dist/config.js CHANGED
@@ -35,6 +35,7 @@ try {
35
35
  // localStorage doesn't exist (or the value is not properly formatted)
36
36
  }
37
37
  const i18n = translationKeys;
38
+ const glDropdownConfig = {};
38
39
  let configured = false;
39
40
 
40
41
  /**
@@ -43,11 +44,12 @@ let configured = false;
43
44
  * @typedef {object} GitLabUIConfiguration
44
45
  * @template TValue=string
45
46
  * @property {undefined | Object} translations Generic translations for component labels to fall back to.
46
- * @property {boolean} disableTranslations Whether translation capabilities should be disabled. Suppresses the warning about missing translations.
47
+ * @property {boolean} [useImprovedHideHeuristics] Temporary flag to enable improved hide heuristics for dropdowns.
47
48
  */
48
49
  const setConfigs = function () {
49
50
  let {
50
- translations
51
+ translations,
52
+ useImprovedHideHeuristics
51
53
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
52
54
  if (configured) {
53
55
  if (process.env.NODE_ENV === 'development') {
@@ -80,7 +82,24 @@ const setConfigs = function () {
80
82
  }
81
83
  Object.assign(i18n, translations);
82
84
  }
85
+
86
+ // Temporary flag to enable the improved hide heuristics feature.
87
+ // This flag allows the feature to be opt-in during the rollout phase,
88
+ // giving us the flexibility to test and validate its impact on user experience.
89
+
90
+ // The global variable `useImprovedHideHeuristics` is set to a boolean value
91
+ // to indicate whether the improved hide heuristics should be used.
92
+
93
+ // Future Plan:
94
+ // Once the improved hide heuristics feature is validated and stable,
95
+ // we will remove this temporary flag and make the feature the default behavior.
96
+ // At that point, there will be no need for opt-in or opt-out mechanisms for this feature.
97
+ if (typeof useImprovedHideHeuristics === 'boolean') {
98
+ Object.assign(glDropdownConfig, {
99
+ useImprovedHideHeuristics
100
+ });
101
+ }
83
102
  };
84
103
 
85
104
  export default setConfigs;
86
- export { i18n };
105
+ export { glDropdownConfig, i18n };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "87.6.1",
3
+ "version": "87.7.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -3,6 +3,7 @@
3
3
  import clamp from 'lodash/clamp';
4
4
  import uniqueId from 'lodash/uniqueId';
5
5
  import { stopEvent, filterVisible } from '../../../../utils/utils';
6
+ import { glDropdownConfig } from '../../../../config';
6
7
  import {
7
8
  GL_DROPDOWN_SHOWN,
8
9
  GL_DROPDOWN_HIDDEN,
@@ -235,7 +236,9 @@ export default {
235
236
  improvedHideHeuristics: {
236
237
  type: Boolean,
237
238
  required: false,
238
- default: false,
239
+ default() {
240
+ return Boolean(glDropdownConfig.useImprovedHideHeuristics);
241
+ },
239
242
  },
240
243
  },
241
244
  data() {
@@ -4,6 +4,7 @@ import clamp from 'lodash/clamp';
4
4
  import uniqueId from 'lodash/uniqueId';
5
5
  import isNil from 'lodash/isNil';
6
6
  import { stopEvent } from '../../../../utils/utils';
7
+ import { glDropdownConfig } from '../../../../config';
7
8
  import {
8
9
  GL_DROPDOWN_SHOWN,
9
10
  GL_DROPDOWN_HIDDEN,
@@ -356,7 +357,9 @@ export default {
356
357
  improvedHideHeuristics: {
357
358
  type: Boolean,
358
359
  required: false,
359
- default: false,
360
+ default() {
361
+ return Boolean(glDropdownConfig.useImprovedHideHeuristics);
362
+ },
360
363
  },
361
364
  },
362
365
  data() {
package/src/config.js CHANGED
@@ -39,6 +39,8 @@ try {
39
39
 
40
40
  export const i18n = translationKeys;
41
41
 
42
+ export const glDropdownConfig = {};
43
+
42
44
  let configured = false;
43
45
 
44
46
  /**
@@ -47,9 +49,9 @@ let configured = false;
47
49
  * @typedef {object} GitLabUIConfiguration
48
50
  * @template TValue=string
49
51
  * @property {undefined | Object} translations Generic translations for component labels to fall back to.
50
- * @property {boolean} disableTranslations Whether translation capabilities should be disabled. Suppresses the warning about missing translations.
52
+ * @property {boolean} [useImprovedHideHeuristics] Temporary flag to enable improved hide heuristics for dropdowns.
51
53
  */
52
- const setConfigs = ({ translations } = {}) => {
54
+ const setConfigs = ({ translations, useImprovedHideHeuristics } = {}) => {
53
55
  if (configured) {
54
56
  if (process.env.NODE_ENV === 'development') {
55
57
  throw new Error('GitLab UI can only be configured once!');
@@ -87,6 +89,23 @@ const setConfigs = ({ translations } = {}) => {
87
89
 
88
90
  Object.assign(i18n, translations);
89
91
  }
92
+
93
+ // Temporary flag to enable the improved hide heuristics feature.
94
+ // This flag allows the feature to be opt-in during the rollout phase,
95
+ // giving us the flexibility to test and validate its impact on user experience.
96
+
97
+ // The global variable `useImprovedHideHeuristics` is set to a boolean value
98
+ // to indicate whether the improved hide heuristics should be used.
99
+
100
+ // Future Plan:
101
+ // Once the improved hide heuristics feature is validated and stable,
102
+ // we will remove this temporary flag and make the feature the default behavior.
103
+ // At that point, there will be no need for opt-in or opt-out mechanisms for this feature.
104
+ if (typeof useImprovedHideHeuristics === 'boolean') {
105
+ Object.assign(glDropdownConfig, {
106
+ useImprovedHideHeuristics,
107
+ });
108
+ }
90
109
  };
91
110
 
92
111
  export default setConfigs;