@gridkitjs/dom 0.3.3 → 0.4.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/dist/index.d.ts +65 -23
- package/dist/index.js +240 -131
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -87,7 +87,8 @@ interface AttachedChecklist {
|
|
|
87
87
|
* How many items the whole list holds, mounted or not. Starts at 0, so a
|
|
88
88
|
* renderer calls this straight after attaching, and again whenever the
|
|
89
89
|
* list changes — a search narrowing it, say. A focused place past the new
|
|
90
|
-
* end moves back to the last item
|
|
90
|
+
* end moves back to the last item, and so does a move still waiting for
|
|
91
|
+
* an item past it.
|
|
91
92
|
*/
|
|
92
93
|
readonly setCount: (count: number) => void;
|
|
93
94
|
/**
|
|
@@ -196,14 +197,24 @@ interface ColumnResizeGestureHandlers {
|
|
|
196
197
|
* spurious resize on every click.
|
|
197
198
|
*/
|
|
198
199
|
readonly onEnd: (width: number | null) => void;
|
|
199
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Escape, a cancelled pointer or an aborted `signal`: the column goes back
|
|
202
|
+
* to `session.startWidth`.
|
|
203
|
+
*/
|
|
200
204
|
readonly onCancel: () => void;
|
|
205
|
+
/**
|
|
206
|
+
* Cancels the resize when aborted, as Escape does. For a renderer whose
|
|
207
|
+
* handle goes away mid-drag, so what it draws for the resize ends with it.
|
|
208
|
+
* Already aborted, no resize starts.
|
|
209
|
+
*/
|
|
210
|
+
readonly signal?: AbortSignal;
|
|
201
211
|
}
|
|
202
212
|
/**
|
|
203
213
|
* Drags a column's edge from `press` on its resize `handle`, turning pointer
|
|
204
214
|
* positions into widths through `@gridkitjs/core`'s `session` — begun with
|
|
205
215
|
* `beginColumnResize` — and reporting them. Returns whether a resize began:
|
|
206
|
-
* only the primary button of the primary pointer starts one
|
|
216
|
+
* only the primary button of the primary pointer starts one, and not once
|
|
217
|
+
* `handlers.signal` has aborted.
|
|
207
218
|
*
|
|
208
219
|
* Captures the pointer on `handle`, so the drag keeps reporting wherever the
|
|
209
220
|
* pointer goes, and prevents the press's default, so it does not select the
|
|
@@ -289,18 +300,25 @@ interface DragReorderHandlers<Target> {
|
|
|
289
300
|
readonly onState: (state: DragReorderState<Target>) => void;
|
|
290
301
|
/** The pointer was released over a valid target. */
|
|
291
302
|
readonly onDrop: (target: Target, id: string) => void;
|
|
303
|
+
/**
|
|
304
|
+
* Cancels the drag when aborted, as Escape does: `onState(NO_DRAG)`, no
|
|
305
|
+
* drop. For a renderer whose dragged element goes away mid-drag, so what
|
|
306
|
+
* it draws for the drag ends with it. Already aborted, no drag starts.
|
|
307
|
+
*/
|
|
308
|
+
readonly signal?: AbortSignal;
|
|
292
309
|
}
|
|
293
310
|
/**
|
|
294
311
|
* The pointer mechanics behind every drag-to-reorder gesture in the grid — a
|
|
295
312
|
* column header dragged among the others or into the group-by bar, a
|
|
296
313
|
* group-by chip dragged within it: capture, the drag threshold, and the ghost
|
|
297
314
|
* trailing the pointer, holding the spot it was picked up by. Returns whether
|
|
298
|
-
* a gesture began; only the main button of the primary pointer starts one
|
|
315
|
+
* a gesture began; only the main button of the primary pointer starts one,
|
|
316
|
+
* and not once `handlers.signal` has aborted.
|
|
299
317
|
*
|
|
300
318
|
* The press is left to its default, so the pressed element still takes focus;
|
|
301
319
|
* until the pointer has travelled `DRAG_THRESHOLD` pixels nothing is
|
|
302
|
-
* reported, so a press that never moves stays a click. Escape,
|
|
303
|
-
* pointer
|
|
320
|
+
* reported, so a press that never moves stays a click. Escape, a cancelled
|
|
321
|
+
* pointer or an aborted signal leaves the order as it was.
|
|
304
322
|
*
|
|
305
323
|
* Pointer events rather than HTML5 drag-and-drop: `dragenter`/`dragleave`
|
|
306
324
|
* fire per descendant, so a dragged item's own inner markup would each report
|
|
@@ -428,8 +446,13 @@ interface GridFocusController {
|
|
|
428
446
|
/**
|
|
429
447
|
* Connects the tab stop to the rendered rows, which the browser's focus
|
|
430
448
|
* then follows it among. Returns the function that disconnects them.
|
|
449
|
+
*
|
|
450
|
+
* `root`, the element holding every row, lets the user take over from a
|
|
451
|
+
* move still waiting for its row to be drawn: focus leaving `root`, or a
|
|
452
|
+
* wheel or a press inside it, drops the move, so a row mounting later
|
|
453
|
+
* neither scrolls back to itself nor pulls focus back into the grid.
|
|
431
454
|
*/
|
|
432
|
-
readonly attach: (rows: GridFocusRows) => () => void;
|
|
455
|
+
readonly attach: (rows: GridFocusRows, root?: HTMLElement | null) => () => void;
|
|
433
456
|
/**
|
|
434
457
|
* Called by the renderer once it has drawn `drawn` — a value `getFocus`
|
|
435
458
|
* returned — so the browser's focus follows a move to the cell now in the
|
|
@@ -481,8 +504,9 @@ interface InfiniteScrollOptions {
|
|
|
481
504
|
readonly hasMore: boolean;
|
|
482
505
|
/**
|
|
483
506
|
* Called at most once per approach: when the sentinel comes within
|
|
484
|
-
* `rootMargin` of the root's visible area
|
|
485
|
-
* `isLoadingMore`
|
|
507
|
+
* `rootMargin` of the root's visible area. Not again until that load has
|
|
508
|
+
* finished (`isLoadingMore` back to `false`), `hasMore` has changed, or
|
|
509
|
+
* the sentinel has left `rootMargin` and come back.
|
|
486
510
|
*/
|
|
487
511
|
readonly onLoadMore?: (() => void) | undefined;
|
|
488
512
|
/** Whether a load `onLoadMore` started is still in flight. */
|
|
@@ -494,24 +518,24 @@ interface InfiniteScroll {
|
|
|
494
518
|
/**
|
|
495
519
|
* Takes the current options. Cheap when nothing changed, so a renderer may
|
|
496
520
|
* call it after every render; a new sentinel or `rootMargin` restarts the
|
|
497
|
-
* observer, and
|
|
521
|
+
* observer, and a load finishing or `hasMore` changing re-checks at once.
|
|
498
522
|
*/
|
|
499
523
|
readonly update: (options: InfiniteScrollOptions) => void;
|
|
500
|
-
/** Stops watching for good. */
|
|
524
|
+
/** Stops watching for good: a later `update` does nothing. */
|
|
501
525
|
readonly detach: () => void;
|
|
502
526
|
}
|
|
503
527
|
/**
|
|
504
528
|
* Turns a sentinel's approach to the bottom of the scrolling `root` into
|
|
505
|
-
* `onLoadMore` calls, no more than one per
|
|
506
|
-
*
|
|
529
|
+
* `onLoadMore` calls, no more than one per approach while no load is in
|
|
530
|
+
* flight.
|
|
507
531
|
*
|
|
508
|
-
*
|
|
509
|
-
* observer's last report),
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
* `hasMore` changes, so they live here rather than on any one observer.
|
|
532
|
+
* Two facts drive it: whether the sentinel is intersecting (as of the
|
|
533
|
+
* observer's last report), and the `LoadState`. Both outlive the sentinel
|
|
534
|
+
* itself, which a renderer mounts and unmounts as `hasMore` changes, so they
|
|
535
|
+
* live here rather than on any one observer.
|
|
513
536
|
*
|
|
514
|
-
* Off means off: with `hasMore` false,
|
|
537
|
+
* Off means off: with `hasMore` false, no sentinel, or once detached, no
|
|
538
|
+
* observer exists.
|
|
515
539
|
*/
|
|
516
540
|
declare function attachInfiniteScroll(root: Element, options: InfiniteScrollOptions): InfiniteScroll;
|
|
517
541
|
|
|
@@ -676,9 +700,19 @@ interface OverlayOptions extends OverlayPlacementOptions {
|
|
|
676
700
|
readonly initialFocus?: OverlayInitialFocus | undefined;
|
|
677
701
|
/**
|
|
678
702
|
* Where focus goes when the overlay detaches. Defaults to the element that
|
|
679
|
-
* had focus when it attached; `null` leaves focus alone
|
|
703
|
+
* had focus when it attached; `null` leaves focus alone, unless
|
|
704
|
+
* `returnFocusFallback` names somewhere.
|
|
680
705
|
*/
|
|
681
706
|
readonly returnFocusTo?: HTMLElement | null | undefined;
|
|
707
|
+
/**
|
|
708
|
+
* Where focus goes when there is nothing to return it to as the overlay
|
|
709
|
+
* detaches: `returnFocusTo` is `null`, or has left the page — the button a
|
|
710
|
+
* menu opened from, taken away by what the menu ran. Called then, so it
|
|
711
|
+
* can name what is on the page by that time; returning `null` leaves focus
|
|
712
|
+
* alone. Like the return itself, it applies only while focus is still in
|
|
713
|
+
* the panel, in an overlay above it, or nowhere.
|
|
714
|
+
*/
|
|
715
|
+
readonly returnFocusFallback?: (() => HTMLElement | null) | undefined;
|
|
682
716
|
/**
|
|
683
717
|
* Whether a scroll outside the panel just after input inside it — an
|
|
684
718
|
* `input` or `change` event, in the two animation frames that follow it —
|
|
@@ -728,6 +762,8 @@ interface OverlayOptions extends OverlayPlacementOptions {
|
|
|
728
762
|
* Detaching removes every listener and returns focus, but only when focus is
|
|
729
763
|
* still in the panel, in an overlay above it, or nowhere — a click that
|
|
730
764
|
* dismissed it by landing on another control leaves focus on that control.
|
|
765
|
+
* Focus goes to `returnFocusFallback` instead when the element it would
|
|
766
|
+
* return to has left the page.
|
|
731
767
|
* Any overlay still above it is dismissed with `"parent"` and detached first.
|
|
732
768
|
*/
|
|
733
769
|
declare function attachOverlay(anchor: OverlayAnchor, panel: HTMLElement, options: OverlayOptions): () => void;
|
|
@@ -759,10 +795,15 @@ interface RowVirtualizer {
|
|
|
759
795
|
/**
|
|
760
796
|
* Scrolls so row `index` is in view. A mounted row is scrolled to directly;
|
|
761
797
|
* one outside the window is jumped to at its estimated offset, then
|
|
762
|
-
* scrolled to properly once it mounts and can be measured.
|
|
798
|
+
* scrolled to properly once it mounts and can be measured. A later call
|
|
799
|
+
* replaces one still waiting for its row, and so does a row count that no
|
|
800
|
+
* longer holds that row.
|
|
763
801
|
*/
|
|
764
802
|
readonly scrollToIndex: (index: number, options?: ScrollIntoViewOptions) => void;
|
|
765
|
-
/**
|
|
803
|
+
/**
|
|
804
|
+
* Stops listening, measuring and scrolling, for good: every method does
|
|
805
|
+
* nothing after it.
|
|
806
|
+
*/
|
|
766
807
|
readonly destroy: () => void;
|
|
767
808
|
}
|
|
768
809
|
/**
|
|
@@ -877,7 +918,8 @@ interface PrintDocumentOptions {
|
|
|
877
918
|
* which a popup blocker would stop.
|
|
878
919
|
*
|
|
879
920
|
* One print at a time: a call while a print is open resolves at once
|
|
880
|
-
* without printing.
|
|
921
|
+
* without printing. Rejects, with the frame removed, if the frame is taken
|
|
922
|
+
* out of the page before it loads or the dialog fails to open.
|
|
881
923
|
*/
|
|
882
924
|
declare function printDocument(options: PrintDocumentOptions): Promise<void>;
|
|
883
925
|
|