1.8.1 • Published 10 months ago

@finastra/menu v1.8.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Menu

fds-menu component is mwc-menu with a different tag to homogenize with FDS library.

See it on NPM! How big is this package in your project? Storybook

Usage

The full document can be found here

Import

npm i @finastra/menu
npm i @finastra/list;
npm i @finastra/button;
import '@finastra/menu';
import '@finastra/button';
import '@finastra/list';

...
<div style="position: relative;">
    <fds-button id="basicButton" raised label="Open Basic Menu"></fds-button>
    <fds-menu id="basicMenu">
        <fds-list-item>one</fds-list-item>
        <fds-list-item>two</fds-list-item>
        <fds-list-item disabled><div>four</div></fds-list-item>
        <li divider></li>
        <fds-list-item>five</fds-list-item>
    </fds-menu>
</div>

<script>
  const menu = document.getElementById('basicMenu');
  const button = document.getElementById('basicButton');

  // anchor must share a parent with menu that is `position: relative`
  menu.anchor = button;
  button.addEventListener('click', function() {
    menu.open = !menu.open;
  });
</script>

API

Properties

PropertyAttributeModifiersTypeDefaultDescription
absoluteabsolutebooleanfalseMakes the menu's position absolute which will be relative to whichever ancestor has position:relative. Setting x and y will modify the menu's left and top. Setting anchor will attempt to position the menu to the anchor.
activatableactivatablebooleanfalseProxies to mwc-list's activatable property.
anchoranchorHTMLElement \| nullnullDetermines from which element the floating menu should calculate sizing and position offsets. In the default case, both mwc-menu and the anchor should share a parent with position:relative. Changing anchor typically requires absolute or fixed.
cornercorner"TOP_LEFT" \| "TOP_RIGHT" \| "BOTTOM_LEFT" \| "BOTTOM_RIGHT" \| "TOP_START" \| "TOP_END" \| "BOTTOM_START" \| "BOTTOM_END""TOP_START"Corner of the anchor from which the menu should position itself.
defaultFocusdefaultFocus"NONE" \| "LIST_ROOT" \| "FIRST_ITEM" \| "LAST_ITEM""LIST_ROOT"Item to focus upon menu open.
fixedfixedbooleanfalseMakes the menu's position fixed which will be relative to the window. Setting x and y will modify the menu's left and top. Setting anchor will attempt to position the menu to the anchor's immediate position before opening.
forceGroupSelectionforceGroupSelectionbooleanfalseForces a menu group to have a selected item by preventing deselection of menu items in menu groups via user interaction.
fullwidthfullwidthbooleanfalseSets surface width to 100%.
indexreadonlyMWCListIndex
innerAriaLabelinnerAriaLabelstring \| nullnullProxies to mwc-list's innerAriaLabel property.
innerRoleinnerRole"menu" \| "listbox""menu"Proxies to mwc-list's innerRole property.
itemsitemsListItemBase[]"[]"Proxies to mwc-list's index property.
mdcRootMenuSurfaceRoot element for MDC Foundation usage.Define in your component with the @query decorator
menuCornermenuCornerMenuCorner"START"Horizontal corner of the menu from which the menu should position itself. NOTE: Only horizontal corners are supported.
multimultibooleanfalseProxies to mwc-list's multi property.
openopenbooleanfalseWhether the menu should open and display.
quickquickbooleanfalseWhether to skip the opening animation.
selectedselectedListItemBase \| ListItemBase[] \| nullnullProxies to mwc-list's selected property.
slotElementHTMLSlotElement \| null
stayOpenOnBodyClickstayOpenOnBodyClickbooleanfalsePrevents the menu from closing when clicking outside the menu.
stylesCSSResult[]"baseStyle","styles"
wrapFocuswrapFocusbooleanfalseProxies to mwc-list's wrapFocus property.
xxnumber \| nullnullSets horizontal position when absolute. When given an anchor, sets horizontal position relative to anchor at given corner. Requires y not to be null.
yynumber \| nullnullSets vertical position when absolute. When given an anchor, sets vertical position relative to anchor at given corner. Requires x not to be null.

Methods

MethodType
click(): void
close(): void
focusItemAtIndex(index: number): void
getFocusedItemIndex(): number
layout(updateItems?: boolean \| undefined): void
select(index: MWCListIndex): void
show(): void

Events

EventType
actionActionDetail
closed
items-updated
opened
selectedSelectedDetail

CSS Custom Properties

PropertyDefaultDescription
--fds-menu-item-height"48px"Height of single-line list-items in the menu.
--fds-menu-max-height"calc(100vh - 32px)"Menu max-height.
--fds-menu-max-width"calc(100vw - 32px)"Menu max-width.
--fds-menu-min-width"112px"Menu min-width.
--fds-menu-z-index8Z-index of the popup menu surface.
1.8.1

10 months ago

1.8.0

12 months ago

1.7.0

1 year ago

1.6.0

1 year ago

1.4.2

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.2.9

1 year ago

1.2.12

1 year ago

1.2.13

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.2.14

1 year ago

1.2.15

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.42

2 years ago

0.0.44

2 years ago

1.0.3

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago