@gitlab/ui 93.4.0 → 94.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": "93.4.0",
3
+ "version": "94.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,23 @@ like mentioned in the implementation example.
14
14
  _Full documentation for the
15
15
  `field` prop [here.](https://bootstrap-vue.org/docs/components/table#fields-column-definitions)_
16
16
 
17
+ ## Header text alignment
18
+
19
+ To align a given `TH` element's text to the right, set the `thAlignRight` property to `true` in
20
+ the fields definition. This will ensure that proper styling is applied, including when the column
21
+ is sortable.
22
+
23
+ ```js
24
+ const fields = [
25
+ {
26
+ key: "column_one",
27
+ label: __("First column"),
28
+ sortable: true,
29
+ thAlignRight: true,
30
+ },
31
+ ];
32
+ ```
33
+
17
34
  ## Use `GlTableLite` when possible
18
35
 
19
36
  If you don't need all the features of `GlTable`, like filtering, sorting, or
@@ -5,9 +5,8 @@ table.gl-table {
5
5
  tr {
6
6
  th,
7
7
  td {
8
- @apply gl-border-b-solid gl-border-b-1;
8
+ @apply gl-border-b-1 gl-p-5 gl-border-b-solid;
9
9
  border-color: var(--gl-border-color-default);
10
- @apply gl-p-5;
11
10
  @include gl-bg-transparent;
12
11
  @apply gl-leading-normal;
13
12
  @apply gl-text-base;
@@ -18,12 +17,15 @@ table.gl-table {
18
17
  @apply gl-font-bold;
19
18
  color: var(--gl-text-color-heading);
20
19
 
21
- &.gl-text-right > div {
22
- flex-direction: row-reverse;
20
+ .gl-table-th-sort-icon-wrapper {
21
+ @apply gl-ml-2;
22
+ }
23
+
24
+ &.gl-table-th-align-right > div {
25
+ @apply gl-flex-row-reverse;
23
26
 
24
- div.gl-ml-2 {
25
- @apply gl-ml-0;
26
- @apply gl-mr-2;
27
+ .gl-table-th-sort-icon-wrapper {
28
+ @apply gl-ml-0 gl-mr-2;
27
29
  }
28
30
  }
29
31
 
@@ -83,7 +85,7 @@ table.gl-table {
83
85
  }
84
86
 
85
87
  &:first-child {
86
- @apply gl-border-t-solid gl-border-t-1;
88
+ @apply gl-border-t-1 gl-border-t-solid;
87
89
  }
88
90
 
89
91
  &:not(:first-child) {
@@ -61,6 +61,22 @@ export default {
61
61
  ...Object.keys(this.$scopedSlots).filter((slotName) => slotName.startsWith('head(')),
62
62
  ];
63
63
  },
64
+ computedFields() {
65
+ return this.fields?.map((field) => {
66
+ if (typeof field === 'string') {
67
+ return field;
68
+ }
69
+ const { thAlignRight, thClass = '', ...rest } = field;
70
+ const computedThClass = Array.isArray(thClass) ? thClass : thClass.split(' ');
71
+ if (thAlignRight) {
72
+ computedThClass.push('gl-table-th-align-right');
73
+ }
74
+ return {
75
+ ...rest,
76
+ thClass: computedThClass,
77
+ };
78
+ });
79
+ },
64
80
  },
65
81
  mounted() {
66
82
  // logWarning will call isDev before logging any message
@@ -97,7 +113,7 @@ export default {
97
113
  <template>
98
114
  <b-table
99
115
  :table-class="localTableClass"
100
- :fields="fields"
116
+ :fields="computedFields"
101
117
  :sort-by.sync="localSortBy"
102
118
  :sort-desc.sync="localSortDesc"
103
119
  no-sort-reset
@@ -112,7 +128,7 @@ export default {
112
128
  <slot :name="headSlotName" v-bind="scope"
113
129
  ><span>{{ scope.label }}</span></slot
114
130
  ><template v-if="isSortable(scope)">
115
- <div class="gl-ml-2 gl-flex gl-w-5 gl-justify-center">
131
+ <div class="gl-table-th-sort-icon-wrapper gl-flex gl-w-5 gl-justify-center">
116
132
  <span
117
133
  name="sort-icon"
118
134
  data-testid="sort-icon"