@getflip/swirl-components 0.95.0 → 0.95.2
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/swirl-action-list_3.cjs.entry.js +10 -20
- package/dist/cjs/swirl-app-layout_7.cjs.entry.js +20 -9
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +10 -2
- package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
- package/dist/cjs/swirl-option-list_2.cjs.entry.js +5 -3
- package/dist/cjs/swirl-select.cjs.entry.js +4 -2
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/collection/components/swirl-action-list/swirl-action-list.js +10 -20
- package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.js +10 -2
- package/dist/collection/components/swirl-modal/swirl-modal.css +1 -0
- package/dist/collection/components/swirl-option-list/swirl-option-list.js +5 -3
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.js +20 -9
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.spec.js +8 -9
- package/dist/collection/components/swirl-select/swirl-select.js +4 -2
- package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/components/swirl-action-list2.js +10 -20
- package/dist/components/swirl-autocomplete.js +10 -2
- package/dist/components/swirl-modal.js +1 -1
- package/dist/components/swirl-option-list2.js +5 -3
- package/dist/components/swirl-resource-list2.js +20 -9
- package/dist/components/swirl-select.js +4 -2
- package/dist/esm/swirl-action-list_3.entry.js +10 -20
- package/dist/esm/swirl-app-layout_7.entry.js +20 -9
- package/dist/esm/swirl-autocomplete.entry.js +10 -2
- package/dist/esm/swirl-modal.entry.js +1 -1
- package/dist/esm/swirl-option-list_2.entry.js +5 -3
- package/dist/esm/swirl-select.entry.js +4 -2
- package/dist/swirl-components/{p-89898ac6.entry.js → p-057b650a.entry.js} +1 -1
- package/dist/swirl-components/p-0e6c2f2b.entry.js +1 -0
- package/dist/swirl-components/{p-789efdba.entry.js → p-0fc0cd2c.entry.js} +1 -1
- package/dist/swirl-components/p-59408f77.entry.js +1 -0
- package/dist/swirl-components/p-6f07c958.entry.js +1 -0
- package/dist/swirl-components/{p-1d1edae3.entry.js → p-8a00faee.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 +1 -6
- package/dist/types/components/swirl-select/swirl-select.d.ts +2 -0
- package/package.json +1 -1
- package/dist/swirl-components/p-0067f11b.entry.js +0 -1
- package/dist/swirl-components/p-56fa872b.entry.js +0 -1
- package/dist/swirl-components/p-bf258885.entry.js +0 -1
|
@@ -16,35 +16,25 @@ export class SwirlActionList {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.observeSlotChanges();
|
|
22
|
-
}
|
|
23
|
-
disconnectedCallback() {
|
|
24
|
-
this.observer?.disconnect();
|
|
25
|
-
}
|
|
26
|
-
observeSlotChanges() {
|
|
27
|
-
this.observer = new MutationObserver(() => {
|
|
28
|
-
this.updateItems();
|
|
29
|
-
});
|
|
30
|
-
this.observer.observe(this.el, { childList: true });
|
|
31
|
-
}
|
|
32
|
-
updateItems() {
|
|
33
|
-
this.items = querySelectorAllDeep(this.el, '[role="menuitem"]');
|
|
19
|
+
getItems() {
|
|
20
|
+
return querySelectorAllDeep(this.el, '[role="menuitem"]');
|
|
34
21
|
}
|
|
35
22
|
focusNextItem() {
|
|
23
|
+
const items = this.getItems();
|
|
36
24
|
const activeItemIndex = this.getActiveItemIndex();
|
|
37
|
-
const newIndex = (activeItemIndex + 1) %
|
|
38
|
-
|
|
25
|
+
const newIndex = (activeItemIndex + 1) % items.length;
|
|
26
|
+
items[newIndex].focus();
|
|
39
27
|
}
|
|
40
28
|
focusPreviousItem() {
|
|
29
|
+
const items = this.getItems();
|
|
41
30
|
const activeItemIndex = this.getActiveItemIndex();
|
|
42
|
-
const newIndex = activeItemIndex === 0 ?
|
|
43
|
-
|
|
31
|
+
const newIndex = activeItemIndex === 0 ? items.length - 1 : activeItemIndex - 1;
|
|
32
|
+
items[newIndex]?.focus();
|
|
44
33
|
}
|
|
45
34
|
getActiveItemIndex() {
|
|
35
|
+
const items = this.getItems();
|
|
46
36
|
const activeElement = getActiveElement();
|
|
47
|
-
return
|
|
37
|
+
return items.findIndex((item) => item === activeElement ||
|
|
48
38
|
item === activeElement?.querySelector('[role="menuitem"]'));
|
|
49
39
|
}
|
|
50
40
|
render() {
|
|
@@ -32,8 +32,16 @@ export class SwirlAutocomplete {
|
|
|
32
32
|
!this.value.some((item) => item.id === suggestion.id)),
|
|
33
33
|
];
|
|
34
34
|
this.valueChange.emit(this.value);
|
|
35
|
-
this.inputEl.
|
|
36
|
-
|
|
35
|
+
this.inputEl.value = "";
|
|
36
|
+
const input = this.inputEl.querySelector("input");
|
|
37
|
+
if (Boolean(input)) {
|
|
38
|
+
input.value = "";
|
|
39
|
+
queueMicrotask(() => {
|
|
40
|
+
input.focus();
|
|
41
|
+
this.close();
|
|
42
|
+
});
|
|
43
|
+
this.updateSuggestions(input.value);
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
else {
|
|
39
47
|
if (Boolean(event.detail[0])) {
|
|
@@ -294,9 +294,11 @@ export class SwirlOptionList {
|
|
|
294
294
|
this.focusItem(newIndex);
|
|
295
295
|
}
|
|
296
296
|
getActiveItemIndex() {
|
|
297
|
-
return this.
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
return Boolean(this.focusedItem)
|
|
298
|
+
? this.items
|
|
299
|
+
.map((item) => item.querySelector('[role="option"]'))
|
|
300
|
+
.findIndex((item) => item === this.focusedItem)
|
|
301
|
+
: 0;
|
|
300
302
|
}
|
|
301
303
|
getItemIndex(item) {
|
|
302
304
|
return this.items.map((i) => i).findIndex((i) => i === item);
|
|
@@ -29,7 +29,7 @@ export class SwirlResourceList {
|
|
|
29
29
|
this.draggingStartIndex = undefined;
|
|
30
30
|
};
|
|
31
31
|
this.onKeyDown = (event) => {
|
|
32
|
-
if (event.
|
|
32
|
+
if (event.code === "ArrowDown") {
|
|
33
33
|
event.preventDefault();
|
|
34
34
|
if (!Boolean(this.dragging)) {
|
|
35
35
|
this.focusItemAtIndex((this.focusedIndex + 1) % this.items.length);
|
|
@@ -38,7 +38,7 @@ export class SwirlResourceList {
|
|
|
38
38
|
this.moveDraggedItemDown();
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
else if (event.
|
|
41
|
+
else if (event.code === "ArrowUp") {
|
|
42
42
|
event.preventDefault();
|
|
43
43
|
if (!Boolean(this.dragging)) {
|
|
44
44
|
const prevIndex = this.focusedIndex === 0
|
|
@@ -50,7 +50,7 @@ export class SwirlResourceList {
|
|
|
50
50
|
this.moveDraggedItemUp();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
else if (event.
|
|
53
|
+
else if (event.code === "Space" || event.code === "Enter") {
|
|
54
54
|
const target = event.composedPath()[0];
|
|
55
55
|
if (Boolean(this.dragging) &&
|
|
56
56
|
!target?.classList.contains("resource-list-item__drag-handle")) {
|
|
@@ -58,11 +58,11 @@ export class SwirlResourceList {
|
|
|
58
58
|
this.stopDrag(this.dragging);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
else if (event.
|
|
61
|
+
else if (event.code === "Home") {
|
|
62
62
|
event.preventDefault();
|
|
63
63
|
this.focusItemAtIndex(0);
|
|
64
64
|
}
|
|
65
|
-
else if (event.
|
|
65
|
+
else if (event.code === "End") {
|
|
66
66
|
event.preventDefault();
|
|
67
67
|
this.focusItemAtIndex(this.items.length - 1);
|
|
68
68
|
}
|
|
@@ -90,7 +90,11 @@ export class SwirlResourceList {
|
|
|
90
90
|
this.setItemAllowDragState();
|
|
91
91
|
this.setupDragDrop();
|
|
92
92
|
});
|
|
93
|
-
this.observer.observe(this.el, {
|
|
93
|
+
this.observer.observe(this.el, {
|
|
94
|
+
childList: true,
|
|
95
|
+
characterData: true,
|
|
96
|
+
subtree: true,
|
|
97
|
+
});
|
|
94
98
|
}
|
|
95
99
|
watchAllowDrag() {
|
|
96
100
|
this.setItemAllowDragState();
|
|
@@ -105,9 +109,12 @@ export class SwirlResourceList {
|
|
|
105
109
|
return this.items.map((i) => i).findIndex((i) => i === item);
|
|
106
110
|
}
|
|
107
111
|
removeItemsFromTabOrder() {
|
|
108
|
-
this.items.forEach((item) =>
|
|
109
|
-
?.querySelector(".resource-list-item__content, .resource-list-file-item")
|
|
110
|
-
?.
|
|
112
|
+
this.items.forEach((item) => {
|
|
113
|
+
const focusableEl = item?.querySelector(".resource-list-item__content, .resource-list-file-item");
|
|
114
|
+
const dragHandle = item?.querySelector(".resource-list-item__drag-handle");
|
|
115
|
+
focusableEl?.setAttribute("tabIndex", "-1");
|
|
116
|
+
dragHandle?.setAttribute("tabIndex", "-1");
|
|
117
|
+
});
|
|
111
118
|
}
|
|
112
119
|
setItemAllowDragState() {
|
|
113
120
|
if (this.allowDrag) {
|
|
@@ -148,6 +155,10 @@ export class SwirlResourceList {
|
|
|
148
155
|
return;
|
|
149
156
|
}
|
|
150
157
|
const interactiveElement = item.querySelector(".resource-list-item__content, .resource-list-file-item");
|
|
158
|
+
const dragHandle = item.querySelector(".resource-list-item__drag-handle");
|
|
159
|
+
if (Boolean(dragHandle)) {
|
|
160
|
+
dragHandle.setAttribute("tabIndex", "0");
|
|
161
|
+
}
|
|
151
162
|
if (!Boolean(interactiveElement)) {
|
|
152
163
|
return;
|
|
153
164
|
}
|
|
@@ -60,23 +60,21 @@ describe("swirl-resource-list", () => {
|
|
|
60
60
|
});
|
|
61
61
|
const items = Array.from(page.root.querySelectorAll("swirl-resource-list-item"));
|
|
62
62
|
const interactiveElements = items.map((item) => item.querySelector(".resource-list-item__content"));
|
|
63
|
-
// focuses the first element if list is focused
|
|
64
|
-
page.root.children[0].focus();
|
|
65
63
|
expect(interactiveElements[0].getAttribute("tabIndex")).toBe("0");
|
|
66
|
-
// Down arrow
|
|
67
|
-
page.root.dispatchEvent(new KeyboardEvent("keydown", {
|
|
64
|
+
// Down arrow focuses the next element
|
|
65
|
+
page.root.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowDown" }));
|
|
68
66
|
expect(interactiveElements[0].getAttribute("tabIndex")).toBe("-1");
|
|
69
67
|
expect(interactiveElements[1].getAttribute("tabIndex")).toBe("0");
|
|
70
68
|
// Up arrow focues the next element
|
|
71
|
-
page.root.dispatchEvent(new KeyboardEvent("keydown", {
|
|
69
|
+
page.root.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowUp" }));
|
|
72
70
|
expect(interactiveElements[0].getAttribute("tabIndex")).toBe("0");
|
|
73
71
|
expect(interactiveElements[1].getAttribute("tabIndex")).toBe("-1");
|
|
74
72
|
// End key focues the first element
|
|
75
|
-
page.root.dispatchEvent(new KeyboardEvent("keydown", {
|
|
73
|
+
page.root.dispatchEvent(new KeyboardEvent("keydown", { code: "End" }));
|
|
76
74
|
expect(interactiveElements[0].getAttribute("tabIndex")).toBe("-1");
|
|
77
75
|
expect(interactiveElements[1].getAttribute("tabIndex")).toBe("0");
|
|
78
76
|
// Home key focues the first element
|
|
79
|
-
page.root.dispatchEvent(new KeyboardEvent("keydown", {
|
|
77
|
+
page.root.dispatchEvent(new KeyboardEvent("keydown", { code: "Home" }));
|
|
80
78
|
expect(interactiveElements[0].getAttribute("tabIndex")).toBe("0");
|
|
81
79
|
expect(interactiveElements[1].getAttribute("tabIndex")).toBe("-1");
|
|
82
80
|
});
|
|
@@ -101,10 +99,11 @@ describe("swirl-resource-list", () => {
|
|
|
101
99
|
.dispatchEvent(new KeyboardEvent("keydown", { code: "Space" }));
|
|
102
100
|
await page.waitForChanges();
|
|
103
101
|
expect(assistiveText.innerHTML).toBe("Item grabbed. Use arrow keys to move item up or down. Use spacebar to save position.");
|
|
104
|
-
|
|
102
|
+
await page.waitForChanges();
|
|
103
|
+
resourceList.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowDown" }));
|
|
105
104
|
await page.waitForChanges();
|
|
106
105
|
expect(assistiveText.innerHTML).toBe("Current position: 2");
|
|
107
|
-
resourceList.dispatchEvent(new KeyboardEvent("keydown", {
|
|
106
|
+
resourceList.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowUp" }));
|
|
108
107
|
await page.waitForChanges();
|
|
109
108
|
expect(assistiveText.innerHTML).toBe("Current position: 1");
|
|
110
109
|
});
|
|
@@ -23,9 +23,11 @@ export class SwirlSelect {
|
|
|
23
23
|
this.onOpen = (event) => {
|
|
24
24
|
this.placement = event.detail.position?.placement;
|
|
25
25
|
this.open = true;
|
|
26
|
+
this.optionList.querySelector('[tabIndex="0"]')?.focus();
|
|
26
27
|
};
|
|
27
28
|
this.onClose = () => {
|
|
28
29
|
this.open = false;
|
|
30
|
+
this.input.focus();
|
|
29
31
|
};
|
|
30
32
|
this.onKeyDown = (event) => {
|
|
31
33
|
if (event.code === "Space" || event.code === "Enter") {
|
|
@@ -78,11 +80,11 @@ export class SwirlSelect {
|
|
|
78
80
|
"select--inline": this.inline,
|
|
79
81
|
"select--multi": this.multiSelect,
|
|
80
82
|
});
|
|
81
|
-
return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
|
|
83
|
+
return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, ref: (el) => (this.input = el), type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
|
|
82
84
|
?.map((value) => this.options.find((option) => option.value === value))
|
|
83
85
|
?.map((option) => (h("swirl-tag", { "aria-hidden": "true", label: option?.label,
|
|
84
86
|
// eslint-disable-next-line react/jsx-no-bind
|
|
85
|
-
onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
|
|
87
|
+
onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, ref: (el) => (this.optionList = el), value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
|
|
86
88
|
}
|
|
87
89
|
static get is() { return "swirl-select"; }
|
|
88
90
|
static get encapsulation() { return "scoped"; }
|