@getflip/swirl-components 0.8.1 → 0.8.2

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.
@@ -1,6 +1,5 @@
1
1
  import { Component, Element, Event, h, Host, Listen, Method, Prop, State, } from "@stencil/core";
2
2
  import classnames from "classnames";
3
- import { createFocusTrap } from "focus-trap";
4
3
  import { isMobileViewport } from "../../utils";
5
4
  export class FlipConsoleLayout {
6
5
  constructor() {
@@ -23,11 +22,16 @@ export class FlipConsoleLayout {
23
22
  this.hideSidebar();
24
23
  };
25
24
  this.onClick = (event) => {
25
+ var _a;
26
26
  const target = event.target;
27
27
  const clickOnToggle = Boolean(target.closest(".console-layout__mobile-navigation-button"));
28
+ const clickOnOverlay = ((_a = target.closest("[slot]")) === null || _a === void 0 ? void 0 : _a.slot) === "overlays";
28
29
  const clickInsideSidebar = event.composedPath().includes(this.sidebarEl);
29
- if (!clickInsideSidebar && !clickOnToggle && this.sidebarActive) {
30
- this.sidebarActive = false;
30
+ if (!clickInsideSidebar &&
31
+ !clickOnToggle &&
32
+ !clickOnOverlay &&
33
+ this.sidebarActive) {
34
+ this.deactivateSidebar();
31
35
  }
32
36
  };
33
37
  this.onKeyDown = (event) => {
@@ -37,13 +41,6 @@ export class FlipConsoleLayout {
37
41
  };
38
42
  }
39
43
  componentDidLoad() {
40
- const sidebarContents = [
41
- this.sidebarEl,
42
- ...Array.from(this.el.querySelectorAll('[slot="navigation"], [slot="user"]')).filter((el) => Boolean(el)),
43
- ];
44
- this.focusTrap = createFocusTrap(sidebarContents, {
45
- clickOutsideDeactivates: true,
46
- });
47
44
  queueMicrotask(() => {
48
45
  if (!isMobileViewport()) {
49
46
  this.activateSidebar();
@@ -94,16 +91,14 @@ export class FlipConsoleLayout {
94
91
  this.sidebarActive = true;
95
92
  this.sidebarEl.removeAttribute("inert");
96
93
  if (isMobileViewport()) {
97
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.activate();
94
+ (_a = this.el.querySelector("flip-tree-navigation-item")) === null || _a === void 0 ? void 0 : _a.focus();
98
95
  }
99
96
  }
100
97
  deactivateSidebar() {
101
- var _a;
102
98
  this.sidebarActive = false;
103
99
  if (isMobileViewport()) {
104
100
  this.sidebarEl.setAttribute("inert", "");
105
101
  }
106
- (_a = this.focusTrap) === null || _a === void 0 ? void 0 : _a.deactivate({ returnFocus: true });
107
102
  }
108
103
  render() {
109
104
  const className = classnames("console-layout", {
@@ -142,7 +137,9 @@ export class FlipConsoleLayout {
142
137
  h("flip-heading", { as: "h2", class: "console-layout__heading", headingId: "heading", level: 1, text: this.heading }),
143
138
  this.subheading && (h("flip-text", { class: "console-layout__subheading", color: "subdued" }, this.subheading)))),
144
139
  h("div", { class: "console-layout__integration" },
145
- h("slot", { name: "content" })))))));
140
+ h("slot", { name: "content" }))),
141
+ h("div", { class: "console-layout__overlays" },
142
+ h("slot", { name: "overlays" }))))));
146
143
  }
147
144
  static get is() { return "flip-console-layout"; }
148
145
  static get encapsulation() { return "shadow"; }
@@ -25,6 +25,7 @@ export class FlipPopover {
25
25
  };
26
26
  this.onKeydown = (event) => {
27
27
  if (event.code === "Escape" && this.active) {
28
+ event.stopPropagation();
28
29
  this.close();
29
30
  }
30
31
  };