x4js 1.5.22 → 1.5.24
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/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +3 -3
- package/lib/esm/index.mjs +15731 -9
- package/lib/esm/index.mjs.map +3 -3
- package/lib/src/component.ts +18 -12
- package/lib/src/datastore.ts +45 -57
- package/lib/src/drag_manager.ts +23 -6
- package/lib/src/layout.ts +13 -1
- package/lib/src/router.ts +50 -9
- package/lib/src/version.ts +1 -1
- package/lib/types/action.d.ts +57 -0
- package/lib/types/app_sockets.d.ts +29 -0
- package/lib/types/application.d.ts +104 -0
- package/lib/types/autocomplete.d.ts +58 -0
- package/lib/types/base_component.d.ts +88 -0
- package/lib/types/button.d.ts +151 -0
- package/lib/types/calendar.d.ts +82 -0
- package/lib/types/canvas.d.ts +92 -0
- package/lib/types/cardview.d.ts +87 -0
- package/lib/types/checkbox.d.ts +77 -0
- package/lib/types/color.d.ts +148 -0
- package/lib/types/colorpicker.d.ts +107 -0
- package/lib/types/combobox.d.ts +107 -0
- package/lib/types/component.d.ts +601 -0
- package/lib/types/datastore.d.ts +396 -0
- package/lib/types/dialog.d.ts +175 -0
- package/lib/types/dom_events.d.ts +302 -0
- package/lib/types/drag_manager.d.ts +58 -0
- package/lib/types/drawtext.d.ts +48 -0
- package/lib/types/fileupload.d.ts +64 -0
- package/lib/types/form.d.ts +133 -0
- package/lib/types/formatters.d.ts +35 -0
- package/lib/types/gridview.d.ts +175 -0
- package/lib/types/i18n.d.ts +73 -0
- package/lib/types/icon.d.ts +64 -0
- package/lib/types/image.d.ts +55 -0
- package/lib/types/index.d.ts +84 -5896
- package/lib/types/input.d.ts +91 -0
- package/lib/types/label.d.ts +58 -0
- package/lib/types/layout.d.ts +89 -0
- package/lib/types/link.d.ts +50 -0
- package/lib/types/listview.d.ts +178 -0
- package/lib/types/md5.d.ts +61 -0
- package/lib/types/menu.d.ts +130 -0
- package/lib/types/messagebox.d.ts +69 -0
- package/lib/types/panel.d.ts +47 -0
- package/lib/types/popup.d.ts +75 -0
- package/lib/types/property_editor.d.ts +71 -0
- package/lib/types/radiobtn.d.ts +73 -0
- package/lib/types/rating.d.ts +53 -0
- package/lib/types/request.d.ts +52 -0
- package/lib/types/router.d.ts +67 -0
- package/lib/types/settings.d.ts +37 -0
- package/lib/types/sidebarview.d.ts +49 -0
- package/lib/types/spreadsheet.d.ts +222 -0
- package/lib/types/styles.d.ts +85 -0
- package/lib/types/svgcomponent.d.ts +215 -0
- package/lib/types/tabbar.d.ts +58 -0
- package/lib/types/tabview.d.ts +49 -0
- package/lib/types/textarea.d.ts +77 -0
- package/lib/types/textedit.d.ts +123 -0
- package/lib/types/toaster.d.ts +42 -0
- package/lib/types/tools.d.ts +394 -0
- package/lib/types/tooltips.d.ts +46 -0
- package/lib/types/treeview.d.ts +144 -0
- package/lib/types/version.d.ts +29 -0
- package/lib/types/x4dom.d.ts +49 -0
- package/lib/types/x4events.d.ts +269 -0
- package/lib/types/x4react.d.ts +41 -0
- package/package.json +1 -1
package/lib/src/component.ts
CHANGED
|
@@ -174,6 +174,7 @@ interface CInternalProps {
|
|
|
174
174
|
dom_events: any;
|
|
175
175
|
classes: IMap<boolean>;
|
|
176
176
|
uid: number;
|
|
177
|
+
created: boolean;
|
|
177
178
|
inrender: boolean;
|
|
178
179
|
}
|
|
179
180
|
|
|
@@ -891,6 +892,18 @@ export class Component<P extends CProps<CEventMap> = CProps<CEventMap>, E extend
|
|
|
891
892
|
|
|
892
893
|
// notify descendants that we have been created (dom exists)
|
|
893
894
|
|
|
895
|
+
const notify = ( c: Component ) => {
|
|
896
|
+
|
|
897
|
+
if( !c.m_iprops.created ) {
|
|
898
|
+
if (c.dom && c.m_iprops.dom_events && c.m_iprops.dom_events.create) {
|
|
899
|
+
c.dom.dispatchEvent(new Event('create'));
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
c.componentCreated();
|
|
903
|
+
c.m_iprops.created = true;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
894
907
|
for (let mutation of mutations) {
|
|
895
908
|
|
|
896
909
|
if (mutation.type == 'childList') {
|
|
@@ -902,24 +915,16 @@ export class Component<P extends CProps<CEventMap> = CProps<CEventMap>, E extend
|
|
|
902
915
|
|
|
903
916
|
if (el) {
|
|
904
917
|
el.enumChilds((c: Component) => {
|
|
905
|
-
|
|
906
|
-
if (c.dom && c.m_iprops.dom_events && c.m_iprops.dom_events.create) {
|
|
907
|
-
c.dom.dispatchEvent(new Event('create'));
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
c.componentCreated();
|
|
911
|
-
|
|
918
|
+
notify( c );
|
|
912
919
|
}, true);
|
|
913
920
|
|
|
914
|
-
|
|
915
|
-
el.dom.dispatchEvent(new Event('create'));
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
el.componentCreated();
|
|
921
|
+
notify( el );
|
|
919
922
|
}
|
|
920
923
|
}
|
|
921
924
|
}
|
|
922
925
|
}
|
|
926
|
+
|
|
927
|
+
|
|
923
928
|
}
|
|
924
929
|
|
|
925
930
|
public dispose() {
|
|
@@ -953,6 +958,7 @@ export class Component<P extends CProps<CEventMap> = CProps<CEventMap>, E extend
|
|
|
953
958
|
}
|
|
954
959
|
|
|
955
960
|
this.componentDisposed();
|
|
961
|
+
this.m_iprops.created = false;
|
|
956
962
|
// todo: pb on update this.removeAllListeners( null );
|
|
957
963
|
}
|
|
958
964
|
|
package/lib/src/datastore.ts
CHANGED
|
@@ -39,7 +39,6 @@ export type FieldType = 'string' | 'int' | 'float' | 'date' | 'bool' | 'array' |
|
|
|
39
39
|
export type DataIndex = Uint32Array;
|
|
40
40
|
|
|
41
41
|
interface EvDataChange extends BasicEvent {
|
|
42
|
-
|
|
43
42
|
type: string;
|
|
44
43
|
id: any;
|
|
45
44
|
}
|
|
@@ -49,6 +48,8 @@ function EvDataChange( type: 'create' | 'update' | 'delete' | 'data' | 'change',
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
|
|
51
|
+
|
|
52
|
+
|
|
52
53
|
/**
|
|
53
54
|
* fields definition
|
|
54
55
|
* field with index=0 is record id
|
|
@@ -553,55 +554,55 @@ interface DataEventMap extends BaseComponentEventMap {
|
|
|
553
554
|
change?: EvChange;
|
|
554
555
|
}
|
|
555
556
|
|
|
557
|
+
type DataSolver = ( data: any ) => Record[];
|
|
558
|
+
|
|
556
559
|
export interface DataProxyProps extends BaseComponentProps<DataEventMap> {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
+
url: string;
|
|
561
|
+
params?: string[];
|
|
562
|
+
solver?: DataSolver;
|
|
560
563
|
}
|
|
561
564
|
|
|
562
565
|
export class DataProxy extends BaseComponent<DataProxyProps,DataEventMap> {
|
|
563
|
-
|
|
566
|
+
|
|
564
567
|
constructor( props: DataProxyProps ) {
|
|
565
568
|
super( props );
|
|
566
569
|
}
|
|
567
570
|
|
|
568
|
-
load( ) {
|
|
571
|
+
load( url?: string ) {
|
|
572
|
+
if( url ) {
|
|
573
|
+
this.m_props.url = url;
|
|
574
|
+
}
|
|
575
|
+
|
|
569
576
|
this._refresh( );
|
|
570
577
|
}
|
|
571
578
|
|
|
572
|
-
save( data ) {
|
|
573
|
-
if( this.m_props.type=='local' ) {
|
|
574
|
-
console.assert( false ); // not imp
|
|
575
|
-
/*
|
|
576
|
-
const fs = require('fs');
|
|
577
|
-
fs.writeFileSync( this.m_path, data );
|
|
578
|
-
*/
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
579
|
private _refresh( delay: number = 0 ) {
|
|
583
580
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
581
|
+
const load = async ( ) => {
|
|
582
|
+
|
|
583
|
+
let url = this.m_props.url;
|
|
584
|
+
if( this.m_props.params ) {
|
|
585
|
+
url += '?' + this.m_props.params.join( '&' );
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const r = await fetch( url );
|
|
589
|
+
if( r.ok ) {
|
|
590
|
+
const raw = await r.json( );
|
|
591
|
+
|
|
592
|
+
let json = raw;
|
|
593
|
+
if( this.m_props.solver ) {
|
|
594
|
+
json = this.m_props.solver( json );
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
this.emit( 'change', EvChange(json,raw) );
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if( delay ) {
|
|
602
|
+
setTimeout( load, delay );
|
|
593
603
|
}
|
|
594
604
|
else {
|
|
595
|
-
|
|
596
|
-
ajaxRequest( {
|
|
597
|
-
url: this.m_props.path,
|
|
598
|
-
method: 'GET',
|
|
599
|
-
params: this.m_props.params,
|
|
600
|
-
success: ( data ) => {
|
|
601
|
-
this.emit( 'change', EvChange(data) );
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
}, delay );
|
|
605
|
+
load( );
|
|
605
606
|
}
|
|
606
607
|
}
|
|
607
608
|
}
|
|
@@ -650,7 +651,13 @@ export class DataStore extends EventSource<DataStoreEventMap> {
|
|
|
650
651
|
this.setRawData( props.data );
|
|
651
652
|
}
|
|
652
653
|
else if( props.url ) {
|
|
653
|
-
this.
|
|
654
|
+
this.m_proxy = new DataProxy( {
|
|
655
|
+
url: props.url,
|
|
656
|
+
solver: props.solver,
|
|
657
|
+
events: { change: (ev) => { this.setData( ev.value ); } }
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
this.m_proxy.load( );
|
|
654
661
|
}
|
|
655
662
|
}
|
|
656
663
|
|
|
@@ -659,27 +666,8 @@ export class DataStore extends EventSource<DataStoreEventMap> {
|
|
|
659
666
|
* @param records
|
|
660
667
|
*/
|
|
661
668
|
|
|
662
|
-
load( url
|
|
663
|
-
|
|
664
|
-
//todo: that
|
|
665
|
-
if( url.substr(0,7)==='file://' ) {
|
|
666
|
-
this.m_proxy = new DataProxy( {
|
|
667
|
-
type: 'local',
|
|
668
|
-
path: url.substr( 7 ),
|
|
669
|
-
events: { change: (ev) => { this.setData( ev.value ); } }
|
|
670
|
-
});
|
|
671
|
-
|
|
672
|
-
this.m_proxy.load( );
|
|
673
|
-
}
|
|
674
|
-
else {
|
|
675
|
-
this.m_proxy = new DataProxy( {
|
|
676
|
-
type: 'ajax',
|
|
677
|
-
path: url,
|
|
678
|
-
events: { change: (ev) => { this.setData( ev.value ); } }
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
this.m_proxy.load( );
|
|
682
|
-
}
|
|
669
|
+
load( url?: string ) {
|
|
670
|
+
this.m_proxy.load( url );
|
|
683
671
|
}
|
|
684
672
|
|
|
685
673
|
reload( ) {
|
package/lib/src/drag_manager.ts
CHANGED
|
@@ -34,7 +34,12 @@ import { Point } from './tools';
|
|
|
34
34
|
|
|
35
35
|
const x_drag_cb = Symbol( 'x-drag-cb' );
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
interface DropInfo {
|
|
38
|
+
pt: Point;
|
|
39
|
+
data: DataTransfer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type DropCallback = ( command: 'enter' | 'leave' | 'drag' | 'drop', el: Component, infos: DropInfo ) => void;
|
|
38
43
|
type FilterCallback = ( el: Component ) => boolean;
|
|
39
44
|
|
|
40
45
|
/**
|
|
@@ -91,10 +96,10 @@ class DragManager {
|
|
|
91
96
|
*
|
|
92
97
|
*/
|
|
93
98
|
|
|
94
|
-
registerDropTarget(el: Component, cb: DropCallback, filterCB
|
|
99
|
+
registerDropTarget(el: Component, cb: DropCallback, filterCB?: FilterCallback ) {
|
|
95
100
|
|
|
96
101
|
const dragEnter = (ev: DragEvent) => {
|
|
97
|
-
if( !filterCB(this.dragSource) ) {
|
|
102
|
+
if( filterCB && !filterCB(this.dragSource) ) {
|
|
98
103
|
console.log( 'reject ', el );
|
|
99
104
|
ev.dataTransfer.dropEffect = 'none';
|
|
100
105
|
return;
|
|
@@ -108,7 +113,7 @@ class DragManager {
|
|
|
108
113
|
const dragOver = (ev: DragEvent) => {
|
|
109
114
|
//console.log( "dragover", ev.target );
|
|
110
115
|
|
|
111
|
-
if( !filterCB(this.dragSource) ) {
|
|
116
|
+
if( filterCB && !filterCB(this.dragSource) ) {
|
|
112
117
|
console.log( 'reject ', el );
|
|
113
118
|
ev.dataTransfer.dropEffect = 'none';
|
|
114
119
|
return;
|
|
@@ -122,7 +127,12 @@ class DragManager {
|
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
if( this.dropTarget ) {
|
|
125
|
-
|
|
130
|
+
const infos = {
|
|
131
|
+
pt: new Point( ev.pageX, ev.pageY ),
|
|
132
|
+
data: ev.dataTransfer,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
cb( 'drag', this.dragSource, infos );
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
ev.dataTransfer.dropEffect = 'copy';
|
|
@@ -135,10 +145,17 @@ class DragManager {
|
|
|
135
145
|
};
|
|
136
146
|
|
|
137
147
|
const drop = (ev: DragEvent) => {
|
|
138
|
-
|
|
148
|
+
const infos = {
|
|
149
|
+
pt: new Point( ev.pageX, ev.pageY ),
|
|
150
|
+
data: ev.dataTransfer,
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
cb('drop', this.dragSource, infos );
|
|
139
154
|
|
|
140
155
|
this.dropTarget = null;
|
|
141
156
|
el.removeClass('drop-over');
|
|
157
|
+
|
|
158
|
+
ev.preventDefault();
|
|
142
159
|
}
|
|
143
160
|
|
|
144
161
|
el.setDomEvent('dragenter', dragEnter);
|
package/lib/src/layout.ts
CHANGED
|
@@ -153,7 +153,8 @@ interface CellData {
|
|
|
153
153
|
width?: number;
|
|
154
154
|
height?: number;
|
|
155
155
|
cls?: string;
|
|
156
|
-
item
|
|
156
|
+
item?: ComponentContent;
|
|
157
|
+
data?: any;
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
export class TableLayout extends Container<TableLayoutProps> {
|
|
@@ -204,6 +205,17 @@ export class TableLayout extends Container<TableLayoutProps> {
|
|
|
204
205
|
this._setCell(row, col, cell, true);
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
setCellData(row: number, col: number, data: any ) {
|
|
209
|
+
let cell = this._getCell(row, col);
|
|
210
|
+
cell.data = data;
|
|
211
|
+
this._setCell(row, col, cell, true);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getCellData(row: number, col: number ) {
|
|
215
|
+
let cell = this._getCell(row, col, false);
|
|
216
|
+
return cell?.data;
|
|
217
|
+
}
|
|
218
|
+
|
|
207
219
|
merge(row: number, col: number, rowCount: number, colCount: number) {
|
|
208
220
|
let cell = this._getCell(row, col);
|
|
209
221
|
cell.rowSpan = rowCount;
|
package/lib/src/router.ts
CHANGED
|
@@ -93,18 +93,46 @@ function parseRoute(str: string | RegExp, loose = false): Segment {
|
|
|
93
93
|
interface RouterEventMap extends EventMap {
|
|
94
94
|
error: EvError;
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* micro router
|
|
100
|
+
*
|
|
101
|
+
* ```
|
|
102
|
+
* const router = new Router( );
|
|
103
|
+
*
|
|
104
|
+
* router.get( "/detail/:id", ( params: any ) => {
|
|
105
|
+
* this._showDetail( detail );
|
|
106
|
+
* } );
|
|
107
|
+
*
|
|
108
|
+
* router.get( "/:id", ( params: any ) => {
|
|
109
|
+
* if( params.id==0 )
|
|
110
|
+
* router.navigate( '/home' );
|
|
111
|
+
* }
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* router.on( "error", ( ) => {
|
|
115
|
+
* router.navigate( '/home' );
|
|
116
|
+
* })
|
|
117
|
+
*
|
|
118
|
+
* router.init( );
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
|
|
97
123
|
export class Router extends EventSource< RouterEventMap > {
|
|
98
124
|
|
|
99
|
-
private
|
|
125
|
+
private m_routes: Route[];
|
|
126
|
+
private m_useHash: boolean;
|
|
100
127
|
|
|
101
|
-
constructor() {
|
|
128
|
+
constructor( useHash = true ) {
|
|
102
129
|
super( );
|
|
103
130
|
|
|
104
|
-
this.
|
|
131
|
+
this.m_routes = [];
|
|
132
|
+
this.m_useHash = useHash;
|
|
105
133
|
|
|
106
134
|
window.addEventListener('popstate', (event) => {
|
|
107
|
-
const url =
|
|
135
|
+
const url = this._getLocation( );
|
|
108
136
|
const found = this._find(url);
|
|
109
137
|
|
|
110
138
|
found.handlers.forEach(h => {
|
|
@@ -115,11 +143,15 @@ export class Router extends EventSource< RouterEventMap > {
|
|
|
115
143
|
|
|
116
144
|
get(uri: string | RegExp, handler: RouteHandler ) {
|
|
117
145
|
let { keys, pattern } = parseRoute(uri);
|
|
118
|
-
this.
|
|
146
|
+
this.m_routes.push({ keys, pattern, handler });
|
|
119
147
|
}
|
|
120
148
|
|
|
121
149
|
init() {
|
|
122
|
-
this.navigate(
|
|
150
|
+
this.navigate( this._getLocation() );
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private _getLocation( ) {
|
|
154
|
+
return this.m_useHash ? '/'+x4document.location.hash.substring(1) : x4document.location.pathname;
|
|
123
155
|
}
|
|
124
156
|
|
|
125
157
|
navigate( uri: string, notify = true ) {
|
|
@@ -133,7 +165,16 @@ export class Router extends EventSource< RouterEventMap > {
|
|
|
133
165
|
return;
|
|
134
166
|
}
|
|
135
167
|
|
|
136
|
-
|
|
168
|
+
if( this.m_useHash ) {
|
|
169
|
+
while( uri.startsWith('/') ) {
|
|
170
|
+
uri = uri.substring( 1 );
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
window.history.pushState({}, '', '#'+uri );
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
window.history.pushState({}, '', uri );
|
|
177
|
+
}
|
|
137
178
|
|
|
138
179
|
if( notify ) {
|
|
139
180
|
found.handlers.forEach( h => {
|
|
@@ -148,7 +189,7 @@ export class Router extends EventSource< RouterEventMap > {
|
|
|
148
189
|
let params = {};
|
|
149
190
|
let handlers = [];
|
|
150
191
|
|
|
151
|
-
for (const tmp of this.
|
|
192
|
+
for (const tmp of this.m_routes ) {
|
|
152
193
|
if (!tmp.keys ) {
|
|
153
194
|
matches = tmp.pattern.exec(url);
|
|
154
195
|
if (!matches) {
|
package/lib/src/version.ts
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file action.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
|
+
import { BasicEvent, EvChange } from './x4events';
|
|
30
|
+
import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component';
|
|
31
|
+
import { IconID } from "./icon";
|
|
32
|
+
import { EventHandler } from './component';
|
|
33
|
+
export interface EvAction extends BasicEvent {
|
|
34
|
+
}
|
|
35
|
+
export declare function EvAction(source: Action): EvAction;
|
|
36
|
+
interface ActionEventMap extends BaseComponentEventMap {
|
|
37
|
+
run: EvAction;
|
|
38
|
+
change: EvChange;
|
|
39
|
+
}
|
|
40
|
+
interface ActionProps extends BaseComponentProps<ActionEventMap> {
|
|
41
|
+
id?: any;
|
|
42
|
+
text?: string;
|
|
43
|
+
icon?: IconID;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
checked?: boolean;
|
|
47
|
+
run: EventHandler<EvAction>;
|
|
48
|
+
change?: EventHandler<EvChange>;
|
|
49
|
+
}
|
|
50
|
+
export declare class Action extends BaseComponent<ActionProps, ActionEventMap> {
|
|
51
|
+
constructor(props: ActionProps);
|
|
52
|
+
get props(): ActionProps;
|
|
53
|
+
set text(t: string);
|
|
54
|
+
set icon(i: IconID);
|
|
55
|
+
fire(): void;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file app_sockets.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
|
+
export declare function setupWSMessaging(closeCB: () => void): void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file application.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
|
+
import { EvMessage } from './x4events';
|
|
30
|
+
import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component';
|
|
31
|
+
import { Component } from './component';
|
|
32
|
+
import { Settings } from './settings';
|
|
33
|
+
interface ApplicationEventMap extends BaseComponentEventMap {
|
|
34
|
+
message: EvMessage;
|
|
35
|
+
global: EvMessage;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
export interface ApplicationProps extends BaseComponentProps<ApplicationEventMap> {
|
|
41
|
+
app_name: string;
|
|
42
|
+
app_version: string;
|
|
43
|
+
app_uid?: string;
|
|
44
|
+
locale?: string;
|
|
45
|
+
renderTo?: HTMLElement;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents an x4 application, which is typically a single page app.
|
|
49
|
+
* You should inherit Application to define yours.
|
|
50
|
+
* Application derives from BaseComponent so you can use that to implement a global messaging system.
|
|
51
|
+
* @example ```ts
|
|
52
|
+
*
|
|
53
|
+
* // in yout main caode
|
|
54
|
+
* let app = new Application( );
|
|
55
|
+
*
|
|
56
|
+
* app.events.close.on( ( ev ) => {
|
|
57
|
+
* ... do something
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // somewhere else in the source
|
|
61
|
+
* function xxx( ) {
|
|
62
|
+
* let app = Application.instance( );
|
|
63
|
+
* app.events.close.emit( new Events.close() );
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export declare class Application<P extends ApplicationProps = ApplicationProps, E extends ApplicationEventMap = ApplicationEventMap> extends BaseComponent<P, E> {
|
|
67
|
+
private static self;
|
|
68
|
+
/**
|
|
69
|
+
* the application singleton
|
|
70
|
+
*/
|
|
71
|
+
static instance(): Application;
|
|
72
|
+
private m_mainView;
|
|
73
|
+
private m_app_name;
|
|
74
|
+
private m_app_version;
|
|
75
|
+
private m_app_uid;
|
|
76
|
+
private m_local_storage;
|
|
77
|
+
private m_user_data;
|
|
78
|
+
private m_touch_time;
|
|
79
|
+
private m_touch_count;
|
|
80
|
+
constructor(props: P);
|
|
81
|
+
ApplicationCreated(): void;
|
|
82
|
+
get app_name(): string;
|
|
83
|
+
get app_uid(): string;
|
|
84
|
+
get app_version(): string;
|
|
85
|
+
get local_storage(): Settings;
|
|
86
|
+
get user_data(): any;
|
|
87
|
+
get history(): any;
|
|
88
|
+
/**
|
|
89
|
+
* define the application root object (MainView)
|
|
90
|
+
* @example ```ts
|
|
91
|
+
*
|
|
92
|
+
* let myApp = new Application( ... );
|
|
93
|
+
* let mainView = new VLayout( ... );
|
|
94
|
+
* myApp.mainView = mainView;
|
|
95
|
+
*/
|
|
96
|
+
setMainView(root: Component, clearBefore: boolean): void;
|
|
97
|
+
set mainView(root: Component);
|
|
98
|
+
get mainView(): Component;
|
|
99
|
+
setTitle(title: string): void;
|
|
100
|
+
disableZoomWheel(): void;
|
|
101
|
+
enterModal(enter: boolean): void;
|
|
102
|
+
enableTouchDblClick(): void;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file autocomplete.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
|
+
import { TextEdit, TextEditProps } from './textedit';
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
interface AutoCompleteProps extends TextEditProps {
|
|
34
|
+
enumValues: (filter: string) => string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export declare class AutoComplete extends TextEdit<AutoCompleteProps> {
|
|
40
|
+
private m_popup;
|
|
41
|
+
private m_popvis;
|
|
42
|
+
private m_needval;
|
|
43
|
+
private m_lockpop;
|
|
44
|
+
constructor(props: AutoCompleteProps);
|
|
45
|
+
_onKey(e: KeyboardEvent): void;
|
|
46
|
+
private _onChange;
|
|
47
|
+
componentDisposed(): void;
|
|
48
|
+
/**
|
|
49
|
+
* display the popup
|
|
50
|
+
*/
|
|
51
|
+
showPopup(items: string[]): void;
|
|
52
|
+
protected _validate(value: string): boolean;
|
|
53
|
+
validate(): boolean;
|
|
54
|
+
private _checkFocus;
|
|
55
|
+
private _hidePopup;
|
|
56
|
+
private _onFocus;
|
|
57
|
+
}
|
|
58
|
+
export {};
|