x4js 1.5.16 → 1.5.18
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/app_sockets.js +74 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/treeview.js +27 -12
- package/lib/cjs/version.js +1 -1
- package/lib/esm/app_sockets.js +70 -0
- package/lib/esm/index.mjs +1 -0
- package/lib/esm/treeview.js +26 -12
- package/lib/esm/version.js +1 -1
- package/lib/{src/version.ts → types/app_sockets.d.ts} +29 -30
- package/lib/types/index.d.ts +1 -0
- package/lib/types/treeview.d.ts +5 -2
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -4
- package/lib/src/MIT-license.md +0 -14
- package/lib/src/action.ts +0 -88
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/application.ts +0 -251
- package/lib/src/autocomplete.ts +0 -197
- package/lib/src/base64.ts +0 -166
- package/lib/src/base_component.ts +0 -152
- package/lib/src/button.ts +0 -355
- package/lib/src/calendar.ts +0 -328
- package/lib/src/canvas.ts +0 -505
- package/lib/src/cardview.ts +0 -227
- package/lib/src/checkbox.ts +0 -188
- package/lib/src/color.ts +0 -752
- package/lib/src/colorpicker.ts +0 -1639
- package/lib/src/combobox.ts +0 -465
- package/lib/src/component.ts +0 -2329
- package/lib/src/datastore.ts +0 -1322
- package/lib/src/dialog.ts +0 -656
- package/lib/src/dom_events.ts +0 -315
- package/lib/src/drag_manager.ts +0 -199
- package/lib/src/drawtext.ts +0 -355
- package/lib/src/fileupload.ts +0 -213
- package/lib/src/form.ts +0 -375
- package/lib/src/formatters.ts +0 -105
- package/lib/src/gridview.ts +0 -1185
- package/lib/src/i18n.ts +0 -346
- package/lib/src/icon.ts +0 -335
- package/lib/src/image.ts +0 -204
- package/lib/src/index.ts +0 -88
- package/lib/src/input.ts +0 -249
- package/lib/src/label.ts +0 -128
- package/lib/src/layout.ts +0 -430
- package/lib/src/link.ts +0 -86
- package/lib/src/listview.ts +0 -765
- package/lib/src/md5.ts +0 -438
- package/lib/src/menu.ts +0 -425
- package/lib/src/messagebox.ts +0 -224
- package/lib/src/panel.ts +0 -86
- package/lib/src/popup.ts +0 -494
- package/lib/src/property_editor.ts +0 -337
- package/lib/src/radiobtn.ts +0 -197
- package/lib/src/rating.ts +0 -135
- package/lib/src/request.ts +0 -300
- package/lib/src/router.ts +0 -185
- package/lib/src/settings.ts +0 -77
- package/lib/src/sidebarview.ts +0 -103
- package/lib/src/spreadsheet.ts +0 -1449
- package/lib/src/styles.ts +0 -343
- package/lib/src/svgcomponent.ts +0 -577
- package/lib/src/tabbar.ts +0 -151
- package/lib/src/tabview.ts +0 -110
- package/lib/src/textarea.ts +0 -235
- package/lib/src/textedit.ts +0 -544
- package/lib/src/toaster.ts +0 -80
- package/lib/src/tools.ts +0 -1473
- package/lib/src/tooltips.ts +0 -191
- package/lib/src/treeview.ts +0 -696
- package/lib/src/x4.less +0 -2243
- package/lib/src/x4dom.ts +0 -57
- package/lib/src/x4events.ts +0 -585
- package/lib/src/x4react.ts +0 -90
- package/lib/x4.css +0 -1780
package/lib/src/application.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
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
|
-
|
|
30
|
-
import { x4document } from './x4dom'
|
|
31
|
-
import { EvMessage } from './x4events'
|
|
32
|
-
import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component'
|
|
33
|
-
import { Component, flyWrap } from './component'
|
|
34
|
-
import { Settings } from './settings'
|
|
35
|
-
import { _tr } from './i18n'
|
|
36
|
-
|
|
37
|
-
const _x4_touch_time = Symbol( );
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
interface ApplicationEventMap extends BaseComponentEventMap {
|
|
41
|
-
message: EvMessage;
|
|
42
|
-
global: EvMessage;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
export interface ApplicationProps extends BaseComponentProps<ApplicationEventMap> {
|
|
50
|
-
app_name: string; //
|
|
51
|
-
app_version: string; //
|
|
52
|
-
app_uid?: string;
|
|
53
|
-
locale?: string; // fr-FR
|
|
54
|
-
renderTo?: HTMLElement;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Represents an x4 application, which is typically a single page app.
|
|
59
|
-
* You should inherit Application to define yours.
|
|
60
|
-
* Application derives from BaseComponent so you can use that to implement a global messaging system.
|
|
61
|
-
* @example ```ts
|
|
62
|
-
*
|
|
63
|
-
* // in yout main caode
|
|
64
|
-
* let app = new Application( );
|
|
65
|
-
*
|
|
66
|
-
* app.events.close.on( ( ev ) => {
|
|
67
|
-
* ... do something
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* // somewhere else in the source
|
|
71
|
-
* function xxx( ) {
|
|
72
|
-
* let app = Application.instance( );
|
|
73
|
-
* app.events.close.emit( new Events.close() );
|
|
74
|
-
* }
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
export class Application<P extends ApplicationProps = ApplicationProps, E extends ApplicationEventMap = ApplicationEventMap> extends BaseComponent<P,E> {
|
|
78
|
-
|
|
79
|
-
private static self: Application = null;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* the application singleton
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
static instance( ) : Application {
|
|
86
|
-
return Application.self;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private m_mainView: Component;
|
|
90
|
-
|
|
91
|
-
private m_app_name: string;
|
|
92
|
-
private m_app_version: string;
|
|
93
|
-
private m_app_uid: string;
|
|
94
|
-
|
|
95
|
-
private m_local_storage: Settings;
|
|
96
|
-
private m_user_data: any;
|
|
97
|
-
|
|
98
|
-
private m_touch_time: number;
|
|
99
|
-
private m_touch_count: number;
|
|
100
|
-
|
|
101
|
-
constructor( props : P ) {
|
|
102
|
-
console.assert( Application.self===null, 'application is a singleton' );
|
|
103
|
-
super( props );
|
|
104
|
-
|
|
105
|
-
this.m_app_name = props.app_name ?? 'application';
|
|
106
|
-
this.m_app_version = props.app_version ?? '1.0';
|
|
107
|
-
this.m_app_uid = props.app_uid ?? 'application';
|
|
108
|
-
|
|
109
|
-
let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
|
|
110
|
-
this.m_local_storage = new Settings( settings_name );
|
|
111
|
-
this.m_user_data = {};
|
|
112
|
-
|
|
113
|
-
this.m_touch_time = 0;
|
|
114
|
-
this.m_touch_count = 0;
|
|
115
|
-
|
|
116
|
-
(Application.self as any) = this;
|
|
117
|
-
|
|
118
|
-
if( 'onload' in globalThis ) {
|
|
119
|
-
globalThis.addEventListener( 'load', ( ) => {
|
|
120
|
-
this.ApplicationCreated( );
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
this.ApplicationCreated( );
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
ApplicationCreated( ) {
|
|
129
|
-
this.setTitle( '' );
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public get app_name( ) {
|
|
133
|
-
return this.m_app_name;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public get app_uid( ) {
|
|
137
|
-
return this.m_app_uid;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public get app_version( ) {
|
|
141
|
-
return this.m_app_version;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public get local_storage( ) {
|
|
145
|
-
return this.m_local_storage;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public get user_data( ) {
|
|
149
|
-
return this.m_user_data;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public get history( ) {
|
|
153
|
-
//if( !this.m_history ) {
|
|
154
|
-
// this.m_history = new NavigationHistory( );
|
|
155
|
-
//}
|
|
156
|
-
//
|
|
157
|
-
//return this.m_history;
|
|
158
|
-
debugger;
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* define the application root object (MainView)
|
|
164
|
-
* @example ```ts
|
|
165
|
-
*
|
|
166
|
-
* let myApp = new Application( ... );
|
|
167
|
-
* let mainView = new VLayout( ... );
|
|
168
|
-
* myApp.mainView = mainView;
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
public setMainView( root: Component, clearBefore: boolean ) {
|
|
172
|
-
|
|
173
|
-
const ddom = this.m_props.renderTo ?? x4document.body;
|
|
174
|
-
const dest = flyWrap( ddom );
|
|
175
|
-
|
|
176
|
-
if( !this.m_props.renderTo ) {
|
|
177
|
-
dest.setStyleValue( 'position', 'absolute' );
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
dest.addClass( 'x4-root-element' );
|
|
181
|
-
if( clearBefore ) {
|
|
182
|
-
dest._empty( );
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
this.m_mainView = root;
|
|
186
|
-
|
|
187
|
-
root.setStyleValue( 'position', 'absolute' );
|
|
188
|
-
root._build();
|
|
189
|
-
|
|
190
|
-
ddom.appendChild( root.dom );
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
set mainView( root: Component ) {
|
|
194
|
-
this.setMainView( root, false );
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public get mainView( ) : Component {
|
|
198
|
-
return this.m_mainView;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
public setTitle( title: string ) {
|
|
202
|
-
x4document.title = this.m_app_name + (title ? (' > ' + title) : '');
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public disableZoomWheel( ) {
|
|
206
|
-
|
|
207
|
-
window.addEventListener('wheel', function( ev: WheelEvent ) {
|
|
208
|
-
if( ev.ctrlKey ) {
|
|
209
|
-
ev.preventDefault( );
|
|
210
|
-
//ev.stopPropagation( );
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
}, { passive: false, capture: true } );
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
public enterModal( enter: boolean ) {
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public enableTouchDblClick( ) {
|
|
220
|
-
x4document.addEventListener( 'touchstart', ( ev: TouchEvent ) => {
|
|
221
|
-
|
|
222
|
-
let now = Date.now( );
|
|
223
|
-
if( (now-this.m_touch_time) > 700 ) {
|
|
224
|
-
this.m_touch_count = 1;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
this.m_touch_count++;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
this.m_touch_time = now;
|
|
231
|
-
|
|
232
|
-
if( this.m_touch_count==2 ) {
|
|
233
|
-
this.m_touch_count = 0;
|
|
234
|
-
|
|
235
|
-
// dirty fake dblclick event
|
|
236
|
-
const tch = ev.touches[0];
|
|
237
|
-
let fake: any = {type: "dblclick" };
|
|
238
|
-
for( const n in tch ) {
|
|
239
|
-
fake[n] = tch[n];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// ignore -> private: dirty x2
|
|
243
|
-
(Component as any)._dispatchEvent( fake );
|
|
244
|
-
ev.stopPropagation( );
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
package/lib/src/autocomplete.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
|
|
30
|
-
import { ListViewItem, PopupListView } from "./listview";
|
|
31
|
-
import { TextEdit, TextEditProps } from './textedit';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
interface AutoCompleteProps extends TextEditProps {
|
|
38
|
-
enumValues: ( filter: string ) => string[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
export class AutoComplete extends TextEdit<AutoCompleteProps> {
|
|
46
|
-
|
|
47
|
-
private m_popup: PopupListView;
|
|
48
|
-
private m_popvis: boolean;
|
|
49
|
-
private m_needval: boolean;
|
|
50
|
-
private m_lockpop: boolean;
|
|
51
|
-
|
|
52
|
-
constructor( props: AutoCompleteProps ) {
|
|
53
|
-
super( props );
|
|
54
|
-
|
|
55
|
-
this.setDomEvent( "input", ( ) => this._onChange( ) );
|
|
56
|
-
this.setDomEvent( "focusin", ( ) => this._onFocus( ) );
|
|
57
|
-
this.startTimer( "focus-check", 100, true, () => this._checkFocus() );
|
|
58
|
-
|
|
59
|
-
this.m_popvis = false;
|
|
60
|
-
this.m_needval = false;
|
|
61
|
-
this.m_lockpop = false;
|
|
62
|
-
|
|
63
|
-
this.setDomEvent( "keydown", e => this._onKey(e) );
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
_onKey( e: KeyboardEvent ) {
|
|
67
|
-
if( this.m_popvis ) {
|
|
68
|
-
if( e.key=="ArrowUp" || e.key=="ArrowDown" ) {
|
|
69
|
-
this.m_lockpop = true;
|
|
70
|
-
this.m_popup.handleKey( e );
|
|
71
|
-
this.m_lockpop = false;
|
|
72
|
-
|
|
73
|
-
e.preventDefault( );
|
|
74
|
-
e.stopPropagation( );
|
|
75
|
-
}
|
|
76
|
-
else if( e.key=="Escape" ) {
|
|
77
|
-
this._hidePopup( );
|
|
78
|
-
|
|
79
|
-
e.preventDefault( );
|
|
80
|
-
e.stopPropagation( );
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if( e.key=="ArrowDown" ) {
|
|
84
|
-
this._onChange( );
|
|
85
|
-
e.preventDefault( );
|
|
86
|
-
e.stopPropagation( );
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private _onChange( ) {
|
|
91
|
-
const items = this.m_props.enumValues( this.value );
|
|
92
|
-
this.showPopup( items );
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
componentDisposed( ) {
|
|
96
|
-
if( this.m_popup ) {
|
|
97
|
-
this._hidePopup( );
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
super.componentDisposed( );
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* display the popup
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
showPopup( items: string[] ) {
|
|
108
|
-
|
|
109
|
-
let props = this.m_props;
|
|
110
|
-
if (props.readOnly || this.hasClass("@disable") ) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// need creation ?
|
|
115
|
-
|
|
116
|
-
if( !this.m_popup ) {
|
|
117
|
-
let cstyle = this.getComputedStyle( );
|
|
118
|
-
let fontFamily = cstyle.value( 'fontFamily' );
|
|
119
|
-
let fontSize = cstyle.value( 'fontSize' );
|
|
120
|
-
|
|
121
|
-
// prepare the combo listview
|
|
122
|
-
this.m_popup = new PopupListView({
|
|
123
|
-
cls: '@combo-popup',
|
|
124
|
-
attrs: {
|
|
125
|
-
tabindex: 0
|
|
126
|
-
},
|
|
127
|
-
selectionChange: (e) => {
|
|
128
|
-
this.value = (e.selection as ListViewItem).id
|
|
129
|
-
if( !this.m_lockpop ) {
|
|
130
|
-
this._hidePopup( );
|
|
131
|
-
this.focus( );
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
style: {
|
|
135
|
-
fontFamily,
|
|
136
|
-
fontSize
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.m_popup.items = items.map( c => ({ id: c, text: c }) );
|
|
142
|
-
|
|
143
|
-
let r1 = this.m_ui_input.getBoundingRect();
|
|
144
|
-
this.m_popup.setStyle({
|
|
145
|
-
minWidth: r1.width,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
this.m_popup.displayAt(r1.left, r1.bottom);
|
|
149
|
-
this.m_popvis = true;
|
|
150
|
-
|
|
151
|
-
//if( this.value!==undefined ) {
|
|
152
|
-
// this.m_popup.selection = this.value;
|
|
153
|
-
//}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
protected override _validate(value: string): boolean {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
override validate( ): boolean {
|
|
161
|
-
return super._validate( this.value );
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private _checkFocus( ) {
|
|
165
|
-
const focus = document.activeElement;
|
|
166
|
-
if( this.dom && this.dom.contains(focus) ) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if( this.m_popup && this.m_popup.dom && this.m_popup.dom.contains(focus) ) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
this._hidePopup( );
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private _hidePopup( ) {
|
|
178
|
-
|
|
179
|
-
if( this.m_popvis ) {
|
|
180
|
-
this.m_popup.close();
|
|
181
|
-
this.m_popvis = false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if( this.m_needval ) {
|
|
185
|
-
this.validate( );
|
|
186
|
-
this.m_needval = false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private _onFocus( ) {
|
|
191
|
-
if( this.value.length==0 ) {
|
|
192
|
-
this._onChange( );
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.m_needval = true;
|
|
196
|
-
}
|
|
197
|
-
}
|
package/lib/src/base64.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file base64.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
|
-
|
|
30
|
-
const _alphabet: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
31
|
-
let _lookup: any = null;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export class Base64 {
|
|
35
|
-
lookup: any = null;
|
|
36
|
-
|
|
37
|
-
static encode(s: string | Uint8Array ) {
|
|
38
|
-
let buffer;
|
|
39
|
-
|
|
40
|
-
if( s instanceof Uint8Array ) {
|
|
41
|
-
buffer = []
|
|
42
|
-
s.forEach( (v) => {
|
|
43
|
-
buffer.push( v );
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
buffer = Base64._toUtf8(s);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let position = -1;
|
|
51
|
-
let len = buffer.length;
|
|
52
|
-
let nan1, nan2;
|
|
53
|
-
let enc = [, , ,];
|
|
54
|
-
|
|
55
|
-
let result = '';
|
|
56
|
-
while (++position < len) {
|
|
57
|
-
nan1 = buffer[position + 1], nan2 = buffer[position + 2];
|
|
58
|
-
enc[0] = buffer[position] >> 2;
|
|
59
|
-
enc[1] = ((buffer[position] & 3) << 4) | (buffer[++position] >> 4);
|
|
60
|
-
|
|
61
|
-
if (isNaN(nan1)) {
|
|
62
|
-
enc[2] = enc[3] = 64;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
enc[2] = ((buffer[position] & 15) << 2) | (buffer[++position] >> 6);
|
|
66
|
-
enc[3] = (isNaN(nan2)) ? 64 : buffer[position] & 63;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
result += _alphabet[enc[0]] + _alphabet[enc[1]] + _alphabet[enc[2]] + _alphabet[enc[3]];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static decode(s: string) {
|
|
76
|
-
let buffer = Base64._fromUtf8(s);
|
|
77
|
-
|
|
78
|
-
let position = 0;
|
|
79
|
-
let len = buffer.length;
|
|
80
|
-
|
|
81
|
-
let result = '';
|
|
82
|
-
while (position < len) {
|
|
83
|
-
if (buffer[position] < 128) {
|
|
84
|
-
result += String.fromCharCode(buffer[position++]);
|
|
85
|
-
}
|
|
86
|
-
else if (buffer[position] > 191 && buffer[position] < 224) {
|
|
87
|
-
result += String.fromCharCode(((buffer[position++] & 31) << 6) | (buffer[position++] & 63));
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
result += String.fromCharCode(((buffer[position++] & 15) << 12) | ((buffer[position++] & 63) << 6) | (buffer[position++] & 63));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private static _toUtf8(s) {
|
|
98
|
-
let position = -1;
|
|
99
|
-
let len = s.length;
|
|
100
|
-
|
|
101
|
-
let chr;
|
|
102
|
-
let buffer = [];
|
|
103
|
-
|
|
104
|
-
if (/^[\x00-\x7f]*$/.test(s)) {
|
|
105
|
-
while (++position < len) {
|
|
106
|
-
buffer.push(s.charCodeAt(position));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
while (++position < len) {
|
|
111
|
-
chr = s.charCodeAt(position);
|
|
112
|
-
if (chr < 128) {
|
|
113
|
-
buffer.push(chr);
|
|
114
|
-
}
|
|
115
|
-
else if (chr < 2048) {
|
|
116
|
-
buffer.push((chr >> 6) | 192, (chr & 63) | 128);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
buffer.push((chr >> 12) | 224, ((chr >> 6) & 63) | 128, (chr & 63) | 128);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return buffer;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private static _fromUtf8(s) {
|
|
128
|
-
let position = -1;
|
|
129
|
-
let len;
|
|
130
|
-
let buffer = [];
|
|
131
|
-
let enc = [, , ,];
|
|
132
|
-
|
|
133
|
-
if (!_lookup) {
|
|
134
|
-
len = _alphabet.length;
|
|
135
|
-
_lookup = {};
|
|
136
|
-
while (++position < len) {
|
|
137
|
-
_lookup[_alphabet[position]] = position;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
position = -1;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
len = s.length;
|
|
144
|
-
while (position < len) {
|
|
145
|
-
enc[0] = _lookup[s.charAt(++position)];
|
|
146
|
-
enc[1] = _lookup[s.charAt(++position)];
|
|
147
|
-
buffer.push((enc[0] << 2) | (enc[1] >> 4));
|
|
148
|
-
|
|
149
|
-
enc[2] = _lookup[s.charAt(++position)];
|
|
150
|
-
if (enc[2] == 64) {
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
buffer.push(((enc[1] & 15) << 4) | (enc[2] >> 2));
|
|
155
|
-
enc[3] = _lookup[s.charAt(++position)];
|
|
156
|
-
|
|
157
|
-
if (enc[3] == 64) {
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
buffer.push(((enc[2] & 3) << 6) | enc[3]);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return buffer;
|
|
165
|
-
}
|
|
166
|
-
}
|