x4js 1.5.5 → 1.5.7
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 +8 -1
- package/lib/README.md +8 -1
- package/lib/changelog.txt +12 -0
- package/lib/cjs/calendar.js +7 -2
- package/lib/cjs/combobox.js +111 -21
- package/lib/cjs/label.js +2 -2
- package/lib/cjs/listview.js +3 -1
- package/lib/cjs/messagebox.js +27 -0
- package/lib/cjs/popup.js +2 -2
- package/lib/cjs/tools.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/calendar.js +7 -2
- package/lib/esm/combobox.js +114 -22
- package/lib/esm/label.js +3 -3
- package/lib/esm/listview.js +3 -1
- package/lib/esm/messagebox.js +16 -0
- package/lib/esm/popup.js +2 -2
- package/lib/esm/tools.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/src/calendar.ts +8 -2
- package/lib/src/combobox.ts +141 -38
- package/lib/src/label.ts +3 -3
- package/lib/src/listview.ts +5 -2
- package/lib/src/messagebox.ts +21 -0
- package/lib/src/popup.ts +2 -2
- package/lib/src/tools.ts +1 -1
- package/lib/src/version.ts +1 -1
- package/lib/types/calendar.d.ts +2 -1
- package/lib/types/combobox.d.ts +11 -5
- package/lib/types/listview.d.ts +1 -1
- package/lib/types/messagebox.d.ts +1 -0
- package/lib/types/popup.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/esm/label.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
import { Component } from './component';
|
|
30
|
-
import { HtmlString } from './tools';
|
|
30
|
+
import { escapeHtml, HtmlString } from './tools';
|
|
31
31
|
import { Icon } from './icon';
|
|
32
32
|
/**
|
|
33
33
|
* Standard label
|
|
@@ -45,7 +45,7 @@ export class Label extends Component {
|
|
|
45
45
|
render(props) {
|
|
46
46
|
let text = this.m_props.text;
|
|
47
47
|
if (this.m_props.multiline && !(text instanceof HtmlString)) {
|
|
48
|
-
text = new HtmlString(text
|
|
48
|
+
text = new HtmlString(escapeHtml(text, true));
|
|
49
49
|
}
|
|
50
50
|
if (!props.icon) {
|
|
51
51
|
this.setContent(text);
|
|
@@ -70,7 +70,7 @@ export class Label extends Component {
|
|
|
70
70
|
props.text = txt;
|
|
71
71
|
let text = this.m_props.text;
|
|
72
72
|
if (this.m_props.multiline && !(text instanceof HtmlString)) {
|
|
73
|
-
text = new HtmlString(text
|
|
73
|
+
text = new HtmlString(escapeHtml(text, true));
|
|
74
74
|
}
|
|
75
75
|
if (this.dom) {
|
|
76
76
|
let comp = this;
|
package/lib/esm/listview.js
CHANGED
|
@@ -59,7 +59,7 @@ export class ListView extends VLayout {
|
|
|
59
59
|
this._buildItems();
|
|
60
60
|
}
|
|
61
61
|
else if (this.m_props.populate) {
|
|
62
|
-
this.items = this.m_props.populate();
|
|
62
|
+
this.items = this.m_props.populate(null);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
render(props) {
|
|
@@ -307,6 +307,8 @@ export class ListView extends VLayout {
|
|
|
307
307
|
}
|
|
308
308
|
/** @ignore */
|
|
309
309
|
_handleClick(e) {
|
|
310
|
+
e.stopImmediatePropagation();
|
|
311
|
+
e.preventDefault();
|
|
310
312
|
let dom = e.target, self = this.dom, list_items = this.m_props.items; // already created by build
|
|
311
313
|
// go up until we find something interesting
|
|
312
314
|
while (dom && dom != self) {
|
package/lib/esm/messagebox.js
CHANGED
|
@@ -76,6 +76,22 @@ export class MessageBox extends Dialog {
|
|
|
76
76
|
msg.show();
|
|
77
77
|
return msg;
|
|
78
78
|
}
|
|
79
|
+
static async showAsync(props) {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
let _props;
|
|
82
|
+
const cb = (btn) => {
|
|
83
|
+
resolve(btn);
|
|
84
|
+
};
|
|
85
|
+
if (isString(props) || isHtmlString(props)) {
|
|
86
|
+
_props = { message: props, click: cb };
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
_props = { ...props, click: cb };
|
|
90
|
+
}
|
|
91
|
+
const msg = new MessageBox(_props);
|
|
92
|
+
msg.show();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
79
95
|
/**
|
|
80
96
|
* display an alert message
|
|
81
97
|
*/
|
package/lib/esm/popup.js
CHANGED
|
@@ -134,8 +134,8 @@ export class Popup extends Container {
|
|
|
134
134
|
* @param x
|
|
135
135
|
* @param y
|
|
136
136
|
*/
|
|
137
|
-
displayAt(x, y, align = 'top left', offset) {
|
|
138
|
-
this.show();
|
|
137
|
+
displayAt(x, y, align = 'top left', offset, modal = false) {
|
|
138
|
+
this.show(modal);
|
|
139
139
|
let halign = 'l', valign = 't';
|
|
140
140
|
if (align.indexOf('right') >= 0) {
|
|
141
141
|
halign = 'r';
|
package/lib/esm/tools.js
CHANGED
|
@@ -269,7 +269,7 @@ export function sprintf(format, ...args) {
|
|
|
269
269
|
*/
|
|
270
270
|
export function escapeHtml(unsafe, nl_br = false) {
|
|
271
271
|
if (!unsafe || unsafe.length == 0) {
|
|
272
|
-
return
|
|
272
|
+
return "";
|
|
273
273
|
}
|
|
274
274
|
let result = unsafe.replace(/[<>\&\"\']/g, function (c) {
|
|
275
275
|
return '&#' + c.charCodeAt(0) + ';';
|
package/lib/esm/version.js
CHANGED
package/lib/src/calendar.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { Button } from './button';
|
|
|
33
33
|
import { Popup } from './popup';
|
|
34
34
|
import { Component, CProps, ContainerEventMap, Flex } from './component'
|
|
35
35
|
import { EvChange, EventCallback } from './x4events'
|
|
36
|
+
import { Point } from "./tools"
|
|
36
37
|
|
|
37
38
|
import { _tr } from './i18n';
|
|
38
39
|
import { Label } from './label';
|
|
@@ -308,9 +309,14 @@ export class PopupCalendar extends Popup {
|
|
|
308
309
|
}
|
|
309
310
|
|
|
310
311
|
/** @ignore */
|
|
311
|
-
show(modal?: boolean) {
|
|
312
|
+
show(modal?: boolean, at?: Point ) {
|
|
312
313
|
x4document.addEventListener('mousedown', this._handleClick);
|
|
313
|
-
|
|
314
|
+
if( at ) {
|
|
315
|
+
super.displayAt( at.x, at.y, 'top left', undefined, modal );
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
super.show(modal);
|
|
319
|
+
}
|
|
314
320
|
}
|
|
315
321
|
|
|
316
322
|
/** @ignore */
|
package/lib/src/combobox.ts
CHANGED
|
@@ -38,7 +38,7 @@ import { Input } from './input'
|
|
|
38
38
|
import { Label } from './label'
|
|
39
39
|
import { Button } from './button'
|
|
40
40
|
import { HLayout } from './layout'
|
|
41
|
-
import { PopupListView, ListViewItem,
|
|
41
|
+
import { PopupListView, ListViewItem, EvCancel, PopulateItems } from './listview';
|
|
42
42
|
import { DataStore, DataView, Record } from './datastore'
|
|
43
43
|
import { isFunction, HtmlString } from './tools'
|
|
44
44
|
|
|
@@ -73,12 +73,12 @@ export interface ComboBoxProps extends CProps<ComboBoxEventMap> {
|
|
|
73
73
|
|
|
74
74
|
labelAlign?: 'left' | 'right';
|
|
75
75
|
|
|
76
|
-
items?: ListViewItem[];
|
|
77
|
-
populate?: PopulateItems; // if not specified, fire 'populate' event
|
|
76
|
+
items?: ListViewItem[] | PopulateItems;
|
|
78
77
|
value?: any; // shown value at init
|
|
79
78
|
|
|
80
79
|
renderer?: ComboItemRender;
|
|
81
80
|
selectionChange?: EventCallback<EvSelectionChange>;// shortcut to events: { selectionChange: ... }
|
|
81
|
+
editable?: boolean;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -87,43 +87,97 @@ export interface ComboBoxProps extends CProps<ComboBoxEventMap> {
|
|
|
87
87
|
|
|
88
88
|
export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
89
89
|
|
|
90
|
-
private m_ui_input: Component;
|
|
90
|
+
private m_ui_input: Input | Component;
|
|
91
91
|
private m_ui_button: Button;
|
|
92
92
|
private m_popup: PopupListView;
|
|
93
|
-
|
|
93
|
+
private m_lockpop: boolean;
|
|
94
|
+
private m_lockchg: boolean;
|
|
95
|
+
private m_popvis: boolean;
|
|
94
96
|
private m_selection: ListViewItem;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
|
|
97
98
|
constructor(props: ComboBoxProps) {
|
|
98
99
|
super(props);
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
if( !props.editable ) {
|
|
102
|
+
this.setDomEvent( 'keypress', () => this.showPopup() );
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.setDomEvent( 'click', () => {
|
|
106
|
+
if( this.m_props.editable ) {
|
|
107
|
+
this.m_ui_input.focus( );
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this.showPopup();
|
|
111
|
+
} );
|
|
102
112
|
|
|
113
|
+
this.setDomEvent("keydown", e => this._onKey(e));
|
|
103
114
|
this.mapPropEvents(props, 'selectionChange' );
|
|
115
|
+
|
|
116
|
+
this.m_popvis = false;
|
|
117
|
+
this.m_lockpop = false;
|
|
118
|
+
this.m_lockchg = false;
|
|
104
119
|
}
|
|
105
120
|
|
|
121
|
+
_onKey(e) {
|
|
122
|
+
if (this.m_popvis) {
|
|
123
|
+
if (e.key == "ArrowUp" || e.key == "ArrowDown") {
|
|
124
|
+
this.m_lockpop = true;
|
|
125
|
+
this.m_popup.handleKey(e);
|
|
126
|
+
this.m_lockpop = false;
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
}
|
|
130
|
+
else if (e.key == "Escape") {
|
|
131
|
+
this._hidePopup();
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
106
138
|
set items( items: ListViewItem[] ) {
|
|
107
139
|
this.m_props.items = items;
|
|
108
140
|
if( this.m_popup ) {
|
|
109
141
|
this.m_popup.items = items;
|
|
110
142
|
}
|
|
111
143
|
}
|
|
112
|
-
|
|
144
|
+
|
|
113
145
|
/** @ignore */
|
|
114
146
|
render( props: ComboBoxProps ) {
|
|
115
147
|
|
|
116
148
|
if( !props.renderer ) {
|
|
117
|
-
|
|
149
|
+
|
|
150
|
+
const input = new Input( {
|
|
118
151
|
flex : 1,
|
|
119
|
-
readOnly : true,
|
|
152
|
+
readOnly : this.m_props.editable ? false : true,
|
|
120
153
|
tabIndex : 0,
|
|
121
154
|
name: props.name,
|
|
122
155
|
value_hook: {
|
|
123
156
|
get: (): string => { return this.value; },
|
|
124
157
|
set: (v: string) => { this.value = v; }
|
|
158
|
+
},
|
|
159
|
+
dom_events: {
|
|
160
|
+
focus: () => {
|
|
161
|
+
if( this.m_props.editable && input.value.length==0 ) {
|
|
162
|
+
this.showPopup( );
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
input: ( ) => {
|
|
166
|
+
if( this.m_lockchg ) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const text = input.value;
|
|
171
|
+
this.m_selection = { id: undefined, text };
|
|
172
|
+
let items = this.showPopup( );
|
|
173
|
+
if( items && items.length && items[0].text==text ) {
|
|
174
|
+
this.m_selection = { id: items[0].id, text };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
125
177
|
}
|
|
126
178
|
});
|
|
179
|
+
|
|
180
|
+
this.m_ui_input = input;
|
|
127
181
|
}
|
|
128
182
|
else {
|
|
129
183
|
this.m_ui_input = new Component( {
|
|
@@ -162,7 +216,9 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
162
216
|
cls: 'gadget',
|
|
163
217
|
icon: 'var( --x4-icon-angle-down )',
|
|
164
218
|
tabIndex: false,
|
|
165
|
-
click: () =>
|
|
219
|
+
click: () => {
|
|
220
|
+
this.showPopup( false )
|
|
221
|
+
},
|
|
166
222
|
dom_events: {
|
|
167
223
|
focus: () => { this.dom.focus(); },
|
|
168
224
|
}
|
|
@@ -188,11 +244,21 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
188
244
|
* display the popup
|
|
189
245
|
*/
|
|
190
246
|
|
|
191
|
-
showPopup() {
|
|
247
|
+
showPopup( filter_items: boolean = true ) {
|
|
192
248
|
|
|
193
249
|
let props = this.m_props;
|
|
194
250
|
if (props.readOnly || this.hasClass("@disable") ) {
|
|
195
|
-
return;
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let items = props.items;
|
|
255
|
+
if( isFunction( items ) ) {
|
|
256
|
+
const filter = filter_items ? (this.m_ui_input as Input).value : null;
|
|
257
|
+
items = items( filter );
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if( items.length==0 ) {
|
|
261
|
+
return null;
|
|
196
262
|
}
|
|
197
263
|
|
|
198
264
|
// need creation ?
|
|
@@ -205,10 +271,17 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
205
271
|
// prepare the combo listview
|
|
206
272
|
this.m_popup = new PopupListView({
|
|
207
273
|
cls: '@combo-popup',
|
|
208
|
-
items: props.items,
|
|
209
274
|
populate: props.populate,
|
|
210
275
|
renderItem: this.m_props.renderer,
|
|
211
|
-
selectionChange: (e) =>
|
|
276
|
+
selectionChange: (e) => {
|
|
277
|
+
|
|
278
|
+
this._selectItem(e);
|
|
279
|
+
|
|
280
|
+
if (!this.m_lockpop) {
|
|
281
|
+
this._hidePopup();
|
|
282
|
+
this.focus();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
212
285
|
cancel: ( e ) => this.signal( 'cancel', e ),
|
|
213
286
|
style: {
|
|
214
287
|
fontFamily,
|
|
@@ -216,6 +289,8 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
216
289
|
}
|
|
217
290
|
});
|
|
218
291
|
}
|
|
292
|
+
|
|
293
|
+
this.m_popup.items = items;
|
|
219
294
|
|
|
220
295
|
let r1 = this.m_ui_button.getBoundingRect(),
|
|
221
296
|
r2 = this.m_ui_input.getBoundingRect();
|
|
@@ -225,10 +300,14 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
225
300
|
});
|
|
226
301
|
|
|
227
302
|
this.m_popup.displayAt(r2.left, r2.bottom);
|
|
303
|
+
this.m_popvis = true;
|
|
304
|
+
this.startTimer("focus-check", 100, true, () => this._checkFocus());
|
|
228
305
|
|
|
229
306
|
if( this.value!==undefined ) {
|
|
230
307
|
this.m_popup.selection = this.value;
|
|
231
308
|
}
|
|
309
|
+
|
|
310
|
+
return items;
|
|
232
311
|
}
|
|
233
312
|
|
|
234
313
|
/** @ignore
|
|
@@ -241,8 +320,10 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
241
320
|
return;
|
|
242
321
|
}
|
|
243
322
|
|
|
323
|
+
this.m_lockchg = true;
|
|
244
324
|
this._setInput( item, true );
|
|
245
|
-
|
|
325
|
+
this.m_lockchg = false;
|
|
326
|
+
|
|
246
327
|
this.m_selection = {
|
|
247
328
|
id: item.id,
|
|
248
329
|
text: item.text
|
|
@@ -250,9 +331,8 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
250
331
|
|
|
251
332
|
this.emit( 'selectionChange', EvSelectionChange( item ) );
|
|
252
333
|
this.emit( 'change', EvChange(item.id) );
|
|
253
|
-
this.m_ui_input.focus( );
|
|
254
|
-
|
|
255
|
-
this.m_popup.hide( );
|
|
334
|
+
//this.m_ui_input.focus( );
|
|
335
|
+
//this.m_popup.hide( );
|
|
256
336
|
}
|
|
257
337
|
|
|
258
338
|
/**
|
|
@@ -294,7 +374,15 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
294
374
|
}
|
|
295
375
|
|
|
296
376
|
public get valueText( ) {
|
|
297
|
-
|
|
377
|
+
if( this.m_selection ) {
|
|
378
|
+
return this.m_selection.text;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if( this.m_props.editable ) {
|
|
382
|
+
return (this.m_ui_input as Input).value;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return '';
|
|
298
386
|
}
|
|
299
387
|
|
|
300
388
|
/**
|
|
@@ -305,9 +393,9 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
305
393
|
let items = this.m_props.items;
|
|
306
394
|
|
|
307
395
|
if( isFunction(items) ) {
|
|
308
|
-
items = items( );
|
|
396
|
+
items = items( null );
|
|
309
397
|
}
|
|
310
|
-
|
|
398
|
+
|
|
311
399
|
const found = items.some( (v) => {
|
|
312
400
|
if (v.id === id) {
|
|
313
401
|
this._setInput( v );
|
|
@@ -326,6 +414,27 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
326
414
|
return this.m_ui_input instanceof Input ? this.m_ui_input : null;
|
|
327
415
|
}
|
|
328
416
|
|
|
417
|
+
_checkFocus() {
|
|
418
|
+
const focus = document.activeElement;
|
|
419
|
+
if (this.dom && this.dom.contains(focus) || focus==document.body ) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (this.m_popup && this.m_popup.dom && this.m_popup.dom.contains(focus)) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
this._hidePopup();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
_hidePopup() {
|
|
431
|
+
if (this.m_popvis) {
|
|
432
|
+
this.m_popup.close();
|
|
433
|
+
this.m_popvis = false;
|
|
434
|
+
this.stopTimer("focus-check");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
329
438
|
static storeProxy( props: ComboStoreProxyProps ): PopulateItems {
|
|
330
439
|
|
|
331
440
|
let view: DataView = props.store instanceof DataStore ? props.store.createView() : props.store;
|
|
@@ -343,20 +452,14 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
|
343
452
|
return result;
|
|
344
453
|
};
|
|
345
454
|
}
|
|
346
|
-
}
|
|
347
455
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
456
|
+
focus( ) {
|
|
457
|
+
if( this.m_props.editable ) {
|
|
458
|
+
this.m_ui_input.focus( );
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
super.focus( );
|
|
462
|
+
}
|
|
463
|
+
}
|
|
355
464
|
}
|
|
356
465
|
|
|
357
|
-
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
package/lib/src/label.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
30
|
import { Component, CProps } from './component'
|
|
31
|
-
import { HtmlString } from './tools'
|
|
31
|
+
import { escapeHtml, HtmlString } from './tools'
|
|
32
32
|
import { Icon, IconID } from './icon'
|
|
33
33
|
|
|
34
34
|
// ============================================================================
|
|
@@ -69,7 +69,7 @@ export class Label extends Component<LabelProps>
|
|
|
69
69
|
|
|
70
70
|
let text: any = this.m_props.text;
|
|
71
71
|
if( this.m_props.multiline && !(text instanceof HtmlString) ) {
|
|
72
|
-
text = new HtmlString( (text
|
|
72
|
+
text = new HtmlString( escapeHtml(text,true) );
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if( !props.icon ) {
|
|
@@ -102,7 +102,7 @@ export class Label extends Component<LabelProps>
|
|
|
102
102
|
|
|
103
103
|
let text: any = this.m_props.text;
|
|
104
104
|
if( this.m_props.multiline && !(text instanceof HtmlString) ) {
|
|
105
|
-
text = new HtmlString(
|
|
105
|
+
text = new HtmlString(escapeHtml(text,true) );
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if( this.dom ) {
|
package/lib/src/listview.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface RenderListItem {
|
|
|
62
62
|
* callback to fill the list
|
|
63
63
|
*/
|
|
64
64
|
export interface PopulateItems {
|
|
65
|
-
(): ListViewItem[];
|
|
65
|
+
( filter: string ): ListViewItem[];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -137,7 +137,7 @@ export class ListView extends VLayout<ListViewProps,ListViewEventMap> {
|
|
|
137
137
|
this._buildItems();
|
|
138
138
|
}
|
|
139
139
|
else if( this.m_props.populate ) {
|
|
140
|
-
this.items = this.m_props.populate( );
|
|
140
|
+
this.items = this.m_props.populate( null );
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -449,6 +449,9 @@ export class ListView extends VLayout<ListViewProps,ListViewEventMap> {
|
|
|
449
449
|
/** @ignore */
|
|
450
450
|
private _handleClick(e: MouseEvent) {
|
|
451
451
|
|
|
452
|
+
e.stopImmediatePropagation();
|
|
453
|
+
e.preventDefault( );
|
|
454
|
+
|
|
452
455
|
let dom = e.target as HTMLElement,
|
|
453
456
|
self = this.dom,
|
|
454
457
|
list_items = this.m_props.items as ListViewItem[]; // already created by build
|
package/lib/src/messagebox.ts
CHANGED
|
@@ -105,6 +105,27 @@ export class MessageBox extends Dialog<MessageBoxProps>
|
|
|
105
105
|
return msg;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
static async showAsync( props: string | HtmlString | MessageBoxProps): Promise<string> {
|
|
109
|
+
return new Promise( (resolve, reject ) => {
|
|
110
|
+
|
|
111
|
+
let _props: MessageBoxProps;
|
|
112
|
+
|
|
113
|
+
const cb = ( btn: string ) => {
|
|
114
|
+
resolve( btn );
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (isString(props) || isHtmlString(props)) {
|
|
118
|
+
_props = { message: props, click: cb };
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
_props = { ...props, click: cb };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const msg = new MessageBox(_props);
|
|
125
|
+
msg.show();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
108
129
|
/**
|
|
109
130
|
* display an alert message
|
|
110
131
|
*/
|
package/lib/src/popup.ts
CHANGED
|
@@ -185,9 +185,9 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap =
|
|
|
185
185
|
* @param y
|
|
186
186
|
*/
|
|
187
187
|
|
|
188
|
-
public displayAt(x: number, y: number, align: string = 'top left', offset?: { x, y }) {
|
|
188
|
+
public displayAt(x: number, y: number, align: string = 'top left', offset?: { x, y }, modal = false ) {
|
|
189
189
|
|
|
190
|
-
this.show();
|
|
190
|
+
this.show( modal );
|
|
191
191
|
|
|
192
192
|
let halign = 'l',
|
|
193
193
|
valign = 't';
|
package/lib/src/tools.ts
CHANGED
|
@@ -346,7 +346,7 @@ export function sprintf(format: string, ...args) {
|
|
|
346
346
|
*/
|
|
347
347
|
export function escapeHtml(unsafe: string, nl_br = false): string {
|
|
348
348
|
if (!unsafe || unsafe.length == 0) {
|
|
349
|
-
return
|
|
349
|
+
return "";
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
let result = unsafe.replace(/[<>\&\"\']/g, function (c) {
|
package/lib/src/version.ts
CHANGED
package/lib/types/calendar.d.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import { Popup } from './popup';
|
|
30
30
|
import { CProps, ContainerEventMap } from './component';
|
|
31
31
|
import { EvChange, EventCallback } from './x4events';
|
|
32
|
+
import { Point } from "./tools";
|
|
32
33
|
import { VLayout } from './layout';
|
|
33
34
|
interface CalendarEventMap extends ContainerEventMap {
|
|
34
35
|
change?: EvChange;
|
|
@@ -74,7 +75,7 @@ export declare class PopupCalendar extends Popup {
|
|
|
74
75
|
constructor(props: CalendarProps);
|
|
75
76
|
private _handleClick;
|
|
76
77
|
/** @ignore */
|
|
77
|
-
show(modal?: boolean): void;
|
|
78
|
+
show(modal?: boolean, at?: Point): void;
|
|
78
79
|
/** @ignore */
|
|
79
80
|
close(): void;
|
|
80
81
|
}
|
package/lib/types/combobox.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { Component, CProps, ContainerEventMap } from './component';
|
|
|
33
33
|
import { EvChange, EvSelectionChange, EventCallback } from './x4events';
|
|
34
34
|
import { Input } from './input';
|
|
35
35
|
import { HLayout } from './layout';
|
|
36
|
-
import { ListViewItem,
|
|
36
|
+
import { ListViewItem, EvCancel, PopulateItems } from './listview';
|
|
37
37
|
import { DataStore, DataView, Record } from './datastore';
|
|
38
38
|
import { HtmlString } from './tools';
|
|
39
39
|
export interface ComboStoreProxyProps {
|
|
@@ -55,11 +55,11 @@ export interface ComboBoxProps extends CProps<ComboBoxEventMap> {
|
|
|
55
55
|
label?: string;
|
|
56
56
|
labelWidth?: number;
|
|
57
57
|
labelAlign?: 'left' | 'right';
|
|
58
|
-
items?: ListViewItem[];
|
|
59
|
-
populate?: PopulateItems;
|
|
58
|
+
items?: ListViewItem[] | PopulateItems;
|
|
60
59
|
value?: any;
|
|
61
60
|
renderer?: ComboItemRender;
|
|
62
61
|
selectionChange?: EventCallback<EvSelectionChange>;
|
|
62
|
+
editable?: boolean;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* @review use textedit
|
|
@@ -68,9 +68,12 @@ export declare class ComboBox extends HLayout<ComboBoxProps, ComboBoxEventMap> {
|
|
|
68
68
|
private m_ui_input;
|
|
69
69
|
private m_ui_button;
|
|
70
70
|
private m_popup;
|
|
71
|
+
private m_lockpop;
|
|
72
|
+
private m_lockchg;
|
|
73
|
+
private m_popvis;
|
|
71
74
|
private m_selection;
|
|
72
|
-
private m_defer_sel;
|
|
73
75
|
constructor(props: ComboBoxProps);
|
|
76
|
+
_onKey(e: any): void;
|
|
74
77
|
set items(items: ListViewItem[]);
|
|
75
78
|
/** @ignore */
|
|
76
79
|
render(props: ComboBoxProps): void;
|
|
@@ -78,7 +81,7 @@ export declare class ComboBox extends HLayout<ComboBoxProps, ComboBoxEventMap> {
|
|
|
78
81
|
/**
|
|
79
82
|
* display the popup
|
|
80
83
|
*/
|
|
81
|
-
showPopup():
|
|
84
|
+
showPopup(filter_items?: boolean): ListViewItem[];
|
|
82
85
|
/** @ignore
|
|
83
86
|
*/
|
|
84
87
|
private _selectItem;
|
|
@@ -96,6 +99,9 @@ export declare class ComboBox extends HLayout<ComboBoxProps, ComboBoxEventMap> {
|
|
|
96
99
|
*/
|
|
97
100
|
set value(id: any);
|
|
98
101
|
get input(): Input;
|
|
102
|
+
_checkFocus(): void;
|
|
103
|
+
_hidePopup(): void;
|
|
99
104
|
static storeProxy(props: ComboStoreProxyProps): PopulateItems;
|
|
105
|
+
focus(): void;
|
|
100
106
|
}
|
|
101
107
|
export {};
|
package/lib/types/listview.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export declare class MessageBox extends Dialog<MessageBoxProps> {
|
|
|
46
46
|
* display a messagebox
|
|
47
47
|
*/
|
|
48
48
|
static show(props: string | HtmlString | MessageBoxProps): MessageBox;
|
|
49
|
+
static showAsync(props: string | HtmlString | MessageBoxProps): Promise<string>;
|
|
49
50
|
/**
|
|
50
51
|
* display an alert message
|
|
51
52
|
*/
|
package/lib/types/popup.d.ts
CHANGED
package/lib/types/version.d.ts
CHANGED