Class TJSMenu
Index
Constructors
Methods
Constructors
constructor
- new TJSMenu(options): TJSMenu
Parameters
- options: ComponentConstructorOptions<TJSMenu.Props>
Returns TJSMenu
Methods
$destroy
$on
- $on<K>(type, callback): (() => void)
Type Parameters
Parameters
- type: K
- callback: ((e: CustomEvent<any>) => void)
- (e): void
Parameters
- e: CustomEvent<any>
Returns void
Returns (() => void)
- (): 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
before
andafter
which place named components before or after the main menu data driven items.Exported props include:
menu
(TJSMenuData): 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 TJSMenuItemData; defines data driven menu items.offset
: Optional X / Y offsets for the menu display.styles
: Styles to be applied inline viaapplyStyles
action.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. Thedetail
data 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-menu
as 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
styles
object w/ key / value props to set to the details. The default fallback variables target both TJSMenu and TJSContextMenu. The fewpopup
defaults target first level overlaid components inside an application.CSS Variables