0.42.2 • Published 27 days ago

@spectrum-web-components/action-menu v0.42.2

Weekly downloads
176
License
Apache-2.0
Repository
github
Last release
27 days ago

Description

An <sp-action-menu> is an action button that triggers an overlay with <sp-menu-items> for activation. Use an <sp-menu> element to outline the items that will be made available to the user when interacting with the <sp-action-menu> element. By default <sp-action-menu> does not manage a selection. If you'd like for a selection to be held by the <sp-menu> that is presented in its overlay, use selects="single" to activate this functionality.

Usage

See it on NPM! How big is this package in your project? Try it on webcomponents.dev

yarn add @spectrum-web-components/action-menu

Import the side effectful registration of <sp-action-menu> via:

import '@spectrum-web-components/action-menu/sp-action-menu.js';

The default of <sp-action-menu> will load dependencies in @spectrum-web-components/overlay asynchronously via a dynamic import. In the case that you would like to import those tranverse dependencies statically, import the side effectful registration of <sp-action-menu> as follows:

import '@spectrum-web-components/action-menu/sync/sp-action-menu.js';

When looking to leverage the ActionMenu base class as a type and/or for extension purposes, do so via:

import { ActionMenu } from '@spectrum-web-components/action-menu';

Sizes

<sp-action-menu size="s">
    <span slot="label">More Actions</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>
<sp-action-menu size="m">
    <span slot="label">More Actions</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>
<sp-action-menu size="l">
    <span slot="label">More Actions</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>
<sp-action-menu size="xl">
    <span slot="label">More Actions</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>

Variants

No icon

In order to deliver an <sp-action-menu> without an icon, use the label-only slot. This will supress any icon from being displayed, both the default ellipsis icon or any icon the user might provide to the element.

<sp-action-menu>
    <span slot="label-only">More Actions</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>

No visible label

The visible label that is be provided via the default <slot> interface can be ommitted in preference of an icon only interface. In this context be sure that the <sp-action-menu> continued to be accessible to screen readers by applying the label attribute. This will apply an aria-label attribute of the same value to the <button> element that toggles the menu list.

<sp-action-menu label="More Actions">
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>

Alternate icon

A custom icon can be supplied via the icon slot in order to replace the default meatballs icon.

<sp-action-menu>
    <sp-icon-settings slot="icon"></sp-icon-settings>
    <span slot="label">Actions under the gear</span>
    <sp-menu-item>
        Deselect
    </sp-menu-item>
    <sp-menu-item>
        Select inverse
    </sp-menu-item>
    <sp-menu-item>
        Feather...
    </sp-menu-item>
    <sp-menu-item>
        Select and mask...
    </sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>
        Save selection
    </sp-menu-item>
    <sp-menu-item disabled>
        Make work path
    </sp-menu-item>
</sp-action-menu>

Selection.

When selects is set to single, the <sp-action-menu> element will maintain one selected item after an initial selection is made.

<p>
    The value of the `&lt;sp-action-menu&gt;` element is:
    <span id="single-value"></span>
</p>
<sp-action-menu
    selects="single"
    onchange="this.previousElementSibling.querySelector('#single-value').textContent=this.value"
>
    <span slot="label">Available shapes</span>
    <sp-menu-item value="shape-1-square">Square</sp-menu-item>
    <sp-menu-item value="shape-2-triangle">Triangle</sp-menu-item>
    <sp-menu-item value="shape-3-parallelogram">Parallelogram</sp-menu-item>
    <sp-menu-item value="shape-4-star">Star</sp-menu-item>
    <sp-menu-item value="shape-5-hexagon">Hexagon</sp-menu-item>
    <sp-menu-item value="shape-6-circle" disabled>Circle</sp-menu-item>
</sp-action-menu>

Accessibility

An <sp-action-menu> parent will ensure that the internal <sp-menu> features a role of listbox and contains children with the role option. Upon focusing the <sp-action-menu> using ArrowDown will also open the menu while throwing focus into first selected (or unselected when none are selected) menu item to assist in selecting of a new value.

Adding tootip in action menu

Tooltip in action menu can be attached via adding and can be customized by using various parameters (e.g. placement, content, etc) as needed.

<sp-action-menu>
    <sp-tooltip slot="tooltip" self-managed placement="bottom">
        Content
    </sp-tooltip>
    <span slot="label">Available shapes</span>
    <sp-menu-item value="shape-1-square">Square</sp-menu-item>
    <sp-menu-item value="shape-2-triangle">Triangle</sp-menu-item>
    <sp-menu-item value="shape-3-parallelogram">Parallelogram</sp-menu-item>
</sp-action-menu>
0.42.2

27 days ago

0.42.1

28 days ago

0.42.0

1 month ago

0.41.2

2 months ago

0.41.1

2 months ago

0.41.0

3 months ago

0.40.5

3 months ago

0.40.4

3 months ago

0.40.3

4 months ago

0.40.2

4 months ago

0.40.1

5 months ago

0.35.1-rc.15

9 months ago

0.35.1-rc.26

9 months ago

0.35.1-rc.24

9 months ago

0.38.0

8 months ago

0.35.1-rc.34

9 months ago

0.35.1-rc.43

9 months ago

0.35.1-rc.41

9 months ago

0.39.1

7 months ago

0.39.0

7 months ago

0.39.4

6 months ago

0.39.3

6 months ago

0.39.2

7 months ago

0.36.0

9 months ago

0.40.0

6 months ago

0.37.0

9 months ago

0.34.1-rc.0

10 months ago

0.34.0

10 months ago

0.35.0

9 months ago

0.33.3-overlay.66

10 months ago

0.33.3-overlay.61

10 months ago

0.32.0

11 months ago

0.31.1-react.3

12 months ago

0.31.1-react.2

12 months ago

0.33.2

11 months ago

0.33.1

11 months ago

0.33.0

11 months ago

0.30.0

12 months ago

0.33.1-overlay.41

11 months ago

0.32.1-overlay.33

11 months ago

0.32.1-overlay.41

11 months ago

0.31.0

12 months ago

0.31.1-overlay.29

12 months ago

0.31.1-react.21

11 months ago

0.30.1-overlay.30

12 months ago

0.30.1-overlay.31

12 months ago

0.30.1-overlay.38

12 months ago

0.30.1-overlay.37

12 months ago

0.30.1-overlay.41

12 months ago

0.30.1-overlay.42

12 months ago

0.30.1-overlay.40

12 months ago

0.16.0

1 year ago

0.16.1

1 year ago

0.16.2

1 year ago

0.15.14

1 year ago

0.15.13

1 year ago

0.15.12

1 year ago

0.15.9-react.54

1 year ago

0.15.10

1 year ago

0.15.11

1 year ago

0.15.9

1 year ago

0.15.4

2 years ago

0.15.5

2 years ago

0.15.6

2 years ago

0.15.7

1 year ago

0.15.8

1 year ago

0.15.1

2 years ago

0.15.2

2 years ago

0.15.3

2 years ago

0.14.1-devmode.0

2 years ago

0.14.1-devmode.7

2 years ago

0.14.0

2 years ago

0.14.1

2 years ago

0.15.0

2 years ago

0.15.0-devmode.0

2 years ago

0.13.16

2 years ago

0.14.2-devmode.0

2 years ago

0.13.15-slim.2

2 years ago

0.13.15

2 years ago

0.13.14

2 years ago

0.13.13

2 years ago

0.13.12

2 years ago

0.13.11

2 years ago

0.13.11-slim.10

2 years ago

0.14.0-slim.10

2 years ago

0.13.9-express.0

2 years ago

0.13.8

2 years ago

0.13.9

2 years ago

0.13.10

2 years ago

0.13.6

2 years ago

0.13.7

2 years ago

0.13.2

2 years ago

0.13.3

2 years ago

0.13.4

2 years ago

0.13.5

2 years ago

0.13.3-express.0

2 years ago

0.13.8-express.9

2 years ago

0.13.0

2 years ago

0.13.1

2 years ago

0.13.2-express.0

2 years ago

0.12.1

2 years ago

0.12.0

2 years ago

0.11.6

3 years ago

0.11.5

3 years ago

0.11.4

3 years ago

0.11.3

3 years ago

0.11.2

3 years ago

0.11.2-beta.3

3 years ago

0.11.1

3 years ago

0.11.2-alpha.1

3 years ago

0.11.0

3 years ago

0.11.1-alpha.1

3 years ago

0.10.4

3 years ago

0.10.5-alpha.1

3 years ago

0.10.3

3 years ago

0.10.4-alpha.1

3 years ago

0.10.3-alpha.1

3 years ago

0.10.2

3 years ago

0.10.2-alpha.14

3 years ago

0.10.2-alpha.13

3 years ago

0.10.2-alpha.12

3 years ago

0.10.2-alpha.1

3 years ago

0.10.1

3 years ago

0.10.1-alpha.22

3 years ago

0.10.1-alpha.0

3 years ago

0.10.0

3 years ago

0.9.8-alpha.0

3 years ago

0.9.7

3 years ago

0.9.6

3 years ago

0.9.6-alpha.1

3 years ago

0.9.6-alpha.0

3 years ago

0.9.5-alpha.26

3 years ago

0.9.5

3 years ago

0.9.5-alpha.23

3 years ago

0.9.5-alpha.22

3 years ago

0.9.5-alpha.21

3 years ago

0.9.5-beta.17

3 years ago

0.9.5-beta.16

3 years ago

0.9.5-beta.11

3 years ago

0.9.5-beta.10

3 years ago

0.9.5-beta.13

3 years ago

0.9.5-beta.12

3 years ago

0.9.5-beta.15

3 years ago

0.9.5-beta.14

3 years ago

0.9.5-alpha.12

3 years ago

0.9.5-alpha.11

3 years ago

0.9.5-alpha.10

3 years ago

0.9.5-alpha.17

3 years ago

0.9.5-alpha.9

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.3-alpha.33

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.6.6-alpha.178

3 years ago

0.7.0

3 years ago

0.7.0-alpha.40

3 years ago

0.6.6-alpha.169

3 years ago

0.6.6-alpha.84

3 years ago

0.6.6-alpha.85

3 years ago

0.6.6-alpha.60

3 years ago

0.6.5-alpha.0

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.4-beta.17

4 years ago

0.6.4-alpha.17

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.2-alpha.0

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.7-alpha.44

4 years ago

0.5.7

4 years ago

0.5.7-alpha.1

4 years ago

0.5.6-alpha.0

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.11-alpha.38

4 years ago

0.4.11-alpha.6

4 years ago

0.4.10

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.5-alpha.0

4 years ago

0.4.5-alpha.1

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago