x4js 1.4.4 → 1.4.7

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.
Files changed (85) hide show
  1. package/lib/application.d.ts +96 -0
  2. package/lib/application.js +146 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +139 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +81 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +241 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +241 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +358 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +156 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +130 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +588 -0
  19. package/lib/colorpicker.js +86 -80
  20. package/lib/combobox.js +26 -22
  21. package/lib/component.d.ts +572 -0
  22. package/lib/component.js +1729 -0
  23. package/lib/datastore.js +29 -20
  24. package/lib/dialog.js +41 -36
  25. package/lib/dom_events.d.ts +284 -0
  26. package/lib/dom_events.js +14 -0
  27. package/lib/drag_manager.js +4 -1
  28. package/lib/drawtext.js +9 -5
  29. package/lib/fileupload.js +19 -12
  30. package/lib/form.js +29 -25
  31. package/lib/formatters.js +19 -10
  32. package/lib/gridview.js +40 -35
  33. package/lib/hosts/host.d.ts +44 -0
  34. package/lib/hosts/host.js +73 -0
  35. package/lib/i18n.d.ts +67 -0
  36. package/lib/i18n.js +175 -0
  37. package/lib/icon.d.ts +56 -0
  38. package/lib/icon.js +178 -0
  39. package/lib/image.js +7 -3
  40. package/lib/index.js +71 -55
  41. package/lib/input.d.ts +86 -0
  42. package/lib/input.js +176 -0
  43. package/lib/label.d.ts +54 -0
  44. package/lib/label.js +90 -0
  45. package/lib/layout.d.ts +77 -0
  46. package/lib/layout.js +271 -0
  47. package/lib/link.js +9 -5
  48. package/lib/listview.js +34 -27
  49. package/lib/md5.js +5 -1
  50. package/lib/menu.d.ts +122 -0
  51. package/lib/menu.js +284 -0
  52. package/lib/messagebox.js +22 -17
  53. package/lib/panel.js +13 -9
  54. package/lib/popup.d.ts +71 -0
  55. package/lib/popup.js +378 -0
  56. package/lib/property_editor.js +20 -16
  57. package/lib/radiobtn.js +13 -9
  58. package/lib/rating.js +13 -9
  59. package/lib/request.js +16 -9
  60. package/lib/router.js +5 -1
  61. package/lib/settings.d.ts +33 -0
  62. package/lib/settings.js +67 -0
  63. package/lib/sidebarview.js +12 -8
  64. package/lib/smartedit.js +16 -11
  65. package/lib/spreadsheet.js +35 -31
  66. package/lib/styles.d.ts +81 -0
  67. package/lib/styles.js +268 -0
  68. package/lib/svgcomponent.js +8 -3
  69. package/lib/tabbar.js +10 -6
  70. package/lib/tabview.js +10 -6
  71. package/lib/textarea.js +10 -6
  72. package/lib/textedit.js +39 -35
  73. package/lib/texthiliter.js +8 -4
  74. package/lib/toaster.js +8 -4
  75. package/lib/tools.d.ts +382 -0
  76. package/lib/tools.js +1142 -0
  77. package/lib/tooltips.js +14 -9
  78. package/lib/treeview.js +30 -26
  79. package/lib/x4_events.d.ts +253 -0
  80. package/lib/x4_events.js +375 -0
  81. package/package.json +1 -1
  82. package/src/application.ts +9 -4
  83. package/src/x4.less +143 -107
  84. package/tsconfig.json +1 -1
  85. package/x4.css +1541 -0
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \_/ / / _
@@ -22,11 +23,13 @@
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
  **/
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.TextHiliter = void 0;
25
28
  /**
26
29
  * idea came from https://www.cdolivet.com/editarea
27
30
  */
28
- import { Component } from './component';
29
- export class TextHiliter extends Component {
31
+ const component_1 = require("./component");
32
+ class TextHiliter extends component_1.Component {
30
33
  m_text;
31
34
  m_ed;
32
35
  m_hi;
@@ -42,11 +45,11 @@ export class TextHiliter extends Component {
42
45
  /** @ignore */
43
46
  render() {
44
47
  this.setContent([
45
- this.m_hi = new Component({
48
+ this.m_hi = new component_1.Component({
46
49
  tag: 'span',
47
50
  cls: '@fit @syntax-hiliter',
48
51
  }),
49
- this.m_ed = new Component({
52
+ this.m_ed = new component_1.Component({
50
53
  tag: 'textarea',
51
54
  cls: '@fit',
52
55
  width: '100%',
@@ -217,3 +220,4 @@ export class TextHiliter extends Component {
217
220
  return result + '\n\n\n';
218
221
  }
219
222
  }
223
+ exports.TextHiliter = TextHiliter;
package/lib/toaster.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \_/ / / _
@@ -22,9 +23,11 @@
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
- import { Label } from "./label";
26
- import { Popup } from './popup';
27
- export class Toaster extends Popup {
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.Toaster = void 0;
28
+ const label_1 = require("./label");
29
+ const popup_1 = require("./popup");
30
+ class Toaster extends popup_1.Popup {
28
31
  m_message;
29
32
  m_icon;
30
33
  constructor(props) {
@@ -38,7 +41,7 @@ export class Toaster extends Popup {
38
41
  render() {
39
42
  this.addClass('@hlayout');
40
43
  this.setContent([
41
- new Label({ icon: this.m_icon, text: this.m_message })
44
+ new label_1.Label({ icon: this.m_icon, text: this.m_message })
42
45
  ]);
43
46
  }
44
47
  show() {
@@ -56,3 +59,4 @@ export class Toaster extends Popup {
56
59
  });
57
60
  }
58
61
  }
62
+ exports.Toaster = Toaster;
package/lib/tools.d.ts ADDED
@@ -0,0 +1,382 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file tools.ts
9
+ * @author Etienne Cochard
10
+ * @license
11
+ * Copyright (c) 2019-2021 R-libre ingenierie
12
+ *
13
+ * This program is free software; you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation; either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * 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
+ /**
26
+ * @return true is the device has touch
27
+ */
28
+ export declare function isTouchDevice(): boolean;
29
+ /**
30
+ * round to a given number of decimals
31
+ * @param num numbre to round
32
+ * @param ndec number of decimals
33
+ * @returns number rounded
34
+ */
35
+ export declare function roundTo(num: number, ndec: number): number;
36
+ /**
37
+ * parse an intl formatted number
38
+ * understand grouping and ',' separator
39
+ * @review us format: grouping = ','
40
+ * @param num
41
+ */
42
+ export declare function parseIntlFloat(num: string): number;
43
+ /**
44
+ * inverse of camel case
45
+ * theThingToCase -> the-thing-to-case
46
+ * @param {String} str
47
+ */
48
+ export declare function pascalCase(string: string): string;
49
+ export declare type Constructor<T> = new (...args: any[]) => T;
50
+ export declare class Point {
51
+ x: number;
52
+ y: number;
53
+ constructor(x?: number, y?: number);
54
+ }
55
+ export declare class Size {
56
+ width: number;
57
+ height: number;
58
+ constructor(w?: number, h?: number);
59
+ }
60
+ export declare class Rect {
61
+ left: number;
62
+ top: number;
63
+ width: number;
64
+ height: number;
65
+ constructor();
66
+ constructor(rc: Rect);
67
+ constructor(rc: DOMRect);
68
+ constructor(left: number, top: number, width: number, height: number);
69
+ set(left: number, top: number, width: number, height: number): void;
70
+ get bottom(): number;
71
+ set bottom(bottom: number);
72
+ get right(): number;
73
+ set right(right: number);
74
+ get topLeft(): Point;
75
+ get bottomRight(): Point;
76
+ get size(): Size;
77
+ moveTo(left: number, top: number): this;
78
+ movedTo(left: number, top: number): Rect;
79
+ moveBy(dx: number, dy: number): this;
80
+ movedBy(dx: number, dy: number): Rect;
81
+ isEmpty(): boolean;
82
+ normalize(): this;
83
+ normalized(): Rect;
84
+ /**
85
+ * @deprecated
86
+ */
87
+ containsPt(x: number, y: number): boolean;
88
+ contains(pt: Point): boolean;
89
+ contains(rc: Rect): boolean;
90
+ touches(rc: Rect): boolean;
91
+ inflate(dx: number, dy?: number): void;
92
+ inflatedBy(dx: number, dy?: number): Rect;
93
+ combine(rc: Rect): void;
94
+ }
95
+ /**
96
+ * replace {0..9} by given arguments
97
+ * @param format string
98
+ * @param args
99
+ *
100
+ * @example ```ts
101
+ *
102
+ * console.log( sprintf( 'here is arg 1 {1} and arg 0 {0}', 'argument 0', 'argument 1' ) )
103
+ */
104
+ export declare function sprintf(format: string, ...args: any[]): string;
105
+ /**
106
+ * replace special characters for display
107
+ * @param unsafe
108
+ *
109
+ * console.log( escapeHtml('<div style="width:50px; height: 50px; background-color:red"></div>') );
110
+ */
111
+ export declare function escapeHtml(unsafe: string, nl_br?: boolean): string;
112
+ /**
113
+ * replace special characters for display
114
+ * @author Steven Levithan <http://slevithan.com/>
115
+ * @param unsafe
116
+ *
117
+ * console.log( removeHtmlTags('<h1>sss</h1>') );
118
+ */
119
+ export declare function removeHtmlTags(unsafe: string, nl_br?: boolean): string;
120
+ /**
121
+ * change the current locale for misc translations (date...)
122
+ * @param locale
123
+ */
124
+ export declare function _date_set_locale(locale: string): void;
125
+ /**
126
+ *
127
+ * @param date
128
+ * @param options
129
+ * @example
130
+ * let date = new Date( );
131
+ * let options = { day: 'numeric', month: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric' };
132
+ * let text = date_format( date, options );
133
+ */
134
+ export declare function date_format(date: Date, options?: any): string;
135
+ /**
136
+ *
137
+ * @param date
138
+ * @param options
139
+ */
140
+ export declare function date_diff(date1: Date, date2: Date, options?: any): string;
141
+ export declare function date_to_sql(date: Date, withHours: boolean): string;
142
+ /**
143
+ * construct a date from an utc date time (sql format)
144
+ * YYYY-MM-DD HH:MM:SS
145
+ */
146
+ export declare function date_sql_utc(date: string): Date;
147
+ /**
148
+ * return a number that is a representation of the date
149
+ * this number can be compared with another hash
150
+ */
151
+ export declare function date_hash(date: Date): number;
152
+ /**
153
+ * return a copy of a date
154
+ */
155
+ export declare function date_clone(date: Date): Date;
156
+ /**
157
+ * return the week number of a date
158
+ */
159
+ export declare function date_calc_weeknum(date: Date): number;
160
+ /**
161
+ * parse a date according to the given format
162
+ * @param value - string date to parse
163
+ * @param fmts - format list - i18 tranlation by default
164
+ * allowed format specifiers:
165
+ * d or D: date (1 or 2 digits)
166
+ * m or M: month (1 or 2 digits)
167
+ * y or Y: year (2 or 4 digits)
168
+ * h or H: hours (1 or 2 digits)
169
+ * i or I: minutes (1 or 2 digits)
170
+ * s or S: seconds (1 or 2 digits)
171
+ * <space>: 1 or more spaces
172
+ * any other char: <0 or more spaces><the char><0 or more spaces>
173
+ * each specifiers is separated from other by a pipe (|)
174
+ * more specific at first
175
+ * @example
176
+ * 'd/m/y|d m Y|dmy|y-m-d h:i:s|y-m-d'
177
+ */
178
+ export declare function parseIntlDate(value: string, fmts?: string): Date;
179
+ /**
180
+ * format a date as string
181
+ * @param date - date to format
182
+ * @param fmt - format
183
+ * format specifiers:
184
+ * d: date
185
+ * D: 2 digits date padded with 0
186
+ * j: day of week short mode 'mon'
187
+ * J: day of week long mode 'monday'
188
+ * w: week number
189
+ * m: month
190
+ * M: 2 digits month padded with 0
191
+ * o: month short mode 'jan'
192
+ * O: month long mode 'january'
193
+ * y or Y: year
194
+ * h: hour (24 format)
195
+ * H: 2 digits hour (24 format) padded with 0
196
+ * i: minutes
197
+ * I: 2 digits minutes padded with 0
198
+ * s: seconds
199
+ * S: 2 digits seconds padded with 0
200
+ * a: am or pm
201
+ * anything else is inserted
202
+ * if you need to insert some text, put it between {}
203
+ *
204
+ * @example
205
+ *
206
+ * 01/01/1970 11:25:00 with '{this is my demo date formatter: }H-i*M'
207
+ * "this is my demo date formatter: 11-25*january"
208
+ */
209
+ export declare function formatIntlDate(date: Date, fmt?: string): string;
210
+ export declare function calcAge(birth: Date, ref?: Date): number;
211
+ /**
212
+ * date object patch
213
+ */
214
+ declare global {
215
+ interface Date {
216
+ hash(): number;
217
+ clone(): Date;
218
+ weekNum(): number;
219
+ format(format: string): string;
220
+ isSameDay(date: Date): boolean;
221
+ addDays(days: number): any;
222
+ }
223
+ }
224
+ /**
225
+ *
226
+ * @param data data to export
227
+ * @param mimetype - 'text/plain'
228
+ */
229
+ export declare function downloadData(data: any, mimetype: string, filename: string): void;
230
+ /**
231
+ * check if a value is a string
232
+ * @param val
233
+ */
234
+ export declare function isString(val: any): val is string;
235
+ /**
236
+ * check is a value is an array
237
+ * @param val
238
+ */
239
+ export declare function isArray(val: any): val is any[];
240
+ /**
241
+ *
242
+ */
243
+ export declare function isFunction(val: any): val is Function;
244
+ /**
245
+ *
246
+ */
247
+ export declare function isLiteralObject(val: any): boolean;
248
+ /**
249
+ * prepend 0 to a value to a given length
250
+ * @param value
251
+ * @param length
252
+ */
253
+ export declare function pad(what: unknown, size: number, ch?: string): string;
254
+ /**
255
+ * return true if val is a finite number
256
+ */
257
+ export declare function isNumber(val: any): val is number;
258
+ /**
259
+ *
260
+ * @param name
261
+ */
262
+ export declare function waitFontLoading(name: string): Promise<void>;
263
+ /**
264
+ *
265
+ * @param fn
266
+ * @param tm
267
+ *
268
+ * @example:
269
+ *
270
+ * defer( ( ) => {
271
+ * console.log( x );
272
+ * } )( );
273
+ */
274
+ export declare function deferCall(fn: Function, tm?: number, ...args: any[]): void;
275
+ /**
276
+ *
277
+ */
278
+ export declare function asap(cb: (time: number) => void): void;
279
+ /**
280
+ * micro md to html
281
+ *
282
+ * understand:
283
+ * **bold**
284
+ * *italic*
285
+ *
286
+ * > quote
287
+ * - list
288
+ * # title lvl 1
289
+ * ## title lvl 2
290
+ * ### title lvl 3 ...
291
+ *
292
+ */
293
+ export declare function markdownToHtml(text: string): string;
294
+ /**
295
+ *
296
+ */
297
+ export declare class NetworkError extends Error {
298
+ private m_code;
299
+ constructor(response: Response);
300
+ constructor(code: number, text: string);
301
+ get code(): number;
302
+ }
303
+ /**
304
+ * return the mouse pos in client coordinates
305
+ * handle correctly touch & mouse
306
+ */
307
+ export declare function getMousePos(ev: UIEvent, fromDoc: boolean): Point;
308
+ /**
309
+ * clamp a value
310
+ * @param v - value to clamp
311
+ * @param min - min value
312
+ * @param max - max value
313
+ * @returns clamped value
314
+ */
315
+ export declare function clamp(v: number, min: number, max: number): number;
316
+ /**
317
+ *
318
+ */
319
+ export interface IDisposable {
320
+ dispose(): any;
321
+ }
322
+ export declare class HtmlString extends String {
323
+ constructor(text: string);
324
+ static from(text: string): HtmlString;
325
+ }
326
+ export declare function html(a: any, ...b: any[]): HtmlString;
327
+ export declare function isHtmlString(val: any): val is HtmlString;
328
+ export declare class Clipboard {
329
+ static copy(data: any): void;
330
+ static paste(cb: (data: string) => void): void;
331
+ }
332
+ /**
333
+ * Calculates the CRC32 checksum of a string.
334
+ * taken from: https://gist.github.com/wqli78/1330293/6d85cc967f32cccfcbad94ae7d088a3dcfc14bd9
335
+ *
336
+ * @param {String} str
337
+ * @param {Boolean} hex
338
+ * @return {String} checksum
339
+ * @api public
340
+ */
341
+ export declare function crc32(str: any): number;
342
+ /**
343
+ * taken from this excellent article:
344
+ * https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
345
+ *
346
+ * @example:
347
+ * class MyClass extends mix(MyBaseClass).with(Mixin1, Mixin2) {
348
+ * }
349
+ **/
350
+ export declare const mix: (superclass: any) => MixinBuilder;
351
+ declare class MixinBuilder {
352
+ private superclass;
353
+ constructor(superclass: any);
354
+ with(...mixins: any[]): any;
355
+ }
356
+ /**
357
+ * @example
358
+ *
359
+ * ```
360
+ * const cls = classNames( 'class1 class2', {
361
+ * 'class3': false,
362
+ * 'class4': true,
363
+ * });
364
+ *
365
+ * // even shorter
366
+ * const class1 = true, class2 = false;
367
+ * const cls = classNames( { class1, class2 } ); // cls = "class1"
368
+ *
369
+ * ```
370
+ *
371
+ * @returns
372
+ */
373
+ export declare function classNames(...args: (string | any)[]): string;
374
+ /**
375
+ *
376
+ */
377
+ interface PasswordRule {
378
+ chars: string;
379
+ min: number;
380
+ }
381
+ export declare function generatePassword(length: number, rules?: PasswordRule[]): string;
382
+ export {};