@citygross/components 0.15.6 → 0.15.7

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.
@@ -478,11 +478,11 @@ var makeCateringPortionsString = function (variant, cartItem, unit) {
478
478
  return qString;
479
479
  };
480
480
 
481
+ var focusableSelectors = 'button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
481
482
  var focusTrap = function (_a) {
482
483
  var _b;
483
484
  var exitFunction = _a.exitFunction, ref = _a.ref;
484
- var elements = 'button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
485
- var focusableElements = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(elements);
485
+ var focusableElements = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(focusableSelectors);
486
486
  if (focusableElements &&
487
487
  focusableElements.length > 0 &&
488
488
  focusableElements[0] instanceof HTMLElement) {
@@ -491,7 +491,7 @@ var focusTrap = function (_a) {
491
491
  var handleKeyDown = function (e) {
492
492
  if (!ref.current)
493
493
  return;
494
- var focusable = Array.from(ref.current.querySelectorAll(elements));
494
+ var focusable = Array.from(ref.current.querySelectorAll(focusableSelectors));
495
495
  if (focusable.length === 0)
496
496
  return;
497
497
  var firstElement = focusable[0];
@@ -517,6 +517,39 @@ var focusTrap = function (_a) {
517
517
  };
518
518
  };
519
519
 
520
+ var toggleInert = function (_a) {
521
+ var elements = _a.elements, isInert = _a.isInert;
522
+ var snapshots = elements
523
+ .filter(function (element) { return Boolean(element); })
524
+ .map(function (element) { return ({
525
+ element: element,
526
+ hadInert: element.hasAttribute('inert')
527
+ }); });
528
+ snapshots.forEach(function (_a) {
529
+ var element = _a.element, hadInert = _a.hadInert;
530
+ if (isInert) {
531
+ if (!hadInert) {
532
+ element.setAttribute('inert', '');
533
+ }
534
+ return;
535
+ }
536
+ if (!hadInert) {
537
+ element.removeAttribute('inert');
538
+ }
539
+ });
540
+ return function () {
541
+ snapshots.forEach(function (_a) {
542
+ var element = _a.element, hadInert = _a.hadInert;
543
+ if (hadInert) {
544
+ element.setAttribute('inert', '');
545
+ }
546
+ else {
547
+ element.removeAttribute('inert');
548
+ }
549
+ });
550
+ };
551
+ };
552
+
520
553
  var formatLeadingZero = function (day) { return day.replace(/^0+/, ''); };
521
554
 
522
555
  var formatPostalCode = function (postalCode, spaceIndex) {
@@ -18919,6 +18952,7 @@ index.__exports.capitalizedAllWords = capitalizedAllWords;
18919
18952
  index.__exports.comparisonTypes = comparisonTypes;
18920
18953
  index.__exports.emailRegex = emailRegex;
18921
18954
  index.__exports.focusTrap = focusTrap;
18955
+ index.__exports.focusableSelectors = focusableSelectors;
18922
18956
  index.__exports.formatDateToLocale = formatDateToLocale;
18923
18957
  index.__exports.formatLeadingZero = formatLeadingZero;
18924
18958
  index.__exports.formatPostalCode = formatPostalCode;
@@ -18932,6 +18966,7 @@ index.__exports.makeCateringPortionsString = makeCateringPortionsString;
18932
18966
  index.__exports.moment = moment;
18933
18967
  index.__exports.nameRegex = nameRegex;
18934
18968
  index.__exports.phoneRegex = phoneRegex;
18969
+ index.__exports.toggleInert = toggleInert;
18935
18970
  index.__exports.useDetectDevice = useDetectDevice;
18936
18971
  index.__exports.useFixedModalScroll = useFixedModalScroll;
18937
18972
  index.__exports.useOutsideClick = useOutsideClick;