@api-client/ui 0.5.10 → 0.5.12
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/build/src/elements/code-editor/internals/CodeEditor.d.ts +197 -0
- package/build/src/elements/code-editor/internals/CodeEditor.d.ts.map +1 -0
- package/build/src/elements/code-editor/internals/CodeEditor.js +612 -0
- package/build/src/elements/code-editor/internals/CodeEditor.js.map +1 -0
- package/build/src/elements/code-editor/internals/CodeEditor.styles.d.ts +3 -0
- package/build/src/elements/code-editor/internals/CodeEditor.styles.d.ts.map +1 -0
- package/build/src/elements/code-editor/internals/CodeEditor.styles.js +150 -0
- package/build/src/elements/code-editor/internals/CodeEditor.styles.js.map +1 -0
- package/build/src/elements/code-editor/internals/Linter.d.ts +5 -0
- package/build/src/elements/code-editor/internals/Linter.d.ts.map +1 -0
- package/build/src/elements/code-editor/internals/Linter.js +74 -0
- package/build/src/elements/code-editor/internals/Linter.js.map +1 -0
- package/build/src/elements/code-editor/ui-code-editor.d.ts +13 -0
- package/build/src/elements/code-editor/ui-code-editor.d.ts.map +1 -0
- package/build/src/elements/code-editor/ui-code-editor.js +28 -0
- package/build/src/elements/code-editor/ui-code-editor.js.map +1 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -1
- package/build/src/md/chip/internals/Chip.styles.d.ts.map +1 -1
- package/build/src/md/chip/internals/Chip.styles.js +1 -0
- package/build/src/md/chip/internals/Chip.styles.js.map +1 -1
- package/demo/elements/code-editor/CodeEditorDemo.ts +212 -0
- package/demo/elements/code-editor/index.html +19 -0
- package/demo/elements/index.html +3 -0
- package/package.json +11 -3
- package/src/elements/code-editor/README.md +204 -0
- package/src/elements/code-editor/internals/CodeEditor.styles.ts +150 -0
- package/src/elements/code-editor/internals/CodeEditor.ts +595 -0
- package/src/elements/code-editor/internals/Linter.ts +87 -0
- package/src/elements/code-editor/ui-code-editor.ts +24 -0
- package/src/index.ts +10 -0
- package/src/md/chip/internals/Chip.styles.ts +1 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
export interface FunctionSchema {
|
|
3
|
+
/** Unique identifier for the function */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Function name */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Function description */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Function parameters */
|
|
10
|
+
parameters?: FunctionParameter[];
|
|
11
|
+
/** Return type description */
|
|
12
|
+
returns?: string;
|
|
13
|
+
/** Additional metadata */
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface FunctionParameter {
|
|
17
|
+
/** Parameter name */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Parameter type */
|
|
20
|
+
type: string;
|
|
21
|
+
/** Parameter description */
|
|
22
|
+
description?: string;
|
|
23
|
+
/** Whether parameter is required */
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/** Default value */
|
|
26
|
+
defaultValue?: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface Suggestion {
|
|
29
|
+
/** Unique identifier for the suggestion */
|
|
30
|
+
id: string;
|
|
31
|
+
/** Main label displayed */
|
|
32
|
+
label: string;
|
|
33
|
+
/** Supporting description text */
|
|
34
|
+
description?: string;
|
|
35
|
+
/** Suffix text (e.g., type, category) */
|
|
36
|
+
suffix?: string;
|
|
37
|
+
/** Additional data associated with the suggestion */
|
|
38
|
+
data?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface FunctionInsertEvent {
|
|
41
|
+
/** The inserted function schema */
|
|
42
|
+
functionSchema: FunctionSchema;
|
|
43
|
+
/** The position where the function was inserted */
|
|
44
|
+
position: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SuggestionInsertEvent {
|
|
47
|
+
/** The inserted suggestion */
|
|
48
|
+
suggestion: Suggestion;
|
|
49
|
+
/** The position where the suggestion was inserted */
|
|
50
|
+
position: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A CodeMirror 6 based editor component that supports function autocomplete and suggestion placeholders.
|
|
54
|
+
*
|
|
55
|
+
* Features:
|
|
56
|
+
* - Dynamic function schema loading
|
|
57
|
+
* - Autocomplete for functions and suggestions
|
|
58
|
+
* - Suggestion placeholders with double curly braces ({{suggestion}})
|
|
59
|
+
* - Keyboard navigation
|
|
60
|
+
* - Accessibility support
|
|
61
|
+
*
|
|
62
|
+
* @fires function-insert - When a function is inserted
|
|
63
|
+
* @fires suggestion-insert - When a suggestion is inserted
|
|
64
|
+
* @fires input - When the editor content changes
|
|
65
|
+
* @fires change - When the editor loses focus and content has changed
|
|
66
|
+
*/
|
|
67
|
+
export default class CodeEditor extends LitElement {
|
|
68
|
+
/**
|
|
69
|
+
* Shadow root configuration for the component.
|
|
70
|
+
* Uses 'open' mode for accessibility and delegates focus to enable proper focus management.
|
|
71
|
+
*/
|
|
72
|
+
static shadowRootOptions: ShadowRootInit;
|
|
73
|
+
/**
|
|
74
|
+
* The label text displayed as placeholder/floating label
|
|
75
|
+
*/
|
|
76
|
+
accessor label: string;
|
|
77
|
+
/**
|
|
78
|
+
* Supporting text displayed below the editor
|
|
79
|
+
*/
|
|
80
|
+
accessor supportingText: string;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the component is disabled
|
|
83
|
+
*/
|
|
84
|
+
accessor disabled: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the component is in an invalid state
|
|
87
|
+
*/
|
|
88
|
+
accessor invalid: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The name attribute for form integration
|
|
91
|
+
*/
|
|
92
|
+
accessor name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the input is required
|
|
95
|
+
*/
|
|
96
|
+
accessor required: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Placeholder text shown when editor is empty
|
|
99
|
+
*/
|
|
100
|
+
accessor placeholder: string;
|
|
101
|
+
/**
|
|
102
|
+
* The editor content value
|
|
103
|
+
*/
|
|
104
|
+
accessor value: string;
|
|
105
|
+
/**
|
|
106
|
+
* Available function schemas for autocomplete
|
|
107
|
+
*/
|
|
108
|
+
accessor functionSchemas: FunctionSchema[];
|
|
109
|
+
/**
|
|
110
|
+
* Available suggestions for autocomplete
|
|
111
|
+
*/
|
|
112
|
+
accessor suggestions: Suggestion[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether to use dark theme
|
|
115
|
+
*/
|
|
116
|
+
accessor darkTheme: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Programming language for syntax highlighting
|
|
119
|
+
*/
|
|
120
|
+
accessor language: string;
|
|
121
|
+
private accessor editorContainer;
|
|
122
|
+
private accessor hasContent;
|
|
123
|
+
private accessor isEditorFocus;
|
|
124
|
+
private editorView?;
|
|
125
|
+
private suggestionMap;
|
|
126
|
+
private functionMap;
|
|
127
|
+
private _previousValue;
|
|
128
|
+
/**
|
|
129
|
+
* Get all suggestions (placeholders) currently in the editor
|
|
130
|
+
*/
|
|
131
|
+
get activeSuggestions(): Suggestion[];
|
|
132
|
+
connectedCallback(): void;
|
|
133
|
+
disconnectedCallback(): void;
|
|
134
|
+
firstUpdated(): void;
|
|
135
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
136
|
+
/**
|
|
137
|
+
* Initialize CodeMirror editor with extensions
|
|
138
|
+
*/
|
|
139
|
+
private initializeCodeMirror;
|
|
140
|
+
/**
|
|
141
|
+
* Create completion source for functions and suggestions
|
|
142
|
+
*/
|
|
143
|
+
private createCompletionSource;
|
|
144
|
+
/**
|
|
145
|
+
* Format function information for autocomplete
|
|
146
|
+
*/
|
|
147
|
+
private formatFunctionInfo;
|
|
148
|
+
/**
|
|
149
|
+
* Format function call with parameters
|
|
150
|
+
*/
|
|
151
|
+
private formatFunctionCall;
|
|
152
|
+
/**
|
|
153
|
+
* Setup suggestion and function maps for quick lookup
|
|
154
|
+
*/
|
|
155
|
+
private setupSuggestionMaps;
|
|
156
|
+
/**
|
|
157
|
+
* Update editor content when value changes
|
|
158
|
+
*/
|
|
159
|
+
private updateEditorContent;
|
|
160
|
+
/**
|
|
161
|
+
* Update editor state (e.g., disabled state)
|
|
162
|
+
*/
|
|
163
|
+
private updateEditorState;
|
|
164
|
+
/**
|
|
165
|
+
* Handle editor content change
|
|
166
|
+
*/
|
|
167
|
+
private handleEditorChange;
|
|
168
|
+
/**
|
|
169
|
+
* Handle focus change
|
|
170
|
+
*/
|
|
171
|
+
private handleFocusChange;
|
|
172
|
+
/**
|
|
173
|
+
* Dispatch function insert event
|
|
174
|
+
*/
|
|
175
|
+
private dispatchFunctionInsert;
|
|
176
|
+
/**
|
|
177
|
+
* Dispatch suggestion insert event
|
|
178
|
+
*/
|
|
179
|
+
private dispatchSuggestionInsert;
|
|
180
|
+
/**
|
|
181
|
+
* Focus the editor
|
|
182
|
+
*/
|
|
183
|
+
focus(): void;
|
|
184
|
+
/**
|
|
185
|
+
* Get the editor's current selection
|
|
186
|
+
*/
|
|
187
|
+
getSelection(): {
|
|
188
|
+
from: number;
|
|
189
|
+
to: number;
|
|
190
|
+
} | null;
|
|
191
|
+
/**
|
|
192
|
+
* Insert text at the current cursor position
|
|
193
|
+
*/
|
|
194
|
+
insertText(text: string): void;
|
|
195
|
+
render(): TemplateResult;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=CodeEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,KAAK,CAAA;AAoB/E,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,2BAA2B;IAC3B,WA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