@getflip/swirl-components 0.63.0 → 0.64.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.
- package/components.json +537 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-action-list_3.cjs.entry.js +7 -3
- package/dist/cjs/swirl-app-layout_7.cjs.entry.js +1 -1
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
- package/dist/cjs/swirl-banner.cjs.entry.js +1 -1
- package/dist/cjs/swirl-button.cjs.entry.js +2 -2
- package/dist/cjs/swirl-carousel.cjs.entry.js +1 -1
- package/dist/cjs/swirl-chip.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-console-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-date-input.cjs.entry.js +1 -1
- package/dist/cjs/swirl-file-viewer_7.cjs.entry.js +1 -1
- package/dist/cjs/swirl-form-control.cjs.entry.js +1 -1
- package/dist/cjs/swirl-icon-check-small_3.cjs.entry.js +107 -0
- package/dist/cjs/swirl-icon-error_3.cjs.entry.js +1 -1
- package/dist/cjs/swirl-inline-status.cjs.entry.js +1 -1
- package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
- package/dist/cjs/swirl-menu-item.cjs.entry.js +120 -0
- package/dist/cjs/swirl-menu.cjs.entry.js +303 -0
- package/dist/cjs/{swirl-icon-check-small_4.cjs.entry.js → swirl-option-list.cjs.entry.js} +1 -100
- package/dist/cjs/swirl-pagination.cjs.entry.js +1 -1
- package/dist/cjs/swirl-pdf-reader.cjs.entry.js +1 -1
- package/dist/cjs/swirl-popover.cjs.entry.js +6 -3
- package/dist/cjs/swirl-resource-list-file-item.cjs.entry.js +1 -1
- package/dist/cjs/swirl-search.cjs.entry.js +1 -1
- package/dist/cjs/swirl-select.cjs.entry.js +1 -1
- package/dist/cjs/swirl-shell-layout.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-column.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table-row.cjs.entry.js +1 -1
- package/dist/cjs/swirl-table.cjs.entry.js +1 -1
- package/dist/cjs/swirl-text-input.cjs.entry.js +2 -2
- package/dist/cjs/swirl-toast.cjs.entry.js +1 -1
- package/dist/cjs/{utils-f1b4e064.js → utils-c00c09b9.js} +18 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/swirl-action-list-item/swirl-action-list-item.css +13 -0
- package/dist/collection/components/swirl-action-list-item/swirl-action-list-item.js +56 -1
- package/dist/collection/components/swirl-action-list-item/swirl-action-list-item.stories.js +1 -0
- package/dist/collection/components/swirl-button/swirl-button.css +4 -0
- package/dist/collection/components/swirl-menu/swirl-menu.css +98 -0
- package/dist/collection/components/swirl-menu/swirl-menu.js +638 -0
- package/dist/collection/components/swirl-menu/swirl-menu.stories.js +59 -0
- package/dist/collection/components/swirl-menu-item/swirl-menu-item.css +11 -0
- package/dist/collection/components/swirl-menu-item/swirl-menu-item.js +301 -0
- package/dist/collection/components/swirl-menu-item/swirl-menu-item.stories.js +20 -0
- package/dist/collection/components/swirl-option-list-item/swirl-option-list-item.css +2 -1
- package/dist/collection/components/swirl-option-list-item/swirl-option-list-item.js +25 -1
- package/dist/collection/components/swirl-popover/swirl-popover.js +5 -2
- package/dist/collection/components/swirl-text-input/swirl-text-input.js +1 -1
- package/dist/collection/utils.js +17 -0
- package/dist/components/swirl-action-list-item2.js +9 -2
- package/dist/components/swirl-button2.js +1 -1
- package/dist/components/swirl-menu-item.d.ts +11 -0
- package/dist/components/swirl-menu-item.js +177 -0
- package/dist/components/swirl-menu.d.ts +11 -0
- package/dist/components/swirl-menu.js +348 -0
- package/dist/components/swirl-option-list-item2.js +4 -2
- package/dist/components/swirl-popover2.js +5 -2
- package/dist/components/swirl-text-input2.js +1 -1
- package/dist/components/utils.js +18 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-action-list_3.entry.js +7 -3
- package/dist/esm/swirl-app-layout_7.entry.js +1 -1
- package/dist/esm/swirl-autocomplete.entry.js +1 -1
- package/dist/esm/swirl-banner.entry.js +1 -1
- package/dist/esm/swirl-button.entry.js +2 -2
- package/dist/esm/swirl-carousel.entry.js +1 -1
- package/dist/esm/swirl-chip.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-console-layout.entry.js +1 -1
- package/dist/esm/swirl-date-input.entry.js +1 -1
- package/dist/esm/swirl-file-viewer_7.entry.js +1 -1
- package/dist/esm/swirl-form-control.entry.js +1 -1
- package/dist/esm/swirl-icon-check-small_3.entry.js +101 -0
- package/dist/esm/swirl-icon-error_3.entry.js +1 -1
- package/dist/esm/swirl-inline-status.entry.js +1 -1
- package/dist/esm/swirl-lightbox.entry.js +1 -1
- package/dist/esm/swirl-menu-item.entry.js +116 -0
- package/dist/esm/swirl-menu.entry.js +299 -0
- package/dist/esm/{swirl-icon-check-small_4.entry.js → swirl-option-list.entry.js} +3 -99
- package/dist/esm/swirl-pagination.entry.js +1 -1
- package/dist/esm/swirl-pdf-reader.entry.js +1 -1
- package/dist/esm/swirl-popover.entry.js +6 -3
- package/dist/esm/swirl-resource-list-file-item.entry.js +1 -1
- package/dist/esm/swirl-search.entry.js +1 -1
- package/dist/esm/swirl-select.entry.js +1 -1
- package/dist/esm/swirl-shell-layout.entry.js +1 -1
- package/dist/esm/swirl-table-column.entry.js +1 -1
- package/dist/esm/swirl-table-row.entry.js +1 -1
- package/dist/esm/swirl-table.entry.js +1 -1
- package/dist/esm/swirl-text-input.entry.js +2 -2
- package/dist/esm/swirl-toast.entry.js +1 -1
- package/dist/esm/{utils-61f188cc.js → utils-bc84f36e.js} +18 -1
- package/dist/swirl-components/{p-8dfc39cb.entry.js → p-0923d414.entry.js} +1 -1
- package/dist/swirl-components/{p-6ff9eaeb.entry.js → p-0bbb5fc1.entry.js} +1 -1
- package/dist/swirl-components/p-10982642.entry.js +1 -0
- package/dist/swirl-components/p-15a0c3b7.entry.js +1 -0
- package/dist/swirl-components/{p-61a52a24.entry.js → p-3a65de25.entry.js} +1 -1
- package/dist/swirl-components/{p-9426ae2f.entry.js → p-3f771d50.entry.js} +1 -1
- package/dist/swirl-components/{p-7412f5ee.entry.js → p-4a4de053.entry.js} +1 -1
- package/dist/swirl-components/{p-9b0a9699.entry.js → p-55b1272e.entry.js} +1 -1
- package/dist/swirl-components/p-5e3b655e.entry.js +1 -0
- package/dist/swirl-components/{p-f5a94ea4.entry.js → p-6374ba81.entry.js} +1 -1
- package/dist/swirl-components/p-646e00de.js +1 -0
- package/dist/swirl-components/{p-9ad9ce19.entry.js → p-67c5bd0b.entry.js} +1 -1
- package/dist/swirl-components/{p-64b92967.entry.js → p-6837305a.entry.js} +1 -1
- package/dist/swirl-components/{p-793efeb4.entry.js → p-72551401.entry.js} +1 -1
- package/dist/swirl-components/{p-ec92d2e5.entry.js → p-853c0b12.entry.js} +1 -1
- package/dist/swirl-components/p-8b24d376.entry.js +1 -0
- package/dist/swirl-components/{p-5b691374.entry.js → p-8d998dbc.entry.js} +1 -1
- package/dist/swirl-components/{p-063afb09.entry.js → p-96ef492c.entry.js} +1 -1
- package/dist/swirl-components/{p-4f44b9e7.entry.js → p-994c100c.entry.js} +1 -1
- package/dist/swirl-components/{p-c2d3b142.entry.js → p-9ffbe866.entry.js} +1 -1
- package/dist/swirl-components/{p-d463715d.entry.js → p-a40d9dad.entry.js} +1 -1
- package/dist/swirl-components/{p-3a763e22.entry.js → p-a478559c.entry.js} +1 -1
- package/dist/swirl-components/{p-40546623.entry.js → p-a57959f0.entry.js} +1 -1
- package/dist/swirl-components/{p-457e9e49.entry.js → p-a5a28ec0.entry.js} +1 -1
- package/dist/swirl-components/{p-4820eae0.entry.js → p-a7c6a435.entry.js} +1 -1
- package/dist/swirl-components/p-ba73baae.entry.js +7 -0
- package/dist/swirl-components/{p-77daca19.entry.js → p-bbe3144e.entry.js} +1 -1
- package/dist/swirl-components/{p-c009d887.entry.js → p-c18d7dce.entry.js} +1 -1
- package/dist/swirl-components/{p-e5cec3a4.entry.js → p-c6e03bee.entry.js} +1 -1
- package/dist/swirl-components/p-e67ac70c.entry.js +1 -0
- package/dist/swirl-components/p-f5be17c6.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-action-list-item/swirl-action-list-item.d.ts +3 -0
- package/dist/types/components/swirl-menu/swirl-menu.d.ts +78 -0
- package/dist/types/components/swirl-menu/swirl-menu.stories.d.ts +14 -0
- package/dist/types/components/swirl-menu-item/swirl-menu-item.d.ts +35 -0
- package/dist/types/components/swirl-menu-item/swirl-menu-item.stories.d.ts +14 -0
- package/dist/types/components/swirl-option-list-item/swirl-option-list-item.d.ts +2 -0
- package/dist/types/components.d.ts +114 -2
- package/dist/types/utils.d.ts +1 -0
- package/package.json +1 -1
- package/vscode-data.json +118 -0
- package/dist/swirl-components/p-438b3941.js +0 -1
- package/dist/swirl-components/p-5a715e12.entry.js +0 -1
- package/dist/swirl-components/p-5e837595.entry.js +0 -8
- package/dist/swirl-components/p-b78ef534.entry.js +0 -1
- package/dist/swirl-components/p-f1f97749.entry.js +0 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as closestPassShadow, p as parentsPassShadow } from './utils.js';
|
|
3
|
+
import { c as classnames } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$6 } from './swirl-action-list-item2.js';
|
|
5
|
+
import { d as defineCustomElement$5 } from './swirl-icon-check-small2.js';
|
|
6
|
+
import { d as defineCustomElement$4 } from './swirl-icon-check-strong2.js';
|
|
7
|
+
import { d as defineCustomElement$3 } from './swirl-icon-drag-handle2.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './swirl-option-list-item2.js';
|
|
9
|
+
|
|
10
|
+
const swirlMenuItemCss = ":host{display:block}:host *{box-sizing:border-box}.menu-item--expanded ::part(action-list-item){background-color:var(--s-surface-overlay-hovered)}";
|
|
11
|
+
|
|
12
|
+
const SwirlMenuItem$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.__registerHost();
|
|
16
|
+
this.__attachShadow();
|
|
17
|
+
this.onSlotChange = () => {
|
|
18
|
+
this.subMenu = this.el.querySelector("swirl-menu");
|
|
19
|
+
this.updateActionListItemProps();
|
|
20
|
+
};
|
|
21
|
+
this.onActionListItemClick = () => {
|
|
22
|
+
if (this.actionListItem.disabled) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.rootMenu.activateMenuItem(this.el);
|
|
26
|
+
};
|
|
27
|
+
this.onOptionListItemClick = () => {
|
|
28
|
+
if (this.optionListItem.disabled) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.parentMenu.updateSelection(this.optionListItem);
|
|
32
|
+
};
|
|
33
|
+
this.onOptionListItemKeyDown = (event) => {
|
|
34
|
+
if (event.code === "Space") {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
else if (event.code === "Enter") {
|
|
38
|
+
if (this.optionListItem.disabled) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
this.parentMenu.updateSelection(this.optionListItem);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.onOptionListItemKeyUp = (event) => {
|
|
46
|
+
if (event.code === "Space") {
|
|
47
|
+
if (this.optionListItem.disabled) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
this.parentMenu.updateSelection(this.optionListItem);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
this.description = undefined;
|
|
55
|
+
this.disabled = undefined;
|
|
56
|
+
this.expanded = undefined;
|
|
57
|
+
this.icon = undefined;
|
|
58
|
+
this.intent = "default";
|
|
59
|
+
this.label = undefined;
|
|
60
|
+
this.value = undefined;
|
|
61
|
+
this.parentMenu = undefined;
|
|
62
|
+
this.subMenu = undefined;
|
|
63
|
+
}
|
|
64
|
+
componentWillLoad() {
|
|
65
|
+
this.parentMenu = closestPassShadow(this.el, "swirl-menu");
|
|
66
|
+
this.rootMenu = parentsPassShadow(this.el, "swirl-menu").pop();
|
|
67
|
+
this.subMenu = this.el.querySelector("swirl-menu");
|
|
68
|
+
}
|
|
69
|
+
watchExpanded() {
|
|
70
|
+
this.updateActionListItemProps();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the items sub menu
|
|
74
|
+
*/
|
|
75
|
+
async getSubMenu() {
|
|
76
|
+
return this.subMenu;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the items parent menu
|
|
80
|
+
*/
|
|
81
|
+
async getParentMenu() {
|
|
82
|
+
return this.parentMenu;
|
|
83
|
+
}
|
|
84
|
+
updateActionListItemProps() {
|
|
85
|
+
if (!Boolean(this.actionListItem)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.actionListItem.swirlAriaExpanded = this.expanded ? "true" : undefined;
|
|
89
|
+
this.actionListItem.swirlAriaHaspopup = Boolean(this.subMenu)
|
|
90
|
+
? "true"
|
|
91
|
+
: undefined;
|
|
92
|
+
this.actionListItem.suffix = Boolean(this.subMenu)
|
|
93
|
+
? '<swirl-icon-chevron-right size="16"></swirl-icon-chevron-right>'
|
|
94
|
+
: undefined;
|
|
95
|
+
}
|
|
96
|
+
renderActionListItem() {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
const badge = Boolean((_a = this.subMenu) === null || _a === void 0 ? void 0 : _a.value)
|
|
99
|
+
? (_c = Array.from(((_b = this.subMenu) === null || _b === void 0 ? void 0 : _b.querySelectorAll("swirl-menu-item")) || []).find((item) => { var _a; return item.value === ((_a = this.subMenu) === null || _a === void 0 ? void 0 : _a.value); })) === null || _c === void 0 ? void 0 : _c.label
|
|
100
|
+
: undefined;
|
|
101
|
+
return (h("swirl-action-list-item", { badge: badge, description: this.description, disabled: this.disabled, icon: this.icon, intent: this.intent, label: this.label, onClick: this.onActionListItemClick, ref: (el) => (this.actionListItem = el) }));
|
|
102
|
+
}
|
|
103
|
+
renderOptionListItem() {
|
|
104
|
+
var _a;
|
|
105
|
+
return (h("swirl-option-list-item", { disabled: this.disabled, icon: this.icon, label: this.label, onClick: this.onOptionListItemClick, onKeyDown: this.onOptionListItemKeyDown, onKeyUp: this.onOptionListItemKeyUp, ref: (el) => (this.optionListItem = el), selected: ((_a = this.parentMenu) === null || _a === void 0 ? void 0 : _a.value) === this.value, swirlAriaRole: "menuitemradio", value: this.value }));
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
var _a;
|
|
109
|
+
const className = classnames("menu-item", {
|
|
110
|
+
"menu-item--expanded": this.expanded,
|
|
111
|
+
});
|
|
112
|
+
return (h(Host, null, h("div", { class: className }, ((_a = this.parentMenu) === null || _a === void 0 ? void 0 : _a.variant) === "selection"
|
|
113
|
+
? this.renderOptionListItem()
|
|
114
|
+
: this.renderActionListItem(), h("slot", { onSlotchange: this.onSlotChange }))));
|
|
115
|
+
}
|
|
116
|
+
get el() { return this; }
|
|
117
|
+
static get watchers() { return {
|
|
118
|
+
"expanded": ["watchExpanded"]
|
|
119
|
+
}; }
|
|
120
|
+
static get style() { return swirlMenuItemCss; }
|
|
121
|
+
}, [1, "swirl-menu-item", {
|
|
122
|
+
"description": [1],
|
|
123
|
+
"disabled": [4],
|
|
124
|
+
"expanded": [4],
|
|
125
|
+
"icon": [1],
|
|
126
|
+
"intent": [1],
|
|
127
|
+
"label": [1],
|
|
128
|
+
"value": [1],
|
|
129
|
+
"parentMenu": [32],
|
|
130
|
+
"subMenu": [32],
|
|
131
|
+
"getSubMenu": [64],
|
|
132
|
+
"getParentMenu": [64]
|
|
133
|
+
}]);
|
|
134
|
+
function defineCustomElement$1() {
|
|
135
|
+
if (typeof customElements === "undefined") {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const components = ["swirl-menu-item", "swirl-action-list-item", "swirl-icon-check-small", "swirl-icon-check-strong", "swirl-icon-drag-handle", "swirl-option-list-item"];
|
|
139
|
+
components.forEach(tagName => { switch (tagName) {
|
|
140
|
+
case "swirl-menu-item":
|
|
141
|
+
if (!customElements.get(tagName)) {
|
|
142
|
+
customElements.define(tagName, SwirlMenuItem$1);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "swirl-action-list-item":
|
|
146
|
+
if (!customElements.get(tagName)) {
|
|
147
|
+
defineCustomElement$6();
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case "swirl-icon-check-small":
|
|
151
|
+
if (!customElements.get(tagName)) {
|
|
152
|
+
defineCustomElement$5();
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
case "swirl-icon-check-strong":
|
|
156
|
+
if (!customElements.get(tagName)) {
|
|
157
|
+
defineCustomElement$4();
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case "swirl-icon-drag-handle":
|
|
161
|
+
if (!customElements.get(tagName)) {
|
|
162
|
+
defineCustomElement$3();
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
case "swirl-option-list-item":
|
|
166
|
+
if (!customElements.get(tagName)) {
|
|
167
|
+
defineCustomElement$2();
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
} });
|
|
171
|
+
}
|
|
172
|
+
defineCustomElement$1();
|
|
173
|
+
|
|
174
|
+
const SwirlMenuItem = SwirlMenuItem$1;
|
|
175
|
+
const defineCustomElement = defineCustomElement$1;
|
|
176
|
+
|
|
177
|
+
export { SwirlMenuItem, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SwirlMenu extends Components.SwirlMenu, HTMLElement {}
|
|
4
|
+
export const SwirlMenu: {
|
|
5
|
+
prototype: SwirlMenu;
|
|
6
|
+
new (): SwirlMenu;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as computePosition, a as autoUpdate, o as offset, f as flip } from './floating-ui.dom.esm.js';
|
|
3
|
+
import { c as classnames } from './index2.js';
|
|
4
|
+
import { q as querySelectorAllDeep, c as closestPassShadow, p as parentsPassShadow, i as isMobileViewport, b as getActiveElement } from './utils.js';
|
|
5
|
+
import { d as defineCustomElement$3 } from './swirl-button2.js';
|
|
6
|
+
import { d as defineCustomElement$2 } from './swirl-heading2.js';
|
|
7
|
+
|
|
8
|
+
const swirlMenuCss = ":host{display:block}:host *{box-sizing:border-box}.menu{width:100%;--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed)}.menu--mobile.menu--root{position:relative}.menu--mobile.menu--root .menu__menu{top:3.5rem;transition:left 0.2s}.menu--mobile.menu--active .menu__menu{display:block}.menu--mobile .menu__menu{position:absolute;top:0;left:0;display:none;width:100%}:not(.menu--mobile).menu--root{position:relative}:not(.menu--mobile).menu--root .menu__menu{position:relative;padding-top:0;padding-bottom:0}:not(.menu--mobile):not(.menu--root) .menu__menu{z-index:1;max-width:22.5rem;border-radius:var(--s-border-radius-sm);box-shadow:var(--s-shadow-level-1)}:not(.menu--mobile).menu--active .menu__menu{display:block}:not(.menu--mobile) .menu__menu{position:fixed;display:none}.menu__mobile-header{display:flex;height:3.5rem;padding-right:var(--s-space-16);padding-left:var(--s-space-16);justify-content:space-between;align-items:center;border-bottom:var(--s-border-width-default) solid var(--s-border-default);gap:var(--s-space-8)}.menu__mobile-header>*{display:inline-flex;flex-shrink:0}.menu__title{min-width:0;flex-grow:1;flex-shrink:1}.menu__title swirl-heading{min-width:0}.menu__done-button{margin-right:calc(-1 * var(--s-space-8))}.menu__menu{padding-top:var(--s-space-8);padding-bottom:var(--s-space-8);background-color:var(--s-surface-overlay-default)}";
|
|
9
|
+
|
|
10
|
+
const SwirlMenu$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.__registerHost();
|
|
14
|
+
this.__attachShadow();
|
|
15
|
+
this.done = createEvent(this, "done", 7);
|
|
16
|
+
this.valueChange = createEvent(this, "valueChange", 7);
|
|
17
|
+
this.mobileMediaQuery = window.matchMedia("(min-width: 768px)");
|
|
18
|
+
this.mediaQueryHandler = () => {
|
|
19
|
+
this.updateMobileState();
|
|
20
|
+
};
|
|
21
|
+
this.resetMenu = () => {
|
|
22
|
+
this.items.forEach((item) => {
|
|
23
|
+
item.tabIndex = -1;
|
|
24
|
+
});
|
|
25
|
+
if (this.level > 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// wait for animation
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
this.activeLevel = 0;
|
|
31
|
+
const subMenus = querySelectorAllDeep(this.el, "swirl-menu");
|
|
32
|
+
// disable sub menus
|
|
33
|
+
subMenus.forEach((subMenu) => {
|
|
34
|
+
subMenu.active = false;
|
|
35
|
+
subMenu.parentElement.expanded = false;
|
|
36
|
+
});
|
|
37
|
+
}, this.mobile ? 200 : 60);
|
|
38
|
+
};
|
|
39
|
+
this.closeMenu = () => {
|
|
40
|
+
if (this.disableAutoUpdate) {
|
|
41
|
+
this.disableAutoUpdate();
|
|
42
|
+
}
|
|
43
|
+
this.popover.close();
|
|
44
|
+
this.resetMenu();
|
|
45
|
+
};
|
|
46
|
+
this.reposition = async () => {
|
|
47
|
+
if (this.mobile || this.level === 0) {
|
|
48
|
+
this.position = undefined;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const trigger = this.el.parentElement;
|
|
52
|
+
if (!Boolean(trigger) || !Boolean(this.menuContainer)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.position = await computePosition(trigger, this.menuContainer, {
|
|
56
|
+
placement: "right-start",
|
|
57
|
+
strategy: "fixed",
|
|
58
|
+
middleware: [offset({ mainAxis: -10, crossAxis: 0 }), flip()],
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
this.onKeyDown = (event) => {
|
|
62
|
+
if (event.code === "ArrowDown") {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
this.focusNextItem();
|
|
66
|
+
}
|
|
67
|
+
else if (event.code === "ArrowUp") {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
this.focusPreviousItem();
|
|
71
|
+
}
|
|
72
|
+
else if (event.code === "ArrowLeft") {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
this.rootMenu.goBack();
|
|
76
|
+
}
|
|
77
|
+
else if (event.code === "ArrowRight") {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
const activeItem = closestPassShadow(this.items[this.getActiveItemIndex()], "swirl-menu-item");
|
|
80
|
+
if (!Boolean(activeItem)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.rootMenu.activateMenuItem(activeItem);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
this.onClose = () => {
|
|
87
|
+
this.closeMenu();
|
|
88
|
+
};
|
|
89
|
+
this.onDone = () => {
|
|
90
|
+
this.closeMenu();
|
|
91
|
+
this.done.emit();
|
|
92
|
+
};
|
|
93
|
+
this.onGoBack = () => {
|
|
94
|
+
this.rootMenu.goBack();
|
|
95
|
+
};
|
|
96
|
+
this.active = true;
|
|
97
|
+
this.label = undefined;
|
|
98
|
+
this.level = 0;
|
|
99
|
+
this.mobileBackButtonLabel = "Back";
|
|
100
|
+
this.mobileCloseMenuButtonLabel = "Close menu";
|
|
101
|
+
this.mobileDoneButtonLabel = "Done";
|
|
102
|
+
this.value = undefined;
|
|
103
|
+
this.variant = "action";
|
|
104
|
+
this.activeLevel = 0;
|
|
105
|
+
this.mobile = undefined;
|
|
106
|
+
this.position = undefined;
|
|
107
|
+
}
|
|
108
|
+
componentWillLoad() {
|
|
109
|
+
this.updateMobileState();
|
|
110
|
+
this.updateLevel();
|
|
111
|
+
this.observeSlotChanges();
|
|
112
|
+
}
|
|
113
|
+
componentDidLoad() {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
(_b = (_a = this.mobileMediaQuery).addEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, "change", this.mediaQueryHandler);
|
|
116
|
+
this.parentMenu = closestPassShadow(this.el.parentElement, "swirl-menu");
|
|
117
|
+
this.popover = closestPassShadow(this.el, "swirl-popover");
|
|
118
|
+
this.rootMenu = parentsPassShadow(this.el, "swirl-menu").pop();
|
|
119
|
+
if (Boolean(this.parentMenu)) {
|
|
120
|
+
queueMicrotask(() => {
|
|
121
|
+
this.active = false;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
this.popover.addEventListener("popoverClose", this.resetMenu);
|
|
125
|
+
this.updateItems();
|
|
126
|
+
}
|
|
127
|
+
disconnectedCallback() {
|
|
128
|
+
var _a, _b, _c;
|
|
129
|
+
this.popover.removeEventListener("popoverClose", this.resetMenu);
|
|
130
|
+
(_b = (_a = this.mobileMediaQuery).removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, "change", this.mediaQueryHandler);
|
|
131
|
+
(_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
132
|
+
}
|
|
133
|
+
watchActive() {
|
|
134
|
+
this.reposition();
|
|
135
|
+
if (this.disableAutoUpdate) {
|
|
136
|
+
this.disableAutoUpdate();
|
|
137
|
+
}
|
|
138
|
+
this.disableAutoUpdate = autoUpdate(this.el.parentElement, this.menuContainer, this.reposition);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Activate a menu item with a sub menu. Only callable on a root menu.
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
async activateMenuItem(menuItem) {
|
|
145
|
+
if (Boolean(this.parentMenu)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const parentMenu = await menuItem.getParentMenu();
|
|
149
|
+
// deactivate sub menus of parent menu
|
|
150
|
+
const subMenus = querySelectorAllDeep(this.el, "swirl-menu").filter((subMenu) => subMenu.level >= parentMenu.level && subMenu !== parentMenu);
|
|
151
|
+
subMenus.forEach((subMenu) => {
|
|
152
|
+
subMenu.active = false;
|
|
153
|
+
subMenu.parentElement.expanded = false;
|
|
154
|
+
});
|
|
155
|
+
// activate sub menu
|
|
156
|
+
const subMenu = await menuItem.getSubMenu();
|
|
157
|
+
if (!Boolean(subMenu)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
menuItem.expanded = true;
|
|
161
|
+
subMenu.active = true;
|
|
162
|
+
this.activeLevel = subMenu.level;
|
|
163
|
+
// wait for animation to focus first item of sub menu
|
|
164
|
+
setTimeout(() => {
|
|
165
|
+
subMenu.focusFirstItem();
|
|
166
|
+
}, this.mobile ? 200 : 60);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Close and reset the menu. Only callable on a root menu.
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
async close() {
|
|
173
|
+
this.closeMenu();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Collapse the currently active sub menu. Only callable on a root menu.
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
async goBack() {
|
|
180
|
+
if (Boolean(this.parentMenu) || this.activeLevel === 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const currentlyActiveSubMenu = querySelectorAllDeep(this.el, "swirl-menu").find((subMenu) => subMenu.level === this.activeLevel && subMenu.active) || this.rootMenu;
|
|
184
|
+
const deactivatedMenuItem = currentlyActiveSubMenu.parentElement;
|
|
185
|
+
deactivatedMenuItem.expanded = false;
|
|
186
|
+
this.activeLevel = Math.max(this.activeLevel - 1, 0);
|
|
187
|
+
const subMenus = querySelectorAllDeep(this.el, "swirl-menu").filter((subMenu) => subMenu.level > this.activeLevel);
|
|
188
|
+
// disable sub menus of deactivated level(s)
|
|
189
|
+
subMenus.forEach((subMenu) => {
|
|
190
|
+
subMenu.active = false;
|
|
191
|
+
});
|
|
192
|
+
const activatedMenu = querySelectorAllDeep(this.el, "swirl-menu").find((subMenu) => subMenu.level === this.activeLevel && subMenu.active) || this.rootMenu;
|
|
193
|
+
activatedMenu.focusItemAtIndex(Array.from(deactivatedMenuItem.parentElement.children).indexOf(deactivatedMenuItem));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Focus the first menu item.
|
|
197
|
+
* @returns
|
|
198
|
+
*/
|
|
199
|
+
async focusFirstItem() {
|
|
200
|
+
this.focusItem(this.items[0]);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Focus the menu item at index.
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
async focusItemAtIndex(index) {
|
|
207
|
+
this.focusItem(this.items[index]);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Update the selection of a menu with variant "selection".
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
async updateSelection(item) {
|
|
214
|
+
this.valueChange.emit(item.value);
|
|
215
|
+
}
|
|
216
|
+
observeSlotChanges() {
|
|
217
|
+
this.observer = new MutationObserver(() => {
|
|
218
|
+
this.updateItems();
|
|
219
|
+
});
|
|
220
|
+
this.observer.observe(this.el, { childList: true });
|
|
221
|
+
}
|
|
222
|
+
updateMobileState() {
|
|
223
|
+
const mobile = isMobileViewport();
|
|
224
|
+
if (mobile !== this.mobile) {
|
|
225
|
+
this.mobile = mobile;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
updateItems() {
|
|
229
|
+
this.items = [
|
|
230
|
+
...querySelectorAllDeep(this.el, '[role="menuitem"]'),
|
|
231
|
+
...querySelectorAllDeep(this.el, '[role="menuitemradio"]'),
|
|
232
|
+
].filter((item) => {
|
|
233
|
+
return closestPassShadow(item, "swirl-menu") === this.el;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
updateLevel() {
|
|
237
|
+
const parents = parentsPassShadow(this.el.parentNode, "swirl-menu");
|
|
238
|
+
this.level = parents.length;
|
|
239
|
+
}
|
|
240
|
+
focusItem(item) {
|
|
241
|
+
const items = [
|
|
242
|
+
...querySelectorAllDeep(this.rootMenu, '[role="menuitem"]'),
|
|
243
|
+
...querySelectorAllDeep(this.rootMenu, '[role="menuitemradio"]'),
|
|
244
|
+
];
|
|
245
|
+
items.forEach((item) => {
|
|
246
|
+
item.tabIndex = -1;
|
|
247
|
+
});
|
|
248
|
+
if (!Boolean(item)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
item.tabIndex = 0;
|
|
252
|
+
item.focus();
|
|
253
|
+
}
|
|
254
|
+
focusNextItem() {
|
|
255
|
+
const activeItemIndex = this.getActiveItemIndex();
|
|
256
|
+
const newIndex = (activeItemIndex + 1) % this.items.length;
|
|
257
|
+
const item = this.items[newIndex];
|
|
258
|
+
this.focusItem(item);
|
|
259
|
+
}
|
|
260
|
+
focusPreviousItem() {
|
|
261
|
+
const activeItemIndex = this.getActiveItemIndex();
|
|
262
|
+
const newIndex = activeItemIndex === 0 ? this.items.length - 1 : activeItemIndex - 1;
|
|
263
|
+
const item = this.items[newIndex];
|
|
264
|
+
this.focusItem(item);
|
|
265
|
+
}
|
|
266
|
+
getActiveItemIndex() {
|
|
267
|
+
const activeElement = getActiveElement();
|
|
268
|
+
return this.items.findIndex((item) => item === activeElement ||
|
|
269
|
+
item === (activeElement === null || activeElement === void 0 ? void 0 : activeElement.querySelector('[role="menuitem"]')) ||
|
|
270
|
+
item === (activeElement === null || activeElement === void 0 ? void 0 : activeElement.querySelector('[role="menuitemradio"]')));
|
|
271
|
+
}
|
|
272
|
+
render() {
|
|
273
|
+
var _a, _b;
|
|
274
|
+
const isTopLevelMenu = !Boolean(this.parentMenu);
|
|
275
|
+
const ariaLabel = isTopLevelMenu && this.mobile ? undefined : this.label;
|
|
276
|
+
const ariaLabelledby = isTopLevelMenu && this.mobile ? "menu-title" : undefined;
|
|
277
|
+
const role = isTopLevelMenu ? "menubar" : "menu";
|
|
278
|
+
const className = classnames("menu", `menu--level-${this.level}`, {
|
|
279
|
+
"menu--active": this.active,
|
|
280
|
+
"menu--mobile": this.mobile,
|
|
281
|
+
"menu--root": isTopLevelMenu,
|
|
282
|
+
});
|
|
283
|
+
return (h(Host, null, h("div", { class: className }, this.mobile && isTopLevelMenu && (h("div", { class: "menu__mobile-header" }, this.activeLevel === 0 && (h("swirl-button", { hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.mobileCloseMenuButtonLabel, onClick: this.onClose, variant: "plain" })), this.activeLevel > 0 && (h("swirl-button", { hideLabel: true, icon: "<swirl-icon-chevron-left></swirl-icon-chevron-left>", label: this.mobileBackButtonLabel, onClick: this.onGoBack, variant: "plain" })), h("span", { class: "menu__title", id: "menu-title" }, h("swirl-heading", { align: "center", as: "span", level: 4, text: this.label, truncate: true })), h("swirl-button", { class: "menu__done-button", intent: "primary", label: this.mobileDoneButtonLabel, onClick: this.onDone }))), h("div", { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": "vertical", class: "menu__menu", onKeyDown: this.onKeyDown, ref: (el) => (this.menuContainer = el), role: role, style: !this.mobile && this.level > 0
|
|
284
|
+
? {
|
|
285
|
+
top: Boolean(this.position) ? `${(_a = this.position) === null || _a === void 0 ? void 0 : _a.y}px` : "",
|
|
286
|
+
left: Boolean(this.position) ? `${(_b = this.position) === null || _b === void 0 ? void 0 : _b.x}px` : "",
|
|
287
|
+
}
|
|
288
|
+
: this.mobile
|
|
289
|
+
? {
|
|
290
|
+
left: isTopLevelMenu
|
|
291
|
+
? `calc(-100% * ${this.activeLevel})`
|
|
292
|
+
: "100%",
|
|
293
|
+
}
|
|
294
|
+
: undefined }, h("slot", null)))));
|
|
295
|
+
}
|
|
296
|
+
get el() { return this; }
|
|
297
|
+
static get watchers() { return {
|
|
298
|
+
"active": ["watchActive"]
|
|
299
|
+
}; }
|
|
300
|
+
static get style() { return swirlMenuCss; }
|
|
301
|
+
}, [1, "swirl-menu", {
|
|
302
|
+
"active": [1028],
|
|
303
|
+
"label": [1],
|
|
304
|
+
"level": [1026],
|
|
305
|
+
"mobileBackButtonLabel": [1, "mobile-back-button-label"],
|
|
306
|
+
"mobileCloseMenuButtonLabel": [1, "mobile-close-menu-button-label"],
|
|
307
|
+
"mobileDoneButtonLabel": [1, "mobile-done-button-label"],
|
|
308
|
+
"value": [1],
|
|
309
|
+
"variant": [1],
|
|
310
|
+
"activeLevel": [32],
|
|
311
|
+
"mobile": [32],
|
|
312
|
+
"position": [32],
|
|
313
|
+
"activateMenuItem": [64],
|
|
314
|
+
"close": [64],
|
|
315
|
+
"goBack": [64],
|
|
316
|
+
"focusFirstItem": [64],
|
|
317
|
+
"focusItemAtIndex": [64],
|
|
318
|
+
"updateSelection": [64]
|
|
319
|
+
}]);
|
|
320
|
+
function defineCustomElement$1() {
|
|
321
|
+
if (typeof customElements === "undefined") {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const components = ["swirl-menu", "swirl-button", "swirl-heading"];
|
|
325
|
+
components.forEach(tagName => { switch (tagName) {
|
|
326
|
+
case "swirl-menu":
|
|
327
|
+
if (!customElements.get(tagName)) {
|
|
328
|
+
customElements.define(tagName, SwirlMenu$1);
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
case "swirl-button":
|
|
332
|
+
if (!customElements.get(tagName)) {
|
|
333
|
+
defineCustomElement$3();
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
case "swirl-heading":
|
|
337
|
+
if (!customElements.get(tagName)) {
|
|
338
|
+
defineCustomElement$2();
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
} });
|
|
342
|
+
}
|
|
343
|
+
defineCustomElement$1();
|
|
344
|
+
|
|
345
|
+
const SwirlMenu = SwirlMenu$1;
|
|
346
|
+
const defineCustomElement = defineCustomElement$1;
|
|
347
|
+
|
|
348
|
+
export { SwirlMenu, defineCustomElement };
|
|
@@ -5,7 +5,7 @@ import { d as defineCustomElement$3 } from './swirl-icon-check-small2.js';
|
|
|
5
5
|
import { d as defineCustomElement$2 } from './swirl-icon-check-strong2.js';
|
|
6
6
|
import { d as defineCustomElement$1 } from './swirl-icon-drag-handle2.js';
|
|
7
7
|
|
|
8
|
-
const swirlOptionListItemCss = ".sc-swirl-option-list-item-h{position:relative;display:inline-flex;width:100%}.sc-swirl-option-list-item-h *.sc-swirl-option-list-item{box-sizing:border-box}.option-list-item.sc-swirl-option-list-item{display:inline-flex;width:100%;min-height:3rem;padding:var(--s-space-12) var(--s-space-16);align-items:center;background-color:var(--s-surface-overlay-default);cursor:pointer;gap:var(--s-space-12)}.option-list-item.sc-swirl-option-list-item:hover:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-hovered)}.option-list-item.sc-swirl-option-list-item:active:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-pressed)}.option-list-item.sc-swirl-option-list-item:focus{outline:none}.option-list-item.sc-swirl-option-list-item:focus-visible{background-color:var(--s-surface-overlay-hovered)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item.sc-swirl-option-list-item{min-height:0;padding:var(--s-space-12);gap:var(--s-space-8)}}.option-list-item--draggable.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{padding-right:calc(var(--s-space-16) + 1.5rem)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item--draggable.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{padding-right:calc(var(--s-space-16) + 1rem)}}.option-list-item--dragging.sc-swirl-option-list-item{z-index:1;border-radius:var(--s-border-radius-s);background-color:var(--s-surface-overlay-pressed);box-shadow:0 0.0625rem 0.125rem rgba(25, 26, 28, 0.08),\n 0 0.25rem 2rem rgba(25, 26, 28, 0.16)}.option-list-item--dragging.sc-swirl-option-list-item:hover:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-pressed)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{color:var(--s-text-highlight)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__icon.sc-swirl-option-list-item{color:var(--s-icon-highlight)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{border-color:var(--s-icon-highlight);color:var(--s-text-on-status);background-color:var(--s-icon-highlight)}.option-list-item--disabled.sc-swirl-option-list-item{cursor:default}.option-list-item--disabled.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{background-color:var(--s-icon-disabled)}.option-list-item--disabled.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-icon.sc-swirl-option-list-item{color:var(--s-text-on-status)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{color:var(--s-text-disabled)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__icon.sc-swirl-option-list-item,.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__selection-icon.sc-swirl-option-list-item,.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__checkbox-icon.sc-swirl-option-list-item{color:var(--s-icon-disabled)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{border-color:var(--s-icon-disabled);background-color:var(--s-surface-overlay-default)}.option-list-item__label.sc-swirl-option-list-item{flex-grow:1;color:var(--s-text-default);font-size:var(--s-font-size-base);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-base);text-align:left}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item__label.sc-swirl-option-list-item{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.option-list-item__icon.sc-swirl-option-list-item{display:inline-flex;flex-shrink:0;color:var(--s-icon-default)}.option-list-item__selection-icon.sc-swirl-option-list-item{display:inline-flex;flex-shrink:0;color:var(--s-icon-highlight)}.option-list-item__checkbox.sc-swirl-option-list-item{display:inline-flex;width:1.5rem;height:1.5rem;padding:var(--s-space-2)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item__checkbox.sc-swirl-option-list-item{width:1.375rem;height:1.375rem}}.option-list-item__checkbox-box.sc-swirl-option-list-item{display:inline-flex;width:100%;height:100%;justify-content:center;align-items:center;border:0.125rem solid var(--s-icon-default);border-radius:var(--s-border-radius-s)}.option-list-item__checkbox-icon.sc-swirl-option-list-item{display:inline-flex}.option-list-item__drag-handle.sc-swirl-option-list-item{position:absolute;z-index:1;top:50%;right:var(--s-space-4);display:inline-flex;margin:0;padding:0;padding:var(--s-space-8);flex-shrink:0;border:none;color:var(--s-icon-default);background-color:transparent;cursor:grab;transform:translateY(-50%)}.option-list-item__drag-handle.sc-swirl-option-list-item:active{cursor:grabbing}.option-list-item__drag-handle.sc-swirl-option-list-item:focus:not(:focus-visible){outline:none}.option-list-item__drag-handle.sc-swirl-option-list-item:focus-visible{outline-color:var(--s-focus-default)}";
|
|
8
|
+
const swirlOptionListItemCss = ".sc-swirl-option-list-item-h{position:relative;display:inline-flex;width:100%}.sc-swirl-option-list-item-h *.sc-swirl-option-list-item{box-sizing:border-box}.option-list-item.sc-swirl-option-list-item{display:inline-flex;width:100%;min-width:15rem;min-height:3rem;padding:var(--s-space-12) var(--s-space-16);align-items:center;background-color:var(--s-surface-overlay-default);cursor:pointer;gap:var(--s-space-12)}.option-list-item.sc-swirl-option-list-item:hover:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-hovered)}.option-list-item.sc-swirl-option-list-item:active:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-pressed)}.option-list-item.sc-swirl-option-list-item:focus{outline:none}.option-list-item.sc-swirl-option-list-item:focus-visible{background-color:var(--s-surface-overlay-hovered)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item.sc-swirl-option-list-item{min-height:0;padding:var(--s-space-8) var(--s-space-12);gap:var(--s-space-8)}}.option-list-item--draggable.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{padding-right:calc(var(--s-space-16) + 1.5rem)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item--draggable.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{padding-right:calc(var(--s-space-16) + 1rem)}}.option-list-item--dragging.sc-swirl-option-list-item{z-index:1;border-radius:var(--s-border-radius-s);background-color:var(--s-surface-overlay-pressed);box-shadow:0 0.0625rem 0.125rem rgba(25, 26, 28, 0.08),\n 0 0.25rem 2rem rgba(25, 26, 28, 0.16)}.option-list-item--dragging.sc-swirl-option-list-item:hover:not(.option-list-item--disabled){background-color:var(--s-surface-overlay-pressed)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{color:var(--s-text-highlight)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__icon.sc-swirl-option-list-item{color:var(--s-icon-highlight)}.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{border-color:var(--s-icon-highlight);color:var(--s-text-on-status);background-color:var(--s-icon-highlight)}.option-list-item--disabled.sc-swirl-option-list-item{cursor:default}.option-list-item--disabled.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{background-color:var(--s-icon-disabled)}.option-list-item--disabled.option-list-item--selected.sc-swirl-option-list-item .option-list-item__checkbox-icon.sc-swirl-option-list-item{color:var(--s-text-on-status)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__label.sc-swirl-option-list-item{color:var(--s-text-disabled)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__icon.sc-swirl-option-list-item,.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__selection-icon.sc-swirl-option-list-item,.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__checkbox-icon.sc-swirl-option-list-item{color:var(--s-icon-disabled)}.option-list-item--disabled.sc-swirl-option-list-item .option-list-item__checkbox-box.sc-swirl-option-list-item{border-color:var(--s-icon-disabled);background-color:var(--s-surface-overlay-default)}.option-list-item__label.sc-swirl-option-list-item{flex-grow:1;color:var(--s-text-default);font-size:var(--s-font-size-base);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-base);text-align:left}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item__label.sc-swirl-option-list-item{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.option-list-item__icon.sc-swirl-option-list-item{display:inline-flex;flex-shrink:0;color:var(--s-icon-default)}.option-list-item__selection-icon.sc-swirl-option-list-item{display:inline-flex;flex-shrink:0;color:var(--s-icon-highlight)}.option-list-item__checkbox.sc-swirl-option-list-item{display:inline-flex;width:1.5rem;height:1.5rem;padding:var(--s-space-2)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.option-list-item__checkbox.sc-swirl-option-list-item{width:1.375rem;height:1.375rem}}.option-list-item__checkbox-box.sc-swirl-option-list-item{display:inline-flex;width:100%;height:100%;justify-content:center;align-items:center;border:0.125rem solid var(--s-icon-default);border-radius:var(--s-border-radius-s)}.option-list-item__checkbox-icon.sc-swirl-option-list-item{display:inline-flex}.option-list-item__drag-handle.sc-swirl-option-list-item{position:absolute;z-index:1;top:50%;right:var(--s-space-4);display:inline-flex;margin:0;padding:0;padding:var(--s-space-8);flex-shrink:0;border:none;color:var(--s-icon-default);background-color:transparent;cursor:grab;transform:translateY(-50%)}.option-list-item__drag-handle.sc-swirl-option-list-item:active{cursor:grabbing}.option-list-item__drag-handle.sc-swirl-option-list-item:focus:not(:focus-visible){outline:none}.option-list-item__drag-handle.sc-swirl-option-list-item:focus-visible{outline-color:var(--s-focus-default)}";
|
|
9
9
|
|
|
10
10
|
const SwirlOptionListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
11
11
|
constructor() {
|
|
@@ -32,6 +32,7 @@ const SwirlOptionListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
32
32
|
this.icon = undefined;
|
|
33
33
|
this.label = undefined;
|
|
34
34
|
this.selected = false;
|
|
35
|
+
this.swirlAriaRole = "option";
|
|
35
36
|
this.value = undefined;
|
|
36
37
|
this.iconSize = 24;
|
|
37
38
|
}
|
|
@@ -65,7 +66,7 @@ const SwirlOptionListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
65
66
|
"option-list-item--dragging": this.dragging,
|
|
66
67
|
"option-list-item--selected": this.selected,
|
|
67
68
|
});
|
|
68
|
-
return (h(Host, null, h("div", { "aria-disabled": ariaDisabled, "aria-selected": ariaSelected, class: className, part: "option-list-item", role:
|
|
69
|
+
return (h(Host, null, h("div", { "aria-checked": this.swirlAriaRole === "menuitemradio" ? ariaSelected : undefined, "aria-disabled": ariaDisabled, "aria-selected": this.swirlAriaRole === "option" ? ariaSelected : undefined, class: className, part: "option-list-item", role: this.swirlAriaRole }, showIcon && (h("span", { class: "option-list-item__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) })), showCheckbox && (h("span", { class: "option-list-item__checkbox" }, h("span", { class: "option-list-item__checkbox-box" }, this.selected && (h("swirl-icon-check-strong", { class: "option-list-item__checkbox-icon", size: 16 }))))), h("span", { class: "option-list-item__label", part: "option-list-item__label" }, this.label), showSelectionIcon && (h("span", { class: "option-list-item__selection-icon" }, h("swirl-icon-check-small", { size: this.iconSize })))), this.allowDrag && (h("button", { "aria-describedby": this.dragHandleDescription, "aria-label": `${this.dragHandleLabel} "${this.label}"`, class: "option-list-item__drag-handle", onKeyDown: this.onDragHandleKeyDown, type: "button" }, h("swirl-icon-drag-handle", { size: this.iconSize })))));
|
|
69
70
|
}
|
|
70
71
|
get el() { return this; }
|
|
71
72
|
static get style() { return swirlOptionListItemCss; }
|
|
@@ -79,6 +80,7 @@ const SwirlOptionListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
|
|
|
79
80
|
"icon": [1],
|
|
80
81
|
"label": [1],
|
|
81
82
|
"selected": [1028],
|
|
83
|
+
"swirlAriaRole": [1, "swirl-aria-role"],
|
|
82
84
|
"value": [1],
|
|
83
85
|
"iconSize": [32]
|
|
84
86
|
}]);
|
|
@@ -79,14 +79,17 @@ const SwirlPopover = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
79
79
|
if (!this.active) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
82
83
|
const target = event.target;
|
|
83
84
|
const relatedTarget = event.relatedTarget;
|
|
84
85
|
const activeElement = getActiveElement();
|
|
85
86
|
const popoverLostFocus = !this.el.contains(target) &&
|
|
86
87
|
!this.el.contains(activeElement) &&
|
|
87
|
-
!this.el.contains(relatedTarget || target) &&
|
|
88
88
|
target !== this.triggerEl &&
|
|
89
|
-
|
|
89
|
+
(!isSafari ||
|
|
90
|
+
(isSafari &&
|
|
91
|
+
!this.el.contains(relatedTarget || target) &&
|
|
92
|
+
relatedTarget !== this.el));
|
|
90
93
|
if (popoverLostFocus) {
|
|
91
94
|
this.close();
|
|
92
95
|
}
|
|
@@ -173,7 +173,7 @@ const SwirlTextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
173
173
|
"text-input--inline": this.inline,
|
|
174
174
|
"text-input--show-password": this.type === "password" && this.showPassword,
|
|
175
175
|
});
|
|
176
|
-
return (h(Host, null, h("div", { class: className }, this.prefixLabel && (h("span", { class: "text-input__prefix" }, this.prefixLabel)), h(Tag, { "aria-autocomplete": this.swirlAriaAutocomplete, "aria-controls": this.swirlAriaControls, "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-invalid": ariaInvalid, autoComplete: this.autoComplete, autoFocus: this.autoFocus, class: "text-input__input", disabled: this.disabled, inputMode: this.mode, maxLength: this.maxLength, max: this.type === "number" ? this.max : undefined, min: this.type === "number" ? this.min : undefined, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, onKeyPress: this.onKeyPress, placeholder: !Boolean(this.suffixLabel) ? this.placeholder : undefined, ref: (el) => (this.inputEl = el), required: this.required, role: this.swirlRole, rows: this.rows > 1 ? this.rows : this.autoGrow ? 1 : undefined, spellcheck: this.spellCheck, step: this.type === "number" ? this.step : undefined, type: type, value: this.
|
|
176
|
+
return (h(Host, null, h("div", { class: className }, this.prefixLabel && (h("span", { class: "text-input__prefix" }, this.prefixLabel)), h(Tag, { "aria-autocomplete": this.swirlAriaAutocomplete, "aria-controls": this.swirlAriaControls, "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-invalid": ariaInvalid, autoComplete: this.autoComplete, autoFocus: this.autoFocus, class: "text-input__input", disabled: this.disabled, inputMode: this.mode, maxLength: this.maxLength, max: this.type === "number" ? this.max : undefined, min: this.type === "number" ? this.min : undefined, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, onKeyPress: this.onKeyPress, placeholder: !Boolean(this.suffixLabel) ? this.placeholder : undefined, ref: (el) => (this.inputEl = el), required: this.required, role: this.swirlRole, rows: this.rows > 1 ? this.rows : this.autoGrow ? 1 : undefined, spellcheck: this.spellCheck, step: this.type === "number" ? this.step : undefined, type: type, value: this.value }, this.rows > 1 && this.value), this.suffixLabel && (h("span", { class: "text-input__suffix" }, this.suffixLabel)), showClearButton && (h("button", { "aria-label": this.clearButtonLabel, class: "text-input__clear-button", onClick: this.clear, part: "text-input__clear-button", type: "button" }, h("swirl-icon-cancel", { size: this.iconSize }))), showPasswordToggle && (h("button", { "aria-label": this.passwordToggleLabel, class: "text-input__password-toggle", onClick: this.togglePassword, type: "button" }, this.showPassword ? (h("swirl-icon-visibility-off", { size: this.iconSize })) : (h("swirl-icon-visibility", { size: this.iconSize })))), showStepper && (h("span", { class: "text-input__stepper" }, h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.increaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-less", { size: this.iconSize })), h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.decreaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-more", { size: this.iconSize })))), this.showCharacterCounter && (h("span", { class: "text-input__character-counter" }, ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0, " ", Boolean(this.maxLength) ? `/ ${this.maxLength}` : "")))));
|
|
177
177
|
}
|
|
178
178
|
static get style() { return swirlTextInputCss; }
|
|
179
179
|
}, [2, "swirl-text-input", {
|
package/dist/components/utils.js
CHANGED
|
@@ -69,6 +69,23 @@ function getVisibleHeight(element, container) {
|
|
|
69
69
|
function isMobileViewport() {
|
|
70
70
|
return !window.matchMedia("(min-width: 768px)").matches;
|
|
71
71
|
}
|
|
72
|
+
function parentsPassShadow(node, selector, matches = []) {
|
|
73
|
+
if (!node) {
|
|
74
|
+
return matches;
|
|
75
|
+
}
|
|
76
|
+
if (node instanceof ShadowRoot) {
|
|
77
|
+
return parentsPassShadow(node.host, selector, matches);
|
|
78
|
+
}
|
|
79
|
+
if (node instanceof HTMLElement) {
|
|
80
|
+
if (node.matches(selector)) {
|
|
81
|
+
return parentsPassShadow(node.parentNode, selector, [...matches, node]);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return parentsPassShadow(node.parentNode, selector, matches);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return parentsPassShadow(node.parentNode, selector, matches);
|
|
88
|
+
}
|
|
72
89
|
function querySelectorAllDeep(root, selector) {
|
|
73
90
|
function collectAllElementsDeep(selector, root) {
|
|
74
91
|
if (!Boolean(root)) {
|
|
@@ -94,4 +111,4 @@ function querySelectorAllDeep(root, selector) {
|
|
|
94
111
|
return matches;
|
|
95
112
|
}
|
|
96
113
|
|
|
97
|
-
export { getVisibleHeight as a, getActiveElement as b, closestPassShadow as c, debounce as d, getDesktopMediaQuery as g, isMobileViewport as i, querySelectorAllDeep as q };
|
|
114
|
+
export { getVisibleHeight as a, getActiveElement as b, closestPassShadow as c, debounce as d, getDesktopMediaQuery as g, isMobileViewport as i, parentsPassShadow as p, querySelectorAllDeep as q };
|