@openproject/primer-view-components 0.0.0-20260202070026 → 0.0.0-20260202070538

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.
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { controller } from "@github/catalyst";
7
+ import { controller } from '@github/catalyst';
8
8
  let DataTableElement = class DataTableElement extends HTMLElement {
9
9
  constructor() {
10
10
  super();
@@ -13,19 +13,19 @@ let DataTableElement = class DataTableElement extends HTMLElement {
13
13
  sortTableByAriaSort(this.table);
14
14
  }
15
15
  toggleSort(event) {
16
- const header = event.target.closest("th");
17
- const ariaSort = header.getAttribute("aria-sort");
18
- const sortAscendingIcon = header.querySelector(".TableSortIcon--ascending");
19
- const sortDescendingIcon = header.querySelector(".TableSortIcon--descending");
20
- if (ariaSort === "descending") {
21
- header.setAttribute("aria-sort", "ascending");
22
- sortAscendingIcon?.classList.remove("d-none");
23
- sortDescendingIcon?.classList.add("d-none");
16
+ const header = event.target.closest('th');
17
+ const ariaSort = header.getAttribute('aria-sort');
18
+ const sortAscendingIcon = header.querySelector('.TableSortIcon--ascending');
19
+ const sortDescendingIcon = header.querySelector('.TableSortIcon--descending');
20
+ if (ariaSort === 'descending') {
21
+ header.setAttribute('aria-sort', 'ascending');
22
+ sortAscendingIcon?.classList.remove('d-none');
23
+ sortDescendingIcon?.classList.add('d-none');
24
24
  }
25
25
  else {
26
- header.setAttribute("aria-sort", "descending");
27
- sortDescendingIcon?.classList.remove("d-none");
28
- sortAscendingIcon?.classList.add("d-none");
26
+ header.setAttribute('aria-sort', 'descending');
27
+ sortDescendingIcon?.classList.remove('d-none');
28
+ sortAscendingIcon?.classList.add('d-none');
29
29
  }
30
30
  const siblings = Array.from(header.parentElement.children).filter((el) => el !== header && el instanceof HTMLElement);
31
31
  for (const sibling of siblings) {
@@ -34,7 +34,7 @@ let DataTableElement = class DataTableElement extends HTMLElement {
34
34
  sortTableByAriaSort(this.table);
35
35
  }
36
36
  get table() {
37
- return this.querySelector("table");
37
+ return this.querySelector('table');
38
38
  }
39
39
  };
40
40
  DataTableElement = __decorate([
@@ -42,41 +42,41 @@ DataTableElement = __decorate([
42
42
  ], DataTableElement);
43
43
  export { DataTableElement };
44
44
  function resetSort(th) {
45
- th.removeAttribute("aria-sort");
46
- const sortAscendingIcon = th.querySelector(".TableSortIcon--ascending");
47
- const sortDescendingIcon = th.querySelector(".TableSortIcon--descending");
48
- sortAscendingIcon?.classList.remove("d-none");
49
- sortDescendingIcon?.classList.add("d-none");
45
+ th.removeAttribute('aria-sort');
46
+ const sortAscendingIcon = th.querySelector('.TableSortIcon--ascending');
47
+ const sortDescendingIcon = th.querySelector('.TableSortIcon--descending');
48
+ sortAscendingIcon?.classList.remove('d-none');
49
+ sortDescendingIcon?.classList.add('d-none');
50
50
  }
51
51
  //if (!customElements.get('data-table')) {
52
52
  // customElements.define('data-table', DataTableElement);
53
53
  //}
54
54
  function sortTableByAriaSort(table) {
55
- const headers = Array.from(table.querySelectorAll("thead th"));
56
- const tbody = table.querySelector("tbody");
57
- const sortedHeader = headers.find(th => th.getAttribute("aria-sort") === "ascending" ||
58
- th.getAttribute("aria-sort") === "descending");
55
+ const headers = Array.from(table.querySelectorAll('thead th'));
56
+ const tbody = table.querySelector('tbody');
57
+ const sortedHeader = headers.find(th => th.getAttribute('aria-sort') === 'ascending' ||
58
+ th.getAttribute('aria-sort') === 'descending');
59
59
  if (!sortedHeader)
60
60
  return;
61
61
  const columnIndex = headers.indexOf(sortedHeader);
62
- const direction = sortedHeader.getAttribute("aria-sort");
63
- const rows = Array.from(tbody.querySelectorAll("tr"));
62
+ const direction = sortedHeader.getAttribute('aria-sort');
63
+ const rows = Array.from(tbody.querySelectorAll('tr'));
64
64
  const sortedRows = rows.sort((a, b) => {
65
- const aText = a.children[columnIndex].textContent?.trim() ?? "";
66
- const bText = b.children[columnIndex].textContent?.trim() ?? "";
65
+ const aText = a.children[columnIndex].textContent?.trim() ?? '';
66
+ const bText = b.children[columnIndex].textContent?.trim() ?? '';
67
67
  const aNum = parseFloat(aText);
68
68
  const bNum = parseFloat(bText);
69
69
  const valueA = Number.isNaN(aNum) ? aText : aNum;
70
70
  const valueB = Number.isNaN(bNum) ? bText : bNum;
71
71
  if (valueA < valueB)
72
- return direction === "ascending" ? -1 : 1;
72
+ return direction === 'ascending' ? -1 : 1;
73
73
  if (valueA > valueB)
74
- return direction === "ascending" ? 1 : -1;
74
+ return direction === 'ascending' ? 1 : -1;
75
75
  return 0;
76
76
  });
77
77
  tbody.append(...sortedRows);
78
78
  }
79
- if (!window.customElements.get("data-table-element")) {
79
+ if (!window.customElements.get('data-table-element')) {
80
80
  window.DataTableElement = DataTableElement;
81
- window.customElements.define("data-table-element", DataTableElement);
81
+ window.customElements.define('data-table-element', DataTableElement);
82
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openproject/primer-view-components",
3
- "version": "0.0.0-20260202070026",
3
+ "version": "0.0.0-20260202070538",
4
4
  "description": "ViewComponents of the Primer Design System for OpenProject",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",