@getflip/swirl-components 0.123.0 → 0.124.1
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.
- package/components.json +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-action-list_3.cjs.entry.js +39 -1
- package/dist/cjs/swirl-app-layout_6.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/collection/components/swirl-action-list/swirl-action-list.js +44 -1
- package/dist/collection/components/swirl-action-list/swirl-action-list.spec.js +1 -1
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.stories.js +1 -7
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.css +1 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-action-list2.js +42 -2
- package/dist/components/swirl-resource-list-item2.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-action-list_3.entry.js +39 -1
- package/dist/esm/swirl-app-layout_6.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/swirl-components/p-49a5b56e.entry.js +1 -0
- package/dist/swirl-components/{p-142bef54.entry.js → p-d771a7e8.entry.js} +1 -1
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-action-list/swirl-action-list.d.ts +5 -0
- package/package.json +1 -1
- package/dist/swirl-components/p-931fd6bb.entry.js +0 -1
|
@@ -15,6 +15,44 @@ export class SwirlActionList {
|
|
|
15
15
|
this.focusPreviousItem();
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
this.onFocusOut = (event) => {
|
|
19
|
+
if (this.isInsidePopover) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const elementReceivingFocus = event.relatedTarget;
|
|
23
|
+
const elementLosingFocus = event.target;
|
|
24
|
+
const losingElementIsListItem = elementLosingFocus?.tagName === "SWIRL-ACTION-LIST-ITEM";
|
|
25
|
+
const receivingElementIsOutsideActionList = elementReceivingFocus === null ||
|
|
26
|
+
!this.el.contains(elementReceivingFocus);
|
|
27
|
+
if (!this.isInsidePopover &&
|
|
28
|
+
receivingElementIsOutsideActionList &&
|
|
29
|
+
losingElementIsListItem) {
|
|
30
|
+
this.container.setAttribute("tabindex", "0");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.onFocus = () => {
|
|
34
|
+
if (this.isInsidePopover) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.container.removeAttribute("tabindex");
|
|
38
|
+
const items = this.getItems();
|
|
39
|
+
const activeItemIndex = this.getActiveItemIndex();
|
|
40
|
+
if (activeItemIndex > -1) {
|
|
41
|
+
items[activeItemIndex]?.focus();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
items[0]?.focus();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this.isInsidePopover = undefined;
|
|
48
|
+
}
|
|
49
|
+
componentDidLoad() {
|
|
50
|
+
queueMicrotask(() => {
|
|
51
|
+
this.isInsidePopover = this.el.closest("swirl-popover") !== null;
|
|
52
|
+
if (!this.isInsidePopover) {
|
|
53
|
+
this.container.setAttribute("tabindex", "0");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
18
56
|
}
|
|
19
57
|
getItems() {
|
|
20
58
|
return querySelectorAllDeep(this.el, '[role="menuitem"]');
|
|
@@ -38,7 +76,7 @@ export class SwirlActionList {
|
|
|
38
76
|
item === activeElement?.querySelector('[role="menuitem"]'));
|
|
39
77
|
}
|
|
40
78
|
render() {
|
|
41
|
-
return (h(Host, null, h("div", { "aria-orientation": "vertical", class: "action-list", onKeyDown: this.onKeyDown, role: "menu" }, h("slot", null))));
|
|
79
|
+
return (h(Host, null, h("div", { "aria-orientation": "vertical", class: "action-list", onFocusout: this.isInsidePopover ? undefined : this.onFocusOut, onFocus: this.isInsidePopover ? undefined : this.onFocus, onKeyDown: this.onKeyDown, ref: (el) => (this.container = el), role: "menu" }, h("slot", null))));
|
|
42
80
|
}
|
|
43
81
|
static get is() { return "swirl-action-list"; }
|
|
44
82
|
static get encapsulation() { return "shadow"; }
|
|
@@ -52,5 +90,10 @@ export class SwirlActionList {
|
|
|
52
90
|
"$": ["swirl-action-list.css"]
|
|
53
91
|
};
|
|
54
92
|
}
|
|
93
|
+
static get states() {
|
|
94
|
+
return {
|
|
95
|
+
"isInsidePopover": {}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
55
98
|
static get elementRef() { return "el"; }
|
|
56
99
|
}
|
|
@@ -20,7 +20,7 @@ describe("swirl-action-list", () => {
|
|
|
20
20
|
expect(page.root).toEqualHtml(`
|
|
21
21
|
<swirl-action-list>
|
|
22
22
|
<mock:shadow-root>
|
|
23
|
-
<div aria-orientation="vertical" class="action-list" role="menu">
|
|
23
|
+
<div aria-orientation="vertical" class="action-list" role="menu" tabindex="0">
|
|
24
24
|
<slot></slot>
|
|
25
25
|
</div>
|
|
26
26
|
</mock:shadow-root>
|
|
@@ -11,7 +11,6 @@ export default {
|
|
|
11
11
|
title: "Components/SwirlResourceList",
|
|
12
12
|
};
|
|
13
13
|
const Template = (args) => {
|
|
14
|
-
const container = document.createElement("div");
|
|
15
14
|
const element = generateStoryElement("swirl-resource-list", args);
|
|
16
15
|
element.innerHTML = `
|
|
17
16
|
<swirl-resource-list-item
|
|
@@ -34,14 +33,9 @@ const Template = (args) => {
|
|
|
34
33
|
<swirl-avatar label="John Doe" src="https://picsum.photos/id/1027/144/144" slot="media"></swirl-avatar>
|
|
35
34
|
</swirl-resource-list-item>
|
|
36
35
|
`;
|
|
37
|
-
|
|
38
|
-
container.appendChild(element);
|
|
39
|
-
container.appendChild(input);
|
|
40
|
-
element.controllingElement = input;
|
|
41
|
-
return container;
|
|
36
|
+
return element;
|
|
42
37
|
};
|
|
43
38
|
export const SwirlResourceList = Template.bind({});
|
|
44
39
|
SwirlResourceList.args = {
|
|
45
40
|
label: "A resource list",
|
|
46
|
-
focusSelectedItems: false,
|
|
47
41
|
};
|