@stacksjs/components 0.2.854 → 0.2.857
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/CodeEditor-jg4w7e15.stx +497 -0
- package/dist/ContextMenu-43g3w5tp.stx +188 -0
- package/dist/DataGrid-7rt7v865.stx +376 -0
- package/dist/GraphView-0t3t9mec.stx +320 -0
- package/dist/JsonTree-satc4010.stx +317 -0
- package/dist/PreviewFrame-erbgvzj8.stx +257 -0
- package/dist/SplitPane-7sqfdwqa.stx +159 -0
- package/dist/code-editor/editor.js +2166 -0
- package/dist/component-api/component-api.js +36 -0
- package/dist/components/CodeBlock.d.ts +12 -5
- package/dist/context-menu/context-menu.js +575 -0
- package/dist/data-grid/data-grid.js +1244 -0
- package/dist/graph-view/graph-view.js +1408 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +34 -15
- package/dist/json-tree/json-tree.js +1121 -0
- package/dist/preview-frame/preview-frame.js +356 -0
- package/dist/split-pane/split-pane.js +364 -0
- package/dist/ui/code-editor/CodeEditor.d.ts +46 -0
- package/dist/ui/code-editor/controller.d.ts +103 -0
- package/dist/ui/code-editor/core/commands.d.ts +55 -0
- package/dist/ui/code-editor/core/completion.d.ts +40 -0
- package/dist/ui/code-editor/core/editor.d.ts +69 -0
- package/dist/ui/code-editor/core/highlight.d.ts +61 -0
- package/dist/ui/code-editor/core/history.d.ts +27 -0
- package/dist/ui/code-editor/core/index.d.ts +13 -0
- package/dist/ui/code-editor/core/keymap.d.ts +38 -0
- package/dist/ui/code-editor/core/selection.d.ts +30 -0
- package/dist/ui/code-editor/core/text.d.ts +64 -0
- package/dist/ui/code-editor/editor.d.ts +15 -0
- package/dist/ui/code-editor/index.d.ts +29 -0
- package/dist/ui/code-editor/tokenizer.d.ts +18 -0
- package/dist/ui/code-editor/view.d.ts +59 -0
- package/dist/ui/context-menu/ContextMenu.d.ts +14 -0
- package/dist/ui/context-menu/context-menu.d.ts +8 -0
- package/dist/ui/context-menu/core.d.ts +74 -0
- package/dist/ui/context-menu/index.d.ts +11 -0
- package/dist/ui/context-menu/view.d.ts +36 -0
- package/dist/ui/data-grid/DataGrid.d.ts +30 -0
- package/dist/ui/data-grid/core.d.ts +141 -0
- package/dist/ui/data-grid/data-grid.d.ts +9 -0
- package/dist/ui/data-grid/index.d.ts +20 -0
- package/dist/ui/data-grid/view.d.ts +56 -0
- package/dist/ui/graph-view/GraphView.d.ts +21 -0
- package/dist/ui/graph-view/core/edges.d.ts +34 -0
- package/dist/ui/graph-view/core/force.d.ts +10 -0
- package/dist/ui/graph-view/core/graph.d.ts +83 -0
- package/dist/ui/graph-view/core/index.d.ts +5 -0
- package/dist/ui/graph-view/core/layered.d.ts +24 -0
- package/dist/ui/graph-view/core/viewport.d.ts +34 -0
- package/dist/ui/graph-view/graph-view.d.ts +9 -0
- package/dist/ui/graph-view/index.d.ts +21 -0
- package/dist/ui/graph-view/view.d.ts +51 -0
- package/dist/ui/json-tree/JsonTree.d.ts +18 -0
- package/dist/ui/json-tree/core.d.ts +108 -0
- package/dist/ui/json-tree/index.d.ts +18 -0
- package/dist/ui/json-tree/json-tree.d.ts +10 -0
- package/dist/ui/json-tree/tinker.d.ts +84 -0
- package/dist/ui/json-tree/view.d.ts +59 -0
- package/dist/ui/preview-frame/PreviewFrame.d.ts +44 -0
- package/dist/ui/preview-frame/core.d.ts +81 -0
- package/dist/ui/preview-frame/index.d.ts +19 -0
- package/dist/ui/preview-frame/preview-frame.d.ts +8 -0
- package/dist/ui/preview-frame/view.d.ts +37 -0
- package/dist/ui/split-pane/SplitPane.d.ts +18 -0
- package/dist/ui/split-pane/core.d.ts +58 -0
- package/dist/ui/split-pane/index.d.ts +15 -0
- package/dist/ui/split-pane/split-pane.d.ts +8 -0
- package/dist/ui/split-pane/view.d.ts +27 -0
- package/dist/ui/virtual-table/index.d.ts +6 -0
- package/dist/utils/component-api.d.ts +4 -0
- package/dist/utils/highlighter.d.ts +19 -1
- package/dist/utils/highlighter.js +24 -7
- package/dist/utils/syntax-theme.d.ts +44 -0
- package/package.json +44 -4
- package/src/components/CodeBlock.stx +195 -17
- package/src/index.ts +10 -0
- package/src/ui/code-editor/CodeEditor.stx +497 -0
- package/src/ui/code-editor/README.md +135 -0
- package/src/ui/code-editor/controller.ts +517 -0
- package/src/ui/code-editor/core/commands.ts +381 -0
- package/src/ui/code-editor/core/completion.ts +212 -0
- package/src/ui/code-editor/core/editor.ts +319 -0
- package/src/ui/code-editor/core/highlight.ts +203 -0
- package/src/ui/code-editor/core/history.ts +190 -0
- package/src/ui/code-editor/core/index.ts +14 -0
- package/src/ui/code-editor/core/keymap.ts +125 -0
- package/src/ui/code-editor/core/selection.ts +104 -0
- package/src/ui/code-editor/core/text.ts +252 -0
- package/src/ui/code-editor/editor.ts +16 -0
- package/src/ui/code-editor/index.ts +46 -0
- package/src/ui/code-editor/tokenizer.ts +74 -0
- package/src/ui/code-editor/view.ts +1066 -0
- package/src/ui/context-menu/ContextMenu.stx +188 -0
- package/src/ui/context-menu/README.md +117 -0
- package/src/ui/context-menu/context-menu.ts +8 -0
- package/src/ui/context-menu/core.ts +250 -0
- package/src/ui/context-menu/index.ts +16 -0
- package/src/ui/context-menu/view.ts +540 -0
- package/src/ui/data-grid/DataGrid.stx +376 -0
- package/src/ui/data-grid/README.md +204 -0
- package/src/ui/data-grid/core.ts +813 -0
- package/src/ui/data-grid/data-grid.ts +9 -0
- package/src/ui/data-grid/index.ts +34 -0
- package/src/ui/data-grid/view.ts +806 -0
- package/src/ui/graph-view/GraphView.stx +320 -0
- package/src/ui/graph-view/README.md +210 -0
- package/src/ui/graph-view/core/edges.ts +180 -0
- package/src/ui/graph-view/core/force.ts +237 -0
- package/src/ui/graph-view/core/graph.ts +277 -0
- package/src/ui/graph-view/core/index.ts +5 -0
- package/src/ui/graph-view/core/layered.ts +256 -0
- package/src/ui/graph-view/core/viewport.ts +141 -0
- package/src/ui/graph-view/graph-view.ts +9 -0
- package/src/ui/graph-view/index.ts +35 -0
- package/src/ui/graph-view/view.ts +809 -0
- package/src/ui/json-tree/JsonTree.stx +317 -0
- package/src/ui/json-tree/README.md +193 -0
- package/src/ui/json-tree/core.ts +588 -0
- package/src/ui/json-tree/index.ts +28 -0
- package/src/ui/json-tree/json-tree.ts +10 -0
- package/src/ui/json-tree/tinker.ts +349 -0
- package/src/ui/json-tree/view.ts +665 -0
- package/src/ui/preview-frame/PreviewFrame.stx +257 -0
- package/src/ui/preview-frame/README.md +107 -0
- package/src/ui/preview-frame/core.ts +195 -0
- package/src/ui/preview-frame/index.ts +31 -0
- package/src/ui/preview-frame/preview-frame.ts +8 -0
- package/src/ui/preview-frame/view.ts +336 -0
- package/src/ui/split-pane/README.md +87 -0
- package/src/ui/split-pane/SplitPane.stx +159 -0
- package/src/ui/split-pane/core.ts +200 -0
- package/src/ui/split-pane/index.ts +24 -0
- package/src/ui/split-pane/split-pane.ts +8 -0
- package/src/ui/split-pane/view.ts +305 -0
- package/src/ui/virtual-table/index.ts +6 -0
- package/src/utils/component-api.ts +72 -0
- package/src/utils/highlighter.ts +121 -218
- package/src/utils/syntax-theme.ts +144 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Highlighting that only redoes what a change could have affected.
|
|
3
|
+
*
|
|
4
|
+
* A tokenizer reads a line given the state the previous line left it in:
|
|
5
|
+
* inside a block comment, inside a template string, or nowhere in particular.
|
|
6
|
+
* So each line is remembered with the state it started in, and after an edit the
|
|
7
|
+
* tokenizer starts at the first changed line and stops at the first unchanged
|
|
8
|
+
* line it would enter in the same state as last time. That line, and everything
|
|
9
|
+
* below it, would tokenize exactly as it already has.
|
|
10
|
+
*
|
|
11
|
+
* For an ordinary keystroke that is one line. For one that opens a block
|
|
12
|
+
* comment it is every line down to wherever the comment ends, which is the
|
|
13
|
+
* honest answer, and it is why the work is given a budget: a pass stops when
|
|
14
|
+
* the budget is spent and says where it got to, and the caller continues when
|
|
15
|
+
* it is idle. The lines on screen are done first either way.
|
|
16
|
+
*
|
|
17
|
+
* The tokenizer is passed in. This file does not import one, which keeps the
|
|
18
|
+
* editor core free of the highlighter and lets a test use a tokenizer small
|
|
19
|
+
* enough to reason about.
|
|
20
|
+
*/
|
|
21
|
+
export declare interface HighlightToken {
|
|
22
|
+
type: string
|
|
23
|
+
content: string
|
|
24
|
+
}
|
|
25
|
+
/** A tokenizer, one line at a time, with its state made explicit. */
|
|
26
|
+
export declare interface LineTokenizer<State = unknown> {
|
|
27
|
+
initialState: () => State
|
|
28
|
+
tokenizeLine: (text: string, state: State) => { tokens: HighlightToken[], endState: State }
|
|
29
|
+
stateKey: (state: State) => string
|
|
30
|
+
}
|
|
31
|
+
export declare interface HighlightedLine<State = unknown> {
|
|
32
|
+
text: string
|
|
33
|
+
tokens: HighlightToken[]
|
|
34
|
+
startKey: string
|
|
35
|
+
endState: State
|
|
36
|
+
endKey: string
|
|
37
|
+
}
|
|
38
|
+
export declare interface LineChange {
|
|
39
|
+
fromLine: number
|
|
40
|
+
removedLines: number
|
|
41
|
+
insertedLines: number
|
|
42
|
+
}
|
|
43
|
+
export declare interface HighlightPass {
|
|
44
|
+
from: number
|
|
45
|
+
to: number
|
|
46
|
+
pending: boolean
|
|
47
|
+
}
|
|
48
|
+
/** A source of line text: the document, or anything shaped like it. */
|
|
49
|
+
export declare interface LineSource {
|
|
50
|
+
readonly lineCount: number
|
|
51
|
+
line: (index: number) => string
|
|
52
|
+
}
|
|
53
|
+
export declare class LineHighlighter<State = unknown> {
|
|
54
|
+
constructor(tokenizer: LineTokenizer<State>, source: LineSource);
|
|
55
|
+
reset(tokenizer?: LineTokenizer<State>, source?: LineSource): void;
|
|
56
|
+
get(index: number): HighlightedLine<State> | null;
|
|
57
|
+
get pending(): boolean;
|
|
58
|
+
get firstDirtyLine(): number;
|
|
59
|
+
applyChange(change: LineChange): void;
|
|
60
|
+
update(options?: { through?: number, maxLines?: number }): HighlightPass;
|
|
61
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AppliedChange, ChangeSpec } from './text';
|
|
2
|
+
import type { EditorSelection } from './selection';
|
|
3
|
+
/** The changes that put the document back, in after-the-change coordinates. */
|
|
4
|
+
export declare function invertChanges(applied: readonly AppliedChange[]): ChangeSpec[];
|
|
5
|
+
export declare interface HistoryEntry {
|
|
6
|
+
changes: ChangeSpec[]
|
|
7
|
+
inverse: ChangeSpec[]
|
|
8
|
+
before: EditorSelection
|
|
9
|
+
after: EditorSelection
|
|
10
|
+
kind: string
|
|
11
|
+
time: number
|
|
12
|
+
}
|
|
13
|
+
export declare interface HistoryOptions {
|
|
14
|
+
depth?: number
|
|
15
|
+
groupDelay?: number
|
|
16
|
+
}
|
|
17
|
+
export declare class History {
|
|
18
|
+
constructor(options?: HistoryOptions);
|
|
19
|
+
get canUndo(): boolean;
|
|
20
|
+
get canRedo(): boolean;
|
|
21
|
+
get undoDepth(): number;
|
|
22
|
+
clear(): void;
|
|
23
|
+
record(applied: readonly AppliedChange[], before: EditorSelection, after: EditorSelection, kind: string, time: number): void;
|
|
24
|
+
breakGroup(): void;
|
|
25
|
+
popUndo(): HistoryEntry | undefined;
|
|
26
|
+
popRedo(): HistoryEntry | undefined;
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor core: a document, a selection, a history, commands and a keymap.
|
|
3
|
+
*
|
|
4
|
+
* Framework free and DOM free. `../view.ts` is the half that draws it.
|
|
5
|
+
*/
|
|
6
|
+
export * from './commands';
|
|
7
|
+
export * from './completion';
|
|
8
|
+
export * from './editor';
|
|
9
|
+
export * from './highlight';
|
|
10
|
+
export * from './history';
|
|
11
|
+
export * from './keymap';
|
|
12
|
+
export * from './selection';
|
|
13
|
+
export * from './text';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Whether this is a platform where the command key is Command. */
|
|
2
|
+
export declare function isApplePlatform(platform?: string): boolean;
|
|
3
|
+
/** `Mod-Shift-z` and `shift-mod-Z` as the one canonical spelling. */
|
|
4
|
+
export declare function normalizeBinding(binding: string, apple: boolean): string;
|
|
5
|
+
/** The canonical name of a key press. */
|
|
6
|
+
export declare function keyName(event: KeyLike): string;
|
|
7
|
+
/**
|
|
8
|
+
* Build a keymap for one platform.
|
|
9
|
+
*
|
|
10
|
+
* Later maps win, and binding a key to an empty string unbinds it - which is
|
|
11
|
+
* how a host takes Tab back for focus, or gives `Mod-Enter` to something else.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createKeymap(maps?: readonly Keymap[], apple?: boolean): ResolvedKeymap;
|
|
14
|
+
export declare const defaultKeymap: Keymap;
|
|
15
|
+
/**
|
|
16
|
+
* Keys to command names.
|
|
17
|
+
*
|
|
18
|
+
* A binding is written the way it is said: `Mod-Shift-Enter`. `Mod` is Command
|
|
19
|
+
* on a Mac and Control everywhere else, resolved when the keymap is built, so
|
|
20
|
+
* one table serves both and neither shows up in the other's shortcuts.
|
|
21
|
+
*
|
|
22
|
+
* The map answers with a name rather than a function. The editor core owns
|
|
23
|
+
* some commands (indent, undo) and the view owns others (run, complete), and
|
|
24
|
+
* neither should have to import the other to be bound to a key.
|
|
25
|
+
*/
|
|
26
|
+
/** The part of a keyboard event a binding is decided on. */
|
|
27
|
+
export declare interface KeyLike {
|
|
28
|
+
key: string
|
|
29
|
+
ctrlKey?: boolean
|
|
30
|
+
metaKey?: boolean
|
|
31
|
+
altKey?: boolean
|
|
32
|
+
shiftKey?: boolean
|
|
33
|
+
}
|
|
34
|
+
export declare interface ResolvedKeymap {
|
|
35
|
+
lookup: (event: KeyLike) => string | undefined
|
|
36
|
+
bindings: ReadonlyMap<string, string>
|
|
37
|
+
}
|
|
38
|
+
export type Keymap = Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ChangeSpec } from './text';
|
|
2
|
+
export declare function range(anchor: number, head?: number): SelectionRange;
|
|
3
|
+
export declare function singleSelection(anchor: number, head?: number): EditorSelection;
|
|
4
|
+
export declare function rangeFrom(value: SelectionRange): number;
|
|
5
|
+
export declare function rangeTo(value: SelectionRange): number;
|
|
6
|
+
export declare function rangeEmpty(value: SelectionRange): boolean;
|
|
7
|
+
export declare function mainRange(selection: EditorSelection): SelectionRange;
|
|
8
|
+
export declare function selectionsEqual(a: EditorSelection, b: EditorSelection): boolean;
|
|
9
|
+
export declare function clampSelection(selection: EditorSelection, length: number): EditorSelection;
|
|
10
|
+
/**
|
|
11
|
+
* Where an offset ends up after a set of changes.
|
|
12
|
+
*
|
|
13
|
+
* `changes` are in the coordinates of the document before any of them, sorted
|
|
14
|
+
* and not overlapping, which is the form a transaction holds them in.
|
|
15
|
+
*
|
|
16
|
+
* `assoc` settles the one ambiguous case, an offset exactly where text was
|
|
17
|
+
* inserted: `1` puts it after the insertion, which is what a caret wants (you
|
|
18
|
+
* typed, the caret moved), and `-1` leaves it before.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mapOffset(offset: number, changes: readonly ChangeSpec[], assoc?: -1 | 1): number;
|
|
21
|
+
export declare function mapSelection(selection: EditorSelection, changes: readonly ChangeSpec[]): EditorSelection;
|
|
22
|
+
/** `anchor` is where the selection started, `head` where the caret is. */
|
|
23
|
+
export declare interface SelectionRange {
|
|
24
|
+
anchor: number
|
|
25
|
+
head: number
|
|
26
|
+
}
|
|
27
|
+
export declare interface EditorSelection {
|
|
28
|
+
ranges: SelectionRange[]
|
|
29
|
+
main: number
|
|
30
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** One line ending throughout: a textarea reports `\n` whatever was pasted. */
|
|
2
|
+
export declare function normalizeNewlines(text: string): string;
|
|
3
|
+
/** Leading spaces and tabs of a line. */
|
|
4
|
+
export declare function leadingWhitespace(text: string): string;
|
|
5
|
+
/** Width of a run of indentation in columns, tabs advancing to the next stop. */
|
|
6
|
+
export declare function indentWidth(whitespace: string, tabSize: number): number;
|
|
7
|
+
/** Indentation of a given width, written the way the editor is set to write it. */
|
|
8
|
+
export declare function indentString(width: number, tabSize: number, insertSpaces: boolean): string;
|
|
9
|
+
/**
|
|
10
|
+
* The document: text held as lines.
|
|
11
|
+
*
|
|
12
|
+
* Lines, not one string, because everything an editor asks is a line question.
|
|
13
|
+
* Which lines are on screen, which line changed, what the indentation of this
|
|
14
|
+
* one is. A single string answers each of those with a scan from the top, and a
|
|
15
|
+
* keystroke in a two-thousand-line file would pay for all two thousand.
|
|
16
|
+
*
|
|
17
|
+
* Offsets are still the coordinate everything else speaks - a textarea reports
|
|
18
|
+
* its selection as two of them, and a change is "from here to there" - so the
|
|
19
|
+
* document converts both ways. The table of line starts behind that is rebuilt
|
|
20
|
+
* lazily and only from the first line that changed.
|
|
21
|
+
*
|
|
22
|
+
* Mutable on purpose. An edit touches one or two entries of the array, and the
|
|
23
|
+
* history keeps what it needs to reverse it (the removed text), which is all an
|
|
24
|
+
* immutable document would have bought.
|
|
25
|
+
*/
|
|
26
|
+
/** A place in the document. Both zero-based; `column` counts UTF-16 units. */
|
|
27
|
+
export declare interface Position {
|
|
28
|
+
line: number
|
|
29
|
+
column: number
|
|
30
|
+
}
|
|
31
|
+
/** Replace `from..to` with `insert`. Offsets into the document before the change. */
|
|
32
|
+
export declare interface ChangeSpec {
|
|
33
|
+
from: number
|
|
34
|
+
to: number
|
|
35
|
+
insert: string
|
|
36
|
+
}
|
|
37
|
+
/** What a change did, in the terms each consumer needs. */
|
|
38
|
+
export declare interface AppliedChange extends ChangeSpec {
|
|
39
|
+
removed: string
|
|
40
|
+
fromLine: number
|
|
41
|
+
removedLines: number
|
|
42
|
+
insertedLines: number
|
|
43
|
+
}
|
|
44
|
+
export declare interface LineInfo {
|
|
45
|
+
index: number
|
|
46
|
+
from: number
|
|
47
|
+
to: number
|
|
48
|
+
text: string
|
|
49
|
+
}
|
|
50
|
+
export declare class TextDocument {
|
|
51
|
+
constructor(text?: string);
|
|
52
|
+
get lineCount(): number;
|
|
53
|
+
get length(): number;
|
|
54
|
+
line(index: number): string;
|
|
55
|
+
toString(): string;
|
|
56
|
+
adoptText(text: string): void;
|
|
57
|
+
lineIndexAt(offset: number): number;
|
|
58
|
+
lineAt(offset: number): LineInfo;
|
|
59
|
+
lineInfo(index: number): LineInfo;
|
|
60
|
+
positionAt(offset: number): Position;
|
|
61
|
+
offsetAt(position: Position): number;
|
|
62
|
+
slice(from: number, to: number): string;
|
|
63
|
+
replace(from: number, to: number, insert: string): AppliedChange;
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The code editor without its stx template.
|
|
3
|
+
*
|
|
4
|
+
* `@stacksjs/components/code-editor`. Everything `<CodeEditor>` is made of, for
|
|
5
|
+
* a host that mounts one itself or that wants the model on its own:
|
|
6
|
+
*
|
|
7
|
+
* - `EditorCore` and the rest of `./core`: the document, selection, history,
|
|
8
|
+
* commands and keymap. No DOM, so it runs anywhere.
|
|
9
|
+
* - `EditorView`: the text field over its painted copy.
|
|
10
|
+
* - `CodeEditorController`: the two joined, with highlighting and completion.
|
|
11
|
+
*/
|
|
12
|
+
export * from './controller';
|
|
13
|
+
export * from './core/index';
|
|
14
|
+
export { createLanguageTokenizer, MAX_TOKENIZED_LINE_LENGTH, tokenizerStateKey } from './tokenizer';
|
|
15
|
+
export * from './view';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type { CodeEditorConfig, CodeEditorHooks, CompletionRequest, PopupItem, PopupState, RunDetail, RunSelectionDetail, SelectionDetail } from './controller';
|
|
2
|
+
export type { CompletionItem, Keymap, Position } from './core/index';
|
|
3
|
+
export type { CaretAnchor, DiagnosticSeverity, EditorDiagnostic, EditorViewOptions, EditorWidget } from './view';
|
|
4
|
+
export declare interface CodeEditorProps {
|
|
5
|
+
value?: string
|
|
6
|
+
language?: string
|
|
7
|
+
readonly?: boolean
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
lineNumbers?: boolean
|
|
10
|
+
highlight?: boolean
|
|
11
|
+
tabSize?: number
|
|
12
|
+
insertSpaces?: boolean
|
|
13
|
+
autoComplete?: boolean
|
|
14
|
+
completions?: import('./core/index').CompletionItem[]
|
|
15
|
+
widgets?: import('./view').EditorWidget[]
|
|
16
|
+
diagnostics?: import('./view').EditorDiagnostic[]
|
|
17
|
+
inlineDiagnostics?: boolean
|
|
18
|
+
ghostText?: string
|
|
19
|
+
keymap?: import('./core/index').Keymap
|
|
20
|
+
theme?: 'light' | 'dark'
|
|
21
|
+
height?: string
|
|
22
|
+
placeholder?: string
|
|
23
|
+
label?: string
|
|
24
|
+
autofocus?: boolean
|
|
25
|
+
name?: string
|
|
26
|
+
id?: string
|
|
27
|
+
className?: string
|
|
28
|
+
}
|
|
29
|
+
export { default as CodeEditor } from './CodeEditor';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { LineTokenizer } from './core/highlight';
|
|
2
|
+
import type { TokenizerState } from 'ts-syntax-highlighter/browser';
|
|
3
|
+
/** A string equal exactly when two tokenizer states are. */
|
|
4
|
+
export declare function tokenizerStateKey(state: TokenizerState): string;
|
|
5
|
+
/**
|
|
6
|
+
* A line tokenizer for a language, or null when the highlighter has no grammar
|
|
7
|
+
* for it. The editor shows plain text then, which is the right floor: the code
|
|
8
|
+
* is the content and the colour is decoration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createLanguageTokenizer(language: string): Promise<LineTokenizer<TokenizerState> | null>;
|
|
11
|
+
/**
|
|
12
|
+
* A line longer than this is shown plain.
|
|
13
|
+
*
|
|
14
|
+
* A minified bundle is one line of a hundred thousand characters. Nobody reads
|
|
15
|
+
* it, some grammars are quadratic in it, and it would be re-tokenized whole on
|
|
16
|
+
* every key typed into it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MAX_TOKENIZED_LINE_LENGTH: unknown;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { EditorCore, HighlightedLine, LineTokenizer, Position, ResolvedKeymap, Transaction } from './core/index';
|
|
2
|
+
/** One line as HTML: a span per coloured run, plain text left unwrapped. */
|
|
3
|
+
export declare function renderLineHtml(line: HighlightedLine | null, text: string): string;
|
|
4
|
+
/** Something shown beside or after a line: a result, a note, an error. */
|
|
5
|
+
export declare interface EditorWidget {
|
|
6
|
+
line: number
|
|
7
|
+
column?: number | 'end'
|
|
8
|
+
text: string
|
|
9
|
+
kind?: string
|
|
10
|
+
className?: string
|
|
11
|
+
}
|
|
12
|
+
/** A range with something to say about it, drawn as a squiggle. */
|
|
13
|
+
export declare interface EditorDiagnostic {
|
|
14
|
+
from: Position
|
|
15
|
+
to: Position
|
|
16
|
+
message: string
|
|
17
|
+
severity?: DiagnosticSeverity
|
|
18
|
+
source?: string
|
|
19
|
+
}
|
|
20
|
+
/** Where the caret is, for anything that has to be placed beside it. */
|
|
21
|
+
export declare interface CaretAnchor {
|
|
22
|
+
left: number
|
|
23
|
+
top: number
|
|
24
|
+
bottom: number
|
|
25
|
+
spaceAbove: number
|
|
26
|
+
spaceBelow: number
|
|
27
|
+
}
|
|
28
|
+
export declare interface EditorViewOptions {
|
|
29
|
+
core: EditorCore
|
|
30
|
+
keymap: ResolvedKeymap
|
|
31
|
+
onTransaction?: (transaction: Transaction) => void
|
|
32
|
+
onCommand?: (name: string) => boolean
|
|
33
|
+
onKeydown?: (event: KeyboardEvent) => boolean
|
|
34
|
+
onFocus?: () => void
|
|
35
|
+
onBlur?: () => void
|
|
36
|
+
onGhost?: (outcome: 'accept' | 'dismiss', text: string) => void
|
|
37
|
+
inlineDiagnostics?: boolean
|
|
38
|
+
}
|
|
39
|
+
export type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
|
|
40
|
+
export declare class EditorView {
|
|
41
|
+
readonly core: EditorCore;
|
|
42
|
+
constructor(root: HTMLElement, options: EditorViewOptions);
|
|
43
|
+
setKeymap(keymap: ResolvedKeymap): void;
|
|
44
|
+
setLineNumbers(show: boolean): void;
|
|
45
|
+
setReadOnly(readOnly: boolean): void;
|
|
46
|
+
setTokenizer<State>(tokenizer: LineTokenizer<State> | null): void;
|
|
47
|
+
layout(): void;
|
|
48
|
+
render(): void;
|
|
49
|
+
caretAnchor(offset?: number): CaretAnchor;
|
|
50
|
+
revealCaret(): void;
|
|
51
|
+
focus(): void;
|
|
52
|
+
get hasFocus(): boolean;
|
|
53
|
+
setWidgets(widgets: readonly EditorWidget[]): void;
|
|
54
|
+
setDiagnostics(diagnostics: readonly EditorDiagnostic[]): void;
|
|
55
|
+
setGhostText(text: string | null, outcome?: 'accept' | 'dismiss' | null): void;
|
|
56
|
+
get ghostText(): string;
|
|
57
|
+
acceptGhost(): boolean;
|
|
58
|
+
destroy(): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DefineComponent } from '@stacksjs/stx';
|
|
2
|
+
declare const __dtsx_component__: __DtsxStxComponentType;
|
|
3
|
+
/*
|
|
4
|
+
* The items, when they arrive as a plain prop. A bound list (`:items="list()"`)
|
|
5
|
+
* or a function that builds one for the element clicked on (`:items="menuFor"`)
|
|
6
|
+
* is read live by the client script.
|
|
7
|
+
*/
|
|
8
|
+
export declare const items: unknown;
|
|
9
|
+
export declare const label: unknown;
|
|
10
|
+
export declare const disabled: ReturnType<typeof $bool>;
|
|
11
|
+
export declare const className: unknown;
|
|
12
|
+
export declare const menuId: unknown;
|
|
13
|
+
declare type __DtsxStxComponentType = DefineComponent<{ items?: unknown, label?: string, disabled?: unknown, className?: string, id?: string }> & { readonly __stxEmits?: ["select", "open", "close"] }
|
|
14
|
+
export default __dtsx_component__;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settle a list of items: every item gets an id, and separators that divide
|
|
3
|
+
* nothing are dropped (one at either end, or two in a row), so a host can
|
|
4
|
+
* build a list out of optional groups without tidying it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveItems(items: readonly MenuItem[] | null | undefined, parent?: number[]): ResolvedItem[];
|
|
7
|
+
/** Whether the keyboard can land on an item. A disabled item can be read, so it can; a separator cannot. */
|
|
8
|
+
export declare function isFocusable(item: MenuItem | undefined): boolean;
|
|
9
|
+
/** Whether choosing the item does anything. */
|
|
10
|
+
export declare function isActionable(item: MenuItem | undefined): boolean;
|
|
11
|
+
export declare function hasSubmenu(item: MenuItem | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The item an arrow key moves to from `from`, wrapping at the ends.
|
|
14
|
+
* `from` of -1 is "nothing yet": down goes to the first item and up to the last.
|
|
15
|
+
*/
|
|
16
|
+
export declare function stepIndex(items: readonly MenuItem[], from: number, direction: 1 | -1): number;
|
|
17
|
+
export declare function firstIndex(items: readonly MenuItem[]): number;
|
|
18
|
+
export declare function lastIndex(items: readonly MenuItem[]): number;
|
|
19
|
+
/**
|
|
20
|
+
* The item a typed string jumps to. A single repeated letter cycles through
|
|
21
|
+
* the items starting with it; anything longer is a prefix, searched from the
|
|
22
|
+
* current item so typing more keeps the match.
|
|
23
|
+
*/
|
|
24
|
+
export declare function typeAheadIndex(items: readonly MenuItem[], from: number, typed: string): number;
|
|
25
|
+
/** Find an item anywhere in the tree by id. */
|
|
26
|
+
export declare function findItem(items: readonly ResolvedItem[], id: string): ResolvedItem | null;
|
|
27
|
+
/**
|
|
28
|
+
* Where a menu opened at a point goes.
|
|
29
|
+
*
|
|
30
|
+
* Down and to the right of the point, as a pointer expects. A menu that would
|
|
31
|
+
* leave the viewport on a side opens the other way from the point instead; one
|
|
32
|
+
* that fits neither way is pushed back inside, so its first items stay
|
|
33
|
+
* reachable.
|
|
34
|
+
*/
|
|
35
|
+
export declare function placeAtPoint(point: MenuPoint, menu: MenuSize, viewport: MenuSize, margin?: number): MenuPoint;
|
|
36
|
+
/** Where a menu anchored to an element goes: under it, aligned to its left edge, or above when there is no room. */
|
|
37
|
+
export declare function placeAtBox(anchor: MenuBox, menu: MenuSize, viewport: MenuSize, margin?: number, gap?: number): MenuPoint;
|
|
38
|
+
/**
|
|
39
|
+
* Where a submenu goes: beside the item that opens it, level with it. To the
|
|
40
|
+
* right when it fits, otherwise to the left, and pushed up when it would run
|
|
41
|
+
* off the bottom. `overlap` tucks it slightly under its parent's edge.
|
|
42
|
+
*/
|
|
43
|
+
export declare function placeSubmenu(item: MenuBox, menu: MenuSize, viewport: MenuSize, margin?: number, overlap?: number): MenuPoint & { side: 'right' | 'left' };
|
|
44
|
+
/** A shortcut as this platform writes it: `⇧⌘P` on a Mac, `Ctrl+Shift+P` elsewhere. */
|
|
45
|
+
export declare function formatShortcut(shortcut: string | undefined, apple: boolean): string;
|
|
46
|
+
/** The same shortcut for `aria-keyshortcuts`, which has its own spelling. */
|
|
47
|
+
export declare function ariaShortcut(shortcut: string | undefined, apple: boolean): string;
|
|
48
|
+
/**
|
|
49
|
+
* What a menu is and how one is moved through. No DOM.
|
|
50
|
+
*
|
|
51
|
+
* The items, which of them the arrow keys can land on, what a typed letter
|
|
52
|
+
* jumps to, where a menu goes so that it stays on screen, and how a shortcut
|
|
53
|
+
* is written on this platform.
|
|
54
|
+
*/
|
|
55
|
+
export declare interface MenuItem {
|
|
56
|
+
id?: string
|
|
57
|
+
label?: string
|
|
58
|
+
shortcut?: string
|
|
59
|
+
disabled?: boolean
|
|
60
|
+
separator?: boolean
|
|
61
|
+
children?: MenuItem[]
|
|
62
|
+
checked?: boolean
|
|
63
|
+
danger?: boolean
|
|
64
|
+
value?: unknown
|
|
65
|
+
}
|
|
66
|
+
/** An item as the view draws it: with its id settled and its place in the tree. */
|
|
67
|
+
export declare interface ResolvedItem extends MenuItem {
|
|
68
|
+
id: string
|
|
69
|
+
path: number[]
|
|
70
|
+
children?: ResolvedItem[]
|
|
71
|
+
}
|
|
72
|
+
export declare interface MenuPoint { x: number, y: number }
|
|
73
|
+
export declare interface MenuSize { width: number, height: number }
|
|
74
|
+
export declare interface MenuBox { left: number, top: number, right: number, bottom: number }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MenuItem } from './core';
|
|
2
|
+
export declare interface ContextMenuProps {
|
|
3
|
+
items?: MenuItem[] | ((target: Element | null) => MenuItem[] | null | undefined)
|
|
4
|
+
label?: string
|
|
5
|
+
disabled?: boolean
|
|
6
|
+
id?: string
|
|
7
|
+
className?: string
|
|
8
|
+
}
|
|
9
|
+
export { default as ContextMenu } from './ContextMenu';
|
|
10
|
+
export * from './core';
|
|
11
|
+
export * from './view';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MenuItem, MenuPoint } from './core';
|
|
2
|
+
export declare interface ContextMenuOptions {
|
|
3
|
+
items?: MenuItemsSource | null
|
|
4
|
+
label?: string
|
|
5
|
+
disabled?: boolean
|
|
6
|
+
apple?: boolean
|
|
7
|
+
}
|
|
8
|
+
export declare interface MenuSelectDetail {
|
|
9
|
+
item: MenuItem
|
|
10
|
+
id: string
|
|
11
|
+
path: number[]
|
|
12
|
+
target: Element | null
|
|
13
|
+
}
|
|
14
|
+
export declare interface MenuOpenDetail {
|
|
15
|
+
x: number
|
|
16
|
+
y: number
|
|
17
|
+
target: Element | null
|
|
18
|
+
keyboard: boolean
|
|
19
|
+
}
|
|
20
|
+
export declare interface ContextMenuCallbacks {
|
|
21
|
+
onSelect?: (detail: MenuSelectDetail) => void
|
|
22
|
+
onOpen?: (detail: MenuOpenDetail) => void
|
|
23
|
+
onClose?: (detail: { reason: MenuCloseReason }) => void
|
|
24
|
+
}
|
|
25
|
+
export type MenuItemsSource = MenuItem[] | ((target: Element | null) => MenuItem[] | null | undefined);
|
|
26
|
+
export type MenuCloseReason = 'select' | 'escape' | 'outside' | 'blur' | 'tab' | 'api';
|
|
27
|
+
export declare class ContextMenuView {
|
|
28
|
+
constructor(root: HTMLElement, options?: ContextMenuOptions, callbacks?: ContextMenuCallbacks);
|
|
29
|
+
get isOpen(): boolean;
|
|
30
|
+
setItems(items: MenuItemsSource | null | undefined): void;
|
|
31
|
+
setDisabled(disabled: boolean): void;
|
|
32
|
+
setLabel(label: string): void;
|
|
33
|
+
open(at: MenuPoint | Element, items?: MenuItem[] | null, options?: { keyboard?: boolean, target?: Element | null }): boolean;
|
|
34
|
+
close(reason?: MenuCloseReason, restoreFocus?: boolean): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DefineComponent } from '@stacksjs/stx';
|
|
2
|
+
declare const __dtsx_component__: __DtsxStxComponentType;
|
|
3
|
+
/*
|
|
4
|
+
* Rows written into the page as a plain prop. A bound one (`:rows="rows()"`)
|
|
5
|
+
* is read live by the client script; this is what it starts from.
|
|
6
|
+
*/
|
|
7
|
+
export declare const rows: unknown;
|
|
8
|
+
export declare const columns: unknown;
|
|
9
|
+
export declare const rowHeight: unknown;
|
|
10
|
+
export declare const headerHeight: unknown;
|
|
11
|
+
/* A CSS length. `100%` fills a sized parent, which is what a pane wants. */
|
|
12
|
+
export declare const height: unknown;
|
|
13
|
+
export declare const filterable: unknown;
|
|
14
|
+
export declare const exportable: unknown;
|
|
15
|
+
export declare const selectable: unknown;
|
|
16
|
+
export declare const contextMenu: ReturnType<typeof $bool>;
|
|
17
|
+
export declare const filter: boolean;
|
|
18
|
+
export declare const label: unknown;
|
|
19
|
+
export declare const fileName: unknown;
|
|
20
|
+
export declare const className: unknown;
|
|
21
|
+
/*
|
|
22
|
+
* Ids unique to this instance: the grid, its filter and its status line all
|
|
23
|
+
* have to be findable when two grids share a page.
|
|
24
|
+
*/
|
|
25
|
+
export declare const gridId: unknown;
|
|
26
|
+
export declare const filterId: string;
|
|
27
|
+
export declare const statusId: string;
|
|
28
|
+
export declare const hasToolbar: unknown;
|
|
29
|
+
declare type __DtsxStxComponentType = DefineComponent<{ rows?: unknown, columns?: unknown, rowHeight?: unknown, headerHeight?: unknown, height?: string, filterable?: unknown, exportable?: unknown, selectable?: unknown, contextMenu?: unknown, filter?: unknown, label?: string, fileName?: string, className?: string, id?: string }> & { readonly __stxEmits?: ["sort", "filter", "select", "cell", "activate", "copy", "export", "context"] }
|
|
30
|
+
export default __dtsx_component__;
|