tsgrid-ui 1.0.0
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/CHANGELOG.md +50 -0
- package/LICENSE +22 -0
- package/MIGRATION-FROM-W2UI.md +191 -0
- package/dist/tsgrid-ui.css +4264 -0
- package/dist/tsgrid-ui.d.ts +2432 -0
- package/dist/tsgrid-ui.es6.js +24236 -0
- package/dist/tsgrid-ui.js +24309 -0
- package/dist/tsgrid-ui.min.css +2 -0
- package/package.json +88 -0
- package/readme.md +107 -0
|
@@ -0,0 +1,2432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Part of TsUi 2.0 library
|
|
3
|
+
* - Dependencies: TsUtils
|
|
4
|
+
* - on/off/trigger methods id not showing in help
|
|
5
|
+
* - refactored with event object
|
|
6
|
+
*
|
|
7
|
+
* Chanes in 2.0.+
|
|
8
|
+
* - added unmount that cleans up the box
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
interface TsEventData {
|
|
12
|
+
type?: string | null;
|
|
13
|
+
target?: unknown;
|
|
14
|
+
phase?: string;
|
|
15
|
+
object?: unknown;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface TsEventListener {
|
|
19
|
+
name: string;
|
|
20
|
+
edata: {
|
|
21
|
+
type: string | null;
|
|
22
|
+
execute: string;
|
|
23
|
+
onComplete: null;
|
|
24
|
+
scope?: string;
|
|
25
|
+
handler?: unknown;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
handler: Function;
|
|
29
|
+
}
|
|
30
|
+
declare class TsEvent {
|
|
31
|
+
type: string | null;
|
|
32
|
+
detail: TsEventData;
|
|
33
|
+
owner: TsBase;
|
|
34
|
+
target: unknown;
|
|
35
|
+
phase: string;
|
|
36
|
+
object: unknown;
|
|
37
|
+
execute: null;
|
|
38
|
+
isStopped: boolean;
|
|
39
|
+
isCancelled: boolean;
|
|
40
|
+
onComplete: ((edata: TsEvent) => void) | null;
|
|
41
|
+
listeners: Array<(edata: TsEvent) => void>;
|
|
42
|
+
complete: Promise<TsEvent>;
|
|
43
|
+
_resolve: (value: TsEvent) => void;
|
|
44
|
+
_reject: (reason?: unknown) => void;
|
|
45
|
+
constructor(owner: TsBase, edata: TsEventData);
|
|
46
|
+
finish(detail?: Partial<TsEventData>): void;
|
|
47
|
+
done(func: (edata: TsEvent) => void): void;
|
|
48
|
+
preventDefault(): void;
|
|
49
|
+
stopPropagation(): void;
|
|
50
|
+
}
|
|
51
|
+
declare class TsBase {
|
|
52
|
+
activeEvents: TsEvent[];
|
|
53
|
+
listeners: TsEventListener[];
|
|
54
|
+
debug: boolean;
|
|
55
|
+
name?: string;
|
|
56
|
+
box?: HTMLElement | null;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
/**
|
|
59
|
+
* Initializes base object for TsUi, registers it with TsUi object
|
|
60
|
+
*
|
|
61
|
+
* @param {string} name - name of the object
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
constructor(name?: string);
|
|
65
|
+
/**
|
|
66
|
+
* Adds event listener, supports event phase and event scoping
|
|
67
|
+
*
|
|
68
|
+
* @param {*} edata - an object or string, if string "eventName:phase.scope"
|
|
69
|
+
* @param {*} handler
|
|
70
|
+
* @returns itself
|
|
71
|
+
*/
|
|
72
|
+
on(events: string | TsEventData | Array<string | TsEventData>, handler: Function): this;
|
|
73
|
+
/**
|
|
74
|
+
* Removes event listener, supports event phase and event scoping
|
|
75
|
+
*
|
|
76
|
+
* @param {*} edata - an object or string, if string "eventName:phase.scope"
|
|
77
|
+
* @param {*} handler
|
|
78
|
+
* @returns itself
|
|
79
|
+
*/
|
|
80
|
+
off(events: string | TsEventData | Array<string | TsEventData>, handler?: Function): this;
|
|
81
|
+
/**
|
|
82
|
+
* Triggers even listeners for a specific event, loops through this.listeners
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} edata - Object
|
|
85
|
+
* @returns modified edata
|
|
86
|
+
*
|
|
87
|
+
* NOTE: `edata` is typed as `any` here intentionally. The method mutates the argument
|
|
88
|
+
* from TsEventData into a TsEvent mid-execution. Runtime type mutation is inherent
|
|
89
|
+
* to the event dispatch pattern. Phase 6 strict tighten will revisit this.
|
|
90
|
+
*/
|
|
91
|
+
trigger(eventName: string | TsEventData | TsEvent, edataIn?: TsEventData): TsEvent;
|
|
92
|
+
/**
|
|
93
|
+
* This method renders component into the box. It is overwritten in descendents and in this base
|
|
94
|
+
* component it is empty.
|
|
95
|
+
*/
|
|
96
|
+
render(_box?: HTMLElement | string | null): void;
|
|
97
|
+
/**
|
|
98
|
+
* Removes all classes that start with tsg-* and sets box to null. It is needed so that control will
|
|
99
|
+
* release the box to be used for other widgets
|
|
100
|
+
*/
|
|
101
|
+
unmount(): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type QuerySelector = string | Node | Window | Query | Array<Node | Element> | Iterable<Node | Element> | null | undefined;
|
|
105
|
+
type QueryContext = Document | Element | ShadowRoot | DocumentFragment;
|
|
106
|
+
interface EventRecord {
|
|
107
|
+
event: string;
|
|
108
|
+
scope: string | undefined;
|
|
109
|
+
callback: EventListener;
|
|
110
|
+
options: AddEventListenerOptions | boolean | undefined;
|
|
111
|
+
}
|
|
112
|
+
interface MQueryData {
|
|
113
|
+
events?: EventRecord[];
|
|
114
|
+
prevDisplay?: string;
|
|
115
|
+
[key: string]: unknown;
|
|
116
|
+
}
|
|
117
|
+
declare global {
|
|
118
|
+
interface Node {
|
|
119
|
+
_mQuery?: MQueryData;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
declare class Query {
|
|
123
|
+
static version: number;
|
|
124
|
+
context: QueryContext;
|
|
125
|
+
nodes: Node[];
|
|
126
|
+
length: number;
|
|
127
|
+
[index: number]: Node;
|
|
128
|
+
constructor(selector: QuerySelector, context?: QueryContext);
|
|
129
|
+
static _fragment(html: string): DocumentFragment;
|
|
130
|
+
static _scriptConvert(node: Node): Node;
|
|
131
|
+
static _fixProp(name: string): string;
|
|
132
|
+
_insert(method: string, html: string | Query | Node): Query;
|
|
133
|
+
_save(node: Node, name: string, value: unknown): void;
|
|
134
|
+
get(index?: number): Node | Node[] | null;
|
|
135
|
+
eq(index: number): Query;
|
|
136
|
+
then(fun: (q: Query) => Query | null | undefined): Query;
|
|
137
|
+
find(selector: string): Query;
|
|
138
|
+
filter(selector: string | Node | ((node: Node) => boolean)): Query;
|
|
139
|
+
next(): Query;
|
|
140
|
+
prev(): Query;
|
|
141
|
+
shadow(selector?: string): Query;
|
|
142
|
+
closest(selector: string): Query;
|
|
143
|
+
host(all?: boolean): Query;
|
|
144
|
+
parent(selector?: string): Query;
|
|
145
|
+
parents(selector?: string, firstOnly?: boolean): Query;
|
|
146
|
+
add(more: Query | Node | Node[]): Query;
|
|
147
|
+
each(func: (node: Node, ind: number, col: Query) => void): Query;
|
|
148
|
+
append(html: string | Query | Node): Query;
|
|
149
|
+
prepend(html: string | Query | Node): Query;
|
|
150
|
+
after(html: string | Query | Node): Query;
|
|
151
|
+
before(html: string | Query | Node): Query;
|
|
152
|
+
replace(html: string | Query | Node): Query;
|
|
153
|
+
remove(): Query;
|
|
154
|
+
css(key?: string | Record<string, string | number>, value?: string | number): string | Record<string, string> | undefined | Query;
|
|
155
|
+
addClass(classes: string): Query;
|
|
156
|
+
removeClass(classes: string | string[] | null): Query;
|
|
157
|
+
toggleClass(classes: string | string[] | null, force?: boolean): Query;
|
|
158
|
+
hasClass(classes: string | string[] | null): boolean | string[];
|
|
159
|
+
on(events: string, options: AddEventListenerOptions | EventListener | {
|
|
160
|
+
delegate?: string;
|
|
161
|
+
} | undefined, callback?: EventListener): Query;
|
|
162
|
+
on(events: string, callback: EventListener): Query;
|
|
163
|
+
off(events?: string, options?: AddEventListenerOptions | EventListener, callback?: EventListener): Query;
|
|
164
|
+
trigger(name: string | Event | CustomEvent, options?: EventInit): Query;
|
|
165
|
+
attr(name: string): string | undefined;
|
|
166
|
+
attr(name: string | Record<string, string>, value?: string): Query;
|
|
167
|
+
removeAttr(...attrs: string[]): Query;
|
|
168
|
+
prop(name: string): unknown;
|
|
169
|
+
prop(name: string | Record<string, unknown>, value?: unknown): Query;
|
|
170
|
+
removeProp(...props: string[]): Query;
|
|
171
|
+
data(key?: string | Record<string, unknown>, value?: unknown): unknown | Query;
|
|
172
|
+
removeData(key: string | string[]): Query;
|
|
173
|
+
show(): Query;
|
|
174
|
+
hide(): Query;
|
|
175
|
+
toggle(force?: boolean): Query;
|
|
176
|
+
empty(): Query;
|
|
177
|
+
html(html?: string | HTMLElement): string | Query | undefined;
|
|
178
|
+
text(text?: string): unknown | Query;
|
|
179
|
+
val(value?: string): unknown | Query;
|
|
180
|
+
change(): Query;
|
|
181
|
+
click(): Query;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Part of TsUi 2.0 library
|
|
186
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsLocale
|
|
187
|
+
*
|
|
188
|
+
* T2.5: @ts-nocheck removed; file typed aggressively per typing_policy.
|
|
189
|
+
* See commit body for targeted-any inventory.
|
|
190
|
+
*
|
|
191
|
+
* == TODO ==
|
|
192
|
+
* - add TsUtils.lang wrap for all captions in all buttons.
|
|
193
|
+
* - check transition (also with layout)
|
|
194
|
+
* - deprecate TsUtils.tooltip
|
|
195
|
+
*
|
|
196
|
+
* == 2.0 changes
|
|
197
|
+
* - CSP - fixed inline events (TsUtils.tooltip still has it)
|
|
198
|
+
* - transition returns a promise
|
|
199
|
+
* - removed jQuery
|
|
200
|
+
* - refactores TsUtils.message()
|
|
201
|
+
* - added TsUtils.confirm()
|
|
202
|
+
* - added isPlainObject
|
|
203
|
+
* - added stripSpaces
|
|
204
|
+
* - implemented marker - can now take an element or just html
|
|
205
|
+
* - cssPrefix - deprecated
|
|
206
|
+
* - TsUtils.debounce
|
|
207
|
+
* - TsUtils.prepareParams
|
|
208
|
+
* - TsUtils.getStrHeight
|
|
209
|
+
* - TsUtils.getStrDimentions
|
|
210
|
+
* - TsUtils.alrert() - same as TsUtils.message()
|
|
211
|
+
* - TsUtils.prompt() - similar to TsPrompt
|
|
212
|
+
* - TsUtils.normMenu(..., options) got options parameter that can have itemMap
|
|
213
|
+
* - TsUtils.getNested()
|
|
214
|
+
* - TsUtils.wait() - async timer
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
declare const query: (selector: unknown, context?: unknown) => Query;
|
|
218
|
+
declare const TsUi: Record<string, unknown>;
|
|
219
|
+
/** Settings object merged from TsLocale + user locale overrides */
|
|
220
|
+
interface TsUISettings {
|
|
221
|
+
dataType: string;
|
|
222
|
+
dateFormat: string;
|
|
223
|
+
timeFormat: string;
|
|
224
|
+
datetimeFormat: string;
|
|
225
|
+
dateStartYear: number;
|
|
226
|
+
dateEndYear: number;
|
|
227
|
+
currencyPrefix: string;
|
|
228
|
+
currencySuffix: string;
|
|
229
|
+
currencyPrecision: number;
|
|
230
|
+
groupSymbol: string;
|
|
231
|
+
decimalSymbol: string;
|
|
232
|
+
shortmonths: string[];
|
|
233
|
+
fullmonths: string[];
|
|
234
|
+
shortdays: string[];
|
|
235
|
+
fulldays: string[];
|
|
236
|
+
weekStarts: string;
|
|
237
|
+
macButtonOrder: boolean;
|
|
238
|
+
warnNoPhrase: boolean;
|
|
239
|
+
phrases: Record<string, string> | null;
|
|
240
|
+
missing?: Record<string, string>;
|
|
241
|
+
locale?: string;
|
|
242
|
+
[key: string]: unknown;
|
|
243
|
+
}
|
|
244
|
+
/** Extra data passed to grid cell formatters */
|
|
245
|
+
interface TsFormatterExtra {
|
|
246
|
+
value: unknown;
|
|
247
|
+
params?: unknown;
|
|
248
|
+
record?: unknown;
|
|
249
|
+
[key: string]: unknown;
|
|
250
|
+
}
|
|
251
|
+
/** Signature of a grid-cell formatter function */
|
|
252
|
+
type TsFormatter = (record: TsFormatterExtra, extra?: TsFormatterExtra) => string;
|
|
253
|
+
/** Options for TsUtils.lock() */
|
|
254
|
+
interface TsLockOptions {
|
|
255
|
+
msg?: string | number;
|
|
256
|
+
spinner?: boolean;
|
|
257
|
+
opacity?: number;
|
|
258
|
+
bgColor?: string;
|
|
259
|
+
onClick?: () => void;
|
|
260
|
+
}
|
|
261
|
+
/** Return value from TsUtils.isTime() when retTime === true */
|
|
262
|
+
interface TsTimeResult {
|
|
263
|
+
hours: number;
|
|
264
|
+
minutes: number;
|
|
265
|
+
seconds: number;
|
|
266
|
+
}
|
|
267
|
+
/** RGB(A) color as returned by TsUtils.parseColor() */
|
|
268
|
+
interface TsColorRgb {
|
|
269
|
+
r: number;
|
|
270
|
+
g: number;
|
|
271
|
+
b: number;
|
|
272
|
+
a: number;
|
|
273
|
+
}
|
|
274
|
+
/** A normalized menu item */
|
|
275
|
+
interface TsMenuItem {
|
|
276
|
+
id: string | number | null;
|
|
277
|
+
text: string;
|
|
278
|
+
caption?: string;
|
|
279
|
+
class?: string;
|
|
280
|
+
style?: string;
|
|
281
|
+
attrs?: string;
|
|
282
|
+
[key: string]: unknown;
|
|
283
|
+
}
|
|
284
|
+
/** Options for TsUtils.normMenu() */
|
|
285
|
+
interface TsNormMenuOptions {
|
|
286
|
+
itemMap?: {
|
|
287
|
+
id: string;
|
|
288
|
+
text: string;
|
|
289
|
+
};
|
|
290
|
+
[key: string]: unknown;
|
|
291
|
+
}
|
|
292
|
+
/** Options for TsUtils.clone() */
|
|
293
|
+
interface TsCloneOptions {
|
|
294
|
+
functions?: boolean;
|
|
295
|
+
elements?: boolean;
|
|
296
|
+
events?: boolean;
|
|
297
|
+
exclude?: string[] | ((key: string, ctx: {
|
|
298
|
+
obj: unknown;
|
|
299
|
+
parent: string;
|
|
300
|
+
}) => boolean);
|
|
301
|
+
parent?: string;
|
|
302
|
+
}
|
|
303
|
+
/** Promise-chain handle returned by TsUtils.message() / .confirm() / .prompt() */
|
|
304
|
+
interface TsMessageProm {
|
|
305
|
+
self: TsBase;
|
|
306
|
+
action(callBack: (event: unknown) => void): TsMessageProm;
|
|
307
|
+
close(callBack: (event: unknown) => void): TsMessageProm;
|
|
308
|
+
open(callBack: (event: unknown) => void): TsMessageProm;
|
|
309
|
+
then(callBack: (event: unknown) => void): TsMessageProm;
|
|
310
|
+
change?: (callBack: (event: unknown) => void) => TsMessageProm;
|
|
311
|
+
[key: string]: unknown;
|
|
312
|
+
}
|
|
313
|
+
/** Where-descriptor for TsUtils.message() */
|
|
314
|
+
interface TsMessageWhere {
|
|
315
|
+
box: string | Element | null;
|
|
316
|
+
after?: string | Element | null;
|
|
317
|
+
owner?: {
|
|
318
|
+
name?: string;
|
|
319
|
+
lock?: (...args: unknown[]) => void;
|
|
320
|
+
unlock?: (...args: unknown[]) => void;
|
|
321
|
+
focus?: () => void;
|
|
322
|
+
};
|
|
323
|
+
param?: unknown;
|
|
324
|
+
}
|
|
325
|
+
/** Options for TsUtils.message() */
|
|
326
|
+
interface TsMessageOptions {
|
|
327
|
+
width?: number;
|
|
328
|
+
height?: number;
|
|
329
|
+
text?: string | null;
|
|
330
|
+
body?: string;
|
|
331
|
+
buttons?: string;
|
|
332
|
+
html?: string;
|
|
333
|
+
focus?: number | string | null;
|
|
334
|
+
hideOn?: string[];
|
|
335
|
+
actions?: Record<string, unknown>;
|
|
336
|
+
cancelAction?: string;
|
|
337
|
+
on?: unknown;
|
|
338
|
+
onOpen?: unknown;
|
|
339
|
+
onClose?: unknown;
|
|
340
|
+
onAction?: unknown;
|
|
341
|
+
originalWidth?: number;
|
|
342
|
+
originalHeight?: number;
|
|
343
|
+
msgIndex?: number;
|
|
344
|
+
tmp?: {
|
|
345
|
+
zIndex: string;
|
|
346
|
+
overflow: string;
|
|
347
|
+
};
|
|
348
|
+
input?: Element | null;
|
|
349
|
+
box?: Element | null;
|
|
350
|
+
trigger?: (event: string, data: Record<string, unknown>) => unknown;
|
|
351
|
+
close?: () => void;
|
|
352
|
+
setFocus?: (focus: number | string | null | undefined) => void;
|
|
353
|
+
action?: (action: string, event: unknown) => void;
|
|
354
|
+
[key: string]: unknown;
|
|
355
|
+
}
|
|
356
|
+
declare class Utils {
|
|
357
|
+
version: string;
|
|
358
|
+
tmp: Record<string, unknown>;
|
|
359
|
+
settings: TsUISettings;
|
|
360
|
+
i18nCompare: (a: string, b: string) => number;
|
|
361
|
+
hasLocalStorage: boolean;
|
|
362
|
+
isMac: boolean;
|
|
363
|
+
isMobile: boolean;
|
|
364
|
+
isIOS: boolean;
|
|
365
|
+
isAndroid: boolean;
|
|
366
|
+
isSafari: boolean;
|
|
367
|
+
isFirefox: boolean;
|
|
368
|
+
formatters: Record<string, TsFormatter>;
|
|
369
|
+
constructor();
|
|
370
|
+
isBin(val: unknown): boolean;
|
|
371
|
+
isInt(val: unknown): boolean;
|
|
372
|
+
isFloat(val: unknown): boolean;
|
|
373
|
+
isMoney(val: unknown): boolean;
|
|
374
|
+
isHex(val: unknown): boolean;
|
|
375
|
+
isAlphaNumeric(val: unknown): boolean;
|
|
376
|
+
isEmail(val: unknown): boolean;
|
|
377
|
+
isIpAddress(val: unknown): boolean;
|
|
378
|
+
isDate(val: unknown, format?: string | null, retDate?: boolean): boolean | Date;
|
|
379
|
+
isTime(val: unknown, retTime?: boolean): boolean | TsTimeResult;
|
|
380
|
+
isDateTime(val: unknown, format?: string | null, retDate?: boolean): boolean | Date;
|
|
381
|
+
age(dateStr: unknown): string;
|
|
382
|
+
interval(value: number): string;
|
|
383
|
+
date(dateStr: unknown): string;
|
|
384
|
+
formatSize(sizeStr: unknown): string | number;
|
|
385
|
+
formatNumber(val: unknown, fraction?: number | string | null, useGrouping?: boolean): string;
|
|
386
|
+
formatDate(dateStr: unknown, format?: string | null): string;
|
|
387
|
+
formatTime(dateStr: unknown, format?: string | null): string;
|
|
388
|
+
formatDateTime(dateStr: unknown, format?: string | null): string;
|
|
389
|
+
stripSpaces(html: unknown): unknown;
|
|
390
|
+
stripTags(html: unknown): unknown;
|
|
391
|
+
encodeTags(html: unknown): unknown;
|
|
392
|
+
decodeTags(html: unknown): unknown;
|
|
393
|
+
escapeId(id: unknown): string;
|
|
394
|
+
unescapeId(id: string | null | undefined): string;
|
|
395
|
+
base64encode(str: string): string;
|
|
396
|
+
base64decode(encodedStr: string): string;
|
|
397
|
+
sha256(str: string): Promise<string>;
|
|
398
|
+
transition(div_old: HTMLElement, div_new: HTMLElement, type: string, callBack?: () => void): Promise<void>;
|
|
399
|
+
lock(box: unknown, options?: TsLockOptions | string, ...rest: unknown[]): void;
|
|
400
|
+
unlock(box: unknown, speed?: number): void;
|
|
401
|
+
/**
|
|
402
|
+
* Opens a context message, similar in parameters as TsPopup.open()
|
|
403
|
+
*
|
|
404
|
+
* Sample Calls
|
|
405
|
+
* TsUtils.message({ box: '#div', text: 'message' }).ok(() => {})
|
|
406
|
+
* TsUtils.message({ box: '#div', text: 'message', width: 300 }).ok(() => {})
|
|
407
|
+
* TsUtils.message({ box: '#div', text: 'message', actions: ['Save'] }).Save(() => {})
|
|
408
|
+
*
|
|
409
|
+
* Used in TsGrid, TsForm, TsLayout (should be in TsPopup too)
|
|
410
|
+
* should be called with .call(...) method
|
|
411
|
+
*
|
|
412
|
+
* @param where = {
|
|
413
|
+
* box, // where to open
|
|
414
|
+
* after, // title if any, adds title heights
|
|
415
|
+
* param // additional parameters, used in layouts for panel
|
|
416
|
+
* }
|
|
417
|
+
* @param options {
|
|
418
|
+
* width, // (int), width in px, if negative, then it is maxWidth - width
|
|
419
|
+
* height, // (int), height in px, if negative, then it is maxHeight - height
|
|
420
|
+
* text, // centered text
|
|
421
|
+
* body, // body of the message
|
|
422
|
+
* buttons, // buttons of the message
|
|
423
|
+
* html, // if body & buttons are not defined, then html is the entire message
|
|
424
|
+
* focus, // int or id with a selector, default is 0
|
|
425
|
+
* hideOn, // ['esc', 'click'], default is ['esc']
|
|
426
|
+
* actions, // array of actions (only if buttons is not defined)
|
|
427
|
+
* onOpen, // event when opened
|
|
428
|
+
* onClose, // event when closed
|
|
429
|
+
* onAction, // event on action
|
|
430
|
+
* }
|
|
431
|
+
*/
|
|
432
|
+
message(where: TsMessageWhere, options?: TsMessageOptions | string | number): TsMessageProm | undefined;
|
|
433
|
+
alert(where: TsMessageWhere, options?: TsMessageOptions | string | number): TsMessageProm | undefined;
|
|
434
|
+
/**
|
|
435
|
+
* Shows a prompt as a context message. It will use same where: { box: ... } as TsUtils.message() function
|
|
436
|
+
* but it will have options similar to TsPrompt dialog
|
|
437
|
+
*
|
|
438
|
+
* Example:
|
|
439
|
+
* - TsUtils.conrirm({
|
|
440
|
+
* box: '#custom',
|
|
441
|
+
* text: 'Some message'
|
|
442
|
+
* })
|
|
443
|
+
* .yes(event => console.log(event))
|
|
444
|
+
*/
|
|
445
|
+
confirm(where: TsMessageWhere, options?: TsMessageOptions | string | number): TsMessageProm | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* Shows a prompt as a context message. It will use same where: { box: ... } as TsUtils.message() function
|
|
448
|
+
* but it will have options similar to TsPrompt dialog
|
|
449
|
+
*
|
|
450
|
+
* Example:
|
|
451
|
+
* - TsUtils.prompt({
|
|
452
|
+
* box: '#custom',
|
|
453
|
+
* label: 'Enter Name',
|
|
454
|
+
* textarea: false,
|
|
455
|
+
* attrs: 'style="border: 1px solid red"'
|
|
456
|
+
* })
|
|
457
|
+
* .ok(event => console.log(event))
|
|
458
|
+
*/
|
|
459
|
+
prompt(where: TsMessageWhere, options?: TsMessageOptions | string | number): TsMessageProm | undefined;
|
|
460
|
+
/**
|
|
461
|
+
* Normalizes yes, no buttons for confirmation dialog
|
|
462
|
+
*
|
|
463
|
+
* @param {*} options
|
|
464
|
+
* @returns options
|
|
465
|
+
*/
|
|
466
|
+
normButtons(options: Record<string, unknown>, btn: Record<string, unknown>): Record<string, unknown>;
|
|
467
|
+
/**
|
|
468
|
+
* Shows small notification message at the bottom of the page, or containter that you specify
|
|
469
|
+
* in options.where (could be element or a selector)
|
|
470
|
+
*
|
|
471
|
+
* TsUtils.notify('Document saved')
|
|
472
|
+
* TsUtils.notify('Mesage sent ${udon}', { actions: { undo: function () {...} }})
|
|
473
|
+
*
|
|
474
|
+
* @param {String/Object} options can be {
|
|
475
|
+
* text: string, // message, can be html
|
|
476
|
+
* where: el/selector, // element or selector where to show, default is document.body
|
|
477
|
+
* timeout: int, // timeout when to hide, if 0 - indefinite
|
|
478
|
+
* error: boolean, // add error clases
|
|
479
|
+
* class: string, // additional class strings
|
|
480
|
+
* actions: object // object with action functions, it should correspot to templated text: '... ${action} ...'
|
|
481
|
+
* }
|
|
482
|
+
* @returns promise
|
|
483
|
+
*/
|
|
484
|
+
notify(text: string | Record<string, unknown>, options?: Record<string, unknown>): Promise<void>;
|
|
485
|
+
getSize(el: unknown, type: string): number;
|
|
486
|
+
getStrDimentions(str: string, styles?: string, raw?: boolean): {
|
|
487
|
+
width: any;
|
|
488
|
+
height: any;
|
|
489
|
+
};
|
|
490
|
+
getStrWidth(str: string, styles?: string, raw?: boolean): any;
|
|
491
|
+
getStrHeight(str: string, styles?: string, raw?: boolean): any;
|
|
492
|
+
execTemplate(str: any, replace_obj: any): any;
|
|
493
|
+
marker(el: any, items: any, options?: any): any;
|
|
494
|
+
lang(phrase: string, params?: Record<string, string | number> | boolean): string;
|
|
495
|
+
locale(locale: string | string[] | Record<string, unknown>, keepPhrases?: boolean, noMerge?: boolean): Promise<{
|
|
496
|
+
file: string;
|
|
497
|
+
data: unknown;
|
|
498
|
+
} | void>;
|
|
499
|
+
scrollBarSize(): unknown;
|
|
500
|
+
checkName(name: string): boolean;
|
|
501
|
+
checkUniqueId(id: any, items: any, desc: any, obj: any): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Takes an object and encodes it into params string to be passed as a url
|
|
504
|
+
* { a: 1, b: 'str'} => "a=1&b=str"
|
|
505
|
+
* { a: 1, b: { c: 2 }} => "a=1&b[c]=2"
|
|
506
|
+
* { a: 1, b: {c: { k: 'dfdf' } } } => "a=1&b[c][k]=dfdf"
|
|
507
|
+
*/
|
|
508
|
+
encodeParams(obj: any, prefix?: string): string;
|
|
509
|
+
parseRoute(route: string): {
|
|
510
|
+
path: RegExp;
|
|
511
|
+
keys: {
|
|
512
|
+
name: string;
|
|
513
|
+
optional: boolean;
|
|
514
|
+
}[];
|
|
515
|
+
};
|
|
516
|
+
getCursorPosition(input: any): number | null;
|
|
517
|
+
setCursorPosition(input: HTMLElement | null, pos: number, posEnd?: number): void;
|
|
518
|
+
parseColor(str: string | null | undefined): TsColorRgb | null;
|
|
519
|
+
colorContrast(color1: string, color2: string): string;
|
|
520
|
+
hsv2rgb(h: any, s?: any, v?: any, a?: any): {
|
|
521
|
+
r: number;
|
|
522
|
+
g: number;
|
|
523
|
+
b: number;
|
|
524
|
+
a: number;
|
|
525
|
+
};
|
|
526
|
+
rgb2hsv(r: any, g?: any, b?: any, a?: any): {
|
|
527
|
+
h: number;
|
|
528
|
+
s: number;
|
|
529
|
+
v: number;
|
|
530
|
+
a: number;
|
|
531
|
+
};
|
|
532
|
+
tooltip(html: string | Record<string, unknown>, options?: Record<string, unknown>): string;
|
|
533
|
+
isPlainObject(value: unknown): boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Deep copy of an object or an array. Function, events and HTML elements will not be cloned,
|
|
536
|
+
* you can choose to include them or not, by default they are included.
|
|
537
|
+
* You can also exclude certain elements from final object if used with options: { exclude }
|
|
538
|
+
*/
|
|
539
|
+
clone(obj: unknown, options?: Partial<TsCloneOptions>): any;
|
|
540
|
+
/**
|
|
541
|
+
* Deep extend an object, if an array, it overwrrites it, cloning objects in the process
|
|
542
|
+
* target, source1, source2, ...
|
|
543
|
+
*/
|
|
544
|
+
extend(target: any, source: any, ...rest: unknown[]): any;
|
|
545
|
+
naturalCompare(a: unknown, b: unknown): number;
|
|
546
|
+
/**
|
|
547
|
+
* Takes a menu (used in drop downs, context menu, field: list/combo/enum) and normalizes it to the common structure, which
|
|
548
|
+
* is { id: ..., text: ... }. In options you can pass { itemMap: { id: 'id_field', text: 'text_field' }} that will be used
|
|
549
|
+
* to find out id and text fields.
|
|
550
|
+
*/
|
|
551
|
+
normMenu(menu: unknown, options?: TsNormMenuOptions): TsMenuItem[] | undefined;
|
|
552
|
+
/**
|
|
553
|
+
* Takes Url object and fetchOptions and changes it in place applying selected user dataType. Since
|
|
554
|
+
* dataType is in TsUtils. This method is used in grid, form and tooltip to prepare fetch parameters
|
|
555
|
+
*/
|
|
556
|
+
prepareParams(url: URL, fetchOptions: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
557
|
+
bindEvents(selector: unknown, subject: Record<string, unknown>): void;
|
|
558
|
+
debounce(func: (...args: any[]) => void, wait?: number): (...args: any[]) => void;
|
|
559
|
+
wait(time?: number): Promise<void>;
|
|
560
|
+
getNested(obj: any, prop: any): unknown;
|
|
561
|
+
}
|
|
562
|
+
declare var TsUtils: Utils;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Part of TsUi 2.0 library
|
|
566
|
+
* - Dependencies: none
|
|
567
|
+
*
|
|
568
|
+
* These are the master locale settings that will be used by TsUtils
|
|
569
|
+
*
|
|
570
|
+
* "locale" should be the IETF language tag in the form xx-YY,
|
|
571
|
+
* where xx is the ISO 639-1 language code ( see https://en.wikipedia.org/wiki/ISO_639-1 ) and
|
|
572
|
+
* YY is the ISO 3166-1 alpha-2 country code ( see https://en.wikipedia.org/wiki/ISO_3166-2 )
|
|
573
|
+
*/
|
|
574
|
+
interface TsLocaleSettings {
|
|
575
|
+
locale: string;
|
|
576
|
+
dateFormat: string;
|
|
577
|
+
timeFormat: string;
|
|
578
|
+
datetimeFormat: string;
|
|
579
|
+
currencyPrefix: string;
|
|
580
|
+
currencySuffix: string;
|
|
581
|
+
currencyPrecision: number;
|
|
582
|
+
groupSymbol: string;
|
|
583
|
+
decimalSymbol: string;
|
|
584
|
+
shortmonths: string[];
|
|
585
|
+
fullmonths: string[];
|
|
586
|
+
shortdays: string[];
|
|
587
|
+
fulldays: string[];
|
|
588
|
+
weekStarts: string;
|
|
589
|
+
phrases: Record<string, string> | null;
|
|
590
|
+
}
|
|
591
|
+
declare const TsLocale: TsLocaleSettings;
|
|
592
|
+
|
|
593
|
+
interface DialogOptions {
|
|
594
|
+
title?: string;
|
|
595
|
+
text?: string;
|
|
596
|
+
body?: string;
|
|
597
|
+
buttons?: string;
|
|
598
|
+
width?: number;
|
|
599
|
+
height?: number;
|
|
600
|
+
focus?: number | string | null;
|
|
601
|
+
actions?: Record<string, unknown> | null;
|
|
602
|
+
style?: string;
|
|
603
|
+
speed?: number;
|
|
604
|
+
blockPage?: boolean;
|
|
605
|
+
modal?: boolean;
|
|
606
|
+
maximized?: boolean;
|
|
607
|
+
keyboard?: boolean;
|
|
608
|
+
showClose?: boolean;
|
|
609
|
+
showMax?: boolean;
|
|
610
|
+
resizable?: boolean;
|
|
611
|
+
transition?: unknown;
|
|
612
|
+
openMaximized?: boolean;
|
|
613
|
+
moved?: boolean;
|
|
614
|
+
prevSize?: string | null;
|
|
615
|
+
cancelAction?: string;
|
|
616
|
+
closingTimer?: ReturnType<typeof setTimeout>;
|
|
617
|
+
_last_focus?: HTMLElement | null;
|
|
618
|
+
[key: string]: unknown;
|
|
619
|
+
}
|
|
620
|
+
declare class TsDialog extends TsBase {
|
|
621
|
+
defaults: DialogOptions;
|
|
622
|
+
options: DialogOptions;
|
|
623
|
+
name: string;
|
|
624
|
+
status: string;
|
|
625
|
+
tmp: Record<string, unknown>;
|
|
626
|
+
handleResize: (event?: any) => void;
|
|
627
|
+
_promCreated: (value?: unknown) => void;
|
|
628
|
+
_promOpened: (value?: unknown) => void;
|
|
629
|
+
_promClosing: (value?: unknown) => void;
|
|
630
|
+
_promClosed: (value?: unknown) => void;
|
|
631
|
+
_timer?: ReturnType<typeof setTimeout>;
|
|
632
|
+
constructor();
|
|
633
|
+
/**
|
|
634
|
+
* Sample calls
|
|
635
|
+
* - TsPopup.open('ddd').ok(() => { TsPopup.close() })
|
|
636
|
+
* - TsPopup.open('ddd', { height: 120 }).ok(() => { TsPopup.close() })
|
|
637
|
+
* - TsPopup.open({ body: 'text', title: 'caption', actions: ["Close"] }).close(() => { TsPopup.close() })
|
|
638
|
+
* - TsPopup.open({ body: 'text', title: 'caption', actions: { Close() { TsPopup.close() }} })
|
|
639
|
+
*/
|
|
640
|
+
open(options?: any, extraOptions?: any): (Record<string, unknown> & {
|
|
641
|
+
self: TsDialog;
|
|
642
|
+
action(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
643
|
+
close(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
644
|
+
then(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
645
|
+
}) | undefined;
|
|
646
|
+
load(options: any): Promise<unknown>;
|
|
647
|
+
template(data: any, id: any, options?: any): (Record<string, unknown> & {
|
|
648
|
+
self: TsDialog;
|
|
649
|
+
action(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
650
|
+
close(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
651
|
+
then(callBack: any): Record<string, unknown> & /*elided*/ any;
|
|
652
|
+
}) | undefined;
|
|
653
|
+
action(action: any, event?: any): void;
|
|
654
|
+
keydown(event: any): void;
|
|
655
|
+
close(immediate?: any): void;
|
|
656
|
+
toggle(): void;
|
|
657
|
+
max(): void;
|
|
658
|
+
min(): void;
|
|
659
|
+
clear(): void;
|
|
660
|
+
reset(): void;
|
|
661
|
+
message(options: any): TsMessageProm | undefined;
|
|
662
|
+
confirm(options: any): TsMessageProm | undefined;
|
|
663
|
+
setFocus(focus?: any): void;
|
|
664
|
+
lock(msg?: any, showSpinner?: any): void;
|
|
665
|
+
unlock(speed?: any): void;
|
|
666
|
+
center(width?: any, height?: any, force?: any): {
|
|
667
|
+
top: number;
|
|
668
|
+
left: number;
|
|
669
|
+
width: any;
|
|
670
|
+
height: any;
|
|
671
|
+
};
|
|
672
|
+
resize(newWidth: any, newHeight: any, callBack?: any): Promise<unknown>;
|
|
673
|
+
resizeMessages(): void;
|
|
674
|
+
}
|
|
675
|
+
declare function TsAlert(msg: any, title?: any, callBack?: any): any;
|
|
676
|
+
declare function TsConfirm(msg: any, title?: any, callBack?: any): any;
|
|
677
|
+
declare function TsPrompt(label: any, title?: any, callBack?: any): any;
|
|
678
|
+
declare const TsPopup: TsDialog;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Part of TsUi 2.0 library
|
|
682
|
+
* - Dependencies: mQuery, TsUtils, TsBase
|
|
683
|
+
*
|
|
684
|
+
* T3.1: Ported to TypeScript with aggressive typing per typing_policy.
|
|
685
|
+
* No @ts-nocheck. Targeted `any` sites documented with // any: comments.
|
|
686
|
+
*
|
|
687
|
+
* TODO:
|
|
688
|
+
* - need help pages
|
|
689
|
+
*
|
|
690
|
+
* 2.0 Changes
|
|
691
|
+
* - multiple tooltips to the same anchor
|
|
692
|
+
* - options.contextMenu
|
|
693
|
+
* - options.prefilter - if true, it will show prefiltered items for TsMenu, otherwise all
|
|
694
|
+
* - menu.item.help, menu.item.hotkey, menu.item.extra
|
|
695
|
+
* - options.selected -> for TsMenu
|
|
696
|
+
* - options.tooltip => {}
|
|
697
|
+
* - TsMenu event onTooltip
|
|
698
|
+
* - added onMouseEnter and onMouseLeave for TsMenu
|
|
699
|
+
*/
|
|
700
|
+
|
|
701
|
+
/** Base options shared by all tooltip variants */
|
|
702
|
+
interface TooltipOptions {
|
|
703
|
+
name?: string | null;
|
|
704
|
+
html?: string;
|
|
705
|
+
style?: string;
|
|
706
|
+
class?: string;
|
|
707
|
+
position?: string | string[];
|
|
708
|
+
draggable?: boolean;
|
|
709
|
+
align?: string;
|
|
710
|
+
anchor?: HTMLElement | null;
|
|
711
|
+
contextMenu?: boolean;
|
|
712
|
+
anchorClass?: string;
|
|
713
|
+
anchorStyle?: string;
|
|
714
|
+
autoShow?: boolean;
|
|
715
|
+
autoShowOn?: string | null;
|
|
716
|
+
autoHideOn?: string | null;
|
|
717
|
+
arrowSize?: number;
|
|
718
|
+
screenMargin?: number;
|
|
719
|
+
autoResize?: boolean;
|
|
720
|
+
margin?: number;
|
|
721
|
+
offsetX?: number;
|
|
722
|
+
offsetY?: number;
|
|
723
|
+
maxWidth?: number | null;
|
|
724
|
+
maxHeight?: number | null;
|
|
725
|
+
hideOn?: string | string[] | null;
|
|
726
|
+
onThen?: ((event: unknown) => void) | null;
|
|
727
|
+
onShow?: ((event: unknown) => void) | null;
|
|
728
|
+
onHide?: ((event: unknown) => void) | null;
|
|
729
|
+
onUpdate?: ((event: unknown) => void) | null;
|
|
730
|
+
onMove?: ((event: unknown) => void) | null;
|
|
731
|
+
_keep?: boolean;
|
|
732
|
+
text?: string;
|
|
733
|
+
[key: string]: unknown;
|
|
734
|
+
}
|
|
735
|
+
/** A single menu item */
|
|
736
|
+
interface MenuItem {
|
|
737
|
+
id?: string | number | null;
|
|
738
|
+
text?: string | null | ((item: MenuItem, options: MenuOptions) => string);
|
|
739
|
+
style?: string;
|
|
740
|
+
icon?: string | null;
|
|
741
|
+
count?: string | number | null;
|
|
742
|
+
tooltip?: string | {
|
|
743
|
+
html?: string;
|
|
744
|
+
[key: string]: unknown;
|
|
745
|
+
} | null;
|
|
746
|
+
hint?: string | null;
|
|
747
|
+
hotkey?: string | null;
|
|
748
|
+
removable?: boolean | null;
|
|
749
|
+
remove?: boolean | null;
|
|
750
|
+
help?: string | null;
|
|
751
|
+
items?: MenuItem[] | ((item: MenuItem) => MenuItem[]) | null;
|
|
752
|
+
indent?: number;
|
|
753
|
+
type?: 'check' | 'radio' | 'break' | null;
|
|
754
|
+
group?: string | boolean | null;
|
|
755
|
+
expanded?: boolean;
|
|
756
|
+
hidden?: boolean;
|
|
757
|
+
checked?: boolean | null;
|
|
758
|
+
disabled?: boolean;
|
|
759
|
+
keepOpen?: boolean | null;
|
|
760
|
+
extra?: string;
|
|
761
|
+
_noSearchInside?: boolean;
|
|
762
|
+
[key: string]: unknown;
|
|
763
|
+
}
|
|
764
|
+
/** Options for TsMenu (MenuTooltip) */
|
|
765
|
+
interface MenuOptions extends TooltipOptions {
|
|
766
|
+
type?: 'normal' | 'radio' | 'check';
|
|
767
|
+
items?: MenuItem[];
|
|
768
|
+
selected?: null | string | number | MenuItem | Array<string | number | MenuItem>;
|
|
769
|
+
render?: ((item: MenuItem, options: MenuOptions) => string) | null;
|
|
770
|
+
spinner?: boolean;
|
|
771
|
+
msgNoItems?: string;
|
|
772
|
+
msgSearch?: string;
|
|
773
|
+
topHTML?: string;
|
|
774
|
+
menuStyle?: string;
|
|
775
|
+
search?: boolean;
|
|
776
|
+
filter?: boolean;
|
|
777
|
+
match?: 'contains' | 'is' | 'begins' | 'begins with' | 'ends' | 'ends with' | 'regexp';
|
|
778
|
+
markSearch?: boolean;
|
|
779
|
+
prefilter?: boolean;
|
|
780
|
+
altRows?: boolean;
|
|
781
|
+
url?: string;
|
|
782
|
+
postData?: Record<string, unknown>;
|
|
783
|
+
method?: string;
|
|
784
|
+
recId?: string | ((item: Record<string, unknown>) => unknown) | null;
|
|
785
|
+
recid?: string | null;
|
|
786
|
+
recText?: string | ((item: Record<string, unknown>) => unknown) | null;
|
|
787
|
+
cacheMax?: number;
|
|
788
|
+
minLength?: number;
|
|
789
|
+
debounce?: number;
|
|
790
|
+
hideSelected?: boolean;
|
|
791
|
+
parentOverlay?: TooltipOverlay | null;
|
|
792
|
+
parents?: number[];
|
|
793
|
+
onSelect?: ((event: unknown) => void) | null;
|
|
794
|
+
onSubMenu?: ((event: unknown) => void) | null;
|
|
795
|
+
onRemove?: ((event: unknown) => void) | null;
|
|
796
|
+
onTooltip?: ((event: unknown) => void) | null;
|
|
797
|
+
onMouseEnter?: ((event: unknown) => void) | null;
|
|
798
|
+
onMouseLeave?: ((event: unknown) => void) | null;
|
|
799
|
+
}
|
|
800
|
+
/** Options for TsColor (ColorTooltip) */
|
|
801
|
+
interface ColorOptions extends TooltipOptions {
|
|
802
|
+
advanced?: boolean;
|
|
803
|
+
transparent?: boolean;
|
|
804
|
+
color?: string;
|
|
805
|
+
updateInput?: boolean;
|
|
806
|
+
onSelect?: ((event: unknown) => void) | null;
|
|
807
|
+
onLiveUpdate?: ((event: unknown) => void) | null;
|
|
808
|
+
}
|
|
809
|
+
/** Options for TsDate (DateTooltip) */
|
|
810
|
+
interface DateOptions extends TooltipOptions {
|
|
811
|
+
type?: 'date' | 'time' | 'datetime';
|
|
812
|
+
value?: string;
|
|
813
|
+
format?: string;
|
|
814
|
+
start?: string | HTMLElement | null;
|
|
815
|
+
end?: string | HTMLElement | null;
|
|
816
|
+
btnNow?: boolean;
|
|
817
|
+
blockDates?: string[];
|
|
818
|
+
blockWeekdays?: number[];
|
|
819
|
+
colored?: Record<string, string>;
|
|
820
|
+
noMinutes?: boolean;
|
|
821
|
+
startTime?: string;
|
|
822
|
+
endTime?: string;
|
|
823
|
+
onSelect?: ((event: unknown) => void) | null;
|
|
824
|
+
}
|
|
825
|
+
/** The overlay object — a TsBase instance extended at runtime with many dynamic props */
|
|
826
|
+
type TooltipOverlay = // any: dynamic TsBase extension
|
|
827
|
+
InstanceType<typeof TsBase> & {
|
|
828
|
+
id: string;
|
|
829
|
+
name: string;
|
|
830
|
+
options: TooltipOptions & MenuOptions & ColorOptions & DateOptions;
|
|
831
|
+
anchor: HTMLElement;
|
|
832
|
+
self: Tooltip;
|
|
833
|
+
displayed: boolean;
|
|
834
|
+
box: HTMLElement & {
|
|
835
|
+
overlay?: TooltipOverlay;
|
|
836
|
+
} | null;
|
|
837
|
+
needsUpdate?: boolean;
|
|
838
|
+
prevOptions?: TooltipOptions;
|
|
839
|
+
tmp: Record<string, unknown>;
|
|
840
|
+
selected?: string | number | null;
|
|
841
|
+
newColor?: string;
|
|
842
|
+
newValue?: string;
|
|
843
|
+
newDate?: string;
|
|
844
|
+
next?: () => void;
|
|
845
|
+
prev?: () => void;
|
|
846
|
+
click?: () => void;
|
|
847
|
+
hide: () => void;
|
|
848
|
+
};
|
|
849
|
+
/** Return value of Tooltip.attach() */
|
|
850
|
+
interface AttachReturn {
|
|
851
|
+
overlay: TooltipOverlay;
|
|
852
|
+
then: (callback: (event: unknown) => void) => AttachReturn;
|
|
853
|
+
show: (callback: (event: unknown) => void) => AttachReturn;
|
|
854
|
+
hide: (callback: (event: unknown) => void) => AttachReturn;
|
|
855
|
+
update: (callback: (event: unknown) => void) => AttachReturn;
|
|
856
|
+
move: (callback: (event: unknown) => void) => AttachReturn;
|
|
857
|
+
liveUpdate?: (callback: (event: unknown) => void) => AttachReturn;
|
|
858
|
+
select?: (callback: (event: unknown) => void) => AttachReturn;
|
|
859
|
+
remove?: (callback: (event: unknown) => void) => AttachReturn;
|
|
860
|
+
subMenu?: (callback: (event: unknown) => void) => AttachReturn;
|
|
861
|
+
}
|
|
862
|
+
/** Position calculation result */
|
|
863
|
+
interface TooltipPosition {
|
|
864
|
+
left: number;
|
|
865
|
+
top: number;
|
|
866
|
+
arrow: {
|
|
867
|
+
offset: number;
|
|
868
|
+
class: string;
|
|
869
|
+
style: string;
|
|
870
|
+
};
|
|
871
|
+
adjust: {
|
|
872
|
+
left: number;
|
|
873
|
+
top: number;
|
|
874
|
+
};
|
|
875
|
+
width?: number;
|
|
876
|
+
height?: number;
|
|
877
|
+
pos: string;
|
|
878
|
+
}
|
|
879
|
+
declare class Tooltip {
|
|
880
|
+
static active: Record<string, TooltipOverlay>;
|
|
881
|
+
defaults: TooltipOptions;
|
|
882
|
+
setColor?: (color: Partial<{
|
|
883
|
+
h: number;
|
|
884
|
+
s: number;
|
|
885
|
+
v: number;
|
|
886
|
+
a: number;
|
|
887
|
+
}>, fullUpdate?: boolean, initial?: string) => void;
|
|
888
|
+
initControls(_overlay: any): void;
|
|
889
|
+
constructor();
|
|
890
|
+
static observeRemove: MutationObserver;
|
|
891
|
+
trigger(event: any, data?: any): {
|
|
892
|
+
isCancelled?: boolean;
|
|
893
|
+
finish: () => void;
|
|
894
|
+
detail?: Record<string, unknown>;
|
|
895
|
+
};
|
|
896
|
+
get(name?: string | true): string[] | Record<string, TooltipOverlay> | TooltipOverlay | undefined;
|
|
897
|
+
attach(anchorArg?: HTMLElement | TooltipOptions | null, textArg?: string | TooltipOptions): AttachReturn | undefined;
|
|
898
|
+
update(name: string, html: string): void;
|
|
899
|
+
show(name?: string | HTMLElement | TooltipOptions, extraOptions?: TooltipOptions): AttachReturn | {
|
|
900
|
+
overlay: TooltipOverlay;
|
|
901
|
+
} | undefined;
|
|
902
|
+
hide(name?: string | HTMLElement): void;
|
|
903
|
+
resize(name?: string): {
|
|
904
|
+
moved: boolean;
|
|
905
|
+
resize: boolean;
|
|
906
|
+
} | {
|
|
907
|
+
multiple: boolean;
|
|
908
|
+
} | void;
|
|
909
|
+
getPosition(name: string): TooltipPosition | undefined;
|
|
910
|
+
/**
|
|
911
|
+
* Move overlay node to the end of its parent (typically body) so it stacks above other .tsg-overlay siblings
|
|
912
|
+
* without relying on z-index. No-op if it is already the last element child.
|
|
913
|
+
*/
|
|
914
|
+
bringOverlayToFront(overlay: TooltipOverlay): void;
|
|
915
|
+
startDrag(event: MouseEvent & {
|
|
916
|
+
target: EventTarget & {
|
|
917
|
+
_lastBoundingRect?: DOMRect;
|
|
918
|
+
};
|
|
919
|
+
}): void;
|
|
920
|
+
}
|
|
921
|
+
declare class ColorTooltip extends Tooltip {
|
|
922
|
+
static custom_colors: string[];
|
|
923
|
+
palette: string[][];
|
|
924
|
+
index: [number, number];
|
|
925
|
+
constructor();
|
|
926
|
+
attach(anchor: any, text?: any): AttachReturn | undefined;
|
|
927
|
+
select(color: any, name: any): void;
|
|
928
|
+
nextColor(direction: string): string | undefined;
|
|
929
|
+
tabClick(index: any, name: any): void;
|
|
930
|
+
getColorHTML(name: any, options: any): string;
|
|
931
|
+
getCustomColorsHTML(name: string): string;
|
|
932
|
+
initControls(overlay: TooltipOverlay): void;
|
|
933
|
+
addCustomColor(color: any, _name: any): any;
|
|
934
|
+
pickAndSelect(name: string, event: any): Promise<void>;
|
|
935
|
+
pickAndUse(_name: string): Promise<void>;
|
|
936
|
+
pickColor(): Promise<string | undefined>;
|
|
937
|
+
}
|
|
938
|
+
declare class MenuTooltip extends Tooltip {
|
|
939
|
+
constructor();
|
|
940
|
+
attach(anchor: any, text?: any): AttachReturn | undefined;
|
|
941
|
+
update(name: any, items: any): void;
|
|
942
|
+
initControls(overlay: any): void;
|
|
943
|
+
getCurrent(name: string, id?: any): {
|
|
944
|
+
last: number;
|
|
945
|
+
index: any;
|
|
946
|
+
items: any;
|
|
947
|
+
item: any;
|
|
948
|
+
parents: string;
|
|
949
|
+
};
|
|
950
|
+
getMenuHTML(options: any): string;
|
|
951
|
+
openSubMenu(event: any): void;
|
|
952
|
+
closeSubMenu(event: any): void;
|
|
953
|
+
refreshIndex(name: string, instant?: boolean): void;
|
|
954
|
+
showTooltip(name: string, options?: any): void;
|
|
955
|
+
refreshSearch(name: string): void;
|
|
956
|
+
/**
|
|
957
|
+
* Loops through the items and markes item.hidden = true for those that need to be hidden, and item.hidden = false
|
|
958
|
+
* for those that are visible. Return a promise (since items can be on the server) with the number of visible items.
|
|
959
|
+
*/
|
|
960
|
+
applyFilter(name: string, items: any, search: any, debounce?: any): Promise<any>;
|
|
961
|
+
request(overlay: any, search: any, debounce: any): Promise<any>;
|
|
962
|
+
/**
|
|
963
|
+
* Builds an array of item ids that sequencial order for navigation with up/down keys. Skips hidden and disabled items
|
|
964
|
+
* and goes into nested structures. It will remember last active chain in 'overlay.tmp.activeChain'
|
|
965
|
+
*/
|
|
966
|
+
getActiveChain(name: string, items?: any, parents?: any[], res?: any[], noSave?: boolean): any[];
|
|
967
|
+
menuDown(overlay: any, event: any, index: any, parents: any): void;
|
|
968
|
+
menuClick(overlay: any, event: any, index: any, parents: any): void;
|
|
969
|
+
findChecked(items: any): any[];
|
|
970
|
+
keyUp(overlay: any, event: any): void;
|
|
971
|
+
}
|
|
972
|
+
declare class DateTooltip extends Tooltip {
|
|
973
|
+
daysCount: number[];
|
|
974
|
+
today: string;
|
|
975
|
+
constructor();
|
|
976
|
+
attach(anchor: any, text?: any): AttachReturn | undefined;
|
|
977
|
+
initControls(overlay: any): void;
|
|
978
|
+
getMonthHTML(options: any, month?: any, year?: any): {
|
|
979
|
+
html: string;
|
|
980
|
+
month: any;
|
|
981
|
+
year: any;
|
|
982
|
+
};
|
|
983
|
+
getYearHTML(): string;
|
|
984
|
+
getHourHTML(options: any): {
|
|
985
|
+
html: string;
|
|
986
|
+
};
|
|
987
|
+
getMinHTML(hour: any, options: any): {
|
|
988
|
+
html: string;
|
|
989
|
+
};
|
|
990
|
+
inRange(str: any, options: any, dateOnly?: boolean): boolean;
|
|
991
|
+
str2min(str: any): number | null;
|
|
992
|
+
min2str(time: number, format?: any): string;
|
|
993
|
+
}
|
|
994
|
+
declare const TsTooltip: Tooltip;
|
|
995
|
+
declare const TsMenu: MenuTooltip;
|
|
996
|
+
declare const TsColor: ColorTooltip;
|
|
997
|
+
declare const TsDate: DateTooltip;
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Part of TsUi 2.0 library
|
|
1001
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsTooltip, TsColor, TsMenu
|
|
1002
|
+
*
|
|
1003
|
+
* == TODO ==
|
|
1004
|
+
* - tab navigation (index state)
|
|
1005
|
+
* - vertical toolbar
|
|
1006
|
+
* - TsMenu on second click of tb button should hide
|
|
1007
|
+
* - button display groups for each show/hide, possibly add state: { single: t/f, multiple: t/f, type: 'font' }
|
|
1008
|
+
* - item.count - should just support html, so a custom block can be created, such as a colored line
|
|
1009
|
+
*
|
|
1010
|
+
* == 2.0 changes
|
|
1011
|
+
* - CSP - fixed inline events
|
|
1012
|
+
* - removed jQuery dependency
|
|
1013
|
+
* - item.icon - can be class or <custom-icon-component> or <svg>
|
|
1014
|
+
* - new w2tooltips and TsMenu
|
|
1015
|
+
* - scroll returns promise
|
|
1016
|
+
* - added onMouseEntter, onMouseLeave, onMouseDown, onMouseUp events
|
|
1017
|
+
* - add(..., skipRefresh), insert(..., skipRefresh)
|
|
1018
|
+
* - item.items can be a function
|
|
1019
|
+
* - item.icon_style - style for the icon
|
|
1020
|
+
* - item.icon - can be a function
|
|
1021
|
+
* - item.type = 'label', item.type = 'input'
|
|
1022
|
+
* - item.placeholder
|
|
1023
|
+
* - item.input: { spinner, style, min, max, step, precision, suffix }
|
|
1024
|
+
* - item.backColor
|
|
1025
|
+
* - onLiveUpdate - for colors
|
|
1026
|
+
*/
|
|
1027
|
+
|
|
1028
|
+
declare class TsToolbar extends TsBase {
|
|
1029
|
+
box: HTMLElement | null;
|
|
1030
|
+
name: string;
|
|
1031
|
+
routeData: Record<string, unknown>;
|
|
1032
|
+
items: any[];
|
|
1033
|
+
right: string | string[];
|
|
1034
|
+
tooltip: string;
|
|
1035
|
+
item_template: Record<string, unknown>;
|
|
1036
|
+
last: any;
|
|
1037
|
+
_refresh: (opts: any) => void;
|
|
1038
|
+
_refreshDebounced: () => void;
|
|
1039
|
+
[key: string]: any;
|
|
1040
|
+
constructor(options: any);
|
|
1041
|
+
add(items: any, skipRefresh?: any): void;
|
|
1042
|
+
insert(id: any, items: any, skipRefresh?: any): void;
|
|
1043
|
+
remove(...args: any[]): number;
|
|
1044
|
+
set(id: any, newOptions: any): boolean;
|
|
1045
|
+
get(id?: any, returnIndex?: boolean, items?: any[]): any;
|
|
1046
|
+
setCount(id: any, count: any, className?: any, style?: any): void;
|
|
1047
|
+
show(...args: any[]): any[];
|
|
1048
|
+
hide(...args: any[]): any[];
|
|
1049
|
+
enable(...args: any[]): any[];
|
|
1050
|
+
disable(...args: any[]): any[];
|
|
1051
|
+
check(...args: any[]): any[];
|
|
1052
|
+
uncheck(...args: any[]): any[];
|
|
1053
|
+
click(id: any, event?: any): void;
|
|
1054
|
+
scroll(direction?: any, line?: any, instant?: any): Promise<void>;
|
|
1055
|
+
render(box?: any): number | undefined;
|
|
1056
|
+
refresh(id?: any): number | false | undefined;
|
|
1057
|
+
resize(): number | undefined;
|
|
1058
|
+
destroy(): void;
|
|
1059
|
+
unmount(): void;
|
|
1060
|
+
getItemHTML(item: any): string;
|
|
1061
|
+
spinner(id: any, action: any, event?: any): void;
|
|
1062
|
+
change(id?: any, value?: any, dynamic?: any): void;
|
|
1063
|
+
tooltipShow(id: any): void;
|
|
1064
|
+
tooltipHide(_id: any): void;
|
|
1065
|
+
menuClick(event: any): void;
|
|
1066
|
+
colorClick(event: any): void;
|
|
1067
|
+
mouseAction(event: any, target: any, action: any, id: any): void;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Part of TsUi 2.0 library
|
|
1072
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsTooltip, TsMenu
|
|
1073
|
+
*
|
|
1074
|
+
* == TODO ==
|
|
1075
|
+
* - dbl click should be like it is in grid (with timer not HTML dbl click event)
|
|
1076
|
+
* - node.style is misleading - should be there to apply color for example
|
|
1077
|
+
* - node.plus - is not working
|
|
1078
|
+
*
|
|
1079
|
+
* == 2.0 changes
|
|
1080
|
+
* - remove jQuery dependency
|
|
1081
|
+
* - deprecarted obj.img, node.img
|
|
1082
|
+
* - CSP - fixed inline events
|
|
1083
|
+
* - observeResize for the box
|
|
1084
|
+
* - search(..., compare) - comparison function
|
|
1085
|
+
* - editable = true
|
|
1086
|
+
* - edit(id) - new method
|
|
1087
|
+
* - onEdit, onRename - new events
|
|
1088
|
+
* - reorder = true - to allow reorder
|
|
1089
|
+
* - mouseDown - for reorder
|
|
1090
|
+
* - onReorder, onDragStart, onDragOver - events
|
|
1091
|
+
* - this.mutlti - for multi select (ctrl for one at a time and shift for range)
|
|
1092
|
+
* - onSelect, onUnselect - new events
|
|
1093
|
+
* - prev(), next(), getChain()
|
|
1094
|
+
*/
|
|
1095
|
+
|
|
1096
|
+
/** Options accepted by refresh() */
|
|
1097
|
+
interface TsSidebarRefreshOptions {
|
|
1098
|
+
recursive?: boolean;
|
|
1099
|
+
}
|
|
1100
|
+
/** Options accepted by update() — mirrors node property names that can be updated in-place */
|
|
1101
|
+
interface TsSidebarUpdateOptions {
|
|
1102
|
+
icon?: string | ((nd: unknown, level: number) => string) | null;
|
|
1103
|
+
class?: string | null;
|
|
1104
|
+
style?: string | null;
|
|
1105
|
+
text?: string | ((nd: unknown, level: number) => string) | null;
|
|
1106
|
+
count?: number | string | null;
|
|
1107
|
+
[key: string]: unknown;
|
|
1108
|
+
}
|
|
1109
|
+
/** Options accepted by setCount() */
|
|
1110
|
+
interface TsSidebarSetCountOptions {
|
|
1111
|
+
className?: string;
|
|
1112
|
+
style?: string;
|
|
1113
|
+
noRepeat?: boolean;
|
|
1114
|
+
}
|
|
1115
|
+
/** Options for find() */
|
|
1116
|
+
interface TsSidebarFindOptions {
|
|
1117
|
+
returnDisabled?: boolean;
|
|
1118
|
+
returnGroups?: boolean;
|
|
1119
|
+
[key: string]: unknown;
|
|
1120
|
+
}
|
|
1121
|
+
/** Options for sort() */
|
|
1122
|
+
interface TsSidebarSortOptions {
|
|
1123
|
+
foldersFirst?: boolean;
|
|
1124
|
+
caseSensitive?: boolean;
|
|
1125
|
+
reverse?: boolean;
|
|
1126
|
+
[key: string]: unknown;
|
|
1127
|
+
}
|
|
1128
|
+
declare class TsSidebar extends TsBase {
|
|
1129
|
+
box: HTMLElement | null;
|
|
1130
|
+
name: string;
|
|
1131
|
+
nodes: any[];
|
|
1132
|
+
selected: any;
|
|
1133
|
+
img: any;
|
|
1134
|
+
icon: any;
|
|
1135
|
+
style: string;
|
|
1136
|
+
hasFocus: boolean;
|
|
1137
|
+
flat: boolean;
|
|
1138
|
+
flatButton: boolean;
|
|
1139
|
+
keyboard: boolean;
|
|
1140
|
+
editable: boolean;
|
|
1141
|
+
reorder: boolean;
|
|
1142
|
+
tabIndex: number | null;
|
|
1143
|
+
routeData: Record<string, unknown>;
|
|
1144
|
+
multi: boolean;
|
|
1145
|
+
skipRefresh: boolean;
|
|
1146
|
+
last: any;
|
|
1147
|
+
node_template: Record<string, unknown>;
|
|
1148
|
+
[key: string]: any;
|
|
1149
|
+
constructor(options: any);
|
|
1150
|
+
add(parent?: any, nodes?: any): any;
|
|
1151
|
+
insert(parent?: any, before?: any, nodes?: any): any;
|
|
1152
|
+
remove(...args: any[]): number;
|
|
1153
|
+
set(parent?: any, id?: any, node?: any): boolean | null;
|
|
1154
|
+
get(parent?: any, id?: any, returnIndex?: any): any;
|
|
1155
|
+
setCount(id: any, count: any, options?: TsSidebarSetCountOptions): void;
|
|
1156
|
+
find(parent?: any, params?: any, results?: any): any;
|
|
1157
|
+
sort(options: TsSidebarSortOptions | null | undefined, nodes?: any): void;
|
|
1158
|
+
each(fn: any, nodes?: any): void;
|
|
1159
|
+
search(str: any, compare?: any): number;
|
|
1160
|
+
show(...args: any[]): any[];
|
|
1161
|
+
hide(...args: any[]): any[];
|
|
1162
|
+
enable(...args: any[]): any[];
|
|
1163
|
+
disable(...args: any[]): any[];
|
|
1164
|
+
select(id: any): boolean | undefined;
|
|
1165
|
+
unselect(id?: any): boolean | undefined;
|
|
1166
|
+
toggle(id: any): boolean | undefined;
|
|
1167
|
+
collapse(id: any): boolean | undefined;
|
|
1168
|
+
expand(id: any): true | undefined;
|
|
1169
|
+
collapseAll(parent?: any): boolean;
|
|
1170
|
+
expandAll(parent?: any): false | undefined;
|
|
1171
|
+
expandParents(id: any): boolean;
|
|
1172
|
+
click(id: any, event?: any): void;
|
|
1173
|
+
flatMenu(el: any, items: any): void;
|
|
1174
|
+
focus(event?: any): false | undefined;
|
|
1175
|
+
blur(event: any): false | undefined;
|
|
1176
|
+
next(node: any, noSubs?: any): any;
|
|
1177
|
+
prev(node: any): any;
|
|
1178
|
+
getChain(nodes?: any, options?: TsSidebarFindOptions): any[];
|
|
1179
|
+
keydown(event: any): void;
|
|
1180
|
+
inView(id: any): boolean;
|
|
1181
|
+
scrollIntoView(id?: any, instant?: any): Promise<void>;
|
|
1182
|
+
dblClick(id: any, event: any): void;
|
|
1183
|
+
/**
|
|
1184
|
+
* This is needed for not reorder
|
|
1185
|
+
*/
|
|
1186
|
+
mouseDown(id: any, event: any): void;
|
|
1187
|
+
edit(id: any): Node | Node[] | null | undefined;
|
|
1188
|
+
contextMenu(id: any, event: any): void;
|
|
1189
|
+
menuClick(itemId: any, detail?: any): void;
|
|
1190
|
+
goFlat(): void;
|
|
1191
|
+
render(box?: any): number | undefined;
|
|
1192
|
+
update(id: any, options?: TsSidebarUpdateOptions): TsSidebarUpdateOptions;
|
|
1193
|
+
refresh(id?: any, options?: TsSidebarRefreshOptions): number | undefined;
|
|
1194
|
+
mouseAction(action: any, anchor: any, nodeId: any, event: any, type: any): void;
|
|
1195
|
+
tooltip(el: any, text: any): void;
|
|
1196
|
+
otherTooltip(el: any, text: any): void;
|
|
1197
|
+
showPlus(el: any, color: any): void;
|
|
1198
|
+
resize(): number | undefined;
|
|
1199
|
+
destroy(): void;
|
|
1200
|
+
unmount(): void;
|
|
1201
|
+
lock(msg?: any, showSpinner?: any): void;
|
|
1202
|
+
unlock(speed: any): void;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Part of TsUi 2.0 library
|
|
1207
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsTooltip
|
|
1208
|
+
*
|
|
1209
|
+
* == 2.0 changes
|
|
1210
|
+
* - CSP - fixed inline events
|
|
1211
|
+
* - removed jQuery dependency
|
|
1212
|
+
* - observeResize for the box
|
|
1213
|
+
* - refactored w2events
|
|
1214
|
+
* - scrollIntoView - removed callback
|
|
1215
|
+
* - scroll, scrollIntoView return promise
|
|
1216
|
+
* - animateInsert, animateClose - returns a promise
|
|
1217
|
+
* - add, insert return a promise
|
|
1218
|
+
* - onMouseEnter, onMouseLeave, onMouseDown, onMouseUp
|
|
1219
|
+
*/
|
|
1220
|
+
|
|
1221
|
+
declare class TsTabs extends TsBase {
|
|
1222
|
+
box: HTMLElement | null;
|
|
1223
|
+
name: string;
|
|
1224
|
+
active: any;
|
|
1225
|
+
reorder: boolean;
|
|
1226
|
+
flow: string;
|
|
1227
|
+
tooltip: string;
|
|
1228
|
+
tabs: any[];
|
|
1229
|
+
routeData: Record<string, unknown>;
|
|
1230
|
+
last: any;
|
|
1231
|
+
right: string;
|
|
1232
|
+
style: string;
|
|
1233
|
+
tab_template: Record<string, unknown>;
|
|
1234
|
+
[key: string]: any;
|
|
1235
|
+
constructor(options: any);
|
|
1236
|
+
add(tab: any): Promise<any>;
|
|
1237
|
+
insert(id: any, tabs: any): Promise<any>;
|
|
1238
|
+
remove(...ids: any[]): number;
|
|
1239
|
+
select(id: any): boolean;
|
|
1240
|
+
set(id: any, tab: any): boolean;
|
|
1241
|
+
get(id?: any, returnIndex?: boolean): any;
|
|
1242
|
+
show(...ids: any[]): any[];
|
|
1243
|
+
hide(...ids: any[]): any[];
|
|
1244
|
+
enable(...ids: any[]): any[];
|
|
1245
|
+
disable(...ids: any[]): any[];
|
|
1246
|
+
dragMove(event: MouseEvent): void;
|
|
1247
|
+
mouseAction(action: string, id: any, event: MouseEvent): void;
|
|
1248
|
+
tooltipShow(id: any): void;
|
|
1249
|
+
tooltipHide(_id: any): void;
|
|
1250
|
+
getTabHTML(id: any): string | false;
|
|
1251
|
+
refresh(id?: any): number | undefined;
|
|
1252
|
+
render(box?: any): number | false | undefined;
|
|
1253
|
+
initReorder(id: any, event: MouseEvent): void;
|
|
1254
|
+
scroll(direction?: any, instant?: any): Promise<void>;
|
|
1255
|
+
scrollIntoView(id?: any, instant?: any): Promise<void>;
|
|
1256
|
+
resize(): number | undefined;
|
|
1257
|
+
destroy(): void;
|
|
1258
|
+
unmount(): void;
|
|
1259
|
+
click(id: any, event?: MouseEvent): false | void;
|
|
1260
|
+
clickClose(id: any, event?: MouseEvent): false | void;
|
|
1261
|
+
animateClose(id?: any): Promise<void>;
|
|
1262
|
+
animateInsert(id: any, tab: any): Promise<void>;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/** Valid panel type names in a layout */
|
|
1266
|
+
type TsPanelType = 'top' | 'left' | 'main' | 'preview' | 'right' | 'bottom';
|
|
1267
|
+
/** Content that can be placed in a layout panel */
|
|
1268
|
+
type TsPanelContent = string | {
|
|
1269
|
+
render: (box?: HTMLElement) => void;
|
|
1270
|
+
unmount?: () => void;
|
|
1271
|
+
box?: HTMLElement | null;
|
|
1272
|
+
[key: string]: unknown;
|
|
1273
|
+
};
|
|
1274
|
+
/** Individual panel configuration and runtime state */
|
|
1275
|
+
interface TsLayoutPanel {
|
|
1276
|
+
type: TsPanelType | null;
|
|
1277
|
+
title: string;
|
|
1278
|
+
size: number | string;
|
|
1279
|
+
minSize: number;
|
|
1280
|
+
maxSize: number | boolean;
|
|
1281
|
+
hidden: boolean;
|
|
1282
|
+
resizable: boolean;
|
|
1283
|
+
overflow: string;
|
|
1284
|
+
style: string;
|
|
1285
|
+
html: TsPanelContent;
|
|
1286
|
+
tabs: TsTabs | Record<string, unknown> | null;
|
|
1287
|
+
toolbar: TsToolbar | Record<string, unknown> | null;
|
|
1288
|
+
/** Runtime-computed width (read-only after resize) */
|
|
1289
|
+
width: number | null;
|
|
1290
|
+
/** Runtime-computed height (read-only after resize) */
|
|
1291
|
+
height: number | null;
|
|
1292
|
+
/** Runtime-computed size in pixels */
|
|
1293
|
+
sizeCalculated?: number;
|
|
1294
|
+
show: {
|
|
1295
|
+
toolbar: boolean;
|
|
1296
|
+
tabs: boolean;
|
|
1297
|
+
};
|
|
1298
|
+
removed: ((info: {
|
|
1299
|
+
panel: string;
|
|
1300
|
+
html: TsPanelContent;
|
|
1301
|
+
html_new: TsPanelContent;
|
|
1302
|
+
transition: string;
|
|
1303
|
+
}) => void) | null;
|
|
1304
|
+
onRefresh: ((event: unknown) => void) | null;
|
|
1305
|
+
onShow: ((event: unknown) => void) | null;
|
|
1306
|
+
onHide: ((event: unknown) => void) | null;
|
|
1307
|
+
}
|
|
1308
|
+
/** Options for the html() method return promise-like */
|
|
1309
|
+
interface TsHtmlResult {
|
|
1310
|
+
panel: string;
|
|
1311
|
+
html: TsPanelContent;
|
|
1312
|
+
error: boolean;
|
|
1313
|
+
cancelled: boolean;
|
|
1314
|
+
status?: boolean;
|
|
1315
|
+
removed: (cb: () => void) => void;
|
|
1316
|
+
}
|
|
1317
|
+
declare class TsLayout extends TsBase {
|
|
1318
|
+
box: HTMLElement | null;
|
|
1319
|
+
name: string;
|
|
1320
|
+
panels: TsLayoutPanel[];
|
|
1321
|
+
last: Record<string, any>;
|
|
1322
|
+
padding: number;
|
|
1323
|
+
resizer: number;
|
|
1324
|
+
style: string;
|
|
1325
|
+
onShow: ((event: unknown) => void) | null;
|
|
1326
|
+
onHide: ((event: unknown) => void) | null;
|
|
1327
|
+
onResizing: ((event: unknown) => void) | null;
|
|
1328
|
+
onResizerClick: ((event: unknown) => void) | null;
|
|
1329
|
+
onRender: ((event: unknown) => void) | null;
|
|
1330
|
+
onRefresh: ((event: unknown) => void) | null;
|
|
1331
|
+
onChange: ((event: unknown) => void) | null;
|
|
1332
|
+
onResize: ((event: unknown) => void) | null;
|
|
1333
|
+
onDestroy: ((event: unknown) => void) | null;
|
|
1334
|
+
panel_template: TsLayoutPanel;
|
|
1335
|
+
[key: string]: any;
|
|
1336
|
+
constructor(options: any);
|
|
1337
|
+
html(panel: string, data: TsPanelContent, transition?: string): TsHtmlResult;
|
|
1338
|
+
message(panel: string, options: unknown): TsMessageProm | undefined;
|
|
1339
|
+
confirm(panel: string, options: unknown): TsMessageProm | undefined;
|
|
1340
|
+
load(panel: string, url: string, transition?: string): Promise<void | TsHtmlResult>;
|
|
1341
|
+
sizeTo(panel: string, size: number | string, instant?: boolean): boolean;
|
|
1342
|
+
show(panel: string, immediate?: boolean): boolean | undefined;
|
|
1343
|
+
hide(panel: string, immediate?: boolean): boolean | undefined;
|
|
1344
|
+
toggle(panel: string, immediate?: boolean): boolean | undefined;
|
|
1345
|
+
set(panel: string, options: Partial<TsLayoutPanel>): boolean;
|
|
1346
|
+
get(panel: string, returnIndex?: boolean): any;
|
|
1347
|
+
el(panel: string): HTMLElement | null;
|
|
1348
|
+
hideToolbar(panel: string): void;
|
|
1349
|
+
showToolbar(panel: string): void;
|
|
1350
|
+
toggleToolbar(panel: string): void;
|
|
1351
|
+
assignToolbar(panel: string, toolbar: TsToolbar | string | null): void;
|
|
1352
|
+
hideTabs(panel: string): void;
|
|
1353
|
+
showTabs(panel: string): void;
|
|
1354
|
+
toggleTabs(panel: string): void;
|
|
1355
|
+
assignTabs(panel: string, tabs: TsTabs | string | null): void;
|
|
1356
|
+
render(box?: HTMLElement | string): number | false | undefined;
|
|
1357
|
+
unmount(): void;
|
|
1358
|
+
destroy(): boolean | undefined;
|
|
1359
|
+
refresh(panel?: string): number | undefined;
|
|
1360
|
+
resize(): number | false | undefined;
|
|
1361
|
+
resizeBoxes(panel?: string): void;
|
|
1362
|
+
lock(panel: string, msg: unknown, showSpinner?: boolean): void;
|
|
1363
|
+
unlock(panel: string, speed?: number): void;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Shared branded primitive types for TsUi public API.
|
|
1368
|
+
*
|
|
1369
|
+
* Branded types prevent accidental cross-assignment of semantically different
|
|
1370
|
+
* string/number values (e.g. passing a FieldName where a RecId is expected).
|
|
1371
|
+
*
|
|
1372
|
+
* Usage:
|
|
1373
|
+
* const id: RecId = 'row-1' as RecId
|
|
1374
|
+
* const panel: LayoutPanelId = 'left' as LayoutPanelId
|
|
1375
|
+
*
|
|
1376
|
+
* @module types
|
|
1377
|
+
*/
|
|
1378
|
+
/**
|
|
1379
|
+
* Creates a branded (nominal) type from a base type K and brand tag T.
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* type UserId = Brand<number, 'UserId'>
|
|
1383
|
+
*
|
|
1384
|
+
* @internal
|
|
1385
|
+
*/
|
|
1386
|
+
type Brand<K, T> = K & {
|
|
1387
|
+
readonly __brand: T;
|
|
1388
|
+
};
|
|
1389
|
+
/**
|
|
1390
|
+
* A record identifier value — the `recid` field used across TsGrid records.
|
|
1391
|
+
* Can be either a string or a number at runtime; branded to prevent mixing
|
|
1392
|
+
* generic string/number primitives with record identifiers.
|
|
1393
|
+
*
|
|
1394
|
+
* @example
|
|
1395
|
+
* const recid: RecId = 42 as RecId
|
|
1396
|
+
*/
|
|
1397
|
+
type RecId = Brand<string | number, 'RecId'>;
|
|
1398
|
+
|
|
1399
|
+
/** A single data record stored in the grid */
|
|
1400
|
+
interface TsGridRecord {
|
|
1401
|
+
recid: string | number;
|
|
1402
|
+
TsUi?: {
|
|
1403
|
+
summary?: boolean;
|
|
1404
|
+
children?: TsGridRecord[];
|
|
1405
|
+
parent_recid?: string | number;
|
|
1406
|
+
expanded?: boolean;
|
|
1407
|
+
selectable?: boolean;
|
|
1408
|
+
styles?: Record<string, string>;
|
|
1409
|
+
[key: string]: any;
|
|
1410
|
+
};
|
|
1411
|
+
[key: string]: any;
|
|
1412
|
+
}
|
|
1413
|
+
/** Sort descriptor used in grid.sortData */
|
|
1414
|
+
interface TsGridSortData {
|
|
1415
|
+
field: string;
|
|
1416
|
+
direction: 'asc' | 'desc';
|
|
1417
|
+
field_?: string;
|
|
1418
|
+
[key: string]: any;
|
|
1419
|
+
}
|
|
1420
|
+
/** Virtual scroll state kept in grid.last.vscroll */
|
|
1421
|
+
interface TsGridVScroll {
|
|
1422
|
+
scrollTop: number;
|
|
1423
|
+
scrollLeft: number;
|
|
1424
|
+
recIndStart: number | null;
|
|
1425
|
+
recIndEnd: number | null;
|
|
1426
|
+
colIndStart: number;
|
|
1427
|
+
colIndEnd: number;
|
|
1428
|
+
pull_more: boolean;
|
|
1429
|
+
pull_refresh: boolean;
|
|
1430
|
+
show_extra: number;
|
|
1431
|
+
}
|
|
1432
|
+
/** Fetch state kept in grid.last.fetch */
|
|
1433
|
+
interface TsGridFetch {
|
|
1434
|
+
action: string;
|
|
1435
|
+
offset?: number | null;
|
|
1436
|
+
start: number;
|
|
1437
|
+
response: number;
|
|
1438
|
+
options: RequestInit | null;
|
|
1439
|
+
controller: AbortController | null;
|
|
1440
|
+
loaded: boolean;
|
|
1441
|
+
hasMore: boolean;
|
|
1442
|
+
}
|
|
1443
|
+
/** Column definition — T5.2 */
|
|
1444
|
+
interface TsGridColumn {
|
|
1445
|
+
field: string;
|
|
1446
|
+
text: string | ((col: TsGridColumn) => string);
|
|
1447
|
+
size?: string | number;
|
|
1448
|
+
min?: number;
|
|
1449
|
+
max?: number;
|
|
1450
|
+
frozen?: boolean;
|
|
1451
|
+
hidden?: boolean;
|
|
1452
|
+
hideable?: boolean;
|
|
1453
|
+
resizable?: boolean;
|
|
1454
|
+
sortable?: boolean;
|
|
1455
|
+
searchable?: boolean | string;
|
|
1456
|
+
sortMode?: string;
|
|
1457
|
+
editable?: boolean | {
|
|
1458
|
+
type: string;
|
|
1459
|
+
[key: string]: any;
|
|
1460
|
+
} | ((rec: TsGridRecord, cell: any) => any);
|
|
1461
|
+
render?: string | ((record: TsGridRecord, index: number, colIndex: number) => string);
|
|
1462
|
+
tooltip?: string;
|
|
1463
|
+
style?: string;
|
|
1464
|
+
attr?: string;
|
|
1465
|
+
clipboardCopy?: boolean | ((record: TsGridRecord, cell: any) => string);
|
|
1466
|
+
colspan?: Record<string, number> | ((record: TsGridRecord, index: number) => number);
|
|
1467
|
+
sizeCalculated?: string;
|
|
1468
|
+
sizeOriginal?: string | number;
|
|
1469
|
+
sizeType?: string;
|
|
1470
|
+
gridMinWidth?: number;
|
|
1471
|
+
[key: string]: any;
|
|
1472
|
+
}
|
|
1473
|
+
/** Search field definition — T5.2 */
|
|
1474
|
+
interface TsGridSearch {
|
|
1475
|
+
field: string;
|
|
1476
|
+
label?: string;
|
|
1477
|
+
caption?: string;
|
|
1478
|
+
type: string;
|
|
1479
|
+
hidden?: boolean;
|
|
1480
|
+
attr?: string;
|
|
1481
|
+
text?: string;
|
|
1482
|
+
style?: string;
|
|
1483
|
+
operator?: string;
|
|
1484
|
+
operators?: string[];
|
|
1485
|
+
options?: Record<string, any>;
|
|
1486
|
+
value?: any;
|
|
1487
|
+
svalue?: any;
|
|
1488
|
+
[key: string]: any;
|
|
1489
|
+
}
|
|
1490
|
+
/** Internal last-state object */
|
|
1491
|
+
interface TsGridLast {
|
|
1492
|
+
field: string;
|
|
1493
|
+
label: string;
|
|
1494
|
+
logic: 'AND' | 'OR';
|
|
1495
|
+
search: string;
|
|
1496
|
+
searchIds: number[];
|
|
1497
|
+
selection: TsGridSelection;
|
|
1498
|
+
saved_sel: any | null;
|
|
1499
|
+
multi: boolean;
|
|
1500
|
+
fetch: TsGridFetch;
|
|
1501
|
+
vscroll: TsGridVScroll;
|
|
1502
|
+
sel_ind: number | null;
|
|
1503
|
+
sel_col: number | null;
|
|
1504
|
+
sel_type: string | null;
|
|
1505
|
+
sel_recid: string | number | null;
|
|
1506
|
+
idCache: Record<string | number, number>;
|
|
1507
|
+
move: any | null;
|
|
1508
|
+
cancelClick: boolean | null;
|
|
1509
|
+
inEditMode: boolean;
|
|
1510
|
+
_edit: {
|
|
1511
|
+
value: any;
|
|
1512
|
+
index: number;
|
|
1513
|
+
column: number;
|
|
1514
|
+
recid: string | number;
|
|
1515
|
+
[key: string]: any;
|
|
1516
|
+
} | null;
|
|
1517
|
+
kbd_timer: ReturnType<typeof setTimeout> | null;
|
|
1518
|
+
marker_timer: ReturnType<typeof setTimeout> | null;
|
|
1519
|
+
click_time: number | null;
|
|
1520
|
+
click_recid: string | number | null;
|
|
1521
|
+
bubbleEl: HTMLElement | null;
|
|
1522
|
+
colResizing: boolean;
|
|
1523
|
+
tmp: any | null;
|
|
1524
|
+
copy_event: any | null;
|
|
1525
|
+
userSelect: string;
|
|
1526
|
+
columnDrag: false | {
|
|
1527
|
+
remove(): void;
|
|
1528
|
+
};
|
|
1529
|
+
state: any | null;
|
|
1530
|
+
toolbar_height: number;
|
|
1531
|
+
groupBy_links: Record<string, TsGridRecord>;
|
|
1532
|
+
originalSort?: (string | number)[];
|
|
1533
|
+
[key: string]: any;
|
|
1534
|
+
}
|
|
1535
|
+
/** Cell-level selection descriptor returned by `getSelectionCells()` (and by `getSelection()` when `selectType === 'cell'`). */
|
|
1536
|
+
interface TsGridCellSelection {
|
|
1537
|
+
recid: string | number;
|
|
1538
|
+
index: number;
|
|
1539
|
+
column: number;
|
|
1540
|
+
}
|
|
1541
|
+
/** Selection state — T5.4 */
|
|
1542
|
+
interface TsGridSelection {
|
|
1543
|
+
indexes: number[];
|
|
1544
|
+
columns: Record<string | number, number[]>;
|
|
1545
|
+
}
|
|
1546
|
+
/** Range endpoint (used in addRange / refreshRanges) */
|
|
1547
|
+
interface TsGridRangeEndpoint {
|
|
1548
|
+
recid: string | number;
|
|
1549
|
+
column: number;
|
|
1550
|
+
index?: number;
|
|
1551
|
+
}
|
|
1552
|
+
/** Range descriptor for addRange / refreshRanges */
|
|
1553
|
+
interface TsGridRange {
|
|
1554
|
+
name: string;
|
|
1555
|
+
range: TsGridRangeEndpoint[];
|
|
1556
|
+
style?: string;
|
|
1557
|
+
class?: string;
|
|
1558
|
+
[key: string]: any;
|
|
1559
|
+
}
|
|
1560
|
+
/** Active search filter — one entry in grid.searchData — T5.5 */
|
|
1561
|
+
interface TsGridSearchFilter {
|
|
1562
|
+
field: string;
|
|
1563
|
+
type: string;
|
|
1564
|
+
operator: string;
|
|
1565
|
+
value?: any;
|
|
1566
|
+
svalue?: any;
|
|
1567
|
+
text?: string;
|
|
1568
|
+
[key: string]: any;
|
|
1569
|
+
}
|
|
1570
|
+
/** GroupBy configuration object */
|
|
1571
|
+
interface TsGridGroupBy {
|
|
1572
|
+
field: string;
|
|
1573
|
+
[key: string]: any;
|
|
1574
|
+
}
|
|
1575
|
+
declare class TsGrid extends TsBase {
|
|
1576
|
+
[key: string]: any;
|
|
1577
|
+
name: string;
|
|
1578
|
+
box: HTMLElement | null;
|
|
1579
|
+
columns: TsGridColumn[];
|
|
1580
|
+
columnGroups: any[];
|
|
1581
|
+
records: TsGridRecord[];
|
|
1582
|
+
summary: TsGridRecord[];
|
|
1583
|
+
searches: TsGridSearch[];
|
|
1584
|
+
toolbar: any;
|
|
1585
|
+
ranges: TsGridRange[];
|
|
1586
|
+
contextMenu: any[];
|
|
1587
|
+
searchMap: Record<string, string>;
|
|
1588
|
+
searchData: TsGridSearchFilter[];
|
|
1589
|
+
sortMap: Record<string, string>;
|
|
1590
|
+
sortData: TsGridSortData[];
|
|
1591
|
+
savedSearches: any[];
|
|
1592
|
+
defaultSearches: any[];
|
|
1593
|
+
groupBy: TsGridGroupBy | null;
|
|
1594
|
+
total: number;
|
|
1595
|
+
recid: string | null;
|
|
1596
|
+
hierarchyColumn: number;
|
|
1597
|
+
last: TsGridLast;
|
|
1598
|
+
header: string;
|
|
1599
|
+
url: any;
|
|
1600
|
+
limit: number;
|
|
1601
|
+
offset: number;
|
|
1602
|
+
postData: Record<string, any>;
|
|
1603
|
+
routeData: Record<string, any>;
|
|
1604
|
+
httpHeaders: Record<string, string>;
|
|
1605
|
+
show: {
|
|
1606
|
+
header: boolean;
|
|
1607
|
+
toolbar: boolean;
|
|
1608
|
+
footer: boolean;
|
|
1609
|
+
columnMenu: boolean;
|
|
1610
|
+
columnHeaders: boolean;
|
|
1611
|
+
lineNumbers: boolean;
|
|
1612
|
+
expandColumn: boolean;
|
|
1613
|
+
selectColumn: boolean;
|
|
1614
|
+
emptyRecords: boolean;
|
|
1615
|
+
toolbarReload: boolean;
|
|
1616
|
+
toolbarColumns: boolean;
|
|
1617
|
+
toolbarSearch: boolean;
|
|
1618
|
+
toolbarAdd: boolean;
|
|
1619
|
+
toolbarEdit: boolean;
|
|
1620
|
+
toolbarDelete: boolean;
|
|
1621
|
+
toolbarSave: boolean;
|
|
1622
|
+
searchAll: boolean;
|
|
1623
|
+
searchLogic: boolean;
|
|
1624
|
+
searchHiddenMsg: boolean;
|
|
1625
|
+
searchSave: boolean;
|
|
1626
|
+
statusRange: boolean;
|
|
1627
|
+
statusBuffered: boolean;
|
|
1628
|
+
statusRecordID: boolean;
|
|
1629
|
+
statusSelection: boolean;
|
|
1630
|
+
statusResponse: boolean;
|
|
1631
|
+
statusSort: boolean;
|
|
1632
|
+
statusSearch: boolean;
|
|
1633
|
+
recordTitles: boolean;
|
|
1634
|
+
selectionBorder: boolean;
|
|
1635
|
+
selectionResizer: boolean;
|
|
1636
|
+
skipRecords: boolean;
|
|
1637
|
+
saveRestoreState: boolean;
|
|
1638
|
+
columns?: boolean;
|
|
1639
|
+
};
|
|
1640
|
+
stateId: string | null;
|
|
1641
|
+
hasFocus: boolean;
|
|
1642
|
+
autoLoad: boolean;
|
|
1643
|
+
fixedBody: boolean;
|
|
1644
|
+
recordHeight: number;
|
|
1645
|
+
lineNumberWidth: number;
|
|
1646
|
+
keyboard: boolean;
|
|
1647
|
+
selectType: 'row' | 'cell';
|
|
1648
|
+
liveSearch: boolean;
|
|
1649
|
+
multiSearch: boolean;
|
|
1650
|
+
multiSelect: boolean;
|
|
1651
|
+
multiSort: boolean;
|
|
1652
|
+
reorderColumns: boolean;
|
|
1653
|
+
reorderRows: boolean;
|
|
1654
|
+
showExtraOnSearch: number;
|
|
1655
|
+
markSearch: boolean;
|
|
1656
|
+
columnTooltip: string;
|
|
1657
|
+
disableCVS: boolean;
|
|
1658
|
+
nestedFields: boolean;
|
|
1659
|
+
vs_start: number;
|
|
1660
|
+
vs_extra: number;
|
|
1661
|
+
style: string;
|
|
1662
|
+
tabIndex: number | null;
|
|
1663
|
+
dataType: string | null;
|
|
1664
|
+
parser: ((data: any) => any) | null;
|
|
1665
|
+
advanceOnEdit: boolean;
|
|
1666
|
+
useLocalStorage: boolean;
|
|
1667
|
+
colTemplate: Record<string, any>;
|
|
1668
|
+
stateColProps: Record<string, boolean>;
|
|
1669
|
+
msgDelete: string;
|
|
1670
|
+
msgNotJSON: string;
|
|
1671
|
+
msgHTTPError: string;
|
|
1672
|
+
msgServerError: string;
|
|
1673
|
+
msgRefresh: string;
|
|
1674
|
+
msgNeedReload: string;
|
|
1675
|
+
msgEmpty: string;
|
|
1676
|
+
buttons: Record<string, any>;
|
|
1677
|
+
operators: Record<string, any[]>;
|
|
1678
|
+
defaultOperator: Record<string, string>;
|
|
1679
|
+
operatorsMap: Record<string, string>;
|
|
1680
|
+
onAdd: ((event: CustomEvent) => void) | null;
|
|
1681
|
+
onEdit: ((event: CustomEvent) => void) | null;
|
|
1682
|
+
onRequest: ((event: CustomEvent) => void) | null;
|
|
1683
|
+
onLoad: ((event: CustomEvent) => void) | null;
|
|
1684
|
+
onDelete: ((event: CustomEvent) => void) | null;
|
|
1685
|
+
onSave: ((event: CustomEvent) => void) | null;
|
|
1686
|
+
onSelect: ((event: CustomEvent) => void) | null;
|
|
1687
|
+
onClick: ((event: CustomEvent) => void) | null;
|
|
1688
|
+
onDblClick: ((event: CustomEvent) => void) | null;
|
|
1689
|
+
onContextMenu: ((event: CustomEvent) => void) | null;
|
|
1690
|
+
onContextMenuClick: ((event: CustomEvent) => void) | null;
|
|
1691
|
+
onColumnClick: ((event: CustomEvent) => void) | null;
|
|
1692
|
+
onColumnDblClick: ((event: CustomEvent) => void) | null;
|
|
1693
|
+
onColumnContextMenu: ((event: CustomEvent) => void) | null;
|
|
1694
|
+
onColumnResize: ((event: CustomEvent) => void) | null;
|
|
1695
|
+
onColumnAutoResize: ((event: CustomEvent) => void) | null;
|
|
1696
|
+
onSort: ((event: CustomEvent) => void) | null;
|
|
1697
|
+
onSearch: ((event: CustomEvent) => void) | null;
|
|
1698
|
+
onSearchOpen: ((event: CustomEvent) => void) | null;
|
|
1699
|
+
onSearchClose: ((event: CustomEvent) => void) | null;
|
|
1700
|
+
onChange: ((event: CustomEvent) => void) | null;
|
|
1701
|
+
onRestore: ((event: CustomEvent) => void) | null;
|
|
1702
|
+
onExpand: ((event: CustomEvent) => void) | null;
|
|
1703
|
+
onCollapse: ((event: CustomEvent) => void) | null;
|
|
1704
|
+
onError: ((event: CustomEvent) => void) | null;
|
|
1705
|
+
onKeydown: ((event: CustomEvent) => void) | null;
|
|
1706
|
+
onToolbar: ((event: CustomEvent) => void) | null;
|
|
1707
|
+
onColumnOnOff: ((event: CustomEvent) => void) | null;
|
|
1708
|
+
onCopy: ((event: CustomEvent) => void) | null;
|
|
1709
|
+
onPaste: ((event: CustomEvent) => void) | null;
|
|
1710
|
+
onSelectionExtend: ((event: CustomEvent) => void) | null;
|
|
1711
|
+
onEditField: ((event: CustomEvent) => void) | null;
|
|
1712
|
+
onRender: ((event: CustomEvent) => void) | null;
|
|
1713
|
+
onRefresh: ((event: CustomEvent) => void) | null;
|
|
1714
|
+
onReload: ((event: CustomEvent) => void) | null;
|
|
1715
|
+
onResize: ((event: CustomEvent) => void) | null;
|
|
1716
|
+
onDestroy: ((event: CustomEvent) => void) | null;
|
|
1717
|
+
onStateSave: ((event: CustomEvent) => void) | null;
|
|
1718
|
+
onStateRestore: ((event: CustomEvent) => void) | null;
|
|
1719
|
+
onFocus: ((event: CustomEvent) => void) | null;
|
|
1720
|
+
onBlur: ((event: CustomEvent) => void) | null;
|
|
1721
|
+
onReorderRow: ((event: CustomEvent) => void) | null;
|
|
1722
|
+
onSearchSave: ((event: CustomEvent) => void) | null;
|
|
1723
|
+
onSearchRemove: ((event: CustomEvent) => void) | null;
|
|
1724
|
+
onSearchSelect: ((event: CustomEvent) => void) | null;
|
|
1725
|
+
onColumnSelect: ((event: CustomEvent) => void) | null;
|
|
1726
|
+
onColumnDragStart: ((event: CustomEvent) => void) | null;
|
|
1727
|
+
onColumnDragEnd: ((event: CustomEvent) => void) | null;
|
|
1728
|
+
onResizerDblClick: ((event: CustomEvent) => void) | null;
|
|
1729
|
+
onMouseEnter: ((event: CustomEvent) => void) | null;
|
|
1730
|
+
onMouseLeave: ((event: CustomEvent) => void) | null;
|
|
1731
|
+
constructor(options: Record<string, any>);
|
|
1732
|
+
add(record: TsGridRecord | TsGridRecord[], first?: boolean): number;
|
|
1733
|
+
find(obj?: Record<string, any>, returnIndex?: boolean, displayedOnly?: boolean): (string | number)[];
|
|
1734
|
+
set(recid: any, record?: any, noRefresh?: boolean): boolean;
|
|
1735
|
+
replace(recid: string | number, record: TsGridRecord, noRefresh?: boolean): boolean;
|
|
1736
|
+
get(recid: (string | number)[], returnIndex?: boolean): (TsGridRecord | number)[];
|
|
1737
|
+
get(recid: string | number, returnIndex: true): number | null;
|
|
1738
|
+
get(recid: string | number, returnIndex?: false): TsGridRecord | null;
|
|
1739
|
+
getFirst(offset?: number): TsGridRecord | null;
|
|
1740
|
+
remove(...recids: (string | number)[]): number;
|
|
1741
|
+
/**
|
|
1742
|
+
* If there is a this.groupBy, then process all records with that in mind. It will remember groups in this.last.groupBy_links, that
|
|
1743
|
+
* needs to be cleared when record is cleared
|
|
1744
|
+
*/
|
|
1745
|
+
processGroupBy(): void;
|
|
1746
|
+
/** Add one or more columns. If `columns` is omitted, `before` is treated as the column(s) to append. */
|
|
1747
|
+
addColumn(before: any, columns?: any): number;
|
|
1748
|
+
removeColumn(...fields: string[]): number;
|
|
1749
|
+
getColumn(): string[];
|
|
1750
|
+
getColumn(field: string, returnIndex: true): number | null;
|
|
1751
|
+
getColumn(field: string, returnIndex?: false): TsGridColumn | null;
|
|
1752
|
+
updateColumn(fields: string | string[], updates: Partial<TsGridColumn> | Record<string, any>): number;
|
|
1753
|
+
toggleColumn(...fields: string[]): number;
|
|
1754
|
+
showColumn(...fields: string[]): number;
|
|
1755
|
+
hideColumn(...fields: string[]): number;
|
|
1756
|
+
/** Add one or more search fields. If `search` is omitted, `before` is treated as the search(es) to append. */
|
|
1757
|
+
addSearch(before: any, search?: any): number;
|
|
1758
|
+
removeSearch(...fields: string[]): number;
|
|
1759
|
+
getSearch(): string[];
|
|
1760
|
+
getSearch(field: string, returnIndex: true): number | null;
|
|
1761
|
+
getSearch(field: string, returnIndex?: false): TsGridSearch | null;
|
|
1762
|
+
toggleSearch(...fields: string[]): number;
|
|
1763
|
+
showSearch(...fields: string[]): number;
|
|
1764
|
+
hideSearch(...fields: string[]): number;
|
|
1765
|
+
getSearchData(field: string): Record<string, any> | null;
|
|
1766
|
+
localSort(silent?: boolean, noResetRefresh?: boolean): number | undefined;
|
|
1767
|
+
localSearch(silent?: boolean): number | undefined;
|
|
1768
|
+
getRangeData(range: [{
|
|
1769
|
+
recid: string | number;
|
|
1770
|
+
column: number;
|
|
1771
|
+
}, {
|
|
1772
|
+
recid: string | number;
|
|
1773
|
+
column: number;
|
|
1774
|
+
}], extra?: boolean): any[];
|
|
1775
|
+
addRange(rangesInput: TsGridRange | TsGridRange[] | string | Record<string, any>): number;
|
|
1776
|
+
removeRange(...names: string[]): number;
|
|
1777
|
+
refreshRanges(): number | undefined;
|
|
1778
|
+
select(...selectArgs: any[]): number | undefined;
|
|
1779
|
+
unselect(...unselectArgs: any[]): number;
|
|
1780
|
+
compareSelection(newSel: any[]): {
|
|
1781
|
+
select: any[];
|
|
1782
|
+
unselect: any[];
|
|
1783
|
+
};
|
|
1784
|
+
selectAll(): number | undefined;
|
|
1785
|
+
selectNone(skipEvent?: boolean): number | undefined;
|
|
1786
|
+
updateToolbar(sel?: any, _areAllSelected?: boolean): void;
|
|
1787
|
+
/**
|
|
1788
|
+
* Row-mode selection. Returns the recids of selected records, or their indexes
|
|
1789
|
+
* when `returnIndex === true`. Unaffected by `selectType === 'cell'` — callers
|
|
1790
|
+
* should branch on `this.selectType` and use `getSelectionCells()` for cell mode.
|
|
1791
|
+
*/
|
|
1792
|
+
getSelectionRows(returnIndex?: boolean): RecId[] | number[];
|
|
1793
|
+
/**
|
|
1794
|
+
* Cell-mode selection. Returns one descriptor per selected cell. `returnIndex`
|
|
1795
|
+
* is intentionally not a parameter — it was ignored in cell mode by the legacy
|
|
1796
|
+
* `getSelection()` API.
|
|
1797
|
+
*/
|
|
1798
|
+
getSelectionCells(): TsGridCellSelection[];
|
|
1799
|
+
/**
|
|
1800
|
+
* Discriminated-union wrapper. The shape depends on `this.selectType`:
|
|
1801
|
+
* - `'row'` → `RecId[]` (or `number[]` if `returnIndex === true`)
|
|
1802
|
+
* - `'cell'` → `TsGridCellSelection[]` (`returnIndex` is ignored)
|
|
1803
|
+
*
|
|
1804
|
+
* Prefer the typed split methods (`getSelectionRows` / `getSelectionCells`)
|
|
1805
|
+
* when the caller knows the mode statically. This wrapper is kept for back-
|
|
1806
|
+
* compat with the v2.0 API and for callers that genuinely handle both modes.
|
|
1807
|
+
*/
|
|
1808
|
+
getSelection(returnIndex?: boolean): RecId[] | number[] | TsGridCellSelection[];
|
|
1809
|
+
search(field?: any, value?: any): void;
|
|
1810
|
+
searchOpen(options?: any): void;
|
|
1811
|
+
searchClose(): void;
|
|
1812
|
+
searchFieldTooltip(ind: any, sd_ind: any, el: any): void;
|
|
1813
|
+
searchSuggest(imediate?: boolean, forceHide?: boolean, anchor?: HTMLElement | Element): void;
|
|
1814
|
+
searchSave(): void;
|
|
1815
|
+
cache(type: any): any;
|
|
1816
|
+
cacheSave(type: any, value: any): boolean;
|
|
1817
|
+
searchReset(noReload?: boolean): void;
|
|
1818
|
+
searchShowFields(forceHide?: boolean): void;
|
|
1819
|
+
searchInitInput(field: string, _value?: any): void;
|
|
1820
|
+
clear(noRefresh?: boolean): void;
|
|
1821
|
+
reset(noRefresh?: boolean): void;
|
|
1822
|
+
skip(offset: any, callBack?: any): void;
|
|
1823
|
+
load(url: any, callBack?: any): Promise<any>;
|
|
1824
|
+
reload(callBack?: (...args: any[]) => void): Promise<any>;
|
|
1825
|
+
request(action: string, postData?: Record<string, any>, url?: any, callBack?: (...args: any[]) => void): Promise<any>;
|
|
1826
|
+
requestComplete(data: any, action: any, callBack: any, resolve: any, reject: any): Promise<any> | undefined;
|
|
1827
|
+
error(msg: any): void;
|
|
1828
|
+
getChanges(recordsBase?: TsGridRecord[]): Record<string, any>[];
|
|
1829
|
+
mergeChanges(): void;
|
|
1830
|
+
save(callBack?: (data: any) => void): void;
|
|
1831
|
+
editField(recid: string | number, column: number, value: any, event?: any): void;
|
|
1832
|
+
editChange(input?: any, index?: any, column?: any, event?: any): void;
|
|
1833
|
+
editDone(index?: any, column?: any, event?: any): void;
|
|
1834
|
+
'delete'(force?: boolean): void;
|
|
1835
|
+
click(recid: string | number | {
|
|
1836
|
+
recid: string | number;
|
|
1837
|
+
column?: number;
|
|
1838
|
+
} | any, event?: MouseEvent | any): void;
|
|
1839
|
+
columnClick(field: string, event?: MouseEvent | any): void;
|
|
1840
|
+
columnDblClick(field: any, event: any): void;
|
|
1841
|
+
columnContextMenu(field: any, event: any): void;
|
|
1842
|
+
columnAutoSize(colIndex?: number): true | undefined;
|
|
1843
|
+
columnAutoSizeAll(): void;
|
|
1844
|
+
focus(event?: Event | any): false | undefined;
|
|
1845
|
+
blur(event?: Event | any): false | undefined;
|
|
1846
|
+
keydown(event: KeyboardEvent | any): void;
|
|
1847
|
+
scrollIntoView(ind?: number | null, column?: number, instant?: boolean, recTop?: boolean): void;
|
|
1848
|
+
scrollToColumn(field: any): void;
|
|
1849
|
+
dblClick(recid: string | number | {
|
|
1850
|
+
recid: string | number;
|
|
1851
|
+
column?: number;
|
|
1852
|
+
} | any, event?: MouseEvent | any): void;
|
|
1853
|
+
showContextMenu(event: MouseEvent | any, options: {
|
|
1854
|
+
recid?: string | number;
|
|
1855
|
+
index?: number;
|
|
1856
|
+
column?: number;
|
|
1857
|
+
}): void;
|
|
1858
|
+
contextMenuClick(recid: string | number, column: number | null, event: any): void;
|
|
1859
|
+
toggle(recid: string | number, _event?: Event): boolean | undefined;
|
|
1860
|
+
/**
|
|
1861
|
+
* When record is expaned, then TsUi.children of the record is copied into this.records and this.total is updated. It will
|
|
1862
|
+
* also set TsUi._copeid = true, so it would not copy it again.
|
|
1863
|
+
*
|
|
1864
|
+
* There is also updateExpaned() that is called in this.refresh()
|
|
1865
|
+
*/
|
|
1866
|
+
expand(recid: any, noRefresh?: any): boolean;
|
|
1867
|
+
collapse(recid: any, noRefresh?: any): boolean;
|
|
1868
|
+
updateExpanded(): void;
|
|
1869
|
+
sort(field?: string, direction?: 'asc' | 'desc' | '' | null, multiField?: boolean): void;
|
|
1870
|
+
copy(flag: any, oEvent?: ClipboardEvent | any): any;
|
|
1871
|
+
/**
|
|
1872
|
+
* Gets value to be copied to the clipboard
|
|
1873
|
+
* @param ind index of the record
|
|
1874
|
+
* @param col_ind index of the column
|
|
1875
|
+
* @returns the displayed value of the field's record associated with the cell
|
|
1876
|
+
*/
|
|
1877
|
+
getCellCopy(ind: any, col_ind: any): unknown;
|
|
1878
|
+
paste(text: string, event?: ClipboardEvent | any): void;
|
|
1879
|
+
resize(): number | undefined;
|
|
1880
|
+
update({ cells, fullCellRefresh, ignoreColumns }?: any): number;
|
|
1881
|
+
refreshCell(recid: any, field: any): boolean;
|
|
1882
|
+
refreshRow(recid: any, ind?: any): boolean;
|
|
1883
|
+
refresh(): number | undefined;
|
|
1884
|
+
refreshSearch(): void;
|
|
1885
|
+
refreshBody(): void;
|
|
1886
|
+
render(box?: HTMLElement | string | null): number | undefined;
|
|
1887
|
+
unmount(): void;
|
|
1888
|
+
destroy(): void;
|
|
1889
|
+
initColumnOnOff(): any[];
|
|
1890
|
+
initColumnDrag(_box?: any): {
|
|
1891
|
+
remove(): void;
|
|
1892
|
+
};
|
|
1893
|
+
columnOnOff(event: MouseEvent | any, field: string): void;
|
|
1894
|
+
initToolbar(): void;
|
|
1895
|
+
initResize(): void;
|
|
1896
|
+
resizeBoxes(): void;
|
|
1897
|
+
resizeRecords(): void;
|
|
1898
|
+
getSearchesHTML(): string;
|
|
1899
|
+
getOperators(type: any, opers: any): string;
|
|
1900
|
+
initOperator(ind: any): void;
|
|
1901
|
+
initSearchLists(changedField?: any): void;
|
|
1902
|
+
initSearches(): void;
|
|
1903
|
+
getColumnsHTML(): string[];
|
|
1904
|
+
getColumnCellHTML(i: any): string;
|
|
1905
|
+
columnTooltipShow(ind: any, _event: any): void;
|
|
1906
|
+
columnTooltipHide(_ind: any, _event: any): void;
|
|
1907
|
+
getRecordsHTML(): string[];
|
|
1908
|
+
getSummaryHTML(): string[] | undefined;
|
|
1909
|
+
scroll(event?: Event | any): void;
|
|
1910
|
+
getRecordHTML(ind: number, lineNum: number, summary?: boolean): string[] | "";
|
|
1911
|
+
getLineHTML(lineNum: number): string;
|
|
1912
|
+
getCellHTML(ind: number, col_ind: number, summary?: boolean, col_span?: number): any;
|
|
1913
|
+
clipboardCopy(ind: any, col_ind: any, summary: any): void;
|
|
1914
|
+
showBubble(ind: any, col_ind: any, summary: any): any;
|
|
1915
|
+
getCellEditable(ind: number, col_ind: number): any;
|
|
1916
|
+
getCellValue(ind: number, col_ind: number, summary?: boolean, extra?: boolean): any;
|
|
1917
|
+
getFooterHTML(): string;
|
|
1918
|
+
status(msg?: string): void;
|
|
1919
|
+
lock(msg?: string, showSpinner?: boolean): void;
|
|
1920
|
+
unlock(speed?: number): void;
|
|
1921
|
+
stateSave(returnOnly: any): {
|
|
1922
|
+
columns: Record<string, any>[];
|
|
1923
|
+
show: any;
|
|
1924
|
+
last: any;
|
|
1925
|
+
sortData: any[];
|
|
1926
|
+
searchData: any[];
|
|
1927
|
+
} | undefined;
|
|
1928
|
+
stateRestore(newState?: any): true | undefined;
|
|
1929
|
+
stateReset(): void;
|
|
1930
|
+
parseField(obj: TsGridRecord | null | undefined, field: string): any;
|
|
1931
|
+
prepareData(): void;
|
|
1932
|
+
nextCell(index: number, col_ind: number, editable?: boolean): {
|
|
1933
|
+
index: number;
|
|
1934
|
+
colIndex: number;
|
|
1935
|
+
} | null;
|
|
1936
|
+
prevCell(index: number, col_ind: number, editable?: boolean): {
|
|
1937
|
+
index: number;
|
|
1938
|
+
colIndex: number;
|
|
1939
|
+
} | null;
|
|
1940
|
+
nextRow(ind: number, col_ind?: number, numRows?: number): number | null;
|
|
1941
|
+
prevRow(ind: number, col_ind?: number, numRows?: number): number | null;
|
|
1942
|
+
selectionSave(): any;
|
|
1943
|
+
selectionRestore(noRefresh?: boolean): number;
|
|
1944
|
+
message(options?: any): TsMessageProm | undefined;
|
|
1945
|
+
confirm(options: any): TsMessageProm | undefined;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
/**
|
|
1949
|
+
* Part of TsUi 2.0 library
|
|
1950
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsTabs, TsToolbar, TsTooltip, TsField
|
|
1951
|
+
*
|
|
1952
|
+
* T4.2: Ported to TypeScript with aggressive typing per typing_policy.
|
|
1953
|
+
* No @ts-nocheck. Targeted `any` sites documented with // any: comments.
|
|
1954
|
+
* Bug fix: line 1317 (original) `?? response.statusText` was unreachable
|
|
1955
|
+
* because string concat always produces non-null; fixed to `|| response.statusText`.
|
|
1956
|
+
*
|
|
1957
|
+
* == TODO ==
|
|
1958
|
+
* - include delta on save
|
|
1959
|
+
* - tabs below some fields (could already be implemented)
|
|
1960
|
+
* - form with toolbar & tabs
|
|
1961
|
+
* - promise for load, save, etc.
|
|
1962
|
+
*
|
|
1963
|
+
* == 2.0 changes
|
|
1964
|
+
* - CSP - fixed inline events
|
|
1965
|
+
* - removed jQuery dependency
|
|
1966
|
+
* - better groups support tabs now
|
|
1967
|
+
* - form.confirm - refactored
|
|
1968
|
+
* - form.message - refactored
|
|
1969
|
+
* - observeResize for the box
|
|
1970
|
+
* - removed msgNotJSON, msgAJAXerror
|
|
1971
|
+
* - applyFocus -> setFocus
|
|
1972
|
+
* - getFieldValue(fieldName) = returns { curent, previous, original }
|
|
1973
|
+
* - setFieldVallue(fieldName, value)
|
|
1974
|
+
* - getValue(..., original) -- return original if any
|
|
1975
|
+
* - added .hideErrors()
|
|
1976
|
+
* - reuqest, save, submit - return promises
|
|
1977
|
+
* - this.recid = null if no record needs to be pulled
|
|
1978
|
+
* - remove form.multiplart
|
|
1979
|
+
* - this.method - for saving only
|
|
1980
|
+
* - added field.html.class
|
|
1981
|
+
* - setValue(..., noRefresh)
|
|
1982
|
+
* - rememberOriginal()
|
|
1983
|
+
* - saveCleanRecord
|
|
1984
|
+
* - added options.itemMap = { id: 'id', text: 'text' } - to map id, text fields if needed
|
|
1985
|
+
* - hideGroup/showGroup - new methods
|
|
1986
|
+
* - getAction/actionHide/actionShow/actionDisable/actionEnable - new methods
|
|
1987
|
+
*/
|
|
1988
|
+
|
|
1989
|
+
declare class TsForm extends TsBase {
|
|
1990
|
+
[key: string]: any;
|
|
1991
|
+
name: string;
|
|
1992
|
+
header: string;
|
|
1993
|
+
box: HTMLElement | null;
|
|
1994
|
+
url: string | {
|
|
1995
|
+
get?: string;
|
|
1996
|
+
save?: string;
|
|
1997
|
+
};
|
|
1998
|
+
method: string | null;
|
|
1999
|
+
routeData: Record<string, any>;
|
|
2000
|
+
formURL: string;
|
|
2001
|
+
formHTML: string;
|
|
2002
|
+
page: number;
|
|
2003
|
+
pageStyle: string;
|
|
2004
|
+
recid: any;
|
|
2005
|
+
fields: any[];
|
|
2006
|
+
actions: Record<string, any>;
|
|
2007
|
+
record: Record<string, any>;
|
|
2008
|
+
original: Record<string, any> | null;
|
|
2009
|
+
dataType: string | null;
|
|
2010
|
+
saveCleanRecord: boolean;
|
|
2011
|
+
postData: Record<string, any>;
|
|
2012
|
+
httpHeaders: Record<string, string>;
|
|
2013
|
+
toolbar: any;
|
|
2014
|
+
tabs: any;
|
|
2015
|
+
style: string;
|
|
2016
|
+
focus: number | string;
|
|
2017
|
+
autosize: boolean;
|
|
2018
|
+
nestedFields: boolean;
|
|
2019
|
+
tabindexBase: number;
|
|
2020
|
+
isGenerated: boolean;
|
|
2021
|
+
last: {
|
|
2022
|
+
fetchCtrl: AbortController | null;
|
|
2023
|
+
fetchOptions: RequestInit | null;
|
|
2024
|
+
errors: any[];
|
|
2025
|
+
errorsShown?: boolean;
|
|
2026
|
+
observeResize?: ResizeObserver;
|
|
2027
|
+
};
|
|
2028
|
+
onRequest: ((event: CustomEvent) => void) | null;
|
|
2029
|
+
onLoad: ((event: CustomEvent) => void) | null;
|
|
2030
|
+
onValidate: ((event: CustomEvent) => void) | null;
|
|
2031
|
+
onSubmit: ((event: CustomEvent) => void) | null;
|
|
2032
|
+
onProgress: ((event: CustomEvent) => void) | null;
|
|
2033
|
+
onSave: ((event: CustomEvent) => void) | null;
|
|
2034
|
+
onChange: ((event: CustomEvent) => void) | null;
|
|
2035
|
+
onInput: ((event: CustomEvent) => void) | null;
|
|
2036
|
+
onRender: ((event: CustomEvent) => void) | null;
|
|
2037
|
+
onRefresh: ((event: CustomEvent) => void) | null;
|
|
2038
|
+
onResize: ((event: CustomEvent) => void) | null;
|
|
2039
|
+
onDestroy: ((event: CustomEvent) => void) | null;
|
|
2040
|
+
onAction: ((event: CustomEvent) => void) | null;
|
|
2041
|
+
onToolbar: ((event: CustomEvent) => void) | null;
|
|
2042
|
+
onError: ((event: CustomEvent) => void) | null;
|
|
2043
|
+
msgRefresh: string;
|
|
2044
|
+
msgSaving: string;
|
|
2045
|
+
msgServerError: string;
|
|
2046
|
+
ALL_TYPES: string[];
|
|
2047
|
+
LIST_TYPES: string[];
|
|
2048
|
+
TsFIELD_TYPES: string[];
|
|
2049
|
+
constructor(options: Record<string, any>);
|
|
2050
|
+
get(field?: string, returnIndex?: boolean): any;
|
|
2051
|
+
set(field: string, obj: Record<string, any>): boolean;
|
|
2052
|
+
getValue(field: string, original?: boolean): any;
|
|
2053
|
+
setValue(field: string, value: any, noRefresh?: boolean): boolean;
|
|
2054
|
+
rememberOriginal(): void;
|
|
2055
|
+
getFieldValue(name: string): {
|
|
2056
|
+
current: any;
|
|
2057
|
+
previous: any;
|
|
2058
|
+
original: any;
|
|
2059
|
+
} | undefined;
|
|
2060
|
+
findItem(item: any, items: any[]): any;
|
|
2061
|
+
setFieldValue(name: string, value: any): void;
|
|
2062
|
+
show(...args: string[]): string[];
|
|
2063
|
+
hide(...args: string[]): string[];
|
|
2064
|
+
enable(...args: string[]): string[];
|
|
2065
|
+
disable(...args: string[]): string[];
|
|
2066
|
+
updateEmptyGroups(): void;
|
|
2067
|
+
hideGroup(groupName: string): void;
|
|
2068
|
+
showGroup(groupName: string): void;
|
|
2069
|
+
/**
|
|
2070
|
+
* When user clicks on group title, it will toggle the group (collapse or expand it).
|
|
2071
|
+
*/
|
|
2072
|
+
toggleGroup(groupName: string, show?: boolean): void;
|
|
2073
|
+
change(...args: string[]): void;
|
|
2074
|
+
reload(callBack?: (() => void)): Promise<any>;
|
|
2075
|
+
clear(...args: any[]): void;
|
|
2076
|
+
error(msg: string): void;
|
|
2077
|
+
message(options: any): any;
|
|
2078
|
+
confirm(options: any): any;
|
|
2079
|
+
validate(showErrors?: boolean): any[] | undefined;
|
|
2080
|
+
showErrors(): void;
|
|
2081
|
+
hideErrors(): void;
|
|
2082
|
+
getChanges(): Record<string, any> | null;
|
|
2083
|
+
getCleanRecord(strict?: boolean): Record<string, any>;
|
|
2084
|
+
request(postData?: any, callBack?: (data: any) => void): Promise<any> | void;
|
|
2085
|
+
submit(postData?: any, callBack?: (data: any) => void): Promise<any> | void;
|
|
2086
|
+
save(postData?: any, callBack?: (data: any) => void): Promise<any> | void;
|
|
2087
|
+
lock(msg: string, showSpinner?: boolean): void;
|
|
2088
|
+
unlock(speed?: number): void;
|
|
2089
|
+
lockPage(page: number, msg?: string, spinner?: boolean): boolean;
|
|
2090
|
+
unlockPage(page: number, speed?: number): boolean;
|
|
2091
|
+
goto(page: number): void;
|
|
2092
|
+
generateHTML(): string | false;
|
|
2093
|
+
action(action: string, event: Event): void;
|
|
2094
|
+
getAction(action: string): any;
|
|
2095
|
+
actionHide(action: string): void;
|
|
2096
|
+
actionShow(action: string): void;
|
|
2097
|
+
actionDisable(action: string): void;
|
|
2098
|
+
actionEnable(action: string): void;
|
|
2099
|
+
resize(): void;
|
|
2100
|
+
refresh(...args: any[]): number;
|
|
2101
|
+
render(box?: HTMLElement | string): number | void;
|
|
2102
|
+
unmount(): void;
|
|
2103
|
+
destroy(): void;
|
|
2104
|
+
setFocus(focus?: number | string): any;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
/**
|
|
2108
|
+
* Part of TsUi 2.0 library
|
|
2109
|
+
* - Dependencies: mQuery, TsUtils, TsBase, TsTooltip, TsColor, TsMenu, TsDate
|
|
2110
|
+
*
|
|
2111
|
+
* T4.1: Ported to TypeScript with aggressive typing per typing_policy.
|
|
2112
|
+
* No @ts-nocheck. Targeted `any` sites documented with // any: comments.
|
|
2113
|
+
* Discriminated union on `type` property for per-type option shapes.
|
|
2114
|
+
*
|
|
2115
|
+
* == TODO ==
|
|
2116
|
+
* - upload (regular files)
|
|
2117
|
+
* - BUG with prefix/postfix and arrows (test in different contexts)
|
|
2118
|
+
* - multiple date selection
|
|
2119
|
+
* - month selection, year selections
|
|
2120
|
+
* - MultiSelect - Allow Copy/Paste for single and multi values
|
|
2121
|
+
* - add routeData to list/enum
|
|
2122
|
+
* - ENUM, LIST: should have same as grid (limit, offset, search, sort)
|
|
2123
|
+
* - ENUM, LIST: should support wild chars
|
|
2124
|
+
* - add selection of predefined times (used for appointments)
|
|
2125
|
+
* - options.items - can be an array
|
|
2126
|
+
* - options.msgNoItems - can be a function
|
|
2127
|
+
* - REMOTE fields
|
|
2128
|
+
*
|
|
2129
|
+
* == 2.0 changes
|
|
2130
|
+
* - removed jQuery dependency
|
|
2131
|
+
* - enum options.autoAdd
|
|
2132
|
+
* - [numeric, date] - options.autoCorrect to enforce range and validity
|
|
2133
|
+
* - remote source response items => records or just an array
|
|
2134
|
+
* - deprecated "success" field for remote source response
|
|
2135
|
+
* - CSP - fixed inline events
|
|
2136
|
+
* - remove clear, use reset instead
|
|
2137
|
+
* - options.msgSearch
|
|
2138
|
+
* - options.msgNoItems
|
|
2139
|
+
*/
|
|
2140
|
+
|
|
2141
|
+
/** Shared numeric-field options (int, float, money, currency, percent, alphanumeric, bin, hex, text) */
|
|
2142
|
+
interface TsFieldNumericOptions {
|
|
2143
|
+
type?: string;
|
|
2144
|
+
min?: number | null;
|
|
2145
|
+
max?: number | null;
|
|
2146
|
+
step?: number;
|
|
2147
|
+
autoFormat?: boolean;
|
|
2148
|
+
autoCorrect?: boolean;
|
|
2149
|
+
currency?: {
|
|
2150
|
+
prefix: string;
|
|
2151
|
+
suffix: string;
|
|
2152
|
+
precision: number;
|
|
2153
|
+
};
|
|
2154
|
+
decimalSymbol?: string;
|
|
2155
|
+
groupSymbol?: string;
|
|
2156
|
+
arrows?: boolean;
|
|
2157
|
+
keyboard?: boolean;
|
|
2158
|
+
precision?: number | null;
|
|
2159
|
+
prefix?: string;
|
|
2160
|
+
suffix?: string;
|
|
2161
|
+
numberRE?: RegExp;
|
|
2162
|
+
moneyRE?: RegExp;
|
|
2163
|
+
percentRE?: RegExp;
|
|
2164
|
+
[key: string]: any;
|
|
2165
|
+
}
|
|
2166
|
+
/** Color-field options */
|
|
2167
|
+
interface TsFieldColorOptions {
|
|
2168
|
+
type?: string;
|
|
2169
|
+
prefix?: string;
|
|
2170
|
+
suffix?: string;
|
|
2171
|
+
arrows?: boolean;
|
|
2172
|
+
advanced?: boolean | null;
|
|
2173
|
+
transparent?: boolean;
|
|
2174
|
+
[key: string]: any;
|
|
2175
|
+
}
|
|
2176
|
+
/** Date-field options */
|
|
2177
|
+
interface TsFieldDateOptions {
|
|
2178
|
+
type?: string;
|
|
2179
|
+
format?: string;
|
|
2180
|
+
keyboard?: boolean;
|
|
2181
|
+
autoCorrect?: boolean;
|
|
2182
|
+
start?: string | null;
|
|
2183
|
+
end?: string | null;
|
|
2184
|
+
blockDates?: string[];
|
|
2185
|
+
blockWeekdays?: number[];
|
|
2186
|
+
colored?: Record<string, string>;
|
|
2187
|
+
btnNow?: boolean;
|
|
2188
|
+
[key: string]: any;
|
|
2189
|
+
}
|
|
2190
|
+
/** Time-field options */
|
|
2191
|
+
interface TsFieldTimeOptions {
|
|
2192
|
+
type?: string;
|
|
2193
|
+
format?: string;
|
|
2194
|
+
keyboard?: boolean;
|
|
2195
|
+
autoCorrect?: boolean;
|
|
2196
|
+
start?: string | null;
|
|
2197
|
+
end?: string | null;
|
|
2198
|
+
btnNow?: boolean;
|
|
2199
|
+
noMinutes?: boolean;
|
|
2200
|
+
[key: string]: any;
|
|
2201
|
+
}
|
|
2202
|
+
/** DateTime-field options */
|
|
2203
|
+
interface TsFieldDateTimeOptions {
|
|
2204
|
+
type?: string;
|
|
2205
|
+
format?: string;
|
|
2206
|
+
keyboard?: boolean;
|
|
2207
|
+
autoCorrect?: boolean;
|
|
2208
|
+
start?: string | null;
|
|
2209
|
+
end?: string | null;
|
|
2210
|
+
startTime?: string | null;
|
|
2211
|
+
endTime?: string | null;
|
|
2212
|
+
blockDates?: string[];
|
|
2213
|
+
blockWeekdays?: number[];
|
|
2214
|
+
colored?: Record<string, string>;
|
|
2215
|
+
btnNow?: boolean;
|
|
2216
|
+
noMinutes?: boolean;
|
|
2217
|
+
[key: string]: any;
|
|
2218
|
+
}
|
|
2219
|
+
/** List/combo-field options */
|
|
2220
|
+
interface TsFieldListOptions {
|
|
2221
|
+
type?: string;
|
|
2222
|
+
items?: any[];
|
|
2223
|
+
_items_fun?: ((...args: any[]) => any) | null;
|
|
2224
|
+
selected?: Record<string, any> | null;
|
|
2225
|
+
itemMap?: {
|
|
2226
|
+
id: string;
|
|
2227
|
+
text: string;
|
|
2228
|
+
} | null;
|
|
2229
|
+
match?: 'contains' | 'is' | 'begins' | 'ends';
|
|
2230
|
+
filter?: boolean;
|
|
2231
|
+
compare?: ((...args: any[]) => any) | null;
|
|
2232
|
+
prefix?: string;
|
|
2233
|
+
suffix?: string;
|
|
2234
|
+
icon?: string | null;
|
|
2235
|
+
iconStyle?: string;
|
|
2236
|
+
url?: string | null;
|
|
2237
|
+
method?: string | null;
|
|
2238
|
+
postData?: Record<string, unknown>;
|
|
2239
|
+
recId?: string | ((item: any) => any) | null;
|
|
2240
|
+
recText?: string | ((item: any) => any) | null;
|
|
2241
|
+
debounce?: number;
|
|
2242
|
+
minLength?: number;
|
|
2243
|
+
cacheMax?: number;
|
|
2244
|
+
renderDrop?: ((...args: any[]) => string) | null;
|
|
2245
|
+
maxDropHeight?: number;
|
|
2246
|
+
maxDropWidth?: number | null;
|
|
2247
|
+
minDropWidth?: number | null;
|
|
2248
|
+
markSearch?: boolean;
|
|
2249
|
+
align?: 'left' | 'right' | 'both' | 'none';
|
|
2250
|
+
altRows?: boolean;
|
|
2251
|
+
openOnFocus?: boolean;
|
|
2252
|
+
hideSelected?: boolean;
|
|
2253
|
+
msgNoItems?: string;
|
|
2254
|
+
msgSearch?: string;
|
|
2255
|
+
onSearch?: ((...args: any[]) => void) | null;
|
|
2256
|
+
onRequest?: ((...args: any[]) => void) | null;
|
|
2257
|
+
onLoad?: ((...args: any[]) => void) | null;
|
|
2258
|
+
onError?: ((...args: any[]) => void) | null;
|
|
2259
|
+
index?: number[];
|
|
2260
|
+
[key: string]: any;
|
|
2261
|
+
}
|
|
2262
|
+
/** Enum-field options */
|
|
2263
|
+
interface TsFieldEnumOptions {
|
|
2264
|
+
type?: string;
|
|
2265
|
+
items?: any[];
|
|
2266
|
+
_items_fun?: ((...args: any[]) => any) | null;
|
|
2267
|
+
selected?: any[];
|
|
2268
|
+
itemMap?: {
|
|
2269
|
+
id: string;
|
|
2270
|
+
text: string;
|
|
2271
|
+
} | null;
|
|
2272
|
+
max?: number;
|
|
2273
|
+
match?: 'contains' | 'is' | 'begins' | 'ends';
|
|
2274
|
+
filter?: boolean;
|
|
2275
|
+
compare?: ((...args: any[]) => any) | null;
|
|
2276
|
+
url?: string | null;
|
|
2277
|
+
method?: string | null;
|
|
2278
|
+
postData?: Record<string, unknown>;
|
|
2279
|
+
recId?: string | ((item: any) => any) | null;
|
|
2280
|
+
recText?: string | ((item: any) => any) | null;
|
|
2281
|
+
debounce?: number;
|
|
2282
|
+
minLength?: number;
|
|
2283
|
+
cacheMax?: number;
|
|
2284
|
+
maxItemWidth?: number;
|
|
2285
|
+
maxDropHeight?: number;
|
|
2286
|
+
maxDropWidth?: number | null;
|
|
2287
|
+
renderItem?: ((item: any, ind: number, removeBtn: string) => string) | null;
|
|
2288
|
+
renderDrop?: ((...args: any[]) => string) | null;
|
|
2289
|
+
style?: string;
|
|
2290
|
+
openOnFocus?: boolean;
|
|
2291
|
+
markSearch?: boolean;
|
|
2292
|
+
align?: 'left' | 'right' | 'both' | 'none';
|
|
2293
|
+
altRows?: boolean;
|
|
2294
|
+
hideSelected?: boolean;
|
|
2295
|
+
msgNoItems?: string;
|
|
2296
|
+
msgSearch?: string;
|
|
2297
|
+
onAdd?: ((...args: any[]) => void) | null;
|
|
2298
|
+
onNew?: ((...args: any[]) => void) | null;
|
|
2299
|
+
onRemove?: ((...args: any[]) => void) | null;
|
|
2300
|
+
onSearch?: ((...args: any[]) => void) | null;
|
|
2301
|
+
onClick?: ((...args: any[]) => void) | null;
|
|
2302
|
+
onRequest?: ((...args: any[]) => void) | null;
|
|
2303
|
+
onLoad?: ((...args: any[]) => void) | null;
|
|
2304
|
+
onError?: ((...args: any[]) => void) | null;
|
|
2305
|
+
onScroll?: ((...args: any[]) => void) | null;
|
|
2306
|
+
onMouseEnter?: ((...args: any[]) => void) | null;
|
|
2307
|
+
onMouseLeave?: ((...args: any[]) => void) | null;
|
|
2308
|
+
[key: string]: any;
|
|
2309
|
+
}
|
|
2310
|
+
/** File-field options */
|
|
2311
|
+
interface TsFieldFileOptions {
|
|
2312
|
+
type?: string;
|
|
2313
|
+
selected?: any[];
|
|
2314
|
+
max?: number;
|
|
2315
|
+
maxSize?: number;
|
|
2316
|
+
maxFileSize?: number;
|
|
2317
|
+
renderItem?: ((item: any, ind: number, removeBtn: string) => string) | null;
|
|
2318
|
+
maxItemWidth?: number;
|
|
2319
|
+
maxDropHeight?: number;
|
|
2320
|
+
maxDropWidth?: number | null;
|
|
2321
|
+
readContent?: boolean;
|
|
2322
|
+
showErrors?: boolean;
|
|
2323
|
+
align?: 'left' | 'right' | 'both' | 'none';
|
|
2324
|
+
altRows?: boolean;
|
|
2325
|
+
style?: string;
|
|
2326
|
+
onClick?: ((...args: any[]) => void) | null;
|
|
2327
|
+
onAdd?: ((...args: any[]) => void) | null;
|
|
2328
|
+
onRemove?: ((...args: any[]) => void) | null;
|
|
2329
|
+
onMouseEnter?: ((...args: any[]) => void) | null;
|
|
2330
|
+
onMouseLeave?: ((...args: any[]) => void) | null;
|
|
2331
|
+
[key: string]: any;
|
|
2332
|
+
}
|
|
2333
|
+
/** Discriminated union: all possible options for a TsField instance */
|
|
2334
|
+
type TsFieldOptions = TsFieldNumericOptions | TsFieldColorOptions | TsFieldDateOptions | TsFieldTimeOptions | TsFieldDateTimeOptions | TsFieldListOptions | TsFieldEnumOptions | TsFieldFileOptions;
|
|
2335
|
+
/** Constructor input — the type discriminant lives here */
|
|
2336
|
+
interface TsFieldInput {
|
|
2337
|
+
type?: string;
|
|
2338
|
+
el?: HTMLElement | null;
|
|
2339
|
+
onClick?: ((...args: any[]) => void) | null;
|
|
2340
|
+
onAdd?: ((...args: any[]) => void) | null;
|
|
2341
|
+
onNew?: ((...args: any[]) => void) | null;
|
|
2342
|
+
onRemove?: ((...args: any[]) => void) | null;
|
|
2343
|
+
onMouseEnter?: ((...args: any[]) => void) | null;
|
|
2344
|
+
onMouseLeave?: ((...args: any[]) => void) | null;
|
|
2345
|
+
onScroll?: ((...args: any[]) => void) | null;
|
|
2346
|
+
[key: string]: any;
|
|
2347
|
+
}
|
|
2348
|
+
/** Helper elements bag */
|
|
2349
|
+
interface TsFieldHelpers {
|
|
2350
|
+
prefix?: HTMLElement | null;
|
|
2351
|
+
suffix?: HTMLElement | null;
|
|
2352
|
+
arrows?: HTMLElement | null;
|
|
2353
|
+
search?: HTMLElement | null;
|
|
2354
|
+
search_focus?: HTMLInputElement;
|
|
2355
|
+
multi?: Query;
|
|
2356
|
+
[key: string]: any;
|
|
2357
|
+
}
|
|
2358
|
+
/** Temp state bag */
|
|
2359
|
+
interface TsFieldTmp {
|
|
2360
|
+
'old-padding-left'?: string | null;
|
|
2361
|
+
'old-padding-right'?: string | null;
|
|
2362
|
+
'old-background-color'?: string;
|
|
2363
|
+
'old-border-color'?: string;
|
|
2364
|
+
'old-tabIndex'?: number;
|
|
2365
|
+
'min-height'?: number;
|
|
2366
|
+
'max-height'?: number;
|
|
2367
|
+
'current_width'?: number;
|
|
2368
|
+
pholder?: string;
|
|
2369
|
+
overlay?: any;
|
|
2370
|
+
openedOnFocus?: boolean;
|
|
2371
|
+
sizeTimer?: ReturnType<typeof setInterval>;
|
|
2372
|
+
[key: string]: any;
|
|
2373
|
+
}
|
|
2374
|
+
declare global {
|
|
2375
|
+
interface HTMLElement {
|
|
2376
|
+
_w2field?: TsField;
|
|
2377
|
+
}
|
|
2378
|
+
interface HTMLInputElement {
|
|
2379
|
+
_w2field?: TsField;
|
|
2380
|
+
}
|
|
2381
|
+
interface HTMLTextAreaElement {
|
|
2382
|
+
_w2field?: TsField;
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
type TsFieldElement = HTMLInputElement | HTMLTextAreaElement;
|
|
2386
|
+
declare class TsField extends TsBase {
|
|
2387
|
+
el: TsFieldElement | null;
|
|
2388
|
+
selected: any;
|
|
2389
|
+
helpers: TsFieldHelpers;
|
|
2390
|
+
type: string;
|
|
2391
|
+
options: TsFieldOptions;
|
|
2392
|
+
onClick: ((...args: any[]) => void) | null;
|
|
2393
|
+
onAdd: ((...args: any[]) => void) | null;
|
|
2394
|
+
onNew: ((...args: any[]) => void) | null;
|
|
2395
|
+
onRemove: ((...args: any[]) => void) | null;
|
|
2396
|
+
onMouseEnter: ((...args: any[]) => void) | null;
|
|
2397
|
+
onMouseLeave: ((...args: any[]) => void) | null;
|
|
2398
|
+
onScroll: ((...args: any[]) => void) | null;
|
|
2399
|
+
tmp: TsFieldTmp;
|
|
2400
|
+
constructor(type: string | TsFieldInput, options?: TsFieldInput);
|
|
2401
|
+
render(el: HTMLElement): void;
|
|
2402
|
+
init(): void;
|
|
2403
|
+
get(): any;
|
|
2404
|
+
set(val: any, append?: boolean): void;
|
|
2405
|
+
setIndex(ind: number, append?: boolean): boolean;
|
|
2406
|
+
refresh(): number;
|
|
2407
|
+
resize(): void;
|
|
2408
|
+
reset(): void;
|
|
2409
|
+
clean(val: any): any;
|
|
2410
|
+
format(val: any): any;
|
|
2411
|
+
change(event: Event): false | void;
|
|
2412
|
+
click(event: MouseEvent): void;
|
|
2413
|
+
focus(event: FocusEvent & {
|
|
2414
|
+
showMenu?: boolean;
|
|
2415
|
+
}): void;
|
|
2416
|
+
blur(_event: FocusEvent): void;
|
|
2417
|
+
keyDown(event: KeyboardEvent, extra?: {
|
|
2418
|
+
keyCode?: number;
|
|
2419
|
+
}): false | void;
|
|
2420
|
+
keyUp(event: KeyboardEvent): void;
|
|
2421
|
+
findItemIndex(items: any[], id: any, parents?: number[]): number[];
|
|
2422
|
+
updateOverlay(_indexOnly?: boolean): void;
|
|
2423
|
+
isStrValid(ch: string, loose?: boolean): boolean;
|
|
2424
|
+
addPrefix(): void;
|
|
2425
|
+
addSuffix(): void;
|
|
2426
|
+
addSearch(): void;
|
|
2427
|
+
addMultiSearch(): void;
|
|
2428
|
+
addFile(file: File): void;
|
|
2429
|
+
moveCaret2end(): void;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
export { Tooltip, TsAlert, TsBase, TsColor, TsConfirm, TsDate, TsDialog, TsEvent, TsField, TsForm, TsGrid, TsLayout, TsLocale, TsMenu, TsPopup, TsPrompt, TsSidebar, TsTabs, TsToolbar, TsTooltip, TsUi, TsUtils, query };
|