mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
chore: format files with Prettier 3
This commit is contained in:
parent
1dcd09bd98
commit
8e996dc683
391 changed files with 3725 additions and 3785 deletions
|
@ -97,7 +97,7 @@
|
|||
if (target != null) {
|
||||
if (Array.isArray(target)) {
|
||||
target.forEach((node) =>
|
||||
node?.removeEventListener("contextmenu", openMenu)
|
||||
node?.removeEventListener("contextmenu", openMenu),
|
||||
);
|
||||
} else {
|
||||
target.removeEventListener("contextmenu", openMenu);
|
||||
|
@ -139,58 +139,58 @@
|
|||
</script>
|
||||
|
||||
<svelte:window
|
||||
on:contextmenu="{(e) => {
|
||||
on:contextmenu={(e) => {
|
||||
if (target != null) return;
|
||||
if (level > 1) return;
|
||||
if (!ref) return;
|
||||
openMenu(e);
|
||||
}}"
|
||||
on:click="{(e) => {
|
||||
}}
|
||||
on:click={(e) => {
|
||||
if (!open) return;
|
||||
close();
|
||||
}}"
|
||||
on:keydown="{(e) => {
|
||||
if (open && e.key === 'Escape') close();
|
||||
}}"
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (open && e.key === "Escape") close();
|
||||
}}
|
||||
/>
|
||||
|
||||
<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
|
||||
<ul
|
||||
bind:this="{ref}"
|
||||
bind:this={ref}
|
||||
role="menu"
|
||||
tabindex="-1"
|
||||
data-direction="{direction}"
|
||||
data-level="{level}"
|
||||
class:bx--menu="{true}"
|
||||
class:bx--menu--open="{open}"
|
||||
class:bx--menu--invisible="{open && x === 0 && y === 0}"
|
||||
class:bx--menu--root="{level === 1}"
|
||||
data-direction={direction}
|
||||
data-level={level}
|
||||
class:bx--menu={true}
|
||||
class:bx--menu--open={open}
|
||||
class:bx--menu--invisible={open && x === 0 && y === 0}
|
||||
class:bx--menu--root={level === 1}
|
||||
style:left="{x}px"
|
||||
style:top="{y}px"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:click="{({ target }) => {
|
||||
const closestOption = target.closest('[tabindex]');
|
||||
on:click={({ target }) => {
|
||||
const closestOption = target.closest("[tabindex]");
|
||||
|
||||
if (closestOption && closestOption.getAttribute('role') !== 'menuitem') {
|
||||
if (closestOption && closestOption.getAttribute("role") !== "menuitem") {
|
||||
close();
|
||||
}
|
||||
}}"
|
||||
}}
|
||||
on:keydown
|
||||
on:keydown="{(e) => {
|
||||
on:keydown={(e) => {
|
||||
if (open) e.preventDefault();
|
||||
if ($hasPopup) return;
|
||||
|
||||
if (e.key === 'ArrowDown') {
|
||||
if (e.key === "ArrowDown") {
|
||||
if (focusIndex < options.length - 1) focusIndex++;
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
} else if (e.key === "ArrowUp") {
|
||||
if (focusIndex === -1) {
|
||||
focusIndex = options.length - 1;
|
||||
} else {
|
||||
if (focusIndex > 0) focusIndex--;
|
||||
}
|
||||
}
|
||||
}}"
|
||||
}}
|
||||
>
|
||||
<slot />
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue