@coherent.js/client 1.0.0-rc.6 → 1.0.1
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/package.json +1 -1
- package/types/index.d.ts +56 -18
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -313,32 +313,70 @@ export interface CustomEventData {
|
|
|
313
313
|
// Event Delegation Types (Plan 02-01)
|
|
314
314
|
// ============================================================================
|
|
315
315
|
|
|
316
|
-
/**
|
|
317
|
-
export interface
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
/** A component whose state a delegated handler may read and write */
|
|
317
|
+
export interface HandlerComponentRef {
|
|
318
|
+
getState?: () => any;
|
|
319
|
+
setState?: (state: any) => void;
|
|
320
|
+
[key: string]: any;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** A registered handler and the component it belongs to */
|
|
324
|
+
export interface RegisteredHandler {
|
|
325
|
+
handler: StateAwareHandler;
|
|
326
|
+
componentRef: HandlerComponentRef | null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Routes document-level events to handlers registered by id.
|
|
331
|
+
*
|
|
332
|
+
* Focus and blur are delegated in the capture phase, since they do not bubble.
|
|
333
|
+
*/
|
|
334
|
+
export class EventDelegation {
|
|
335
|
+
constructor(registry?: HandlerRegistry);
|
|
336
|
+
|
|
337
|
+
registry: HandlerRegistry;
|
|
338
|
+
initialized: boolean;
|
|
339
|
+
root: Document | Element | null;
|
|
340
|
+
/** Event types delegated from the root */
|
|
341
|
+
eventTypes: string[];
|
|
342
|
+
|
|
343
|
+
/** Attach listeners to `root`; idempotent, and a no-op without a document */
|
|
344
|
+
initialize(root?: Document | Element | null): void;
|
|
345
|
+
|
|
346
|
+
/** Dispatch one delegated event to its registered handler */
|
|
347
|
+
handleEvent(event: Event, eventType: string): void;
|
|
348
|
+
|
|
349
|
+
/** Remove every listener attached by `initialize()` */
|
|
321
350
|
destroy(): void;
|
|
322
|
-
|
|
351
|
+
|
|
323
352
|
isInitialized(): boolean;
|
|
324
353
|
}
|
|
325
354
|
|
|
326
|
-
/**
|
|
327
|
-
export
|
|
328
|
-
|
|
355
|
+
/** Stores delegated event handlers by id. */
|
|
356
|
+
export class HandlerRegistry {
|
|
357
|
+
constructor();
|
|
358
|
+
|
|
359
|
+
handlers: Map<string, RegisteredHandler>;
|
|
360
|
+
|
|
361
|
+
/** Register a handler, optionally bound to a component */
|
|
329
362
|
register(
|
|
330
|
-
|
|
363
|
+
handlerId: string,
|
|
331
364
|
handler: StateAwareHandler,
|
|
332
|
-
componentRef?:
|
|
365
|
+
componentRef?: HandlerComponentRef | null
|
|
333
366
|
): void;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
has(
|
|
340
|
-
/** Clear all handlers */
|
|
367
|
+
|
|
368
|
+
/** Remove a handler; `false` when the id was not registered */
|
|
369
|
+
unregister(handlerId: string): boolean;
|
|
370
|
+
|
|
371
|
+
get(handlerId: string): RegisteredHandler | undefined;
|
|
372
|
+
has(handlerId: string): boolean;
|
|
341
373
|
clear(): void;
|
|
374
|
+
|
|
375
|
+
/** Ids of every handler registered against one component */
|
|
376
|
+
getByComponent(componentRef: HandlerComponentRef | null): string[];
|
|
377
|
+
|
|
378
|
+
/** How many handlers are registered */
|
|
379
|
+
get size(): number;
|
|
342
380
|
}
|
|
343
381
|
|
|
344
382
|
// ============================================================================
|