@getflip/swirl-components 0.78.1 → 0.80.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.
Files changed (88) hide show
  1. package/components.json +140 -6
  2. package/dist/cjs/file-manager.cjs.entry.js +2 -1
  3. package/dist/cjs/index-506fe4ea.js +2 -2
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/swirl-app-layout_7.cjs.entry.js +7 -4
  6. package/dist/cjs/swirl-button.cjs.entry.js +3 -1
  7. package/dist/cjs/swirl-components.cjs.js +1 -1
  8. package/dist/cjs/swirl-date-input.cjs.entry.js +1 -1
  9. package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
  10. package/dist/cjs/swirl-pdf-reader.cjs.entry.js +2 -2
  11. package/dist/cjs/{swirl-popover.cjs.entry.js → swirl-popover_2.cjs.entry.js} +105 -18
  12. package/dist/cjs/swirl-select.cjs.entry.js +2 -2
  13. package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
  14. package/dist/collection/collection-manifest.json +1 -0
  15. package/dist/collection/components/swirl-button/swirl-button.js +37 -1
  16. package/dist/collection/components/swirl-date-input/swirl-date-input.js +1 -1
  17. package/dist/collection/components/swirl-date-input/swirl-date-input.spec.js +6 -4
  18. package/dist/collection/components/swirl-lightbox/swirl-lightbox.js +1 -1
  19. package/dist/collection/components/swirl-lightbox/swirl-lightbox.spec.js +6 -4
  20. package/dist/collection/components/swirl-menu/swirl-menu.spec.js +38 -14
  21. package/dist/collection/components/swirl-menu/swirl-menu.stories.js +35 -33
  22. package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.js +2 -2
  23. package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.spec.js +4 -2
  24. package/dist/collection/components/swirl-popover/swirl-popover.js +53 -39
  25. package/dist/collection/components/swirl-popover/swirl-popover.spec.js +20 -11
  26. package/dist/collection/components/swirl-popover/swirl-popover.stories.js +8 -25
  27. package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.css +3 -0
  28. package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.js +132 -0
  29. package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.spec.js +26 -0
  30. package/dist/collection/components/swirl-popover-trigger/swirl-popover-trigger.stories.js +48 -0
  31. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.css +7 -0
  32. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.js +7 -3
  33. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js +1 -0
  34. package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.stories.js +29 -29
  35. package/dist/collection/components/swirl-select/swirl-select.js +2 -2
  36. package/dist/collection/components/swirl-select/swirl-select.spec.js +4 -2
  37. package/dist/collection/prototypes/file-manager/file-manager.js +4 -2
  38. package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
  39. package/dist/components/file-manager.js +54 -46
  40. package/dist/components/swirl-button2.js +5 -1
  41. package/dist/components/swirl-date-input.js +13 -7
  42. package/dist/components/swirl-lightbox.js +21 -15
  43. package/dist/components/swirl-pdf-reader.js +48 -42
  44. package/dist/components/swirl-popover-trigger.d.ts +11 -0
  45. package/dist/components/swirl-popover-trigger.js +6 -0
  46. package/dist/components/swirl-popover-trigger2.js +99 -0
  47. package/dist/components/swirl-popover2.js +27 -19
  48. package/dist/components/swirl-resource-list-item2.js +19 -10
  49. package/dist/components/swirl-select.js +18 -12
  50. package/dist/esm/file-manager.entry.js +2 -1
  51. package/dist/esm/index-99d0060d.js +2 -2
  52. package/dist/esm/loader.js +1 -1
  53. package/dist/esm/swirl-app-layout_7.entry.js +7 -4
  54. package/dist/esm/swirl-button.entry.js +3 -1
  55. package/dist/esm/swirl-components.js +1 -1
  56. package/dist/esm/swirl-date-input.entry.js +1 -1
  57. package/dist/esm/swirl-lightbox.entry.js +1 -1
  58. package/dist/esm/swirl-pdf-reader.entry.js +2 -2
  59. package/dist/esm/{swirl-popover.entry.js → swirl-popover_2.entry.js} +105 -19
  60. package/dist/esm/swirl-select.entry.js +2 -2
  61. package/dist/swirl-components/p-0fce283f.entry.js +1 -0
  62. package/dist/swirl-components/p-2278aeae.entry.js +1 -0
  63. package/dist/swirl-components/p-251884ec.entry.js +1 -0
  64. package/dist/swirl-components/{p-a16a6381.entry.js → p-30ae7d5c.entry.js} +1 -1
  65. package/dist/swirl-components/p-3abcd491.entry.js +1 -0
  66. package/dist/swirl-components/p-6832ee6c.entry.js +1 -0
  67. package/dist/swirl-components/p-794d25e2.entry.js +1 -0
  68. package/dist/swirl-components/p-ed921838.entry.js +1 -0
  69. package/dist/swirl-components/swirl-components.esm.js +1 -1
  70. package/dist/types/components/swirl-button/swirl-button.d.ts +2 -0
  71. package/dist/types/components/swirl-popover/swirl-popover.d.ts +4 -5
  72. package/dist/types/components/swirl-popover/swirl-popover.stories.d.ts +0 -3
  73. package/dist/types/components/swirl-popover-trigger/swirl-popover-trigger.d.ts +13 -0
  74. package/dist/types/components/swirl-popover-trigger/swirl-popover-trigger.stories.d.ts +22 -0
  75. package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.d.ts +1 -0
  76. package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.stories.d.ts +8 -3
  77. package/dist/types/components.d.ts +26 -5
  78. package/dist/types/prototypes/file-manager/file-manager.d.ts +1 -0
  79. package/package.json +1 -1
  80. package/vscode-data.json +25 -0
  81. package/dist/swirl-components/p-8c507544.entry.js +0 -1
  82. package/dist/swirl-components/p-acd95936.entry.js +0 -1
  83. package/dist/swirl-components/p-b105d565.entry.js +0 -1
  84. package/dist/swirl-components/p-b28fadcf.entry.js +0 -1
  85. package/dist/swirl-components/p-d98edc75.entry.js +0 -1
  86. package/dist/swirl-components/p-ef50db1d.entry.js +0 -1
  87. package/dist/swirl-components/p-f990566c.entry.js +0 -1
  88. package/dist/typings.d.ts +0 -1
@@ -197,6 +197,7 @@
197
197
  "./components/swirl-lightbox/swirl-lightbox.js",
198
198
  "./components/swirl-list/swirl-list.js",
199
199
  "./components/swirl-menu-item/swirl-menu-item.js",
200
+ "./components/swirl-popover-trigger/swirl-popover-trigger.js",
200
201
  "./components/swirl-option-list/swirl-option-list.js",
201
202
  "./components/swirl-option-list-section/swirl-option-list-section.js",
202
203
  "./components/swirl-pdf-reader/swirl-pdf-reader.js",
@@ -9,8 +9,10 @@ export class SwirlButton {
9
9
  };
10
10
  this.disabled = undefined;
11
11
  this.download = undefined;
12
+ this.swirlAriaControls = undefined;
12
13
  this.swirlAriaDescribedby = undefined;
13
14
  this.swirlAriaExpanded = undefined;
15
+ this.swirlAriaHaspopup = undefined;
14
16
  this.swirlAriaLabel = undefined;
15
17
  this.form = undefined;
16
18
  this.hideLabel = undefined;
@@ -64,7 +66,7 @@ export class SwirlButton {
64
66
  "button--pill": this.pill,
65
67
  });
66
68
  const Tag = isLink ? "a" : "button";
67
- return (h(Host, { style: { pointerEvents: this.disabled ? "none" : "" } }, h(Tag, { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled && !isLink ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-label": ariaLabel, class: className, disabled: isLink ? undefined : this.disabled, download: isLink ? undefined : this.download, form: isLink ? undefined : this.form, href: this.href, name: isLink ? undefined : this.name, target: isLink ? this.target : undefined, type: isLink ? undefined : this.type, value: isLink ? undefined : this.value }, this.icon && (h("span", { class: "button__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) })), !hideLabel && h("span", { class: "button__label" }, this.label))));
69
+ return (h(Host, { style: { pointerEvents: this.disabled ? "none" : "" } }, h(Tag, { "aria-controls": this.swirlAriaControls, "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled && !isLink ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-haspopup": this.swirlAriaHaspopup, "aria-label": ariaLabel, class: className, disabled: isLink ? undefined : this.disabled, download: isLink ? undefined : this.download, form: isLink ? undefined : this.form, href: this.href, name: isLink ? undefined : this.name, target: isLink ? this.target : undefined, type: isLink ? undefined : this.type, value: isLink ? undefined : this.value }, this.icon && (h("span", { class: "button__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) })), !hideLabel && h("span", { class: "button__label" }, this.label))));
68
70
  }
69
71
  static get is() { return "swirl-button"; }
70
72
  static get encapsulation() { return "scoped"; }
@@ -114,6 +116,23 @@ export class SwirlButton {
114
116
  "attribute": "download",
115
117
  "reflect": false
116
118
  },
119
+ "swirlAriaControls": {
120
+ "type": "string",
121
+ "mutable": false,
122
+ "complexType": {
123
+ "original": "string",
124
+ "resolved": "string",
125
+ "references": {}
126
+ },
127
+ "required": false,
128
+ "optional": true,
129
+ "docs": {
130
+ "tags": [],
131
+ "text": ""
132
+ },
133
+ "attribute": "swirl-aria-controls",
134
+ "reflect": false
135
+ },
117
136
  "swirlAriaDescribedby": {
118
137
  "type": "string",
119
138
  "mutable": false,
@@ -148,6 +167,23 @@ export class SwirlButton {
148
167
  "attribute": "swirl-aria-expanded",
149
168
  "reflect": false
150
169
  },
170
+ "swirlAriaHaspopup": {
171
+ "type": "string",
172
+ "mutable": false,
173
+ "complexType": {
174
+ "original": "string",
175
+ "resolved": "string",
176
+ "references": {}
177
+ },
178
+ "required": false,
179
+ "optional": true,
180
+ "docs": {
181
+ "tags": [],
182
+ "text": ""
183
+ },
184
+ "attribute": "swirl-aria-haspopup",
185
+ "reflect": false
186
+ },
151
187
  "swirlAriaLabel": {
152
188
  "type": "string",
153
189
  "mutable": false,
@@ -103,7 +103,7 @@ export class SwirlDateInput {
103
103
  const className = classnames("date-input", {
104
104
  "date-input--inline": this.inline,
105
105
  });
106
- return (h(Host, null, h("div", { class: className }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "date-input__input", disabled: this.disabled, id: this.id, onClick: this.onClick, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, required: this.required, type: "text", value: displayValue }), h("button", { "aria-label": this.datePickerTriggerLabel, class: "date-input__date-picker-button", disabled: this.disabled, id: `${this.id}-trigger`, type: "button" }, h("swirl-icon-today", { size: this.iconSize }))), !this.disabled && (h("swirl-popover", { animation: "scale-in-y", label: this.datePickerLabel, placement: "bottom-end", popoverId: `popover-${this.id}`, ref: (el) => (this.pickerPopover = el), trigger: `${this.id}-trigger` }, h("swirl-date-picker", { labels: this.labels, locale: this.locale, onValueChange: this.onPickDate, value: dateValue })))));
106
+ return (h(Host, null, h("div", { class: className }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "date-input__input", disabled: this.disabled, id: this.id, onClick: this.onClick, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, required: this.required, type: "text", value: displayValue }), h("swirl-popover-trigger", { popover: `popover-${this.id}` }, h("button", { "aria-label": this.datePickerTriggerLabel, class: "date-input__date-picker-button", disabled: this.disabled, type: "button" }, h("swirl-icon-today", { size: this.iconSize })))), !this.disabled && (h("swirl-popover", { animation: "scale-in-y", id: `popover-${this.id}`, label: this.datePickerLabel, placement: "bottom-end", ref: (el) => (this.pickerPopover = el) }, h("swirl-date-picker", { labels: this.labels, locale: this.locale, onValueChange: this.onPickDate, value: dateValue })))));
107
107
  }
108
108
  static get is() { return "swirl-date-input"; }
109
109
  static get encapsulation() { return "scoped"; }
@@ -17,11 +17,13 @@ describe("swirl-date-input", () => {
17
17
  <swirl-date-input>
18
18
  <div class="date-input">
19
19
  <input class="date-input__input" id="swirl-date-input-0" placeholder="yyyy-mm-dd" type="text">
20
- <button aria-label="Open date picker" class="date-input__date-picker-button" id="swirl-date-input-0-trigger" type="button">
21
- <swirl-icon-today size="24"></swirl-icon-today>
22
- </button>
20
+ <swirl-popover-trigger popover="popover-swirl-date-input-0">
21
+ <button aria-label="Open date picker" class="date-input__date-picker-button" type="button">
22
+ <swirl-icon-today size="24"></swirl-icon-today>
23
+ </button>
24
+ </swirl-popover-trigger>
23
25
  </div>
24
- <swirl-popover animation="scale-in-y" label="Date picker" placement="bottom-end" popoverid="popover-swirl-date-input-0" trigger="swirl-date-input-0-trigger">
26
+ <swirl-popover animation="scale-in-y" id="popover-swirl-date-input-0" label="Date picker" placement="bottom-end">
25
27
  <swirl-date-picker locale="en-US"></swirl-date-picker>
26
28
  </swirl-popover>
27
29
  </swirl-date-input>
@@ -226,7 +226,7 @@ export class SwirlLightbox {
226
226
  const className = classnames("lightbox", {
227
227
  "lightbox--closing": this.closing,
228
228
  });
229
- return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "lightbox", onMouseDown: this.onPointerDown, onMouseMove: this.onPointerMove, onMouseOut: this.onPointerUp, onMouseUp: this.onPointerUp, onKeyDown: this.onKeyDown, onTouchEnd: this.onPointerUp, onTouchMove: this.onPointerMove, onTouchStart: this.onPointerDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "lightbox__body", role: "document" }, h("header", { class: "lightbox__header" }, h("button", { "aria-label": this.closeButtonLabel, class: "lightbox__close-button", onClick: this.onCloseButtonClick }, h("swirl-icon-close", null)), h("button", { "aria-label": this.menuTriggerLabel, class: "lightbox__menu-button", id: "slide-menu-trigger" }, h("swirl-icon-more-vertikal", null))), h("div", { "aria-roledescription": "carousel", class: "lightbox__content", role: "group" }, h("div", { "aria-atomic": "false", "aria-live": "polite", class: "lightbox__slides" }, h("slot", { onSlotchange: this.registerSlides }))), h("div", { class: "lightbox__controls" }, h("button", { "aria-label": this.previousSlideButtonLabel, class: "lightbox__previous-slide-button", disabled: this.activeSlideIndex === 0, onClick: this.onPreviousSlideClick }, h("swirl-icon-arrow-left", null)), h("button", { "aria-label": this.nextSlideButtonLabel, class: "lightbox__next-slide-button", disabled: this.activeSlideIndex === this.slides.length - 1, onClick: this.onNextSlideClick }, h("swirl-icon-arrow-right", null))), showPagination && (h("span", { class: "lightbox__pagination" }, h("span", { "aria-current": "page" }, this.activeSlideIndex + 1), " /", " ", this.slides.length))), h("swirl-popover", { animation: "scale-in-y", disableScrollLock: true, label: this.menuLabel, placement: "bottom-end", popoverId: "slide-menu", ref: (el) => (this.menu = el), trigger: "slide-menu-trigger" }, h("swirl-stack", null, h("div", { class: "lightbox__meta" }, currentThumbnailUrl && (h("div", { class: "lightbox__thumbnail" }, h("swirl-thumbnail", { alt: "", src: currentThumbnailUrl }))), h("div", { class: "lightbox__file-info" }, h("swirl-text", { truncate: true, weight: "semibold" }, currentFileName), h("swirl-text", { color: "subdued", size: "sm", truncate: true }, currentFileType))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { icon: "<swirl-icon-download></swirl-icon-download>", label: this.downloadButtonLabel, onClick: this.onDownloadButtonClick }), h("slot", { name: "menu-items" })))))));
229
+ return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "lightbox", onMouseDown: this.onPointerDown, onMouseMove: this.onPointerMove, onMouseOut: this.onPointerUp, onMouseUp: this.onPointerUp, onKeyDown: this.onKeyDown, onTouchEnd: this.onPointerUp, onTouchMove: this.onPointerMove, onTouchStart: this.onPointerDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "lightbox__body", role: "document" }, h("header", { class: "lightbox__header" }, h("button", { "aria-label": this.closeButtonLabel, class: "lightbox__close-button", onClick: this.onCloseButtonClick }, h("swirl-icon-close", null)), h("swirl-popover-trigger", { popover: this.menu }, h("button", { "aria-label": this.menuTriggerLabel, class: "lightbox__menu-button" }, h("swirl-icon-more-vertikal", null)))), h("div", { "aria-roledescription": "carousel", class: "lightbox__content", role: "group" }, h("div", { "aria-atomic": "false", "aria-live": "polite", class: "lightbox__slides" }, h("slot", { onSlotchange: this.registerSlides }))), h("div", { class: "lightbox__controls" }, h("button", { "aria-label": this.previousSlideButtonLabel, class: "lightbox__previous-slide-button", disabled: this.activeSlideIndex === 0, onClick: this.onPreviousSlideClick }, h("swirl-icon-arrow-left", null)), h("button", { "aria-label": this.nextSlideButtonLabel, class: "lightbox__next-slide-button", disabled: this.activeSlideIndex === this.slides.length - 1, onClick: this.onNextSlideClick }, h("swirl-icon-arrow-right", null))), showPagination && (h("span", { class: "lightbox__pagination" }, h("span", { "aria-current": "page" }, this.activeSlideIndex + 1), " /", " ", this.slides.length))), h("swirl-popover", { animation: "scale-in-y", disableScrollLock: true, id: "slide-menu", label: this.menuLabel, placement: "bottom-end", ref: (el) => (this.menu = el) }, h("swirl-stack", null, h("div", { class: "lightbox__meta" }, currentThumbnailUrl && (h("div", { class: "lightbox__thumbnail" }, h("swirl-thumbnail", { alt: "", src: currentThumbnailUrl }))), h("div", { class: "lightbox__file-info" }, h("swirl-text", { truncate: true, weight: "semibold" }, currentFileName), h("swirl-text", { color: "subdued", size: "sm", truncate: true }, currentFileType))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { icon: "<swirl-icon-download></swirl-icon-download>", label: this.downloadButtonLabel, onClick: this.onDownloadButtonClick }), h("slot", { name: "menu-items" })))))));
230
230
  }
231
231
  static get is() { return "swirl-lightbox"; }
232
232
  static get encapsulation() { return "shadow"; }
@@ -28,9 +28,11 @@ describe("swirl-lightbox", () => {
28
28
  <button aria-label="Close" class="lightbox__close-button">
29
29
  <swirl-icon-close></swirl-icon-close>
30
30
  </button>
31
- <button aria-label="Open slide menu" class="lightbox__menu-button" id="slide-menu-trigger">
32
- <swirl-icon-more-vertikal></swirl-icon-more-vertikal>
33
- </button>
31
+ <swirl-popover-trigger>
32
+ <button aria-label="Open slide menu" class="lightbox__menu-button">
33
+ <swirl-icon-more-vertikal></swirl-icon-more-vertikal>
34
+ </button>
35
+ </swirl-popover-trigger>
34
36
  </header>
35
37
  <div aria-roledescription="carousel" class="lightbox__content" role="group">
36
38
  <div aria-atomic="false" aria-live="polite" class="lightbox__slides">
@@ -49,7 +51,7 @@ describe("swirl-lightbox", () => {
49
51
  <span aria-current="page">1</span> / 2
50
52
  </span>
51
53
  </div>
52
- <swirl-popover animation="scale-in-y" disablescrolllock="" label="Slide options" placement="bottom-end" popoverid="slide-menu" trigger="slide-menu-trigger">
54
+ <swirl-popover animation="scale-in-y" disablescrolllock="" id="slide-menu" label="Slide options" placement="bottom-end">
53
55
  <swirl-stack>
54
56
  <div class="lightbox__meta">
55
57
  <div class="lightbox__file-info">
@@ -3,6 +3,7 @@ import { SwirlButton } from "../swirl-button/swirl-button";
3
3
  import { SwirlMenuItem } from "../swirl-menu-item/swirl-menu-item";
4
4
  import { SwirlPopover } from "../swirl-popover/swirl-popover";
5
5
  import { SwirlMenu } from "./swirl-menu";
6
+ import { SwirlPopoverTrigger } from "../swirl-popover-trigger/swirl-popover-trigger";
6
7
  global.DocumentFragment = class DocumentFragment extends Node {
7
8
  };
8
9
  global.ShadowRoot = class ShadowRoot extends DocumentFragment {
@@ -14,8 +15,10 @@ global.MutationObserver = class {
14
15
  };
15
16
  const template = `
16
17
  <div>
17
- <swirl-button id="trigger" label="Trigger"></swirl-button>
18
- <swirl-popover label="Menu" trigger="trigger">
18
+ <swirl-popover-trigger popover="menu">
19
+ <swirl-button label="Trigger"></swirl-button>
20
+ </swirl-popover-trigger>
21
+ <swirl-popover label="Menu" id="menu">
19
22
  <swirl-menu label="Menu">
20
23
  <swirl-menu-item label="Item 1"></swirl-menu-item>
21
24
  <swirl-menu-item label="Item 2">
@@ -44,19 +47,28 @@ describe("swirl-menu", () => {
44
47
  });
45
48
  it("renders", async () => {
46
49
  const page = await newSpecPage({
47
- components: [SwirlButton, SwirlPopover, SwirlMenu, SwirlMenuItem],
50
+ components: [
51
+ SwirlButton,
52
+ SwirlPopover,
53
+ SwirlPopoverTrigger,
54
+ SwirlMenu,
55
+ SwirlMenuItem,
56
+ ],
48
57
  html: template,
49
58
  });
50
59
  expect(page.body.children[0]).toMatchInlineSnapshot(`
51
60
  <div>
52
- <swirl-button id="trigger" label="Trigger">
53
- <button aria-controls="undefined" aria-expanded="false" aria-haspopup="dialog" class="button button--icon-position-start button--intent-default button--size-m button--variant-ghost" type="button">
54
- <span class="button__label">
55
- Trigger
56
- </span>
57
- </button>
58
- </swirl-button>
59
- <swirl-popover label="Menu" trigger="trigger">
61
+ <swirl-popover-trigger popover="menu">
62
+ <!---->
63
+ <swirl-button label="Trigger" swirl-aria-controls="menu" swirl-aria-expanded="false" swirl-aria-haspopup="dialog">
64
+ <button aria-controls="menu" aria-expanded="false" aria-haspopup="dialog" class="button button--icon-position-start button--intent-default button--size-m button--variant-ghost" type="button">
65
+ <span class="button__label">
66
+ Trigger
67
+ </span>
68
+ </button>
69
+ </swirl-button>
70
+ </swirl-popover-trigger>
71
+ <swirl-popover id="menu" label="Menu">
60
72
  <mock:shadow-root>
61
73
  <div class="popover popover--animation-scale-in-xy popover--inactive popover--placement-undefined">
62
74
  <div aria-hidden="true" aria-label="Menu" class="popover__content" part="popover__content" role="dialog" tabindex="-1">
@@ -169,7 +181,13 @@ describe("swirl-menu", () => {
169
181
  });
170
182
  it("starts as active if root menu", async () => {
171
183
  const page = await newSpecPage({
172
- components: [SwirlButton, SwirlPopover, SwirlMenu, SwirlMenuItem],
184
+ components: [
185
+ SwirlButton,
186
+ SwirlPopover,
187
+ SwirlPopoverTrigger,
188
+ SwirlMenu,
189
+ SwirlMenuItem,
190
+ ],
173
191
  html: template,
174
192
  });
175
193
  const menu = page.body.querySelector("swirl-menu");
@@ -178,12 +196,18 @@ describe("swirl-menu", () => {
178
196
  });
179
197
  it("fires done event", async () => {
180
198
  const page = await newSpecPage({
181
- components: [SwirlButton, SwirlPopover, SwirlMenu, SwirlMenuItem],
199
+ components: [
200
+ SwirlButton,
201
+ SwirlPopover,
202
+ SwirlPopoverTrigger,
203
+ SwirlMenu,
204
+ SwirlMenuItem,
205
+ ],
182
206
  html: template,
183
207
  });
184
208
  const spy = jest.fn();
185
209
  const menu = page.body.querySelector("swirl-menu");
186
- const trigger = page.body.querySelector("#trigger");
210
+ const trigger = page.body.querySelector("swirl-popover-trigger");
187
211
  menu.addEventListener("done", spy);
188
212
  trigger.click();
189
213
  const doneButton = Array.from(menu.shadowRoot.querySelectorAll("swirl-button")).find((button) => button.innerText === "Done");
@@ -12,45 +12,47 @@ export default {
12
12
  };
13
13
  const Template = (args) => {
14
14
  const container = document.createElement("div");
15
- const trigger = document.createElement("swirl-button");
15
+ const trigger = document.createElement("swirl-popover-trigger");
16
16
  const popover = document.createElement("swirl-popover");
17
17
  const element = generateStoryElement("swirl-menu", args);
18
- trigger.id = "trigger";
19
- trigger.label = "Open menu";
18
+ trigger.popover = "menu-popover";
19
+ trigger.innerHTML = `
20
+ <swirl-button label="Open menu"></swirl-button>
21
+ `;
20
22
  popover.fullscreenBottomSheet = true;
23
+ popover.id = "menu-popover";
21
24
  popover.label = "Menu popover";
22
- popover.popoverId = "menu-popover";
23
25
  popover.trigger = "trigger";
24
26
  element.innerHTML = `
25
- <swirl-menu-item icon="<swirl-icon-copy></swirl-icon-copy>" label="Duplicate"></swirl-menu-item>
26
- <swirl-menu-item icon="<swirl-icon-delete></swirl-icon-delete>" intent="critical" label="Delete"></swirl-menu-item>
27
- <swirl-menu-item icon="<swirl-icon-ai></swirl-icon-ai>" label="AI features">
28
- <swirl-menu label="AI features">
29
- <swirl-menu-item label="Generate summary"></swirl-menu-item>
30
- <swirl-menu-item label="Simplify"></swirl-menu-item>
31
- <swirl-menu-item disabled label="Check spelling"></swirl-menu-item>
32
- </swirl-menu>
33
- </swirl-menu-item>
34
- <swirl-menu-item icon="<swirl-icon-edit></swirl-icon-edit>" label="Colors">
35
- <swirl-menu label="Colors menu" selection">
36
- <swirl-menu-item label="Text color">
37
- <swirl-menu label="Text color menu" value="blue" variant="selection">
38
- <swirl-menu-item label="Red" value="red"></swirl-menu-item>
39
- <swirl-menu-item label="Blue" value="blue"></swirl-menu-item>
40
- <swirl-menu-item label="Green" value="green"></swirl-menu-item>
41
- </swirl-menu>
42
- </swirl-menu-item>
43
- <swirl-menu-item label="Background color">
44
- <swirl-menu label="Background color menu" variant="selection">
45
- <swirl-menu-item label="Light" value="light"></swirl-menu-item>
46
- <swirl-menu-item label="Dark" value="dark"></swirl-menu-item>
47
- </swirl-menu>
48
- </swirl-menu-item>
49
- </swirl-menu>
50
- </swirl-menu-item>
51
- `;
52
- popover.append(element);
53
- container.append(trigger, popover);
27
+ <swirl-menu-item icon="<swirl-icon-copy></swirl-icon-copy>" label="Duplicate"></swirl-menu-item>
28
+ <swirl-menu-item icon="<swirl-icon-delete></swirl-icon-delete>" intent="critical" label="Delete"></swirl-menu-item>
29
+ <swirl-menu-item icon="<swirl-icon-ai></swirl-icon-ai>" label="AI features">
30
+ <swirl-menu label="AI features">
31
+ <swirl-menu-item label="Generate summary"></swirl-menu-item>
32
+ <swirl-menu-item label="Simplify"></swirl-menu-item>
33
+ <swirl-menu-item disabled label="Check spelling"></swirl-menu-item>
34
+ </swirl-menu>
35
+ </swirl-menu-item>
36
+ <swirl-menu-item icon="<swirl-icon-edit></swirl-icon-edit>" label="Colors">
37
+ <swirl-menu label="Colors menu" selection">
38
+ <swirl-menu-item label="Text color">
39
+ <swirl-menu label="Text color menu" value="blue" variant="selection">
40
+ <swirl-menu-item label="Red" value="red"></swirl-menu-item>
41
+ <swirl-menu-item label="Blue" value="blue"></swirl-menu-item>
42
+ <swirl-menu-item label="Green" value="green"></swirl-menu-item>
43
+ </swirl-menu>
44
+ </swirl-menu-item>
45
+ <swirl-menu-item label="Background color">
46
+ <swirl-menu label="Background color menu" variant="selection">
47
+ <swirl-menu-item label="Light" value="light"></swirl-menu-item>
48
+ <swirl-menu-item label="Dark" value="dark"></swirl-menu-item>
49
+ </swirl-menu>
50
+ </swirl-menu-item>
51
+ </swirl-menu>
52
+ </swirl-menu-item>
53
+ `;
54
+ popover.append("\n ", element, "\n ");
55
+ container.append("\n ", trigger, "\n ", popover, "\n");
54
56
  return container;
55
57
  };
56
58
  export const SwirlMenu = Template.bind({});
@@ -162,12 +162,12 @@ export class SwirlPdfReader {
162
162
  "pdf-reader--closing": this.closing,
163
163
  "pdf-reader--show-thumbnails": this.showThumbnails,
164
164
  });
165
- return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "pdf-reader", onKeyDown: this.onKeyDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "pdf-reader__body", role: "document" }, h("header", { class: "pdf-reader__header" }, h("span", { class: "pdf-reader__header-left" }, h("swirl-button", { class: "pdf-reader__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick }), h("span", { class: "pdf-reader__label" }, this.label)), h("span", { class: "pdf-reader__header-center" }, h("span", { class: "pdf-reader__zoom-button-container" }, h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[0], hideLabel: true, icon: "<swirl-icon-remove></swirl-icon-remove>", label: this.zoomOutButtonLabel, onClick: this.onZoomOutButtonClick }), h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], hideLabel: true, icon: "<swirl-icon-add></swirl-icon-add>", label: this.zoomInButtonLabel, onClick: this.onZoomInButtonClick })), h("span", { class: "pdf-reader__zoom-select-container" }, h("select", { "aria-label": this.zoomSelectLabel, class: "pdf-reader__zoom-select", name: "zoom-select", id: "zoom-select", onChange: this.onZoomChange }, h("option", { selected: this.zoom === "auto", value: "auto" }, this.autoZoomLabel), this.zoomSteps.map((zoom) => (h("option", { key: zoom, selected: this.zoom === zoom, value: zoom }, zoom * 100, "%")))), h("swirl-icon-expand-more", { class: "pdf-reader__zoom-select-icon" }))), h("span", { class: "pdf-reader__header-right" }, h("swirl-button", { class: "pdf-reader__menu-button", hideLabel: true, icon: "<swirl-icon-more-vertikal></swirl-icon-more-vertikal>", id: "menu-trigger", label: this.menuTriggerLabel })), h("span", { class: "pdf-reader__floating-tools" }, h("button", { "aria-label": this.sideBySideButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleViewMode, type: "button" }, h("swirl-icon-menu-book", null)), h("button", { "aria-controls": "thumbnails", "aria-expanded": String(Boolean(this.showThumbnails)), "aria-label": this.thumbnailsButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleThumbnals, type: "button" }, h("swirl-icon-file-copy", null)))), h("div", { class: "pdf-reader__content" }, h("nav", { "aria-label": this.thumbnailsLabel, class: "pdf-reader__thumbnails", id: "thumbnails" }, this.thumbnails.map((thumbnail, index) => {
165
+ return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "pdf-reader", onKeyDown: this.onKeyDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "pdf-reader__body", role: "document" }, h("header", { class: "pdf-reader__header" }, h("span", { class: "pdf-reader__header-left" }, h("swirl-button", { class: "pdf-reader__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick }), h("span", { class: "pdf-reader__label" }, this.label)), h("span", { class: "pdf-reader__header-center" }, h("span", { class: "pdf-reader__zoom-button-container" }, h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[0], hideLabel: true, icon: "<swirl-icon-remove></swirl-icon-remove>", label: this.zoomOutButtonLabel, onClick: this.onZoomOutButtonClick }), h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], hideLabel: true, icon: "<swirl-icon-add></swirl-icon-add>", label: this.zoomInButtonLabel, onClick: this.onZoomInButtonClick })), h("span", { class: "pdf-reader__zoom-select-container" }, h("select", { "aria-label": this.zoomSelectLabel, class: "pdf-reader__zoom-select", name: "zoom-select", id: "zoom-select", onChange: this.onZoomChange }, h("option", { selected: this.zoom === "auto", value: "auto" }, this.autoZoomLabel), this.zoomSteps.map((zoom) => (h("option", { key: zoom, selected: this.zoom === zoom, value: zoom }, zoom * 100, "%")))), h("swirl-icon-expand-more", { class: "pdf-reader__zoom-select-icon" }))), h("span", { class: "pdf-reader__header-right" }, h("swirl-popover-trigger", { popover: this.menu }, h("swirl-button", { class: "pdf-reader__menu-button", hideLabel: true, icon: "<swirl-icon-more-vertikal></swirl-icon-more-vertikal>", label: this.menuTriggerLabel }))), h("span", { class: "pdf-reader__floating-tools" }, h("button", { "aria-label": this.sideBySideButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleViewMode, type: "button" }, h("swirl-icon-menu-book", null)), h("button", { "aria-controls": "thumbnails", "aria-expanded": String(Boolean(this.showThumbnails)), "aria-label": this.thumbnailsButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleThumbnals, type: "button" }, h("swirl-icon-file-copy", null)))), h("div", { class: "pdf-reader__content" }, h("nav", { "aria-label": this.thumbnailsLabel, class: "pdf-reader__thumbnails", id: "thumbnails" }, this.thumbnails.map((thumbnail, index) => {
166
166
  const thumbnailClassName = classnames("pdf-reader__thumbnail", {
167
167
  "pdf-reader__thumbnail--active": this.visiblePages[0] === index + 1,
168
168
  });
169
169
  return (h("button", { "aria-label": `${this.thumbnailButtonLabel} ${index + 1}`, class: thumbnailClassName, onClick: this.onThumbnailClick(index), type: "button" }, h("img", { src: thumbnail.toDataURL("image/png"), alt: "" })));
170
- })), h("swirl-file-viewer", { active: this.active, class: "pdf-reader__viewer", file: this.file, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, ref: (el) => (this.viewer = el), type: "application/pdf", viewMode: this.viewMode, zoom: this.zoom }), h("div", { class: "pdf-reader__mobile-zoom-controls" }, h("button", { "aria-label": this.autoZoomLabel, class: "pdf-reader__mobile-zoom-button", onClick: this.onZoomAutoButtonClick, type: "button" }, this.zoom === "auto" ? (h("swirl-icon-fullscreen-exit", null)) : (h("swirl-icon-fullscreen", null))), h("button", { "aria-label": this.zoomInButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], onClick: this.onZoomInButtonClick, type: "button" }, h("swirl-icon-add", null)), h("button", { "aria-label": this.zoomOutButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[0], onClick: this.onZoomOutButtonClick, type: "button" }, h("swirl-icon-remove", null))))), h("swirl-popover", { animation: "scale-in-y", disableScrollLock: true, label: this.menuLabel, placement: "bottom-end", popoverId: "menu", ref: (el) => (this.menu = el), trigger: "menu-trigger" }, h("swirl-stack", null, h("div", { class: "pdf-reader__meta" }, h("div", { class: "pdf-reader__file-icon" }, h("svg", { fill: "none", height: "36", viewBox: "0 0 24 36", width: "24" }, h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }), h("path", { d: "M3.59961 9.00001C3.59961 8.0059 4.4055 7.20001 5.39961 7.20001H14.854C15.3314 7.20001 15.7893 7.38965 16.1268 7.72722L19.8724 11.4728C20.21 11.8104 20.3996 12.2682 20.3996 12.7456V27C20.3996 27.9941 19.5937 28.8 18.5996 28.8H5.39961C4.4055 28.8 3.59961 27.9941 3.59961 27V9.00001Z", fill: "#FF574D" }), h("path", { d: "M15.5996 7.36166V10.2C15.5996 11.1941 16.4055 12 17.3996 12H20.2379C20.3237 12.1884 20.3768 12.3913 20.3937 12.6H17.3996C16.0785 12.6 15.0067 11.5325 14.9996 10.213L14.9996 7.20587C15.2083 7.2228 15.4112 7.27593 15.5996 7.36166Z", fill: "white" }), h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }))), h("div", { class: "pdf-reader__file-info" }, h("swirl-text", { truncate: true, weight: "semibold" }, this.label), h("swirl-text", { color: "subdued", size: "sm", truncate: true }, this.fileTypeLabel))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { class: "pdf-reader__print-button", icon: "<swirl-icon-print></swirl-icon-print>", label: this.printButtonLabel, onClick: this.onPrintButtonClick }), h("swirl-action-list-item", { class: "pdf-reader__download-button", disabled: this.downloading, icon: !this.downloading
170
+ })), h("swirl-file-viewer", { active: this.active, class: "pdf-reader__viewer", file: this.file, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, ref: (el) => (this.viewer = el), type: "application/pdf", viewMode: this.viewMode, zoom: this.zoom }), h("div", { class: "pdf-reader__mobile-zoom-controls" }, h("button", { "aria-label": this.autoZoomLabel, class: "pdf-reader__mobile-zoom-button", onClick: this.onZoomAutoButtonClick, type: "button" }, this.zoom === "auto" ? (h("swirl-icon-fullscreen-exit", null)) : (h("swirl-icon-fullscreen", null))), h("button", { "aria-label": this.zoomInButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], onClick: this.onZoomInButtonClick, type: "button" }, h("swirl-icon-add", null)), h("button", { "aria-label": this.zoomOutButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[0], onClick: this.onZoomOutButtonClick, type: "button" }, h("swirl-icon-remove", null))))), h("swirl-popover", { animation: "scale-in-y", disableScrollLock: true, id: "menu", label: this.menuLabel, placement: "bottom-end", ref: (el) => (this.menu = el) }, h("swirl-stack", null, h("div", { class: "pdf-reader__meta" }, h("div", { class: "pdf-reader__file-icon" }, h("svg", { fill: "none", height: "36", viewBox: "0 0 24 36", width: "24" }, h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }), h("path", { d: "M3.59961 9.00001C3.59961 8.0059 4.4055 7.20001 5.39961 7.20001H14.854C15.3314 7.20001 15.7893 7.38965 16.1268 7.72722L19.8724 11.4728C20.21 11.8104 20.3996 12.2682 20.3996 12.7456V27C20.3996 27.9941 19.5937 28.8 18.5996 28.8H5.39961C4.4055 28.8 3.59961 27.9941 3.59961 27V9.00001Z", fill: "#FF574D" }), h("path", { d: "M15.5996 7.36166V10.2C15.5996 11.1941 16.4055 12 17.3996 12H20.2379C20.3237 12.1884 20.3768 12.3913 20.3937 12.6H17.3996C16.0785 12.6 15.0067 11.5325 14.9996 10.213L14.9996 7.20587C15.2083 7.2228 15.4112 7.27593 15.5996 7.36166Z", fill: "white" }), h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }))), h("div", { class: "pdf-reader__file-info" }, h("swirl-text", { truncate: true, weight: "semibold" }, this.label), h("swirl-text", { color: "subdued", size: "sm", truncate: true }, this.fileTypeLabel))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { class: "pdf-reader__print-button", icon: "<swirl-icon-print></swirl-icon-print>", label: this.printButtonLabel, onClick: this.onPrintButtonClick }), h("swirl-action-list-item", { class: "pdf-reader__download-button", disabled: this.downloading, icon: !this.downloading
171
171
  ? "<swirl-icon-download></swirl-icon-download>"
172
172
  : '<swirl-spinner size="xs"></swirl-spinner>', label: this.downloadButtonLabel, onClick: this.onDownloadButtonClick }), h("slot", { name: "menu-items" })))))));
173
173
  }
@@ -48,7 +48,9 @@ describe("swirl-pdf-reader", () => {
48
48
  </span>
49
49
  </span>
50
50
  <span class="pdf-reader__header-right">
51
- <swirl-button class="pdf-reader__menu-button" hidelabel="" icon="<swirl-icon-more-vertikal></swirl-icon-more-vertikal>" id="menu-trigger" label="Open file menu"></swirl-button>
51
+ <swirl-popover-trigger>
52
+ <swirl-button class="pdf-reader__menu-button" hidelabel="" icon="<swirl-icon-more-vertikal></swirl-icon-more-vertikal>" label="Open file menu"></swirl-button>
53
+ </swirl-popover-trigger>
52
54
  </span>
53
55
  <span class="pdf-reader__floating-tools">
54
56
  <button aria-label="Toggle side by side view" class="pdf-reader__floating-tool-button" type="button">
@@ -75,7 +77,7 @@ describe("swirl-pdf-reader", () => {
75
77
  </div>
76
78
  </div>
77
79
  </div>
78
- <swirl-popover animation="scale-in-y" disablescrolllock="" label="File menu" placement="bottom-end" popoverid="menu" trigger="menu-trigger">
80
+ <swirl-popover animation="scale-in-y" disablescrolllock="" id="menu" label="File menu" placement="bottom-end">
79
81
  <swirl-stack>
80
82
  <div class="pdf-reader__meta">
81
83
  <div class="pdf-reader__file-icon">
@@ -54,8 +54,8 @@ export class SwirlPopover {
54
54
  this.label = undefined;
55
55
  this.maxHeight = "22rem";
56
56
  this.offset = 8;
57
- this.placement = "bottom-start";
58
57
  this.popoverId = undefined;
58
+ this.placement = "bottom-start";
59
59
  this.trigger = undefined;
60
60
  this.triggerContainer = undefined;
61
61
  this.useContainerWidth = undefined;
@@ -65,13 +65,16 @@ export class SwirlPopover {
65
65
  }
66
66
  componentDidLoad() {
67
67
  this.connectTrigger();
68
- this.updateFocusableChildren();
69
68
  this.updateTriggerAttributes();
69
+ if (Boolean(this.trigger)) {
70
+ console.warn('[Swirl] The "trigger" prop of swirl-popover is deprecated and will be removed with the next major release. Please use the swirl-popover-trigger component instead. https://swirl-storybook.flip-app.dev/?path=/docs/components-swirlpopovertrigger--docs');
71
+ }
70
72
  }
71
73
  disconnectedCallback() {
72
74
  this.unlockBodyScroll();
73
75
  }
74
76
  onWindowFocusIn(event) {
77
+ var _a;
75
78
  if (!this.active) {
76
79
  return;
77
80
  }
@@ -82,7 +85,7 @@ export class SwirlPopover {
82
85
  const popoverLostFocus = !this.el.contains(target) &&
83
86
  !this.el.contains(activeElement) &&
84
87
  target !== this.triggerEl &&
85
- !this.triggerEl.contains(target) &&
88
+ !((_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.contains(target)) &&
86
89
  (!isSafari ||
87
90
  (isSafari &&
88
91
  !this.el.contains(relatedTarget || target) &&
@@ -102,7 +105,7 @@ export class SwirlPopover {
102
105
  .some((el) => Boolean(el) && el instanceof Node
103
106
  ? this.el.contains(el)
104
107
  : false);
105
- const clickedTrigger = event.target === this.triggerEl;
108
+ const clickedTrigger = target === this.triggerEl;
106
109
  if (!clickedChild && !clickedShadowChild && !clickedTrigger) {
107
110
  this.close();
108
111
  }
@@ -133,19 +136,20 @@ export class SwirlPopover {
133
136
  * Open the popover.
134
137
  * @returns
135
138
  */
136
- async open() {
137
- if (this.active) {
139
+ async open(triggerEl) {
140
+ this.triggerEl = triggerEl || this.triggerEl;
141
+ if (this.active || !Boolean(this.triggerEl)) {
138
142
  return;
139
143
  }
140
144
  this.adjustWidth();
141
145
  this.active = true;
142
- this.updateFocusableChildren();
143
146
  this.updateTriggerAttributes();
147
+ const focusableChildren = this.getFocusableChildren();
144
148
  requestAnimationFrame(async () => {
145
149
  await this.reposition();
146
150
  this.popoverOpen.emit({ position: this.position });
147
- if (this.focusableChildren.length > 0) {
148
- this.focusableChildren[0].focus();
151
+ if (focusableChildren.length > 0) {
152
+ focusableChildren[0].focus();
149
153
  }
150
154
  else {
151
155
  this.contentContainer.focus();
@@ -153,12 +157,16 @@ export class SwirlPopover {
153
157
  if (this.disableAutoUpdate) {
154
158
  this.disableAutoUpdate();
155
159
  }
156
- this.disableAutoUpdate = autoUpdate(this.triggerEl, this.contentContainer, this.reposition);
160
+ this.disableAutoUpdate = autoUpdate(this.triggerEl, this.contentContainer, () => this.reposition());
157
161
  this.scrollContainer.scrollTop = 0;
158
162
  this.lockBodyScroll();
159
163
  });
160
164
  }
161
165
  connectTrigger() {
166
+ if (!Boolean(this.trigger)) {
167
+ this.triggerEl = undefined;
168
+ return;
169
+ }
162
170
  this.triggerEl =
163
171
  typeof this.trigger === "string"
164
172
  ? querySelectorAllDeep(this.triggerContainer || document.body, `#${this.trigger}`)[0]
@@ -171,10 +179,10 @@ export class SwirlPopover {
171
179
  });
172
180
  }
173
181
  getNativeTriggerElement() {
174
- var _a, _b, _c;
175
- return this.triggerEl.tagName.startsWith("SWIRL-")
176
- ? (((_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.children[0]) ||
177
- ((_c = (_b = this.triggerEl) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.children[0]) ||
182
+ var _a, _b, _c, _d;
183
+ return ((_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.tagName.startsWith("SWIRL-"))
184
+ ? (((_b = this.triggerEl) === null || _b === void 0 ? void 0 : _b.children[0]) ||
185
+ ((_d = (_c = this.triggerEl) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.children[0]) ||
178
186
  this.triggerEl)
179
187
  : this.triggerEl;
180
188
  }
@@ -183,12 +191,12 @@ export class SwirlPopover {
183
191
  return;
184
192
  }
185
193
  const nativeTriggerEl = this.getNativeTriggerElement();
186
- nativeTriggerEl.setAttribute("aria-controls", this.popoverId);
194
+ nativeTriggerEl.setAttribute("aria-controls", this.el.id);
187
195
  nativeTriggerEl.setAttribute("aria-expanded", String(this.active));
188
196
  nativeTriggerEl.setAttribute("aria-haspopup", "dialog");
189
197
  }
190
- updateFocusableChildren() {
191
- this.focusableChildren = querySelectorAllDeep(this.el, '[role="menuitem"], [role="listbox"]');
198
+ getFocusableChildren() {
199
+ return querySelectorAllDeep(this.el, '[role="menuitem"], [role="listbox"]');
192
200
  }
193
201
  adjustWidth() {
194
202
  let useContainerWidth = this.useContainerWidth;
@@ -235,7 +243,7 @@ export class SwirlPopover {
235
243
  "popover--fullscreen-bottom-sheet": this.fullscreenBottomSheet,
236
244
  "popover--inactive": !this.active,
237
245
  });
238
- return (h(Host, { id: this.popoverId }, h("div", { class: className, onKeyDown: this.onKeydown }, h("div", { "aria-hidden": !this.active ? "true" : "false", "aria-label": this.label, class: "popover__content", part: "popover__content", role: "dialog", ref: (el) => (this.contentContainer = el), style: {
246
+ return (h(Host, null, h("div", { class: className, onKeyDown: this.onKeydown }, h("div", { "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: {
239
247
  top: Boolean(this.position) ? `${(_b = this.position) === null || _b === void 0 ? void 0 : _b.y}px` : "",
240
248
  left: Boolean(this.position) ? `${(_c = this.position) === null || _c === void 0 ? void 0 : _c.x}px` : "",
241
249
  }, tabindex: "-1" }, h("span", { class: "popover__handle" }), h("div", { class: "popover__scroll-container", ref: (el) => (this.scrollContainer = el), style: {
@@ -386,6 +394,23 @@ export class SwirlPopover {
386
394
  "reflect": false,
387
395
  "defaultValue": "8"
388
396
  },
397
+ "popoverId": {
398
+ "type": "string",
399
+ "mutable": false,
400
+ "complexType": {
401
+ "original": "string",
402
+ "resolved": "string",
403
+ "references": {}
404
+ },
405
+ "required": false,
406
+ "optional": true,
407
+ "docs": {
408
+ "tags": [],
409
+ "text": ""
410
+ },
411
+ "attribute": "popover-id",
412
+ "reflect": false
413
+ },
389
414
  "placement": {
390
415
  "type": "string",
391
416
  "mutable": false,
@@ -409,23 +434,6 @@ export class SwirlPopover {
409
434
  "reflect": false,
410
435
  "defaultValue": "\"bottom-start\""
411
436
  },
412
- "popoverId": {
413
- "type": "string",
414
- "mutable": false,
415
- "complexType": {
416
- "original": "string",
417
- "resolved": "string",
418
- "references": {}
419
- },
420
- "required": true,
421
- "optional": false,
422
- "docs": {
423
- "tags": [],
424
- "text": ""
425
- },
426
- "attribute": "popover-id",
427
- "reflect": false
428
- },
429
437
  "trigger": {
430
438
  "type": "string",
431
439
  "mutable": false,
@@ -438,8 +446,8 @@ export class SwirlPopover {
438
446
  }
439
447
  }
440
448
  },
441
- "required": true,
442
- "optional": false,
449
+ "required": false,
450
+ "optional": true,
443
451
  "docs": {
444
452
  "tags": [],
445
453
  "text": ""
@@ -553,11 +561,17 @@ export class SwirlPopover {
553
561
  },
554
562
  "open": {
555
563
  "complexType": {
556
- "signature": "() => Promise<void>",
557
- "parameters": [],
564
+ "signature": "(triggerEl?: HTMLElement) => Promise<void>",
565
+ "parameters": [{
566
+ "tags": [],
567
+ "text": ""
568
+ }],
558
569
  "references": {
559
570
  "Promise": {
560
571
  "location": "global"
572
+ },
573
+ "HTMLElement": {
574
+ "location": "global"
561
575
  }
562
576
  },
563
577
  "return": "Promise<void>"