@karmo-co/drift-kit-public 25.25.1 → 25.26.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/components.js CHANGED
@@ -8652,6 +8652,13 @@
8652
8652
  var a = announcers[kind];
8653
8653
  if (a && a.isConnected)
8654
8654
  return a;
8655
+ a = document.querySelector('.dk-component-toast-announcer[aria-live="' + kind + '"]');
8656
+ if (a) {
8657
+ announcers[kind] = a;
8658
+ return a;
8659
+ }
8660
+ if (!document.body)
8661
+ return null;
8655
8662
  a = document.createElement('div');
8656
8663
  a.className = 'dk-component-toast-announcer';
8657
8664
  a.setAttribute('aria-live', kind);
@@ -8666,9 +8673,17 @@
8666
8673
  }
8667
8674
  function announce(kind, text) {
8668
8675
  var a = announcer(kind);
8676
+ if (!a)
8677
+ return null;
8669
8678
  a.textContent = '';
8670
8679
  setTimeout(function () { a.textContent = text; }, 50);
8680
+ return a;
8671
8681
  }
8682
+ function prepare() { announcer('polite'); announcer('assertive'); }
8683
+ if (document.body)
8684
+ prepare();
8685
+ else
8686
+ document.addEventListener('DOMContentLoaded', prepare);
8672
8687
  function esc(s) {
8673
8688
  return String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
8674
8689
  }
@@ -8713,7 +8728,8 @@
8713
8728
  var status = STATUSES.indexOf(opts.status) > -1 ? opts.status : 'primary';
8714
8729
  var placement = PLACEMENTS.indexOf(opts.placement) > -1 ? opts.placement : (variant === 'compact' ? 'bottom-center' : 'top-right');
8715
8730
  var counter = variant === 'default' && !!opts.counter;
8716
- var duration = typeof opts.duration === 'number' ? opts.duration : (counter ? 4200 : (variant === 'compact' ? 3500 : 0));
8731
+ var sticky = status === 'error' || status === 'warning';
8732
+ var duration = typeof opts.duration === 'number' ? opts.duration : (counter ? 4200 : (variant === 'compact' && !sticky ? 3500 : 0));
8717
8733
  if (opts.dismissible === false && !(duration > 0))
8718
8734
  duration = variant === 'compact' ? 3500 : 4200;
8719
8735
  var replace = opts.replace != null ? !!opts.replace : variant === 'compact';
@@ -8763,8 +8779,7 @@
8763
8779
  [opts.title, opts.description].filter(Boolean).map(function (t, i, all) {
8764
8780
  return i < all.length - 1 && !/[.!?]$/.test(t) ? t + '.' : t;
8765
8781
  }).join(' ');
8766
- if (said)
8767
- announce(assertive ? 'assertive' : 'polite', said);
8782
+ var spoke = said ? announce(assertive ? 'assertive' : 'polite', said) : null;
8768
8783
  if (dk.component.feedbackBadge && dk.component.feedbackBadge.init)
8769
8784
  dk.component.feedbackBadge.init(el);
8770
8785
  if (dk.component.icon && dk.component.icon.init)
@@ -8817,6 +8832,8 @@
8817
8832
  if (i > -1)
8818
8833
  live.splice(i, 1);
8819
8834
  el.remove();
8835
+ if (spoke && spoke.textContent === said)
8836
+ spoke.textContent = '';
8820
8837
  if (typeof opts.onClose === 'function')
8821
8838
  opts.onClose();
8822
8839
  }
@@ -12139,16 +12156,23 @@
12139
12156
  }
12140
12157
  function clearance() {
12141
12158
  var shell = root.closest('.dk-component-app-shell');
12142
- if (!shell)
12143
- return;
12159
+ var host = shell && shell.hasAttribute('data-contained') ? shell : document.documentElement;
12144
12160
  if (presentation !== 'bar') {
12145
- shell.style.removeProperty('--_shell-bar');
12161
+ if (shell)
12162
+ shell.style.removeProperty('--_shell-bar');
12163
+ if (host.__dkBarOwner === root) {
12164
+ host.style.removeProperty('--dk-sidebar-bar-clearance');
12165
+ host.__dkBarOwner = null;
12166
+ }
12146
12167
  return;
12147
12168
  }
12148
12169
  var r = root.getBoundingClientRect();
12149
- var bottom = shell.hasAttribute('data-contained') ? shell.getBoundingClientRect().bottom : window.innerHeight;
12170
+ var bottom = shell && shell.hasAttribute('data-contained') ? shell.getBoundingClientRect().bottom : window.innerHeight;
12150
12171
  var h = Math.max(0, Math.round(bottom - r.top));
12151
- shell.style.setProperty('--_shell-bar', h + 'px');
12172
+ if (shell)
12173
+ shell.style.setProperty('--_shell-bar', h + 'px');
12174
+ host.style.setProperty('--dk-sidebar-bar-clearance', h + 'px');
12175
+ host.__dkBarOwner = root;
12152
12176
  }
12153
12177
  function focusables() {
12154
12178
  return qa(root, 'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])').filter(function (el) {
@@ -12374,6 +12398,12 @@
12374
12398
  if (more && more.__dcDropdown && more.__dcDropdown.isOpen())
12375
12399
  more.__dcDropdown.close();
12376
12400
  token = {};
12401
+ [document.documentElement, root.closest('.dk-component-app-shell')].forEach(function (h) {
12402
+ if (h && h.__dkBarOwner === root) {
12403
+ h.style.removeProperty('--dk-sidebar-bar-clearance');
12404
+ h.__dkBarOwner = null;
12405
+ }
12406
+ });
12377
12407
  delete root.__dcSidebar;
12378
12408
  }
12379
12409
  };