@getflip/swirl-components 0.402.0 → 0.403.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.
@@ -17,7 +17,7 @@ export class SwirlPopover {
17
17
  this.returnFocusToTrigger = true;
18
18
  this.active = false;
19
19
  this.closing = false;
20
- this.toggle = (event) => {
20
+ this.togglePopover = (event) => {
21
21
  event.stopPropagation();
22
22
  if (this.active) {
23
23
  this.close();
@@ -189,6 +189,17 @@ export class SwirlPopover {
189
189
  async isOpen() {
190
190
  return this.active && !this.closing;
191
191
  }
192
+ /**
193
+ * Toggles the popover.
194
+ */
195
+ async toggle(triggerEl) {
196
+ if (this.active) {
197
+ this.close();
198
+ }
199
+ else {
200
+ this.open(triggerEl);
201
+ }
202
+ }
192
203
  connectTrigger() {
193
204
  if (!Boolean(this.trigger)) {
194
205
  this.triggerEl = undefined;
@@ -202,7 +213,7 @@ export class SwirlPopover {
202
213
  return;
203
214
  }
204
215
  this.triggerEl.addEventListener("click", (event) => {
205
- this.toggle(event);
216
+ this.togglePopover(event);
206
217
  });
207
218
  }
208
219
  getNativeTriggerElement() {
@@ -270,14 +281,14 @@ export class SwirlPopover {
270
281
  "popover--transparent": this.transparent,
271
282
  "popover--padded": this.padded,
272
283
  });
273
- return (h(Host, { key: 'cae2c409308bf89dc66f2b89456568046aaded46', style: { display: this.active ? "inline-flex" : "none" } }, h("div", { key: 'db3717521769c75c2653098cbb625224dbb2eb55', class: className, onKeyDown: this.onKeydown }, h("div", { key: '3aab5c2bb11f1beea924f3c7de4e65a1fc8eb1d7', "aria-hidden": !this.active ? "true" : "false", "aria-label": this.label, class: "popover__content", id: this.popoverId, part: "popover__content", role: "dialog", ref: (el) => (this.contentContainer = el), style: {
284
+ return (h(Host, { key: '20930a84eeb5cf30530117d809323e552b53f2b5', style: { display: this.active ? "inline-flex" : "none" } }, h("div", { key: '390101c87f025ef7eb61b880b70b0577c183e62f', class: className, onKeyDown: this.onKeydown }, h("div", { key: 'c3feb1eb33a7fc3ca59306b72fceadf6d0e89f25', "aria-hidden": !this.active ? "true" : "false", "aria-label": this.label, class: "popover__content", id: this.popoverId, part: "popover__content", role: "dialog", ref: (el) => (this.contentContainer = el), style: {
274
285
  top: Boolean(this.position) ? `${this.position?.y}px` : "",
275
286
  left: Boolean(this.position) ? `${this.position?.x}px` : "",
276
- }, tabindex: "-1" }, h("span", { key: '8e448d47cb436bf6480559afc079eb6bce38fe12', class: "popover__handle" }), h("div", { key: '86c8939a2de68df053efacb31bdc97707007259f', class: "popover__scroll-container", part: "popover__scroll-container", ref: (el) => (this.scrollContainer = el), style: {
287
+ }, tabindex: "-1" }, h("span", { key: '47ef833faab1dcae48d5369a9caf4a9272d8733c', class: "popover__handle" }), h("div", { key: '02c79e428646f063b18c2fff68a826e004f0c4b1', class: "popover__scroll-container", part: "popover__scroll-container", ref: (el) => (this.scrollContainer = el), style: {
277
288
  maxHeight: !mobile && Boolean(this.maxHeight)
278
289
  ? this.maxHeight
279
290
  : undefined,
280
- } }, h("slot", { key: 'a5cd47d451b4cd8874b3f76a2dcab3818d71ab1c' }))), this.active && (h("div", { key: '05fbf70a43239cca62a57ca654aa78c3914069da', class: "popover__backdrop", onClick: this.onCloseButtonClick })))));
291
+ } }, h("slot", { key: 'c06749f1f530d2d9639849232b1ba84775c434c8' }))), this.active && (h("div", { key: '644eb0090c7244cfa3f16b26bfce5a2d04687c77', class: "popover__backdrop", onClick: this.onCloseButtonClick })))));
281
292
  }
282
293
  static get is() { return "swirl-popover"; }
283
294
  static get encapsulation() { return "shadow"; }
@@ -731,6 +742,31 @@ export class SwirlPopover {
731
742
  "text": "Promise<boolean>"
732
743
  }]
733
744
  }
745
+ },
746
+ "toggle": {
747
+ "complexType": {
748
+ "signature": "(triggerEl?: HTMLElement) => Promise<void>",
749
+ "parameters": [{
750
+ "name": "triggerEl",
751
+ "type": "HTMLElement",
752
+ "docs": ""
753
+ }],
754
+ "references": {
755
+ "Promise": {
756
+ "location": "global",
757
+ "id": "global::Promise"
758
+ },
759
+ "HTMLElement": {
760
+ "location": "global",
761
+ "id": "global::HTMLElement"
762
+ }
763
+ },
764
+ "return": "Promise<void>"
765
+ },
766
+ "docs": {
767
+ "text": "Toggles the popover.",
768
+ "tags": []
769
+ }
734
770
  }
735
771
  };
736
772
  }
@@ -51,7 +51,7 @@ export class SwirlPopoverTrigger {
51
51
  return;
52
52
  const popoverEl = this.getPopoverEl();
53
53
  const triggerEl = this.getTriggerEl();
54
- popoverEl.open(triggerEl);
54
+ popoverEl.toggle(triggerEl);
55
55
  popoverEl.addEventListener("popoverOpen", () => {
56
56
  this.updateTriggerElAriaAttributes(true);
57
57
  }, { once: true });
@@ -153,7 +153,7 @@ export class SwirlPopoverTrigger {
153
153
  return isActive;
154
154
  }
155
155
  render() {
156
- return (h(Host, { key: 'd29a8367b14d3539999b84e5e853a5718f1e4b44', onClick: this.onClick, onMouseenter: this.onMouseenter, onMouseleave: this.onMouseleave }, h("slot", { key: '614ece098209821558723743a5ddf9b230a7b222' })));
156
+ return (h(Host, { key: '9d1fa62750efba0d0272daa9f2417188d5d5f48d', onClick: this.onClick, onMouseenter: this.onMouseenter, onMouseleave: this.onMouseleave }, h("slot", { key: 'bff58df5b11475f2367f6d86c939ac36c0c0116b' })));
157
157
  }
158
158
  static get is() { return "swirl-popover-trigger"; }
159
159
  static get encapsulation() { return "scoped"; }