@roadtrip/components 3.41.2 → 3.42.1

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.
Files changed (44) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/road-badge_14.cjs.entry.js +1612 -12
  3. package/dist/cjs/road-badge_14.cjs.entry.js.map +1 -1
  4. package/dist/cjs/road-card.cjs.entry.js +46 -16
  5. package/dist/cjs/road-card.cjs.entry.js.map +1 -1
  6. package/dist/cjs/road-navbar-v2.cjs.entry.js.map +1 -1
  7. package/dist/cjs/roadtrip.cjs.js +1 -1
  8. package/dist/collection/components/button/button.css +76 -5
  9. package/dist/collection/components/button/button.js +26 -1
  10. package/dist/collection/components/button/button.js.map +1 -1
  11. package/dist/collection/components/button/button.stories.js +67 -0
  12. package/dist/collection/components/card/card.css +58 -11
  13. package/dist/collection/components/card/card.js +90 -20
  14. package/dist/collection/components/card/card.js.map +1 -1
  15. package/dist/collection/components/card/card.stories.js +330 -75
  16. package/dist/collection/components/drawer/drawer.js +31 -10
  17. package/dist/collection/components/drawer/drawer.js.map +1 -1
  18. package/dist/esm/loader.js +1 -1
  19. package/dist/esm/road-badge_14.entry.js +1612 -12
  20. package/dist/esm/road-badge_14.entry.js.map +1 -1
  21. package/dist/esm/road-card.entry.js +46 -16
  22. package/dist/esm/road-card.entry.js.map +1 -1
  23. package/dist/esm/road-navbar-v2.entry.js.map +1 -1
  24. package/dist/esm/roadtrip.js +1 -1
  25. package/dist/html.html-data.json +12 -0
  26. package/dist/roadtrip/p-d89d49b2.entry.js +2 -0
  27. package/dist/roadtrip/p-d89d49b2.entry.js.map +1 -0
  28. package/dist/roadtrip/p-f46b6488.entry.js +18 -0
  29. package/dist/roadtrip/p-f46b6488.entry.js.map +1 -0
  30. package/dist/roadtrip/p-fdcebcc3.entry.js.map +1 -1
  31. package/dist/roadtrip/roadtrip.css +1 -1
  32. package/dist/roadtrip/roadtrip.esm.js +1 -1
  33. package/dist/roadtrip/roadtrip.esm.js.map +1 -1
  34. package/dist/types/components/button/button.d.ts +4 -0
  35. package/dist/types/components/card/card.d.ts +15 -5
  36. package/dist/types/components/drawer/drawer.d.ts +9 -4
  37. package/dist/types/components.d.ts +28 -4
  38. package/hydrate/index.js +1663 -29
  39. package/hydrate/index.mjs +1663 -29
  40. package/package.json +2 -1
  41. package/dist/roadtrip/p-36f8563a.entry.js +0 -2
  42. package/dist/roadtrip/p-36f8563a.entry.js.map +0 -1
  43. package/dist/roadtrip/p-d8dd3342.entry.js +0 -10
  44. package/dist/roadtrip/p-d8dd3342.entry.js.map +0 -1
package/hydrate/index.mjs CHANGED
@@ -3613,7 +3613,7 @@ class Banner {
3613
3613
  }; }
3614
3614
  }
3615
3615
 
3616
- const buttonCss = ":host{--border-radius:0.25rem;--font-size:var(--road-button-medium);--margin-bottom:1rem;--padding-start:1.5rem;--padding-end:1.5rem;box-sizing:border-box;display:inline-flex;display:-webkit-inline-flex;align-items:center;justify-content:center;height:3rem;padding:0;margin-bottom:var(--margin-bottom);font-family:var(--road-font, sans-serif);font-size:var(--font-size);font-weight:700;line-height:1.375;color:var(--road-grey-10);text-decoration:none;white-space:nowrap;vertical-align:middle;background:transparent;border:1px solid transparent;border-radius:var(--border-radius);transition:background 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}:host(:hover){text-decoration:none}:host(.focus-visible){text-decoration:underline;outline:auto}.button-native{position:relative;display:flex;flex-flow:row nowrap;flex-shrink:0;align-items:center;justify-content:center;width:100%;height:100%;padding:0 var(--padding-end) 0 var(--padding-start);margin:0;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;color:inherit;text-align:inherit;text-decoration:none;text-indent:inherit;text-overflow:inherit;text-transform:inherit;letter-spacing:inherit;white-space:inherit;cursor:pointer;background:transparent;border:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}:host(.btn-default:not([disabled]).focus-visible){background:var(--road-grey-80)}:host(.btn-primary){color:var(--road-on-button-primary);background:var(--road-button-primary)}:host(.btn-primary) ::slotted(road-icon){color:var(--road-on-button-primary)}:host(.btn-primary:not([disabled]):hover),:host(.btn-primary:not([disabled]).focus-visible){background:var(--road-button-primary-variant);outline:0}:host(.btn-secondary){color:var(--road-on-button-secondary);background:var(--road-button-secondary)}:host(.btn-secondary) ::slotted(road-icon){color:var(--road-on-button-secondary)}:host(.btn-secondary:not([disabled]):hover),:host(.btn-secondary:not([disabled]).focus-visible){background:var(--road-button-secondary-variant)}:host(.btn-destructive){color:var(--road-on-button-destructive-primary);background:var(--road-button-destructive-primary)}:host(.btn-destructive) ::slotted(road-icon){color:var(--road-on-button-destructive-primary)}:host(.btn-destructive:not([disabled]):hover),:host(.btn-destructive:not([disabled]).focus-visible){background:var(--road-button-destructive-primary-variant)}:host(.btn-link){font-weight:400;color:var(--road-link-primary);text-decoration:underline;background:transparent}:host(.btn-link:not([disabled]):hover),:host(.btn-link:not([disabled]).focus-visible){color:var(--road-primary-30)}:host(.btn-outline-primary),:host(.btn-outline-secondary),:host(.btn-outline-default),:host(.btn-outline-destructive){background:transparent}:host(.btn-outline-default){color:var(--road-on-surface-weak);background:var(--road-surface);border-color:var(--road-input-outline)}:host(.btn-outline-default) ::slotted(road-icon){color:var(--road-on-surface-weak)}:host(.btn-outline-default:hover),:host(.btn-outline-default.focus-visible){background:var(--road-grey-80)}:host(.btn-ghost){color:var(--road-on-button-ghost)}:host(.btn-ghost) ::slotted(road-icon){color:var(--road-on-button-ghost)}:host(.btn-ghost:hover),:host(.btn-ghost.focus-visible){background:var(--road-button-ghost-variant)}:host([aria-disabled].btn-outline-primary){background:none}:host(.btn-outline-primary){color:var(--road-button-primary);border-color:var(--road-button-tertiary-outline)}:host(.btn-outline-primary) ::slotted(road-icon){color:var(--road-button-primary)}:host(.btn-outline-primary:hover),:host(.btn-outline-primary.focus-visible){background:var(--road-button-tertiary-variant)}:host(.btn-outline-secondary){color:var(--road-button-secondary);border-color:var(--road-button-secondary)}:host(.btn-outline-secondary) ::slotted(road-icon){color:var(--road-button-secondary)}:host(.btn-outline-secondary:hover),:host(.btn-outline-secondary.focus-visible){background:var(--road-button-tertiary-variant)}:host(.btn-outline-destructive){color:var(--road-on-button-destructive-secondary);border-color:var(--road-button-destructive-outline)}:host(.btn-outline-destructive) ::slotted(road-icon){color:var(--road-on-button-destructive-secondary)}:host(.btn-outline-destructive:hover),:host(.btn-outline-destructive.focus-visible){background:var(--road-button-destructive-secondary-variant)}:host([aria-disabled]){color:var(--road-on-surface-disabled);pointer-events:none;cursor:not-allowed;background-color:var(--road-surface-disabled);border-color:1px solid var(--road-surface-disabled)}:host([aria-disabled]) ::slotted(road-icon){color:var(--road-on-surface-disabled)}.button-native:disabled{cursor:not-allowed}::slotted([slot=\"start\"]){margin-right:0.5rem}::slotted([slot=\"end\"]){margin-left:0.5rem}:host(.btn-xl){height:3.5rem}:host(.btn-xl) ::slotted(road-icon){width:2rem;height:2rem}:host(.btn-icon.btn-xl){width:56px}:host(.btn-lg){height:3rem}:host(.btn-lg) ::slotted(road-icon){width:2rem;height:2rem}:host(.btn-icon.btn-lg){width:48px}:host(.btn-md){--font-size:var(--road-font-size-14);height:2.5rem}:host(.btn-md) ::slotted(road-icon){width:1.5rem;height:1.5rem}:host(.btn-icon.btn-md){width:40px}:host(.btn-sm){--font-size:var(--road-font-size-14);height:2rem}:host(.btn-sm) ::slotted(road-icon){width:1.25rem;height:1.25rem}:host(.btn-icon.btn-sm){width:32px}:host(.btn-block){width:100%}:host(.btn-icon) .button-native{padding:0}::slotted(road-badge){position:absolute;top:4px;left:calc(50% + 0.375rem);box-sizing:border-box;height:auto}";
3616
+ const buttonCss = ":host{--border-radius:0.25rem;--font-size:var(--road-button-medium);--margin-bottom:1rem;--padding-start:1.5rem;--padding-end:1.5rem;box-sizing:border-box;display:inline-flex;display:-webkit-inline-flex;align-items:center;justify-content:center;height:3rem;padding:0;margin-bottom:var(--margin-bottom);font-family:var(--road-font, sans-serif);font-size:var(--font-size);font-weight:700;line-height:1.375;color:var(--road-grey-10);text-decoration:none;white-space:nowrap;vertical-align:middle;background:transparent;border:1px solid transparent;border-radius:var(--border-radius);transition:background 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}:host(:hover){text-decoration:none}:host(.focus-visible){text-decoration:underline;outline:auto}.button-native{position:relative;display:flex;flex-flow:row nowrap;flex-shrink:0;align-items:center;justify-content:center;width:100%;height:100%;padding:0 var(--padding-end) 0 var(--padding-start);margin:0;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;color:inherit;text-align:inherit;text-decoration:none;text-indent:inherit;text-overflow:inherit;text-transform:inherit;letter-spacing:inherit;white-space:inherit;cursor:pointer;background:transparent;border:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}:host(.btn-default:not([disabled]).focus-visible){background:var(--road-grey-80)}:host(.btn-primary){color:var(--road-on-button-primary);background:var(--road-button-primary)}:host(.btn-primary) ::slotted(road-icon){color:var(--road-on-button-primary)}:host(.btn-primary:not([disabled]):hover),:host(.btn-primary:not([disabled]).focus-visible){background:var(--road-button-primary-variant);outline:0}:host(.btn-secondary){color:var(--road-on-button-secondary);background:var(--road-button-secondary)}:host(.btn-secondary) ::slotted(road-icon){color:var(--road-on-button-secondary)}:host(.btn-secondary:not([disabled]):hover),:host(.btn-secondary:not([disabled]).focus-visible){background:var(--road-button-secondary-variant)}:host(.btn-destructive){color:var(--road-on-button-destructive-primary);background:var(--road-button-destructive-primary)}:host(.btn-destructive) ::slotted(road-icon){color:var(--road-on-button-destructive-primary)}:host(.btn-destructive:not([disabled]):hover),:host(.btn-destructive:not([disabled]).focus-visible){background:var(--road-button-destructive-primary-variant)}:host(.btn-link){font-weight:400;color:var(--road-link-primary);text-decoration:underline;background:transparent}:host(.btn-link:not([disabled]):hover),:host(.btn-link:not([disabled]).focus-visible){color:var(--road-primary-30)}:host(.btn-outline-primary),:host(.btn-outline-secondary),:host(.btn-outline-default),:host(.btn-outline-destructive){background:transparent}:host(.btn-outline-default){color:var(--road-on-surface-weak);background:var(--road-surface);border-color:var(--road-input-outline)}:host(.btn-outline-default) ::slotted(road-icon){color:var(--road-on-surface-weak)}:host(.btn-outline-default:hover),:host(.btn-outline-default.focus-visible){background:var(--road-grey-80)}:host(.btn-outline-default.focus-visible),:host(.btn-outline-default:focus-visible){background:var(--road-surface-disabled);outline-offset:1px;outline:2px solid var(--road-outline)}:host(.btn-outline-default) .button-native:focus,:host(.btn-outline-default) .button-native:focus-visible{outline:none}:host(.btn-ghost){color:var(--road-on-button-ghost)}:host(.btn-ghost:not(.btn-inverse):hover){background:var(--road-button-ghost-variant)}:host(.btn-ghost:not(.btn-inverse).focus-visible),:host(.btn-ghost:not(.btn-inverse):focus-visible){background:var(--road-button-ghost-variant);outline-offset:1px;outline:2px solid var(--road-button-ghost-variant)}:host(.btn-ghost:not(.btn-inverse)) .button-native:focus,:host(.btn-ghost:not(.btn-inverse)) .button-native:focus-visible{outline:none}:host(.btn-outline-ghost:not(.btn-inverse):hover){background:var(--road-surface-disabled)}:host(.btn-outline-ghost:not(.btn-inverse).focus-visible),:host(.btn-outline-ghost:not(.btn-inverse):focus-visible){border:1px solid var(--road-outline);background:var(--road-surface-disabled);outline-offset:1px;outline:2px solid var(--road-outline)}:host(.btn-outline-ghost:not(.btn-inverse)) .button-native:focus,:host(.btn-outline-ghost:not(.btn-inverse)) .button-native:focus-visible{outline:none}:host(.btn-inverse) .button-native:focus,:host(.btn-inverse) .button-native:focus-visible{outline:none}:host(.btn-inverse) ::slotted(road-icon){color:var(--road-on-button-ghost)}:host(.btn-inverse:hover){outline:1px solid var(--road-on-header-surface)}:host(.btn-inverse.focus-visible),:host(.btn-inverse:focus-visible),:host(.btn-inverse:focus){outline:thick double var(--road-on-header-surface)}:host([aria-disabled].btn-inverse){border:1px solid var(--road-on-header-surface-disabled);background:var(--road-on-header-surface-disabled)}:host([aria-disabled].btn-inverse) ::slotted(road-icon){color:var(--road-on-header-surface-disabled)}:host([aria-disabled].btn-outline-primary){background:none}:host(.btn-outline-primary){color:var(--road-button-primary);border-color:var(--road-button-tertiary-outline)}:host(.btn-outline-primary) ::slotted(road-icon){color:var(--road-button-primary)}:host(.btn-outline-primary:hover),:host(.btn-outline-primary.focus-visible){background:var(--road-button-tertiary-variant)}:host(.btn-outline-secondary){color:var(--road-button-secondary);border-color:var(--road-button-secondary)}:host(.btn-outline-secondary) ::slotted(road-icon){color:var(--road-button-secondary)}:host(.btn-outline-secondary:hover),:host(.btn-outline-secondary.focus-visible){background:var(--road-button-tertiary-variant)}:host(.btn-outline-destructive){color:var(--road-on-button-destructive-secondary);border-color:var(--road-button-destructive-outline)}:host(.btn-outline-destructive) ::slotted(road-icon){color:var(--road-on-button-destructive-secondary)}:host(.btn-outline-destructive:hover),:host(.btn-outline-destructive.focus-visible){background:var(--road-button-destructive-secondary-variant)}:host([aria-disabled]){color:var(--road-on-surface-disabled);pointer-events:none;cursor:not-allowed;background-color:var(--road-surface-disabled);border-color:1px solid var(--road-surface-disabled)}:host([aria-disabled]) ::slotted(road-icon){color:var(--road-on-surface-disabled)}.button-native:disabled{cursor:not-allowed}::slotted([slot=\"start\"]){margin-right:0.5rem}::slotted([slot=\"end\"]){margin-left:0.5rem}:host(.btn-xl){height:3.5rem}:host(.btn-xl) ::slotted(road-icon){width:2rem;height:2rem}:host(.btn-icon.btn-xl){width:56px}:host(.btn-lg){height:3rem}:host(.btn-lg) ::slotted(road-icon){width:2rem;height:2rem}:host(.btn-icon.btn-lg){width:48px}:host(.btn-md){--font-size:var(--road-font-size-14);height:2.5rem}:host(.btn-md) ::slotted(road-icon){width:1.5rem;height:1.5rem}:host(.btn-icon.btn-md){width:40px}:host(.btn-sm){--font-size:var(--road-font-size-14);height:2rem}:host(.btn-sm) ::slotted(road-icon){width:1.25rem;height:1.25rem}:host(.btn-icon.btn-sm){width:32px}:host(.btn-block){width:100%}:host(.btn-icon) .button-native{padding:0}::slotted(road-badge){position:absolute;top:4px;left:calc(50% + 0.375rem);box-sizing:border-box;height:auto}";
3617
3617
  var RoadButtonStyle0 = buttonCss;
3618
3618
 
3619
3619
  /**
@@ -3643,6 +3643,10 @@ class Button$1 {
3643
3643
  * The type of the button.
3644
3644
  */
3645
3645
  this.buttonType = 'button';
3646
+ /**
3647
+ * If `true`, the button will use inverse colors (when in headers or dark backgrounds).
3648
+ */
3649
+ this.inverse = false;
3646
3650
  /**
3647
3651
  * If `true`, display only an icon in the button.
3648
3652
  */
@@ -3700,7 +3704,8 @@ class Button$1 {
3700
3704
  const sizeClass = this.size !== undefined ? `btn-${this.size}` : '';
3701
3705
  const expandClass = this.expand ? 'btn-block' : '';
3702
3706
  const iconOnlyClass = this.iconOnly ? 'btn-icon' : '';
3703
- return (hAsync(Host, { key: '79d849dd58e95934ff3ab4c9c5b5edd65fb4c899', class: [colorClass, sizeClass, expandClass, iconOnlyClass].filter(Boolean).join(' '), onClick: this.onClick, "aria-disabled": disabled ? 'true' : null }, hAsync(TagType, Object.assign({ key: '764448aaf4c6c221563aa2d9b00c0b55c0fdea21' }, attrs, { class: "button-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur }), hAsync("slot", { key: '54a7978f6da8b45b48db0ab31cec66d592172e90', name: "start" }), hAsync("slot", { key: '09f29be168b254fa9e3d73273938493d14cbca2f' }), hAsync("slot", { key: '8a014e7ebeed34446a89729ff771ac0a7c97639e', name: "end" }))));
3707
+ const inverseClass = this.inverse ? 'btn-inverse' : '';
3708
+ return (hAsync(Host, { key: '10bf8a00e2cf0abe8a3116ed54c9bce15fae6b0f', class: [colorClass, sizeClass, expandClass, iconOnlyClass, inverseClass].filter(Boolean).join(' '), onClick: this.onClick, "aria-disabled": disabled ? 'true' : null }, hAsync(TagType, Object.assign({ key: 'b4d651d32195f88f6958d3261cd88ee46476ea95' }, attrs, { class: "button-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur }), hAsync("slot", { key: '8e931be9fcf7a6894ed71921f110c3726d2a4215', name: "start" }), hAsync("slot", { key: '4a26d78cb726e7487e8ac5fb5006b7b7c70185b3' }), hAsync("slot", { key: 'a8f44025e68ce0142b3eee4991d9c86bb22233ee', name: "end" }))));
3704
3709
  }
3705
3710
  get el() { return getElement(this); }
3706
3711
  static get style() { return RoadButtonStyle0; }
@@ -3711,6 +3716,7 @@ class Button$1 {
3711
3716
  "color": [1],
3712
3717
  "size": [513],
3713
3718
  "buttonType": [1, "button-type"],
3719
+ "inverse": [4],
3714
3720
  "iconOnly": [516, "icon-only"],
3715
3721
  "disabled": [516],
3716
3722
  "expand": [516],
@@ -3849,7 +3855,7 @@ class ButtonBar {
3849
3855
  }; }
3850
3856
  }
3851
3857
 
3852
- const cardCss = ":host{position:relative;box-sizing:border-box;display:block;margin-bottom:var(--margin-bottom, 1rem);background:var(--road-surface);border:1px solid var(--road-outline-weak);border-radius:var(--road-spacing-02)}:host(.card-elevation-none){box-shadow:none}:host(.card-elevation-lowest){box-shadow:var(--road-elevation-lowest)}:host(.card-elevation-average){box-shadow:var(--road-elevation-average)}.card-native{box-sizing:border-box;display:block;width:100%;height:100%;padding:var(--road-spacing-06);margin:0;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;color:inherit;text-align:center;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;letter-spacing:inherit;white-space:inherit;background:var(--road-surface);border:0;border-radius:0.25rem;outline:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}.card-native:focus{border:1px solid var(--road-primary)}a,button{cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}::slotted(road-icon){text-align:center}";
3858
+ const cardCss = ":host{position:relative;box-sizing:border-box;display:block;margin-bottom:var(--margin-bottom, 1rem);background:var(--road-surface);border:1px solid var(--road-outline-weak);border-radius:var(--road-spacing-02);padding:var(--road-spacing-03)}:host(.card-elevation-none){box-shadow:none}:host(.card-elevation-lowest){box-shadow:var(--road-elevation-lowest)}:host(.card-elevation-average){box-shadow:var(--road-elevation-average)}:host(.is-button){border:1px solid var(--road-outline)}:host(.is-button:hover){border:1px solid var(--road-outline-variant);outline:2px solid var(--road-button-ghost-variant)}:host(.is-button:focus-visible),:host(.is-button:focus){border:1px solid var(--road-outline);outline-offset:1px;outline:2px solid var(--road-outline-variant)}:host(.is-button.is-disabled){cursor:not-allowed;pointer-events:none;border:1px solid var(--road-surface-disabled);background:var(--road-surface-disabled)}:host(.is-button.is-disabled) .card-native,:host(.is-button.selected.is-disabled) .card-native{background:none}:host(.is-button.selected){border:2px solid var(--road-primary);outline:none}:host(.is-button.selected:hover){border:2px solid var(--road-outline-variant);outline:2px solid var(--road-button-ghost-variant)}:host(.is-button.selected:focus-visible),:host(.is-button.selected:focus){border:2px solid var(--road-outline-variant);outline-offset:1px;outline:2px solid var(--road-outline-variant)}:host(.is-button.selected.is-disabled){cursor:not-allowed;pointer-events:none;outline:none;background:var(--road-surface-disabled);border:2px solid var(--road-surface-disabled)}.card-native{box-sizing:border-box;display:block;width:100%;height:100%;padding:var(--road-spacing-06);margin:0;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;color:inherit;text-align:center;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;letter-spacing:inherit;white-space:inherit;background:var(--road-surface);border:0;border-radius:0.25rem;outline:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}a,button{cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}::slotted(road-icon){text-align:center}";
3853
3859
  var RoadCardStyle0 = cardCss;
3854
3860
 
3855
3861
  /**
@@ -3863,45 +3869,71 @@ class Card {
3863
3869
  this.roadcardclick = createEvent(this, "roadcardclick", 7);
3864
3870
  this.roadCardClick = createEvent(this, "roadCardClick", 7);
3865
3871
  /**
3866
- * The elevation.
3867
- */
3868
- this.elevation = 'none';
3872
+ * The elevation.
3873
+ */
3874
+ this.elevation = "none";
3869
3875
  /**
3870
3876
  * If `true`, a button tag will be rendered and the card will be tappable.
3871
3877
  */
3872
3878
  this.button = false;
3879
+ /**
3880
+ * If `true`, the card has the `selected` state and the `selected` class is applied on the host.
3881
+ * Toggled automatically when the card is clicked (when clickable).
3882
+ */
3883
+ this.selected = false;
3884
+ /**
3885
+ * If `true`, the card is disabled and cannot be clicked.
3886
+ * Only applies when in button mode (button=true and no href).
3887
+ */
3888
+ this.disabled = false;
3873
3889
  /**
3874
3890
  * The type of the button. Only used when an `onclick` or `button` property is present.
3875
3891
  */
3876
- this.type = 'button';
3877
- this.onClick = () => {
3892
+ this.type = "button";
3893
+ this.onClick = (e) => {
3878
3894
  var _a, _b;
3895
+ // If disabled in button mode, prevent all interactions
3896
+ const isButtonMode = this.button && this.href === undefined;
3897
+ if (isButtonMode && this.disabled) {
3898
+ e.preventDefault();
3899
+ e.stopPropagation();
3900
+ return;
3901
+ }
3902
+ // Toggle selected state on click for clickable cards
3903
+ this.selected = !this.selected;
3879
3904
  if (this.value !== undefined) {
3880
3905
  this.roadcardclick.emit({
3881
3906
  value: this.value,
3882
- label: (_a = this.el.querySelector('road-label')) === null || _a === void 0 ? void 0 : _a.textContent,
3907
+ label: (_a = this.el.querySelector("road-label")) === null || _a === void 0 ? void 0 : _a.textContent,
3883
3908
  });
3884
3909
  this.roadCardClick.emit({
3885
3910
  value: this.value,
3886
- label: (_b = this.el.querySelector('road-label')) === null || _b === void 0 ? void 0 : _b.textContent,
3911
+ label: (_b = this.el.querySelector("road-label")) === null || _b === void 0 ? void 0 : _b.textContent,
3887
3912
  });
3888
3913
  }
3889
3914
  };
3890
3915
  }
3891
3916
  isClickable() {
3892
- return (this.href !== undefined || this.button);
3917
+ return this.href !== undefined || this.button;
3893
3918
  }
3894
3919
  renderCard() {
3895
3920
  const clickable = this.isClickable();
3896
3921
  if (!clickable) {
3897
- return [
3898
- hAsync("slot", null)
3899
- ];
3922
+ return [hAsync("slot", null)];
3900
3923
  }
3901
3924
  const { href } = this;
3902
- const TagType = clickable ? (href === undefined ? 'button' : 'a') : 'div';
3903
- const attrs = (TagType === 'button')
3904
- ? { type: this.type }
3925
+ const TagType = clickable
3926
+ ? href === undefined
3927
+ ? "button"
3928
+ : "a"
3929
+ : "div";
3930
+ const isButtonMode = this.button && href === undefined;
3931
+ const attrs = TagType === "button"
3932
+ ? {
3933
+ type: this.type,
3934
+ disabled: isButtonMode && this.disabled,
3935
+ "aria-disabled": isButtonMode && this.disabled ? "true" : undefined,
3936
+ }
3905
3937
  : {
3906
3938
  download: this.download,
3907
3939
  href: this.href,
@@ -3912,8 +3944,12 @@ class Card {
3912
3944
  }
3913
3945
  render() {
3914
3946
  const { elevation } = this;
3947
+ const isButtonMode = this.button && this.href === undefined;
3915
3948
  const elevationClass = this.elevation ? `card-elevation-${elevation}` : ``;
3916
- return (hAsync(Host, { key: 'f5bd5b9245b805dbd174a96b76b349af87e4e938', class: `${elevationClass}` }, this.renderCard()));
3949
+ const selectedClass = this.selected ? "selected" : "";
3950
+ const isButtonClass = isButtonMode ? "is-button" : "";
3951
+ const disabledClass = isButtonMode && this.disabled ? "is-disabled" : "";
3952
+ return (hAsync(Host, { key: '5ef381ca3d9d8028cc1e3a10cc06511602964437', class: `${elevationClass} ${selectedClass} ${isButtonClass} ${disabledClass}` }, this.renderCard()));
3917
3953
  }
3918
3954
  get el() { return getElement(this); }
3919
3955
  static get style() { return RoadCardStyle0; }
@@ -3924,6 +3960,8 @@ class Card {
3924
3960
  "elevation": [1],
3925
3961
  "button": [4],
3926
3962
  "value": [1],
3963
+ "selected": [516],
3964
+ "disabled": [516],
3927
3965
  "type": [1],
3928
3966
  "download": [1],
3929
3967
  "href": [1],
@@ -3932,7 +3970,7 @@ class Card {
3932
3970
  },
3933
3971
  "$listeners$": undefined,
3934
3972
  "$lazyBundleId$": "-",
3935
- "$attrsToReflect$": []
3973
+ "$attrsToReflect$": [["selected", "selected"], ["disabled", "disabled"]]
3936
3974
  }; }
3937
3975
  }
3938
3976
 
@@ -11332,6 +11370,1586 @@ class Dialog {
11332
11370
  }; }
11333
11371
  }
11334
11372
 
11373
+ /*!
11374
+ * tabbable 6.3.0
11375
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
11376
+ */
11377
+ // NOTE: separate `:not()` selectors has broader browser support than the newer
11378
+ // `:not([inert], [inert] *)` (Feb 2023)
11379
+ // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
11380
+ // the entire query to fail, resulting in no nodes found, which will break a lot
11381
+ // of things... so we have to rely on JS to identify nodes inside an inert container
11382
+ var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
11383
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
11384
+ var NoElement = typeof Element === 'undefined';
11385
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
11386
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
11387
+ var _element$getRootNode;
11388
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
11389
+ } : function (element) {
11390
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
11391
+ };
11392
+
11393
+ /**
11394
+ * Determines if a node is inert or in an inert ancestor.
11395
+ * @param {Element} [node]
11396
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
11397
+ * see if any of them are inert. If false, only `node` itself is considered.
11398
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
11399
+ * False if `node` is falsy.
11400
+ */
11401
+ var _isInert = function isInert(node, lookUp) {
11402
+ var _node$getAttribute;
11403
+ if (lookUp === void 0) {
11404
+ lookUp = true;
11405
+ }
11406
+ // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
11407
+ // JS API property; we have to check the attribute, which can either be empty or 'true';
11408
+ // if it's `null` (not specified) or 'false', it's an active element
11409
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');
11410
+ var inert = inertAtt === '' || inertAtt === 'true';
11411
+
11412
+ // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
11413
+ // if it weren't for `matches()` not being a function on shadow roots; the following
11414
+ // code works for any kind of node
11415
+ // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
11416
+ // so it likely would not support `:is([inert] *)` either...
11417
+ var result = inert || lookUp && node && _isInert(node.parentNode); // recursive
11418
+
11419
+ return result;
11420
+ };
11421
+
11422
+ /**
11423
+ * Determines if a node's content is editable.
11424
+ * @param {Element} [node]
11425
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
11426
+ */
11427
+ var isContentEditable = function isContentEditable(node) {
11428
+ var _node$getAttribute2;
11429
+ // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
11430
+ // to use the attribute directly to check for this, which can either be empty or 'true';
11431
+ // if it's `null` (not specified) or 'false', it's a non-editable element
11432
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');
11433
+ return attValue === '' || attValue === 'true';
11434
+ };
11435
+
11436
+ /**
11437
+ * @param {Element} el container to check in
11438
+ * @param {boolean} includeContainer add container to check
11439
+ * @param {(node: Element) => boolean} filter filter candidates
11440
+ * @returns {Element[]}
11441
+ */
11442
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
11443
+ // even if `includeContainer=false`, we still have to check it for inertness because
11444
+ // if it's inert, all its children are inert
11445
+ if (_isInert(el)) {
11446
+ return [];
11447
+ }
11448
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
11449
+ if (includeContainer && matches.call(el, candidateSelector)) {
11450
+ candidates.unshift(el);
11451
+ }
11452
+ candidates = candidates.filter(filter);
11453
+ return candidates;
11454
+ };
11455
+
11456
+ /**
11457
+ * @callback GetShadowRoot
11458
+ * @param {Element} element to check for shadow root
11459
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
11460
+ */
11461
+
11462
+ /**
11463
+ * @callback ShadowRootFilter
11464
+ * @param {Element} shadowHostNode the element which contains shadow content
11465
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
11466
+ */
11467
+
11468
+ /**
11469
+ * @typedef {Object} CandidateScope
11470
+ * @property {Element} scopeParent contains inner candidates
11471
+ * @property {Element[]} candidates list of candidates found in the scope parent
11472
+ */
11473
+
11474
+ /**
11475
+ * @typedef {Object} IterativeOptions
11476
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
11477
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
11478
+ * or a boolean stating if it has an undisclosed shadow root
11479
+ * @property {(node: Element) => boolean} filter filter candidates
11480
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
11481
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
11482
+ */
11483
+
11484
+ /**
11485
+ * @param {Element[]} elements list of element containers to match candidates from
11486
+ * @param {boolean} includeContainer add container list to check
11487
+ * @param {IterativeOptions} options
11488
+ * @returns {Array.<Element|CandidateScope>}
11489
+ */
11490
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
11491
+ var candidates = [];
11492
+ var elementsToCheck = Array.from(elements);
11493
+ while (elementsToCheck.length) {
11494
+ var element = elementsToCheck.shift();
11495
+ if (_isInert(element, false)) {
11496
+ // no need to look up since we're drilling down
11497
+ // anything inside this container will also be inert
11498
+ continue;
11499
+ }
11500
+ if (element.tagName === 'SLOT') {
11501
+ // add shadow dom slot scope (slot itself cannot be focusable)
11502
+ var assigned = element.assignedElements();
11503
+ var content = assigned.length ? assigned : element.children;
11504
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
11505
+ if (options.flatten) {
11506
+ candidates.push.apply(candidates, nestedCandidates);
11507
+ } else {
11508
+ candidates.push({
11509
+ scopeParent: element,
11510
+ candidates: nestedCandidates
11511
+ });
11512
+ }
11513
+ } else {
11514
+ // check candidate element
11515
+ var validCandidate = matches.call(element, candidateSelector);
11516
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
11517
+ candidates.push(element);
11518
+ }
11519
+
11520
+ // iterate over shadow content if possible
11521
+ var shadowRoot = element.shadowRoot ||
11522
+ // check for an undisclosed shadow
11523
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
11524
+
11525
+ // no inert look up because we're already drilling down and checking for inertness
11526
+ // on the way down, so all containers to this root node should have already been
11527
+ // vetted as non-inert
11528
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
11529
+ if (shadowRoot && validShadowRoot) {
11530
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
11531
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
11532
+ // child candidates found because they're likely slotted elements (elements that are
11533
+ // children of the web component element (which has the shadow), in the light dom, but
11534
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
11535
+ // _after_ we return from this recursive call
11536
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
11537
+ if (options.flatten) {
11538
+ candidates.push.apply(candidates, _nestedCandidates);
11539
+ } else {
11540
+ candidates.push({
11541
+ scopeParent: element,
11542
+ candidates: _nestedCandidates
11543
+ });
11544
+ }
11545
+ } else {
11546
+ // there's not shadow so just dig into the element's (light dom) children
11547
+ // __without__ giving the element special scope treatment
11548
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
11549
+ }
11550
+ }
11551
+ }
11552
+ return candidates;
11553
+ };
11554
+
11555
+ /**
11556
+ * @private
11557
+ * Determines if the node has an explicitly specified `tabindex` attribute.
11558
+ * @param {HTMLElement} node
11559
+ * @returns {boolean} True if so; false if not.
11560
+ */
11561
+ var hasTabIndex = function hasTabIndex(node) {
11562
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
11563
+ };
11564
+
11565
+ /**
11566
+ * Determine the tab index of a given node.
11567
+ * @param {HTMLElement} node
11568
+ * @returns {number} Tab order (negative, 0, or positive number).
11569
+ * @throws {Error} If `node` is falsy.
11570
+ */
11571
+ var getTabIndex = function getTabIndex(node) {
11572
+ if (!node) {
11573
+ throw new Error('No node provided');
11574
+ }
11575
+ if (node.tabIndex < 0) {
11576
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
11577
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
11578
+ // yet they are still part of the regular tab order; in FF, they get a default
11579
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
11580
+ // order, consider their tab index to be 0.
11581
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
11582
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
11583
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
11584
+ return 0;
11585
+ }
11586
+ }
11587
+ return node.tabIndex;
11588
+ };
11589
+
11590
+ /**
11591
+ * Determine the tab index of a given node __for sort order purposes__.
11592
+ * @param {HTMLElement} node
11593
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
11594
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
11595
+ * inserted into the correct sort position.
11596
+ * @returns {number} Tab order (negative, 0, or positive number).
11597
+ */
11598
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
11599
+ var tabIndex = getTabIndex(node);
11600
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
11601
+ return 0;
11602
+ }
11603
+ return tabIndex;
11604
+ };
11605
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
11606
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
11607
+ };
11608
+ var isInput = function isInput(node) {
11609
+ return node.tagName === 'INPUT';
11610
+ };
11611
+ var isHiddenInput = function isHiddenInput(node) {
11612
+ return isInput(node) && node.type === 'hidden';
11613
+ };
11614
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
11615
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
11616
+ return child.tagName === 'SUMMARY';
11617
+ });
11618
+ return r;
11619
+ };
11620
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
11621
+ for (var i = 0; i < nodes.length; i++) {
11622
+ if (nodes[i].checked && nodes[i].form === form) {
11623
+ return nodes[i];
11624
+ }
11625
+ }
11626
+ };
11627
+ var isTabbableRadio = function isTabbableRadio(node) {
11628
+ if (!node.name) {
11629
+ return true;
11630
+ }
11631
+ var radioScope = node.form || getRootNode(node);
11632
+ var queryRadios = function queryRadios(name) {
11633
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
11634
+ };
11635
+ var radioSet;
11636
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
11637
+ radioSet = queryRadios(window.CSS.escape(node.name));
11638
+ } else {
11639
+ try {
11640
+ radioSet = queryRadios(node.name);
11641
+ } catch (err) {
11642
+ // eslint-disable-next-line no-console
11643
+ console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
11644
+ return false;
11645
+ }
11646
+ }
11647
+ var checked = getCheckedRadio(radioSet, node.form);
11648
+ return !checked || checked === node;
11649
+ };
11650
+ var isRadio = function isRadio(node) {
11651
+ return isInput(node) && node.type === 'radio';
11652
+ };
11653
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
11654
+ return isRadio(node) && !isTabbableRadio(node);
11655
+ };
11656
+
11657
+ // determines if a node is ultimately attached to the window's document
11658
+ var isNodeAttached = function isNodeAttached(node) {
11659
+ var _nodeRoot;
11660
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
11661
+ // (but NOT _the_ document; see second 'If' comment below for more).
11662
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
11663
+ // is attached, and the one we need to check if it's in the document or not (because the
11664
+ // shadow, and all nodes it contains, is never considered in the document since shadows
11665
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
11666
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
11667
+ // visibility, including all the nodes it contains). The host could be any normal node,
11668
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
11669
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
11670
+ // tested).
11671
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
11672
+ // that is attached (or find none) because the node might be in nested shadows...
11673
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
11674
+ // document (per the docs) and while it's a Document-type object, that document does not
11675
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
11676
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
11677
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
11678
+ // node is actually detached.
11679
+ // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
11680
+ // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
11681
+ // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
11682
+ // `ownerDocument` will be `null`, hence the optional chaining on it.
11683
+ var nodeRoot = node && getRootNode(node);
11684
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
11685
+
11686
+ // in some cases, a detached node will return itself as the root instead of a document or
11687
+ // shadow root object, in which case, we shouldn't try to look further up the host chain
11688
+ var attached = false;
11689
+ if (nodeRoot && nodeRoot !== node) {
11690
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
11691
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
11692
+ while (!attached && nodeRootHost) {
11693
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
11694
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
11695
+ // which means we need to get the host's host and check if that parent host is contained
11696
+ // in (i.e. attached to) the document
11697
+ nodeRoot = getRootNode(nodeRootHost);
11698
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
11699
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
11700
+ }
11701
+ }
11702
+ return attached;
11703
+ };
11704
+ var isZeroArea = function isZeroArea(node) {
11705
+ var _node$getBoundingClie = node.getBoundingClientRect(),
11706
+ width = _node$getBoundingClie.width,
11707
+ height = _node$getBoundingClie.height;
11708
+ return width === 0 && height === 0;
11709
+ };
11710
+ var isHidden = function isHidden(node, _ref) {
11711
+ var displayCheck = _ref.displayCheck,
11712
+ getShadowRoot = _ref.getShadowRoot;
11713
+ if (displayCheck === 'full-native') {
11714
+ if ('checkVisibility' in node) {
11715
+ // Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
11716
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
11717
+ var visible = node.checkVisibility({
11718
+ // Checking opacity might be desirable for some use cases, but natively,
11719
+ // opacity zero elements _are_ focusable and tabbable.
11720
+ checkOpacity: false,
11721
+ opacityProperty: false,
11722
+ contentVisibilityAuto: true,
11723
+ visibilityProperty: true,
11724
+ // This is an alias for `visibilityProperty`. Contemporary browsers
11725
+ // support both. However, this alias has wider browser support (Chrome
11726
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
11727
+ // we include it anyway.
11728
+ checkVisibilityCSS: true
11729
+ });
11730
+ return !visible;
11731
+ }
11732
+ // Fall through to manual visibility checks
11733
+ }
11734
+
11735
+ // NOTE: visibility will be `undefined` if node is detached from the document
11736
+ // (see notes about this further down), which means we will consider it visible
11737
+ // (this is legacy behavior from a very long way back)
11738
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
11739
+ // _visibility_ check, not a _display_ check
11740
+ if (getComputedStyle(node).visibility === 'hidden') {
11741
+ return true;
11742
+ }
11743
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
11744
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
11745
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
11746
+ return true;
11747
+ }
11748
+ if (!displayCheck || displayCheck === 'full' ||
11749
+ // full-native can run this branch when it falls through in case
11750
+ // Element#checkVisibility is unsupported
11751
+ displayCheck === 'full-native' || displayCheck === 'legacy-full') {
11752
+ if (typeof getShadowRoot === 'function') {
11753
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
11754
+ // 'non-zero-area' fallback
11755
+ var originalNode = node;
11756
+ while (node) {
11757
+ var parentElement = node.parentElement;
11758
+ var rootNode = getRootNode(node);
11759
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
11760
+ ) {
11761
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
11762
+ // fall back to a non-zero-area test
11763
+ return isZeroArea(node);
11764
+ } else if (node.assignedSlot) {
11765
+ // iterate up slot
11766
+ node = node.assignedSlot;
11767
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
11768
+ // cross shadow boundary
11769
+ node = rootNode.host;
11770
+ } else {
11771
+ // iterate up normal dom
11772
+ node = parentElement;
11773
+ }
11774
+ }
11775
+ node = originalNode;
11776
+ }
11777
+ // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
11778
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
11779
+ // it might be a falsy value, which means shadow DOM support is disabled
11780
+
11781
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
11782
+ // now we can just test to see if it would normally be visible or not, provided it's
11783
+ // attached to the main document.
11784
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
11785
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
11786
+
11787
+ if (isNodeAttached(node)) {
11788
+ // this works wherever the node is: if there's at least one client rect, it's
11789
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
11790
+ // node itself is hidden in place of its contents; and there's no need to search
11791
+ // up the hierarchy either
11792
+ return !node.getClientRects().length;
11793
+ }
11794
+
11795
+ // Else, the node isn't attached to the document, which means the `getClientRects()`
11796
+ // API will __always__ return zero rects (this can happen, for example, if React
11797
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
11798
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
11799
+ //
11800
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
11801
+ // because styles are only computed for nodes that are in the document.
11802
+ //
11803
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
11804
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
11805
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
11806
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
11807
+ // considering __everything__ to be visible because of the innability to determine styles.
11808
+ //
11809
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
11810
+ // nodes as visible with the 'none' fallback.__
11811
+ if (displayCheck !== 'legacy-full') {
11812
+ return true; // hidden
11813
+ }
11814
+ // else, fallback to 'none' mode and consider the node visible
11815
+ } else if (displayCheck === 'non-zero-area') {
11816
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
11817
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
11818
+ // client rect, we don't special-case for whether the node is attached or not. In
11819
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
11820
+ // times, and that includes attached or not.
11821
+ return isZeroArea(node);
11822
+ }
11823
+
11824
+ // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
11825
+ // it's visible
11826
+ return false;
11827
+ };
11828
+
11829
+ // form fields (nested) inside a disabled fieldset are not focusable/tabbable
11830
+ // unless they are in the _first_ <legend> element of the top-most disabled
11831
+ // fieldset
11832
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
11833
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
11834
+ var parentNode = node.parentElement;
11835
+ // check if `node` is contained in a disabled <fieldset>
11836
+ while (parentNode) {
11837
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
11838
+ // look for the first <legend> among the children of the disabled <fieldset>
11839
+ for (var i = 0; i < parentNode.children.length; i++) {
11840
+ var child = parentNode.children.item(i);
11841
+ // when the first <legend> (in document order) is found
11842
+ if (child.tagName === 'LEGEND') {
11843
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
11844
+ // return whether `node` is a descendant of its first <legend>
11845
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
11846
+ }
11847
+ }
11848
+ // the disabled <fieldset> containing `node` has no <legend>
11849
+ return true;
11850
+ }
11851
+ parentNode = parentNode.parentElement;
11852
+ }
11853
+ }
11854
+
11855
+ // else, node's tabbable/focusable state should not be affected by a fieldset's
11856
+ // enabled/disabled state
11857
+ return false;
11858
+ };
11859
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
11860
+ if (node.disabled ||
11861
+ // we must do an inert look up to filter out any elements inside an inert ancestor
11862
+ // because we're limited in the type of selectors we can use in JSDom (see related
11863
+ // note related to `candidateSelectors`)
11864
+ _isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
11865
+ // For a details element with a summary, the summary element gets the focus
11866
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
11867
+ return false;
11868
+ }
11869
+ return true;
11870
+ };
11871
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
11872
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
11873
+ return false;
11874
+ }
11875
+ return true;
11876
+ };
11877
+ var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
11878
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
11879
+ if (isNaN(tabIndex) || tabIndex >= 0) {
11880
+ return true;
11881
+ }
11882
+ // If a custom element has an explicit negative tabindex,
11883
+ // browsers will not allow tab targeting said element's children.
11884
+ return false;
11885
+ };
11886
+
11887
+ /**
11888
+ * @param {Array.<Element|CandidateScope>} candidates
11889
+ * @returns Element[]
11890
+ */
11891
+ var _sortByOrder = function sortByOrder(candidates) {
11892
+ var regularTabbables = [];
11893
+ var orderedTabbables = [];
11894
+ candidates.forEach(function (item, i) {
11895
+ var isScope = !!item.scopeParent;
11896
+ var element = isScope ? item.scopeParent : item;
11897
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
11898
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
11899
+ if (candidateTabindex === 0) {
11900
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
11901
+ } else {
11902
+ orderedTabbables.push({
11903
+ documentOrder: i,
11904
+ tabIndex: candidateTabindex,
11905
+ item: item,
11906
+ isScope: isScope,
11907
+ content: elements
11908
+ });
11909
+ }
11910
+ });
11911
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
11912
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
11913
+ return acc;
11914
+ }, []).concat(regularTabbables);
11915
+ };
11916
+ var tabbable = function tabbable(container, options) {
11917
+ options = options || {};
11918
+ var candidates;
11919
+ if (options.getShadowRoot) {
11920
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
11921
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
11922
+ flatten: false,
11923
+ getShadowRoot: options.getShadowRoot,
11924
+ shadowRootFilter: isShadowRootTabbable
11925
+ });
11926
+ } else {
11927
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
11928
+ }
11929
+ return _sortByOrder(candidates);
11930
+ };
11931
+ var focusable = function focusable(container, options) {
11932
+ options = options || {};
11933
+ var candidates;
11934
+ if (options.getShadowRoot) {
11935
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
11936
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
11937
+ flatten: true,
11938
+ getShadowRoot: options.getShadowRoot
11939
+ });
11940
+ } else {
11941
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
11942
+ }
11943
+ return candidates;
11944
+ };
11945
+ var isTabbable = function isTabbable(node, options) {
11946
+ options = options || {};
11947
+ if (!node) {
11948
+ throw new Error('No node provided');
11949
+ }
11950
+ if (matches.call(node, candidateSelector) === false) {
11951
+ return false;
11952
+ }
11953
+ return isNodeMatchingSelectorTabbable(options, node);
11954
+ };
11955
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
11956
+ var isFocusable = function isFocusable(node, options) {
11957
+ options = options || {};
11958
+ if (!node) {
11959
+ throw new Error('No node provided');
11960
+ }
11961
+ if (matches.call(node, focusableCandidateSelector) === false) {
11962
+ return false;
11963
+ }
11964
+ return isNodeMatchingSelectorFocusable(options, node);
11965
+ };
11966
+
11967
+ /*!
11968
+ * focus-trap 7.6.6
11969
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
11970
+ */
11971
+
11972
+ function _arrayLikeToArray(r, a) {
11973
+ (null == a || a > r.length) && (a = r.length);
11974
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
11975
+ return n;
11976
+ }
11977
+ function _arrayWithoutHoles(r) {
11978
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
11979
+ }
11980
+ function _defineProperty(e, r, t) {
11981
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
11982
+ value: t,
11983
+ enumerable: true,
11984
+ configurable: true,
11985
+ writable: true
11986
+ }) : e[r] = t, e;
11987
+ }
11988
+ function _iterableToArray(r) {
11989
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
11990
+ }
11991
+ function _nonIterableSpread() {
11992
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
11993
+ }
11994
+ function ownKeys(e, r) {
11995
+ var t = Object.keys(e);
11996
+ if (Object.getOwnPropertySymbols) {
11997
+ var o = Object.getOwnPropertySymbols(e);
11998
+ r && (o = o.filter(function (r) {
11999
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
12000
+ })), t.push.apply(t, o);
12001
+ }
12002
+ return t;
12003
+ }
12004
+ function _objectSpread2(e) {
12005
+ for (var r = 1; r < arguments.length; r++) {
12006
+ var t = null != arguments[r] ? arguments[r] : {};
12007
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
12008
+ _defineProperty(e, r, t[r]);
12009
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
12010
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
12011
+ });
12012
+ }
12013
+ return e;
12014
+ }
12015
+ function _toConsumableArray(r) {
12016
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
12017
+ }
12018
+ function _toPrimitive(t, r) {
12019
+ if ("object" != typeof t || !t) return t;
12020
+ var e = t[Symbol.toPrimitive];
12021
+ if (void 0 !== e) {
12022
+ var i = e.call(t, r);
12023
+ if ("object" != typeof i) return i;
12024
+ throw new TypeError("@@toPrimitive must return a primitive value.");
12025
+ }
12026
+ return ("string" === r ? String : Number)(t);
12027
+ }
12028
+ function _toPropertyKey(t) {
12029
+ var i = _toPrimitive(t, "string");
12030
+ return "symbol" == typeof i ? i : i + "";
12031
+ }
12032
+ function _unsupportedIterableToArray(r, a) {
12033
+ if (r) {
12034
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
12035
+ var t = {}.toString.call(r).slice(8, -1);
12036
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
12037
+ }
12038
+ }
12039
+
12040
+ var activeFocusTraps = {
12041
+ activateTrap: function activateTrap(trapStack, trap) {
12042
+ if (trapStack.length > 0) {
12043
+ var activeTrap = trapStack[trapStack.length - 1];
12044
+ if (activeTrap !== trap) {
12045
+ activeTrap._setPausedState(true);
12046
+ }
12047
+ }
12048
+ var trapIndex = trapStack.indexOf(trap);
12049
+ if (trapIndex === -1) {
12050
+ trapStack.push(trap);
12051
+ } else {
12052
+ // move this existing trap to the front of the queue
12053
+ trapStack.splice(trapIndex, 1);
12054
+ trapStack.push(trap);
12055
+ }
12056
+ },
12057
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
12058
+ var trapIndex = trapStack.indexOf(trap);
12059
+ if (trapIndex !== -1) {
12060
+ trapStack.splice(trapIndex, 1);
12061
+ }
12062
+ if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
12063
+ trapStack[trapStack.length - 1]._setPausedState(false);
12064
+ }
12065
+ }
12066
+ };
12067
+ var isSelectableInput = function isSelectableInput(node) {
12068
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
12069
+ };
12070
+ var isEscapeEvent = function isEscapeEvent(e) {
12071
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
12072
+ };
12073
+ var isTabEvent = function isTabEvent(e) {
12074
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
12075
+ };
12076
+
12077
+ // checks for TAB by default
12078
+ var isKeyForward = function isKeyForward(e) {
12079
+ return isTabEvent(e) && !e.shiftKey;
12080
+ };
12081
+
12082
+ // checks for SHIFT+TAB by default
12083
+ var isKeyBackward = function isKeyBackward(e) {
12084
+ return isTabEvent(e) && e.shiftKey;
12085
+ };
12086
+ var delay = function delay(fn) {
12087
+ return setTimeout(fn, 0);
12088
+ };
12089
+
12090
+ /**
12091
+ * Get an option's value when it could be a plain value, or a handler that provides
12092
+ * the value.
12093
+ * @param {*} value Option's value to check.
12094
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
12095
+ * @returns {*} The `value`, or the handler's returned value.
12096
+ */
12097
+ var valueOrHandler = function valueOrHandler(value) {
12098
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12099
+ params[_key - 1] = arguments[_key];
12100
+ }
12101
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
12102
+ };
12103
+ var getActualTarget = function getActualTarget(event) {
12104
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
12105
+ // shadow host. However, event.target.composedPath() will be an array of
12106
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
12107
+ // outer-most (the host HTML document). If we have access to composedPath(),
12108
+ // then use its first element; otherwise, fall back to event.target (and
12109
+ // this only works for an _open_ shadow DOM; otherwise,
12110
+ // composedPath()[0] === event.target always).
12111
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
12112
+ };
12113
+
12114
+ // NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
12115
+ // current instance use the same stack if `userOptions.trapStack` isn't specified
12116
+ var internalTrapStack = [];
12117
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
12118
+ // SSR: a live trap shouldn't be created in this type of environment so this
12119
+ // should be safe code to execute if the `document` option isn't specified
12120
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
12121
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
12122
+ var config = _objectSpread2({
12123
+ returnFocusOnDeactivate: true,
12124
+ escapeDeactivates: true,
12125
+ delayInitialFocus: true,
12126
+ isKeyForward: isKeyForward,
12127
+ isKeyBackward: isKeyBackward
12128
+ }, userOptions);
12129
+ var state = {
12130
+ // containers given to createFocusTrap()
12131
+ // @type {Array<HTMLElement>}
12132
+ containers: [],
12133
+ // list of objects identifying tabbable nodes in `containers` in the trap
12134
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
12135
+ // is active, but the trap should never get to a state where there isn't at least one group
12136
+ // with at least one tabbable node in it (that would lead to an error condition that would
12137
+ // result in an error being thrown)
12138
+ // @type {Array<{
12139
+ // container: HTMLElement,
12140
+ // tabbableNodes: Array<HTMLElement>, // empty if none
12141
+ // focusableNodes: Array<HTMLElement>, // empty if none
12142
+ // posTabIndexesFound: boolean,
12143
+ // firstTabbableNode: HTMLElement|undefined,
12144
+ // lastTabbableNode: HTMLElement|undefined,
12145
+ // firstDomTabbableNode: HTMLElement|undefined,
12146
+ // lastDomTabbableNode: HTMLElement|undefined,
12147
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
12148
+ // }>}
12149
+ containerGroups: [],
12150
+ // same order/length as `containers` list
12151
+
12152
+ // references to objects in `containerGroups`, but only those that actually have
12153
+ // tabbable nodes in them
12154
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
12155
+ // the same length
12156
+ tabbableGroups: [],
12157
+ nodeFocusedBeforeActivation: null,
12158
+ mostRecentlyFocusedNode: null,
12159
+ active: false,
12160
+ paused: false,
12161
+ manuallyPaused: false,
12162
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
12163
+ // has been delayed during activation
12164
+ delayInitialFocusTimer: undefined,
12165
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
12166
+ recentNavEvent: undefined
12167
+ };
12168
+ var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
12169
+
12170
+ /**
12171
+ * Gets a configuration option value.
12172
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
12173
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
12174
+ * @param {string} optionName Name of the option whose value is sought.
12175
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
12176
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
12177
+ */
12178
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
12179
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
12180
+ };
12181
+
12182
+ /**
12183
+ * Finds the index of the container that contains the element.
12184
+ * @param {HTMLElement} element
12185
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
12186
+ * the event's composed path is used to see if includes any known trap containers in the
12187
+ * case where the element is inside a Shadow DOM.
12188
+ * @returns {number} Index of the container in either `state.containers` or
12189
+ * `state.containerGroups` (the order/length of these lists are the same); -1
12190
+ * if the element isn't found.
12191
+ */
12192
+ var findContainerIndex = function findContainerIndex(element, event) {
12193
+ var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
12194
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
12195
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
12196
+ // and we still need to find the element in there
12197
+ return state.containerGroups.findIndex(function (_ref) {
12198
+ var container = _ref.container,
12199
+ tabbableNodes = _ref.tabbableNodes;
12200
+ return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any
12201
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
12202
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
12203
+ // look inside web components even if open)
12204
+ composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
12205
+ return node === element;
12206
+ });
12207
+ });
12208
+ };
12209
+
12210
+ /**
12211
+ * Gets the node for the given option, which is expected to be an option that
12212
+ * can be either a DOM node, a string that is a selector to get a node, `false`
12213
+ * (if a node is explicitly NOT given), or a function that returns any of these
12214
+ * values.
12215
+ * @param {string} optionName
12216
+ * @param {Object} options
12217
+ * @param {boolean} [options.hasFallback] True if the option could be a selector string
12218
+ * and the option allows for a fallback scenario in the case where the selector is
12219
+ * valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
12220
+ * @param {Array} [options.params] Params to pass to the option if it's a function.
12221
+ * @returns {undefined | null | false | HTMLElement | SVGElement} Returns
12222
+ * `undefined` if the option is not specified; `null` if the option didn't resolve
12223
+ * to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
12224
+ * (node explicitly not given); otherwise, the resolved DOM node.
12225
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
12226
+ * resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
12227
+ */
12228
+ var getNodeForOption = function getNodeForOption(optionName) {
12229
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
12230
+ _ref2$hasFallback = _ref2.hasFallback,
12231
+ hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback,
12232
+ _ref2$params = _ref2.params,
12233
+ params = _ref2$params === void 0 ? [] : _ref2$params;
12234
+ var optionValue = config[optionName];
12235
+ if (typeof optionValue === 'function') {
12236
+ optionValue = optionValue.apply(void 0, _toConsumableArray(params));
12237
+ }
12238
+ if (optionValue === true) {
12239
+ optionValue = undefined; // use default value
12240
+ }
12241
+ if (!optionValue) {
12242
+ if (optionValue === undefined || optionValue === false) {
12243
+ return optionValue;
12244
+ }
12245
+ // else, empty string (invalid), null (invalid), 0 (invalid)
12246
+
12247
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
12248
+ }
12249
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
12250
+
12251
+ if (typeof optionValue === 'string') {
12252
+ try {
12253
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
12254
+ } catch (err) {
12255
+ throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
12256
+ }
12257
+ if (!node) {
12258
+ if (!hasFallback) {
12259
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
12260
+ }
12261
+ // else, `node` MUST be `null` because that's what `Document.querySelector()` returns
12262
+ // if the selector is valid but doesn't match anything
12263
+ }
12264
+ }
12265
+ return node;
12266
+ };
12267
+ var getInitialFocusNode = function getInitialFocusNode() {
12268
+ var node = getNodeForOption('initialFocus', {
12269
+ hasFallback: true
12270
+ });
12271
+
12272
+ // false explicitly indicates we want no initialFocus at all
12273
+ if (node === false) {
12274
+ return false;
12275
+ }
12276
+ if (node === undefined || node && !isFocusable(node, config.tabbableOptions)) {
12277
+ // option not specified nor focusable: use fallback options
12278
+ if (findContainerIndex(doc.activeElement) >= 0) {
12279
+ node = doc.activeElement;
12280
+ } else {
12281
+ var firstTabbableGroup = state.tabbableGroups[0];
12282
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
12283
+
12284
+ // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
12285
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
12286
+ }
12287
+ } else if (node === null) {
12288
+ // option is a VALID selector string that doesn't yield a node: use the `fallbackFocus`
12289
+ // option instead of the default behavior when the option isn't specified at all
12290
+ node = getNodeForOption('fallbackFocus');
12291
+ }
12292
+ if (!node) {
12293
+ throw new Error('Your focus-trap needs to have at least one focusable element');
12294
+ }
12295
+ return node;
12296
+ };
12297
+ var updateTabbableNodes = function updateTabbableNodes() {
12298
+ state.containerGroups = state.containers.map(function (container) {
12299
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
12300
+
12301
+ // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
12302
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
12303
+ // are focusable but not tabbable
12304
+ var focusableNodes = focusable(container, config.tabbableOptions);
12305
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
12306
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
12307
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
12308
+ return isTabbable(node);
12309
+ });
12310
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
12311
+ return isTabbable(node);
12312
+ });
12313
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
12314
+ return getTabIndex(node) > 0;
12315
+ });
12316
+ return {
12317
+ container: container,
12318
+ tabbableNodes: tabbableNodes,
12319
+ focusableNodes: focusableNodes,
12320
+ /** True if at least one node with positive `tabindex` was found in this container. */
12321
+ posTabIndexesFound: posTabIndexesFound,
12322
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
12323
+ firstTabbableNode: firstTabbableNode,
12324
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
12325
+ lastTabbableNode: lastTabbableNode,
12326
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
12327
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
12328
+ // because that API doesn't work with Shadow DOM as well as it should (@see
12329
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
12330
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
12331
+ // "close enough most of the time" alternative for positive tabindexes which should generally
12332
+ // be avoided anyway...
12333
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
12334
+ firstDomTabbableNode: firstDomTabbableNode,
12335
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
12336
+ lastDomTabbableNode: lastDomTabbableNode,
12337
+ /**
12338
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
12339
+ * in this container, if any.
12340
+ * @param {HTMLElement} node
12341
+ * @param {boolean} [forward] True if going in forward tab order; false if going
12342
+ * in reverse.
12343
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
12344
+ */
12345
+ nextTabbableNode: function nextTabbableNode(node) {
12346
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12347
+ var nodeIdx = tabbableNodes.indexOf(node);
12348
+ if (nodeIdx < 0) {
12349
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
12350
+ // since `node` should at least have been focusable, we assume that's the case and mimic
12351
+ // what browsers do, which is set focus to the next node in __document position order__,
12352
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
12353
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
12354
+ // basic DOM order
12355
+ if (forward) {
12356
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
12357
+ return isTabbable(el);
12358
+ });
12359
+ }
12360
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
12361
+ return isTabbable(el);
12362
+ });
12363
+ }
12364
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
12365
+ }
12366
+ };
12367
+ });
12368
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
12369
+ return group.tabbableNodes.length > 0;
12370
+ });
12371
+
12372
+ // throw if no groups have tabbable nodes and we don't have a fallback focus node either
12373
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
12374
+ ) {
12375
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
12376
+ }
12377
+
12378
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
12379
+ // doing it across multiple containers where tabindexes could be all over the place
12380
+ // would require Tabbable to support multiple containers, would require additional
12381
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
12382
+ // to look at those containers in document position order rather than user-provided
12383
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
12384
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
12385
+ if (state.containerGroups.find(function (g) {
12386
+ return g.posTabIndexesFound;
12387
+ }) && state.containerGroups.length > 1) {
12388
+ throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
12389
+ }
12390
+ };
12391
+
12392
+ /**
12393
+ * Gets the current activeElement. If it's a web-component and has open shadow-root
12394
+ * it will recursively search inside shadow roots for the "true" activeElement.
12395
+ *
12396
+ * @param {Document | ShadowRoot} el
12397
+ *
12398
+ * @returns {HTMLElement} The element that currently has the focus
12399
+ **/
12400
+ var _getActiveElement = function getActiveElement(el) {
12401
+ var activeElement = el.activeElement;
12402
+ if (!activeElement) {
12403
+ return;
12404
+ }
12405
+ if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
12406
+ return _getActiveElement(activeElement.shadowRoot);
12407
+ }
12408
+ return activeElement;
12409
+ };
12410
+ var _tryFocus = function tryFocus(node) {
12411
+ if (node === false) {
12412
+ return;
12413
+ }
12414
+ if (node === _getActiveElement(document)) {
12415
+ return;
12416
+ }
12417
+ if (!node || !node.focus) {
12418
+ _tryFocus(getInitialFocusNode());
12419
+ return;
12420
+ }
12421
+ node.focus({
12422
+ preventScroll: !!config.preventScroll
12423
+ });
12424
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
12425
+ state.mostRecentlyFocusedNode = node;
12426
+ if (isSelectableInput(node)) {
12427
+ node.select();
12428
+ }
12429
+ };
12430
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
12431
+ var node = getNodeForOption('setReturnFocus', {
12432
+ params: [previousActiveElement]
12433
+ });
12434
+ return node ? node : node === false ? false : previousActiveElement;
12435
+ };
12436
+
12437
+ /**
12438
+ * Finds the next node (in either direction) where focus should move according to a
12439
+ * keyboard focus-in event.
12440
+ * @param {Object} params
12441
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
12442
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
12443
+ * will be used to determine the `target`). Ignored if `target` is specified.
12444
+ * @param {boolean} [params.isBackward] True if focus should move backward.
12445
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
12446
+ * determined given the current state of the trap.
12447
+ */
12448
+ var findNextNavNode = function findNextNavNode(_ref3) {
12449
+ var target = _ref3.target,
12450
+ event = _ref3.event,
12451
+ _ref3$isBackward = _ref3.isBackward,
12452
+ isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
12453
+ target = target || getActualTarget(event);
12454
+ updateTabbableNodes();
12455
+ var destinationNode = null;
12456
+ if (state.tabbableGroups.length > 0) {
12457
+ // make sure the target is actually contained in a group
12458
+ // NOTE: the target may also be the container itself if it's focusable
12459
+ // with tabIndex='-1' and was given initial focus
12460
+ var containerIndex = findContainerIndex(target, event);
12461
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
12462
+ if (containerIndex < 0) {
12463
+ // target not found in any group: quite possible focus has escaped the trap,
12464
+ // so bring it back into...
12465
+ if (isBackward) {
12466
+ // ...the last node in the last group
12467
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
12468
+ } else {
12469
+ // ...the first node in the first group
12470
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
12471
+ }
12472
+ } else if (isBackward) {
12473
+ // REVERSE
12474
+
12475
+ // is the target the first tabbable node in a group?
12476
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
12477
+ var firstTabbableNode = _ref4.firstTabbableNode;
12478
+ return target === firstTabbableNode;
12479
+ });
12480
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
12481
+ // an exception case where the target is either the container itself, or
12482
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
12483
+ // and user clicked on it or node was programmatically given focus)
12484
+ // and is not followed by any other tabbable node, in which
12485
+ // case, we should handle shift+tab as if focus were on the container's
12486
+ // first tabbable node, and go to the last tabbable node of the LAST group
12487
+ startOfGroupIndex = containerIndex;
12488
+ }
12489
+ if (startOfGroupIndex >= 0) {
12490
+ // YES: then shift+tab should go to the last tabbable node in the
12491
+ // previous group (and wrap around to the last tabbable node of
12492
+ // the LAST group if it's the first tabbable node of the FIRST group)
12493
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
12494
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
12495
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
12496
+ } else if (!isTabEvent(event)) {
12497
+ // user must have customized the nav keys so we have to move focus manually _within_
12498
+ // the active group: do this based on the order determined by tabbable()
12499
+ destinationNode = containerGroup.nextTabbableNode(target, false);
12500
+ }
12501
+ } else {
12502
+ // FORWARD
12503
+
12504
+ // is the target the last tabbable node in a group?
12505
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
12506
+ var lastTabbableNode = _ref5.lastTabbableNode;
12507
+ return target === lastTabbableNode;
12508
+ });
12509
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
12510
+ // an exception case where the target is the container itself, or
12511
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
12512
+ // and user clicked on it or node was programmatically given focus)
12513
+ // and is not followed by any other tabbable node, in which
12514
+ // case, we should handle tab as if focus were on the container's
12515
+ // last tabbable node, and go to the first tabbable node of the FIRST group
12516
+ lastOfGroupIndex = containerIndex;
12517
+ }
12518
+ if (lastOfGroupIndex >= 0) {
12519
+ // YES: then tab should go to the first tabbable node in the next
12520
+ // group (and wrap around to the first tabbable node of the FIRST
12521
+ // group if it's the last tabbable node of the LAST group)
12522
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
12523
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
12524
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
12525
+ } else if (!isTabEvent(event)) {
12526
+ // user must have customized the nav keys so we have to move focus manually _within_
12527
+ // the active group: do this based on the order determined by tabbable()
12528
+ destinationNode = containerGroup.nextTabbableNode(target);
12529
+ }
12530
+ }
12531
+ } else {
12532
+ // no groups available
12533
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
12534
+ destinationNode = getNodeForOption('fallbackFocus');
12535
+ }
12536
+ return destinationNode;
12537
+ };
12538
+
12539
+ // This needs to be done on mousedown and touchstart instead of click
12540
+ // so that it precedes the focus event.
12541
+ var checkPointerDown = function checkPointerDown(e) {
12542
+ var target = getActualTarget(e);
12543
+ if (findContainerIndex(target, e) >= 0) {
12544
+ // allow the click since it ocurred inside the trap
12545
+ return;
12546
+ }
12547
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
12548
+ // immediately deactivate the trap
12549
+ trap.deactivate({
12550
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
12551
+ // which will result in the outside click setting focus to the node
12552
+ // that was clicked (and if not focusable, to "nothing"); by setting
12553
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
12554
+ // on activation (or the configured `setReturnFocus` node), whether the
12555
+ // outside click was on a focusable node or not
12556
+ returnFocus: config.returnFocusOnDeactivate
12557
+ });
12558
+ return;
12559
+ }
12560
+
12561
+ // This is needed for mobile devices.
12562
+ // (If we'll only let `click` events through,
12563
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
12564
+ if (valueOrHandler(config.allowOutsideClick, e)) {
12565
+ // allow the click outside the trap to take place
12566
+ return;
12567
+ }
12568
+
12569
+ // otherwise, prevent the click
12570
+ e.preventDefault();
12571
+ };
12572
+
12573
+ // In case focus escapes the trap for some strange reason, pull it back in.
12574
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
12575
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
12576
+ // prevent that from happening by the time we discover that focus escaped
12577
+ var checkFocusIn = function checkFocusIn(event) {
12578
+ var target = getActualTarget(event);
12579
+ var targetContained = findContainerIndex(target, event) >= 0;
12580
+
12581
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
12582
+ if (targetContained || target instanceof Document) {
12583
+ if (targetContained) {
12584
+ state.mostRecentlyFocusedNode = target;
12585
+ }
12586
+ } else {
12587
+ // escaped! pull it back in to where it just left
12588
+ event.stopImmediatePropagation();
12589
+
12590
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
12591
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
12592
+ // toward a node with a positive tab index
12593
+ var nextNode; // next node to focus, if we find one
12594
+ var navAcrossContainers = true;
12595
+ if (state.mostRecentlyFocusedNode) {
12596
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
12597
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
12598
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
12599
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
12600
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
12601
+ // with at least one tabbable node in order to function, so this could be the other container
12602
+ // with nothing tabbable in it)
12603
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
12604
+ if (tabbableNodes.length > 0) {
12605
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
12606
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
12607
+ return node === state.mostRecentlyFocusedNode;
12608
+ });
12609
+ if (mruTabIdx >= 0) {
12610
+ if (config.isKeyForward(state.recentNavEvent)) {
12611
+ if (mruTabIdx + 1 < tabbableNodes.length) {
12612
+ nextNode = tabbableNodes[mruTabIdx + 1];
12613
+ navAcrossContainers = false;
12614
+ }
12615
+ // else, don't wrap within the container as focus should move to next/previous
12616
+ // container
12617
+ } else {
12618
+ if (mruTabIdx - 1 >= 0) {
12619
+ nextNode = tabbableNodes[mruTabIdx - 1];
12620
+ navAcrossContainers = false;
12621
+ }
12622
+ // else, don't wrap within the container as focus should move to next/previous
12623
+ // container
12624
+ }
12625
+ // else, don't find in container order without considering direction too
12626
+ }
12627
+ }
12628
+ // else, no tabbable nodes in that container (which means we must have at least one other
12629
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
12630
+ // an error the last time updateTabbableNodes() was run): find next node among all known
12631
+ // containers
12632
+ } else {
12633
+ // check to see if there's at least one tabbable node with a positive tab index inside
12634
+ // the trap because focus seems to escape when navigating backward from a tabbable node
12635
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
12636
+ // the greatest positive tab index like it should)
12637
+ if (!state.containerGroups.some(function (g) {
12638
+ return g.tabbableNodes.some(function (n) {
12639
+ return getTabIndex(n) > 0;
12640
+ });
12641
+ })) {
12642
+ // no containers with tabbable nodes with positive tab indexes which means the focus
12643
+ // escaped for some other reason and we should just execute the fallback to the
12644
+ // MRU node or initial focus node, if any
12645
+ navAcrossContainers = false;
12646
+ }
12647
+ }
12648
+ } else {
12649
+ // no MRU node means we're likely in some initial condition when the trap has just
12650
+ // been activated and initial focus hasn't been given yet, in which case we should
12651
+ // fall through to trying to focus the initial focus node, which is what should
12652
+ // happen below at this point in the logic
12653
+ navAcrossContainers = false;
12654
+ }
12655
+ if (navAcrossContainers) {
12656
+ nextNode = findNextNavNode({
12657
+ // move FROM the MRU node, not event-related node (which will be the node that is
12658
+ // outside the trap causing the focus escape we're trying to fix)
12659
+ target: state.mostRecentlyFocusedNode,
12660
+ isBackward: config.isKeyBackward(state.recentNavEvent)
12661
+ });
12662
+ }
12663
+ if (nextNode) {
12664
+ _tryFocus(nextNode);
12665
+ } else {
12666
+ _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
12667
+ }
12668
+ }
12669
+ state.recentNavEvent = undefined; // clear
12670
+ };
12671
+
12672
+ // Hijack key nav events on the first and last focusable nodes of the trap,
12673
+ // in order to prevent focus from escaping. If it escapes for even a
12674
+ // moment it can end up scrolling the page and causing confusion so we
12675
+ // kind of need to capture the action at the keydown phase.
12676
+ var checkKeyNav = function checkKeyNav(event) {
12677
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
12678
+ state.recentNavEvent = event;
12679
+ var destinationNode = findNextNavNode({
12680
+ event: event,
12681
+ isBackward: isBackward
12682
+ });
12683
+ if (destinationNode) {
12684
+ if (isTabEvent(event)) {
12685
+ // since tab natively moves focus, we wouldn't have a destination node unless we
12686
+ // were on the edge of a container and had to move to the next/previous edge, in
12687
+ // which case we want to prevent default to keep the browser from moving focus
12688
+ // to where it normally would
12689
+ event.preventDefault();
12690
+ }
12691
+ _tryFocus(destinationNode);
12692
+ }
12693
+ // else, let the browser take care of [shift+]tab and move the focus
12694
+ };
12695
+ var checkTabKey = function checkTabKey(event) {
12696
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
12697
+ checkKeyNav(event, config.isKeyBackward(event));
12698
+ }
12699
+ };
12700
+
12701
+ // we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates
12702
+ var checkEscapeKey = function checkEscapeKey(event) {
12703
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
12704
+ event.preventDefault();
12705
+ trap.deactivate();
12706
+ }
12707
+ };
12708
+ var checkClick = function checkClick(e) {
12709
+ var target = getActualTarget(e);
12710
+ if (findContainerIndex(target, e) >= 0) {
12711
+ return;
12712
+ }
12713
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
12714
+ return;
12715
+ }
12716
+ if (valueOrHandler(config.allowOutsideClick, e)) {
12717
+ return;
12718
+ }
12719
+ e.preventDefault();
12720
+ e.stopImmediatePropagation();
12721
+ };
12722
+
12723
+ //
12724
+ // EVENT LISTENERS
12725
+ //
12726
+
12727
+ var addListeners = function addListeners() {
12728
+ if (!state.active) {
12729
+ return;
12730
+ }
12731
+
12732
+ // There can be only one listening focus trap at a time
12733
+ activeFocusTraps.activateTrap(trapStack, trap);
12734
+
12735
+ // Delay ensures that the focused element doesn't capture the event
12736
+ // that caused the focus trap activation.
12737
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
12738
+ _tryFocus(getInitialFocusNode());
12739
+ }) : _tryFocus(getInitialFocusNode());
12740
+ doc.addEventListener('focusin', checkFocusIn, true);
12741
+ doc.addEventListener('mousedown', checkPointerDown, {
12742
+ capture: true,
12743
+ passive: false
12744
+ });
12745
+ doc.addEventListener('touchstart', checkPointerDown, {
12746
+ capture: true,
12747
+ passive: false
12748
+ });
12749
+ doc.addEventListener('click', checkClick, {
12750
+ capture: true,
12751
+ passive: false
12752
+ });
12753
+ doc.addEventListener('keydown', checkTabKey, {
12754
+ capture: true,
12755
+ passive: false
12756
+ });
12757
+ doc.addEventListener('keydown', checkEscapeKey);
12758
+ return trap;
12759
+ };
12760
+ var removeListeners = function removeListeners() {
12761
+ if (!state.active) {
12762
+ return;
12763
+ }
12764
+ doc.removeEventListener('focusin', checkFocusIn, true);
12765
+ doc.removeEventListener('mousedown', checkPointerDown, true);
12766
+ doc.removeEventListener('touchstart', checkPointerDown, true);
12767
+ doc.removeEventListener('click', checkClick, true);
12768
+ doc.removeEventListener('keydown', checkTabKey, true);
12769
+ doc.removeEventListener('keydown', checkEscapeKey);
12770
+ return trap;
12771
+ };
12772
+
12773
+ //
12774
+ // MUTATION OBSERVER
12775
+ //
12776
+
12777
+ var checkDomRemoval = function checkDomRemoval(mutations) {
12778
+ var isFocusedNodeRemoved = mutations.some(function (mutation) {
12779
+ var removedNodes = Array.from(mutation.removedNodes);
12780
+ return removedNodes.some(function (node) {
12781
+ return node === state.mostRecentlyFocusedNode;
12782
+ });
12783
+ });
12784
+
12785
+ // If the currently focused is removed then browsers will move focus to the
12786
+ // <body> element. If this happens, try to move focus back into the trap.
12787
+ if (isFocusedNodeRemoved) {
12788
+ _tryFocus(getInitialFocusNode());
12789
+ }
12790
+ };
12791
+
12792
+ // Use MutationObserver - if supported - to detect if focused node is removed
12793
+ // from the DOM.
12794
+ var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
12795
+ var updateObservedNodes = function updateObservedNodes() {
12796
+ if (!mutationObserver) {
12797
+ return;
12798
+ }
12799
+ mutationObserver.disconnect();
12800
+ if (state.active && !state.paused) {
12801
+ state.containers.map(function (container) {
12802
+ mutationObserver.observe(container, {
12803
+ subtree: true,
12804
+ childList: true
12805
+ });
12806
+ });
12807
+ }
12808
+ };
12809
+
12810
+ //
12811
+ // TRAP DEFINITION
12812
+ //
12813
+
12814
+ trap = {
12815
+ get active() {
12816
+ return state.active;
12817
+ },
12818
+ get paused() {
12819
+ return state.paused;
12820
+ },
12821
+ activate: function activate(activateOptions) {
12822
+ if (state.active) {
12823
+ return this;
12824
+ }
12825
+ var onActivate = getOption(activateOptions, 'onActivate');
12826
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
12827
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
12828
+ if (!checkCanFocusTrap) {
12829
+ updateTabbableNodes();
12830
+ }
12831
+ state.active = true;
12832
+ state.paused = false;
12833
+ state.nodeFocusedBeforeActivation = _getActiveElement(doc);
12834
+ onActivate === null || onActivate === void 0 || onActivate();
12835
+ var finishActivation = function finishActivation() {
12836
+ if (checkCanFocusTrap) {
12837
+ updateTabbableNodes();
12838
+ }
12839
+ addListeners();
12840
+ updateObservedNodes();
12841
+ onPostActivate === null || onPostActivate === void 0 || onPostActivate();
12842
+ };
12843
+ if (checkCanFocusTrap) {
12844
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
12845
+ return this;
12846
+ }
12847
+ finishActivation();
12848
+ return this;
12849
+ },
12850
+ deactivate: function deactivate(deactivateOptions) {
12851
+ if (!state.active) {
12852
+ return this;
12853
+ }
12854
+ var options = _objectSpread2({
12855
+ onDeactivate: config.onDeactivate,
12856
+ onPostDeactivate: config.onPostDeactivate,
12857
+ checkCanReturnFocus: config.checkCanReturnFocus
12858
+ }, deactivateOptions);
12859
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
12860
+ state.delayInitialFocusTimer = undefined;
12861
+ removeListeners();
12862
+ state.active = false;
12863
+ state.paused = false;
12864
+ updateObservedNodes();
12865
+ activeFocusTraps.deactivateTrap(trapStack, trap);
12866
+ var onDeactivate = getOption(options, 'onDeactivate');
12867
+ var onPostDeactivate = getOption(options, 'onPostDeactivate');
12868
+ var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
12869
+ var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
12870
+ onDeactivate === null || onDeactivate === void 0 || onDeactivate();
12871
+ var finishDeactivation = function finishDeactivation() {
12872
+ delay(function () {
12873
+ if (returnFocus) {
12874
+ _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
12875
+ }
12876
+ onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
12877
+ });
12878
+ };
12879
+ if (returnFocus && checkCanReturnFocus) {
12880
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
12881
+ return this;
12882
+ }
12883
+ finishDeactivation();
12884
+ return this;
12885
+ },
12886
+ pause: function pause(pauseOptions) {
12887
+ if (!state.active) {
12888
+ return this;
12889
+ }
12890
+ state.manuallyPaused = true;
12891
+ return this._setPausedState(true, pauseOptions);
12892
+ },
12893
+ unpause: function unpause(unpauseOptions) {
12894
+ if (!state.active) {
12895
+ return this;
12896
+ }
12897
+ state.manuallyPaused = false;
12898
+ if (trapStack[trapStack.length - 1] !== this) {
12899
+ return this;
12900
+ }
12901
+ return this._setPausedState(false, unpauseOptions);
12902
+ },
12903
+ updateContainerElements: function updateContainerElements(containerElements) {
12904
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
12905
+ state.containers = elementsAsArray.map(function (element) {
12906
+ return typeof element === 'string' ? doc.querySelector(element) : element;
12907
+ });
12908
+ if (state.active) {
12909
+ updateTabbableNodes();
12910
+ }
12911
+ updateObservedNodes();
12912
+ return this;
12913
+ }
12914
+ };
12915
+ Object.defineProperties(trap, {
12916
+ _isManuallyPaused: {
12917
+ value: function value() {
12918
+ return state.manuallyPaused;
12919
+ }
12920
+ },
12921
+ _setPausedState: {
12922
+ value: function value(paused, options) {
12923
+ if (state.paused === paused) {
12924
+ return this;
12925
+ }
12926
+ state.paused = paused;
12927
+ if (paused) {
12928
+ var onPause = getOption(options, 'onPause');
12929
+ var onPostPause = getOption(options, 'onPostPause');
12930
+ onPause === null || onPause === void 0 || onPause();
12931
+ removeListeners();
12932
+ updateObservedNodes();
12933
+ onPostPause === null || onPostPause === void 0 || onPostPause();
12934
+ } else {
12935
+ var onUnpause = getOption(options, 'onUnpause');
12936
+ var onPostUnpause = getOption(options, 'onPostUnpause');
12937
+ onUnpause === null || onUnpause === void 0 || onUnpause();
12938
+ updateTabbableNodes();
12939
+ addListeners();
12940
+ updateObservedNodes();
12941
+ onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
12942
+ }
12943
+ return this;
12944
+ }
12945
+ }
12946
+ });
12947
+
12948
+ // initialize container elements
12949
+ trap.updateContainerElements(elements);
12950
+ return trap;
12951
+ };
12952
+
11335
12953
  const drawerCss = ":host{--background:var(--road-surface);--color:var(--road-on-surface);--header-icon:var(--road-on-surface);--header-color:var(--road-on-surface);--header-background:var(--road-surface);--header-delimiter:0;--back-chevron-color:var(--road-icon);--max-height:auto;--z-index:10;position:fixed;top:0;left:0;z-index:var(--z-index);display:flex;justify-content:flex-start;width:100%;height:100%;overflow:hidden;font-family:var(--road-font, sans-serif);line-height:1.5;color:var(--color);visibility:hidden !important;opacity:0;transition:opacity 0.15s linear, visibility 0.15s}.drawer-overlay{position:absolute;top:0;right:0;bottom:0;left:0;display:block;touch-action:none;cursor:pointer;background:var(--road-overlay)}.drawer-dialog{position:relative;width:100%;pointer-events:none;transition:transform 0.3s ease-out;transform:translateX(-100%)}:host(.drawer-right){justify-content:flex-end}:host(.drawer-right) .drawer-dialog{transform:translateX(100%)}:host(.drawer-bottom){align-items:flex-end}:host(.drawer-bottom) .drawer-dialog{width:100%;max-height:var(--max-height);transform:translateY(100%)}:host(.drawer-bottom) .drawer-content{height:auto}.drawer-content{position:relative;display:flex;flex-direction:column;width:100%;height:100vh;max-height:100vh;pointer-events:auto;background-color:var(--background);background-clip:padding-box;box-shadow:var(--road-elevation-hight)}.drawer-header{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;color:var(--header-color);background:var(--header-background);border-color:var(--road-grey-300);border-style:solid;border-width:var(--header-delimiter)}.drawer-header road-icon{flex-shrink:0;color:var(--header-icon)}.drawer-footer{padding:var(--road-spacing-05);background-color:var(--road-surface)}.drawer-footer.remove-padding{padding:0}.drawer-header-inverse{--header-icon:var(--road-on-primary);--header-color:var(--road-on-primary);--header-background:var(--road-primary-variant);margin-bottom:2.5rem}.drawer-action,.drawer-close{display:flex;align-items:center;justify-content:center;padding:0.5rem;font-family:inherit;font-size:0.875rem;color:inherit;cursor:pointer;background:transparent;border:0;appearance:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}.drawer-header:not(.drawer-header-inverse) .drawer-action road-icon{color:var(--back-chevron-color)}.drawer-action~.drawer-title,.drawer-close~.drawer-title{padding-left:0}.drawer-action-left,.drawer-close-left{margin-right:auto}.drawer-title{display:flex;flex-grow:1;align-items:center;justify-content:center;padding-left:3.5rem;margin:0;font-size:var(--road-body-medium)}.drawer-body{overflow-y:auto;padding:0 var(--road-spacing-05) var(--road-spacing-05)}.drawer-body.remove-padding{padding:0}:host(.drawer-right) .drawer-body,:host(.drawer-left) .drawer-body{height:calc(100vh - 3.5rem)}.drawer-inner{padding:0 1rem 2.5rem}@media (min-width: 768px){.drawer-inner{padding:0 2rem 2.5rem}.drawer-body{padding:0 var(--road-spacing-08) var(--road-spacing-05)}.drawer-body.remove-padding{padding:0}.drawer-footer{padding:var(--road-spacing-05) var(--road-spacing-08)}.drawer-footer.remove-padding{padding:0}}:host(.drawer-open){visibility:visible !important;opacity:1}:host(.drawer-open) .drawer-dialog{transform:none}";
11336
12954
  var RoadDrawerStyle0 = drawerCss;
11337
12955
 
@@ -11355,8 +12973,8 @@ class Drawer {
11355
12973
  */
11356
12974
  this.isOpen = false;
11357
12975
  /**
11358
- * Set removePadding property to true to remove padding for drawer body
11359
- */
12976
+ * Set removePadding property to true to remove padding for drawer body
12977
+ */
11360
12978
  this.removePadding = false;
11361
12979
  /**
11362
12980
  * position of the drawer. e.g. left, right, bottom
@@ -11427,24 +13045,30 @@ class Drawer {
11427
13045
  handleOpen(openValue) {
11428
13046
  if (openValue === true) {
11429
13047
  this.onOpen.emit();
11430
- // Focus the first button element after the drawer is opened
11431
- setTimeout(() => this.focusFirstButton(), 50); // Add a slight delay to ensure the element is rendered
13048
+ // Focus the first button element after the drawer is opened then focus trap
13049
+ setTimeout(() => {
13050
+ var _a;
13051
+ this.focusFirstElement();
13052
+ (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.activate();
13053
+ }, 50); // Add a slight delay to ensure the element is rendered
11432
13054
  }
11433
13055
  else {
11434
13056
  this.el.addEventListener('transitionend', () => {
13057
+ var _a;
13058
+ (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.deactivate();
11435
13059
  this.onClose.emit();
11436
13060
  this.el.shadowRoot && (this.el.shadowRoot.querySelector('.drawer-body').scrollTop = 0);
11437
13061
  }, { once: true });
11438
13062
  }
11439
13063
  }
11440
13064
  /**
11441
- * Find and focus the first button element in the drawer
13065
+ * Find and focus the first element in the drawer
11442
13066
  */
11443
- focusFirstButton() {
13067
+ focusFirstElement() {
11444
13068
  var _a;
11445
- const buttonElement = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('button');
11446
- if (buttonElement) {
11447
- buttonElement.focus(); // Focus the first button element
13069
+ const firstElement = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], [tabindex]:not([tabindex="-1"])')[0];
13070
+ if (firstElement) {
13071
+ firstElement.focus();
11448
13072
  }
11449
13073
  }
11450
13074
  /**
@@ -11459,9 +13083,18 @@ class Drawer {
11459
13083
  * Call close function when clicking an element with data-dismiss="modal" attribute
11460
13084
  */
11461
13085
  componentDidLoad() {
13086
+ var _a;
11462
13087
  this.el.querySelectorAll('[data-dismiss="modal"]').forEach(item => {
11463
13088
  item.addEventListener('click', () => this.close());
11464
13089
  });
13090
+ const drawerContent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".drawer-dialog");
13091
+ this.focusTrap = createFocusTrap(drawerContent, {
13092
+ onActivate: () => drawerContent === null || drawerContent === void 0 ? void 0 : drawerContent.classList.add("focus-trapped"),
13093
+ onDeactivate: () => drawerContent === null || drawerContent === void 0 ? void 0 : drawerContent.classList.remove("focus-trapped"),
13094
+ tabbableOptions: {
13095
+ getShadowRoot: true,
13096
+ },
13097
+ });
11465
13098
  }
11466
13099
  render() {
11467
13100
  var _a, _b, _c, _d;
@@ -11477,7 +13110,7 @@ class Drawer {
11477
13110
  const drawerWidthValue = this.position === 'bottom' ? '100%' : `${this.drawerWidth}px`;
11478
13111
  const footerSlotElement = (_d = this.el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('slot[name="footer"]');
11479
13112
  const hasFooterContent = footerSlotElement instanceof HTMLSlotElement && footerSlotElement.assignedNodes().length > 0;
11480
- return (hAsync(Host, { key: '8a221daad83a03c6635059b21b807ea546f94033', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, hAsync("div", { key: '28de6daf4125334413589e02b3c568936fd54596', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), hAsync("div", { key: '555dd191eb27d3b5b0e97d1a0a29065e1d019195', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document", tabindex: "0" }, hAsync("div", { key: 'ca12f58fd65bec534130f96de55781440a99a3f3', class: "drawer-content" }, hAsync("header", { key: '3fbdbf60e39f0bb41de438fca2f90dd7368d2360', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (hAsync("h2", { class: "drawer-title" }, this.drawerTitle)) : (hAsync("div", { class: "drawer-title" }, hAsync("slot", { name: "title" }))), closeIconElement), hAsync("div", { key: '2c87df1cd3e5aeaff575e06a21cc95bb58e123d5', class: `drawer-body ${removePaddingClass}` }, hAsync("slot", { key: '146a53a578800960a1ec69a9ad73fab9f7ec1d08' })), hAsync("footer", { key: 'b67cf3313766e0b1ec4e903c536c68f8dfbc3cc9', class: `drawer-footer ${removePaddingClass}`, style: { display: hasFooterContent ? 'block' : 'none' } }, hAsync("slot", { key: '2fa3f2e7b39ec3b03fba1a76ceb3a5c64d00c0e5', name: "footer" }))))));
13113
+ return (hAsync(Host, { key: 'a2f62ec1ecc2d5452041c1aef21c219dfb7d37e5', class: `${drawerIsOpenClass} drawer-${this.position}`, tabindex: "0", role: "dialog", "aria-label": ariaLabel }, hAsync("div", { key: '483e792abee343f79a36594eb391203521dac055', class: "drawer-overlay", onClick: this.onClick, tabindex: "-1" }), hAsync("div", { key: 'b0692ac024a6f402915f482177b867f1d3fa5144', class: "drawer-dialog", style: { maxWidth: drawerWidthValue }, role: "document", tabindex: "0" }, hAsync("div", { key: '6afd92780745fe0f6817adb5fba8649a9de0cdd9', class: "drawer-content" }, hAsync("header", { key: '5248706c77aeaa4ce3332acfe7f3b605cbe7fd54', class: `drawer-header ${inverseHeaderClass} ${drawerDelimiterClass}` }, backIconElement, this.drawerTitle ? (hAsync("h2", { class: "drawer-title" }, this.drawerTitle)) : (hAsync("div", { class: "drawer-title" }, hAsync("slot", { name: "title" }))), closeIconElement), hAsync("div", { key: '42ade4a899a1f381af1463ac5217c245de22c241', class: `drawer-body ${removePaddingClass}` }, hAsync("slot", { key: 'adb1a893b61941e6488ba3bc233540ca18d90252' })), hAsync("footer", { key: '7fb54e5564e98777a3fbf3474d323f7fe1eb0e07', class: `drawer-footer ${removePaddingClass}`, style: { display: hasFooterContent ? 'block' : 'none' } }, hAsync("slot", { key: '37f2d0ec86cccc74795bc9a8fb509c5ded347f92', name: "footer" }))))));
11481
13114
  }
11482
13115
  get el() { return getElement(this); }
11483
13116
  static get watchers() { return {
@@ -11500,6 +13133,7 @@ class Drawer {
11500
13133
  "ariaLabelBack": [1, "aria-label-back"],
11501
13134
  "ariaLabelClose": [1, "aria-label-close"],
11502
13135
  "hasCloseIcon": [4, "has-close-icon"],
13136
+ "focusTrap": [32],
11503
13137
  "open": [64],
11504
13138
  "close": [64],
11505
13139
  "back": [64]