@mdbase-dev/ui 0.1.0-beta.164 → 0.1.0-beta.165

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.
@@ -0,0 +1,75 @@
1
+ import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view";
2
+ import { type TableEdit, type TableModel, type TablePosition } from "./table-model.js";
3
+ interface Target {
4
+ tableFrom: number;
5
+ at: TablePosition;
6
+ }
7
+ /** The table cell an element is in, read from the layout: empty and missing cells have no text to hit. */
8
+ export declare function cellTarget(view: EditorView, element: Element | null): Target | null;
9
+ type Item = {
10
+ label: string;
11
+ run: (table: TableModel, at: TablePosition) => TableEdit | null;
12
+ checked?: boolean;
13
+ danger?: boolean;
14
+ disabled?: boolean;
15
+ } | "separator";
16
+ /** One open menu per editor. Built from plain buttons so it reads as a menu to assistive tech. */
17
+ declare class Menu {
18
+ readonly view: EditorView;
19
+ readonly target: Target;
20
+ readonly onClose: () => void;
21
+ readonly dom: HTMLElement;
22
+ private readonly close;
23
+ constructor(view: EditorView, target: Target, items: Item[], x: number, y: number, onClose: () => void);
24
+ private buttons;
25
+ private key;
26
+ private run;
27
+ destroy(refocus: boolean): void;
28
+ }
29
+ interface Drag {
30
+ kind: "row" | "column";
31
+ target: Target;
32
+ x: number;
33
+ y: number;
34
+ /** The row or column index it would land on; null until the pointer has moved. */
35
+ to: number | null;
36
+ }
37
+ /** Row and column grips plus add buttons, drawn over the editor rather than inside the document. */
38
+ declare class Controls {
39
+ readonly view: EditorView;
40
+ readonly layer: HTMLElement;
41
+ readonly column: HTMLButtonElement;
42
+ readonly row: HTMLButtonElement;
43
+ readonly addRow: HTMLButtonElement;
44
+ readonly addColumn: HTMLButtonElement;
45
+ readonly source: HTMLElement;
46
+ readonly drop: HTMLElement;
47
+ hover: Target | null;
48
+ target: Target | null;
49
+ menu: Menu | null;
50
+ drag: Drag | null;
51
+ /** A drag ends with a click on its grip, which must not open the menu. */
52
+ dragged: boolean;
53
+ constructor(view: EditorView);
54
+ current(): Target | null;
55
+ update(update: ViewUpdate): void;
56
+ schedule(): void;
57
+ private cellElements;
58
+ private read;
59
+ private write;
60
+ private open;
61
+ /** Opens both sections at a point, for right-click, long-press and the keyboard. */
62
+ openAt(target: Target, x: number, y: number): void;
63
+ private add;
64
+ /** Rows and columns move by dragging their grip; a press without movement stays a click. */
65
+ private startDrag;
66
+ private moveDrag;
67
+ private endDrag;
68
+ /** The rows or columns a drag can land on, by their rendered rectangles. */
69
+ private slots;
70
+ pointer(event: MouseEvent): void;
71
+ targetAt(element: Element | null): Target | null;
72
+ destroy(): void;
73
+ }
74
+ export declare function tableControls(): ViewPlugin<Controls, undefined>;
75
+ export {};