x4js 1.5.29 → 1.5.32

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/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 );
@@ -31,6 +31,7 @@ import { Component, CProps, Flex, Separator } from './component'
31
31
  import { HLayout, VLayout } from './layout'
32
32
  import { Button } from './button'
33
33
  import { CardView, CardViewProps, ICardViewItem } from './cardview'
34
+ import { Image } from './image';
34
35
 
35
36
  export interface SideBarItem extends ICardViewItem {
36
37
  }
@@ -38,6 +39,7 @@ export interface SideBarItem extends ICardViewItem {
38
39
  export interface SideBarProps extends CardViewProps {
39
40
  bar_sizable?: boolean;
40
41
  bar_width?: number;
42
+ logo?: Image;
41
43
  }
42
44
 
43
45
  /**
@@ -74,7 +76,10 @@ export class SideBarView extends CardView<SideBarProps> {
74
76
  this.m_sidebar.setContent( new VLayout( {
75
77
  flex: 1,
76
78
  cls: 'content',
77
- content: tabs
79
+ content: [
80
+ this.m_props.logo,
81
+ ...tabs
82
+ ]
78
83
  }) );
79
84
 
80
85
  this.setContent( [
@@ -135,7 +135,7 @@ abstract class SVGItem {
135
135
 
136
136
  if (value === undefined || value==='' || value===undefined ) {
137
137
  this.m_style.delete( name );
138
- return;
138
+ return this;
139
139
  }
140
140
 
141
141
  if (!_x4_unitless[name] && (isNumber(value) || reNumber.test(value))) {
@@ -204,7 +204,7 @@ abstract class SVGItem {
204
204
  *
205
205
  */
206
206
 
207
- clip( id: string ) {
207
+ clip( id: string ): this {
208
208
  this.attr( "clip-path", `url(#${id})` );
209
209
  return this;
210
210
  }
@@ -213,24 +213,28 @@ abstract class SVGItem {
213
213
  *
214
214
  */
215
215
 
216
- transform( tr: string ) {
216
+ transform( tr: string ): this {
217
217
  this.attr( "transform", tr );
218
+ return this;
218
219
  }
219
220
 
220
221
  /**
221
222
  *
222
223
  */
223
224
 
224
- rotate( deg: number, cx: number, cy: number ) {
225
+ rotate( deg: number, cx: number, cy: number ): this {
225
226
  this.transform( `rotate( ${deg} ${cx} ${cy} )` );
227
+ return this;
226
228
  }
227
229
 
228
- translate( dx: number, dy: number ) {
230
+ translate( dx: number, dy: number ): this {
229
231
  this.transform( `translate( ${dx} ${dy} )` );
232
+ return this;
230
233
  }
231
234
 
232
- scale( x: number ) {
235
+ scale( x: number ): this {
233
236
  this.transform( `scale( ${x} )` );
237
+ return this;
234
238
  }
235
239
  }
236
240
 
@@ -471,6 +475,12 @@ class SVGGroup extends SVGItem {
471
475
  return shape;
472
476
  }
473
477
 
478
+ group( ) {
479
+ const group = new SVGGroup( );
480
+ this.m_items.push( group );
481
+ return group;
482
+ }
483
+
474
484
  /**
475
485
  *
476
486
  * example
@@ -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.32";
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
  */
@@ -339,7 +340,7 @@ export declare class Component<P extends CProps<CEventMap> = CProps<CEventMap>,
339
340
  * this.setDomEvent( 'drag drop', this._handleDrag, this );
340
341
  * this.setDomEvent( 'dblclick', this._handleDblClick, this );
341
342
  */
342
- setDomEvent<K extends keyof X4ElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: X4ElementEventMap[K]) => void): void;
343
+ setDomEvent<K extends keyof X4ElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: X4ElementEventMap[K]) => void, passive?: boolean): void;
343
344
  private _setDomEvent;
344
345
  /**
345
346
  *
@@ -350,7 +351,7 @@ export declare class Component<P extends CProps<CEventMap> = CProps<CEventMap>,
350
351
  * @param name
351
352
  * @param handler
352
353
  */
353
- createEvent(name: string, handler: Function): void;
354
+ private _createEvent;
354
355
  /**
355
356
  * dispatch a dom event to the appropriated component
356
357
  * called by the system
@@ -216,16 +216,16 @@ export interface DataProxyProps extends BaseComponentProps<DataEventMap> {
216
216
  }
217
217
  export declare class DataProxy extends BaseComponent<DataProxyProps, DataEventMap> {
218
218
  constructor(props: DataProxyProps);
219
- load(url?: string): void;
220
- private _refresh;
219
+ load(url?: string): Promise<void>;
221
220
  }
222
221
  /**
223
222
  *
224
223
  */
225
- interface DataStoreProps extends BaseComponentProps<DataStoreEventMap> {
226
- model: Record;
227
- data?: Record[];
224
+ interface DataStoreProps<T extends Record> extends BaseComponentProps<DataStoreEventMap> {
225
+ model: T;
226
+ data?: T[];
228
227
  url?: string;
228
+ autoload?: false;
229
229
  }
230
230
  interface DataStoreEventMap extends EventMap {
231
231
  data_change: EvDataChange;
@@ -233,19 +233,19 @@ interface DataStoreEventMap extends EventMap {
233
233
  /**
234
234
  *
235
235
  */
236
- export declare class DataStore extends EventSource<DataStoreEventMap> {
237
- protected m_model: Record;
236
+ export declare class DataStore<T extends Record = Record> extends EventSource<DataStoreEventMap> {
237
+ protected m_model: T;
238
238
  protected m_fields: FieldInfo[];
239
- protected m_records: Record[];
239
+ protected m_records: T[];
240
240
  protected m_proxy: DataProxy;
241
241
  protected m_rec_index: DataIndex;
242
- constructor(props: DataStoreProps);
242
+ constructor(props: DataStoreProps<T>);
243
243
  /**
244
244
  *
245
245
  * @param records
246
246
  */
247
- load(url?: string): void;
248
- reload(): void;
247
+ load(url?: string): Promise<void>;
248
+ reload(): Promise<void>;
249
249
  /**
250
250
  * convert raw objects to real records from model
251
251
  * @param records
@@ -255,17 +255,17 @@ export declare class DataStore extends EventSource<DataStoreEventMap> {
255
255
  * just set the records
256
256
  * @param records - must be of the same type as model
257
257
  */
258
- setRawData(records: any[]): void;
258
+ setRawData(records: T[]): void;
259
259
  private _rebuildIndex;
260
260
  /**
261
261
  *
262
262
  */
263
- update(rec: Record): boolean;
263
+ update(rec: T): boolean;
264
264
  /**
265
265
  *
266
266
  * @param data
267
267
  */
268
- append(rec: Record | any): void;
268
+ append(rec: T | any): void;
269
269
  /**
270
270
  *
271
271
  */
@@ -291,19 +291,19 @@ export declare class DataStore extends EventSource<DataStoreEventMap> {
291
291
  * return the record by it's id
292
292
  * @returns record or null
293
293
  */
294
- getById(id: any): Record;
294
+ getById(id: any): T;
295
295
  /**
296
296
  * return a record by it's index
297
297
  * @returns record or null
298
298
  */
299
- getByIndex(index: number): Record;
299
+ getByIndex(index: number): T;
300
300
  private _getRecord;
301
- moveTo(other: DataStore): void;
301
+ moveTo(other: DataStore<T>): void;
302
302
  /**
303
303
  * create a new view on the DataStore
304
304
  * @param opts
305
305
  */
306
- createView(opts?: DataViewProps): DataView;
306
+ createView(opts?: DataViewProps<T>): DataView<T>;
307
307
  /**
308
308
  *
309
309
  */
@@ -312,8 +312,8 @@ export declare class DataStore extends EventSource<DataStoreEventMap> {
312
312
  /**
313
313
  *
314
314
  */
315
- forEach(cb: (rec: Record, index: number) => any): void;
316
- export(): Record[];
315
+ forEach(cb: (rec: T, index: number) => any): void;
316
+ export(): T[];
317
317
  changed(): void;
318
318
  }
319
319
  export interface EvViewChange extends BasicEvent {
@@ -323,8 +323,8 @@ export declare function EvViewChange(action: 'filter' | 'sort' | 'change'): EvVi
323
323
  interface DataViewEventMap extends BaseComponentEventMap {
324
324
  view_change: EvViewChange;
325
325
  }
326
- interface DataViewProps extends BaseComponentProps<DataViewEventMap> {
327
- store?: DataStore;
326
+ interface DataViewProps<T extends Record> extends BaseComponentProps<DataViewEventMap> {
327
+ store?: DataStore<T>;
328
328
  filter?: FilterInfo;
329
329
  order?: string | SortProp[] | SortProp;
330
330
  }
@@ -344,12 +344,12 @@ export interface SortProp {
344
344
  * You can sort the columns & filter data
345
345
  * You can have multiple views for a single DataStore
346
346
  */
347
- export declare class DataView extends BaseComponent<DataViewProps, DataViewEventMap> {
347
+ export declare class DataView<T extends Record = Record> extends BaseComponent<DataViewProps<T>, DataViewEventMap> {
348
348
  protected m_index: DataIndex;
349
- protected m_store: DataStore;
349
+ protected m_store: DataStore<T>;
350
350
  protected m_sort: SortProp[];
351
351
  protected m_filter: FilterInfo;
352
- constructor(props: DataViewProps);
352
+ constructor(props: DataViewProps<T>);
353
353
  private _storeChange;
354
354
  /**
355
355
  *
@@ -367,7 +367,7 @@ export declare class DataView extends BaseComponent<DataViewProps, DataViewEvent
367
367
  /**
368
368
  *
369
369
  */
370
- get store(): DataStore;
370
+ get store(): DataStore<T>;
371
371
  /**
372
372
  *
373
373
  */
@@ -381,16 +381,16 @@ export declare class DataView extends BaseComponent<DataViewProps, DataViewEvent
381
381
  *
382
382
  * @param index
383
383
  */
384
- getByIndex(index: number): Record;
384
+ getByIndex(index: number): T;
385
385
  /**
386
386
  *
387
387
  * @param id
388
388
  */
389
- getById(id: any): Record;
389
+ getById(id: any): T;
390
390
  changed(): void;
391
391
  /**
392
392
  *
393
393
  */
394
- forEach(cb: (rec: Record, index: number) => any): void;
394
+ forEach(cb: (rec: T, index: number) => any): void;
395
395
  }
396
396
  export {};
@@ -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 {};
@@ -29,11 +29,13 @@
29
29
  import { Component } from './component';
30
30
  import { VLayout } from './layout';
31
31
  import { CardView, CardViewProps, ICardViewItem } from './cardview';
32
+ import { Image } from './image';
32
33
  export interface SideBarItem extends ICardViewItem {
33
34
  }
34
35
  export interface SideBarProps extends CardViewProps {
35
36
  bar_sizable?: boolean;
36
37
  bar_width?: number;
38
+ logo?: Image;
37
39
  }
38
40
  /**
39
41
  *
@@ -87,13 +87,13 @@ declare abstract class SVGItem {
87
87
  /**
88
88
  *
89
89
  */
90
- transform(tr: string): void;
90
+ transform(tr: string): this;
91
91
  /**
92
92
  *
93
93
  */
94
- rotate(deg: number, cx: number, cy: number): void;
95
- translate(dx: number, dy: number): void;
96
- scale(x: number): void;
94
+ rotate(deg: number, cx: number, cy: number): this;
95
+ translate(dx: number, dy: number): this;
96
+ scale(x: number): this;
97
97
  }
98
98
  /**
99
99
  *
@@ -173,6 +173,7 @@ declare class SVGGroup extends SVGItem {
173
173
  text(x: any, y: any, txt: any): SVGText;
174
174
  ellipse(x: any, y: any, r1: any, r2?: any): SVGShape;
175
175
  rect(x: any, y: any, w: any, h: any): SVGShape;
176
+ group(): SVGGroup;
176
177
  /**
177
178
  *
178
179
  * example
@@ -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.32";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.5.29",
3
+ "version": "1.5.32",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",