@gitlab/ui 129.1.2 → 129.3.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.
@@ -1,4 +1,4 @@
1
- import { uniqueId, clamp } from 'lodash-es';
1
+ import { uniqueId, isEqual, clamp } from 'lodash-es';
2
2
  import { logWarning, stopEvent } from '../../../../utils/utils';
3
3
  import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_FOCUS_CONTENT, POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, ENTER, ARROW_DOWN, ARROW_UP, END, HOME } from '../constants';
4
4
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
@@ -548,7 +548,7 @@ var script = {
548
548
  watch: {
549
549
  selected: {
550
550
  immediate: true,
551
- handler(newSelected) {
551
+ handler(newSelected, oldSelected) {
552
552
  if (Array.isArray(newSelected)) {
553
553
  if (process.env.NODE_ENV !== 'production' && !this.multiple && newSelected.length) {
554
554
  throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
@@ -557,6 +557,16 @@ var script = {
557
557
  } else {
558
558
  this.selectedValues = [newSelected];
559
559
  }
560
+ if (
561
+ // Do not emit change event immediately on watcher creation.
562
+ oldSelected !== undefined && !isEqual(newSelected, oldSelected)) {
563
+ /**
564
+ * Emitted when the selected prop value changes
565
+ *
566
+ * @event change
567
+ */
568
+ this.$emit('change');
569
+ }
560
570
  }
561
571
  },
562
572
  items: {
@@ -67,8 +67,14 @@ var script = {
67
67
  var _this$config$panels;
68
68
  return ((_this$config$panels = this.config.panels) === null || _this$config$panels === void 0 ? void 0 : _this$config$panels.length) > 0;
69
69
  },
70
+ dashboardHasTitle() {
71
+ return this.$scopedSlots.title || Boolean(this.config.title);
72
+ },
70
73
  dashboardHasDescription() {
71
74
  return this.$scopedSlots.description || Boolean(this.config.description);
75
+ },
76
+ dashboardHasHeader() {
77
+ return this.$scopedSlots.header || this.$scopedSlots.actions || this.dashboardHasTitle || this.dashboardHasDescription;
72
78
  }
73
79
  },
74
80
  methods: {
@@ -82,7 +88,7 @@ var script = {
82
88
  const __vue_script__ = script;
83
89
 
84
90
  /* template */
85
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('section',{staticClass:"gl-my-4 gl-flex gl-items-center"},[_vm._t("header",function(){return [_c('div',{staticClass:"gl-flex gl-w-full gl-flex-col"},[_c('div',{staticClass:"gl-flex gl-items-center"},[_vm._t("title",function(){return [_c('h2',{staticClass:"gl-my-0",attrs:{"data-testid":"title"}},[_vm._v(_vm._s(_vm.config.title))])]})],2),_vm._v(" "),(_vm.dashboardHasDescription)?_c('div',{staticClass:"gl-mt-3 gl-flex"},[_vm._t("description",function(){return [_c('p',{staticClass:"gl-mb-0",attrs:{"data-testid":"description"}},[_vm._v("\n "+_vm._s(_vm.config.description)+"\n ")])]})],2):_vm._e()])]}),_vm._v(" "),(_vm.$scopedSlots.actions)?_c('div',{attrs:{"data-testid":"actions-container"}},[_vm._t("actions")],2):_vm._e()],2),_vm._v(" "),_c('div',{staticClass:"gl-flex"},[_c('div',{staticClass:"gl-flex gl-min-w-0 gl-grow gl-flex-col"},[_vm._t("alert"),_vm._v(" "),(_vm.$scopedSlots.filters)?_c('section',{staticClass:"gl-flex gl-flex-row gl-flex-wrap gl-gap-5 gl-pb-3 gl-pt-4",attrs:{"data-testid":"filters-container"}},[_vm._t("filters")],2):_vm._e(),_vm._v(" "),(_vm.dashboardHasPanels)?_c('grid-layout',{staticClass:"-gl-mx-3",attrs:{"value":_vm.config,"is-static-grid":_vm.isStaticGrid,"cell-height":_vm.cellHeight,"min-cell-height":_vm.minCellHeight},on:{"input":_vm.emitChanges},scopedSlots:_vm._u([{key:"panel",fn:function(ref){
91
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.dashboardHasHeader)?_c('section',{staticClass:"gl-my-4 gl-flex gl-items-center",attrs:{"data-testid":"header-container"}},[_vm._t("header",function(){return [_c('div',{staticClass:"gl-flex gl-w-full gl-flex-col"},[(_vm.dashboardHasTitle)?_c('div',{staticClass:"gl-flex gl-items-center"},[_vm._t("title",function(){return [_c('h2',{staticClass:"gl-my-0",attrs:{"data-testid":"title"}},[_vm._v(_vm._s(_vm.config.title))])]})],2):_vm._e(),_vm._v(" "),(_vm.dashboardHasDescription)?_c('div',{staticClass:"gl-mt-3 gl-flex"},[_vm._t("description",function(){return [_c('p',{staticClass:"gl-mb-0",attrs:{"data-testid":"description"}},[_vm._v("\n "+_vm._s(_vm.config.description)+"\n ")])]})],2):_vm._e()])]}),_vm._v(" "),(_vm.$scopedSlots.actions)?_c('div',{attrs:{"data-testid":"actions-container"}},[_vm._t("actions")],2):_vm._e()],2):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-flex"},[_c('div',{staticClass:"gl-flex gl-min-w-0 gl-grow gl-flex-col"},[_vm._t("alert"),_vm._v(" "),(_vm.$scopedSlots.filters)?_c('section',{staticClass:"gl-flex gl-flex-row gl-flex-wrap gl-gap-5 gl-pb-3 gl-pt-4",attrs:{"data-testid":"filters-container"}},[_vm._t("filters")],2):_vm._e(),_vm._v(" "),(_vm.dashboardHasPanels)?_c('grid-layout',{staticClass:"-gl-mx-3",attrs:{"value":_vm.config,"is-static-grid":_vm.isStaticGrid,"cell-height":_vm.cellHeight,"min-cell-height":_vm.minCellHeight},on:{"input":_vm.emitChanges},scopedSlots:_vm._u([{key:"panel",fn:function(ref){
86
92
  var panel = ref.panel;
87
93
  return [_vm._t("panel",null,null,{ panel: panel })]}}],null,true)}):_vm._t("empty-state")],2)]),_vm._v(" "),_vm._t("footer")],2)};
88
94
  var __vue_staticRenderFns__ = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "129.1.2",
3
+ "version": "129.3.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -101,7 +101,7 @@
101
101
  "@cypress/grep": "^4.1.1",
102
102
  "@gitlab/fonts": "^1.3.1",
103
103
  "@gitlab/svgs": "*",
104
- "@jest/test-sequencer": "30.2.0",
104
+ "@jest/test-sequencer": "30.3.0",
105
105
  "@rollup/plugin-commonjs": "^28.0.9",
106
106
  "@rollup/plugin-node-resolve": "^16.0.3",
107
107
  "@rollup/plugin-replace": "^6.0.3",
@@ -132,17 +132,17 @@
132
132
  "autoprefixer": "10.4.27",
133
133
  "axe-playwright": "^2.2.2",
134
134
  "babel-loader": "^9.2.1",
135
- "cypress": "15.11.0",
135
+ "cypress": "15.12.0",
136
136
  "cypress-real-events": "^1.15.0",
137
137
  "dompurify": "^3.1.2",
138
138
  "emoji-regex": "^10.6.0",
139
139
  "gitlab-api-async-iterator": "^1.3.1",
140
140
  "glob": "11.1.0",
141
141
  "identity-obj-proxy": "^3.0.0",
142
- "jest": "30.2.0",
143
- "jest-circus": "30.2.0",
144
- "jest-environment-jsdom": "30.2.0",
145
- "jest-image-snapshot": "^6.5.1",
142
+ "jest": "30.3.0",
143
+ "jest-circus": "30.3.0",
144
+ "jest-environment-jsdom": "30.3.0",
145
+ "jest-image-snapshot": "^6.5.2",
146
146
  "merge-cobertura": "^1.0.7",
147
147
  "mockdate": "^3.0.5",
148
148
  "module-alias": "^2.3.4",
@@ -160,7 +160,7 @@
160
160
  "rollup-plugin-string": "^3.0.0",
161
161
  "rollup-plugin-svg": "^2.0.0",
162
162
  "rollup-plugin-vue": "^5.1.9",
163
- "sass": "^1.97.3",
163
+ "sass": "^1.98.0",
164
164
  "sass-loader": "^10.5.2",
165
165
  "sass-true": "^9",
166
166
  "start-server-and-test": "^2.1.5",
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { clamp, uniqueId } from 'lodash-es';
2
+ import { clamp, uniqueId, isEqual } from 'lodash-es';
3
3
  import { stopEvent, logWarning } from '../../../../utils/utils';
4
4
  import {
5
5
  GL_DROPDOWN_SHOWN,
@@ -582,7 +582,7 @@ export default {
582
582
  watch: {
583
583
  selected: {
584
584
  immediate: true,
585
- handler(newSelected) {
585
+ handler(newSelected, oldSelected) {
586
586
  if (Array.isArray(newSelected)) {
587
587
  if (process.env.NODE_ENV !== 'production' && !this.multiple && newSelected.length) {
588
588
  throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
@@ -591,6 +591,19 @@ export default {
591
591
  } else {
592
592
  this.selectedValues = [newSelected];
593
593
  }
594
+
595
+ if (
596
+ // Do not emit change event immediately on watcher creation.
597
+ oldSelected !== undefined &&
598
+ !isEqual(newSelected, oldSelected)
599
+ ) {
600
+ /**
601
+ * Emitted when the selected prop value changes
602
+ *
603
+ * @event change
604
+ */
605
+ this.$emit('change');
606
+ }
594
607
  },
595
608
  },
596
609
  items: {
@@ -67,9 +67,20 @@ export default {
67
67
  dashboardHasPanels() {
68
68
  return this.config.panels?.length > 0;
69
69
  },
70
+ dashboardHasTitle() {
71
+ return this.$scopedSlots.title || Boolean(this.config.title);
72
+ },
70
73
  dashboardHasDescription() {
71
74
  return this.$scopedSlots.description || Boolean(this.config.description);
72
75
  },
76
+ dashboardHasHeader() {
77
+ return (
78
+ this.$scopedSlots.header ||
79
+ this.$scopedSlots.actions ||
80
+ this.dashboardHasTitle ||
81
+ this.dashboardHasDescription
82
+ );
83
+ },
73
84
  },
74
85
  methods: {
75
86
  emitChanges(newConfig) {
@@ -80,12 +91,16 @@ export default {
80
91
  </script>
81
92
  <template>
82
93
  <div>
83
- <section class="gl-my-4 gl-flex gl-items-center">
94
+ <section
95
+ v-if="dashboardHasHeader"
96
+ data-testid="header-container"
97
+ class="gl-my-4 gl-flex gl-items-center"
98
+ >
84
99
  <!-- @slot Used to render custom dashboard header state. Replaces the default rendering. -->
85
100
  <slot name="header">
86
101
  <div class="gl-flex gl-w-full gl-flex-col">
87
102
  <!-- Dashboard title -->
88
- <div class="gl-flex gl-items-center">
103
+ <div v-if="dashboardHasTitle" class="gl-flex gl-items-center">
89
104
  <!-- @slot Used to render custom dashboard titles. Replaces the default rendering. -->
90
105
  <slot name="title">
91
106
  <h2 data-testid="title" class="gl-my-0">{{ config.title }}</h2>