@fluid-topics/ft-wc-utils 1.2.50 → 1.2.52

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.
@@ -8,7 +8,7 @@ declare const dynamicDependenciesLoaded: unique symbol;
8
8
  export type FtElementToFocus = {
9
9
  element?: Optional<HTMLElement>;
10
10
  selector?: string;
11
- isKeyboardNavigation?: boolean;
11
+ shadowPath?: string[];
12
12
  };
13
13
  export declare class FtLitElement extends ScopedRegistryLitElement {
14
14
  exportpartsPrefix?: string;
@@ -9,6 +9,7 @@ import { property, state } from "lit/decorators.js";
9
9
  import { jsonProperty } from "./decorators";
10
10
  import { Debouncer } from "./Debouncer";
11
11
  import { ScopedRegistryLitElement } from "./ScopedRegistryLitElement";
12
+ import { shadowQuerySelector } from "./shadowQuerySelector";
12
13
  const constructorPrototype = Symbol("constructorPrototype");
13
14
  const constructorName = Symbol("constructorName");
14
15
  const exportpartsDebouncer = Symbol("exportpartsDebouncer");
@@ -57,12 +58,13 @@ export class FtLitElement extends ScopedRegistryLitElement {
57
58
  }
58
59
  contentAvailableCallback(props) {
59
60
  if (props.has("elementToFocus") && this.elementToFocus != null) {
60
- let { element, selector, isKeyboardNavigation } = this.elementToFocus;
61
+ let { element, selector, shadowPath } = this.elementToFocus;
61
62
  if (selector != null) {
62
- element = this.shadowRoot.querySelector(selector);
63
+ const selectors = [...shadowPath !== null && shadowPath !== void 0 ? shadowPath : [], selector];
64
+ element = shadowQuerySelector(this.shadowRoot, ...selectors);
63
65
  }
64
66
  element === null || element === void 0 ? void 0 : element.focus();
65
- if (!isKeyboardNavigation) {
67
+ if (!window.FluidTopicsA11yHints.isKeyboardNavigation) {
66
68
  element === null || element === void 0 ? void 0 : element.blur();
67
69
  }
68
70
  this.elementToFocus = undefined;
@@ -0,0 +1,3 @@
1
+ export declare class FocusMainContentEvent extends Event {
2
+ constructor();
3
+ }
@@ -0,0 +1,5 @@
1
+ export class FocusMainContentEvent extends Event {
2
+ constructor() {
3
+ super("ft-focus-main-content", { composed: true, bubbles: true });
4
+ }
5
+ }
@@ -0,0 +1,8 @@
1
+ export interface FluidTopicsA11yHints {
2
+ isKeyboardNavigation: boolean;
3
+ }
4
+ declare global {
5
+ interface Window {
6
+ FluidTopicsA11yHints: FluidTopicsA11yHints;
7
+ }
8
+ }
@@ -0,0 +1,15 @@
1
+ window.FluidTopicsA11yHints = {
2
+ isKeyboardNavigation: false,
3
+ };
4
+ function onKeyDown(event) {
5
+ if (event.key === "Enter" || event.key === " " || event.key === "Tab") {
6
+ window.FluidTopicsA11yHints.isKeyboardNavigation = true;
7
+ }
8
+ }
9
+ function onClick(event) {
10
+ // event.detail contains the number of clicks. If it is equal to 0, that means we are using a keyboard
11
+ window.FluidTopicsA11yHints.isKeyboardNavigation = event.detail == 0;
12
+ }
13
+ document.body.addEventListener("keydown", onKeyDown);
14
+ document.body.addEventListener("click", onClick);
15
+ export {};