@1024pix/pix-ui 51.2.0 → 51.4.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,9 +1,19 @@
1
1
  {{#if this.displayHeader}}
2
- <th scope="col" ...attributes>
3
- {{yield to="header"}}
2
+ <th scope="col" ...attributes aria-sort={{this.ariaSort}}>
3
+ <div class="pix-table-header-container">
4
+ {{yield to="header"}}
5
+ {{#if this.sortable}}
6
+ <PixIconButton
7
+ @ariaLabel={{this.iconLabel}}
8
+ @iconName={{this.iconName}}
9
+ @triggerAction={{@onSort}}
10
+ @size="small"
11
+ />
12
+ {{/if}}
13
+ </div>
4
14
  </th>
5
15
  {{else}}
6
- <td ...attributes>
16
+ <td ...attributes class={{this.typeClass}}>
7
17
  {{yield to="cell"}}
8
18
  </td>
9
19
  {{/if}}
@@ -1,7 +1,87 @@
1
1
  import Component from '@glimmer/component';
2
+ import { warn } from '@ember/debug';
2
3
 
3
4
  export default class PixTableColumn extends Component {
4
5
  get displayHeader() {
5
6
  return this.args.context === 'header';
6
7
  }
8
+
9
+ get type() {
10
+ return this.args.type ?? 'text';
11
+ }
12
+
13
+ get sortable() {
14
+ return Boolean(this.args.onSort);
15
+ }
16
+
17
+ get sortOrder() {
18
+ if (this.args.sortOrder === undefined) {
19
+ return undefined;
20
+ }
21
+ const correctSortOrders = ['asc', 'desc', null];
22
+ warn(
23
+ 'PixTableColumn: you need to provide a valid sortOrder',
24
+ correctSortOrders.includes(this.args.sortOrder),
25
+ {
26
+ id: 'pix-ui.table-column.sortOrder.not-valid',
27
+ },
28
+ );
29
+ return this.args.sortOrder;
30
+ }
31
+
32
+ get iconName() {
33
+ const isText = this.type === 'text';
34
+ if (!this.sortOrder) {
35
+ return isText ? 'sortAz' : 'sort';
36
+ }
37
+ if (this.sortOrder === 'asc') {
38
+ return isText ? 'sortAzAsc' : 'sortAsc';
39
+ }
40
+ return isText ? 'sortAzDesc' : 'sortDesc';
41
+ }
42
+
43
+ get iconLabel() {
44
+ warn(
45
+ 'PixTableColumn: parameters `@ariaLabelDefaultSort`, `@ariaLabelSortDesc` and `@ariaLabelSortAsc` are required for sort buttons',
46
+ ![
47
+ this.args.ariaLabelDefaultSort,
48
+ this.args.ariaLabelSortDesc,
49
+ this.args.ariaLabelSortAsc,
50
+ ].includes(undefined),
51
+ {
52
+ id: 'pix-ui.pix-table-column.sortAriaLabels.required',
53
+ },
54
+ );
55
+ if (!this.sortOrder) {
56
+ return this.args.ariaLabelDefaultSort;
57
+ }
58
+ if (this.sortOrder === 'asc') {
59
+ return this.args.ariaLabelSortDesc;
60
+ }
61
+ return this.args.ariaLabelSortAsc;
62
+ }
63
+
64
+ get ariaSort() {
65
+ if (!this.sortable) {
66
+ return undefined;
67
+ }
68
+ if (!this.sortOrder) {
69
+ return 'none';
70
+ }
71
+ if (this.sortOrder === 'asc') {
72
+ return 'ascending';
73
+ }
74
+ return 'descending';
75
+ }
76
+
77
+ get typeClass() {
78
+ const correctTypes = ['number', 'text'];
79
+ warn('PixTableColumn: you need to provide a valid type', correctTypes.includes(this.type), {
80
+ id: 'pix-ui.table-column.type.incorrect',
81
+ });
82
+ if (this.args.type === 'number') {
83
+ return `pix-table-column--number`;
84
+ }
85
+ return '';
86
+ }
7
87
  }
@@ -1,4 +1,4 @@
1
- td.pix-table-basic-column {
1
+ .pix-table-column {
2
2
  &--number{
3
3
  text-align: right;
4
4
  }
@@ -1,4 +1,4 @@
1
- @import 'pix-table-basic-column';
1
+ @import 'pix-table-column';
2
2
 
3
3
  .pix-table {
4
4
  width: 100%;
@@ -32,8 +32,15 @@
32
32
  }
33
33
  }
34
34
 
35
+ .pix-table-header-container {
36
+ display: flex;
37
+ gap: var(--pix-spacing-1x);
38
+ align-items: center;
39
+ }
40
+
35
41
  th {
36
42
  text-align: start;
43
+ vertical-align: middle;
37
44
  }
38
45
 
39
46
  td, th {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "51.2.0",
3
+ "version": "51.4.0",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -1,8 +0,0 @@
1
- <PixTableColumn @context={{@context}} class={{this.typeClass}}>
2
- <:header>
3
- {{@name}}
4
- </:header>
5
- <:cell>
6
- {{@value}}
7
- </:cell>
8
- </PixTableColumn>
@@ -1,16 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { warn } from '@ember/debug';
3
-
4
- export default class PixTableBasicColumn extends Component {
5
- get typeClass() {
6
- const correctTypes = ['number', 'text'];
7
- const type = this.args.type ?? 'text';
8
- warn('PixTableBasicColumn: you need to provide a valid type', correctTypes.includes(type), {
9
- id: 'pix-ui.table-basic-column.type.incorrect',
10
- });
11
- if (this.args.type === 'number') {
12
- return `pix-table-basic-column--number`;
13
- }
14
- return '';
15
- }
16
- }
@@ -1 +0,0 @@
1
- export { default } from '@1024pix/pix-ui/components/pix-table-basic-column';