x4js 1.4.18 → 1.4.20
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/application.d.ts +1 -1
- package/lib/application.js +4 -3
- package/lib/base_component.d.ts +1 -1
- package/lib/base_component.js +3 -3
- package/lib/button.d.ts +1 -1
- package/lib/button.js +3 -3
- package/lib/calendar.d.ts +1 -1
- package/lib/calendar.js +5 -4
- package/lib/canvas.d.ts +1 -1
- package/lib/canvas.js +2 -2
- package/lib/cardview.d.ts +1 -1
- package/lib/cardview.js +2 -2
- package/lib/checkbox.d.ts +1 -1
- package/lib/checkbox.js +2 -2
- package/lib/colorpicker.d.ts +1 -1
- package/lib/colorpicker.js +5 -5
- package/lib/combobox.d.ts +1 -1
- package/lib/combobox.js +3 -3
- package/lib/component.d.ts +1 -5
- package/lib/component.js +35 -39
- package/lib/datastore.d.ts +1 -1
- package/lib/datastore.js +5 -5
- package/lib/dialog.d.ts +1 -1
- package/lib/dialog.js +4 -3
- package/lib/drag_manager.js +30 -1
- package/lib/fileupload.js +2 -1
- package/lib/form.d.ts +1 -1
- package/lib/gridview.d.ts +1 -5
- package/lib/gridview.js +8 -7
- package/lib/i18n.d.ts +35 -33
- package/lib/i18n.js +180 -93
- package/lib/icon.d.ts +1 -1
- package/lib/icon.js +10 -13
- package/lib/image.js +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/input.js +1 -1
- package/lib/link.d.ts +1 -1
- package/lib/link.js +2 -2
- package/lib/listview.d.ts +1 -1
- package/lib/listview.js +10 -9
- package/lib/menu.d.ts +1 -1
- package/lib/menu.js +5 -4
- package/lib/popup.d.ts +1 -1
- package/lib/popup.js +13 -12
- package/lib/property_editor.d.ts +1 -1
- package/lib/property_editor.js +2 -2
- package/lib/radiobtn.d.ts +1 -1
- package/lib/radiobtn.js +4 -3
- package/lib/rating.d.ts +1 -1
- package/lib/rating.js +2 -2
- package/lib/router.d.ts +1 -1
- package/lib/router.js +5 -4
- package/lib/spreadsheet.d.ts +1 -1
- package/lib/spreadsheet.js +9 -8
- package/lib/styles.js +6 -5
- package/lib/svgcomponent.d.ts +1 -1
- package/lib/svgcomponent.js +4 -1
- package/lib/tabbar.d.ts +1 -1
- package/lib/tabbar.js +2 -2
- package/lib/textarea.d.ts +1 -1
- package/lib/textarea.js +2 -2
- package/lib/textedit.d.ts +1 -1
- package/lib/textedit.js +5 -4
- package/lib/tools.d.ts +1 -0
- package/lib/tools.js +15 -6
- package/lib/tooltips.js +6 -5
- package/lib/treeview.d.ts +1 -1
- package/lib/treeview.js +8 -8
- package/lib/x4dom.d.ts +21 -0
- package/lib/x4dom.js +7 -0
- package/lib/x4events.d.ts +266 -0
- package/lib/x4events.js +389 -0
- package/package.json +4 -3
- package/src/application.ts +5 -4
- package/src/base_component.ts +1 -1
- package/src/button.ts +1 -1
- package/src/calendar.ts +5 -3
- package/src/canvas.ts +1 -1
- package/src/cardview.ts +1 -1
- package/src/checkbox.ts +1 -1
- package/src/colorpicker.ts +1 -1
- package/src/combobox.ts +1 -1
- package/src/component.ts +34 -39
- package/src/datastore.ts +1 -1
- package/src/dialog.ts +4 -2
- package/src/drag_manager.ts +4 -1
- package/src/fileupload.ts +2 -1
- package/src/form.ts +1 -1
- package/src/gridview.ts +4 -3
- package/src/hosts/electron.ts +4 -1
- package/src/i18n.ts +234 -97
- package/src/icon.ts +9 -12
- package/src/image.ts +5 -3
- package/src/index.ts +1 -1
- package/src/input.ts +1 -1
- package/src/layout.ts +1 -1
- package/src/link.ts +1 -1
- package/src/listview.ts +6 -4
- package/src/menu.ts +5 -3
- package/src/popup.ts +14 -12
- package/src/property_editor.ts +1 -1
- package/src/radiobtn.ts +4 -2
- package/src/rating.ts +1 -1
- package/src/router.ts +4 -2
- package/src/smartedit.ts +3 -2
- package/src/spreadsheet.ts +8 -6
- package/src/styles.ts +7 -5
- package/src/svgcomponent.ts +4 -1
- package/src/tabbar.ts +1 -1
- package/src/textarea.ts +1 -1
- package/src/textedit.ts +4 -2
- package/src/tools.ts +15 -5
- package/src/tooltips.ts +7 -5
- package/src/treeview.ts +1 -1
- package/src/x4dom.ts +57 -0
- package/src/{x4_events.ts → x4events.ts} +1 -1
- package/tsconfig.json +5 -1
package/lib/x4events.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \_/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / _ \____ _|
|
|
7
|
+
* /__/ \__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file observable.ts
|
|
10
|
+
* @author Etienne Cochard
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
* in the Software without restriction, including without limitation the rights
|
|
17
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
+
* or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
+
**/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.EventSource = exports.EvError = exports.EvDrag = exports.EvMessage = exports.EvTimer = exports.EvContextMenu = exports.EvSelectionChange = exports.EvChange = exports.EvClick = exports.BasicEvent = void 0;
|
|
32
|
+
// default stopPropagation implementation for Events
|
|
33
|
+
const stopPropagation = function () {
|
|
34
|
+
this.propagationStopped = true;
|
|
35
|
+
};
|
|
36
|
+
// default preventDefault implementation for Events
|
|
37
|
+
const preventDefault = function () {
|
|
38
|
+
this.defaultPrevented = true;
|
|
39
|
+
};
|
|
40
|
+
;
|
|
41
|
+
/**
|
|
42
|
+
* BasicEvent Builder
|
|
43
|
+
* this function is responsable of BasicEvent creation
|
|
44
|
+
* ie. is equivalent of new BasicEvent( xxx );
|
|
45
|
+
* @param params
|
|
46
|
+
* @returns BasicEvent
|
|
47
|
+
*/
|
|
48
|
+
function BasicEvent(params) {
|
|
49
|
+
return {
|
|
50
|
+
stopPropagation,
|
|
51
|
+
preventDefault,
|
|
52
|
+
...params,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.BasicEvent = BasicEvent;
|
|
56
|
+
function EvClick(context = null) {
|
|
57
|
+
return BasicEvent({ context });
|
|
58
|
+
}
|
|
59
|
+
exports.EvClick = EvClick;
|
|
60
|
+
function EvChange(value, context = null) {
|
|
61
|
+
return BasicEvent({ value, context });
|
|
62
|
+
}
|
|
63
|
+
exports.EvChange = EvChange;
|
|
64
|
+
function EvSelectionChange(selection, context = null) {
|
|
65
|
+
return BasicEvent({ selection, context });
|
|
66
|
+
}
|
|
67
|
+
exports.EvSelectionChange = EvSelectionChange;
|
|
68
|
+
function EvContextMenu(uievent, context = null) {
|
|
69
|
+
return BasicEvent({ uievent, context });
|
|
70
|
+
}
|
|
71
|
+
exports.EvContextMenu = EvContextMenu;
|
|
72
|
+
function EvTimer(timer, time = 0, context = null) {
|
|
73
|
+
return BasicEvent({ timer, time, context });
|
|
74
|
+
}
|
|
75
|
+
exports.EvTimer = EvTimer;
|
|
76
|
+
function EvMessage(msg, params, source) {
|
|
77
|
+
return BasicEvent({ msg, params, source });
|
|
78
|
+
}
|
|
79
|
+
exports.EvMessage = EvMessage;
|
|
80
|
+
function EvDrag(element, data, ctx) {
|
|
81
|
+
return BasicEvent({ element, data, context: ctx });
|
|
82
|
+
}
|
|
83
|
+
exports.EvDrag = EvDrag;
|
|
84
|
+
function EvError(code, message) {
|
|
85
|
+
return BasicEvent({ code, message });
|
|
86
|
+
}
|
|
87
|
+
exports.EvError = EvError;
|
|
88
|
+
/**
|
|
89
|
+
* Event emitter class
|
|
90
|
+
* this class allow you to emit and handle events
|
|
91
|
+
*
|
|
92
|
+
* @example:
|
|
93
|
+
* ```ts
|
|
94
|
+
*
|
|
95
|
+
* interface EvDoIt extends BasicEvent {
|
|
96
|
+
* param: unknown;
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* function EvDoIt( e: EvDoIt ) : EvDoIt {
|
|
100
|
+
* return BasicEvent<EvDoIt>( e );
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* interface TestEventMap extends EventMap {
|
|
104
|
+
* doit: EvDoIt;
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* let ee = new EventSource<TestEventMap>(null);
|
|
108
|
+
* ee.listen({
|
|
109
|
+
* doit: (e) => {
|
|
110
|
+
* console.log(e);
|
|
111
|
+
* e.preventDefault();
|
|
112
|
+
* },
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* ee.defaults({
|
|
116
|
+
* doit: (e) => {
|
|
117
|
+
* console.log('default handler for ', e.type, e.selection);
|
|
118
|
+
* },
|
|
119
|
+
* })
|
|
120
|
+
*
|
|
121
|
+
* ee.on('doit', (e) => {
|
|
122
|
+
* debugger;
|
|
123
|
+
* })
|
|
124
|
+
*
|
|
125
|
+
* const ev = EvDoIt({ param: 10 });
|
|
126
|
+
* ee.emit('change', ev);
|
|
127
|
+
* if (ev.defaultPrevented) {
|
|
128
|
+
* console.log('prevented');
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
class EventSource {
|
|
133
|
+
m_source;
|
|
134
|
+
m_eventRegistry;
|
|
135
|
+
m_defaultHandlers;
|
|
136
|
+
constructor(source = null) {
|
|
137
|
+
this.m_source = source ?? this;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* emit an event
|
|
141
|
+
* you can stop propagation of event or prevent default
|
|
142
|
+
* @param eventName - name of event to emit
|
|
143
|
+
* @param event - event data
|
|
144
|
+
*/
|
|
145
|
+
emit(type, event) {
|
|
146
|
+
this._emit(type, event);
|
|
147
|
+
}
|
|
148
|
+
_emit(eventName, e) {
|
|
149
|
+
let listeners = this.m_eventRegistry?.get(eventName);
|
|
150
|
+
const defaultHandler = this.m_defaultHandlers?.get(eventName);
|
|
151
|
+
if (!e) {
|
|
152
|
+
e = {};
|
|
153
|
+
}
|
|
154
|
+
if (!e.source) {
|
|
155
|
+
e.source = this.m_source;
|
|
156
|
+
}
|
|
157
|
+
if (!e.type) {
|
|
158
|
+
e.type = eventName;
|
|
159
|
+
}
|
|
160
|
+
if (listeners && listeners.length) {
|
|
161
|
+
if (!e.preventDefault) {
|
|
162
|
+
e.preventDefault = preventDefault;
|
|
163
|
+
}
|
|
164
|
+
if (!e.stopPropagation) {
|
|
165
|
+
e.stopPropagation = stopPropagation;
|
|
166
|
+
}
|
|
167
|
+
// small optimisation
|
|
168
|
+
if (listeners.length == 1) {
|
|
169
|
+
listeners[0](e);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
const temp = listeners.slice();
|
|
173
|
+
for (let i = 0, n = temp.length; i < n; i++) {
|
|
174
|
+
temp[i](e);
|
|
175
|
+
if (e.propagationStopped) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (defaultHandler && defaultHandler.length && !e.defaultPrevented) {
|
|
182
|
+
return defaultHandler[0](e);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* signal en event
|
|
187
|
+
* signaled event are notification : no way to prevent default not stop propagation
|
|
188
|
+
* @param eventName name of event to signal
|
|
189
|
+
* @param event event data
|
|
190
|
+
*/
|
|
191
|
+
signal(type, event, delay = -1) {
|
|
192
|
+
this._signal(type, event, delay);
|
|
193
|
+
}
|
|
194
|
+
_signal(eventName, e, delay = -1) {
|
|
195
|
+
if (!this.m_eventRegistry) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const listeners = this.m_eventRegistry.get(eventName);
|
|
199
|
+
if (!listeners || !listeners.length) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!e) {
|
|
203
|
+
e = {};
|
|
204
|
+
}
|
|
205
|
+
if (!e.type) {
|
|
206
|
+
e.type = eventName;
|
|
207
|
+
}
|
|
208
|
+
if (!e.source) {
|
|
209
|
+
e.source = this.m_source;
|
|
210
|
+
}
|
|
211
|
+
e.preventDefault = e.stopPropagation = () => {
|
|
212
|
+
console.error('this event cannot be stopped not default prevented');
|
|
213
|
+
};
|
|
214
|
+
// small optimisation
|
|
215
|
+
if (listeners.length == 1 && delay == -1) {
|
|
216
|
+
listeners[0](e);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const temp = listeners.slice();
|
|
220
|
+
const call = () => {
|
|
221
|
+
for (let i = 0, n = temp.length; i < n; i++) {
|
|
222
|
+
temp[i](e);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
if (delay == -1) {
|
|
226
|
+
call();
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
setTimeout(call, delay);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* handle an event one time
|
|
235
|
+
* @param eventName - event name to handle
|
|
236
|
+
* @param callback - callback to call when event is signaled
|
|
237
|
+
* @returns Promise if callback is null
|
|
238
|
+
*
|
|
239
|
+
* take care with that because if the event is never fired and you await it,
|
|
240
|
+
* the system may overflow
|
|
241
|
+
*/
|
|
242
|
+
once(type, callback) {
|
|
243
|
+
//@ts-ignore
|
|
244
|
+
this._once(type, callback);
|
|
245
|
+
}
|
|
246
|
+
_once(eventName, callback) {
|
|
247
|
+
const newCallback = (ev) => {
|
|
248
|
+
this._off(eventName, newCallback);
|
|
249
|
+
callback(ev);
|
|
250
|
+
};
|
|
251
|
+
this._on(eventName, newCallback);
|
|
252
|
+
if (!callback) {
|
|
253
|
+
return new Promise(function (resolve) {
|
|
254
|
+
callback = resolve;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* set the event default handler
|
|
260
|
+
* @param eventName - name of the event
|
|
261
|
+
* @param callback - callback to call when the event is not handled (and preventDeault has not been called)
|
|
262
|
+
*/
|
|
263
|
+
setDefaultHandler(eventName, callback) {
|
|
264
|
+
let handlers = this.m_defaultHandlers;
|
|
265
|
+
if (!handlers) {
|
|
266
|
+
handlers = this.m_defaultHandlers = new Map();
|
|
267
|
+
}
|
|
268
|
+
let stack = handlers.get(eventName);
|
|
269
|
+
if (stack) {
|
|
270
|
+
// if already in the stack, remove it
|
|
271
|
+
const idx = stack.indexOf(callback);
|
|
272
|
+
if (idx != -1) {
|
|
273
|
+
stack.splice(idx, 1);
|
|
274
|
+
}
|
|
275
|
+
// then make it first
|
|
276
|
+
stack.unshift(callback);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
handlers.set(eventName, [callback]);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* remove the previous default handler installed for an event
|
|
284
|
+
* @param eventName - event name
|
|
285
|
+
* @param callback - callback handler to remove (must be the same as in setDefaultHandler)
|
|
286
|
+
*/
|
|
287
|
+
removeDefaultHandler(eventName, callback) {
|
|
288
|
+
const handlers = this.m_defaultHandlers;
|
|
289
|
+
if (!handlers) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const stack = handlers.get(eventName);
|
|
293
|
+
if (stack) {
|
|
294
|
+
const idx = stack.indexOf(callback);
|
|
295
|
+
if (idx != -1) {
|
|
296
|
+
stack.splice(idx, 1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* define a set of listeners in one call
|
|
302
|
+
* @param events
|
|
303
|
+
*/
|
|
304
|
+
listen(events) {
|
|
305
|
+
for (let n in events) {
|
|
306
|
+
this._on(n, events[n]);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* define a set of default handlers in one call
|
|
311
|
+
* @param events
|
|
312
|
+
*/
|
|
313
|
+
defaults(events) {
|
|
314
|
+
for (let n in events) {
|
|
315
|
+
this.setDefaultHandler(n, events[n]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* listen for an event
|
|
320
|
+
* @param eventName - event name to listen on
|
|
321
|
+
* @param callback - callback to call
|
|
322
|
+
* @param capturing - if true, capture event before other registred event handlers
|
|
323
|
+
*/
|
|
324
|
+
on(type, callback) {
|
|
325
|
+
//@ts-ignore
|
|
326
|
+
return this._on(type, callback);
|
|
327
|
+
}
|
|
328
|
+
_on(eventName, callback, capturing = false) {
|
|
329
|
+
if (!this.m_eventRegistry) {
|
|
330
|
+
this.m_eventRegistry = new Map();
|
|
331
|
+
}
|
|
332
|
+
let listeners = this.m_eventRegistry.get(eventName);
|
|
333
|
+
if (!listeners) {
|
|
334
|
+
listeners = [];
|
|
335
|
+
this.m_eventRegistry.set(eventName, listeners);
|
|
336
|
+
}
|
|
337
|
+
if (listeners.indexOf(callback) == -1) {
|
|
338
|
+
if (capturing) {
|
|
339
|
+
listeners.unshift(callback);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
listeners.push(callback);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
dispose: () => { this._off(eventName, callback); }
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* stop listening to an event
|
|
351
|
+
* @param eventName - event name
|
|
352
|
+
* @param callback - callback to remove (must be the same as in on )
|
|
353
|
+
*/
|
|
354
|
+
off(type, callback) {
|
|
355
|
+
//@ts-ignore
|
|
356
|
+
return this._off(type, callback);
|
|
357
|
+
}
|
|
358
|
+
_off(eventName, callback) {
|
|
359
|
+
if (!this.m_eventRegistry) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
let listeners = this.m_eventRegistry.get(eventName);
|
|
363
|
+
if (!listeners) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const idx = listeners.indexOf(callback);
|
|
367
|
+
if (idx !== -1) {
|
|
368
|
+
listeners.splice(idx, 1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* remove all listeners for an event
|
|
373
|
+
* @param eventName - event name
|
|
374
|
+
*/
|
|
375
|
+
removeAllListeners(eventName) {
|
|
376
|
+
if (!eventName) {
|
|
377
|
+
this.m_eventRegistry = this.m_defaultHandlers = undefined;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
if (this.m_eventRegistry) {
|
|
381
|
+
this.m_eventRegistry[eventName] = undefined;
|
|
382
|
+
}
|
|
383
|
+
if (this.m_defaultHandlers) {
|
|
384
|
+
this.m_defaultHandlers[eventName] = undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
exports.EventSource = EventSource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x4js",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"description": "X4js core files",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
"framework"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "build.sh"
|
|
17
|
+
"build": "build.sh",
|
|
18
|
+
"mkdoc": "typedoc --tsconfig tsconfig.json --readme none"
|
|
18
19
|
},
|
|
19
20
|
"author": "etienne cochard",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"bugs": {
|
|
22
23
|
"url": "https://github.com/rlibre/x4js/issues"
|
|
23
24
|
},
|
|
24
|
-
"homepage": "https://
|
|
25
|
+
"homepage": "https://x4js.org"
|
|
25
26
|
}
|
|
26
27
|
|
package/src/application.ts
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
|
-
import {
|
|
30
|
+
import { x4document } from './x4dom'
|
|
31
|
+
import { EvMessage } from './x4events'
|
|
31
32
|
import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component'
|
|
32
33
|
import { Component } from './component'
|
|
33
34
|
import { Settings } from './settings'
|
|
@@ -173,7 +174,7 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
173
174
|
this.mainView.addClass( 'x4-root-element' );
|
|
174
175
|
|
|
175
176
|
deferCall( ( ) => {
|
|
176
|
-
const dest = this.m_props.renderTo ??
|
|
177
|
+
const dest = this.m_props.renderTo ?? x4document.body;
|
|
177
178
|
while (dest.firstChild) {
|
|
178
179
|
dest.removeChild(dest.firstChild);
|
|
179
180
|
}
|
|
@@ -186,7 +187,7 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
public setTitle( title: string ) {
|
|
189
|
-
|
|
190
|
+
x4document.title = this.m_app_name + ' > ' + title;
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
public disableZoomWheel( ) {
|
|
@@ -204,7 +205,7 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
public enableTouchDblClick( ) {
|
|
207
|
-
|
|
208
|
+
x4document.addEventListener( 'touchstart', ( ev: TouchEvent ) => {
|
|
208
209
|
|
|
209
210
|
let now = Date.now( );
|
|
210
211
|
if( (now-this.m_touch_time) > 700 ) {
|
package/src/base_component.ts
CHANGED
package/src/button.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
import { Component, CProps, CEventMap, HtmlString } from './component'
|
|
32
|
-
import { EventCallback, EvClick, EvChange } from './
|
|
32
|
+
import { EventCallback, EvClick, EvChange } from './x4events'
|
|
33
33
|
|
|
34
34
|
import { Icon, IconID } from './icon'
|
|
35
35
|
import { Label } from './label'
|
package/src/calendar.ts
CHANGED
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
|
+
import { x4document } from './x4dom'
|
|
31
|
+
|
|
30
32
|
import { Button } from './button';
|
|
31
33
|
import { Popup } from './popup';
|
|
32
34
|
import { Component, CProps, ContainerEventMap, Flex } from './component'
|
|
33
|
-
import { EvChange, EventCallback } from './
|
|
35
|
+
import { EvChange, EventCallback } from './x4events'
|
|
34
36
|
|
|
35
37
|
import { _tr } from './i18n';
|
|
36
38
|
import { Label } from './label';
|
|
@@ -307,13 +309,13 @@ export class PopupCalendar extends Popup {
|
|
|
307
309
|
|
|
308
310
|
/** @ignore */
|
|
309
311
|
show(modal?: boolean) {
|
|
310
|
-
|
|
312
|
+
x4document.addEventListener('mousedown', this._handleClick);
|
|
311
313
|
super.show(modal);
|
|
312
314
|
}
|
|
313
315
|
|
|
314
316
|
/** @ignore */
|
|
315
317
|
close() {
|
|
316
|
-
|
|
318
|
+
x4document.removeEventListener('mousedown', this._handleClick);
|
|
317
319
|
super.close();
|
|
318
320
|
}
|
|
319
321
|
|
package/src/canvas.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
30
|
import { Component, CProps, CEventMap, html } from './component'
|
|
31
|
-
import { BasicEvent, EventCallback } from './
|
|
31
|
+
import { BasicEvent, EventCallback } from './x4events'
|
|
32
32
|
|
|
33
33
|
interface EvPaint extends BasicEvent {
|
|
34
34
|
ctx: CanvasPainter;
|
package/src/cardview.ts
CHANGED
package/src/checkbox.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
30
|
import { CEventMap, Component, CProps } from './component'
|
|
31
|
-
import { EvChange, EventCallback } from './
|
|
31
|
+
import { EvChange, EventCallback } from './x4events'
|
|
32
32
|
import { HtmlString } from './tools'
|
|
33
33
|
|
|
34
34
|
import { Input } from './input'
|
package/src/colorpicker.ts
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
import { Container, Component, ContainerProps, ContainerEventMap } from './component'
|
|
36
36
|
import { CheckBox } from './checkbox'
|
|
37
37
|
import { Dialog, DialogBoxEventMap, DialogProps } from './dialog'
|
|
38
|
-
import { EvChange, EventCallback } from './
|
|
38
|
+
import { EvChange, EventCallback } from './x4events'
|
|
39
39
|
import { VLayout, HLayout } from './layout'
|
|
40
40
|
import { Label } from './label'
|
|
41
41
|
import { Color } from './color'
|
package/src/combobox.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
import { Component, CProps, ContainerEventMap } from './component'
|
|
35
|
-
import { EvChange, EvSelectionChange, EventCallback } from './
|
|
35
|
+
import { EvChange, EvSelectionChange, EventCallback } from './x4events'
|
|
36
36
|
|
|
37
37
|
import { Input } from './input'
|
|
38
38
|
import { Label } from './label'
|