-
-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathshow.tsx
More file actions
47 lines (41 loc) · 1.06 KB
/
show.tsx
File metadata and controls
47 lines (41 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import type { TriggerProps } from './index';
import Trigger from './index';
import type { Root } from 'react-dom/client';
import { createRoot } from 'react-dom/client';
export interface ShowProps extends Omit<TriggerProps, 'children'> {
point: [x: number, y: number];
}
export class TriggerShow {
public container = document.createElement('div');
public root?: Root;
public constructor() {
this.container.id = 'trigger-show-container';
document.body.append(this.container);
}
public show(props: ShowProps) {
if (this.root) {
this.root.unmount();
}
this.root = createRoot(this.container);
this.root.render(
<Trigger
popupPlacement='topLeft'
popupAlign={{
overflow: {
adjustX: 1,
adjustY: 1,
},
}}
popupClassName='point-popup'
{...props}
alignPoint
point={props.point}>
<div />
</Trigger>);
}
public hide() {
this.root?.unmount();
}
}
export const triggerShow = new TriggerShow();