@aurodesignsystem/auro-library 3.0.7 → 3.0.9

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,26 @@
1
1
  # Semantic Release Automated Changelog
2
2
 
3
+ ## [3.0.9](https://github.com/AlaskaAirlines/auro-library/compare/v3.0.8...v3.0.9) (2025-02-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fix runtime error on floatingui with no trigger slot ([060c30f](https://github.com/AlaskaAirlines/auro-library/commit/060c30f3da32004e5e0d978949e7d65c661ddfed))
9
+ * lock body scroll only when bib is open in fullscreen mode ([ce5df91](https://github.com/AlaskaAirlines/auro-library/commit/ce5df91b981d7b41b9e938b7d41cc114a279cb59))
10
+ * simplify the strategy logic on `floatingUI` ([42c89db](https://github.com/AlaskaAirlines/auro-library/commit/42c89dbdf9cb48756928143b09b25aa82989dfd4))
11
+
12
+
13
+ ### Performance Improvements
14
+
15
+ * lock body's scroll while bib is open ([d78b46e](https://github.com/AlaskaAirlines/auro-library/commit/d78b46ecc689f45b75b3a5317ae029d8b3061c1e))
16
+
17
+ ## [3.0.8](https://github.com/AlaskaAirlines/auro-library/compare/v3.0.7...v3.0.8) (2025-02-05)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * temporarily comment out aria-expanded code [#105](https://github.com/AlaskaAirlines/auro-library/issues/105) ([b7cd263](https://github.com/AlaskaAirlines/auro-library/commit/b7cd2632047641d92b3557beef9450d4d9f109c2))
23
+
3
24
  ## [3.0.7](https://github.com/AlaskaAirlines/auro-library/compare/v3.0.6...v3.0.7) (2025-01-13)
4
25
 
5
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem/auro-library",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
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",
@@ -16,37 +16,23 @@ export default class AuroFloatingUI {
16
16
  }
17
17
 
18
18
  /**
19
- * @private
20
- * Adjusts the size of the bib content based on the bibSizer dimensions.
21
- *
22
- * This method retrieves the computed styles of the bibSizer element and applies them to the bib content.
23
- * If the fullscreen parameter is true, it resets the dimensions to their default values. Otherwise, it
24
- * mirrors the width and height from the bibSizer, ensuring that they are not set to zero.
25
- *
26
- * @param {boolean} fullscreen - A flag indicating whether to reset the dimensions for fullscreen mode.
27
- * If true, the bib content dimensions are cleared; if false, they are set
28
- * based on the bibSizer's computed styles.
19
+ * Mirrors the size of the bibSizer element to the bib content.
20
+ * Copies the width, height, max-width, and max-height styles from the bibSizer element to the bib content container.
21
+ * This ensures that the bib content has the same dimensions as the sizer element.
29
22
  */
30
- mirrorSize(fullscreen) {
23
+ mirrorSize() {
31
24
  // mirror the boxsize from bibSizer
32
25
  if (this.element.bibSizer) {
33
26
  const sizerStyle = window.getComputedStyle(this.element.bibSizer);
34
27
  const bibContent = this.element.bib.shadowRoot.querySelector(".container");
35
- if (fullscreen) {
36
- bibContent.style.width = '';
37
- bibContent.style.height = '';
38
- bibContent.style.maxWidth = '';
39
- bibContent.style.maxHeight = '';
40
- } else {
41
- if (sizerStyle.width !== '0px') {
42
- bibContent.style.width = sizerStyle.width;
43
- }
44
- if (sizerStyle.height !== '0px') {
45
- bibContent.style.height = sizerStyle.height;
46
- }
47
- bibContent.style.maxWidth = sizerStyle.maxWidth;
48
- bibContent.style.maxHeight = sizerStyle.maxHeight;
28
+ if (sizerStyle.width !== '0px') {
29
+ bibContent.style.width = sizerStyle.width;
30
+ }
31
+ if (sizerStyle.height !== '0px') {
32
+ bibContent.style.height = sizerStyle.height;
49
33
  }
34
+ bibContent.style.maxWidth = sizerStyle.maxWidth;
35
+ bibContent.style.maxHeight = sizerStyle.maxHeight;
50
36
  }
51
37
  }
52
38
 
@@ -62,11 +48,12 @@ export default class AuroFloatingUI {
62
48
  getPositioningStrategy() {
63
49
  let strategy = 'floating';
64
50
  if (this.element.bib.mobileFullscreenBreakpoint) {
65
- const isMobile = window.matchMedia(`(max-width: ${this.element.bib.mobileFullscreenBreakpoint})`).matches;
66
- if (isMobile) {
51
+ const smallerThanBreakpoint = window.matchMedia(`(max-width: ${this.element.bib.mobileFullscreenBreakpoint})`).matches;
52
+ if (smallerThanBreakpoint) {
67
53
  strategy = 'fullscreen';
68
54
  }
69
55
  }
56
+
70
57
  return strategy;
71
58
  }
72
59
 
@@ -80,13 +67,10 @@ export default class AuroFloatingUI {
80
67
  */
81
68
  position() {
82
69
  const strategy = this.getPositioningStrategy();
83
- if (strategy === 'fullscreen') {
84
- this.configureBibFullscreen(true);
85
- this.mirrorSize(true);
86
- } else {
87
- this.configureBibFullscreen(false);
88
- this.mirrorSize(false);
70
+ this.configureBibStrategy(strategy);
89
71
 
72
+ if (strategy === 'floating') {
73
+ this.mirrorSize();
90
74
  // Define the middlware for the floater configuration
91
75
  const middleware = [
92
76
  offset(this.element.floaterConfig.offset || 0),
@@ -109,28 +93,56 @@ export default class AuroFloatingUI {
109
93
 
110
94
  /**
111
95
  * @private
112
- * Configures the bib element for fullscreen mode based on the mobile status.
96
+ * Configures the bib element's display strategy.
113
97
  *
114
- * This method sets the 'isFullscreen' attribute on the bib element to "true" if the `isMobile` parameter is true,
115
- * and resets its position to the top-left corner of the viewport. If `isMobile` is false, it removes the
116
- * 'isFullscreen' attribute, indicating that the bib is not in fullscreen mode.
98
+ * Sets the bib to fullscreen or floating mode based on the provided strategy.
99
+ * Dispatches a 'strategy-change' event if the strategy changes.
117
100
  *
118
- * @param {boolean} isMobile - A flag indicating whether the current device is mobile.
101
+ * @param {string} strategy - The positioning strategy ('fullscreen' or 'floating').
119
102
  */
120
- configureBibFullscreen(isMobile) {
121
- if (isMobile) {
122
- this.element.bib.setAttribute('isFullscreen', "true");
103
+ configureBibStrategy(strategy) {
104
+ const prevStrategy = this.element.isBibFullscreen ? 'fullscreen' : 'floating';
105
+ if (strategy === 'fullscreen') {
106
+ this.element.isBibFullscreen = true;
123
107
  // reset the prev position
124
108
  this.element.bib.style.top = "0px";
125
109
  this.element.bib.style.left = "0px";
110
+
111
+ // reset the size that was mirroring `size` css-part
112
+ const bibContent = this.element.bib.shadowRoot.querySelector(".container");
113
+ bibContent.style.width = '';
114
+ bibContent.style.height = '';
115
+ bibContent.style.maxWidth = '';
116
+ bibContent.style.maxHeight = '';
117
+
118
+ if (this.element.isPopoverVisible) {
119
+ document.body.style.overflow = 'hidden';
120
+ }
126
121
  } else {
127
- this.element.bib.removeAttribute('isFullscreen');
122
+ this.element.isBibFullscreen = false;
123
+
124
+ document.body.style.overflow = '';
125
+ }
126
+
127
+ if (prevStrategy !== strategy) {
128
+ const event = new CustomEvent(this.eventPrefix ? `${this.eventPrefix}-strategy-change` : 'strategy-change', {
129
+ detail: {
130
+ strategy,
131
+ },
132
+ composed: true
133
+ });
134
+
135
+ this.element.dispatchEvent(event);
128
136
  }
129
137
  }
130
138
 
131
139
  updateState() {
132
140
  const isVisible = this.element.isPopoverVisible;
133
- this.element.trigger.setAttribute('aria-expanded', isVisible);
141
+
142
+ // Refactor this to apply attribute to correct focusable element
143
+ // Reference Issue: https://github.com/AlaskaAirlines/auro-library/issues/105
144
+ //
145
+ // this.element.trigger.setAttribute('aria-expanded', isVisible);
134
146
 
135
147
  if (isVisible) {
136
148
  this.element.bib.setAttribute('data-show', true);
@@ -226,6 +238,7 @@ export default class AuroFloatingUI {
226
238
  this.updateCurrentExpandedDropdown();
227
239
  this.element.isPopoverVisible = true;
228
240
  this.element.triggerChevron?.setAttribute('data-expanded', true);
241
+
229
242
  this.dispatchEventDropdownToggle();
230
243
  this.position();
231
244
 
@@ -243,6 +256,7 @@ export default class AuroFloatingUI {
243
256
  hideBib() {
244
257
  if (this.element.isPopoverVisible && !this.element.disabled && !this.element.noToggle) {
245
258
  this.element.isPopoverVisible = false;
259
+ document.body.style.overflow = '';
246
260
  this.element.triggerChevron?.removeAttribute('data-expanded');
247
261
  this.dispatchEventDropdownToggle();
248
262
  }
@@ -255,7 +269,7 @@ export default class AuroFloatingUI {
255
269
  dispatchEventDropdownToggle() {
256
270
  const event = new CustomEvent(this.eventPrefix ? `${this.eventPrefix}-toggled` : 'toggled', {
257
271
  detail: {
258
- expanded: this.isPopoverVisible,
272
+ expanded: this.element.isPopoverVisible,
259
273
  },
260
274
  composed: true
261
275
  });
@@ -272,7 +286,7 @@ export default class AuroFloatingUI {
272
286
 
273
287
  const event = new CustomEvent(this.eventPrefix ? `${this.eventPrefix}-triggerClick` : "triggerClick", {
274
288
  composed: true,
275
- details: {
289
+ detail: {
276
290
  expanded: this.element.isPopoverVisible
277
291
  }
278
292
  });
@@ -325,6 +339,12 @@ export default class AuroFloatingUI {
325
339
  }
326
340
  }
327
341
 
342
+ /**
343
+ * Manages the tabIndex of the trigger element based on its focusability.
344
+ *
345
+ * If the trigger element or any of its children are inherently focusable, the tabIndex of the component is set to -1.
346
+ * This prevents the component itself from being focusable when the trigger element already handles focus.
347
+ */
328
348
  handleTriggerTabIndex() {
329
349
  const focusableElementSelectors = [
330
350
  'a',
@@ -339,6 +359,9 @@ export default class AuroFloatingUI {
339
359
  ];
340
360
 
341
361
  const triggerNode = this.element.querySelectorAll('[slot="trigger"]')[0];
362
+ if (!triggerNode) {
363
+ return;
364
+ }
342
365
  const triggerNodeTagName = triggerNode.tagName.toLowerCase();
343
366
 
344
367
  focusableElementSelectors.forEach((selector) => {
@@ -367,12 +390,13 @@ export default class AuroFloatingUI {
367
390
 
368
391
  this.handleTriggerTabIndex();
369
392
 
370
- this.element.trigger.addEventListener('keydown', (event) => this.handleEvent(event));
371
- this.element.trigger.addEventListener('click', (event) => this.handleEvent(event));
372
- this.element.trigger.addEventListener('mouseenter', (event) => this.handleEvent(event));
373
- this.element.trigger.addEventListener('mouseleave', (event) => this.handleEvent(event));
374
- this.element.trigger.addEventListener('focus', (event) => this.handleEvent(event));
375
- this.element.trigger.addEventListener('blur', (event) => this.handleEvent(event));
393
+ this.handleEvent = this.handleEvent.bind(this);
394
+ this.element.trigger.addEventListener('keydown', this.handleEvent);
395
+ this.element.trigger.addEventListener('click', this.handleEvent);
396
+ this.element.trigger.addEventListener('mouseenter', this.handleEvent);
397
+ this.element.trigger.addEventListener('mouseleave', this.handleEvent);
398
+ this.element.trigger.addEventListener('focus', this.handleEvent);
399
+ this.element.trigger.addEventListener('blur', this.handleEvent);
376
400
  }
377
401
 
378
402
  disconnect() {
@@ -381,12 +405,12 @@ export default class AuroFloatingUI {
381
405
 
382
406
  // Remove event & keyboard listeners
383
407
  if (this.element?.trigger) {
384
- this.element.trigger.removeEventListener('keydown', (event) => this.handleEvent(event));
385
- this.element.trigger.removeEventListener('click', (event) => this.handleEvent(event));
386
- this.element.trigger.removeEventListener('mouseenter', (event) => this.handleEvent(event));
387
- this.element.trigger.removeEventListener('mouseleave', (event) => this.handleEvent(event));
388
- this.element.trigger.removeEventListener('focus', (event) => this.handleEvent(event));
389
- this.element.trigger.removeEventListener('blur', (event) => this.handleEvent(event));
408
+ this.element.trigger.removeEventListener('keydown', this.handleEvent);
409
+ this.element.trigger.removeEventListener('click', this.handleEvent);
410
+ this.element.trigger.removeEventListener('mouseenter', this.handleEvent);
411
+ this.element.trigger.removeEventListener('mouseleave', this.handleEvent);
412
+ this.element.trigger.removeEventListener('focus', this.handleEvent);
413
+ this.element.trigger.removeEventListener('blur', this.handleEvent);
390
414
  }
391
415
  }
392
416
  }
@@ -55,10 +55,15 @@ export class AuroTemplateFiller {
55
55
  const npmStart = pName.indexOf('@');
56
56
  const namespaceStart = pName.indexOf('/');
57
57
  const nameStart = pName.indexOf('-');
58
+ const packageNamespace = pName.substring(namespaceStart + 1, nameStart);
59
+
60
+ if (nameStart === -1) {
61
+ throw new Error(`No name can be derived from package.json "name" field: '${pName}'. Expected pattern with \`-\` split like [\`@aurodesignsystem/auro-component\` or \`@aurodesignsystem/eslint-config\`, etc.]`);
62
+ }
58
63
 
59
64
  this.values = {
60
65
  'npm': pName.substring(npmStart, namespaceStart),
61
- 'namespace': pName.substring(namespaceStart + 1, nameStart),
66
+ 'namespace': packageNamespace,
62
67
  'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
63
68
  'name': pName.substring(nameStart + 1),
64
69
  'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
@@ -90,7 +95,10 @@ export class AuroTemplateFiller {
90
95
  }, {
91
96
  helpers: {
92
97
  'capitalize': (str) => str.charAt(0).toUpperCase() + str.slice(1),
98
+ // Hard codes `auro-*` with whatever string is passed in.
93
99
  'withAuroNamespace': (str) => `auro-${str}`,
100
+ // Recreats the string from package.json: auro-component, eslint-config, etc.
101
+ 'packageName': () => `${this.values['namespace']}-${this.values['name']}`
94
102
  }
95
103
  })
96
104