@getflip/swirl-components 0.152.1 → 0.153.0

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.
@@ -27,6 +27,9 @@ export class SwirlPopoverTrigger {
27
27
  return;
28
28
  }
29
29
  const triggerEl = this.getTriggerEl();
30
+ if (!Boolean(triggerEl)) {
31
+ return;
32
+ }
30
33
  const popoverId = typeof this.popover === "string" ? this.popover : this.popover?.id;
31
34
  if (triggerEl.tagName.startsWith("SWIRL-")) {
32
35
  triggerEl.setAttribute("swirl-aria-controls", popoverId);
@@ -1,4 +1,4 @@
1
- import { h, Host, } from "@stencil/core";
1
+ import { h, Host } from "@stencil/core";
2
2
  import classnames from "classnames";
3
3
  import { getDesktopMediaQuery } from "../../utils";
4
4
  export class SwirlTextInput {
@@ -114,6 +114,12 @@ export class SwirlTextInput {
114
114
  disconnectedCallback() {
115
115
  this.desktopMediaQuery.removeEventListener?.("change", this.desktopMediaQueryHandler);
116
116
  }
117
+ async blurInput() {
118
+ this.inputEl.blur();
119
+ }
120
+ async focusInput() {
121
+ this.inputEl.focus();
122
+ }
117
123
  watchValue(newValue, oldValue) {
118
124
  if (newValue !== oldValue) {
119
125
  this.valueChange.emit(newValue);
@@ -775,6 +781,42 @@ export class SwirlTextInput {
775
781
  }
776
782
  }];
777
783
  }
784
+ static get methods() {
785
+ return {
786
+ "blurInput": {
787
+ "complexType": {
788
+ "signature": "() => Promise<void>",
789
+ "parameters": [],
790
+ "references": {
791
+ "Promise": {
792
+ "location": "global"
793
+ }
794
+ },
795
+ "return": "Promise<void>"
796
+ },
797
+ "docs": {
798
+ "text": "",
799
+ "tags": []
800
+ }
801
+ },
802
+ "focusInput": {
803
+ "complexType": {
804
+ "signature": "() => Promise<void>",
805
+ "parameters": [],
806
+ "references": {
807
+ "Promise": {
808
+ "location": "global"
809
+ }
810
+ },
811
+ "return": "Promise<void>"
812
+ },
813
+ "docs": {
814
+ "text": "",
815
+ "tags": []
816
+ }
817
+ }
818
+ };
819
+ }
778
820
  static get watchers() {
779
821
  return [{
780
822
  "propName": "value",
@@ -86,4 +86,26 @@ describe("swirl-text-input", () => {
86
86
  expect(spy).toHaveBeenCalled();
87
87
  expect(spy.mock.calls[0][0].detail).toBe("New Value");
88
88
  });
89
+ it("can focus", async () => {
90
+ const page = await newSpecPage({
91
+ components: [SwirlTextInput],
92
+ html: `<swirl-text-input value="Value"></swirl-text-input>`,
93
+ });
94
+ const spy = jest.fn();
95
+ const input = page.root.querySelector(".text-input__input");
96
+ input.addEventListener("focus", spy);
97
+ page.rootInstance.focusInput();
98
+ expect(spy).toHaveBeenCalled();
99
+ });
100
+ it("can blur", async () => {
101
+ const page = await newSpecPage({
102
+ components: [SwirlTextInput],
103
+ html: `<swirl-text-input value="Value"></swirl-text-input>`,
104
+ });
105
+ const spy = jest.fn();
106
+ const input = page.root.querySelector(".text-input__input");
107
+ input.addEventListener("blur", spy);
108
+ page.rootInstance.blurInput();
109
+ expect(spy).toHaveBeenCalled();
110
+ });
89
111
  });