2022-02-04 09:03:24 +00:00
|
|
|
import { IntlString } from '@anticrm/platform'
|
|
|
|
import { writable } from 'svelte/store'
|
2022-05-12 04:10:52 +00:00
|
|
|
import { AnyComponent, AnySvelteComponent, LabelAndProps, TooltipAlignment } from './types'
|
2022-02-04 09:03:24 +00:00
|
|
|
|
2022-05-12 04:10:52 +00:00
|
|
|
const emptyTooltip: LabelAndProps = {
|
2022-02-04 09:03:24 +00:00
|
|
|
label: undefined,
|
|
|
|
element: undefined,
|
|
|
|
direction: undefined,
|
|
|
|
component: undefined,
|
|
|
|
props: undefined,
|
2022-03-29 14:29:53 +00:00
|
|
|
anchor: undefined,
|
|
|
|
onUpdate: undefined
|
2022-05-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
export const tooltipstore = writable<LabelAndProps>(emptyTooltip)
|
2022-02-04 09:03:24 +00:00
|
|
|
|
|
|
|
export function showTooltip (
|
|
|
|
label: IntlString | undefined,
|
|
|
|
element: HTMLElement,
|
2022-04-14 06:07:07 +00:00
|
|
|
direction?: TooltipAlignment,
|
2022-02-04 09:03:24 +00:00
|
|
|
component?: AnySvelteComponent | AnyComponent,
|
|
|
|
props?: any,
|
2022-03-29 14:29:53 +00:00
|
|
|
anchor?: HTMLElement,
|
|
|
|
onUpdate?: (result: any) => void
|
2022-02-04 09:03:24 +00:00
|
|
|
): void {
|
|
|
|
tooltipstore.set({
|
|
|
|
label: label,
|
|
|
|
element: element,
|
|
|
|
direction: direction,
|
|
|
|
component: component,
|
|
|
|
props: props,
|
2022-03-29 14:29:53 +00:00
|
|
|
anchor: anchor,
|
|
|
|
onUpdate: onUpdate
|
2022-02-04 09:03:24 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function closeTooltip (): void {
|
2022-05-12 04:10:52 +00:00
|
|
|
tooltipstore.set(emptyTooltip)
|
2022-02-04 09:03:24 +00:00
|
|
|
}
|