x4js 2.2.50 → 2.2.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.2.50",
3
+ "version": "2.2.51",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -14,7 +14,7 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { Component, ComponentEvents, ComponentProps, EvSelectionChange, makeUniqueComponentId } from '../../core/component';
17
+ import { Component, ComponentEvents, ComponentProps, EvClick, EvSelectionChange, makeUniqueComponentId } from '../../core/component';
18
18
  import { class_ns, IComponentInterface, IFormElement, kbNav, safeText, sanitizeHtml, UnsafeHtml } from '../../core/core_tools';
19
19
  import { EventCallback } from '../../core/core_events';
20
20
 
@@ -31,7 +31,8 @@ import icon from "./updown.svg";
31
31
 
32
32
 
33
33
  interface DropdownEvents extends PopupEvents {
34
- selectionChange: EvSelectionChange;
34
+ //selectionChange: EvSelectionChange;
35
+ click: EvClick;
35
36
  }
36
37
 
37
38
 
@@ -57,8 +58,9 @@ export class DropdownList extends Popup<DropdownProps,DropdownEvents> {
57
58
  ev.preventDefault( );
58
59
  }, true );
59
60
 
60
- this._list.on( "selectionChange", ( ev ) => {
61
- this.fire( "selectionChange", ev );
61
+ this._list.on( "click", ( ev ) => {
62
+ //this.fire( "selectionChange", ev );
63
+ this.fire( "click", ev );
62
64
  })
63
65
  }
64
66
 
@@ -152,11 +154,11 @@ export class Combobox extends Component<ComboboxProps,ComboboxEvents> {
152
154
  }
153
155
  }
154
156
 
155
- this._popup.on( "selectionChange", ( ev ) => {
156
- const [sel] = ev.selection as ListboxID[];
157
+ this._popup.on( "click", ( ev ) => {
158
+ const sel = ev.context as ListboxID;
157
159
  if( sel!==undefined ) { // no empty sel
158
160
  _select( sel );
159
- this.fire( "selectionChange", ev );
161
+ this.fire( "selectionChange", { selection: [sel], empty: false } );
160
162
  }
161
163
  });
162
164
 
@@ -178,8 +180,11 @@ export class Combobox extends Component<ComboboxProps,ComboboxEvents> {
178
180
  switch( ev.key ) {
179
181
  case "Enter":
180
182
  case "Escape": {
181
- this._popup.show( false );
182
- break;
183
+ if( this._popup.isOpen( ) ) {
184
+ this._popup.show( false );
185
+ break;
186
+ }
187
+ return;
183
188
  }
184
189
 
185
190
  case "ArrowUp":
@@ -89,7 +89,8 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogEvents
89
89
  this.fire("btnclick", { button: props.closable } );
90
90
  }
91
91
  else {
92
- this.fire("btnclick", { button: props.buttons[0] } );
92
+ //<no it's ok 99% ! this.fire("btnclick", { button: props.buttons[0] } );
93
+ this.close( );
93
94
  }
94
95
  }
95
96
  }) : null,
@@ -113,6 +114,14 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogEvents
113
114
  // todo cancel
114
115
  ev.preventDefault();
115
116
  ev.stopPropagation();
117
+
118
+ if( isString(props.closable) ) {
119
+ this.fire("btnclick", { button: props.closable } );
120
+ }
121
+ else {
122
+ //<no it's ok 99% ! this.fire("btnclick", { button: props.buttons[0] } );
123
+ this.close( );
124
+ }
116
125
  }
117
126
  else if (ev.key == 'Enter') {
118
127
  const def = this.query<Button>('button.default');
@@ -124,6 +133,10 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogEvents
124
133
  }
125
134
  }
126
135
  })
136
+
137
+ asap( ( ) => {
138
+ this.focusNext( true );
139
+ } );
127
140
  }
128
141
 
129
142
  private focusNext( next: boolean) : boolean {
@@ -251,14 +251,14 @@ export class Listbox extends Component<ListboxProps,ListboxEvents> {
251
251
  while( target && target!=this.dom ) {
252
252
  const c = componentFromDOM( target );
253
253
 
254
- // avoid trapping child ckick
255
- if( c.dom.tagName==='INPUT' ) {
254
+ // avoid trapping child click
255
+ if( c && c.dom.tagName==='INPUT' ) {
256
256
  return;
257
257
  }
258
258
 
259
259
  if( c && c.hasClass("x4item") ) {
260
260
  const id = c.getInternalData( "id" );
261
- const fev: ComponentEvent = { context:id };
261
+ const fev: EvClick = { context:id };
262
262
  if (ev.type == 'click') {
263
263
  this.fire('click', fev );
264
264
  }
@@ -276,6 +276,10 @@ export class Listbox extends Component<ListboxProps,ListboxEvents> {
276
276
  target = target.parentElement;
277
277
  }
278
278
 
279
+ if (ev.type == 'click') {
280
+ this.fire('click', {} );
281
+ }
282
+
279
283
  this.clearSelection( );
280
284
 
281
285
  ev.stopImmediatePropagation();