x4js 2.0.11 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/lib/README.txt +15 -15
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +1 -1
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +1 -1
- package/lib/src/components/base.scss +25 -26
- package/lib/src/components/boxes/boxes.module.scss +37 -37
- package/lib/src/components/boxes/boxes.ts +129 -125
- package/lib/src/components/breadcrumb/breadcrumb.scss +28 -0
- package/lib/src/components/breadcrumb/breadcrumb.ts +84 -0
- package/lib/src/components/breadcrumb/chevron-right.svg +1 -0
- package/lib/src/components/btngroup/btngroup.module.scss +28 -28
- package/lib/src/components/btngroup/btngroup.ts +119 -101
- package/lib/src/components/button/button.module.scss +154 -153
- package/lib/src/components/button/button.ts +117 -117
- package/lib/src/components/calendar/calendar.module.scss +162 -162
- package/lib/src/components/calendar/calendar.ts +326 -325
- package/lib/src/components/checkbox/check.svg +3 -3
- package/lib/src/components/checkbox/checkbox.module.scss +141 -141
- package/lib/src/components/checkbox/checkbox.ts +125 -124
- package/lib/src/components/colorinput/colorinput.module.scss +64 -64
- package/lib/src/components/colorinput/colorinput.ts +90 -87
- package/lib/src/components/colorpicker/colorpicker.module.scss +132 -132
- package/lib/src/components/colorpicker/colorpicker.ts +481 -476
- package/lib/src/components/combobox/combobox.module.scss +123 -120
- package/lib/src/components/combobox/combobox.ts +192 -190
- package/lib/src/components/combobox/updown.svg +3 -3
- package/lib/src/components/components.ts +34 -0
- package/lib/src/components/dialog/dialog.module.scss +71 -71
- package/lib/src/components/dialog/dialog.ts +94 -92
- package/lib/src/components/form/form.module.scss +34 -34
- package/lib/src/components/form/form.ts +41 -36
- package/lib/src/components/grid/datastore.ts +1298 -0
- package/lib/src/components/grid/gridview.ts +1108 -0
- package/lib/src/components/grid/memdb.ts +325 -0
- package/lib/src/components/header/header.module.scss +39 -39
- package/lib/src/components/header/header.ts +129 -123
- package/lib/src/components/icon/icon.module.scss +29 -29
- package/lib/src/components/icon/icon.ts +136 -134
- package/lib/src/components/image/image.module.scss +20 -20
- package/lib/src/components/image/image.ts +68 -66
- package/lib/src/components/input/input.module.scss +69 -69
- package/lib/src/components/input/input.ts +275 -274
- package/lib/src/components/label/label.module.scss +58 -52
- package/lib/src/components/label/label.ts +64 -55
- package/lib/src/components/link/link.ts +78 -0
- package/lib/src/components/listbox/listbox.module.scss +103 -103
- package/lib/src/components/listbox/listbox.ts +431 -427
- package/lib/src/components/menu/menu.module.scss +107 -107
- package/lib/src/components/menu/menu.ts +171 -168
- package/lib/src/components/messages/messages.module.scss +48 -47
- package/lib/src/components/messages/messages.ts +68 -63
- package/lib/src/components/normalize.scss +386 -386
- package/lib/src/components/notification/notification.module.scss +81 -81
- package/lib/src/components/notification/notification.ts +109 -108
- package/lib/src/components/panel/panel.module.scss +47 -47
- package/lib/src/components/panel/panel.ts +57 -56
- package/lib/src/components/popup/popup.module.scss +43 -43
- package/lib/src/components/popup/popup.ts +396 -395
- package/lib/src/components/progress/progress.module.scss +56 -56
- package/lib/src/components/progress/progress.ts +43 -42
- package/lib/src/components/rating/rating.module.scss +22 -22
- package/lib/src/components/rating/rating.ts +131 -125
- package/lib/src/components/shared.scss +90 -76
- package/lib/src/components/sizers/sizer.module.scss +89 -89
- package/lib/src/components/sizers/sizer.ts +123 -119
- package/lib/src/components/slider/slider.module.scss +70 -70
- package/lib/src/components/slider/slider.ts +147 -142
- package/lib/src/components/switch/switch.module.scss +126 -126
- package/lib/src/components/switch/switch.ts +61 -55
- package/lib/src/components/tabs/tabs.module.scss +46 -46
- package/lib/src/components/tabs/tabs.ts +168 -157
- package/lib/src/components/textarea/textarea.module.scss +59 -59
- package/lib/src/components/textarea/textarea.ts +60 -54
- package/lib/src/components/textedit/textedit.module.scss +113 -113
- package/lib/src/components/textedit/textedit.ts +83 -82
- package/lib/src/components/themes.scss +81 -77
- package/lib/src/components/tooltips/tooltips.scss +50 -50
- package/lib/src/components/tooltips/tooltips.ts +103 -102
- package/lib/src/components/treeview/treeview.module.scss +115 -115
- package/lib/src/components/treeview/treeview.ts +410 -403
- package/lib/src/components/viewport/viewport.module.scss +24 -24
- package/lib/src/components/viewport/viewport.ts +41 -38
- package/lib/src/core/component.ts +1002 -979
- package/lib/src/core/core_application.ts +44 -0
- package/lib/src/core/core_colors.ts +249 -249
- package/lib/src/core/core_dom.ts +471 -471
- package/lib/src/core/core_dragdrop.ts +200 -200
- package/lib/src/core/core_element.ts +97 -97
- package/lib/src/core/core_events.ts +149 -149
- package/lib/src/core/core_i18n.ts +377 -377
- package/lib/src/core/core_router.ts +221 -221
- package/lib/src/core/core_styles.ts +214 -214
- package/lib/src/core/core_svg.ts +550 -550
- package/lib/src/core/core_tools.ts +688 -673
- package/lib/src/demo/assets/radio.svg +3 -3
- package/lib/src/demo/index.html +11 -11
- package/lib/src/demo/main.scss +21 -21
- package/lib/src/demo/main.tsx +323 -323
- package/lib/src/types/scss.d.ts +4 -4
- package/lib/src/types/x4react.d.ts +8 -8
- package/lib/src/x4.scss +18 -18
- package/lib/src/x4.ts +31 -60
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +100 -49
- package/package.json +2 -3
- package/src/x4.ts +31 -60
- package/lib/output.d.ts +0 -1472
|
@@ -1,395 +1,396 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file popup.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { Component, ComponentEvent, ComponentEvents, ComponentProps, componentFromDOM, makeUniqueComponentId } from "../../core/component"
|
|
18
|
-
import { CSizer } from '../sizers/sizer';
|
|
19
|
-
import { Rect, Point } from '../../core/core_tools.js';
|
|
20
|
-
|
|
21
|
-
import "./popup.module.scss"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface PopupEvents extends ComponentEvents {
|
|
25
|
-
closed: ComponentEvent;
|
|
26
|
-
opened: ComponentEvent;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface PopupProps extends ComponentProps {
|
|
30
|
-
modal?: boolean;
|
|
31
|
-
autoClose?: boolean | string;
|
|
32
|
-
sizable?: boolean;
|
|
33
|
-
movable?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let modal_mask: Component;
|
|
38
|
-
let modal_count = 0;
|
|
39
|
-
|
|
40
|
-
let modal_stack: Popup[] = [];
|
|
41
|
-
let autoclose_list: Popup[] = [];
|
|
42
|
-
let popup_list: Popup[] = [];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let
|
|
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
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
movers.
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
e.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
new CSizer( "
|
|
322
|
-
new CSizer( "
|
|
323
|
-
new CSizer( "
|
|
324
|
-
new CSizer( "
|
|
325
|
-
new CSizer( "
|
|
326
|
-
new CSizer( "
|
|
327
|
-
new CSizer( "
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
private
|
|
340
|
-
private
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
this.delta.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
e.
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file popup.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
import { Component, ComponentEvent, ComponentEvents, ComponentProps, componentFromDOM, makeUniqueComponentId } from "../../core/component"
|
|
18
|
+
import { CSizer } from '../sizers/sizer';
|
|
19
|
+
import { Rect, Point, class_ns } from '../../core/core_tools.js';
|
|
20
|
+
|
|
21
|
+
import "./popup.module.scss"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export interface PopupEvents extends ComponentEvents {
|
|
25
|
+
closed: ComponentEvent;
|
|
26
|
+
opened: ComponentEvent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PopupProps extends ComponentProps {
|
|
30
|
+
modal?: boolean;
|
|
31
|
+
autoClose?: boolean | string;
|
|
32
|
+
sizable?: boolean;
|
|
33
|
+
movable?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
let modal_mask: Component;
|
|
38
|
+
let modal_count = 0;
|
|
39
|
+
|
|
40
|
+
let modal_stack: Popup[] = [];
|
|
41
|
+
let autoclose_list: Popup[] = [];
|
|
42
|
+
let popup_list: Popup[] = [];
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
@class_ns( "x4" )
|
|
51
|
+
export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = PopupEvents> extends Component<P,E> {
|
|
52
|
+
|
|
53
|
+
private _isopen = false;
|
|
54
|
+
private _isshown = false;
|
|
55
|
+
|
|
56
|
+
constructor( props: P ) {
|
|
57
|
+
super( props );
|
|
58
|
+
|
|
59
|
+
if( this.props.sizable ) {
|
|
60
|
+
this._createSizers( );
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
displayNear( rc: Rect, dst = "top left", src = "top left", offset = {x:0,y:0} ) {
|
|
65
|
+
|
|
66
|
+
this.setStyle( { left: "0px", top: "0px" } ); // avoid scrollbar
|
|
67
|
+
this._show( ); // to compute size
|
|
68
|
+
|
|
69
|
+
let rm = this.getBoundingRect();
|
|
70
|
+
|
|
71
|
+
let xref = rc.left;
|
|
72
|
+
let yref = rc.top;
|
|
73
|
+
|
|
74
|
+
if( src.indexOf('right')>=0 ) {
|
|
75
|
+
xref = (rc.left+rc.width);
|
|
76
|
+
}
|
|
77
|
+
else if( src.indexOf('center')>=0 ) {
|
|
78
|
+
xref = rc.left + rc.width/2;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if( src.indexOf('bottom')>=0 ) {
|
|
82
|
+
yref = rc.bottom;
|
|
83
|
+
}
|
|
84
|
+
else if( src.indexOf('middle')>=0 ) {
|
|
85
|
+
yref = rc.top + rc.height/2;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let halign = 'l';
|
|
89
|
+
if (dst.indexOf('right') >= 0) {
|
|
90
|
+
xref -= rm.width;
|
|
91
|
+
}
|
|
92
|
+
else if( dst.indexOf('center')>=0 ) {
|
|
93
|
+
xref -= rm.width/2;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let valign = 't';
|
|
97
|
+
if (dst.indexOf('bottom') >= 0) {
|
|
98
|
+
yref -= rm.height;
|
|
99
|
+
}
|
|
100
|
+
else if( dst.indexOf('middle')>=0 ) {
|
|
101
|
+
yref -= rm.height/2;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (offset) {
|
|
105
|
+
xref += offset.x;
|
|
106
|
+
yref += offset.y;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// our parent is body, so take care of the scroll position
|
|
110
|
+
xref += document.scrollingElement.scrollLeft;
|
|
111
|
+
yref += document.scrollingElement.scrollTop;
|
|
112
|
+
|
|
113
|
+
this.displayAt( xref, yref );
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
displayCenter( ) {
|
|
121
|
+
this.displayNear( new Rect( window.innerWidth/2, window.innerHeight/2, 0, 0 ), "center middle" );
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
displayAt( x: number, y: number ) {
|
|
129
|
+
//TODO: check is already visible
|
|
130
|
+
this.setStyle( {
|
|
131
|
+
left: x+"px",
|
|
132
|
+
top: y+"px",
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
this._show( );
|
|
136
|
+
|
|
137
|
+
const rc = this.getBoundingRect( );
|
|
138
|
+
const width = window.innerWidth - 16;
|
|
139
|
+
const height = window.innerHeight - 16;
|
|
140
|
+
|
|
141
|
+
if( rc.right>width ) {
|
|
142
|
+
this.setStyleValue( "left", width-rc.width );
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if( rc.bottom>height ) {
|
|
146
|
+
this.setStyleValue( "top", height-rc.height );
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if( this.props.movable ) {
|
|
150
|
+
const movers = this.queryAll( ".caption-element" );
|
|
151
|
+
movers.forEach( m => new CMover(m,this) );
|
|
152
|
+
|
|
153
|
+
if( this.hasClass("popup-caption") ) {
|
|
154
|
+
new CMover(this,this);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this.fire( "opened", {} );
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private _show( ) {
|
|
162
|
+
|
|
163
|
+
if( this.props.modal && !this._isshown ) {
|
|
164
|
+
this._showModalMask( );
|
|
165
|
+
modal_stack.push( this );
|
|
166
|
+
modal_count++;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this._isshown = true;
|
|
170
|
+
|
|
171
|
+
if( this.props.autoClose ) {
|
|
172
|
+
if( autoclose_list.length==0 ) {
|
|
173
|
+
document.addEventListener( "pointerdown", this._dismiss );
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
autoclose_list.push( this );
|
|
177
|
+
this.setData( "close", this.props.autoClose===true ? makeUniqueComponentId() : this.props.autoClose );
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
popup_list.push( this );
|
|
181
|
+
document.body.appendChild( this.dom );
|
|
182
|
+
|
|
183
|
+
this.show( );
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
override show( show = true ) {
|
|
187
|
+
this._isopen = show;
|
|
188
|
+
super.show( show );
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
isOpen( ) {
|
|
192
|
+
return this._isopen;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
close( ) {
|
|
200
|
+
document.body.removeChild( this.dom );
|
|
201
|
+
|
|
202
|
+
// remove from popup list
|
|
203
|
+
const idx = popup_list.indexOf( this );
|
|
204
|
+
console.assert( idx>=0 );
|
|
205
|
+
popup_list.splice( idx, 1 );
|
|
206
|
+
|
|
207
|
+
// remove from auto close list
|
|
208
|
+
if( this.props.autoClose ) {
|
|
209
|
+
const idx = autoclose_list.indexOf( this );
|
|
210
|
+
if( idx>=0 ) {
|
|
211
|
+
autoclose_list.splice( idx, 1 );
|
|
212
|
+
if( autoclose_list.length==0 ) {
|
|
213
|
+
document.removeEventListener( "pointerdown", this._dismiss );
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// update mask
|
|
219
|
+
if( this.props.modal ) {
|
|
220
|
+
const top = modal_stack.pop( );
|
|
221
|
+
console.assert( top==this );
|
|
222
|
+
this._updateModalMask( );
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
this._isshown = false;
|
|
226
|
+
this.fire( "closed", {} );
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* binded
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
private _dismiss = ( e: UIEvent ) => {
|
|
234
|
+
const onac = autoclose_list.some( x=> x.dom.contains(e.target as Node) )
|
|
235
|
+
if( onac ) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
e.preventDefault( );
|
|
240
|
+
e.stopPropagation( );
|
|
241
|
+
|
|
242
|
+
this.dismiss( );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* dismiss all popup belonging to the same group as 'this'
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
dismiss( after = false ) {
|
|
250
|
+
|
|
251
|
+
if( autoclose_list.length==0 ) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const cgroup = this.getData( "close" );
|
|
256
|
+
const inc_group: Popup[] = [];
|
|
257
|
+
const excl_group: Popup[] = [];
|
|
258
|
+
|
|
259
|
+
let aidx = -1;
|
|
260
|
+
if( after ) {
|
|
261
|
+
aidx = autoclose_list.indexOf( this );
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
autoclose_list.forEach( (x,idx) => {
|
|
265
|
+
const group = x.getData( "close" );
|
|
266
|
+
if( group==cgroup && idx>aidx) {
|
|
267
|
+
inc_group.push( x );
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
excl_group.push( x );
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
const list = inc_group.reverse( );
|
|
275
|
+
autoclose_list = excl_group;
|
|
276
|
+
if( autoclose_list.length==0 ) {
|
|
277
|
+
document.removeEventListener( "pointerdown", this._dismiss );
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
list.forEach( x => x.close() );
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
*
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
private _showModalMask( ) {
|
|
288
|
+
|
|
289
|
+
if( !modal_mask ) {
|
|
290
|
+
modal_mask = new Component( {
|
|
291
|
+
cls: "x4modal-mask",
|
|
292
|
+
domEvents: {
|
|
293
|
+
click: this._dismiss
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
modal_mask.show( true );
|
|
299
|
+
document.body.insertAdjacentElement( "beforeend", modal_mask.dom );
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
private _updateModalMask( ) {
|
|
307
|
+
if( --modal_count == 0 ) {
|
|
308
|
+
modal_mask.show( false );
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.dom.insertAdjacentElement( "beforebegin", modal_mask.dom );
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
private _createSizers( ) {
|
|
320
|
+
this.appendContent( [
|
|
321
|
+
new CSizer( "top" ),
|
|
322
|
+
new CSizer( "bottom" ),
|
|
323
|
+
new CSizer( "left" ),
|
|
324
|
+
new CSizer( "right" ),
|
|
325
|
+
new CSizer( "top-left" ),
|
|
326
|
+
new CSizer( "bottom-left" ),
|
|
327
|
+
new CSizer( "top-right" ),
|
|
328
|
+
new CSizer( "bottom-right" ),
|
|
329
|
+
])
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
*
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
class CMover {
|
|
339
|
+
private ref: Component;
|
|
340
|
+
private delta: Point;
|
|
341
|
+
private self: boolean;
|
|
342
|
+
|
|
343
|
+
constructor( x: Component, ref?: Component ) {
|
|
344
|
+
|
|
345
|
+
this.self = ref ? true : false;
|
|
346
|
+
|
|
347
|
+
x.addDOMEvent( "pointerdown", ( e: PointerEvent ) => {
|
|
348
|
+
if( this.self && e.target!=x.dom ) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
x.setCapture( e.pointerId );
|
|
353
|
+
|
|
354
|
+
this.ref = ref ?? componentFromDOM( x.dom.parentElement );
|
|
355
|
+
|
|
356
|
+
this.delta = {x:0,y:0};
|
|
357
|
+
const rc = this.ref.getBoundingRect();
|
|
358
|
+
|
|
359
|
+
this.delta.x = e.pageX-rc.left;
|
|
360
|
+
this.delta.y = e.pageY-rc.top;
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
x.addDOMEvent( "pointerup", ( e: PointerEvent ) => {
|
|
364
|
+
x.releaseCapture( e.pointerId );
|
|
365
|
+
this.ref = null;
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
x.addDOMEvent( "pointermove", ( e: PointerEvent ) => {
|
|
369
|
+
this._onMouseMove( e );
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private _onMouseMove( e: PointerEvent ) {
|
|
374
|
+
if( !this.ref ) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const pt = { x: e.pageX-this.delta.x, y: e.pageY-this.delta.y };
|
|
379
|
+
const rc = this.ref.getBoundingRect( );
|
|
380
|
+
|
|
381
|
+
let nr: any = {
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
this.ref.setStyle( {
|
|
385
|
+
top: pt.y+"",
|
|
386
|
+
left: pt.x+"",
|
|
387
|
+
} );
|
|
388
|
+
|
|
389
|
+
e.preventDefault( );
|
|
390
|
+
e.stopPropagation( );
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|