contextmenu_state.svelte.ts

Declarations
#

16 declarations

view source

contextmenu_attachment
#

contextmenu_state.svelte.ts view source

<T extends ContextmenuParams, U extends T | Array<T>>(params: U | null | undefined): Attachment<HTMLElement | SVGElement>

Creates an attachment that sets up contextmenu behavior on an element.

params

Contextmenu parameters or nullish to disable

type U | null | undefined

returns

Attachment<HTMLElement | SVGElement>

contextmenu_check_global_root
#

contextmenu_state.svelte.ts view source

(get_scoped: () => boolean): void

Registers a contextmenu root and warns if multiple non-scoped roots are detected. Only active in development mode. Automatically handles cleanup on unmount.

get_scoped

Getter function that returns the current scoped value

type () => boolean

returns

void

contextmenu_context
#

contextmenu_state.svelte.ts view source

{ get: (error_message?: string | undefined) => ContextmenuState; get_maybe: () => ContextmenuState | undefined; set: (value: ContextmenuState) => ContextmenuState; }

contextmenu_dimensions_context
#

contextmenu_open
#

contextmenu_state.svelte.ts view source

(target: HTMLElement | SVGElement, x: number, y: number, contextmenu: ContextmenuState, options?: ContextmenuOpenOptions | undefined): boolean

Opens the contextmenu, if appropriate, querying the menu items from the DOM starting at the event target.

target

the leaf element from which to open the contextmenu

type HTMLElement | SVGElement

x

the page X coordinate at which to open the contextmenu, typically the mouse pageX

type number

y

the page Y coordinate at which to open the contextmenu, typically the mouse pageY

type number

contextmenu

the contextmenu store

options?

optional configuration for filtering entries and haptic feedback

type ContextmenuOpenOptions | undefined
optional

returns

boolean

a boolean indicating if the menu was opened or not

contextmenu_submenu_context
#

contextmenu_state.svelte.ts view source

{ get: (error_message?: string | undefined) => SubmenuState; get_maybe: () => SubmenuState | undefined; set: (value: SubmenuState) => SubmenuState; }

ContextmenuActivateResult
#

ContextmenuOpenOptions
#

ContextmenuParams
#

ContextmenuRun
#

ContextmenuState
#

contextmenu_state.svelte.ts view source

Creates a contextmenu store. See usage with ContextmenuRoot.svelte and Contextmenu.svelte.

see also

layout

type Dimensions

has_custom_layout

If an initial layout is provided, control is deferred externally. Otherwise the layout syncs to the page dimensions.

type boolean

readonly

opened

type boolean

x

type number

y

type number

params

type ReadonlyArray<ContextmenuParams>

error

type string | undefined

root_menu

type RootMenuState

readonly

selections

type ReadonlyArray<ItemState>

can_collapse

can_expand

can_select_next

can_select_previous

can_activate

constructor

type new (options?: ContextmenuStateOptions): ContextmenuState

options
default EMPTY_OBJECT

open

type (params: ContextmenuParams[], x: number, y: number): void

params
type ContextmenuParams[]
x
type number
y
type number
returns void

close

type (): void

returns void

reset_items

type (items: readonly ItemState[]): void

items
type readonly ItemState[]
returns void

activate

type (item: ItemState): boolean | Promise<ContextmenuActivateResult>

item
returns boolean | Promise<ContextmenuActivateResult>

activate_selected

type (): boolean | void | Promise<ContextmenuActivateResult>

returns boolean | void | Promise<ContextmenuActivateResult>

select

Activates the selected entry, or if none, selects the first.

type (item: ItemState): void

item
returns void

collapse_selected

type (): void

returns void

expand_selected

type (): void

returns void

select_next

type (): void

returns void

select_previous

type (): void

returns void

select_first

type (): void

returns void

select_last

type (): void

returns void

add_entry

Used by ContextmenuEntry and custom entry components

type (run: () => ContextmenuRun, disabled?: () => boolean): EntryState

run
type () => ContextmenuRun
disabled
type () => boolean
default () => false
returns EntryState

add_submenu

type (): SubmenuState

returns SubmenuState

ContextmenuStateOptions
#

EntryState
#

contextmenu_state.svelte.ts view source

is_menu

readonly

menu

type SubmenuState | RootMenuState

readonly

run

type () => ContextmenuRun

readonly

disabled

type () => boolean

readonly

selected

type boolean

pending

type boolean

error_message

type string | null

promise

type Promise<ContextmenuActivateResult> | null

constructor

type new (menu: SubmenuState | RootMenuState, run: () => ContextmenuRun, disabled?: () => boolean): EntryState

menu
type SubmenuState | RootMenuState
run
type () => ContextmenuRun
disabled
type () => boolean
default () => false

ItemState
#

RootMenuState
#

SubmenuState
#

Depends on
#

Imported by
#