@fluid-topics/ft-wc-utils 1.2.48 → 1.2.49

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,13 +1,20 @@
1
1
  import { PropertyValues } from "lit";
2
2
  import { ScopedRegistryLitElement } from "./ScopedRegistryLitElement";
3
+ import { Optional } from "./generic-types";
3
4
  declare const constructorPrototype: unique symbol;
4
5
  declare const constructorName: unique symbol;
5
6
  declare const exportpartsDebouncer: unique symbol;
6
7
  declare const dynamicDependenciesLoaded: unique symbol;
8
+ export type FtElementToFocus = {
9
+ element?: Optional<HTMLElement>;
10
+ selector?: string;
11
+ isKeyboardNavigation?: boolean;
12
+ };
7
13
  export declare class FtLitElement extends ScopedRegistryLitElement {
8
14
  exportpartsPrefix?: string;
9
15
  exportpartsPrefixes?: string[];
10
16
  customStylesheet?: string;
17
+ elementToFocus?: FtElementToFocus;
11
18
  private useAdoptedStyleSheets;
12
19
  private adoptedCustomStyleSheet;
13
20
  private readonly [constructorPrototype];
@@ -56,6 +56,17 @@ export class FtLitElement extends ScopedRegistryLitElement {
56
56
  });
57
57
  }
58
58
  contentAvailableCallback(props) {
59
+ if (props.has("elementToFocus") && this.elementToFocus != null) {
60
+ let { element, selector, isKeyboardNavigation } = this.elementToFocus;
61
+ if (selector != null) {
62
+ element = this.shadowRoot.querySelector(selector);
63
+ }
64
+ element === null || element === void 0 ? void 0 : element.focus();
65
+ if (!isKeyboardNavigation) {
66
+ element === null || element === void 0 ? void 0 : element.blur();
67
+ }
68
+ this.elementToFocus = undefined;
69
+ }
59
70
  }
60
71
  applyCustomStylesheet(props) {
61
72
  var _b, _c, _d;
@@ -128,6 +139,9 @@ __decorate([
128
139
  __decorate([
129
140
  property()
130
141
  ], FtLitElement.prototype, "customStylesheet", void 0);
142
+ __decorate([
143
+ property()
144
+ ], FtLitElement.prototype, "elementToFocus", void 0);
131
145
  __decorate([
132
146
  state()
133
147
  ], FtLitElement.prototype, "useAdoptedStyleSheets", void 0);