@absolutejs/beacon 0.6.37 → 0.6.39

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/dist/index.js CHANGED
@@ -2024,6 +2024,11 @@ var createBeacon = (options) => {
2024
2024
  const firstGroup = first.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
2025
2025
  return firstGroup !== null && firstGroup === second.closest(INTENTIONAL_CONTROL_GROUP_SELECTOR);
2026
2026
  };
2027
+ const crossesDialogBoundary = (first, second) => {
2028
+ const firstDialog = first.closest('[role="dialog"], dialog');
2029
+ const secondDialog = second.closest('[role="dialog"], dialog');
2030
+ return firstDialog === null !== (secondDialog === null);
2031
+ };
2027
2032
  const scanForControlCollisions = () => {
2028
2033
  const viewportWidth = document.documentElement.clientWidth;
2029
2034
  const viewportHeight = document.documentElement.clientHeight;
@@ -2054,7 +2059,7 @@ var createBeacon = (options) => {
2054
2059
  const second = controls[secondIndex];
2055
2060
  if (second === undefined)
2056
2061
  continue;
2057
- if (first.element.contains(second.element) || second.element.contains(first.element)) {
2062
+ if (first.element.contains(second.element) || second.element.contains(first.element) || crossesDialogBoundary(first.element, second.element)) {
2058
2063
  continue;
2059
2064
  }
2060
2065
  const overlapX = Math.min(first.rect.right, second.rect.right) - Math.max(first.rect.left, second.rect.left);
@@ -2359,7 +2364,31 @@ var createBeacon = (options) => {
2359
2364
  };
2360
2365
  const loadingFirstSeen = new WeakMap;
2361
2366
  const reportedStuckLoading = new WeakSet;
2367
+ const trackedLoadingIndicators = new Set;
2362
2368
  const loadingIndicatorSelector = `[aria-busy="true"], [role="progressbar"], [${BEACON_ATTRIBUTE.LOADING}]`;
2369
+ const resetLoadingIndicator = (indicator) => {
2370
+ loadingFirstSeen.delete(indicator);
2371
+ reportedStuckLoading.delete(indicator);
2372
+ trackedLoadingIndicators.delete(indicator);
2373
+ };
2374
+ const loadingLifecycleObserver = new MutationObserver((records) => {
2375
+ for (const record of records) {
2376
+ if (!(record.target instanceof Element))
2377
+ continue;
2378
+ resetLoadingIndicator(record.target);
2379
+ }
2380
+ });
2381
+ loadingLifecycleObserver.observe(document.documentElement, {
2382
+ attributeFilter: [
2383
+ "aria-busy",
2384
+ "role",
2385
+ BEACON_ATTRIBUTE.LOADING,
2386
+ BEACON_ATTRIBUTE.LOADING_TIMEOUT
2387
+ ],
2388
+ attributes: true,
2389
+ subtree: true
2390
+ });
2391
+ cleanups.push(() => loadingLifecycleObserver.disconnect());
2363
2392
  const isPersistentDeterminateProgress = (indicator) => indicator.getAttribute("role") === "progressbar" && indicator.hasAttribute("aria-valuenow") && indicator.getAttribute("aria-busy") !== "true" && !indicator.hasAttribute(BEACON_ATTRIBUTE.LOADING);
2364
2393
  const hasTrackedLoadingAncestor = (indicator) => {
2365
2394
  let ancestor = indicator.parentElement?.closest(loadingIndicatorSelector);
@@ -2381,23 +2410,27 @@ var createBeacon = (options) => {
2381
2410
  const checkStuckLoading = () => {
2382
2411
  if (document.visibilityState === "hidden")
2383
2412
  return;
2384
- const indicators = document.querySelectorAll(loadingIndicatorSelector);
2413
+ const indicators = Array.from(document.querySelectorAll(loadingIndicatorSelector));
2414
+ const activeIndicators = new Set(indicators);
2415
+ for (const tracked of trackedLoadingIndicators) {
2416
+ if (!activeIndicators.has(tracked))
2417
+ resetLoadingIndicator(tracked);
2418
+ }
2385
2419
  const now = Date.now();
2386
- for (const indicator of Array.from(indicators)) {
2387
- if (isPersistentDeterminateProgress(indicator))
2388
- continue;
2389
- if (isScanExempt(indicator))
2390
- continue;
2391
- if (hasHiddenAncestor(indicator))
2392
- continue;
2393
- if (hasTrackedLoadingAncestor(indicator))
2420
+ for (const indicator of indicators) {
2421
+ if (isPersistentDeterminateProgress(indicator) || isScanExempt(indicator) || hasHiddenAncestor(indicator) || hasTrackedLoadingAncestor(indicator)) {
2422
+ resetLoadingIndicator(indicator);
2394
2423
  continue;
2424
+ }
2395
2425
  const rect = indicator.getBoundingClientRect();
2396
- if (rect.width === 0 && rect.height === 0)
2426
+ if (rect.width === 0 && rect.height === 0) {
2427
+ resetLoadingIndicator(indicator);
2397
2428
  continue;
2429
+ }
2398
2430
  const firstSeen = loadingFirstSeen.get(indicator);
2399
2431
  if (firstSeen === undefined) {
2400
2432
  loadingFirstSeen.set(indicator, now);
2433
+ trackedLoadingIndicators.add(indicator);
2401
2434
  continue;
2402
2435
  }
2403
2436
  const deadlineMs = loadingDeadlineMs(indicator);
@@ -4134,5 +4167,5 @@ export {
4134
4167
  BEACON_ATTRIBUTE
4135
4168
  };
4136
4169
 
4137
- //# debugId=E29B0984FFB5596E64756E2164756E21
4170
+ //# debugId=D84461A5205D5FA564756E2164756E21
4138
4171
  //# sourceMappingURL=index.js.map