2021-04-12 16:26:26 +02:00
|
|
|
<script>
|
2021-04-27 11:48:47 +02:00
|
|
|
import { createEventDispatcher, getContext } from "svelte"
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const actionMenu = getContext("actionMenu")
|
|
|
|
|
2021-04-26 17:34:28 +02:00
|
|
|
export let dataCy
|
|
|
|
export let icon = undefined
|
|
|
|
export let disabled = undefined
|
2021-04-27 11:48:47 +02:00
|
|
|
export let noClose = false
|
|
|
|
|
|
|
|
const onClick = () => {
|
|
|
|
if (actionMenu && !noClose) {
|
|
|
|
actionMenu.hide()
|
|
|
|
}
|
|
|
|
dispatch("click")
|
|
|
|
}
|
2021-04-12 16:26:26 +02:00
|
|
|
</script>
|
|
|
|
|
2021-04-26 17:34:28 +02:00
|
|
|
<li
|
|
|
|
data-cy={dataCy}
|
2021-08-24 16:29:50 +02:00
|
|
|
on:click|preventDefault={disabled ? null : onClick}
|
2021-04-26 17:34:28 +02:00
|
|
|
class="spectrum-Menu-item"
|
|
|
|
class:is-disabled={disabled}
|
|
|
|
role="menuitem"
|
|
|
|
tabindex="0"
|
|
|
|
>
|
|
|
|
{#if icon}
|
|
|
|
<svg
|
2021-05-06 16:33:28 +02:00
|
|
|
class="spectrum-Icon spectrum-Icon--sizeS spectrum-Menu-itemIcon"
|
2021-04-26 17:34:28 +02:00
|
|
|
focusable="false"
|
|
|
|
aria-hidden="true"
|
|
|
|
aria-label={icon}
|
|
|
|
>
|
|
|
|
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
|
|
</svg>
|
|
|
|
{/if}
|
|
|
|
<span class="spectrum-Menu-itemLabel"><slot /></span>
|
|
|
|
</li>
|
2021-05-07 09:36:05 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.spectrum-Menu-itemIcon {
|
|
|
|
align-self: center;
|
|
|
|
}
|
|
|
|
</style>
|