This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi.tsx
More file actions
221 lines (209 loc) · 10.6 KB
/
api.tsx
File metadata and controls
221 lines (209 loc) · 10.6 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/**
* Loading API sample
*/
import { ButtonComponent, CheckBoxComponent } from "@syncfusion/ej2-react-buttons";
import { DropDownListComponent } from "@syncfusion/ej2-react-dropdowns";
import { NumericTextBoxComponent } from "@syncfusion/ej2-react-inputs";
import { TooltipComponent } from "@syncfusion/ej2-react-popups";
import * as React from "react";
import { PropertyPane } from "../common/property-pane";
import { SampleBase } from "../common/sample-base";
import "./api.css";
export class ApiTooltip extends SampleBase<{}, {}> {
public tooltip: TooltipComponent;
public sticky: CheckBoxComponent;
public ddl: DropDownListComponent;
public height: NumericTextBoxComponent;
public width: NumericTextBoxComponent;
public text: any;
public data: string[] = ["Click", "Hover", "Auto"];
public onClick(args: any): void {
if (!args.target.classList.contains("e-control") && !args.target.classList.contains("e-btn")) {
if (this.tooltip && !this.tooltip.isSticky && document.getElementsByClassName("e-tooltip-wrap").length > 0) {
this.tooltip.close();
}
}
}
public onScroll(): void {
if (this.tooltip && document.getElementsByClassName("e-tooltip-wrap").length > 0) {
this.tooltip.close();
}
}
public created(): void {
if (document.getElementById("right-pane")) {
document.getElementById("right-pane").addEventListener("click", this.onClick.bind(this));
document.getElementById("right-pane").addEventListener("scroll", this.onScroll.bind(this));
}
}
public onModeChange(args: any) {
this.tooltip.close();
this.tooltip.opensOn = args.value;
}
public onHeightChange(args: any): void {
this.tooltip.close();
this.tooltip.height = args.value;
this.tooltip.refresh(this.tooltip.element);
}
public onWidthChange(args: any): void {
this.tooltip.close();
this.tooltip.width = args.value;
this.tooltip.refresh(this.tooltip.element);
}
public handleKeyPress(args: any): void {
this.tooltip.close();
this.tooltip.content = args.currentTarget.value;
}
public checkboxChange(args: any) {
this.tooltip.close();
this.tooltip.isSticky = args.checked;
}
render() {
return (
<div className="control-pane">
<div className="control-section">
<div className="col-lg-8 control-section">
<TooltipComponent
created={this.created.bind(this)}
id="defaultTooltip"
ref={t => (this.tooltip = t)}
opensOn="Click"
content="Tooltip content"
>
<ButtonComponent>Show Tooltip</ButtonComponent>
</TooltipComponent>
</div>
<div className="col-lg-4 property-section">
<PropertyPane title="Properties">
<table id="property" title="Properties">
<tbody>
<tr>
<td style={{ width: "50%" }}>
<div className="userselect">Content</div>
</td>
<td style={{ width: "50%", paddingRight: "10px" }}>
<div>
<input
id="value"
ref={t => (this.text = t)}
onKeyUp={this.handleKeyPress.bind(this)}
type="text"
className="e-input"
placeholder="Tooltip content"
/>
</div>
</td>
</tr>
<tr>
<td style={{ width: "50%" }}>
<div className="userselect">Height</div>
</td>
<td style={{ width: "50%", paddingRight: "10px" }}>
<div>
<NumericTextBoxComponent
id="height"
ref={t => (this.height = t)}
value={45}
change={this.onHeightChange.bind(this)}
/>
</div>
</td>
</tr>
<tr>
<td style={{ width: "50%" }}>
<div className="userselect">Width</div>
</td>
<td style={{ width: "50%", paddingRight: "10px" }}>
<div>
<NumericTextBoxComponent
id="width"
ref={t => (this.width = t)}
className="e-input"
value={100}
change={this.onWidthChange.bind(this)}
/>
</div>
</td>
</tr>
<tr>
<td style={{ width: "50%" }}>
<div className="userselect">Open Mode</div>
</td>
<td style={{ width: "50%", paddingRight: "10px" }}>
<div>
<DropDownListComponent
dataSource={this.data}
ref={t => (this.ddl = t)}
placeholder="Select mode"
change={this.onModeChange.bind(this)}
id="ddlelement"
/>
</div>
</td>
</tr>
<tr>
<td style={{ width: "50%" }}>
<div className="userselect">Sticky Mode</div>
</td>
<td style={{ width: "50%", paddingRight: "10px" }}>
<div>
<CheckBoxComponent
id="sticky"
ref={t => (this.sticky = t)}
change={this.checkboxChange.bind(this)}
/>
</div>
</td>
</tr>
</tbody>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>
This sample demonstrates how to customize the tooltip component by using its
properties from the property pane. Select any combination of properties from the
property pane to customize tooltips.
</p>
</div>
<div id="description">
<p>
In this demo, the default tooltip is rendered with minimal configuration. This sample
can be customized further with the combination of tooltip properties from the property
pane. For example,
</p>
<ul>
<li>
Any change made to a textbox in the property pane will be reflected in the tooltip
<a href="https://ej2.syncfusion.com/documentation/tooltip/api-tooltip.html#content">
content
</a>
</li>
<li>
<a href="https://ej2.syncfusion.com/documentation/tooltip/api-tooltip.html?lang=typescript#issticky">
StickyMode
</a>
can be enabled by checking the sticky mode option in the property pane.
</li>
<li>
<a href="https://ej2.syncfusion.com/documentation/tooltip/api-tooltip.html?lang=typescript#height">
Height
</a>
and
<a href="https://ej2.syncfusion.com/documentation/tooltip/api-tooltip.html?lang=typescript#width">
width
</a>
can be changed from the property pane.
</li>
<li>
<a href="https://ej2.syncfusion.com/documentation/tooltip/api-tooltip.html?lang=typescript#openson">
OpenMode
</a>
can be changed from the property pane.
</li>
</ul>
</div>
</div>
);
}
}