x4js 1.4.2

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 (176) hide show
  1. package/lib/application.d.ts +95 -0
  2. package/lib/application.js +137 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +135 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +77 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +235 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +236 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +354 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +152 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +126 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +584 -0
  19. package/lib/colorpicker.d.ts +98 -0
  20. package/lib/colorpicker.js +1457 -0
  21. package/lib/combobox.d.ts +97 -0
  22. package/lib/combobox.js +246 -0
  23. package/lib/component.d.ts +572 -0
  24. package/lib/component.js +1712 -0
  25. package/lib/datastore.d.ts +392 -0
  26. package/lib/datastore.js +986 -0
  27. package/lib/dialog.d.ts +171 -0
  28. package/lib/dialog.js +468 -0
  29. package/lib/dom_events.d.ts +284 -0
  30. package/lib/dom_events.js +13 -0
  31. package/lib/drag_manager.d.ts +26 -0
  32. package/lib/drag_manager.js +118 -0
  33. package/lib/drawtext.d.ts +43 -0
  34. package/lib/drawtext.js +261 -0
  35. package/lib/fileupload.d.ts +60 -0
  36. package/lib/fileupload.js +158 -0
  37. package/lib/form.d.ts +122 -0
  38. package/lib/form.js +293 -0
  39. package/lib/formatters.d.ts +31 -0
  40. package/lib/formatters.js +75 -0
  41. package/lib/gridview.d.ts +171 -0
  42. package/lib/gridview.js +786 -0
  43. package/lib/hosts/host.d.ts +44 -0
  44. package/lib/hosts/host.js +69 -0
  45. package/lib/i18n.d.ts +67 -0
  46. package/lib/i18n.js +169 -0
  47. package/lib/icon.d.ts +56 -0
  48. package/lib/icon.js +173 -0
  49. package/lib/image.d.ts +51 -0
  50. package/lib/image.js +149 -0
  51. package/lib/index.js +1 -0
  52. package/lib/input.d.ts +86 -0
  53. package/lib/input.js +172 -0
  54. package/lib/label.d.ts +54 -0
  55. package/lib/label.js +86 -0
  56. package/lib/layout.d.ts +77 -0
  57. package/lib/layout.js +261 -0
  58. package/lib/link.d.ts +46 -0
  59. package/lib/link.js +55 -0
  60. package/lib/listview.d.ts +173 -0
  61. package/lib/listview.js +532 -0
  62. package/lib/md5.d.ts +56 -0
  63. package/lib/md5.js +397 -0
  64. package/lib/menu.d.ts +122 -0
  65. package/lib/menu.js +276 -0
  66. package/lib/messagebox.d.ts +64 -0
  67. package/lib/messagebox.js +141 -0
  68. package/lib/panel.d.ts +42 -0
  69. package/lib/panel.js +61 -0
  70. package/lib/popup.d.ts +71 -0
  71. package/lib/popup.js +373 -0
  72. package/lib/property_editor.d.ts +67 -0
  73. package/lib/property_editor.js +247 -0
  74. package/lib/radiobtn.d.ts +68 -0
  75. package/lib/radiobtn.js +131 -0
  76. package/lib/rating.d.ts +49 -0
  77. package/lib/rating.js +93 -0
  78. package/lib/request.d.ts +48 -0
  79. package/lib/request.js +220 -0
  80. package/lib/router.d.ts +13 -0
  81. package/lib/router.js +27 -0
  82. package/lib/settings.d.ts +33 -0
  83. package/lib/settings.js +63 -0
  84. package/lib/sidebarview.d.ts +44 -0
  85. package/lib/sidebarview.js +73 -0
  86. package/lib/smartedit.d.ts +103 -0
  87. package/lib/smartedit.js +381 -0
  88. package/lib/spreadsheet.d.ts +214 -0
  89. package/lib/spreadsheet.js +1073 -0
  90. package/lib/styles.d.ts +81 -0
  91. package/lib/styles.js +262 -0
  92. package/lib/svgcomponent.d.ts +165 -0
  93. package/lib/svgcomponent.js +350 -0
  94. package/lib/tabbar.d.ts +41 -0
  95. package/lib/tabbar.js +66 -0
  96. package/lib/tabview.d.ts +45 -0
  97. package/lib/tabview.js +79 -0
  98. package/lib/textarea.d.ts +59 -0
  99. package/lib/textarea.js +119 -0
  100. package/lib/textedit.d.ts +118 -0
  101. package/lib/textedit.js +406 -0
  102. package/lib/texthiliter.d.ts +56 -0
  103. package/lib/texthiliter.js +219 -0
  104. package/lib/toaster.d.ts +38 -0
  105. package/lib/toaster.js +58 -0
  106. package/lib/tools.d.ts +382 -0
  107. package/lib/tools.js +1096 -0
  108. package/lib/tooltips.d.ts +42 -0
  109. package/lib/tooltips.js +148 -0
  110. package/lib/treeview.d.ts +128 -0
  111. package/lib/treeview.js +490 -0
  112. package/lib/x4_events.d.ts +253 -0
  113. package/lib/x4_events.js +363 -0
  114. package/package.json +21 -0
  115. package/src/README.md +2 -0
  116. package/src/application.ts +191 -0
  117. package/src/base64.ts +162 -0
  118. package/src/base_component.ts +118 -0
  119. package/src/button.ts +327 -0
  120. package/src/calendar.ts +312 -0
  121. package/src/canvas.ts +501 -0
  122. package/src/cardview.ts +220 -0
  123. package/src/checkbox.ts +178 -0
  124. package/src/color.ts +748 -0
  125. package/src/colorpicker.ts +1618 -0
  126. package/src/combobox.ts +348 -0
  127. package/src/component.ts +2330 -0
  128. package/src/datastore.ts +1318 -0
  129. package/src/dialog.ts +631 -0
  130. package/src/dom_events.ts +297 -0
  131. package/src/drag_manager.ts +168 -0
  132. package/src/drawtext.ts +342 -0
  133. package/src/fileupload.ts +208 -0
  134. package/src/form.ts +362 -0
  135. package/src/formatters.ts +96 -0
  136. package/src/gridview.ts +1051 -0
  137. package/src/hosts/electron.ts +161 -0
  138. package/src/hosts/host.ts +100 -0
  139. package/src/hosts/nwjs.ts +141 -0
  140. package/src/hosts/nwjs_types.ts +339 -0
  141. package/src/i18n.ts +205 -0
  142. package/src/icon.ts +237 -0
  143. package/src/image.ts +198 -0
  144. package/src/input.ts +236 -0
  145. package/src/label.ts +124 -0
  146. package/src/layout.ts +366 -0
  147. package/src/link.ts +82 -0
  148. package/src/listview.ts +749 -0
  149. package/src/md5.ts +432 -0
  150. package/src/menu.ts +394 -0
  151. package/src/messagebox.ts +199 -0
  152. package/src/panel.ts +81 -0
  153. package/src/popup.ts +488 -0
  154. package/src/property_editor.ts +333 -0
  155. package/src/radiobtn.ts +190 -0
  156. package/src/rating.ts +131 -0
  157. package/src/request.ts +296 -0
  158. package/src/router.ts +43 -0
  159. package/src/settings.ts +75 -0
  160. package/src/sidebarview.ts +97 -0
  161. package/src/smartedit.ts +532 -0
  162. package/src/spreadsheet.ts +1423 -0
  163. package/src/styles.ts +332 -0
  164. package/src/svgcomponent.ts +440 -0
  165. package/src/tabbar.ts +105 -0
  166. package/src/tabview.ts +106 -0
  167. package/src/textarea.ts +183 -0
  168. package/src/textedit.ts +535 -0
  169. package/src/texthiliter.ts +284 -0
  170. package/src/toaster.ts +76 -0
  171. package/src/tools.ts +1391 -0
  172. package/src/tooltips.ts +185 -0
  173. package/src/treeview.ts +670 -0
  174. package/src/x4.less +1940 -0
  175. package/src/x4_events.ts +558 -0
  176. package/tsconfig.json +14 -0
@@ -0,0 +1,392 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file datastore.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
+ import { BasicEvent, EvChange, EventSource, EventMap } from './x4_events';
26
+ import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component';
27
+ export declare type ChangeCallback = (type: string, id?: any) => void;
28
+ export declare type CalcCallback = () => string;
29
+ export declare type FieldType = 'string' | 'int' | 'float' | 'date' | 'bool' | 'array' | 'object' | 'any' | 'calc';
30
+ export declare type DataIndex = Uint32Array;
31
+ interface EvDataChange extends BasicEvent {
32
+ type: string;
33
+ id: any;
34
+ }
35
+ declare function EvDataChange(type: 'create' | 'update' | 'delete' | 'data' | 'change', id?: any): EvDataChange;
36
+ /**
37
+ * fields definition
38
+ * field with index=0 is record id
39
+ */
40
+ export interface MetaData {
41
+ type?: FieldType;
42
+ prec?: number;
43
+ required?: boolean;
44
+ calc?: (rec: Record) => any;
45
+ model?: Record;
46
+ }
47
+ export interface FieldInfo extends MetaData {
48
+ name: string;
49
+ }
50
+ export declare namespace data {
51
+ /**
52
+ * define a record id
53
+ * @example
54
+ * \@data_id()
55
+ * id: string; // this field is the record id
56
+ **/
57
+ export function id(): (ownerCls: any, fldName: any) => void;
58
+ /**
59
+ * @ignore
60
+ */
61
+ export function field(data: MetaData): (ownerCls: any, fldName: any) => void;
62
+ /**
63
+ * following member is a string field
64
+ * @example
65
+ * \@data_string()
66
+ * my_field: string; // this field will be seen as a string
67
+ */
68
+ export function string(props?: MetaData): (ownerCls: any, fldName: any) => void;
69
+ /**
70
+ * following member is an integer field
71
+ * @example
72
+ * \@data_string()
73
+ * my_field: number; // this field will be seen as an integer
74
+ */
75
+ export function int(props?: MetaData): (ownerCls: any, fldName: any) => void;
76
+ /**
77
+ * following member is a float field
78
+ * @example
79
+ * \@data_float()
80
+ * my_field: number; // this field will be seen as a float
81
+ */
82
+ export function float(props?: MetaData): (ownerCls: any, fldName: any) => void;
83
+ /**
84
+ * following member is a boolean field
85
+ * @example
86
+ * \@data_bool()
87
+ * my_field: boolean; // this field will be seen as a boolean
88
+ */
89
+ export function bool(props?: MetaData): (ownerCls: any, fldName: any) => void;
90
+ /**
91
+ * following member is a date field
92
+ * @example
93
+ * \@data_date()
94
+ * my_field: date; // this field will be seen as a date
95
+ */
96
+ export function date(props?: MetaData): (ownerCls: any, fldName: any) => void;
97
+ /**
98
+ * following member is a calculated field
99
+ * @example
100
+ * \@data_calc( )
101
+ * get my_field(): string => {
102
+ * return 'hello';
103
+ * };
104
+ */
105
+ export function calc(props?: MetaData): (ownerCls: any, fldName: any) => void;
106
+ /**
107
+ *
108
+ */
109
+ interface RecordConstructor {
110
+ new (data?: any, id?: any): Record;
111
+ }
112
+ /**
113
+ * following member is a record array
114
+ * @example
115
+ * \@data_array( )
116
+ * my_field(): TypedRecord[];
117
+ */
118
+ export function array(ctor: RecordConstructor, props?: MetaData): (ownerCls: any, fldName: any) => void;
119
+ export {};
120
+ }
121
+ /**
122
+ * record model
123
+ */
124
+ export declare class Record {
125
+ constructor(data?: any, id?: any);
126
+ clone(source?: any): any;
127
+ /**
128
+ * get the record unique identifier
129
+ * by default the return value is the first field
130
+ * @return unique identifier
131
+ */
132
+ getID(): any;
133
+ /**
134
+ * MUST IMPLEMENT
135
+ * @returns fields descriptors
136
+ */
137
+ getFields(): FieldInfo[];
138
+ /**
139
+ *
140
+ */
141
+ validate(): Error[];
142
+ getFieldIndex(name: string): number;
143
+ /**
144
+ * default serializer
145
+ * @returns an object with known record values
146
+ */
147
+ serialize(): any;
148
+ /**
149
+ * default unserializer
150
+ * @param data - input data
151
+ * @returns a new Record
152
+ */
153
+ unSerialize(data: any, id?: any): Record;
154
+ /**
155
+ * field conversion
156
+ * @param field - field descriptor
157
+ * @param input - value to convert
158
+ * @returns the field value in it's original form
159
+ */
160
+ protected _convertField(field: FieldInfo, input: any): any;
161
+ /**
162
+ * get raw value of a field
163
+ * @param name - field name or field index
164
+ */
165
+ getRaw(name: string | number): any;
166
+ /**
167
+ *
168
+ * @param name
169
+ * @param data
170
+ */
171
+ setRaw(name: string, data: string): void;
172
+ /**
173
+ * get field value (as string)
174
+ * @param name - field name
175
+ * @example
176
+ * let value = record.get('field1');
177
+ */
178
+ getField(name: string): string;
179
+ /**
180
+ * set field value
181
+ * @param name - field name
182
+ * @param value - value to set
183
+ * @example
184
+ * record.set( 'field1', 7 );
185
+ */
186
+ setField(name: string, value: any): void;
187
+ }
188
+ /**
189
+ * by default, the field id is rhe first member or the record
190
+ */
191
+ export declare class AutoRecord extends Record {
192
+ private m_data;
193
+ private m_fid;
194
+ constructor(data: any);
195
+ getID(): any;
196
+ getFields(): FieldInfo[];
197
+ getRaw(name: string): string;
198
+ setRaw(name: string, data: string): void;
199
+ clone(data: any): AutoRecord;
200
+ }
201
+ /**
202
+ *
203
+ */
204
+ interface DataEventMap extends BaseComponentEventMap {
205
+ change?: EvChange;
206
+ }
207
+ export interface DataProxyProps extends BaseComponentProps<DataEventMap> {
208
+ type: 'local' | 'immediate' | 'ajax';
209
+ path?: string;
210
+ params?: any;
211
+ }
212
+ export declare class DataProxy extends BaseComponent<DataProxyProps, DataEventMap> {
213
+ constructor(props: DataProxyProps);
214
+ load(): void;
215
+ save(data: any): void;
216
+ private _refresh;
217
+ }
218
+ /**
219
+ *
220
+ */
221
+ interface DataStoreProps extends BaseComponentProps<DataStoreEventMap> {
222
+ model: Record;
223
+ data?: Record[];
224
+ url?: string;
225
+ }
226
+ interface DataStoreEventMap extends EventMap {
227
+ data_change: EvDataChange;
228
+ }
229
+ /**
230
+ *
231
+ */
232
+ export declare class DataStore extends EventSource<DataStoreEventMap> {
233
+ protected m_model: Record;
234
+ protected m_fields: FieldInfo[];
235
+ protected m_records: Record[];
236
+ protected m_proxy: DataProxy;
237
+ protected m_rec_index: DataIndex;
238
+ constructor(props: DataStoreProps);
239
+ /**
240
+ *
241
+ * @param records
242
+ */
243
+ load(url: string): void;
244
+ reload(): void;
245
+ /**
246
+ * convert raw objects to real records from model
247
+ * @param records
248
+ */
249
+ setData(records: any[]): void;
250
+ /**
251
+ * just set the records
252
+ * @param records - must be of the same type as model
253
+ */
254
+ setRawData(records: any[]): void;
255
+ private _rebuildIndex;
256
+ /**
257
+ *
258
+ */
259
+ update(rec: Record): boolean;
260
+ /**
261
+ *
262
+ * @param data
263
+ */
264
+ append(rec: Record | any): void;
265
+ /**
266
+ *
267
+ */
268
+ getMaxId(): any;
269
+ /**
270
+ *
271
+ * @param id
272
+ */
273
+ delete(id: any): boolean;
274
+ /**
275
+ * return the number of records
276
+ */
277
+ get count(): number;
278
+ /**
279
+ * return the fields
280
+ */
281
+ get fields(): FieldInfo[];
282
+ /**
283
+ * find the index of the element with the given id
284
+ */
285
+ indexOfId(id: any): number;
286
+ /**
287
+ * return the record by it's id
288
+ * @returns record or null
289
+ */
290
+ getById(id: any): Record;
291
+ /**
292
+ * return a record by it's index
293
+ * @returns record or null
294
+ */
295
+ getByIndex(index: number): Record;
296
+ private _getRecord;
297
+ moveTo(other: DataStore): void;
298
+ /**
299
+ * create a new view on the DataStore
300
+ * @param opts
301
+ */
302
+ createView(opts?: DataViewProps): DataView;
303
+ /**
304
+ *
305
+ */
306
+ createIndex(filter: FilterInfo): DataIndex;
307
+ sortIndex(index: DataIndex, sort: SortProp[]): Uint32Array;
308
+ /**
309
+ *
310
+ */
311
+ forEach(cb: (rec: Record, index: number) => any): void;
312
+ export(): Record[];
313
+ changed(): void;
314
+ }
315
+ export interface EvViewChange extends BasicEvent {
316
+ action: string;
317
+ }
318
+ export declare function EvViewChange(action: 'filter' | 'sort' | 'change'): EvViewChange;
319
+ interface DataViewEventMap extends BaseComponentEventMap {
320
+ view_change: EvViewChange;
321
+ }
322
+ interface DataViewProps extends BaseComponentProps<DataViewEventMap> {
323
+ store?: DataStore;
324
+ filter?: FilterInfo;
325
+ order?: string | SortProp[] | SortProp;
326
+ }
327
+ export declare type FilterFunc = (rec: Record) => boolean;
328
+ export interface FilterInfo {
329
+ op: '<' | '<=' | '=' | '>=' | '>' | '<>' | 'empty-result' | FilterFunc;
330
+ field?: string;
331
+ value?: string | RegExp;
332
+ caseSensitive?: boolean;
333
+ }
334
+ export interface SortProp {
335
+ field: string;
336
+ ascending: boolean;
337
+ }
338
+ /**
339
+ * Dataview allow different views of the DataStore.
340
+ * You can sort the columns & filter data
341
+ * You can have multiple views for a single DataStore
342
+ */
343
+ export declare class DataView extends BaseComponent<DataViewProps, DataViewEventMap> {
344
+ protected m_index: DataIndex;
345
+ protected m_store: DataStore;
346
+ protected m_sort: SortProp[];
347
+ protected m_filter: FilterInfo;
348
+ constructor(props: DataViewProps);
349
+ private _storeChange;
350
+ /**
351
+ *
352
+ * @param filter
353
+ */
354
+ filter(filter?: FilterInfo): number;
355
+ private _filter;
356
+ /**
357
+ *
358
+ * @param columns
359
+ * @param ascending
360
+ */
361
+ sort(props: SortProp[]): void;
362
+ private _sort;
363
+ /**
364
+ *
365
+ */
366
+ get store(): DataStore;
367
+ /**
368
+ *
369
+ */
370
+ get count(): number;
371
+ /**
372
+ *
373
+ * @param id
374
+ */
375
+ indexOfId(id: any): number;
376
+ /**
377
+ *
378
+ * @param index
379
+ */
380
+ getByIndex(index: number): Record;
381
+ /**
382
+ *
383
+ * @param id
384
+ */
385
+ getById(id: any): Record;
386
+ changed(): void;
387
+ /**
388
+ *
389
+ */
390
+ forEach(cb: (rec: Record, index: number) => any): void;
391
+ }
392
+ export {};