x4js 1.5.16 → 1.5.17

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.
Files changed (75) hide show
  1. package/lib/cjs/app_sockets.js +74 -0
  2. package/lib/cjs/index.js +1 -0
  3. package/lib/cjs/treeview.js +27 -12
  4. package/lib/cjs/version.js +1 -1
  5. package/lib/esm/app_sockets.js +70 -0
  6. package/lib/esm/index.mjs +1 -0
  7. package/lib/esm/treeview.js +26 -12
  8. package/lib/esm/version.js +1 -1
  9. package/lib/{src/version.ts → types/app_sockets.d.ts} +29 -30
  10. package/lib/types/index.d.ts +1 -0
  11. package/lib/types/treeview.d.ts +5 -2
  12. package/lib/types/version.d.ts +1 -1
  13. package/package.json +1 -1
  14. package/lib/src/MIT-license.md +0 -14
  15. package/lib/src/action.ts +0 -88
  16. package/lib/src/alpha.jpg +0 -0
  17. package/lib/src/application.ts +0 -251
  18. package/lib/src/autocomplete.ts +0 -197
  19. package/lib/src/base64.ts +0 -166
  20. package/lib/src/base_component.ts +0 -152
  21. package/lib/src/button.ts +0 -355
  22. package/lib/src/calendar.ts +0 -328
  23. package/lib/src/canvas.ts +0 -505
  24. package/lib/src/cardview.ts +0 -227
  25. package/lib/src/checkbox.ts +0 -188
  26. package/lib/src/color.ts +0 -752
  27. package/lib/src/colorpicker.ts +0 -1639
  28. package/lib/src/combobox.ts +0 -465
  29. package/lib/src/component.ts +0 -2329
  30. package/lib/src/datastore.ts +0 -1322
  31. package/lib/src/dialog.ts +0 -656
  32. package/lib/src/dom_events.ts +0 -315
  33. package/lib/src/drag_manager.ts +0 -199
  34. package/lib/src/drawtext.ts +0 -355
  35. package/lib/src/fileupload.ts +0 -213
  36. package/lib/src/form.ts +0 -375
  37. package/lib/src/formatters.ts +0 -105
  38. package/lib/src/gridview.ts +0 -1185
  39. package/lib/src/i18n.ts +0 -346
  40. package/lib/src/icon.ts +0 -335
  41. package/lib/src/image.ts +0 -204
  42. package/lib/src/index.ts +0 -88
  43. package/lib/src/input.ts +0 -249
  44. package/lib/src/label.ts +0 -128
  45. package/lib/src/layout.ts +0 -430
  46. package/lib/src/link.ts +0 -86
  47. package/lib/src/listview.ts +0 -765
  48. package/lib/src/md5.ts +0 -438
  49. package/lib/src/menu.ts +0 -425
  50. package/lib/src/messagebox.ts +0 -224
  51. package/lib/src/panel.ts +0 -86
  52. package/lib/src/popup.ts +0 -494
  53. package/lib/src/property_editor.ts +0 -337
  54. package/lib/src/radiobtn.ts +0 -197
  55. package/lib/src/rating.ts +0 -135
  56. package/lib/src/request.ts +0 -300
  57. package/lib/src/router.ts +0 -185
  58. package/lib/src/settings.ts +0 -77
  59. package/lib/src/sidebarview.ts +0 -103
  60. package/lib/src/spreadsheet.ts +0 -1449
  61. package/lib/src/styles.ts +0 -343
  62. package/lib/src/svgcomponent.ts +0 -577
  63. package/lib/src/tabbar.ts +0 -151
  64. package/lib/src/tabview.ts +0 -110
  65. package/lib/src/textarea.ts +0 -235
  66. package/lib/src/textedit.ts +0 -544
  67. package/lib/src/toaster.ts +0 -80
  68. package/lib/src/tools.ts +0 -1473
  69. package/lib/src/tooltips.ts +0 -191
  70. package/lib/src/treeview.ts +0 -696
  71. package/lib/src/x4.less +0 -2243
  72. package/lib/src/x4dom.ts +0 -57
  73. package/lib/src/x4events.ts +0 -585
  74. package/lib/src/x4react.ts +0 -90
  75. package/lib/x4.css +0 -1780
@@ -1,765 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \_/ / / _
4
- * \ / /_| |_
5
- * / _ \____ _|
6
- * /__/ \__\ |_|
7
- *
8
- * @file listview.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
-
30
- import { x4document } from './x4dom'
31
-
32
- import { Container, Component, ContainerProps, ContainerEventMap, EvDblClick } from './component'
33
- import { IconID } from './icon';
34
- import { HLayout, VLayout } from './layout'
35
- import { Popup, PopupEventMap, PopupProps } from './popup';
36
- import { HtmlString, isFunction } from './tools';
37
- import { Menu, MenuItem } from "./menu";
38
-
39
- import { EvContextMenu, EvSelectionChange, EvClick, EventCallback, BasicEvent, EvChange } from "./x4events";
40
-
41
- /**
42
- * item definition
43
- */
44
-
45
- export interface ListViewItem {
46
- id: any;
47
- text?: string | HtmlString; // if you need pure text
48
- html?: boolean; // if text is html
49
- icon?: IconID;
50
- data?: any;
51
- };
52
-
53
- /**
54
- * callback to render item
55
- */
56
-
57
- export interface RenderListItem {
58
- (item: ListViewItem): any;
59
- }
60
-
61
- /**
62
- * callback to fill the list
63
- */
64
- export interface PopulateItems {
65
- ( filter: string ): ListViewItem[];
66
- }
67
-
68
- /**
69
- * listview can generate these events
70
- */
71
-
72
- export interface ListViewEventMap extends ContainerEventMap {
73
- click?: EvClick;
74
- dblClick?: EvDblClick;
75
- contextMenu?: EvContextMenu;
76
- selectionChange?: EvSelectionChange;
77
- cancel?: EvCancel;
78
- }
79
-
80
-
81
- /**
82
- * listview properties
83
- */
84
- export interface ListViewProps<E extends ListViewEventMap = ListViewEventMap> extends ContainerProps<E> {
85
- items?: ListViewItem[];
86
- populate?: PopulateItems;
87
- gadgets?: Component[]; // gadgets to instert at bottom
88
-
89
- virtual?: boolean; // if true, items will be rendered on demand
90
- itemHeight?: number; // in case of a virtual list, item height
91
-
92
- renderItem?: RenderListItem;
93
-
94
- click?: EventCallback<EvClick>; // shortcut to events: { click: ... }
95
- dblClick?: EventCallback<EvDblClick>;// shortcut to events: { dblClick: ... }
96
- contextMenu?: EventCallback<EvContextMenu>;// shortcut to events: { contentMenu: ... }
97
- selectionChange?: EventCallback<EvSelectionChange>;// shortcut to events: { selectionChange: ... }
98
- cancel?: EventCallback<EvCancel>; // shortcut to events: { cancel: ... }
99
- }
100
-
101
- /**
102
- * Standard listview class
103
- */
104
-
105
- export class ListView extends VLayout<ListViewProps,ListViewEventMap> {
106
-
107
- protected m_selection: {
108
- item: ListViewItem;
109
- citem: Component;
110
- }
111
-
112
- protected m_defer_sel: any;
113
-
114
- protected m_container: Container;
115
- protected m_view: Container;
116
-
117
- protected m_topIndex: number;
118
- protected m_itemHeight: number;
119
-
120
- protected m_cache: Map<number, Component>; // recycling elements
121
-
122
- constructor(props: ListViewProps) {
123
- super(props);
124
-
125
- this.setDomEvent('keydown', (e) => this.handleKey(e));
126
- this.setDomEvent('click', (e) => this._handleClick(e));
127
- this.setDomEvent('dblclick', (e) => this._handleClick(e));
128
- this.setDomEvent('contextmenu', (e) => this._handleCtxMenu(e));
129
-
130
- this._setTabIndex(props.tabIndex, 0);
131
- this.mapPropEvents(props, 'click', 'dblClick', 'contextMenu', 'selectionChange', 'cancel' );
132
- }
133
-
134
- componentCreated() {
135
-
136
- if (this.m_props.virtual) {
137
- this._buildItems();
138
- }
139
- else if( this.m_props.populate ) {
140
- this.items = this.m_props.populate( null );
141
- }
142
- }
143
-
144
- render(props: ListViewProps) {
145
-
146
- props.items = props.items || [];
147
- props.gadgets = props.gadgets;
148
- props.renderItem = props.renderItem;
149
- props.virtual = props.virtual ?? false;
150
-
151
- this.m_topIndex = 0;
152
-
153
- if (props.virtual) {
154
- console.assert(props.itemHeight !== undefined);
155
- this.m_itemHeight = props.itemHeight;
156
- this.m_cache = new Map<number, Component>();
157
- this.addClass('virtual');
158
- }
159
- else {
160
- this.m_itemHeight = undefined;
161
- this.m_cache = undefined;
162
- }
163
-
164
- this._buildContent();
165
- }
166
-
167
- /**
168
- * change the list of item displayed
169
- * @param items - new array of items
170
- * @deprecated
171
- */
172
-
173
- public set items(items: ListViewItem[]) {
174
- this.setItems( items );
175
- }
176
-
177
- public get items( ) {
178
- return this.m_props.items;
179
- }
180
-
181
- /**
182
- * change the list of item displayed
183
- * @param items - new array of items
184
- */
185
-
186
- public setItems( items: ListViewItem[], keepSel = true ) {
187
- this.m_props.items = items;
188
-
189
- if( !keepSel ) {
190
- this.m_selection = null;
191
- }
192
-
193
- if( !this.m_container ) {
194
- this._buildContent( );
195
- }
196
- else {
197
- this._buildItems( );
198
- }
199
- }
200
-
201
- public handleKey(ev: KeyboardEvent) {
202
-
203
- let moveSel = (sens) => {
204
-
205
- let items: ListViewItem[];
206
- if (isFunction(this.m_props.items)) {
207
- items = this.m_props.items();
208
- this.m_props.items = items;
209
- }
210
- else {
211
- items = this.m_props.items;
212
- }
213
-
214
- let newsel: ListViewItem;
215
- if (!this.m_selection) {
216
- if (items) {
217
- newsel = items[0];
218
- }
219
- }
220
- else {
221
- let index = items.findIndex((item) => item === this.m_selection.item);
222
- if (sens > 0 && index < (items.length - 1)) {
223
- newsel = items[index + 1];
224
- }
225
- else if (sens < 0 && index > 0) {
226
- newsel = items[index - 1];
227
- }
228
- else {
229
- newsel = this.selection
230
- }
231
- }
232
-
233
- let citem = this._findItemWithId(newsel?.id);
234
- this._selectItem(newsel, citem, true);
235
- }
236
-
237
- switch (ev.key) {
238
- case 'ArrowDown': {
239
- moveSel(1);
240
- ev.preventDefault( );
241
- ev.stopPropagation();
242
- break;
243
- }
244
-
245
- case 'ArrowUp': {
246
- moveSel(-1);
247
- ev.preventDefault( );
248
- ev.stopPropagation();
249
- break;
250
- }
251
- }
252
- }
253
-
254
- /** @ignore */
255
- private _buildContent() {
256
-
257
- let props = this.m_props;
258
-
259
- if (props.virtual) {
260
- this.m_container = new Container({
261
- cls: '@scroll-container',
262
- content: []
263
- });
264
-
265
- this.m_view = new Container({
266
- cls: '@scroll-view',
267
- flex: 1,
268
- content: this.m_container,
269
- dom_events: {
270
- sizechange: () => this._updateScroll(true),
271
- scroll: () => this._updateScroll(false),
272
- }
273
- });
274
-
275
- this.setContent(
276
- [
277
- this.m_view,
278
- props.gadgets ? new HLayout({
279
- cls: 'gadgets',
280
- content: props.gadgets
281
- }) : null,
282
- ]
283
- );
284
- }
285
- else {
286
- this.m_view = undefined;
287
- this.m_container = new VLayout({
288
- cls: '@scroll-container',
289
- content: []
290
- });
291
-
292
- this.addClass('@scroll-view');
293
- this.setContent(this.m_container, false);
294
- }
295
-
296
- if (props.virtual) {
297
- this.m_container.setStyleValue('height', props.items.length * this.m_itemHeight);
298
- }
299
-
300
- if (this.dom || !props.virtual ) {
301
- this._buildItems();
302
- }
303
- }
304
-
305
- /**
306
- *
307
- */
308
-
309
- private _updateScroll(forceUpdate: boolean) {
310
-
311
- const update = () => {
312
- let newTop = Math.floor(this.m_view.dom.scrollTop / this.m_itemHeight);
313
-
314
- if (newTop != this.m_topIndex || forceUpdate) {
315
- this.m_topIndex = newTop;
316
- this._buildItems();
317
- }
318
- }
319
-
320
- if (forceUpdate) {
321
- this.startTimer('scroll', 10, false, update);
322
- }
323
- else {
324
- update();
325
- }
326
- }
327
-
328
- private async _buildItems() {
329
- let props = this.m_props;
330
- let items: Component[] = [];
331
-
332
- let list_items = props.items;
333
- if (isFunction(list_items)) {
334
- list_items = list_items();
335
- }
336
-
337
- let selId = this.m_selection?.item.id;
338
- let selFnd = false;
339
-
340
- if (props.virtual) {
341
- let rc = this.getBoundingRect();
342
- let limit = 100;
343
-
344
- let y = 0;
345
- let top = this.m_topIndex * this.m_itemHeight;
346
- let index = this.m_topIndex;
347
- let height = rc.height;
348
- let count = props.items.length;
349
-
350
- let newels = [];
351
-
352
- let cache = this.m_cache;
353
- this.m_cache = new Map<number, Component>();
354
-
355
- while (y < height && index < count && --limit > 0) {
356
-
357
- let it = props.items[index];
358
- let itm: Component;
359
-
360
- if (cache.has(it.id)) {
361
- itm = cache.get(it.id); // reuse it
362
- cache.delete(it.id); // cache will contain only elements to remove
363
- }
364
- else {
365
- itm = this._renderItem(it);
366
- newels.push(itm);
367
- }
368
-
369
- if (selId == it.id) {
370
- itm.addClass('@selected');
371
- selFnd = true;
372
- }
373
-
374
- itm.setStyleValue('top', top + y);
375
- items.push(itm);
376
-
377
- this.m_cache.set(it.id, itm); // keep it for next time
378
-
379
- y += this.m_itemHeight;
380
- index++;
381
- }
382
-
383
- // all element remaining here are to remove
384
- cache.forEach((c) => {
385
- c.dispose();
386
- });
387
-
388
- // append new elements
389
- this.m_container.appendChild(newels);
390
- this.m_container.setStyleValue( 'height', count*this.m_itemHeight );
391
-
392
- // check that it's still existing
393
- if( !selFnd ) {
394
- if( !list_items.some( it => selId == it.id ) ) {
395
- this.m_selection = null;
396
- }
397
- }
398
-
399
- }
400
- else {
401
- list_items.forEach((it) => {
402
- let itm = this._renderItem(it);
403
- if (selId == it.id) {
404
- itm.addClass('@selected');
405
- selFnd = true;
406
- }
407
-
408
- items.push(itm);
409
- });
410
-
411
- this.m_container.setContent(items, false);
412
-
413
- if( !selFnd ) {
414
- this.m_selection = null;
415
- }
416
- }
417
-
418
- if (this.m_defer_sel) {
419
- let t = this.m_defer_sel;
420
- this.m_defer_sel = undefined;
421
- this.selection = t;
422
- }
423
- }
424
-
425
- /** @ignore
426
- * default rendering of an item
427
- */
428
-
429
- private _renderItem(item: ListViewItem): Component {
430
-
431
- const newItem = this.onRenderItem( item );
432
-
433
- newItem.setAttribute( 'data-id', item.id );
434
- newItem.addClass('@list-item');
435
- newItem.setData('item-id', item.id);
436
-
437
- return newItem;
438
- }
439
-
440
- onRenderItem( item: ListViewItem): Component {
441
- if (this.m_props.renderItem) {
442
- return this.m_props.renderItem(item);
443
- }
444
- else {
445
- return new HLayout({ content: item.text });
446
- }
447
- }
448
-
449
- /** @ignore */
450
- private _handleClick(e: MouseEvent) {
451
-
452
- e.stopImmediatePropagation();
453
- e.preventDefault( );
454
-
455
- let dom = e.target as HTMLElement,
456
- self = this.dom,
457
- list_items = this.m_props.items as ListViewItem[]; // already created by build
458
-
459
- // go up until we find something interesting
460
- while (dom && dom != self) {
461
- let itm = Component.getElement(dom),
462
- id = itm?.getData('item-id');
463
-
464
- if (id!==undefined) {
465
- // find the element
466
- let item = list_items.find((item) => item.id == id);
467
- if (item) {
468
- let event: BasicEvent;
469
- if (e.type == 'click') {
470
- event = EvClick(item);
471
- this.emit('click', event);
472
- }
473
- else {
474
- event = EvDblClick(item);
475
- this.emit('dblClick', event);
476
- }
477
-
478
- if (!event.defaultPrevented) {
479
- this._selectItem(item, itm);
480
- }
481
- }
482
- else {
483
- this._selectItem(null, null);
484
- }
485
-
486
- return;
487
- }
488
-
489
- dom = dom.parentElement;
490
- }
491
-
492
- this._selectItem(null, null);
493
- }
494
-
495
- /** @ignore */
496
- private _handleCtxMenu(e: MouseEvent) {
497
-
498
- e.preventDefault();
499
-
500
- let dom = e.target as HTMLElement,
501
- self = this.dom,
502
- list_items = this.m_props.items as ListViewItem[]; // already created by build;
503
-
504
- while (dom && dom != self) {
505
- let itm = Component.getElement(dom),
506
- id = itm?.getData('item-id');
507
-
508
- if (id) {
509
-
510
- // find the element
511
- let item = list_items.find((item) => item.id == id);
512
- if (item) {
513
- this._selectItem(item, itm);
514
- this.emit('contextMenu', EvContextMenu(e, item));
515
- }
516
-
517
- return;
518
- }
519
-
520
- dom = dom.parentElement;
521
- }
522
-
523
- this.emit('contextMenu', EvContextMenu(e, null));
524
- }
525
-
526
- /**
527
- * @ignore
528
- * called when an item is selected by mouse
529
- */
530
-
531
- protected _selectItem(item: ListViewItem, citem: Component, notify = true) {
532
-
533
- if (this.m_selection && this.m_selection.citem) {
534
- this.m_selection.citem.removeClass('@selected');
535
- }
536
-
537
- this.m_selection = item ? {
538
- item: item,
539
- citem: citem
540
- } : null;
541
-
542
- if (this.m_selection && this.m_selection.citem) {
543
- this.m_selection.citem.addClass('@selected');
544
- }
545
-
546
- if (notify) {
547
- this.emit('selectionChange', EvSelectionChange(item));
548
- }
549
- }
550
-
551
- /**
552
- * return the current selection or null
553
- */
554
-
555
- public get selection() {
556
- return this.m_selection ? this.m_selection.item : null;
557
- }
558
-
559
- public set selection(id: any) {
560
- if (id === null || id === undefined) {
561
- this._selectItem(null, null);
562
- }
563
- else {
564
- if (isFunction(this.m_props.items)) {
565
- this.m_defer_sel = id;
566
- }
567
- else {
568
- let item = this.m_props.items.find((item) => item.id == id);
569
- let citem = this._findItemWithId(item.id);
570
- this._selectItem(item, citem, false);
571
- }
572
- }
573
- }
574
-
575
- private _findItemWithId(id: any) {
576
- let citem: Component = null;
577
-
578
- if (this.dom) {
579
- // make the element visible to user
580
- // todo: problem with virtual listview
581
- this.m_container.enumChilds((c: Component) => {
582
- if (c.getData('item-id') == id) {
583
- c.scrollIntoView();
584
- citem = c;
585
- return true;
586
- }
587
- })
588
- }
589
-
590
- return citem;
591
- }
592
-
593
- /**
594
- * append or prepend a new item
595
- * @param item
596
- * @param prepend
597
- * @param select
598
- */
599
-
600
- appendItem( item: ListViewItem, prepend = false, select = true ) {
601
-
602
- if( prepend ) {
603
- this.m_props.items.unshift( item );
604
- }
605
- else {
606
- this.m_props.items.push( item );
607
- }
608
-
609
- if( select ) {
610
- this.selection = null;
611
- }
612
-
613
- if( !this.m_container ) {
614
- this._buildContent();
615
- }
616
- else {
617
- this._buildItems();
618
- }
619
-
620
- if( select ) {
621
- this.selection = item.id;
622
- }
623
- }
624
-
625
- /**
626
- * update an item
627
- */
628
-
629
- updateItem( id: any, item: ListViewItem ) {
630
-
631
- // find item
632
- const idx = this.m_props.items.findIndex( itm => itm.id === id );
633
- if( idx<0 ) {
634
- return;
635
- }
636
-
637
- // take care of selection
638
- let was_sel = false;
639
- if( this.m_selection && this.m_selection.item===this.m_props.items[idx] ) {
640
- was_sel = true;
641
- }
642
-
643
- // replace it in the list
644
- this.m_props.items[idx] = item;
645
-
646
- // rebuild & replace it's line
647
- const oldDOM = this.queryItem( `[data-id="${item.id}"]` )?.dom;
648
- if( oldDOM ) {
649
- const _new = this._renderItem( item );
650
-
651
- if( was_sel ) {
652
- _new.addClass( '@selected' );
653
- this.m_selection.citem = _new;
654
- this.m_selection.item = item;
655
- }
656
-
657
- const newDOM = _new._build( );
658
- this.m_container.dom.replaceChild( newDOM, oldDOM );
659
- }
660
- }
661
-
662
-
663
- }
664
-
665
-
666
-
667
- /**
668
- * Cancel Event
669
- */
670
-
671
- export interface EvCancel extends BasicEvent {
672
- }
673
-
674
- export function EvCancel( context = null ) {
675
- return BasicEvent<EvCancel>({ context });
676
- }
677
-
678
- interface PopupListViewEventMap extends PopupEventMap {
679
- cancel: EvCancel;
680
- }
681
-
682
- interface PopupListViewProps extends PopupProps<PopupListViewEventMap> {
683
-
684
- }
685
-
686
-
687
- /**
688
- *
689
- */
690
-
691
- export class PopupListView extends Popup<PopupListViewProps,PopupListViewEventMap> {
692
-
693
- m_list: ListView;
694
-
695
- constructor(props: ListViewProps) {
696
- super({ tabIndex: false });
697
-
698
- this.enableMask(false);
699
- this.addClass( "@non-maskable" );
700
-
701
- props.tabIndex = false;
702
- this.m_list = new ListView(props);
703
- //this.m_list.addClass( '@fit' );
704
-
705
- this.setContent(this.m_list);
706
- this.mapPropEvents( props, 'cancel' );
707
- }
708
-
709
- set items( items: ListViewItem[] ) {
710
- this.m_list.items = items;
711
- }
712
-
713
- public handleKey( ev: KeyboardEvent ) {
714
- this.m_list.handleKey( ev );
715
- }
716
-
717
-
718
- // todo: move into popup
719
- private _handleClick = (e: MouseEvent) => {
720
- if (!this.dom) {
721
- return;
722
- }
723
-
724
- let newfocus = <HTMLElement>e.target;
725
-
726
- // child of this: ok
727
- if (this.dom.contains(newfocus)) {
728
- return;
729
- }
730
-
731
- // menu: ok
732
- let dest = Component.getElement(newfocus, MenuItem);
733
- if (dest) {
734
- return;
735
- }
736
-
737
- this.signal( 'cancel', EvCancel() );
738
- this.close();
739
- }
740
-
741
- // todo: move into popup
742
- show(modal?: boolean) {
743
- x4document.addEventListener('mousedown', this._handleClick);
744
- super.show(modal);
745
- }
746
-
747
- hide( ) {
748
- x4document.removeEventListener('mousedown', this._handleClick);
749
- super.hide( );
750
- }
751
-
752
- // todo: move into popup
753
- close() {
754
- x4document.removeEventListener('mousedown', this._handleClick);
755
- super.close();
756
- }
757
-
758
- get selection(): any {
759
- return this.m_list.selection;
760
- }
761
-
762
- set selection(itemId: any) {
763
- this.m_list.selection = itemId;
764
- }
765
- }