x4js 1.4.3 → 1.4.6
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 +3 -2
- package/lib/application.js +15 -7
- package/lib/base64.js +5 -1
- package/lib/base_component.js +7 -3
- package/lib/button.js +24 -18
- package/lib/calendar.js +44 -39
- package/lib/canvas.js +9 -5
- package/lib/cardview.js +11 -7
- package/lib/checkbox.js +12 -8
- package/lib/color.js +7 -3
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.js +65 -48
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.js +2 -1
- package/lib/drag_manager.js +4 -1
- package/lib/drawtext.js +9 -5
- package/lib/fileupload.js +19 -12
- package/lib/form.js +29 -25
- package/lib/formatters.js +19 -10
- package/lib/gridview.js +40 -35
- package/lib/hosts/host.js +7 -3
- package/lib/i18n.js +11 -5
- package/lib/icon.js +16 -11
- package/lib/image.js +7 -3
- package/lib/index.d.ts +55 -0
- package/lib/index.js +71 -56
- package/lib/input.js +6 -2
- package/lib/label.js +15 -11
- package/lib/layout.js +23 -13
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.js +27 -19
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.js +25 -20
- package/lib/property_editor.js +20 -16
- package/lib/radiobtn.js +13 -9
- package/lib/rating.js +13 -9
- package/lib/request.js +16 -9
- package/lib/router.d.ts +1 -8
- package/lib/router.js +4 -0
- package/lib/settings.js +8 -4
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.js +15 -9
- package/lib/svgcomponent.js +8 -3
- package/lib/tabbar.js +10 -6
- package/lib/tabview.js +10 -6
- package/lib/textarea.js +10 -6
- package/lib/textedit.js +39 -35
- package/lib/texthiliter.js +8 -4
- package/lib/toaster.js +8 -4
- package/lib/tools.js +97 -51
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.js +21 -9
- package/package.json +2 -1
- package/src/application.ts +8 -4
- package/src/index.ts +55 -0
- package/src/router.ts +1 -1
- package/tsconfig.json +2 -1
- package/lib/list.txt +0 -56
- package/list.txt +0 -0
package/lib/tools.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,14 +23,17 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.generatePassword = exports.classNames = exports.mix = exports.crc32 = exports.Clipboard = exports.isHtmlString = exports.html = exports.HtmlString = exports.clamp = exports.getMousePos = exports.NetworkError = exports.markdownToHtml = exports.asap = exports.deferCall = exports.waitFontLoading = exports.isNumber = exports.pad = exports.isLiteralObject = exports.isFunction = exports.isArray = exports.isString = exports.downloadData = exports.calcAge = exports.formatIntlDate = exports.parseIntlDate = exports.date_calc_weeknum = exports.date_clone = exports.date_hash = exports.date_sql_utc = exports.date_to_sql = exports.date_diff = exports.date_format = exports._date_set_locale = exports.removeHtmlTags = exports.escapeHtml = exports.sprintf = exports.Rect = exports.Size = exports.Point = exports.pascalCase = exports.parseIntlFloat = exports.roundTo = exports.isTouchDevice = void 0;
|
|
28
|
+
const i18n_1 = require("./i18n"); // you MUST create a file named translation.js
|
|
26
29
|
// :: ENVIRONMENT ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
27
30
|
/**
|
|
28
31
|
* @return true is the device has touch
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
function isTouchDevice() {
|
|
31
34
|
return 'ontouchstart' in window;
|
|
32
35
|
}
|
|
36
|
+
exports.isTouchDevice = isTouchDevice;
|
|
33
37
|
// :: NUMBERS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
34
38
|
/**
|
|
35
39
|
* round to a given number of decimals
|
|
@@ -37,7 +41,7 @@ export function isTouchDevice() {
|
|
|
37
41
|
* @param ndec number of decimals
|
|
38
42
|
* @returns number rounded
|
|
39
43
|
*/
|
|
40
|
-
|
|
44
|
+
function roundTo(num, ndec) {
|
|
41
45
|
let mul = Math.pow(10, ndec);
|
|
42
46
|
let res = Math.round(num * mul) / mul;
|
|
43
47
|
if (Object.is(res, -0)) { // res===-0.0
|
|
@@ -45,13 +49,14 @@ export function roundTo(num, ndec) {
|
|
|
45
49
|
}
|
|
46
50
|
return res;
|
|
47
51
|
}
|
|
52
|
+
exports.roundTo = roundTo;
|
|
48
53
|
/**
|
|
49
54
|
* parse an intl formatted number
|
|
50
55
|
* understand grouping and ',' separator
|
|
51
56
|
* @review us format: grouping = ','
|
|
52
57
|
* @param num
|
|
53
58
|
*/
|
|
54
|
-
|
|
59
|
+
function parseIntlFloat(num) {
|
|
55
60
|
num = num.replace(/\s*/g, ''); // group separator
|
|
56
61
|
num = num.replace(',', '.'); // decimal separator
|
|
57
62
|
// accept empty & return 0.0
|
|
@@ -60,6 +65,7 @@ export function parseIntlFloat(num) {
|
|
|
60
65
|
}
|
|
61
66
|
return parseFloat(num);
|
|
62
67
|
}
|
|
68
|
+
exports.parseIntlFloat = parseIntlFloat;
|
|
63
69
|
// :: STRING MANIP ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
64
70
|
const RE_PCASE = /([a-z][A-Z])/g;
|
|
65
71
|
const RE_PCASE2 = /[^-a-z0-9]+/g;
|
|
@@ -68,7 +74,7 @@ const RE_PCASE2 = /[^-a-z0-9]+/g;
|
|
|
68
74
|
* theThingToCase -> the-thing-to-case
|
|
69
75
|
* @param {String} str
|
|
70
76
|
*/
|
|
71
|
-
|
|
77
|
+
function pascalCase(string) {
|
|
72
78
|
let result = string;
|
|
73
79
|
result = result.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
74
80
|
result = result.toLowerCase();
|
|
@@ -79,7 +85,8 @@ export function pascalCase(string) {
|
|
|
79
85
|
result = result.trim();
|
|
80
86
|
return result.replace(/ /g, '-');
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
exports.pascalCase = pascalCase;
|
|
89
|
+
class Point {
|
|
83
90
|
x;
|
|
84
91
|
y;
|
|
85
92
|
constructor(x = 0, y = 0) {
|
|
@@ -87,7 +94,8 @@ export class Point {
|
|
|
87
94
|
this.y = y;
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
|
-
|
|
97
|
+
exports.Point = Point;
|
|
98
|
+
class Size {
|
|
91
99
|
width;
|
|
92
100
|
height;
|
|
93
101
|
constructor(w = 0, h = 0) {
|
|
@@ -95,7 +103,8 @@ export class Size {
|
|
|
95
103
|
this.height = h;
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
|
-
|
|
106
|
+
exports.Size = Size;
|
|
107
|
+
class Rect {
|
|
99
108
|
left;
|
|
100
109
|
top;
|
|
101
110
|
width;
|
|
@@ -235,6 +244,7 @@ export class Rect {
|
|
|
235
244
|
this.bottom = bottom;
|
|
236
245
|
}
|
|
237
246
|
}
|
|
247
|
+
exports.Rect = Rect;
|
|
238
248
|
/**
|
|
239
249
|
* replace {0..9} by given arguments
|
|
240
250
|
* @param format string
|
|
@@ -244,18 +254,19 @@ export class Rect {
|
|
|
244
254
|
*
|
|
245
255
|
* console.log( sprintf( 'here is arg 1 {1} and arg 0 {0}', 'argument 0', 'argument 1' ) )
|
|
246
256
|
*/
|
|
247
|
-
|
|
257
|
+
function sprintf(format, ...args) {
|
|
248
258
|
return format.replace(/{(\d+)}/g, function (match, index) {
|
|
249
259
|
return typeof args[index] != 'undefined' ? args[index] : match;
|
|
250
260
|
});
|
|
251
261
|
}
|
|
262
|
+
exports.sprintf = sprintf;
|
|
252
263
|
/**
|
|
253
264
|
* replace special characters for display
|
|
254
265
|
* @param unsafe
|
|
255
266
|
*
|
|
256
267
|
* console.log( escapeHtml('<div style="width:50px; height: 50px; background-color:red"></div>') );
|
|
257
268
|
*/
|
|
258
|
-
|
|
269
|
+
function escapeHtml(unsafe, nl_br = false) {
|
|
259
270
|
if (!unsafe || unsafe.length == 0) {
|
|
260
271
|
return unsafe;
|
|
261
272
|
}
|
|
@@ -267,6 +278,7 @@ export function escapeHtml(unsafe, nl_br = false) {
|
|
|
267
278
|
}
|
|
268
279
|
return result;
|
|
269
280
|
}
|
|
281
|
+
exports.escapeHtml = escapeHtml;
|
|
270
282
|
/**
|
|
271
283
|
* replace special characters for display
|
|
272
284
|
* @author Steven Levithan <http://slevithan.com/>
|
|
@@ -274,7 +286,7 @@ export function escapeHtml(unsafe, nl_br = false) {
|
|
|
274
286
|
*
|
|
275
287
|
* console.log( removeHtmlTags('<h1>sss</h1>') );
|
|
276
288
|
*/
|
|
277
|
-
|
|
289
|
+
function removeHtmlTags(unsafe, nl_br = false) {
|
|
278
290
|
if (!unsafe || unsafe.length == 0) {
|
|
279
291
|
return unsafe;
|
|
280
292
|
}
|
|
@@ -294,15 +306,17 @@ export function removeHtmlTags(unsafe, nl_br = false) {
|
|
|
294
306
|
}
|
|
295
307
|
return ret_val;
|
|
296
308
|
}
|
|
309
|
+
exports.removeHtmlTags = removeHtmlTags;
|
|
297
310
|
// :: DATES ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
298
311
|
let cur_locale = 'fr-FR';
|
|
299
312
|
/**
|
|
300
313
|
* change the current locale for misc translations (date...)
|
|
301
314
|
* @param locale
|
|
302
315
|
*/
|
|
303
|
-
|
|
316
|
+
function _date_set_locale(locale) {
|
|
304
317
|
cur_locale = locale;
|
|
305
318
|
}
|
|
319
|
+
exports._date_set_locale = _date_set_locale;
|
|
306
320
|
/**
|
|
307
321
|
*
|
|
308
322
|
* @param date
|
|
@@ -312,32 +326,34 @@ export function _date_set_locale(locale) {
|
|
|
312
326
|
* let options = { day: 'numeric', month: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric' };
|
|
313
327
|
* let text = date_format( date, options );
|
|
314
328
|
*/
|
|
315
|
-
|
|
329
|
+
function date_format(date, options) {
|
|
316
330
|
//return new Intl.DateTimeFormat(cur_locale, options).format( date );
|
|
317
331
|
return formatIntlDate(date);
|
|
318
332
|
}
|
|
333
|
+
exports.date_format = date_format;
|
|
319
334
|
/**
|
|
320
335
|
*
|
|
321
336
|
* @param date
|
|
322
337
|
* @param options
|
|
323
338
|
*/
|
|
324
|
-
|
|
339
|
+
function date_diff(date1, date2, options) {
|
|
325
340
|
var dt = (date1.getTime() - date2.getTime()) / 1000;
|
|
326
341
|
// seconds
|
|
327
342
|
let sec = dt;
|
|
328
343
|
if (sec < 60) {
|
|
329
|
-
return sprintf(_tr.global.diff_date_seconds, Math.round(sec));
|
|
344
|
+
return sprintf(i18n_1._tr.global.diff_date_seconds, Math.round(sec));
|
|
330
345
|
}
|
|
331
346
|
// minutes
|
|
332
347
|
let min = Math.floor(sec / 60);
|
|
333
348
|
if (min < 60) {
|
|
334
|
-
return sprintf(_tr.global.diff_date_minutes, Math.round(min));
|
|
349
|
+
return sprintf(i18n_1._tr.global.diff_date_minutes, Math.round(min));
|
|
335
350
|
}
|
|
336
351
|
// hours
|
|
337
352
|
let hrs = Math.floor(min / 60);
|
|
338
|
-
return sprintf(_tr.global.diff_date_hours, hrs, min % 60);
|
|
353
|
+
return sprintf(i18n_1._tr.global.diff_date_hours, hrs, min % 60);
|
|
339
354
|
}
|
|
340
|
-
|
|
355
|
+
exports.date_diff = date_diff;
|
|
356
|
+
function date_to_sql(date, withHours) {
|
|
341
357
|
if (withHours) {
|
|
342
358
|
return formatIntlDate(date, 'Y-M-D H:I:S');
|
|
343
359
|
}
|
|
@@ -345,38 +361,43 @@ export function date_to_sql(date, withHours) {
|
|
|
345
361
|
return formatIntlDate(date, 'Y-M-D');
|
|
346
362
|
}
|
|
347
363
|
}
|
|
364
|
+
exports.date_to_sql = date_to_sql;
|
|
348
365
|
/**
|
|
349
366
|
* construct a date from an utc date time (sql format)
|
|
350
367
|
* YYYY-MM-DD HH:MM:SS
|
|
351
368
|
*/
|
|
352
|
-
|
|
369
|
+
function date_sql_utc(date) {
|
|
353
370
|
let result = new Date(date + ' GMT');
|
|
354
371
|
return result;
|
|
355
372
|
}
|
|
373
|
+
exports.date_sql_utc = date_sql_utc;
|
|
356
374
|
/**
|
|
357
375
|
* return a number that is a representation of the date
|
|
358
376
|
* this number can be compared with another hash
|
|
359
377
|
*/
|
|
360
|
-
|
|
378
|
+
function date_hash(date) {
|
|
361
379
|
return date.getFullYear() << 16 | date.getMonth() << 8 | date.getDate();
|
|
362
380
|
}
|
|
381
|
+
exports.date_hash = date_hash;
|
|
363
382
|
Date.prototype.hash = function () {
|
|
364
383
|
return date_hash(this);
|
|
365
384
|
};
|
|
366
385
|
/**
|
|
367
386
|
* return a copy of a date
|
|
368
387
|
*/
|
|
369
|
-
|
|
388
|
+
function date_clone(date) {
|
|
370
389
|
return new Date(date.getTime());
|
|
371
390
|
}
|
|
391
|
+
exports.date_clone = date_clone;
|
|
372
392
|
/**
|
|
373
393
|
* return the week number of a date
|
|
374
394
|
*/
|
|
375
|
-
|
|
395
|
+
function date_calc_weeknum(date) {
|
|
376
396
|
const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
|
|
377
397
|
const pastDaysOfYear = (date.valueOf() - firstDayOfYear.valueOf()) / 86400000;
|
|
378
398
|
return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7);
|
|
379
399
|
}
|
|
400
|
+
exports.date_calc_weeknum = date_calc_weeknum;
|
|
380
401
|
/**
|
|
381
402
|
* parse a date according to the given format
|
|
382
403
|
* @param value - string date to parse
|
|
@@ -395,7 +416,7 @@ export function date_calc_weeknum(date) {
|
|
|
395
416
|
* @example
|
|
396
417
|
* 'd/m/y|d m Y|dmy|y-m-d h:i:s|y-m-d'
|
|
397
418
|
*/
|
|
398
|
-
|
|
419
|
+
function parseIntlDate(value, fmts = i18n_1._tr.global.date_input_formats) {
|
|
399
420
|
let formats = fmts.split('|');
|
|
400
421
|
for (let fmatch of formats) {
|
|
401
422
|
//review: could do that only once & keep result
|
|
@@ -452,6 +473,7 @@ export function parseIntlDate(value, fmts = _tr.global.date_input_formats) {
|
|
|
452
473
|
}
|
|
453
474
|
return null;
|
|
454
475
|
}
|
|
476
|
+
exports.parseIntlDate = parseIntlDate;
|
|
455
477
|
/**
|
|
456
478
|
* format a date as string
|
|
457
479
|
* @param date - date to format
|
|
@@ -482,7 +504,7 @@ export function parseIntlDate(value, fmts = _tr.global.date_input_formats) {
|
|
|
482
504
|
* 01/01/1970 11:25:00 with '{this is my demo date formatter: }H-i*M'
|
|
483
505
|
* "this is my demo date formatter: 11-25*january"
|
|
484
506
|
*/
|
|
485
|
-
|
|
507
|
+
function formatIntlDate(date, fmt = i18n_1._tr.global.date_format) {
|
|
486
508
|
if (!date) {
|
|
487
509
|
return '';
|
|
488
510
|
}
|
|
@@ -520,10 +542,10 @@ export function formatIntlDate(date, fmt = _tr.global.date_format) {
|
|
|
520
542
|
result += pad(now.day, -2);
|
|
521
543
|
}
|
|
522
544
|
else if (c == 'j') { // day short
|
|
523
|
-
result += _tr.global.day_short[now.wday];
|
|
545
|
+
result += i18n_1._tr.global.day_short[now.wday];
|
|
524
546
|
}
|
|
525
547
|
else if (c == 'J') { // day long
|
|
526
|
-
result += _tr.global.day_long[now.wday];
|
|
548
|
+
result += i18n_1._tr.global.day_long[now.wday];
|
|
527
549
|
}
|
|
528
550
|
else if (c == 'w') { // week
|
|
529
551
|
result += date_calc_weeknum(date);
|
|
@@ -538,10 +560,10 @@ export function formatIntlDate(date, fmt = _tr.global.date_format) {
|
|
|
538
560
|
result += pad(now.month, -2);
|
|
539
561
|
}
|
|
540
562
|
else if (c == 'o') { // month short
|
|
541
|
-
result += _tr.global.month_short[now.month - 1];
|
|
563
|
+
result += i18n_1._tr.global.month_short[now.month - 1];
|
|
542
564
|
}
|
|
543
565
|
else if (c == 'O') { // month long
|
|
544
|
-
result += _tr.global.month_long[now.month - 1];
|
|
566
|
+
result += i18n_1._tr.global.month_long[now.month - 1];
|
|
545
567
|
}
|
|
546
568
|
else if (c == 'y' || c == 'Y') {
|
|
547
569
|
result += pad(now.year, -4);
|
|
@@ -579,7 +601,8 @@ export function formatIntlDate(date, fmt = _tr.global.date_format) {
|
|
|
579
601
|
}
|
|
580
602
|
return result;
|
|
581
603
|
}
|
|
582
|
-
|
|
604
|
+
exports.formatIntlDate = formatIntlDate;
|
|
605
|
+
function calcAge(birth, ref) {
|
|
583
606
|
if (ref === undefined) {
|
|
584
607
|
ref = new Date();
|
|
585
608
|
}
|
|
@@ -592,6 +615,7 @@ export function calcAge(birth, ref) {
|
|
|
592
615
|
}
|
|
593
616
|
return age;
|
|
594
617
|
}
|
|
618
|
+
exports.calcAge = calcAge;
|
|
595
619
|
Date.prototype.isSameDay = function (date) {
|
|
596
620
|
return this.getDate() == date.getDate() && this.getMonth() == date.getMonth() && this.getFullYear() == date.getFullYear();
|
|
597
621
|
};
|
|
@@ -617,7 +641,7 @@ Date.prototype.addDays = function (days) {
|
|
|
617
641
|
* @param data data to export
|
|
618
642
|
* @param mimetype - 'text/plain'
|
|
619
643
|
*/
|
|
620
|
-
|
|
644
|
+
function downloadData(data, mimetype, filename) {
|
|
621
645
|
//if (data !== null && navigator.msSaveBlob) {
|
|
622
646
|
// return navigator.msSaveBlob(new Blob([data], { type: mimetype }), filename);
|
|
623
647
|
//}
|
|
@@ -631,40 +655,45 @@ export function downloadData(data, mimetype, filename) {
|
|
|
631
655
|
a.click();
|
|
632
656
|
window.URL.revokeObjectURL(url);
|
|
633
657
|
}
|
|
658
|
+
exports.downloadData = downloadData;
|
|
634
659
|
// :: MISC ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
635
660
|
/**
|
|
636
661
|
* check if a value is a string
|
|
637
662
|
* @param val
|
|
638
663
|
*/
|
|
639
|
-
|
|
664
|
+
function isString(val) {
|
|
640
665
|
return typeof val === 'string';
|
|
641
666
|
}
|
|
667
|
+
exports.isString = isString;
|
|
642
668
|
/**
|
|
643
669
|
* check is a value is an array
|
|
644
670
|
* @param val
|
|
645
671
|
*/
|
|
646
|
-
|
|
672
|
+
function isArray(val) {
|
|
647
673
|
return val instanceof Array;
|
|
648
674
|
}
|
|
675
|
+
exports.isArray = isArray;
|
|
649
676
|
/**
|
|
650
677
|
*
|
|
651
678
|
*/
|
|
652
|
-
|
|
679
|
+
function isFunction(val) {
|
|
653
680
|
return val instanceof Function;
|
|
654
681
|
}
|
|
682
|
+
exports.isFunction = isFunction;
|
|
655
683
|
/**
|
|
656
684
|
*
|
|
657
685
|
*/
|
|
658
|
-
|
|
686
|
+
function isLiteralObject(val) {
|
|
659
687
|
return (!!val) && (val.constructor === Object);
|
|
660
688
|
}
|
|
689
|
+
exports.isLiteralObject = isLiteralObject;
|
|
661
690
|
;
|
|
662
691
|
/**
|
|
663
692
|
* prepend 0 to a value to a given length
|
|
664
693
|
* @param value
|
|
665
694
|
* @param length
|
|
666
695
|
*/
|
|
667
|
-
|
|
696
|
+
function pad(what, size, ch = '0') {
|
|
668
697
|
let value;
|
|
669
698
|
if (!isString(what)) {
|
|
670
699
|
value = '' + what;
|
|
@@ -679,17 +708,19 @@ export function pad(what, size, ch = '0') {
|
|
|
679
708
|
return value.padStart(-size, ch);
|
|
680
709
|
}
|
|
681
710
|
}
|
|
711
|
+
exports.pad = pad;
|
|
682
712
|
/**
|
|
683
713
|
* return true if val is a finite number
|
|
684
714
|
*/
|
|
685
|
-
|
|
715
|
+
function isNumber(val) {
|
|
686
716
|
return typeof val === 'number' && isFinite(val);
|
|
687
717
|
}
|
|
718
|
+
exports.isNumber = isNumber;
|
|
688
719
|
/**
|
|
689
720
|
*
|
|
690
721
|
* @param name
|
|
691
722
|
*/
|
|
692
|
-
|
|
723
|
+
function waitFontLoading(name) {
|
|
693
724
|
// tip for waiting font loading:
|
|
694
725
|
// by default, body is created invisible ((opacity = 0)
|
|
695
726
|
// we create a div inside with the font we need to wait the loading
|
|
@@ -716,6 +747,7 @@ export function waitFontLoading(name) {
|
|
|
716
747
|
}, 0);
|
|
717
748
|
});
|
|
718
749
|
}
|
|
750
|
+
exports.waitFontLoading = waitFontLoading;
|
|
719
751
|
/**
|
|
720
752
|
*
|
|
721
753
|
* @param fn
|
|
@@ -727,15 +759,17 @@ export function waitFontLoading(name) {
|
|
|
727
759
|
* console.log( x );
|
|
728
760
|
* } )( );
|
|
729
761
|
*/
|
|
730
|
-
|
|
762
|
+
function deferCall(fn, tm = 0, ...args) {
|
|
731
763
|
setTimeout(fn, tm, ...args);
|
|
732
764
|
}
|
|
765
|
+
exports.deferCall = deferCall;
|
|
733
766
|
/**
|
|
734
767
|
*
|
|
735
768
|
*/
|
|
736
|
-
|
|
769
|
+
function asap(cb) {
|
|
737
770
|
requestAnimationFrame(cb);
|
|
738
771
|
}
|
|
772
|
+
exports.asap = asap;
|
|
739
773
|
/**
|
|
740
774
|
* micro md to html
|
|
741
775
|
*
|
|
@@ -750,7 +784,7 @@ export function asap(cb) {
|
|
|
750
784
|
* ### title lvl 3 ...
|
|
751
785
|
*
|
|
752
786
|
*/
|
|
753
|
-
|
|
787
|
+
function markdownToHtml(text) {
|
|
754
788
|
if (!text) {
|
|
755
789
|
return '';
|
|
756
790
|
}
|
|
@@ -833,10 +867,11 @@ export function markdownToHtml(text) {
|
|
|
833
867
|
}
|
|
834
868
|
return result.join('');
|
|
835
869
|
}
|
|
870
|
+
exports.markdownToHtml = markdownToHtml;
|
|
836
871
|
/**
|
|
837
872
|
*
|
|
838
873
|
*/
|
|
839
|
-
|
|
874
|
+
class NetworkError extends Error {
|
|
840
875
|
m_code;
|
|
841
876
|
constructor(a, b) {
|
|
842
877
|
if (a instanceof Response) {
|
|
@@ -852,11 +887,12 @@ export class NetworkError extends Error {
|
|
|
852
887
|
return this.m_code;
|
|
853
888
|
}
|
|
854
889
|
}
|
|
890
|
+
exports.NetworkError = NetworkError;
|
|
855
891
|
/**
|
|
856
892
|
* return the mouse pos in client coordinates
|
|
857
893
|
* handle correctly touch & mouse
|
|
858
894
|
*/
|
|
859
|
-
|
|
895
|
+
function getMousePos(ev, fromDoc) {
|
|
860
896
|
let x_name = 'offsetX', y_name = 'offsetY';
|
|
861
897
|
if (fromDoc) {
|
|
862
898
|
x_name = 'clientX';
|
|
@@ -882,6 +918,7 @@ export function getMousePos(ev, fromDoc) {
|
|
|
882
918
|
return new Point(0, 0);
|
|
883
919
|
}
|
|
884
920
|
}
|
|
921
|
+
exports.getMousePos = getMousePos;
|
|
885
922
|
/**
|
|
886
923
|
* clamp a value
|
|
887
924
|
* @param v - value to clamp
|
|
@@ -889,24 +926,28 @@ export function getMousePos(ev, fromDoc) {
|
|
|
889
926
|
* @param max - max value
|
|
890
927
|
* @returns clamped value
|
|
891
928
|
*/
|
|
892
|
-
|
|
929
|
+
function clamp(v, min, max) {
|
|
893
930
|
return Math.min(Math.max(v, min), max);
|
|
894
931
|
}
|
|
932
|
+
exports.clamp = clamp;
|
|
895
933
|
// :: HTML strings ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
896
|
-
|
|
934
|
+
class HtmlString extends String {
|
|
897
935
|
constructor(text) { super(text); }
|
|
898
936
|
static from(text) {
|
|
899
937
|
return new HtmlString(text);
|
|
900
938
|
}
|
|
901
939
|
}
|
|
902
|
-
|
|
940
|
+
exports.HtmlString = HtmlString;
|
|
941
|
+
function html(a, ...b) {
|
|
903
942
|
return HtmlString.from(String.raw(a, ...b));
|
|
904
943
|
}
|
|
905
|
-
|
|
944
|
+
exports.html = html;
|
|
945
|
+
function isHtmlString(val) {
|
|
906
946
|
return val instanceof HtmlString;
|
|
907
947
|
}
|
|
948
|
+
exports.isHtmlString = isHtmlString;
|
|
908
949
|
// :: CLIPBOARD ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
909
|
-
|
|
950
|
+
class Clipboard {
|
|
910
951
|
static copy(data) {
|
|
911
952
|
if (navigator.clipboard) {
|
|
912
953
|
navigator.clipboard.writeText(JSON.stringify(data));
|
|
@@ -921,6 +962,7 @@ export class Clipboard {
|
|
|
921
962
|
}
|
|
922
963
|
}
|
|
923
964
|
}
|
|
965
|
+
exports.Clipboard = Clipboard;
|
|
924
966
|
// :: CRC32 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
925
967
|
/**
|
|
926
968
|
* Calculates the CRC32 checksum of a string.
|
|
@@ -931,13 +973,14 @@ export class Clipboard {
|
|
|
931
973
|
* @return {String} checksum
|
|
932
974
|
* @api public
|
|
933
975
|
*/
|
|
934
|
-
|
|
976
|
+
function crc32(str) {
|
|
935
977
|
let crc = ~0;
|
|
936
978
|
for (let i = 0, l = str.length; i < l; i++) {
|
|
937
979
|
crc = (crc >>> 8) ^ crc32tab[(crc ^ str.charCodeAt(i)) & 0xff];
|
|
938
980
|
}
|
|
939
981
|
return Math.abs(crc ^ -1);
|
|
940
982
|
}
|
|
983
|
+
exports.crc32 = crc32;
|
|
941
984
|
var crc32tab = [
|
|
942
985
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
|
943
986
|
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
|
@@ -1013,7 +1056,8 @@ var crc32tab = [
|
|
|
1013
1056
|
* class MyClass extends mix(MyBaseClass).with(Mixin1, Mixin2) {
|
|
1014
1057
|
* }
|
|
1015
1058
|
**/
|
|
1016
|
-
|
|
1059
|
+
const mix = (superclass) => new MixinBuilder(superclass);
|
|
1060
|
+
exports.mix = mix;
|
|
1017
1061
|
class MixinBuilder {
|
|
1018
1062
|
superclass;
|
|
1019
1063
|
constructor(superclass) {
|
|
@@ -1040,7 +1084,7 @@ class MixinBuilder {
|
|
|
1040
1084
|
*
|
|
1041
1085
|
* @returns
|
|
1042
1086
|
*/
|
|
1043
|
-
|
|
1087
|
+
function classNames(...args) {
|
|
1044
1088
|
let result = '';
|
|
1045
1089
|
for (const cls of args) {
|
|
1046
1090
|
if (typeof cls === 'string') {
|
|
@@ -1055,7 +1099,8 @@ export function classNames(...args) {
|
|
|
1055
1099
|
}
|
|
1056
1100
|
return result;
|
|
1057
1101
|
}
|
|
1058
|
-
|
|
1102
|
+
exports.classNames = classNames;
|
|
1103
|
+
function generatePassword(length, rules) {
|
|
1059
1104
|
if (!length || length == undefined) {
|
|
1060
1105
|
length = 8;
|
|
1061
1106
|
}
|
|
@@ -1085,6 +1130,7 @@ export function generatePassword(length, rules) {
|
|
|
1085
1130
|
});
|
|
1086
1131
|
return shuffle(pswd);
|
|
1087
1132
|
}
|
|
1133
|
+
exports.generatePassword = generatePassword;
|
|
1088
1134
|
function shuffle(str, maxlength) {
|
|
1089
1135
|
let shuffled = str.split('').sort(() => {
|
|
1090
1136
|
return 0.5 - Math.random();
|
package/lib/tooltips.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,16 +23,18 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.initTooltips = exports.Tooltip = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const label_1 = require("./label");
|
|
30
|
+
const icon_1 = require("./icon");
|
|
31
|
+
const tools_1 = require("./tools");
|
|
29
32
|
let tipTmo;
|
|
30
33
|
let tooltip;
|
|
31
34
|
/**
|
|
32
35
|
*
|
|
33
36
|
*/
|
|
34
|
-
|
|
37
|
+
class Tooltip extends component_1.Component {
|
|
35
38
|
m_text;
|
|
36
39
|
set text(text) {
|
|
37
40
|
this.m_text.text = text;
|
|
@@ -40,8 +43,8 @@ export class Tooltip extends Component {
|
|
|
40
43
|
render() {
|
|
41
44
|
this.setClass('@non-maskable', true);
|
|
42
45
|
this.setContent([
|
|
43
|
-
new Icon({ icon: 'cls(far fa-circle-info)' }),
|
|
44
|
-
this.m_text = new Label({ text: 'help' })
|
|
46
|
+
new icon_1.Icon({ icon: 'cls(far fa-circle-info)' }),
|
|
47
|
+
this.m_text = new label_1.Label({ text: 'help' })
|
|
45
48
|
]);
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
@@ -75,8 +78,9 @@ export class Tooltip extends Component {
|
|
|
75
78
|
this.setStyle({ left: x, top: y });
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
exports.Tooltip = Tooltip;
|
|
82
|
+
function initTooltips(cb) {
|
|
83
|
+
if ((0, tools_1.isTouchDevice)()) {
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
82
86
|
let tipTarget = {
|
|
@@ -146,3 +150,4 @@ export function initTooltips(cb) {
|
|
|
146
150
|
document.body.addEventListener('mouseout', handle_mouse);
|
|
147
151
|
document.body.addEventListener('mousemove', handle_mpos);
|
|
148
152
|
}
|
|
153
|
+
exports.initTooltips = initTooltips;
|