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