@netless/telebox-insider 0.2.29 → 0.2.30

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/dist/index.d.ts CHANGED
@@ -1,6 +1,837 @@
1
- import "./scss/fancy-scrollbar.scss";
2
- export * from "./TeleBox";
3
- export * from "./TeleTitleBar";
4
- export * from "./TeleBoxReact";
5
- export * from "./TeleBoxManager";
6
- export * from "./TeleBoxCollector";
1
+ declare type SideEffectDisposer = () => void;
2
+ declare class SideEffectManager {
3
+ /**
4
+ * Add a side effect.
5
+ * @param executor execute side effect
6
+ * @param disposerID Optional id for the disposer
7
+ * @returns disposerID
8
+ */
9
+ add(executor: () => SideEffectDisposer, disposerID?: string): string;
10
+ /**
11
+ * Add a disposer directly.
12
+ * @param disposer a disposer
13
+ * @param disposerID Optional id for the disposer
14
+ * @returns disposerID
15
+ */
16
+ addDisposer(disposer: SideEffectDisposer, disposerID?: string): string;
17
+ /**
18
+ * Sugar for addEventListener.
19
+ * @param el
20
+ * @param type
21
+ * @param listener
22
+ * @param options
23
+ * @param disposerID Optional id for the disposer
24
+ * @returns disposerID
25
+ */
26
+ addEventListener<K extends keyof WindowEventMap>(el: Window, type: K, listener: (this: Window, ev: WindowEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions, disposerID?: string): string;
27
+ addEventListener<K extends keyof DocumentEventMap>(el: Document, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions, disposerID?: string): string;
28
+ addEventListener<K extends keyof HTMLElementEventMap>(el: HTMLElement, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions, disposerID?: string): string;
29
+ /**
30
+ * Sugar for setTimeout.
31
+ * @param handler
32
+ * @param timeout
33
+ * @param disposerID Optional id for the disposer
34
+ * @returns disposerID
35
+ */
36
+ setTimeout(handler: () => void, timeout: number, disposerID?: string): string;
37
+ /**
38
+ * Sugar for setInterval.
39
+ * @param handler
40
+ * @param timeout
41
+ * @param disposerID Optional id for the disposer
42
+ * @returns disposerID
43
+ */
44
+ setInterval(handler: () => void, timeout: number, disposerID?: string): string;
45
+ /**
46
+ * Remove but not run the disposer. Do nothing if not found.
47
+ * @param disposerID
48
+ */
49
+ remove(disposerID: string): SideEffectDisposer | undefined;
50
+ /**
51
+ * Remove and run the disposer. Do nothing if not found.
52
+ * @param disposerID
53
+ */
54
+ flush(disposerID: string): void;
55
+ /**
56
+ * Remove and run all of the disposers.
57
+ */
58
+ flushAll(): void;
59
+ /**
60
+ * All disposers. Use this only when you know what you are doing.
61
+ */
62
+ readonly disposers: Map<string, SideEffectDisposer>;
63
+ }
64
+
65
+ declare type ValCompare<TValue = any> = (newValue: TValue, oldValue: TValue) => boolean;
66
+ declare type ValReactionSubscriber<TValue = any, TMeta = any> = (newValue: TValue, oldValue: TValue, meta?: TMeta) => void;
67
+ declare type ValSubscriber<TValue = any, TMeta = any> = (newValue: TValue, oldValue: TValue | undefined, meta?: TMeta) => void;
68
+ declare type ValTransform<TValue = any, TDerivedValue = any, TMeta = any> = (newValue: TValue, oldValue: TValue | undefined, meta?: TMeta) => TDerivedValue;
69
+ declare type ValDisposer = () => void;
70
+
71
+ declare class Val<TValue = any, TMeta = any> {
72
+ protected _value: TValue;
73
+ constructor(value: TValue, compare?: ValCompare<TValue>);
74
+ get value(): TValue;
75
+ setValue(value: TValue, meta?: TMeta): void;
76
+ /**
77
+ * Subscribe to value changes without immediate emission.
78
+ */
79
+ reaction(subscriber: ValReactionSubscriber<TValue, TMeta>): ValDisposer;
80
+ /**
81
+ * Subscribe to value changes with immediate emission.
82
+ * @param subscriber
83
+ * @param meta Meta for the immediate emission
84
+ */
85
+ subscribe(subscriber: ValSubscriber<TValue, TMeta>, meta?: TMeta): ValDisposer;
86
+ derive<TDerivedValue = any>(transform: ValTransform<TValue, TDerivedValue, TMeta>, compare?: ValCompare<TDerivedValue>, meta?: TMeta): Val<TDerivedValue, TMeta>;
87
+ destroy(): void;
88
+ /**
89
+ * Add a callback which will be run before destroy
90
+ * @param beforeDestroy
91
+ * @returns Cancel the callback
92
+ */
93
+ addBeforeDestroy(beforeDestroy: () => void): ValDisposer;
94
+ /**
95
+ * Compare two values. Default `===`.
96
+ */
97
+ compare(newValue: TValue, oldValue: TValue): boolean;
98
+ protected _beforeDestroys?: Set<() => void>;
99
+ protected _subscribers?: Set<ValSubscriber<TValue, TMeta> | ValReactionSubscriber<TValue, TMeta>>;
100
+ }
101
+
102
+ declare type TValInputsValueTuple<TValInputs extends readonly Val[]> = Readonly<{
103
+ [K in keyof TValInputs]: ExtractValValue<TValInputs[K]>;
104
+ }>;
105
+ declare type ExtractValValue<TVal> = TVal extends Val<infer TValue, any> ? TValue : never;
106
+ declare type ExtractValMeta<TVal> = TVal extends Val<any, infer TMeta> ? TMeta : never;
107
+ declare type CombineValTransform<TDerivedValue = any, TValues extends readonly any[] = any[], TMeta = any> = (newValues: TValues, oldValues?: TValues, meta?: TMeta) => TDerivedValue;
108
+ declare type Combine = <TDerivedValue = any, TValInputs extends readonly Val[] = Val[], TMeta = ExtractValMeta<TValInputs[number]>>(valInputs: readonly [...TValInputs], transform: CombineValTransform<TDerivedValue, [
109
+ ...TValInputsValueTuple<TValInputs>
110
+ ], TMeta>, compare?: ValCompare<TDerivedValue>, meta?: TMeta) => Val<TDerivedValue, TMeta>;
111
+
112
+ declare type IntersectionFromUnion<TUnion> = (TUnion extends any ? (arg: TUnion) => void : never) extends (arg: infer TArg) => void ? TArg : never;
113
+ declare type ExtractValKeys<TInstance, TKey = keyof TInstance> = TKey extends Extract<keyof TInstance, string> ? TInstance[TKey] extends Val ? TKey : never : never;
114
+ declare type ValEnhancer<TVal, TKey extends string> = Readonly<Record<TKey, ExtractValValue<TVal>> & Record<`_${TKey}$`, TVal> & Record<`set${Capitalize<TKey>}`, (value: ExtractValValue<TVal>, meta?: ExtractValMeta<TVal>) => void>>;
115
+ declare type ToValUnion<TConfig, TKey = ExtractValKeys<TConfig>> = TKey extends ExtractValKeys<TConfig> ? ValEnhancer<TConfig[TKey], TKey> : never;
116
+ declare type ValEnhancedResult<TConfig> = IntersectionFromUnion<ToValUnion<TConfig>>;
117
+
118
+ declare type BindSideEffect = <TVal extends Val>(val: TVal) => TVal;
119
+ declare type CreateVal = <TValue = any, TMeta = any>(value: TValue, compare?: ValCompare<TValue>) => Val<TValue, TMeta>;
120
+ declare type ValSideEffectBinder = {
121
+ bindSideEffect: BindSideEffect;
122
+ combine: Combine;
123
+ createVal: CreateVal;
124
+ };
125
+
126
+ /**
127
+ * Minimal `EventEmitter` interface that is molded against the Node.js
128
+ * `EventEmitter` interface.
129
+ */
130
+ declare class EventEmitter<
131
+ EventTypes extends EventEmitter.ValidEventTypes = string | symbol,
132
+ Context extends any = any
133
+ > {
134
+ static prefixed: string | boolean;
135
+
136
+ /**
137
+ * Return an array listing the events for which the emitter has registered
138
+ * listeners.
139
+ */
140
+ eventNames(): Array<EventEmitter.EventNames<EventTypes>>;
141
+
142
+ /**
143
+ * Return the listeners registered for a given event.
144
+ */
145
+ listeners<T extends EventEmitter.EventNames<EventTypes>>(
146
+ event: T
147
+ ): Array<EventEmitter.EventListener<EventTypes, T>>;
148
+
149
+ /**
150
+ * Return the number of listeners listening to a given event.
151
+ */
152
+ listenerCount(event: EventEmitter.EventNames<EventTypes>): number;
153
+
154
+ /**
155
+ * Calls each of the listeners registered for a given event.
156
+ */
157
+ emit<T extends EventEmitter.EventNames<EventTypes>>(
158
+ event: T,
159
+ ...args: EventEmitter.EventArgs<EventTypes, T>
160
+ ): boolean;
161
+
162
+ /**
163
+ * Add a listener for a given event.
164
+ */
165
+ on<T extends EventEmitter.EventNames<EventTypes>>(
166
+ event: T,
167
+ fn: EventEmitter.EventListener<EventTypes, T>,
168
+ context?: Context
169
+ ): this;
170
+ addListener<T extends EventEmitter.EventNames<EventTypes>>(
171
+ event: T,
172
+ fn: EventEmitter.EventListener<EventTypes, T>,
173
+ context?: Context
174
+ ): this;
175
+
176
+ /**
177
+ * Add a one-time listener for a given event.
178
+ */
179
+ once<T extends EventEmitter.EventNames<EventTypes>>(
180
+ event: T,
181
+ fn: EventEmitter.EventListener<EventTypes, T>,
182
+ context?: Context
183
+ ): this;
184
+
185
+ /**
186
+ * Remove the listeners of a given event.
187
+ */
188
+ removeListener<T extends EventEmitter.EventNames<EventTypes>>(
189
+ event: T,
190
+ fn?: EventEmitter.EventListener<EventTypes, T>,
191
+ context?: Context,
192
+ once?: boolean
193
+ ): this;
194
+ off<T extends EventEmitter.EventNames<EventTypes>>(
195
+ event: T,
196
+ fn?: EventEmitter.EventListener<EventTypes, T>,
197
+ context?: Context,
198
+ once?: boolean
199
+ ): this;
200
+
201
+ /**
202
+ * Remove all listeners, or those of the specified event.
203
+ */
204
+ removeAllListeners(event?: EventEmitter.EventNames<EventTypes>): this;
205
+ }
206
+
207
+ declare namespace EventEmitter {
208
+ export interface ListenerFn<Args extends any[] = any[]> {
209
+ (...args: Args): void;
210
+ }
211
+
212
+ export interface EventEmitterStatic {
213
+ new <
214
+ EventTypes extends ValidEventTypes = string | symbol,
215
+ Context = any
216
+ >(): EventEmitter<EventTypes, Context>;
217
+ }
218
+
219
+ /**
220
+ * `object` should be in either of the following forms:
221
+ * ```
222
+ * interface EventTypes {
223
+ * 'event-with-parameters': any[]
224
+ * 'event-with-example-handler': (...args: any[]) => void
225
+ * }
226
+ * ```
227
+ */
228
+ export type ValidEventTypes = string | symbol | object;
229
+
230
+ export type EventNames<T extends ValidEventTypes> = T extends string | symbol
231
+ ? T
232
+ : keyof T;
233
+
234
+ export type ArgumentMap<T extends object> = {
235
+ [K in keyof T]: T[K] extends (...args: any[]) => void
236
+ ? Parameters<T[K]>
237
+ : T[K] extends any[]
238
+ ? T[K]
239
+ : any[];
240
+ };
241
+
242
+ export type EventListener<
243
+ T extends ValidEventTypes,
244
+ K extends EventNames<T>
245
+ > = T extends string | symbol
246
+ ? (...args: any[]) => void
247
+ : (
248
+ ...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]
249
+ ) => void;
250
+
251
+ export type EventArgs<
252
+ T extends ValidEventTypes,
253
+ K extends EventNames<T>
254
+ > = Parameters<EventListener<T, K>>;
255
+
256
+ export const EventEmitter: EventEmitterStatic;
257
+ }
258
+
259
+ declare enum TELE_BOX_COLOR_SCHEME {
260
+ Light = "light",
261
+ Dark = "dark",
262
+ Auto = "auto"
263
+ }
264
+ declare enum TELE_BOX_STATE {
265
+ Normal = "normal",
266
+ Minimized = "minimized",
267
+ Maximized = "maximized"
268
+ }
269
+ declare enum TELE_BOX_EVENT {
270
+ DarkMode = "dark_mode",
271
+ PrefersColorScheme = "prefers_color_scheme",
272
+ Close = "close",
273
+ Focus = "focus",
274
+ Blur = "blur",
275
+ Move = "move",
276
+ Resize = "resize",
277
+ IntrinsicMove = "intrinsic_move",
278
+ IntrinsicResize = "intrinsic_resize",
279
+ VisualResize = "visual_resize",
280
+ ZIndex = "z_index",
281
+ State = "state",
282
+ Minimized = "minimized",
283
+ Maximized = "maximized",
284
+ Readonly = "readonly",
285
+ Destroyed = "destroyed"
286
+ }
287
+ declare enum TELE_BOX_DELEGATE_EVENT {
288
+ Close = "close",
289
+ Maximize = "maximize",
290
+ Minimize = "minimize"
291
+ }
292
+ declare enum TELE_BOX_RESIZE_HANDLE {
293
+ North = "n",
294
+ South = "s",
295
+ West = "w",
296
+ East = "e",
297
+ NorthWest = "nw",
298
+ NorthEast = "ne",
299
+ SouthEast = "se",
300
+ SouthWest = "sw"
301
+ }
302
+ declare const TeleBoxDragHandleType = "dh";
303
+
304
+ type TeleBoxColorScheme = `${TELE_BOX_COLOR_SCHEME}`;
305
+ type TeleBoxCoord = {
306
+ x: number;
307
+ y: number;
308
+ };
309
+ type TeleBoxSize = {
310
+ width: number;
311
+ height: number;
312
+ };
313
+ type TeleBoxState = `${TELE_BOX_STATE}`;
314
+ interface TeleBoxRect {
315
+ readonly x: number;
316
+ readonly y: number;
317
+ readonly width: number;
318
+ readonly height: number;
319
+ }
320
+ interface TeleBoxConfig {
321
+ /** Box ID. */
322
+ readonly id?: string;
323
+ /** Box title. Default empty. */
324
+ readonly title?: string;
325
+ /** Prefers Box color scheme. Default light. */
326
+ readonly prefersColorScheme?: TeleBoxColorScheme;
327
+ /** Actual Box Dark Mode */
328
+ readonly darkMode?: boolean;
329
+ /** Box visible. Default true. */
330
+ readonly visible?: boolean;
331
+ /** Box width relative to root element. 0~1. Default 0.5. */
332
+ readonly width?: number;
333
+ /** Box height relative to root element. 0~1. Default 0.5. */
334
+ readonly height?: number;
335
+ /** Minimum box width relative to root element. 0~1. Default 0. */
336
+ readonly minWidth?: number;
337
+ /** Minimum box height relative to root element. 0~1. Default 0. */
338
+ readonly minHeight?: number;
339
+ /** x position relative to root element. 0~1. Default 0.1. */
340
+ readonly x?: number;
341
+ /** y position relative to root element. 0~1. Default 0.1. */
342
+ readonly y?: number;
343
+ /** Maximize box. Default false. */
344
+ readonly maximized?: boolean;
345
+ /** Minimize box. Overwrites maximized state. Default false. */
346
+ readonly minimized?: boolean;
347
+ /** The initial state of the box. Default normal. */
348
+ readonly state?: TeleBoxState;
349
+ /** Is box readonly */
350
+ readonly readonly?: boolean;
351
+ /** Able to resize box window. Default true. */
352
+ readonly resizable?: boolean;
353
+ /** Able to drag box window Default true. */
354
+ readonly draggable?: boolean;
355
+ /** Restrict box to always be within the containing area. Default true. */
356
+ readonly fence?: boolean;
357
+ /** Fixed width/height ratio for box window. Default false. */
358
+ readonly fixRatio?: boolean;
359
+ /** Box focused. */
360
+ readonly focus?: boolean;
361
+ /** Base z-index for box. */
362
+ readonly zIndex?: number;
363
+ /** Classname Prefix. For CSS styling. Default "telebox". */
364
+ readonly namespace?: string;
365
+ /** TeleTitleBar Instance. */
366
+ readonly titleBar?: TeleTitleBar;
367
+ /** Box content. */
368
+ readonly content?: HTMLElement;
369
+ /** Box footer. */
370
+ readonly footer?: HTMLElement;
371
+ /** Box content styles. */
372
+ readonly styles?: HTMLStyleElement;
373
+ /** Position and dimension of container */
374
+ readonly containerRect?: TeleBoxRect;
375
+ /** Position and dimension of collector */
376
+ readonly collectorRect?: TeleBoxRect;
377
+ }
378
+ type CheckTeleBoxConfig<T extends Record<`${TELE_BOX_EVENT}`, any>> = T;
379
+ type TeleBoxEventConfig = CheckTeleBoxConfig<{
380
+ dark_mode: boolean;
381
+ prefers_color_scheme: TeleBoxColorScheme;
382
+ close: void;
383
+ focus: void;
384
+ blur: void;
385
+ move: {
386
+ x: number;
387
+ y: number;
388
+ };
389
+ resize: {
390
+ width: number;
391
+ height: number;
392
+ };
393
+ intrinsic_move: {
394
+ x: number;
395
+ y: number;
396
+ };
397
+ intrinsic_resize: {
398
+ width: number;
399
+ height: number;
400
+ };
401
+ visual_resize: {
402
+ width: number;
403
+ height: number;
404
+ };
405
+ z_index: number;
406
+ state: TeleBoxState;
407
+ minimized: boolean;
408
+ maximized: boolean;
409
+ readonly: boolean;
410
+ destroyed: void;
411
+ }>;
412
+ type TeleBoxEvent = keyof TeleBoxEventConfig;
413
+ interface TeleBoxEvents extends EventEmitter<TeleBoxEvent> {
414
+ on<U extends TeleBoxEvent>(event: U, listener: (value: TeleBoxEventConfig[U]) => void): this;
415
+ once<U extends TeleBoxEvent>(event: U, listener: (value: TeleBoxEventConfig[U]) => void): this;
416
+ addListener<U extends TeleBoxEvent>(event: U, listener: (value: TeleBoxEventConfig[U]) => void): this;
417
+ emit<U extends TeleBoxEvent>(event: U, ...value: TeleBoxEventConfig[U] extends void ? [] : [TeleBoxEventConfig[U]]): boolean;
418
+ }
419
+ type TeleBoxHandleType = TELE_BOX_RESIZE_HANDLE | typeof TeleBoxDragHandleType;
420
+ type CheckTeleBoxDelegateConfig<T extends Record<`${TELE_BOX_DELEGATE_EVENT}`, any>> = T;
421
+ type TeleBoxDelegateEventConfig = CheckTeleBoxDelegateConfig<{
422
+ close: void;
423
+ maximize: void;
424
+ minimize: void;
425
+ }>;
426
+ type TeleBoxDelegateEvent = keyof TeleBoxDelegateEventConfig;
427
+ interface TeleBoxDelegateEvents extends EventEmitter<TeleBoxDelegateEvent> {
428
+ on<U extends TeleBoxDelegateEvent>(event: U, listener: (value: TeleBoxDelegateEventConfig[U]) => void): this;
429
+ once<U extends TeleBoxDelegateEvent>(event: U, listener: (value: TeleBoxDelegateEventConfig[U]) => void): this;
430
+ addListener<U extends TeleBoxDelegateEvent>(event: U, listener: (value: TeleBoxDelegateEventConfig[U]) => void): this;
431
+ emit<U extends TeleBoxDelegateEvent>(event: U, ...value: TeleBoxDelegateEventConfig[U] extends void ? [] : [TeleBoxDelegateEventConfig[U]]): boolean;
432
+ }
433
+
434
+ type TeleTitleBarEvent<U = keyof TeleBoxDelegateEventConfig> = U extends keyof TeleBoxDelegateEventConfig ? TeleBoxDelegateEventConfig[U] extends void ? {
435
+ type: U;
436
+ value?: TeleBoxDelegateEventConfig[U];
437
+ } : {
438
+ type: U;
439
+ value: TeleBoxDelegateEventConfig[U];
440
+ } : never;
441
+ interface TeleTitleBarConfig {
442
+ readonly?: boolean;
443
+ title?: string;
444
+ state?: TeleBoxState;
445
+ namespace?: string;
446
+ onEvent?: (event: TeleTitleBarEvent) => void;
447
+ onDragStart?: (event: MouseEvent | TouchEvent) => void;
448
+ }
449
+ interface TeleTitleBar {
450
+ setTitle(title: string): void;
451
+ setState(state: TeleBoxState): void;
452
+ setReadonly(readonly: boolean): void;
453
+ render(): HTMLElement;
454
+ destroy(): void;
455
+ }
456
+
457
+ type DefaultTitleBarButton = TeleTitleBarEvent & {
458
+ readonly iconClassName: string;
459
+ readonly isActive?: (state: TeleBoxState) => boolean;
460
+ };
461
+ interface DefaultTitleBarConfig extends TeleTitleBarConfig {
462
+ buttons?: ReadonlyArray<DefaultTitleBarButton>;
463
+ }
464
+ declare class DefaultTitleBar implements TeleTitleBar {
465
+ constructor({ readonly, title, buttons, onEvent, onDragStart, namespace, state, }?: DefaultTitleBarConfig);
466
+ readonly namespace: string;
467
+ $titleBar: HTMLElement | undefined;
468
+ $title: HTMLElement | undefined;
469
+ $dragArea: HTMLElement;
470
+ setTitle(title: string): void;
471
+ setState(state: TeleBoxState): void;
472
+ setReadonly(readonly: boolean): void;
473
+ render(): HTMLElement;
474
+ renderDragArea(): HTMLElement;
475
+ dragHandle(): HTMLElement | undefined;
476
+ wrapClassName(className: string): string;
477
+ destroy(): void;
478
+ onEvent?: TeleTitleBarConfig["onEvent"];
479
+ onDragStart?: TeleTitleBarConfig["onDragStart"];
480
+ protected readonly: boolean;
481
+ protected title?: string;
482
+ protected buttons: ReadonlyArray<DefaultTitleBarButton>;
483
+ protected state: TeleBoxState;
484
+ protected $btns: HTMLButtonElement[];
485
+ protected sideEffect: SideEffectManager;
486
+ protected lastTitleBarClick: {
487
+ timestamp: number;
488
+ clientX: number;
489
+ clientY: number;
490
+ };
491
+ protected handleTitleBarClick: (ev: MouseEvent) => void;
492
+ protected lastTitleBarTouch: {
493
+ timestamp: number;
494
+ clientX: number;
495
+ clientY: number;
496
+ };
497
+ protected handleTitleBarTouch: (ev: TouchEvent) => void;
498
+ }
499
+
500
+ type ValConfig$1 = {
501
+ prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
502
+ darkMode: Val<boolean, boolean>;
503
+ containerRect: Val<TeleBoxRect, boolean>;
504
+ collectorRect: Val<TeleBoxRect | undefined, boolean>;
505
+ /** Box title. Default empty. */
506
+ title: Val<string, boolean>;
507
+ /** Is box visible */
508
+ visible: Val<boolean, boolean>;
509
+ /** Is box readonly */
510
+ readonly: Val<boolean, boolean>;
511
+ /** Able to resize box window */
512
+ resizable: Val<boolean, boolean>;
513
+ /** Able to drag box window */
514
+ draggable: Val<boolean, boolean>;
515
+ /** Restrict box to always be within the containing area. */
516
+ fence: Val<boolean, boolean>;
517
+ /** Fixed width/height ratio for box window. */
518
+ fixRatio: Val<boolean, boolean>;
519
+ focus: Val<boolean, boolean>;
520
+ zIndex: Val<number, boolean>;
521
+ /** Is box minimized. Default false. */
522
+ minimized: Val<boolean, boolean>;
523
+ /** Is box maximized. Default false. */
524
+ maximized: Val<boolean, boolean>;
525
+ $userContent: Val<HTMLElement | undefined>;
526
+ $userFooter: Val<HTMLElement | undefined>;
527
+ $userStyles: Val<HTMLStyleElement | undefined>;
528
+ };
529
+ interface TeleBox extends ValEnhancedResult<ValConfig$1> {
530
+ }
531
+ declare class TeleBox {
532
+ constructor({ id, title, prefersColorScheme, darkMode, visible, width, height, minWidth, minHeight, x, y, minimized, maximized, readonly, resizable, draggable, fence, fixRatio, focus, zIndex, namespace, titleBar, content, footer, styles, containerRect, collectorRect, }?: TeleBoxConfig);
533
+ readonly id: string;
534
+ /** ClassName Prefix. For CSS styling. Default "telebox" */
535
+ readonly namespace: string;
536
+ readonly events: TeleBoxEvents;
537
+ readonly _delegateEvents: TeleBoxDelegateEvents;
538
+ protected _sideEffect: SideEffectManager;
539
+ protected _valSideEffectBinder: ValSideEffectBinder;
540
+ titleBar: TeleTitleBar;
541
+ _minSize$: Val<TeleBoxSize, boolean>;
542
+ _size$: Val<TeleBoxSize, boolean>;
543
+ _intrinsicSize$: Val<TeleBoxSize, boolean>;
544
+ _visualSize$: Val<TeleBoxSize, boolean>;
545
+ _coord$: Val<TeleBoxCoord, boolean>;
546
+ _intrinsicCoord$: Val<TeleBoxCoord, boolean>;
547
+ get darkMode(): boolean;
548
+ _state$: Val<TeleBoxState, boolean>;
549
+ get state(): TeleBoxState;
550
+ /** @deprecated use setMaximized and setMinimized instead */
551
+ setState(state: TeleBoxState, skipUpdate?: boolean): this;
552
+ /** Minimum box width relative to container element. 0~1. Default 0. */
553
+ get minWidth(): number;
554
+ /** Minimum box height relative to container element. 0~1. Default 0. */
555
+ get minHeight(): number;
556
+ /**
557
+ * @param minWidth Minimum box width relative to container element. 0~1.
558
+ * @returns this
559
+ */
560
+ setMinWidth(minWidth: number, skipUpdate?: boolean): this;
561
+ /**
562
+ * @param minHeight Minimum box height relative to container element. 0~1.
563
+ * @returns this
564
+ */
565
+ setMinHeight(minHeight: number, skipUpdate?: boolean): this;
566
+ /** Intrinsic box width relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.5. */
567
+ get intrinsicWidth(): number;
568
+ /** Intrinsic box height relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.5. */
569
+ get intrinsicHeight(): number;
570
+ /**
571
+ * Resize box.
572
+ * @param width Box width relative to container element. 0~1.
573
+ * @param height Box height relative to container element. 0~1.
574
+ * @param skipUpdate Skip emitting event.
575
+ * @returns this
576
+ */
577
+ resize(width: number, height: number, skipUpdate?: boolean): this;
578
+ /** Box width relative to container element. 0~1. Default 0.5. */
579
+ get width(): number;
580
+ /** Box height relative to container element. 0~1. Default 0.5. */
581
+ get height(): number;
582
+ /** Box width in pixels. */
583
+ get absoluteWidth(): number;
584
+ /** Box height in pixels. */
585
+ get absoluteHeight(): number;
586
+ /** Actual rendered box width relative to container element. 0~1. Default 0.5. */
587
+ get visualWidth(): number;
588
+ /** Actual rendered box height relative to container element. 0~1. Default 0.5. */
589
+ get visualHeight(): number;
590
+ /** Intrinsic box x position relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.1. */
591
+ get intrinsicX(): number;
592
+ /** Intrinsic box y position relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.1. */
593
+ get intrinsicY(): number;
594
+ /**
595
+ * Move box position.
596
+ * @param x x position relative to container element. 0~1.
597
+ * @param y y position relative to container element. 0~1.
598
+ * @param skipUpdate Skip emitting event.
599
+ * @returns this
600
+ */
601
+ move(x: number, y: number, skipUpdate?: boolean): this;
602
+ /** Box x position relative to container element. 0~1. Default 0.1. */
603
+ get x(): number;
604
+ /** Box y position relative to container element. 0~1. Default 0.1. */
605
+ get y(): number;
606
+ /**
607
+ * Resize + Move, with respect to fixed ratio.
608
+ * @param x x position relative to container element. 0~1.
609
+ * @param y y position relative to container element. 0~1.
610
+ * @param width Box width relative to container element. 0~1.
611
+ * @param height Box height relative to container element. 0~1.
612
+ * @param skipUpdate Skip emitting event.
613
+ * @returns this
614
+ */
615
+ transform(x: number, y: number, width: number, height: number, skipUpdate?: boolean): this;
616
+ /**
617
+ * Mount box to a container element.
618
+ */
619
+ mount(container: HTMLElement): this;
620
+ /**
621
+ * Unmount box from the container element.
622
+ */
623
+ unmount(): this;
624
+ /**
625
+ * Mount dom to box content.
626
+ */
627
+ mountContent(content: HTMLElement): this;
628
+ /**
629
+ * Unmount content from the box.
630
+ */
631
+ unmountContent(): this;
632
+ /**
633
+ * Mount dom to box Footer.
634
+ */
635
+ mountFooter(footer: HTMLElement): this;
636
+ /**
637
+ * Unmount Footer from the box.
638
+ */
639
+ unmountFooter(): this;
640
+ getUserStyles(): HTMLStyleElement | undefined;
641
+ mountStyles(styles: string | HTMLStyleElement): this;
642
+ unmountStyles(): this;
643
+ /** DOM of the box */
644
+ $box: HTMLElement;
645
+ /** DOM of the box content */
646
+ $content: HTMLElement;
647
+ /** DOM of the box title bar */
648
+ $titleBar: HTMLElement;
649
+ /** DOM of the box footer */
650
+ $footer: HTMLElement;
651
+ protected _renderSideEffect: SideEffectManager;
652
+ render(root?: HTMLElement): HTMLElement;
653
+ protected _handleTrackStart?: (ev: MouseEvent | TouchEvent) => void;
654
+ handleTrackStart: (ev: MouseEvent | TouchEvent) => void;
655
+ protected _renderResizeHandlers(): void;
656
+ destroy(): void;
657
+ /**
658
+ * Wrap a className with namespace
659
+ */
660
+ wrapClassName(className: string): string;
661
+ }
662
+ type PropKeys<K = keyof TeleBox> = K extends keyof TeleBox ? TeleBox[K] extends Function ? never : K : never;
663
+ type ReadonlyTeleBox = Pick<TeleBox, PropKeys | "wrapClassName" | "mountContent" | "mountFooter" | "mountStyles" | "handleTrackStart">;
664
+
665
+ type StringStyleKeys<T = keyof CSSStyleDeclaration> = T extends keyof CSSStyleDeclaration ? CSSStyleDeclaration[T] extends string ? T : never : never;
666
+ type TeleStyles = Partial<Pick<CSSStyleDeclaration, StringStyleKeys>>;
667
+
668
+ interface TeleBoxCollectorConfig {
669
+ visible?: boolean;
670
+ readonly?: boolean;
671
+ darkMode?: boolean;
672
+ namespace?: string;
673
+ styles?: TeleStyles;
674
+ onClick?: () => void;
675
+ }
676
+ declare class TeleBoxCollector {
677
+ constructor({ visible, readonly, darkMode, namespace, styles, onClick, }?: TeleBoxCollectorConfig);
678
+ readonly styles: TeleStyles;
679
+ readonly namespace: string;
680
+ get visible(): boolean;
681
+ get readonly(): boolean;
682
+ get darkMode(): boolean;
683
+ onClick: (() => void) | undefined;
684
+ $collector: HTMLElement | undefined;
685
+ /**
686
+ * Mount collector to a root element.
687
+ */
688
+ mount(root: HTMLElement): this;
689
+ /**
690
+ * Unmount collector from the root element.
691
+ */
692
+ unmount(): this;
693
+ setVisible(visible: boolean): this;
694
+ setReadonly(readonly: boolean): this;
695
+ setDarkMode(darkMode: boolean): this;
696
+ setStyles(styles: TeleStyles): this;
697
+ render(): HTMLElement;
698
+ destroy(): void;
699
+ wrapClassName(className: string): string;
700
+ protected _visible: boolean;
701
+ protected _readonly: boolean;
702
+ protected _darkMode: boolean;
703
+ protected handleCollectorClick: () => void;
704
+ }
705
+
706
+ declare enum TELE_BOX_MANAGER_EVENT {
707
+ Focused = "focused",
708
+ Blurred = "blurred",
709
+ Created = "created",
710
+ Removed = "removed",
711
+ State = "state",
712
+ Maximized = "maximized",
713
+ Minimized = "minimized",
714
+ Move = "move",
715
+ Resize = "resize",
716
+ IntrinsicMove = "intrinsic_move",
717
+ IntrinsicResize = "intrinsic_resize",
718
+ VisualResize = "visual_resize",
719
+ ZIndex = "z_index",
720
+ PrefersColorScheme = "prefers_color_scheme",
721
+ DarkMode = "dark_mode"
722
+ }
723
+
724
+ interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "prefersColorScheme" | "fence" | "containerRect" | "maximized" | "minimized" | "namespace" | "readonly"> {
725
+ /** Element to mount boxes. */
726
+ root?: HTMLElement;
727
+ /** Where the minimized boxes go. */
728
+ collector?: TeleBoxCollector;
729
+ }
730
+ type TeleBoxManagerBoxConfigBaseProps = "title" | "visible" | "width" | "height" | "minWidth" | "minHeight" | "x" | "y" | "resizable" | "draggable" | "fixRatio" | "zIndex";
731
+ type TeleBoxManagerCreateConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "content" | "footer" | "id" | "focus">;
732
+ type TeleBoxManagerQueryConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "id" | "focus">;
733
+ type TeleBoxManagerUpdateConfig = Pick<TeleBoxConfig, TeleBoxManagerBoxConfigBaseProps | "content" | "footer">;
734
+ type CheckTeleBoxManagerConfig<T extends Record<`${TELE_BOX_MANAGER_EVENT}`, any>> = T;
735
+ type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
736
+ focused: [ReadonlyTeleBox | undefined];
737
+ blurred: [ReadonlyTeleBox | undefined];
738
+ created: [ReadonlyTeleBox];
739
+ removed: [ReadonlyTeleBox[]];
740
+ state: [TeleBoxState];
741
+ maximized: [boolean];
742
+ minimized: [boolean];
743
+ move: [ReadonlyTeleBox];
744
+ resize: [ReadonlyTeleBox];
745
+ intrinsic_move: [ReadonlyTeleBox];
746
+ intrinsic_resize: [ReadonlyTeleBox];
747
+ visual_resize: [ReadonlyTeleBox];
748
+ z_index: [ReadonlyTeleBox];
749
+ prefers_color_scheme: [TeleBoxColorScheme];
750
+ dark_mode: [boolean];
751
+ }>;
752
+ type TeleBoxManagerEvent = keyof TeleBoxManagerEventConfig;
753
+ interface TeleBoxManagerEvents extends EventEmitter<TeleBoxManagerEvent> {
754
+ on<U extends TeleBoxManagerEvent>(event: U, listener: (...value: TeleBoxManagerEventConfig[U]) => void): this;
755
+ once<U extends TeleBoxManagerEvent>(event: U, listener: (...value: TeleBoxManagerEventConfig[U]) => void): this;
756
+ addListener<U extends TeleBoxManagerEvent>(event: U, listener: (...value: TeleBoxManagerEventConfig[U]) => void): this;
757
+ emit<U extends TeleBoxManagerEvent>(event: U, ...value: TeleBoxManagerEventConfig[U]): boolean;
758
+ }
759
+
760
+ type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly">;
761
+ interface MaxTitleBarConfig extends DefaultTitleBarConfig {
762
+ darkMode: boolean;
763
+ boxes: MaxTitleBarTeleBox[];
764
+ containerRect: TeleBoxRect;
765
+ focusedBox?: MaxTitleBarTeleBox;
766
+ }
767
+ declare class MaxTitleBar extends DefaultTitleBar {
768
+ constructor(config: MaxTitleBarConfig);
769
+ focusBox(box?: MaxTitleBarTeleBox): void;
770
+ setContainerRect(rect: TeleBoxRect): void;
771
+ setBoxes(boxes: MaxTitleBarTeleBox[]): void;
772
+ setState(state: TeleBoxState): void;
773
+ setReadonly(readonly: boolean): void;
774
+ setDarkMode(darkMode: boolean): void;
775
+ render(): HTMLElement;
776
+ destroy(): void;
777
+ updateTitles(): void;
778
+ protected renderTitles(): HTMLElement;
779
+ protected darkMode: boolean;
780
+ protected $titles: HTMLElement | undefined;
781
+ protected boxes: MaxTitleBarTeleBox[];
782
+ focusedBox: MaxTitleBarTeleBox | undefined;
783
+ protected containerRect: TeleBoxRect;
784
+ }
785
+
786
+ type ValConfig = {
787
+ prefersColorScheme: Val<TeleBoxColorScheme, boolean>;
788
+ containerRect: Val<TeleBoxRect, boolean>;
789
+ collector: Val<TeleBoxCollector | null>;
790
+ collectorRect: Val<TeleBoxRect | undefined>;
791
+ readonly: Val<boolean, boolean>;
792
+ minimized: Val<boolean, boolean>;
793
+ maximized: Val<boolean, boolean>;
794
+ fence: Val<boolean, boolean>;
795
+ };
796
+ interface TeleBoxManager extends ValEnhancedResult<ValConfig> {
797
+ }
798
+ declare class TeleBoxManager {
799
+ constructor({ root, prefersColorScheme, minimized, maximized, fence, containerRect, collector, namespace, readonly, }?: TeleBoxManagerConfig);
800
+ get boxes(): ReadonlyArray<TeleBox>;
801
+ get topBox(): TeleBox | undefined;
802
+ readonly events: TeleBoxManagerEvents;
803
+ protected _sideEffect: SideEffectManager;
804
+ protected root: HTMLElement;
805
+ readonly namespace: string;
806
+ _darkMode$: Val<boolean, boolean>;
807
+ get darkMode(): boolean;
808
+ _state$: Val<TeleBoxState, boolean>;
809
+ get state(): TeleBoxState;
810
+ /** @deprecated use setMaximized and setMinimized instead */
811
+ setState(state: TeleBoxState, skipUpdate?: boolean): this;
812
+ create(config?: TeleBoxManagerCreateConfig, smartPosition?: boolean): ReadonlyTeleBox;
813
+ query(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox[];
814
+ queryOne(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox | undefined;
815
+ update(boxID: string, config: TeleBoxManagerUpdateConfig, skipUpdate?: boolean): void;
816
+ updateAll(config: TeleBoxManagerUpdateConfig, skipUpdate?: boolean): void;
817
+ remove(boxOrID: string | TeleBox, skipUpdate?: boolean): ReadonlyTeleBox | undefined;
818
+ removeTopBox(): ReadonlyTeleBox | undefined;
819
+ removeAll(skipUpdate?: boolean): ReadonlyTeleBox[];
820
+ destroy(skipUpdate?: boolean): void;
821
+ wrapClassName(className: string): string;
822
+ focusBox(boxOrID: string | TeleBox, skipUpdate?: boolean): void;
823
+ focusTopBox(): void;
824
+ blurBox(boxOrID: string | TeleBox, skipUpdate?: boolean): void;
825
+ blurAll(skipUpdate?: boolean): void;
826
+ protected maxTitleBar: MaxTitleBar;
827
+ protected boxes$: Val<TeleBox[]>;
828
+ protected topBox$: Val<TeleBox | undefined>;
829
+ protected teleBoxMatcher(config: TeleBoxManagerQueryConfig): (box: TeleBox) => boolean;
830
+ protected updateBox(box: TeleBox, config: TeleBoxManagerUpdateConfig, skipUpdate?: boolean): void;
831
+ protected smartPosition(config?: TeleBoxConfig): TeleBoxConfig;
832
+ protected makeBoxTop(box: TeleBox, skipUpdate?: boolean): void;
833
+ protected getBoxIndex(boxOrID: TeleBox | string): number;
834
+ protected getBox(boxOrID: TeleBox | string): TeleBox | undefined;
835
+ }
836
+
837
+ export { DefaultTitleBar, type DefaultTitleBarButton, type DefaultTitleBarConfig, type ReadonlyTeleBox, TELE_BOX_COLOR_SCHEME, TELE_BOX_DELEGATE_EVENT, TELE_BOX_EVENT, TELE_BOX_MANAGER_EVENT, TELE_BOX_RESIZE_HANDLE, TELE_BOX_STATE, TeleBox, TeleBoxCollector, type TeleBoxCollectorConfig, type TeleBoxColorScheme, type TeleBoxConfig, type TeleBoxCoord, type TeleBoxDelegateEvent, type TeleBoxDelegateEventConfig, type TeleBoxDelegateEvents, TeleBoxDragHandleType, type TeleBoxEvent, type TeleBoxEventConfig, type TeleBoxEvents, type TeleBoxHandleType, TeleBoxManager, type TeleBoxManagerConfig, type TeleBoxManagerCreateConfig, type TeleBoxManagerEvent, type TeleBoxManagerEventConfig, type TeleBoxManagerEvents, type TeleBoxManagerQueryConfig, type TeleBoxManagerUpdateConfig, type TeleBoxRect, type TeleBoxSize, type TeleBoxState, type TeleTitleBar, type TeleTitleBarConfig, type TeleTitleBarEvent };