x4js 1.5.29 → 1.5.31

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.
@@ -27,7 +27,7 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
- import { ListViewItem, PopupListView } from "./listview";
30
+ import { RenderListItem, ListViewItem, PopupListView } from "./listview";
31
31
  import { TextEdit, TextEditProps } from './textedit';
32
32
 
33
33
  /**
@@ -40,6 +40,7 @@ interface AutoCompleteProps extends TextEditProps {
40
40
 
41
41
  // a way to change the real value vs displayed value in the popup list
42
42
  selectValue?: ( text: string ) => string;
43
+ renderItem?: RenderListItem
43
44
  }
44
45
 
45
46
  /**
@@ -113,8 +114,13 @@ export class AutoComplete extends TextEdit<AutoCompleteProps> {
113
114
  super.componentDisposed( );
114
115
  }
115
116
 
116
- showPopup( ) {
117
- this._onChange( );
117
+ showPopup( show = true ) {
118
+ if( show ) {
119
+ this._onChange( );
120
+ }
121
+ else {
122
+ this._hidePopup( );
123
+ }
118
124
  }
119
125
 
120
126
  /**
@@ -156,7 +162,8 @@ export class AutoComplete extends TextEdit<AutoCompleteProps> {
156
162
  style: {
157
163
  fontFamily,
158
164
  fontSize
159
- }
165
+ },
166
+ renderItem: props.renderItem,
160
167
  });
161
168
  }
162
169
 
@@ -218,4 +225,8 @@ export class AutoComplete extends TextEdit<AutoCompleteProps> {
218
225
 
219
226
  this.m_needval = true;
220
227
  }
228
+
229
+ isPopupVisible( ) {
230
+ return this.m_popvis;
231
+ }
221
232
  }
@@ -86,20 +86,27 @@ export interface ComboBoxProps extends CProps<ComboBoxEventMap> {
86
86
  editable?: boolean;
87
87
  }
88
88
 
89
+ abstract class InputLike extends Component {
90
+ abstract setValue( text: string );
91
+ abstract getValue( ): string;
92
+ abstract showError( text: string );
93
+ abstract clearError( );
94
+ }
95
+
96
+
89
97
  /**
90
98
  * @review use textedit
91
99
  */
92
100
 
93
101
  export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
94
102
 
95
- private m_ui_input: Input | Component;
103
+ private m_ui_input: Input | InputLike;
96
104
  private m_ui_button: Button;
97
105
  private m_popup: PopupListView;
98
106
  private m_lockpop: boolean;
99
107
  private m_lockchg: boolean;
100
108
  private m_popvis: boolean;
101
109
  private m_selection: ListViewItem;
102
- private m_error_tip: Tooltip;
103
110
 
104
111
  constructor(props: ComboBoxProps) {
105
112
  super(props);
@@ -245,10 +252,6 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
245
252
  }
246
253
 
247
254
  componentDisposed( ) {
248
- if (this.m_error_tip) {
249
- this.m_error_tip.dispose();
250
- }
251
-
252
255
  if( this.m_popup ) {
253
256
  this.m_popup.close( );
254
257
  }
@@ -340,24 +343,11 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
340
343
  }
341
344
 
342
345
  public showError(text: string) {
343
-
344
- if (!this.m_error_tip) {
345
- this.m_error_tip = new Tooltip({ cls: 'error' });
346
- x4document.body.appendChild(this.m_error_tip._build());
347
- }
348
-
349
- let rc = this.m_ui_input.getBoundingRect();
350
- this.m_error_tip.text = text;
351
- this.m_error_tip.displayAt(rc.right, rc.top-8, 'top right');
352
-
353
- this.addClass('@error');
346
+ this.m_ui_input.showError( text );
354
347
  }
355
348
 
356
349
  public clearError() {
357
- if (this.m_error_tip) {
358
- this.m_error_tip.hide();
359
- this.removeClass('@error');
360
- }
350
+ this.m_ui_input.clearError( );
361
351
  }
362
352
 
363
353
  /** @ignore
@@ -279,6 +279,20 @@ export class Component<P extends CProps<CEventMap> = CProps<CEventMap>, E extend
279
279
  }
280
280
  }
281
281
 
282
+ removeChild( item: Component ) {
283
+ if( this.m_props.content ) {
284
+ if (!isArray(this.m_props.content)) {
285
+ this.m_props.content = [this.m_props.content];
286
+ }
287
+
288
+ this.m_props.content = this.m_props.content.filter( x => x!==item );
289
+ }
290
+
291
+ if( this.dom && item.dom ) {
292
+ this.dom.removeChild( item.dom );
293
+ }
294
+ }
295
+
282
296
  /**
283
297
  *
284
298
  */
@@ -239,7 +239,7 @@ interface RecordConstructor {
239
239
  */
240
240
 
241
241
  export function array( ctor: RecordConstructor, props?: MetaData ) {
242
- return data.field( { ...props, type: 'array', model: new ctor() } )
242
+ return data.field( { ...props, type: 'array', model: ctor ? new ctor() : null } )
243
243
  }
244
244
 
245
245
  }
package/lib/src/input.ts CHANGED
@@ -27,6 +27,8 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
+ import { x4document } from './x4dom'
31
+ import { Tooltip } from './tooltips';
30
32
  import { Component, CProps, CEventMap, EvFocus } from './component'
31
33
  //import { EvChange } from './x4_events';
32
34
 
@@ -67,10 +69,20 @@ export interface InputProps<P extends InputEventMap = InputEventMap> extends CPr
67
69
 
68
70
  export class Input extends Component<InputProps,InputEventMap>
69
71
  {
72
+ private m_error_tip: Tooltip;
73
+
70
74
  constructor( props: InputProps ) {
71
75
  super( props );
72
76
  }
73
77
 
78
+ componentDisposed() {
79
+ if (this.m_error_tip) {
80
+ this.m_error_tip.dispose();
81
+ }
82
+
83
+ super.componentDisposed();
84
+ }
85
+
74
86
  /** @ignore */
75
87
  render( props: InputProps ) {
76
88
 
@@ -105,6 +117,28 @@ export class Input extends Component<InputProps,InputEventMap>
105
117
  }
106
118
  }
107
119
 
120
+ public showError(text: string) {
121
+
122
+ if (!this.m_error_tip) {
123
+ this.m_error_tip = new Tooltip({ cls: 'error' });
124
+ x4document.body.appendChild(this.m_error_tip._build());
125
+ }
126
+
127
+ let rc = this.getBoundingRect();
128
+
129
+ this.m_error_tip.text = text;
130
+ this.m_error_tip.displayAt(rc.right, rc.top-8, 'top right');
131
+ this.addClass('@error');
132
+ }
133
+
134
+ public clearError() {
135
+
136
+ if (this.m_error_tip) {
137
+ this.m_error_tip.hide();
138
+ this.removeClass('@error');
139
+ }
140
+ }
141
+
108
142
  public getType( ) {
109
143
  return this.m_props.type;
110
144
  }
@@ -114,7 +148,10 @@ export class Input extends Component<InputProps,InputEventMap>
114
148
  */
115
149
 
116
150
  public get value( ) : string {
117
-
151
+ return this.getValue( );
152
+ }
153
+
154
+ public getValue( ): string {
118
155
  if( this.dom ) {
119
156
  this.m_props.value = (<HTMLInputElement>this.dom).value;
120
157
  }
@@ -129,7 +166,7 @@ export class Input extends Component<InputProps,InputEventMap>
129
166
  }
130
167
 
131
168
  return this.m_props.value;
132
- }
169
+ }
133
170
 
134
171
  /**
135
172
  * Change the editor value
@@ -137,7 +174,10 @@ export class Input extends Component<InputProps,InputEventMap>
137
174
  */
138
175
 
139
176
  public set value( value: string ) {
140
-
177
+ this.setValue( value );
178
+ }
179
+
180
+ public setValue( value: string ) {
141
181
  this.m_props.value = value;
142
182
 
143
183
  if( this.dom ) {
@@ -190,7 +230,7 @@ export class Input extends Component<InputProps,InputEventMap>
190
230
  }
191
231
 
192
232
  public setStoreValue( v: any ) {
193
-
233
+ this.clearError( );
194
234
  if( this.m_props.value_hook ) {
195
235
  return this.m_props.value_hook.set( v );
196
236
  }
package/lib/src/router.ts CHANGED
@@ -154,7 +154,7 @@ export class Router extends EventSource< RouterEventMap > {
154
154
  return this.m_useHash ? '/'+x4document.location.hash.substring(1) : x4document.location.pathname;
155
155
  }
156
156
 
157
- navigate( uri: string, notify = true ) {
157
+ navigate( uri: string, notify = true, replace = false ) {
158
158
 
159
159
  if( !uri.startsWith('/') ) {
160
160
  uri = '/'+uri;
@@ -170,11 +170,15 @@ export class Router extends EventSource< RouterEventMap > {
170
170
  }
171
171
 
172
172
  if( this.m_useHash ) {
173
- while( uri.startsWith('/') ) {
173
+ while( uri.at(0)=='/' ) {
174
174
  uri = uri.substring( 1 );
175
175
  }
176
176
 
177
- window.history.pushState({}, '', '#'+uri );
177
+ uri = '#'+uri;
178
+ }
179
+
180
+ if( replace ) {
181
+ window.history.replaceState({}, '', uri );
178
182
  }
179
183
  else {
180
184
  window.history.pushState({}, '', uri );
@@ -93,8 +93,7 @@ export class TextEdit<T extends TextEditProps = TextEditProps, E extends TextEdi
93
93
 
94
94
  private m_cal_popup: PopupCalendar;
95
95
  protected m_ui_input: Input;
96
- private m_error_tip: Tooltip;
97
-
96
+
98
97
  constructor(props: T) {
99
98
  super(props);
100
99
  this.addClass( '@hlayout' );
@@ -109,14 +108,6 @@ export class TextEdit<T extends TextEditProps = TextEditProps, E extends TextEdi
109
108
  }
110
109
  }
111
110
 
112
- componentDisposed() {
113
- if (this.m_error_tip) {
114
- this.m_error_tip.dispose();
115
- }
116
-
117
- super.componentDisposed();
118
- }
119
-
120
111
  focus() {
121
112
  this.m_ui_input.focus();
122
113
  }
@@ -309,28 +300,18 @@ export class TextEdit<T extends TextEditProps = TextEditProps, E extends TextEdi
309
300
  }
310
301
 
311
302
  public showError(text: string) {
312
-
313
- if (!this.m_error_tip) {
314
- this.m_error_tip = new Tooltip({ cls: 'error' });
315
- x4document.body.appendChild(this.m_error_tip._build());
316
- }
317
-
318
- let rc = this.m_ui_input.getBoundingRect();
319
-
320
- this.m_error_tip.text = text;
321
- this.m_error_tip.displayAt(rc.right, rc.top-8, 'top right');
322
- this.addClass('@error');
303
+ this.m_ui_input.showError( text );
323
304
  }
324
305
 
325
306
  public clearError() {
326
-
327
- if (this.m_error_tip) {
328
- this.m_error_tip.hide();
329
- this.removeClass('@error');
330
- }
307
+ this.m_ui_input.clearError( );
331
308
  }
332
309
 
333
310
  public get value(): string {
311
+ return this.getValue( );
312
+ }
313
+
314
+ public getValue( ) : string {
334
315
  if (this.m_ui_input) {
335
316
  return this.m_ui_input.value;
336
317
  }
@@ -339,7 +320,15 @@ export class TextEdit<T extends TextEditProps = TextEditProps, E extends TextEdi
339
320
  }
340
321
  }
341
322
 
323
+ /**
324
+ *
325
+ */
326
+
342
327
  public set value(value: string) {
328
+ this.setValue( value );
329
+ }
330
+
331
+ public setValue( value: string ) {
343
332
  if (this.m_ui_input) {
344
333
  this.m_ui_input.value = value;
345
334
  }
@@ -27,4 +27,4 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
- export const x4js_version = "1.5.29";
30
+ export const x4js_version = "1.5.31";
package/lib/src/x4.less CHANGED
@@ -665,11 +665,9 @@ textarea {
665
665
  padding-right: 2px;
666
666
  }
667
667
 
668
- &.x-error {
669
- input {
670
- border-bottom: none;
671
- border-left: 4px solid var( --x4-error-color );
672
- }
668
+ input.x-error {
669
+ border-bottom: none;
670
+ border-left: 4px solid var( --x4-error-color );
673
671
  }
674
672
  }
675
673
 
package/lib/styles/x4.css CHANGED
@@ -552,8 +552,8 @@ textarea::selection {
552
552
  content: '*';
553
553
  padding-right: 2px;
554
554
  }
555
- .x-text-edit.x-error input,
556
- .x-combo-box.x-error input {
555
+ .x-text-edit input.x-error,
556
+ .x-combo-box input.x-error {
557
557
  border-bottom: none;
558
558
  border-left: 4px solid var(--x4-error-color);
559
559
  }
@@ -665,11 +665,9 @@ textarea {
665
665
  padding-right: 2px;
666
666
  }
667
667
 
668
- &.x-error {
669
- input {
670
- border-bottom: none;
671
- border-left: 4px solid var( --x4-error-color );
672
- }
668
+ input.x-error {
669
+ border-bottom: none;
670
+ border-left: 4px solid var( --x4-error-color );
673
671
  }
674
672
  }
675
673
 
@@ -26,6 +26,7 @@
26
26
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
+ import { RenderListItem } from "./listview";
29
30
  import { TextEdit, TextEditProps } from './textedit';
30
31
  /**
31
32
  *
@@ -33,6 +34,7 @@ import { TextEdit, TextEditProps } from './textedit';
33
34
  interface AutoCompleteProps extends TextEditProps {
34
35
  enumValues: (filter: string) => string[] | Promise<string[]>;
35
36
  selectValue?: (text: string) => string;
37
+ renderItem?: RenderListItem;
36
38
  }
37
39
  /**
38
40
  *
@@ -46,7 +48,7 @@ export declare class AutoComplete extends TextEdit<AutoCompleteProps> {
46
48
  _onKey(e: KeyboardEvent): void;
47
49
  private _onChange;
48
50
  componentDisposed(): void;
49
- showPopup(): void;
51
+ showPopup(show?: boolean): void;
50
52
  /**
51
53
  * display the popup
52
54
  */
@@ -56,5 +58,6 @@ export declare class AutoComplete extends TextEdit<AutoCompleteProps> {
56
58
  private _checkFocus;
57
59
  private _hidePopup;
58
60
  private _onFocus;
61
+ isPopupVisible(): boolean;
59
62
  }
60
63
  export {};
@@ -70,7 +70,6 @@ export declare class ComboBox extends HLayout<ComboBoxProps, ComboBoxEventMap> {
70
70
  private m_lockchg;
71
71
  private m_popvis;
72
72
  private m_selection;
73
- private m_error_tip;
74
73
  constructor(props: ComboBoxProps);
75
74
  _onKey(e: any): void;
76
75
  set items(items: ListViewItem[]);
@@ -163,6 +163,7 @@ export declare class Component<P extends CProps<CEventMap> = CProps<CEventMap>,
163
163
  * @param content
164
164
  */
165
165
  appendChild(content: ComponentContent): void;
166
+ removeChild(item: Component): void;
166
167
  /**
167
168
  *
168
169
  */
@@ -55,19 +55,25 @@ export interface InputProps<P extends InputEventMap = InputEventMap> extends CPr
55
55
  * CARE derived classes must set this.ui.input
56
56
  */
57
57
  export declare class Input extends Component<InputProps, InputEventMap> {
58
+ private m_error_tip;
58
59
  constructor(props: InputProps);
60
+ componentDisposed(): void;
59
61
  /** @ignore */
60
62
  render(props: InputProps): void;
63
+ showError(text: string): void;
64
+ clearError(): void;
61
65
  getType(): EditType;
62
66
  /**
63
67
  * return the current editor value
64
68
  */
65
69
  get value(): string;
70
+ getValue(): string;
66
71
  /**
67
72
  * Change the editor value
68
73
  * @param value - new value to set
69
74
  */
70
75
  set value(value: string);
76
+ setValue(value: string): void;
71
77
  getStoreValue(): any;
72
78
  setStoreValue(v: any): void;
73
79
  set readOnly(ro: boolean);
@@ -61,7 +61,7 @@ export declare class Router extends EventSource<RouterEventMap> {
61
61
  get(uri: string | RegExp, handler: RouteHandler): void;
62
62
  init(): void;
63
63
  private _getLocation;
64
- navigate(uri: string, notify?: boolean): void;
64
+ navigate(uri: string, notify?: boolean, replace?: boolean): void;
65
65
  private _find;
66
66
  }
67
67
  export {};
@@ -59,10 +59,8 @@ export interface TextEditProps extends InputProps<TextEditEventMap> {
59
59
  export declare class TextEdit<T extends TextEditProps = TextEditProps, E extends TextEditEventMap = TextEditEventMap> extends Component<T, E> {
60
60
  private m_cal_popup;
61
61
  protected m_ui_input: Input;
62
- private m_error_tip;
63
62
  constructor(props: T);
64
63
  componentCreated(): void;
65
- componentDisposed(): void;
66
64
  focus(): void;
67
65
  /** @ignore */
68
66
  render(props: TextEditProps): void;
@@ -82,7 +80,12 @@ export declare class TextEdit<T extends TextEditProps = TextEditProps, E extends
82
80
  showError(text: string): void;
83
81
  clearError(): void;
84
82
  get value(): string;
83
+ getValue(): string;
84
+ /**
85
+ *
86
+ */
85
87
  set value(value: string);
88
+ setValue(value: string): void;
86
89
  /**
87
90
  * select all the text
88
91
  */
@@ -26,4 +26,4 @@
26
26
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
- export declare const x4js_version = "1.5.29";
29
+ export declare const x4js_version = "1.5.31";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.5.29",
3
+ "version": "1.5.31",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",