Class TJSMenu
Hierarchy
- SvelteComponent<TJSMenu.Props, TJSMenu.Events, TJSMenu.Slots>
- TJSMenu (View Summary)
Indexable
- [prop: string]: any
Index
Constructors
Methods
Constructors
constructor
Parameters
- options: ComponentConstructorOptions<TJSMenu.Props>
Returns TJSMenu
Methods
$destroy
Returns void
$on
Type Parameters
- K extends string
Parameters
- type: K
- callback: (e: CustomEvent<any>) => void
Returns () => void
TJSMenu provides a menu component that can be slotted into toggle components like TJSToggleIconButton and TJSToggleLabel.
TJSMenu supports a flexible data driven way to construct the menu items. Depending on the item data that is passed into the menu you can define 4 types of items: 'icon / label', 'image / label', 'class / Svelte component', and 'separator / hr'. TJSMenu also accepts a main slot allowing the entire menu contents to be replaced with a custom component as well as named slots
beforeandafterwhich place named components before or after the main menu data driven items.Exported props include:
menu(TJSMenuData.Menu): An object defining all properties of a menu including potentially data driven minimal Svelte configuration objects (slotAfter,slotBefore, andslotDefault) providing default component implementations.Or in lieu of passing the folder object you can assign these props directly:
items: An iterable list of TJSMenuData.Items; defines data driven menu items.offset: Optional X / Y offsets for the menu display.styles: Styles to be applied inline viaapplyStylesaction.efx: Currently unused; for any future action effects.keyCode: The key code to activate menu items.transitionOptions: Custom transition options for duration and easing function.Events
There is a single that is fired and bubbled up through parent elements:
close:popup- A CustomEvent fired when the menu closes allowing any parent components to update state. Thedetaildata may have two optional fields of data includingkeyboardFocus/ boolean if the close action originated from keyboard navigation and the other istarget/ HTMLElement that is the original event target for the close action.Styling
To style this component use
.tjs-menuas the base selector.There are several local CSS variables that you can use to change the appearance dynamically. Either use CSS props or pass in a
stylesobject w/ key / value props to set to the details. The default fallback variables target both TJSMenu and TJSContextMenu. The fewpopupdefaults target first level overlaid components inside an application.CSS Variables