@aurodesignsystem/auro-library 5.9.0 → 5.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Semantic Release Automated Changelog
2
2
 
3
+ # [5.11.0](https://github.com/AlaskaAirlines/auro-library/compare/v5.10.0...v5.11.0) (2026-02-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * add function for finding closest elem with defined attr [#222](https://github.com/AlaskaAirlines/auro-library/issues/222) ([e0a311d](https://github.com/AlaskaAirlines/auro-library/commit/e0a311db4b2d112d2bcfcce437e75553b16efe3e))
9
+ * new function to get nearest defined locale [#223](https://github.com/AlaskaAirlines/auro-library/issues/223) ([7562865](https://github.com/AlaskaAirlines/auro-library/commit/756286553b301bc679648f2764d23b4682304a40))
10
+
11
+ # [5.10.0](https://github.com/AlaskaAirlines/auro-library/compare/v5.9.0...v5.10.0) (2026-02-17)
12
+
13
+
14
+ ### Features
15
+
16
+ * add class for unique ID generation [#220](https://github.com/AlaskaAirlines/auro-library/issues/220) ([8b7318c](https://github.com/AlaskaAirlines/auro-library/commit/8b7318c7e08c5c5cf858352a3801a680fc63204b))
17
+
3
18
  # [5.9.0](https://github.com/AlaskaAirlines/auro-library/compare/v5.8.0...v5.9.0) (2026-01-28)
4
19
 
5
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem/auro-library",
3
- "version": "5.9.0",
3
+ "version": "5.11.0",
4
4
  "description": "This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Class for interaction with the DOM.
3
+ */
4
+ export class DomHandler {
5
+ /**
6
+ * Walk up the DOM (including Shadow DOM boundaries) to find
7
+ * the closest ancestor with a given attribute.
8
+ *
9
+ * @param {Node} startNode - The node to start from
10
+ * @param {string} attrName - Attribute name to match
11
+ * @returns {Element|null}
12
+ */
13
+ closestWithAttribute(startNode, attrName) {
14
+ let node = startNode;
15
+
16
+ while (node) {
17
+ // Only check Elements
18
+ if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute(attrName)) {
19
+ return node;
20
+ }
21
+
22
+ // Normal DOM parent
23
+ if (node.parentNode) {
24
+ node = node.parentNode;
25
+ continue;
26
+ }
27
+
28
+ // Cross Shadow DOM boundary
29
+ if (node instanceof ShadowRoot) {
30
+ node = node.host;
31
+ continue;
32
+ }
33
+
34
+ // If we're inside a shadow tree and parentNode is null
35
+ if (node.getRootNode) {
36
+ const root = node.getRootNode();
37
+ if (root instanceof ShadowRoot) {
38
+ node = root.host;
39
+ continue;
40
+ }
41
+ }
42
+
43
+ // Nothing left to traverse
44
+ node = null;
45
+ }
46
+
47
+ return null;
48
+ }
49
+
50
+ /**
51
+ * If the locale wasn't set via attribute on `elem`,
52
+ * then use the closest `data-locale` attribute crawling up the DOM tree.
53
+ * If none is found, default to 'en-US'.
54
+ */
55
+ getLocale(elem) {
56
+ let locale = "en-US";
57
+
58
+ try {
59
+ if (elem.hasAttribute("locale")) {
60
+ locale = elem.getAttribute("locale");
61
+ } else {
62
+ const closestLocaleElement = this.closestWithAttribute(
63
+ elem,
64
+ "data-locale",
65
+ );
66
+
67
+ if (closestLocaleElement) {
68
+ locale = closestLocaleElement.getAttribute("data-locale");
69
+ }
70
+ }
71
+ } catch (error) {
72
+ if (!elem) {
73
+ console.debug(
74
+ "Auro getLocale: No element provided, defaulting to 'en-US'",
75
+ );
76
+ } else {
77
+ console.debug(
78
+ "Auro getLocale: Error accessing attributes, defaulting to 'en-US'",
79
+ );
80
+ }
81
+ }
82
+
83
+ return locale;
84
+ }
85
+ }
@@ -0,0 +1 @@
1
+ export * from "./domHandler.mjs";
@@ -0,0 +1 @@
1
+ export * from "./uniqueHash.mjs";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Class for generating unique hashes based on the current timestamp.
3
+ * This can be used to create unique identifiers for elements or data within an application,
4
+ * ensuring that each identifier is distinct and can be easily generated without the need
5
+ * for external libraries or complex algorithms.
6
+ */
7
+ export class UniqueId {
8
+ /**
9
+ * Creates a unique hash based on the current timestamp.
10
+ * @returns {Function} Timestamp as a base-36 string
11
+ */
12
+ create() {
13
+ return Date.now().toString(36);
14
+ }
15
+ }