@gitlab/ui 128.4.0 → 128.5.1

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.
@@ -7,7 +7,6 @@ import { isEvent } from '../../../vendor/bootstrap-vue/src/utils/inspect';
7
7
  import GlIcon from '../icon/icon';
8
8
  import GlLoadingIcon from '../loading_icon/loading_icon';
9
9
  import { SPACE, ENTER } from '../new_dropdowns/constants';
10
- import { glButtonConfig } from '../../../config';
11
10
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
12
11
 
13
12
  var script = {
@@ -77,14 +76,6 @@ var script = {
77
76
  required: false,
78
77
  default: false
79
78
  },
80
- /**
81
- * Keep the button accessible when `loading` is `true`.
82
- */
83
- accessibleLoading: {
84
- type: Boolean,
85
- required: false,
86
- default: () => glButtonConfig.accessibleLoadingButton
87
- },
88
79
  /**
89
80
  * CSS classes to add to the button text.
90
81
  */
@@ -241,11 +232,8 @@ var script = {
241
232
  hasIconOnly() {
242
233
  return isSlotEmpty(this, 'default') && this.hasIcon && this.count == null;
243
234
  },
244
- isButtonDisabled() {
245
- return this.disabled || this.loading;
246
- },
247
235
  isButtonAriaDisabled() {
248
- return this.accessibleLoading && this.isButton && this.loading;
236
+ return this.isButton && this.loading;
249
237
  },
250
238
  buttonClasses() {
251
239
  const classes = ['btn', 'gl-button', `btn-${this.variant}`, `btn-${this.buttonSize}`];
@@ -300,7 +288,7 @@ var script = {
300
288
  // Type only used for "real" buttons
301
289
  type: this.isButton ? this.type : null,
302
290
  // Disabled only set on "real" buttons
303
- disabled: this.isButton ? this.isButtonDisabled : null,
291
+ disabled: this.isButton ? this.disabled : null,
304
292
  // We add a role of button when the tag is not a link or button or when link has `href` of `#`
305
293
  role: this.isNonStandardTag || this.isHashLink ? 'button' : (_this$$attrs = this.$attrs) === null || _this$$attrs === void 0 ? void 0 : _this$$attrs.role,
306
294
  // We set the `aria-disabled` state for non-standard tags
@@ -310,8 +298,7 @@ var script = {
310
298
  tabindex: this.tabindex,
311
299
  // We set the `aria-disabled` state for buttons while loading
312
300
  ...(this.isButtonAriaDisabled ? {
313
- 'aria-disabled': 'true',
314
- disabled: null
301
+ 'aria-disabled': 'true'
315
302
  } : {})
316
303
  };
317
304
  if (this.isLink) {
@@ -1,12 +1,9 @@
1
1
  import Vue from 'vue';
2
- import compose from 'lodash/fp/compose';
3
- import fill from 'lodash/fp/fill';
4
- import filter from 'lodash/fp/filter';
5
- import { insert, intersperse } from '../../../utils/data_utils';
2
+ import { intersperse, insert } from '../../../utils/data_utils';
6
3
  import { isVnodeEmpty } from '../../../utils/is_slot_empty';
7
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
8
5
 
9
- const filterEmptyNodesVue2 = filter(vNode => typeof vNode.tag === 'string' || vNode.text.trim() !== '');
6
+ const filterEmptyNodesVue2 = vNodes => vNodes.filter(vNode => typeof vNode.tag === 'string' || vNode.text.trim() !== '');
10
7
  const {
11
8
  Fragment
12
9
  } = Vue;
@@ -21,17 +18,22 @@ const filterEmptyNodesVue3 = vNode => {
21
18
  }, []).filter(node => !isVnodeEmpty(node));
22
19
  };
23
20
  const filterEmptyNodes = Vue.version.startsWith('3') ? filterEmptyNodesVue3 : filterEmptyNodesVue2;
24
- const insertAfterSecondLastItem = insert(-1);
25
- const replaceSecondLastItem = fill(-2, -1);
26
21
 
27
22
  // handles the addition of the lastSeparator in these two cases:
28
23
  // item1, item2, item3 => item1, item2, and item3
29
24
  // item1, item2 => item1 and item2
30
- const addLastSeparator = lastSeparator => items => {
25
+ const addLastSeparator = (lastSeparator, items) => {
31
26
  if (!lastSeparator) {
32
27
  return items;
33
28
  }
34
- return items.length > 3 ? insertAfterSecondLastItem(lastSeparator, items) : replaceSecondLastItem(lastSeparator, items);
29
+ if (items.length > 3) {
30
+ return insert(-1, lastSeparator, items);
31
+ }
32
+
33
+ // Replace the second-to-last item with lastSeparator
34
+ const result = [...items];
35
+ result[result.length - 2] = lastSeparator;
36
+ return result;
35
37
  };
36
38
  var script = {
37
39
  name: 'GlIntersperse',
@@ -57,8 +59,11 @@ var script = {
57
59
  slots,
58
60
  data
59
61
  } = context;
60
- const filterAndSeparate = compose(addLastSeparator(lastSeparator), intersperse(separator), filterEmptyNodes);
61
- return createElement('span', data, filterAndSeparate(slots().default));
62
+ const slotContent = slots().default || [];
63
+ const filtered = filterEmptyNodes(slotContent);
64
+ const separated = intersperse(separator, filtered);
65
+ const withLastSeparator = addLastSeparator(lastSeparator, separated);
66
+ return createElement('span', data, withLastSeparator);
62
67
  }
63
68
  };
64
69
 
package/dist/config.js CHANGED
@@ -35,7 +35,6 @@ const i18n = translationKeys;
35
35
  const defaultConfig = {
36
36
  firstDayOfWeek: 0 // Defaults to 0 (Sunday)
37
37
  };
38
- const glButtonConfig = {};
39
38
  let configured = false;
40
39
 
41
40
  /**
@@ -51,8 +50,7 @@ let configured = false;
51
50
  const setConfigs = function () {
52
51
  let {
53
52
  translations,
54
- firstDayOfWeek,
55
- accessibleLoadingButton = false
53
+ firstDayOfWeek
56
54
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
55
  if (configured) {
58
56
  if (process.env.NODE_ENV === 'development') {
@@ -87,23 +85,6 @@ const setConfigs = function () {
87
85
  }
88
86
  Object.assign(i18n, translations);
89
87
  }
90
-
91
- // Temporary flag to enable the accessible loading button feature.
92
- // This flag allows the feature to be opt-in during the rollout phase,
93
- // giving us the flexibility to test and validate its impact on user experience.
94
-
95
- // The global variable `accessibleLoadingButton` is set to a boolean value
96
- // to indicate whether the button should be disabled while loading.
97
-
98
- // Future Plan:
99
- // Once the accessible loading button feature is validated and stable,
100
- // we will remove this temporary flag and make the feature the default behavior.
101
- // At that point, there will be no need for opt-in or opt-out mechanisms for this feature.
102
- if (typeof accessibleLoadingButton === 'boolean') {
103
- Object.assign(glButtonConfig, {
104
- accessibleLoadingButton
105
- });
106
- }
107
88
  };
108
89
 
109
- export { setConfigs as default, defaultConfig, glButtonConfig, i18n };
90
+ export { setConfigs as default, defaultConfig, i18n };
@@ -1,5 +1,3 @@
1
- import curry from 'lodash/fp/curry';
2
-
3
1
  const getRepeatingValue = index => {
4
2
  const values = [100, 500, 400, 200, 100, 800, 400, 500, 600, 300, 800, 900, 110, 700, 400, 300, 500, 300, 400, 600, 700];
5
3
  return index < values.length ? values[index] : values[index % values.length];
@@ -8,14 +6,14 @@ const generateTimeSeries = () => new Array(100).fill(0).map((el, i) => [new Date
8
6
 
9
7
  // takes an element and a list and `intersperses' that element between the elements of the list.
10
8
  // (',' ['a', 'b', 'c']) -> ['a', ',', 'b', ',', 'c']
11
- const intersperse = curry((separator, items) => {
9
+ const intersperse = (separator, items) => {
12
10
  const [head, ...rest] = items;
13
11
  const separatorFactory = typeof separator === 'function' ? separator : () => separator;
14
12
  return [head, ...rest.flatMap(item => [separatorFactory(), item], rest)];
15
- });
13
+ };
16
14
 
17
15
  // inserts a value at a given index into an array
18
16
  // (1, 2, [1, 3, 4]) -> [1, 2, 3, 4]
19
- const insert = curry((index, newItem, items) => [...items.slice(0, index), newItem, ...items.slice(index)]);
17
+ const insert = (index, newItem, items) => [...items.slice(0, index), newItem, ...items.slice(index)];
20
18
 
21
19
  export { generateTimeSeries, insert, intersperse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "128.4.0",
3
+ "version": "128.5.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -69,7 +69,7 @@
69
69
  "echarts": "^5.6.0",
70
70
  "gridstack": "^12.4.2",
71
71
  "iframe-resizer": "^4.4.5",
72
- "lodash": "^4.17.21",
72
+ "lodash": "^4.17.23",
73
73
  "popper.js": "^1.16.1",
74
74
  "portal-vue": "2.1.7",
75
75
  "vue-functional-data-merge": "^3.1.0",
@@ -13,7 +13,6 @@ import { isEvent } from '../../../vendor/bootstrap-vue/src/utils/inspect';
13
13
  import GlIcon from '../icon/icon.vue';
14
14
  import GlLoadingIcon from '../loading_icon/loading_icon.vue';
15
15
  import { ENTER, SPACE } from '../new_dropdowns/constants';
16
- import { glButtonConfig } from '../../../config';
17
16
 
18
17
  export default {
19
18
  name: 'GlButton',
@@ -82,14 +81,6 @@ export default {
82
81
  required: false,
83
82
  default: false,
84
83
  },
85
- /**
86
- * Keep the button accessible when `loading` is `true`.
87
- */
88
- accessibleLoading: {
89
- type: Boolean,
90
- required: false,
91
- default: () => glButtonConfig.accessibleLoadingButton,
92
- },
93
84
  /**
94
85
  * CSS classes to add to the button text.
95
86
  */
@@ -246,11 +237,8 @@ export default {
246
237
  hasIconOnly() {
247
238
  return isSlotEmpty(this, 'default') && this.hasIcon && this.count == null;
248
239
  },
249
- isButtonDisabled() {
250
- return this.disabled || this.loading;
251
- },
252
240
  isButtonAriaDisabled() {
253
- return this.accessibleLoading && this.isButton && this.loading;
241
+ return this.isButton && this.loading;
254
242
  },
255
243
  buttonClasses() {
256
244
  const classes = ['btn', 'gl-button', `btn-${this.variant}`, `btn-${this.buttonSize}`];
@@ -309,14 +297,14 @@ export default {
309
297
  // Type only used for "real" buttons
310
298
  type: this.isButton ? this.type : null,
311
299
  // Disabled only set on "real" buttons
312
- disabled: this.isButton ? this.isButtonDisabled : null,
300
+ disabled: this.isButton ? this.disabled : null,
313
301
  // We add a role of button when the tag is not a link or button or when link has `href` of `#`
314
302
  role: this.isNonStandardTag || this.isHashLink ? 'button' : this.$attrs?.role,
315
303
  // We set the `aria-disabled` state for non-standard tags
316
304
  ...(this.isNonStandardTag ? { 'aria-disabled': String(this.disabled) } : {}),
317
305
  tabindex: this.tabindex,
318
306
  // We set the `aria-disabled` state for buttons while loading
319
- ...(this.isButtonAriaDisabled ? { 'aria-disabled': 'true', disabled: null } : {}),
307
+ ...(this.isButtonAriaDisabled ? { 'aria-disabled': 'true' } : {}),
320
308
  };
321
309
 
322
310
  if (this.isLink) {
@@ -1,14 +1,10 @@
1
1
  <script>
2
2
  import Vue from 'vue';
3
- import compose from 'lodash/fp/compose';
4
- import fill from 'lodash/fp/fill';
5
- import filter from 'lodash/fp/filter';
6
3
  import { intersperse, insert } from '../../../utils/data_utils';
7
4
  import { isVnodeEmpty } from '../../../utils/is_slot_empty';
8
5
 
9
- const filterEmptyNodesVue2 = filter(
10
- (vNode) => typeof vNode.tag === 'string' || vNode.text.trim() !== '',
11
- );
6
+ const filterEmptyNodesVue2 = (vNodes) =>
7
+ vNodes.filter((vNode) => typeof vNode.tag === 'string' || vNode.text.trim() !== '');
12
8
 
13
9
  const { Fragment } = Vue;
14
10
  const filterEmptyNodesVue3 = (vNode) => {
@@ -25,20 +21,23 @@ const filterEmptyNodesVue3 = (vNode) => {
25
21
  };
26
22
 
27
23
  const filterEmptyNodes = Vue.version.startsWith('3') ? filterEmptyNodesVue3 : filterEmptyNodesVue2;
28
- const insertAfterSecondLastItem = insert(-1);
29
- const replaceSecondLastItem = fill(-2, -1);
30
24
 
31
25
  // handles the addition of the lastSeparator in these two cases:
32
26
  // item1, item2, item3 => item1, item2, and item3
33
27
  // item1, item2 => item1 and item2
34
- const addLastSeparator = (lastSeparator) => (items) => {
28
+ const addLastSeparator = (lastSeparator, items) => {
35
29
  if (!lastSeparator) {
36
30
  return items;
37
31
  }
38
32
 
39
- return items.length > 3
40
- ? insertAfterSecondLastItem(lastSeparator, items)
41
- : replaceSecondLastItem(lastSeparator, items);
33
+ if (items.length > 3) {
34
+ return insert(-1, lastSeparator, items);
35
+ }
36
+
37
+ // Replace the second-to-last item with lastSeparator
38
+ const result = [...items];
39
+ result[result.length - 2] = lastSeparator;
40
+ return result;
42
41
  };
43
42
 
44
43
  export default {
@@ -63,13 +62,12 @@ export default {
63
62
  data,
64
63
  } = context;
65
64
 
66
- const filterAndSeparate = compose(
67
- addLastSeparator(lastSeparator),
68
- intersperse(separator),
69
- filterEmptyNodes,
70
- );
65
+ const slotContent = slots().default || [];
66
+ const filtered = filterEmptyNodes(slotContent);
67
+ const separated = intersperse(separator, filtered);
68
+ const withLastSeparator = addLastSeparator(lastSeparator, separated);
71
69
 
72
- return createElement('span', data, filterAndSeparate(slots().default));
70
+ return createElement('span', data, withLastSeparator);
73
71
  },
74
72
  };
75
73
  </script>
package/src/config.js CHANGED
@@ -39,8 +39,6 @@ export const defaultConfig = {
39
39
  firstDayOfWeek: 0, // Defaults to 0 (Sunday)
40
40
  };
41
41
 
42
- export const glButtonConfig = {};
43
-
44
42
  let configured = false;
45
43
 
46
44
  /**
@@ -53,7 +51,7 @@ let configured = false;
53
51
  * @property {boolean} [accessibleLoadingButton] Temporary flag to enable accessible loading button.
54
52
  *
55
53
  */
56
- const setConfigs = ({ translations, firstDayOfWeek, accessibleLoadingButton = false } = {}) => {
54
+ const setConfigs = ({ translations, firstDayOfWeek } = {}) => {
57
55
  if (configured) {
58
56
  if (process.env.NODE_ENV === 'development') {
59
57
  throw new Error('GitLab UI can only be configured once!');
@@ -94,23 +92,6 @@ const setConfigs = ({ translations, firstDayOfWeek, accessibleLoadingButton = fa
94
92
 
95
93
  Object.assign(i18n, translations);
96
94
  }
97
-
98
- // Temporary flag to enable the accessible loading button feature.
99
- // This flag allows the feature to be opt-in during the rollout phase,
100
- // giving us the flexibility to test and validate its impact on user experience.
101
-
102
- // The global variable `accessibleLoadingButton` is set to a boolean value
103
- // to indicate whether the button should be disabled while loading.
104
-
105
- // Future Plan:
106
- // Once the accessible loading button feature is validated and stable,
107
- // we will remove this temporary flag and make the feature the default behavior.
108
- // At that point, there will be no need for opt-in or opt-out mechanisms for this feature.
109
- if (typeof accessibleLoadingButton === 'boolean') {
110
- Object.assign(glButtonConfig, {
111
- accessibleLoadingButton,
112
- });
113
- }
114
95
  };
115
96
 
116
97
  export default setConfigs;
@@ -1,5 +1,3 @@
1
- import curry from 'lodash/fp/curry';
2
-
3
1
  const getRepeatingValue = (index) => {
4
2
  const values = [
5
3
  100, 500, 400, 200, 100, 800, 400, 500, 600, 300, 800, 900, 110, 700, 400, 300, 500, 300, 400,
@@ -13,16 +11,16 @@ export const generateTimeSeries = () =>
13
11
 
14
12
  // takes an element and a list and `intersperses' that element between the elements of the list.
15
13
  // (',' ['a', 'b', 'c']) -> ['a', ',', 'b', ',', 'c']
16
- export const intersperse = curry((separator, items) => {
14
+ export const intersperse = (separator, items) => {
17
15
  const [head, ...rest] = items;
18
16
  const separatorFactory = typeof separator === 'function' ? separator : () => separator;
19
17
  return [head, ...rest.flatMap((item) => [separatorFactory(), item], rest)];
20
- });
18
+ };
21
19
 
22
20
  // inserts a value at a given index into an array
23
21
  // (1, 2, [1, 3, 4]) -> [1, 2, 3, 4]
24
- export const insert = curry((index, newItem, items) => [
22
+ export const insert = (index, newItem, items) => [
25
23
  ...items.slice(0, index),
26
24
  newItem,
27
25
  ...items.slice(index),
28
- ]);
26
+ ];