@ansiversa/components 0.0.90 → 0.0.91

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": "@ansiversa/components",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "description": "Shared UI components and layouts for the Ansiversa ecosystem",
5
5
  "type": "module",
6
6
  "exports": {
package/src/AvTable.astro CHANGED
@@ -47,10 +47,7 @@ const dataSortDir = "data-sort-dir" in attrs ? undefined : normalizedSortDir;
47
47
  const controls = Array.from(root.querySelectorAll("[data-av-sort]"));
48
48
  if (!controls.length) return;
49
49
 
50
- function applySortState(key, dir) {
51
- root.dataset.sortKey = key || "";
52
- root.dataset.sortDir = dir || "";
53
-
50
+ function updateUI(key, dir) {
54
51
  controls.forEach((control) => {
55
52
  const sortKey = control.getAttribute("data-av-sort") || "";
56
53
  const th = control.closest("th");
@@ -72,14 +69,14 @@ const dataSortDir = "data-sort-dir" in attrs ? undefined : normalizedSortDir;
72
69
  const startKey = root.dataset.sortKey || initialSortKey;
73
70
  const startDir = root.dataset.sortDir || initialSortDir;
74
71
  if (startKey && startDir) {
75
- applySortState(startKey, startDir);
72
+ updateUI(startKey, startDir);
76
73
  }
77
74
 
78
75
  const observer = new MutationObserver(() => {
79
76
  const nextKey = root.dataset.sortKey || "";
80
77
  const nextDir = root.dataset.sortDir || "";
81
78
  if (nextKey && nextDir) {
82
- applySortState(nextKey, nextDir);
79
+ updateUI(nextKey, nextDir);
83
80
  }
84
81
  });
85
82
 
@@ -98,7 +95,9 @@ const dataSortDir = "data-sort-dir" in attrs ? undefined : normalizedSortDir;
98
95
  const currentDir = root.dataset.sortDir || "";
99
96
  const nextDir = key === currentKey ? (currentDir === "desc" ? "asc" : "desc") : defaultDir;
100
97
 
101
- applySortState(key, nextDir);
98
+ root.dataset.sortKey = key;
99
+ root.dataset.sortDir = nextDir;
100
+ updateUI(key, nextDir);
102
101
  root.dispatchEvent(new CustomEvent("av-sort", { bubbles: true, detail: { key, dir: nextDir } }));
103
102
 
104
103
  if (control.tagName === "BUTTON") {