@gitlab/ui 131.3.2 → 132.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "131.3.2",
3
+ "version": "132.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -103,6 +103,7 @@
103
103
  "@cypress/grep": "^4.1.1",
104
104
  "@figma/code-connect": "^1.4.3",
105
105
  "@gitlab/fonts": "^1.3.1",
106
+ "@gitlab/hybrid-vue": "npm:@vue/compat@3.5.30",
106
107
  "@gitlab/svgs": "*",
107
108
  "@jest/test-sequencer": "30.3.0",
108
109
  "@rollup/plugin-commonjs": "^28.0.9",
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import { uniqueId, isBoolean, omit, pick } from 'lodash-es';
3
3
  import { looseEqual } from '../../../../utils/equality_utils';
4
- import { formOptionsMixin } from '../../../../vendor/bootstrap-vue/src/mixins/form-options';
5
4
  import { SafeHtmlDirective as SafeHtml } from '../../../../directives/safe_html/safe_html';
5
+ import { normalizeOptions } from '../../../../utils/form_options_utils';
6
6
  import GlFormCheckbox from './form_checkbox.vue';
7
7
 
8
8
  // Attributes to pass down to checks/radios instead of applying them to the group
@@ -14,7 +14,6 @@ export default {
14
14
  directives: {
15
15
  SafeHtml,
16
16
  },
17
- mixins: [formOptionsMixin],
18
17
  provide() {
19
18
  return {
20
19
  getCheckboxGroup: () => this,
@@ -98,6 +97,9 @@ export default {
98
97
  };
99
98
  },
100
99
  computed: {
100
+ formOptions() {
101
+ return normalizeOptions(this.options);
102
+ },
101
103
  computedState() {
102
104
  return isBoolean(this.state) ? this.state : null;
103
105
  },
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import { uniqueId, isBoolean, omit, pick } from 'lodash-es';
3
3
  import { looseEqual } from '../../../../utils/equality_utils';
4
- import { formOptionsMixin } from '../../../../vendor/bootstrap-vue/src/mixins/form-options';
5
4
  import { SafeHtmlDirective as SafeHtml } from '../../../../directives/safe_html/safe_html';
5
+ import { normalizeOptions } from '../../../../utils/form_options_utils';
6
6
  import GlFormRadio from '../form_radio/form_radio.vue';
7
7
 
8
8
  // Attributes to pass down to checks/radios instead of applying them to the group
@@ -16,7 +16,6 @@ export default {
16
16
  directives: {
17
17
  SafeHtml,
18
18
  },
19
- mixins: [formOptionsMixin],
20
19
  provide() {
21
20
  return {
22
21
  getRadioGroup: () => this,
@@ -101,6 +100,9 @@ export default {
101
100
  };
102
101
  },
103
102
  computed: {
103
+ formOptions() {
104
+ return normalizeOptions(this.options);
105
+ },
104
106
  computedState() {
105
107
  return isBoolean(this.state) ? this.state : null;
106
108
  },
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Normalizes a single option into a standard { value, text, html, disabled } shape.
3
+ */
4
+ function normalizeOption(option) {
5
+ if (option !== null && typeof option === 'object') {
6
+ const { value, text, html, disabled } = option;
7
+ return {
8
+ value: value === undefined ? text : value,
9
+ text: String(text),
10
+ html,
11
+ disabled: Boolean(disabled),
12
+ };
13
+ }
14
+ return {
15
+ value: option,
16
+ text: String(option),
17
+ disabled: false,
18
+ };
19
+ }
20
+
21
+ /**
22
+ * Normalizes an options array into a consistent format for rendering.
23
+ *
24
+ * Each option can be a primitive (string, number) or an object with
25
+ * `{ value, text, html, disabled }` properties. Primitives are converted
26
+ * to `{ value, text, disabled: false }`. For objects, `value` defaults to
27
+ * `text` when omitted and `disabled` defaults to `false`.
28
+ *
29
+ * @param {Array<string|number|{value?: *, text: string, html?: string, disabled?: boolean}>} options
30
+ * The raw options array to normalize.
31
+ * @returns {Array<{value: *, text: string, html?: string, disabled: boolean}>}
32
+ * The normalized options, or an empty array if the input is not an array.
33
+ */
34
+ export function normalizeOptions(options) {
35
+ if (Array.isArray(options)) {
36
+ return options.map((option) => normalizeOption(option));
37
+ }
38
+ return [];
39
+ }
@@ -20,9 +20,10 @@ import {
20
20
  CODE_UP
21
21
  } from '../../constants/key-codes'
22
22
  import {
23
- PROP_TYPE_ARRAY_OBJECT_STRING,
23
+ PROP_TYPE_ARRAY,
24
24
  PROP_TYPE_BOOLEAN,
25
25
  PROP_TYPE_NUMBER,
26
+ PROP_TYPE_OBJECT,
26
27
  PROP_TYPE_STRING
27
28
  } from '../../constants/props'
28
29
  import {
@@ -45,7 +46,6 @@ import { makeModelMixin } from '../../utils/model'
45
46
  import { toInteger } from '../../utils/number'
46
47
  import { sortKeys } from '../../utils/object'
47
48
  import { observeDom } from '../../utils/observe-dom'
48
- import { makeProp } from '../../utils/props'
49
49
  import { stableSort } from '../../utils/stable-sort'
50
50
  import { idMixin, props as idProps } from '../../mixins/id'
51
51
  import { normalizeSlotMixin } from '../../mixins/normalize-slot'
@@ -76,14 +76,41 @@ const BVTabButton = /*#__PURE__*/ extend({
76
76
  }
77
77
  },
78
78
  props: {
79
- controls: makeProp(PROP_TYPE_STRING),
80
- id: makeProp(PROP_TYPE_STRING),
81
- noKeyNav: makeProp(PROP_TYPE_BOOLEAN, false),
82
- posInSet: makeProp(PROP_TYPE_NUMBER),
83
- setSize: makeProp(PROP_TYPE_NUMBER),
79
+ controls: {
80
+ type: PROP_TYPE_STRING,
81
+ required: false,
82
+ default: undefined
83
+ },
84
+ id: {
85
+ type: PROP_TYPE_STRING,
86
+ required: false,
87
+ default: undefined
88
+ },
89
+ noKeyNav: {
90
+ type: PROP_TYPE_BOOLEAN,
91
+ required: false,
92
+ default: false
93
+ },
94
+ posInSet: {
95
+ type: PROP_TYPE_NUMBER,
96
+ required: false,
97
+ default: undefined
98
+ },
99
+ setSize: {
100
+ type: PROP_TYPE_NUMBER,
101
+ required: false,
102
+ default: undefined
103
+ },
84
104
  // Reference to the child <b-tab> instance
85
- tab: makeProp(),
86
- tabIndex: makeProp(PROP_TYPE_NUMBER)
105
+ tab: {
106
+ required: false,
107
+ default: undefined
108
+ },
109
+ tabIndex: {
110
+ type: PROP_TYPE_NUMBER,
111
+ required: false,
112
+ default: undefined
113
+ }
87
114
  },
88
115
  computed: {
89
116
  bvTabs() {
@@ -188,11 +215,31 @@ const BVTabButton = /*#__PURE__*/ extend({
188
215
 
189
216
  // --- Props ---
190
217
  const navProps = {
191
- align: makeProp(PROP_TYPE_STRING),
192
- fill: makeProp(PROP_TYPE_BOOLEAN, false),
193
- justified: makeProp(PROP_TYPE_BOOLEAN, false),
194
- pills: makeProp(PROP_TYPE_BOOLEAN, false),
195
- small: makeProp(PROP_TYPE_BOOLEAN, false)
218
+ align: {
219
+ type: PROP_TYPE_STRING,
220
+ required: false,
221
+ default: undefined
222
+ },
223
+ fill: {
224
+ type: PROP_TYPE_BOOLEAN,
225
+ required: false,
226
+ default: false
227
+ },
228
+ justified: {
229
+ type: PROP_TYPE_BOOLEAN,
230
+ required: false,
231
+ default: false
232
+ },
233
+ pills: {
234
+ type: PROP_TYPE_BOOLEAN,
235
+ required: false,
236
+ default: false
237
+ },
238
+ small: {
239
+ type: PROP_TYPE_BOOLEAN,
240
+ required: false,
241
+ default: false
242
+ }
196
243
  }
197
244
 
198
245
  export const props = sortKeys({
@@ -200,21 +247,65 @@ export const props = sortKeys({
200
247
  ...modelProps,
201
248
  ...navProps,
202
249
  // Only applied to the currently active `li`
203
- activeNavItemClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
250
+ activeNavItemClass: {
251
+ type: [PROP_TYPE_ARRAY, PROP_TYPE_OBJECT, PROP_TYPE_STRING],
252
+ required: false,
253
+ default: undefined
254
+ },
204
255
  // Only applied to the currently active `<b-tab>`
205
256
  // This prop is sniffed by the `<b-tab>` child
206
- activeTabClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
207
- contentClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
257
+ activeTabClass: {
258
+ type: [PROP_TYPE_ARRAY, PROP_TYPE_OBJECT, PROP_TYPE_STRING],
259
+ required: false,
260
+ default: undefined
261
+ },
262
+ contentClass: {
263
+ type: [PROP_TYPE_ARRAY, PROP_TYPE_OBJECT, PROP_TYPE_STRING],
264
+ required: false,
265
+ default: undefined
266
+ },
208
267
  // Synonym for 'bottom'
209
- end: makeProp(PROP_TYPE_BOOLEAN, false),
268
+ end: {
269
+ type: PROP_TYPE_BOOLEAN,
270
+ required: false,
271
+ default: false
272
+ },
210
273
  // This prop is sniffed by the `<b-tab>` child
211
- lazy: makeProp(PROP_TYPE_BOOLEAN, false),
212
- navClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
213
- navWrapperClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
214
- noFade: makeProp(PROP_TYPE_BOOLEAN, false),
215
- noKeyNav: makeProp(PROP_TYPE_BOOLEAN, false),
216
- noNavStyle: makeProp(PROP_TYPE_BOOLEAN, false),
217
- tag: makeProp(PROP_TYPE_STRING, 'div')
274
+ lazy: {
275
+ type: PROP_TYPE_BOOLEAN,
276
+ required: false,
277
+ default: false
278
+ },
279
+ navClass: {
280
+ type: [PROP_TYPE_ARRAY, PROP_TYPE_OBJECT, PROP_TYPE_STRING],
281
+ required: false,
282
+ default: undefined
283
+ },
284
+ navWrapperClass: {
285
+ type: [PROP_TYPE_ARRAY, PROP_TYPE_OBJECT, PROP_TYPE_STRING],
286
+ required: false,
287
+ default: undefined
288
+ },
289
+ noFade: {
290
+ type: PROP_TYPE_BOOLEAN,
291
+ required: false,
292
+ default: false
293
+ },
294
+ noKeyNav: {
295
+ type: PROP_TYPE_BOOLEAN,
296
+ required: false,
297
+ default: false
298
+ },
299
+ noNavStyle: {
300
+ type: PROP_TYPE_BOOLEAN,
301
+ required: false,
302
+ default: false
303
+ },
304
+ tag: {
305
+ type: PROP_TYPE_STRING,
306
+ required: false,
307
+ default: 'div'
308
+ }
218
309
  })
219
310
 
220
311
  // --- Main component ---