@aquera/nile-elements 0.1.1 → 0.1.3
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/README.md +8 -0
- package/demo/variables.css +0 -556
- package/dist/nile-code-editor/extensionSetup.cjs.js +6 -6
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-drawer/nile-drawer.css.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.css.cjs.js.map +1 -1
- package/dist/nile-drawer/nile-drawer.css.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.esm.js +2 -2
- package/dist/src/nile-code-editor/extensionSetup.d.ts +8 -9
- package/dist/src/nile-code-editor/extensionSetup.js +0 -13
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +49 -15
- package/dist/src/nile-code-editor/nile-code-editor.js +195 -115
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-drawer/nile-drawer.css.js +1 -1
- package/dist/src/nile-drawer/nile-drawer.css.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.js +32 -2
- package/dist/src/nile-form-help-text/nile-form-help-text.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/plop-templates/lit/lit.ts.hbs +2 -2
- package/src/nile-code-editor/extensionSetup.ts +8 -23
- package/src/nile-code-editor/nile-code-editor.ts +209 -124
- package/src/nile-drawer/nile-drawer.css.ts +1 -1
- package/src/nile-form-help-text/nile-form-help-text.ts +37 -3
- package/vscode-html-custom-data.json +13 -2
@@ -10,17 +10,17 @@ import { customElement, query, property } from 'lit/decorators.js';
|
|
10
10
|
import { styles } from './nile-code-editor.css';
|
11
11
|
import { EditorView } from 'codemirror';
|
12
12
|
import { placeholder } from '@codemirror/view';
|
13
|
-
import { Compartment, EditorState
|
13
|
+
import { Compartment, EditorState } from '@codemirror/state';
|
14
14
|
import { lineNumbers } from '@codemirror/view';
|
15
15
|
import { javascript, javascriptLanguage, } from '@codemirror/lang-javascript';
|
16
16
|
import { sql } from '@codemirror/lang-sql';
|
17
17
|
import { json } from '@codemirror/lang-json';
|
18
|
+
import { html as htmlLang } from '@codemirror/lang-html';
|
18
19
|
import { autocompletion } from '@codemirror/autocomplete';
|
19
20
|
import NileElement from '../internal/nile-element';
|
20
21
|
import { basicSetup } from './extensionSetup';
|
21
22
|
import { classMap } from 'lit/directives/class-map.js';
|
22
23
|
import { Theme } from './theme';
|
23
|
-
const TIME_OUT_DURATION = 200;
|
24
24
|
// Choose the appropriate mode for your use case
|
25
25
|
/**
|
26
26
|
* Nile icon component.
|
@@ -35,6 +35,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
35
35
|
this.expandIcon = "expand-2";
|
36
36
|
this.placeholder = "";
|
37
37
|
this.customAutoCompletions = {};
|
38
|
+
this.customCompletionsPaths = [];
|
38
39
|
this.language = 'javascript';
|
39
40
|
this.errorMessage = '';
|
40
41
|
this.error = false;
|
@@ -47,6 +48,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
47
48
|
this.expandable = true;
|
48
49
|
this.readonly = false;
|
49
50
|
this.debounce = false;
|
51
|
+
this.debounceTimeout = 200;
|
50
52
|
this.timeOut = null;
|
51
53
|
// Compartments for initialiazing and switching extensions
|
52
54
|
this.lineNumbersComp = new Compartment();
|
@@ -54,6 +56,19 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
54
56
|
this.readOnlyComp = new Compartment();
|
55
57
|
this.customCompletionComp = new Compartment();
|
56
58
|
this.placeholderComp = new Compartment();
|
59
|
+
/**
|
60
|
+
* Custom autocomplete handler for code editor suggestions
|
61
|
+
* @param context CompletionContext from CodeMirror
|
62
|
+
* @returns CompletionResult with suggestions or null if no suggestions
|
63
|
+
*/
|
64
|
+
this.customAutocomplete = (context) => {
|
65
|
+
// Getting the valid last line, last text from the code editor
|
66
|
+
const text = context.state.doc.sliceString(0, context.pos);
|
67
|
+
const lastWord = text.split('\n').at(-1)?.split(' ').at(-1) || '';
|
68
|
+
const [textBeforeCursor, baseTextAfterSeperation] = splitStringAtLastSeparator(lastWord);
|
69
|
+
return this.getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation)
|
70
|
+
|| this.getTopLevelSuggestions(context, textBeforeCursor);
|
71
|
+
};
|
57
72
|
this.insertBetweenCode = (text) => {
|
58
73
|
const transaction = this.view.state.changeByRange(range => {
|
59
74
|
const { from, to } = range;
|
@@ -61,72 +76,6 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
61
76
|
});
|
62
77
|
this.view.dispatch(transaction);
|
63
78
|
};
|
64
|
-
this.customAutocomplete = (context) => {
|
65
|
-
// Getting the valid last line, last text from the code editor
|
66
|
-
let text = context.state.doc.sliceString(0, context.pos);
|
67
|
-
const [textBeforeCursor, baseTextAfterSeperation] = this.splitStringAtLastSeparator(text.split('\n').at(-1)?.split(' ').at(-1) + '');
|
68
|
-
const textAfterSeperation = baseTextAfterSeperation.replace(/["'\[]/g, '');
|
69
|
-
const isInString = textAfterSeperation != baseTextAfterSeperation;
|
70
|
-
const isBracket = textBeforeCursor.at(-1) == '[';
|
71
|
-
const isDot = textBeforeCursor.at(-1) == '.';
|
72
|
-
if (!this.isValidPath(textBeforeCursor))
|
73
|
-
return { from: context.pos, options: [] };
|
74
|
-
if (['.', '['].includes(textBeforeCursor[textBeforeCursor.length - 1])) {
|
75
|
-
// Parse the path for dot or bracket notation
|
76
|
-
const path = this.parsePath(textBeforeCursor);
|
77
|
-
if (path) {
|
78
|
-
if (isDot && isInString)
|
79
|
-
return null;
|
80
|
-
let resolved = this.resolveNestedProperties(this.customAutoCompletions, path);
|
81
|
-
if (textAfterSeperation) {
|
82
|
-
const obj = {};
|
83
|
-
Object.keys(resolved).forEach((key) => {
|
84
|
-
if (key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())) {
|
85
|
-
obj[key] = resolved[key];
|
86
|
-
}
|
87
|
-
});
|
88
|
-
resolved = obj;
|
89
|
-
}
|
90
|
-
// If resolved is an object, provide its keys as suggestions
|
91
|
-
if (resolved && typeof resolved === 'object') {
|
92
|
-
return {
|
93
|
-
from: context.pos - textAfterSeperation.length,
|
94
|
-
options: Object.keys(resolved).map((key) => ({
|
95
|
-
label: key,
|
96
|
-
type: 'property',
|
97
|
-
info: `Key of ${path[path.length - 1]}`,
|
98
|
-
apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) ? "\'" + key + "\'" : key,
|
99
|
-
boost: 999
|
100
|
-
})),
|
101
|
-
};
|
102
|
-
}
|
103
|
-
}
|
104
|
-
}
|
105
|
-
// Match for top-level object suggestions, e.g., "a"
|
106
|
-
const baseMatch = textBeforeCursor.match(/([a-zA-Z_$][\w$]*)$/);
|
107
|
-
if (baseMatch) {
|
108
|
-
const optionsList = Object.keys(this.customAutoCompletions).filter(key => key.toLowerCase().startsWith(textBeforeCursor.toLowerCase()));
|
109
|
-
return {
|
110
|
-
from: context.pos - baseMatch[1].length,
|
111
|
-
options: optionsList.map((key) => ({
|
112
|
-
label: key,
|
113
|
-
type: 'property',
|
114
|
-
apply: key,
|
115
|
-
boost: 999
|
116
|
-
}))
|
117
|
-
};
|
118
|
-
}
|
119
|
-
// Default to an empty list if no match
|
120
|
-
return null;
|
121
|
-
};
|
122
|
-
this.resolveNestedProperties = (obj, keys) => {
|
123
|
-
return keys.reduce((acc, key) => {
|
124
|
-
if (acc && typeof acc === 'object') {
|
125
|
-
return acc[key];
|
126
|
-
}
|
127
|
-
return null;
|
128
|
-
}, obj);
|
129
|
-
};
|
130
79
|
/* #endregion */
|
131
80
|
}
|
132
81
|
/**
|
@@ -189,7 +138,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
189
138
|
]
|
190
139
|
});
|
191
140
|
}
|
192
|
-
if (changedProperties.has('customAutoCompletions') || changedProperties.has('
|
141
|
+
if (changedProperties.has('customAutoCompletions') || changedProperties.has('customCompletionsPaths')) {
|
193
142
|
this.view.dispatch({
|
194
143
|
effects: [
|
195
144
|
this.customCompletionComp.reconfigure(javascriptLanguage.data.of({
|
@@ -254,7 +203,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
254
203
|
autocomplete: this.customAutocomplete
|
255
204
|
}));
|
256
205
|
this.viewState = EditorState.create({
|
257
|
-
doc: !this.multiline ?
|
206
|
+
doc: !this.multiline ? convertToSingleLine(this.value) : this.value,
|
258
207
|
extensions: [
|
259
208
|
basicSetup({
|
260
209
|
highlightActiveLine: false,
|
@@ -281,28 +230,98 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
281
230
|
});
|
282
231
|
return this.viewState;
|
283
232
|
}
|
233
|
+
/**
|
234
|
+
* Gets nested property suggestions based on the current path
|
235
|
+
* @param context CompletionContext from CodeMirror
|
236
|
+
* @param textBeforeCursor Text before cursor position
|
237
|
+
* @param baseTextAfterSeperation Text after the last separator (. or [)
|
238
|
+
* @returns CompletionResult with nested suggestions or null
|
239
|
+
*/
|
240
|
+
getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation) {
|
241
|
+
// Return early if not a valid path or not ending with . or [
|
242
|
+
if (!isValidPath(textBeforeCursor) || !['.', '['].includes(textBeforeCursor.at(-1))) {
|
243
|
+
return null;
|
244
|
+
}
|
245
|
+
const path = parsePath(textBeforeCursor);
|
246
|
+
if (!path)
|
247
|
+
return null;
|
248
|
+
const textAfterSeperation = baseTextAfterSeperation.replace(/["'\[]/g, '');
|
249
|
+
const isInString = textAfterSeperation !== baseTextAfterSeperation;
|
250
|
+
const isBracket = textBeforeCursor.at(-1) === '[';
|
251
|
+
// Return null if we're in a string after a dot
|
252
|
+
if (textBeforeCursor.at(-1) === '.' && isInString)
|
253
|
+
return null;
|
254
|
+
// Get nested properties and filter by text after separation if it exists
|
255
|
+
let resolved = resolveNestedProperties(this.customAutoCompletions, path);
|
256
|
+
if (!resolved || typeof resolved !== 'object')
|
257
|
+
return null;
|
258
|
+
if (textAfterSeperation) {
|
259
|
+
resolved = Object.fromEntries(Object.entries(resolved).filter(([key]) => key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())));
|
260
|
+
}
|
261
|
+
return {
|
262
|
+
from: context.pos - textAfterSeperation.length,
|
263
|
+
options: Object.keys(resolved).map(key => ({
|
264
|
+
label: key,
|
265
|
+
type: 'property',
|
266
|
+
info: `Key of ${path[path.length - 1]}`,
|
267
|
+
apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString)
|
268
|
+
? `'${key}'`
|
269
|
+
: key,
|
270
|
+
boost: 999
|
271
|
+
}))
|
272
|
+
};
|
273
|
+
}
|
274
|
+
/**
|
275
|
+
* Gets top level suggestions based on custom completions and paths
|
276
|
+
* @param context CompletionContext from CodeMirror
|
277
|
+
* @param textBeforeCursor Text before cursor position
|
278
|
+
* @returns CompletionResult with top level suggestions or null
|
279
|
+
*/
|
280
|
+
getTopLevelSuggestions(context, textBeforeCursor) {
|
281
|
+
const baseMatch = textBeforeCursor.match(/([a-zA-Z_$][\w$]*)$/);
|
282
|
+
if (!baseMatch)
|
283
|
+
return null;
|
284
|
+
const optionsList = Object.keys(this.customAutoCompletions).filter(key => Object.keys(this.customAutoCompletions[key]).length &&
|
285
|
+
key.toLowerCase().startsWith(textBeforeCursor.toLowerCase()));
|
286
|
+
const options = optionsList.map((key) => ({
|
287
|
+
label: key,
|
288
|
+
type: 'property',
|
289
|
+
apply: key,
|
290
|
+
boost: 999
|
291
|
+
}));
|
292
|
+
if (this.customCompletionsPaths.length) {
|
293
|
+
this.customCompletionsPaths
|
294
|
+
.filter(path => path.toLocaleLowerCase().includes(textBeforeCursor.toLocaleLowerCase()))
|
295
|
+
.map(path => {
|
296
|
+
options.push({
|
297
|
+
label: '' + path,
|
298
|
+
type: 'property',
|
299
|
+
apply: '' + path,
|
300
|
+
boost: 998
|
301
|
+
});
|
302
|
+
});
|
303
|
+
}
|
304
|
+
return {
|
305
|
+
from: context.pos - baseMatch[1].length,
|
306
|
+
options: options
|
307
|
+
};
|
308
|
+
}
|
309
|
+
emitAfterTimeout(value) {
|
310
|
+
if (this.timeOut)
|
311
|
+
clearTimeout(this.timeOut);
|
312
|
+
this.timeOut = setTimeout(() => this.emit('nile-change', value, false), this.debounceTimeout);
|
313
|
+
}
|
284
314
|
singleLineMultiLineToggle() {
|
285
315
|
this.view.dispatch({
|
286
316
|
changes: {
|
287
317
|
from: 0,
|
288
318
|
to: this.view.state.doc.length,
|
289
319
|
insert: !this.multiline
|
290
|
-
?
|
320
|
+
? convertToSingleLine(this.value)
|
291
321
|
: this.value,
|
292
322
|
},
|
293
323
|
});
|
294
324
|
}
|
295
|
-
convertToSingleLine(code) {
|
296
|
-
if (!code)
|
297
|
-
return '';
|
298
|
-
// Remove line breaks and unnecessary whitespace
|
299
|
-
return code.replace(/\s+/g, ' ').trim();
|
300
|
-
}
|
301
|
-
emitAfterTimeout(value) {
|
302
|
-
if (this.timeOut)
|
303
|
-
clearTimeout(this.timeOut);
|
304
|
-
this.timeOut = setTimeout(() => this.emit('nile-change', value, false), TIME_OUT_DURATION);
|
305
|
-
}
|
306
325
|
//EXTENSION CONFIGURATIONS
|
307
326
|
getLineNumbersExension() {
|
308
327
|
return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];
|
@@ -313,6 +332,8 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
313
332
|
return sql();
|
314
333
|
case 'json':
|
315
334
|
return json();
|
335
|
+
case 'html':
|
336
|
+
return htmlLang();
|
316
337
|
default:
|
317
338
|
return javascript();
|
318
339
|
}
|
@@ -329,39 +350,6 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
329
350
|
restrictSingleLine() {
|
330
351
|
return EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr);
|
331
352
|
}
|
332
|
-
parsePath(text) {
|
333
|
-
const regex = /([a-zA-Z_$][\w$]*)(\[(?:[^\]]+)\]|\.[a-zA-Z_$][\w$]*)*/g;
|
334
|
-
const matches = [...text.matchAll(regex)];
|
335
|
-
if (matches.length > 0) {
|
336
|
-
const base = matches[0][1]; // The base object name
|
337
|
-
const keys = [base];
|
338
|
-
// Extract keys from dot or bracket notation
|
339
|
-
const pathMatches = text.match(/\[(.*?)\]|\.(\w+)/g) || [];
|
340
|
-
for (const match of pathMatches) {
|
341
|
-
if (match.startsWith('[')) {
|
342
|
-
keys.push(match.slice(1, -1).replace(/['"]/g, '')); // Remove brackets and quotes
|
343
|
-
}
|
344
|
-
else if (match.startsWith('.')) {
|
345
|
-
keys.push(match.slice(1));
|
346
|
-
}
|
347
|
-
}
|
348
|
-
return keys;
|
349
|
-
}
|
350
|
-
return null;
|
351
|
-
}
|
352
|
-
;
|
353
|
-
isValidPath(path) {
|
354
|
-
// Regex to validate the format of the string
|
355
|
-
const regex = /^([a-zA-Z_$][\w$]*)(\.[a-zA-Z_$][\w$]*|\[\s*(['"]?[a-zA-Z0-9_$]*['"]?)\s*\])*([\.\[])?$/;
|
356
|
-
// Test the string against the regex
|
357
|
-
return regex.test(path);
|
358
|
-
}
|
359
|
-
splitStringAtLastSeparator(input) {
|
360
|
-
const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));
|
361
|
-
if (lastSeparatorIndex === -1)
|
362
|
-
return [input, ''];
|
363
|
-
return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];
|
364
|
-
}
|
365
353
|
};
|
366
354
|
__decorate([
|
367
355
|
query('.code-mirror')
|
@@ -378,6 +366,9 @@ __decorate([
|
|
378
366
|
__decorate([
|
379
367
|
property({ type: Object, reflect: true, attribute: true })
|
380
368
|
], NileCodeEditor.prototype, "customAutoCompletions", void 0);
|
369
|
+
__decorate([
|
370
|
+
property({ type: Array, reflect: true, attribute: true })
|
371
|
+
], NileCodeEditor.prototype, "customCompletionsPaths", void 0);
|
381
372
|
__decorate([
|
382
373
|
property({ type: String, reflect: true, attribute: true })
|
383
374
|
], NileCodeEditor.prototype, "language", void 0);
|
@@ -414,9 +405,98 @@ __decorate([
|
|
414
405
|
__decorate([
|
415
406
|
property({ type: Boolean, reflect: true, attribute: true })
|
416
407
|
], NileCodeEditor.prototype, "debounce", void 0);
|
408
|
+
__decorate([
|
409
|
+
property({ type: Number, reflect: true, attribute: true })
|
410
|
+
], NileCodeEditor.prototype, "debounceTimeout", void 0);
|
417
411
|
NileCodeEditor = __decorate([
|
418
412
|
customElement('nile-code-editor')
|
419
413
|
], NileCodeEditor);
|
420
414
|
export { NileCodeEditor };
|
421
415
|
export default NileCodeEditor;
|
416
|
+
/**
|
417
|
+
* Parses a string path into an array of keys representing nested object access
|
418
|
+
* @param text The path string to parse (e.g. "foo.bar[0].baz")
|
419
|
+
* @returns Array of keys if valid path, null otherwise
|
420
|
+
* @example
|
421
|
+
* parsePath("foo.bar[0]") // returns ["foo", "bar", "0"]
|
422
|
+
* parsePath("invalid") // returns null
|
423
|
+
*/
|
424
|
+
function parsePath(text) {
|
425
|
+
const regex = /([a-zA-Z_$][\w$]*)(\[(?:[^\]]+)\]|\.[a-zA-Z_$][\w$]*)*/g;
|
426
|
+
const matches = [...text.matchAll(regex)];
|
427
|
+
if (matches.length > 0) {
|
428
|
+
const base = matches[0][1]; // The base object name
|
429
|
+
const keys = [base];
|
430
|
+
// Extract keys from dot or bracket notation
|
431
|
+
const pathMatches = text.match(/\[(.*?)\]|\.(\w+)/g) || [];
|
432
|
+
for (const match of pathMatches) {
|
433
|
+
if (match.startsWith('[')) {
|
434
|
+
keys.push(match.slice(1, -1).replace(/['"]/g, '')); // Remove brackets and quotes
|
435
|
+
}
|
436
|
+
else if (match.startsWith('.')) {
|
437
|
+
keys.push(match.slice(1));
|
438
|
+
}
|
439
|
+
}
|
440
|
+
return keys;
|
441
|
+
}
|
442
|
+
return null;
|
443
|
+
}
|
444
|
+
;
|
445
|
+
/**
|
446
|
+
* Splits a path string at the last separator (. or [)
|
447
|
+
* @param input The path string to split
|
448
|
+
* @returns Array containing [path up to last separator, remainder after separator]
|
449
|
+
* @example
|
450
|
+
* splitStringAtLastSeparator("foo.bar[0]") // returns ["foo.bar[", "0"]
|
451
|
+
*/
|
452
|
+
function splitStringAtLastSeparator(input) {
|
453
|
+
const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));
|
454
|
+
if (lastSeparatorIndex === -1)
|
455
|
+
return [input, ''];
|
456
|
+
return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];
|
457
|
+
}
|
458
|
+
/**
|
459
|
+
* Traverses an object using an array of keys to access nested properties
|
460
|
+
* @param obj The object to traverse
|
461
|
+
* @param keys Array of keys defining the path to the desired property
|
462
|
+
* @returns The value at the specified path, or null if path is invalid
|
463
|
+
* @example
|
464
|
+
* resolveNestedProperties({foo: {bar: 123}}, ["foo", "bar"]) // returns 123
|
465
|
+
*/
|
466
|
+
function resolveNestedProperties(obj, keys) {
|
467
|
+
return keys.reduce((acc, key) => {
|
468
|
+
if (acc && typeof acc === 'object') {
|
469
|
+
return acc[key];
|
470
|
+
}
|
471
|
+
return null;
|
472
|
+
}, obj);
|
473
|
+
}
|
474
|
+
;
|
475
|
+
/**
|
476
|
+
* Validates if a string represents a valid object path format
|
477
|
+
* @param path The path string to validate
|
478
|
+
* @returns Boolean indicating if path format is valid
|
479
|
+
* @example
|
480
|
+
* isValidPath("foo.bar[0]") // returns true
|
481
|
+
* isValidPath("foo..bar") // returns false
|
482
|
+
*/
|
483
|
+
function isValidPath(path) {
|
484
|
+
// Regex to validate the format of the string
|
485
|
+
const regex = /^([a-zA-Z_$][\w$]*)(\.[a-zA-Z_$][\w$]*|\[\s*(['"]?[a-zA-Z0-9_$]*['"]?)\s*\])*([\.\[])?$/;
|
486
|
+
// Test the string against the regex
|
487
|
+
return regex.test(path);
|
488
|
+
}
|
489
|
+
/**
|
490
|
+
* Converts multi-line code into a single line by removing line breaks and extra whitespace
|
491
|
+
* @param code The code string to convert
|
492
|
+
* @returns Single line version of the code
|
493
|
+
* @example
|
494
|
+
* convertToSingleLine("foo\n bar") // returns "foo bar"
|
495
|
+
*/
|
496
|
+
function convertToSingleLine(code) {
|
497
|
+
if (!code)
|
498
|
+
return '';
|
499
|
+
// Remove line breaks and unnecessary whitespace
|
500
|
+
return code.replace(/\s+/g, ' ').trim();
|
501
|
+
}
|
422
502
|
//# sourceMappingURL=nile-code-editor.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-code-editor.js","sourceRoot":"","sources":["../../../src/nile-code-editor/nile-code-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,IAAI,GAIL,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,kBAAkB,GAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,cAAc,E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E,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwX1B;;AAED,eAAe,cAAc,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValueMap,\n} from 'lit';\n\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-code-editor.css';\nimport { EditorView } from 'codemirror';\nimport { ViewUpdate, placeholder } from '@codemirror/view';\nimport { \n Compartment,\n EditorState,\n} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n scopeCompletionSource,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\nimport { autocompletion,CompletionContext,CompletionResult } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { Theme } from './theme';\n\nconst TIME_OUT_DURATION=200;\n// Choose the appropriate mode for your use case\n\n/**\n * Nile icon component.\n *\n * @tag nile-code-editor\n *\n */\n@customElement('nile-code-editor')\nexport class NileCodeEditor extends NileElement {\n \n @query('.code-mirror') codeEditor: HTMLInputElement;\n\n @property({ type: String, reflect: true , attribute: true }) value = '';\n\n @property({ type: String, reflect: true , attribute: true }) expandIcon = \"expand-2\";\n\n @property({ type: String, reflect: true , attribute: true }) placeholder = \"\";\n\n @property({ type: Object, reflect: true , attribute: true }) customAutoCompletions: object | any = {};\n\n @property({ type: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' = 'javascript';\n\n @property({ type: String, reflect: true , attribute: 'error-message' }) errorMessage: string = '';\n\n @property({ type: Boolean, reflect: true , attribute: 'error' }) error: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: 'noborder' }) noborder: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) multiline: boolean = false;\n \n @property({ type: Boolean, reflect: true , attribute: true }) allowVariableInCustomSuggestion: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbers: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbersMultiline: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) hasScroller: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) expandable: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true}) readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true}) debounce: boolean = false;\n\n public view: EditorView;\n public viewState:EditorState;\n private timeOut: any = null;\n\n // Compartments for initialiazing and switching extensions\n private lineNumbersComp = new Compartment();\n private restrictSingleLineComp = new Compartment();\n private readOnlyComp = new Compartment();\n private customCompletionComp = new Compartment();\n private placeholderComp = new Compartment();\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init',undefined,false);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.view.destroy()\n this.emit('nile-destroy',undefined,false);\n }\n\n firstUpdated() {\n this.createNewView()\n this.emit('nile-after-init',{ \n codeMirrorInstance: this.view, \n createNewView: this.createNewView, \n insertAtCursor: this.insertBetweenCode \n }, false )\n }\n\n protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void{\n super.updated(changedProperties);\n if (changedProperties.has('value') && this.view.state.doc.toString()!=this.value) {\n // Editor has already been initialized, update its state\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('multiline')) {\n this.view.dispatch({\n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())\n ],\n })\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('readonly')) {\n this.view.dispatch({ \n effects: [\n this.readOnlyComp.reconfigure(this.getReadOnlyExtension()),\n ]\n })\n }\n if (changedProperties.has('placeholder')) {\n this.view.dispatch({ \n effects: [\n this.placeholderComp.reconfigure(this.getPlaceholderExtension()),\n ]\n })\n }\n if (changedProperties.has('lineNumbers') || changedProperties.has('lineNumbersMultiline')) {\n this.view.dispatch({ \n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n ]\n })\n }\n if(changedProperties.has('customAutoCompletions') || changedProperties.has('suggestionBracketSupport') ){\n this.view.dispatch({ \n effects: [\n this.customCompletionComp.reconfigure(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }))\n ]\n })\n }\n }\n\n public render(): TemplateResult {\n const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n const noborder = !!this.noborder;\n const noScrollbar = !this.hasScroller\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n 'noborder': noborder,\n 'error': hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n 'no-scroller': noScrollbar\n })}\n >\n ${this.expandable\n ? html` \n <nile-icon\n name=\"${this.expandIcon}\"\n class=\"code-editor__icon__container\"\n size=\"16\"\n color=\"black\"\n @click=\"${(e: CustomEvent) => this.emit('nile-expand')}\"\n ></nile-icon>`\n : ''}\n </div>\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\n }\n\n createNewView(emitEvent=true){\n if(this.view) this.view.destroy();\n this.createState()\n this.view = new EditorView({\n state: this.viewState,\n parent: this.codeEditor\n });\n\n if(emitEvent) this.emit('nile-after-update',{ createNewView: this.createNewView, codeMirrorInstance: this.view, }, false );\n }\n\n createState(){\n const lineNumbersExtension = this.lineNumbersComp.of(this.getLineNumbersExension());\n const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());\n const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension())\n const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension())\n const language = this.getLanguageExtension()\n const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }));\n\n this.viewState = EditorState.create({\n doc: !this.multiline ? this.convertToSingleLine(this.value) : this.value,\n extensions: [\n basicSetup({\n highlightActiveLine: false,\n foldGutter: false,\n }),\n lineNumbersExtension,\n readOnlyExtension,\n restrictSingleLineExtension,\n customAutoCompletions,\n placeholderExtension,\n autocompletion(),\n language,\n EditorView.theme(Theme),\n EditorView.updateListener.of((v: ViewUpdate) => {\n if (v.docChanged) {\n this.debounce ? this.emitAfterTimeout({ value: this.view.state.doc.toString() }) : this.emit('nile-change', { value: this.view.state.doc.toString() })\n }\n }),\n EditorView.domEventHandlers({\n focus: () => this.dispatchEvent(new Event('nile-focus')),\n blur: () => this.dispatchEvent(new Event('nile-blur')),\n }),\n ],\n });\n return this.viewState\n }\n\n singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? this.convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n convertToSingleLine(code: any) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\n }\n\n emitAfterTimeout(value:any){\n if(this.timeOut) clearTimeout(this.timeOut);\n this.timeOut=setTimeout(()=> this.emit('nile-change', value, false), TIME_OUT_DURATION)\n }\n\n public insertBetweenCode=(text: string) => {\n const transaction = this.view.state.changeByRange(range => {\n const { from, to } = range;\n return { changes: { from:from, to, insert: text }, range };\n });\n this.view.dispatch(transaction);\n }\n \n //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension(){\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\n default:\n return javascript(); \n }\n }\n\n getReadOnlyExtension() {\n return this.readonly ? EditorState.readOnly.of(true) : [];\n }\n\n getSingleLineExtension() {\n return !this.multiline ? EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n ) : [];\n }\n\n getPlaceholderExtension(){\n return this.placeholder ? placeholder(this.placeholder) : [];\n }\n\n restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n let text = context.state.doc.sliceString(0, context.pos);\n const [textBeforeCursor, baseTextAfterSeperation] = this.splitStringAtLastSeparator(text.split('\\n').at(-1)?.split(' ').at(-1) + '')\n const textAfterSeperation = baseTextAfterSeperation.replace(/[\"'\\[]/g, '')\n\n const isInString = textAfterSeperation != baseTextAfterSeperation;\n const isBracket = textBeforeCursor.at(-1) == '[';\n const isDot = textBeforeCursor.at(-1) == '.';\n\n if (!this.isValidPath(textBeforeCursor)) return { from: context.pos, options: [] };\n if (['.', '['].includes(textBeforeCursor[textBeforeCursor.length - 1])) {\n // Parse the path for dot or bracket notation\n const path = this.parsePath(textBeforeCursor);\n if (path) {\n if (isDot && isInString) return null;\n let resolved = this.resolveNestedProperties(this.customAutoCompletions, path);\n if (textAfterSeperation) {\n const obj: any = {}\n Object.keys(resolved).forEach((key) => {\n if (key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())) {\n obj[key] = resolved[key]\n }\n })\n resolved = obj\n }\n // If resolved is an object, provide its keys as suggestions\n if (resolved && typeof resolved === 'object') {\n return {\n from: context.pos - textAfterSeperation.length,\n options: Object.keys(resolved).map((key) => ({\n label: key,\n type: 'property',\n info: `Key of ${path[path.length - 1]}`,\n apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) ? \"\\'\" + key + \"\\'\" : key,\n boost: 999\n })),\n };\n }\n }\n }\n\n // Match for top-level object suggestions, e.g., \"a\"\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (baseMatch) {\n const optionsList=Object.keys(this.customAutoCompletions).filter(key=>key.toLowerCase().startsWith(textBeforeCursor.toLowerCase()));\n return {\n from: context.pos - baseMatch[1].length,\n options: optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n }\n }\n // Default to an empty list if no match\n return null;\n };\n\n resolveNestedProperties = (obj:any, keys:any[]) => {\n return keys.reduce((acc, key) => {\n if (acc && typeof acc === 'object') {\n return acc[key];\n }\n return null;\n }, obj);\n };\n\n parsePath(text: string) {\n const regex = /([a-zA-Z_$][\\w$]*)(\\[(?:[^\\]]+)\\]|\\.[a-zA-Z_$][\\w$]*)*/g;\n const matches = [...text.matchAll(regex)];\n if (matches.length > 0) {\n const base = matches[0][1]; // The base object name\n const keys = [base];\n // Extract keys from dot or bracket notation\n const pathMatches = text.match(/\\[(.*?)\\]|\\.(\\w+)/g) || [];\n for (const match of pathMatches) {\n if (match.startsWith('[')) {\n keys.push(match.slice(1, -1).replace(/['\"]/g, '')); // Remove brackets and quotes\n } else if (match.startsWith('.')) {\n keys.push(match.slice(1));\n }\n }\n return keys;\n }\n return null;\n };\n\n isValidPath(path: string) {\n // Regex to validate the format of the string\n const regex = /^([a-zA-Z_$][\\w$]*)(\\.[a-zA-Z_$][\\w$]*|\\[\\s*(['\"]?[a-zA-Z0-9_$]*['\"]?)\\s*\\])*([\\.\\[])?$/;\n // Test the string against the regex\n return regex.test(path);\n }\n\n splitStringAtLastSeparator(input:string) {\n const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));\n if (lastSeparatorIndex === -1) return [input, ''];\n return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];\n }\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"nile-code-editor.js","source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O,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC;AAAA,CAAC;AAEF;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,6CAA6C;IAC7C,MAAM,KAAK,GAAG,yFAAyF,CAAC;IACxG,oCAAoC;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,gDAAgD;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValueMap,\n} from 'lit';\n\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-code-editor.css';\nimport { EditorView } from 'codemirror';\nimport { ViewUpdate, placeholder } from '@codemirror/view';\nimport { \n Compartment,\n EditorState,\n Extension\n} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\nimport { html as htmlLang } from '@codemirror/lang-html';\nimport { autocompletion,CompletionContext,CompletionResult } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { Theme } from './theme';\n\n// Choose the appropriate mode for your use case\n\n/**\n * Nile icon component.\n *\n * @tag nile-code-editor\n *\n */\n@customElement('nile-code-editor')\nexport class NileCodeEditor extends NileElement {\n \n @query('.code-mirror') codeEditor: HTMLInputElement;\n\n @property({ type: String, reflect: true , attribute: true }) value = '';\n\n @property({ type: String, reflect: true , attribute: true }) expandIcon = \"expand-2\";\n\n @property({ type: String, reflect: true , attribute: true }) placeholder = \"\";\n\n @property({ type: Object, reflect: true , attribute: true }) customAutoCompletions: object | any = {};\n\n @property({ type: Array, reflect: true , attribute: true }) customCompletionsPaths: string[] = [];\n\n @property({ type: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' | 'html' = 'javascript';\n\n @property({ type: String, reflect: true , attribute: 'error-message' }) errorMessage: string = '';\n\n @property({ type: Boolean, reflect: true , attribute: 'error' }) error: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: 'noborder' }) noborder: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) multiline: boolean = false;\n \n @property({ type: Boolean, reflect: true , attribute: true }) allowVariableInCustomSuggestion: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbers: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbersMultiline: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) hasScroller: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) expandable: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true}) readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true}) debounce: boolean = false;\n\n @property({ type: Number, reflect: true , attribute: true}) debounceTimeout: number = 200;\n\n public view: EditorView;\n public viewState:EditorState;\n private timeOut: any = null;\n\n // Compartments for initialiazing and switching extensions\n private lineNumbersComp = new Compartment();\n private restrictSingleLineComp = new Compartment();\n private readOnlyComp = new Compartment();\n private customCompletionComp = new Compartment();\n private placeholderComp = new Compartment();\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init',undefined,false);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.view.destroy()\n this.emit('nile-destroy',undefined,false);\n }\n\n firstUpdated() {\n this.createNewView()\n this.emit('nile-after-init',{ \n codeMirrorInstance: this.view, \n createNewView: this.createNewView, \n insertAtCursor: this.insertBetweenCode \n }, false )\n }\n\n protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void{\n super.updated(changedProperties);\n if (changedProperties.has('value') && this.view.state.doc.toString()!=this.value) {\n // Editor has already been initialized, update its state\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('multiline')) {\n this.view.dispatch({\n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())\n ],\n })\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('readonly')) {\n this.view.dispatch({ \n effects: [\n this.readOnlyComp.reconfigure(this.getReadOnlyExtension()),\n ]\n })\n }\n if (changedProperties.has('placeholder')) {\n this.view.dispatch({ \n effects: [\n this.placeholderComp.reconfigure(this.getPlaceholderExtension()),\n ]\n })\n }\n if (changedProperties.has('lineNumbers') || changedProperties.has('lineNumbersMultiline')) {\n this.view.dispatch({ \n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n ]\n })\n }\n if(changedProperties.has('customAutoCompletions') || changedProperties.has('customCompletionsPaths')){\n this.view.dispatch({ \n effects: [\n this.customCompletionComp.reconfigure(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }))\n ]\n })\n }\n }\n\n public render(): TemplateResult {\n const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n const noborder = !!this.noborder;\n const noScrollbar = !this.hasScroller\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n 'noborder': noborder,\n 'error': hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n 'no-scroller': noScrollbar\n })}\n >\n ${this.expandable\n ? html` \n <nile-icon\n name=\"${this.expandIcon}\"\n class=\"code-editor__icon__container\"\n size=\"16\"\n color=\"black\"\n @click=\"${(e: CustomEvent) => this.emit('nile-expand')}\"\n ></nile-icon>`\n : ''}\n </div>\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\n }\n\n createNewView(emitEvent=true){\n if(this.view) this.view.destroy();\n this.createState()\n this.view = new EditorView({\n state: this.viewState,\n parent: this.codeEditor\n });\n\n if(emitEvent) this.emit('nile-after-update',{ createNewView: this.createNewView, codeMirrorInstance: this.view, }, false );\n }\n\n createState(){\n const lineNumbersExtension = this.lineNumbersComp.of(this.getLineNumbersExension());\n const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());\n const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension())\n const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension())\n const language = this.getLanguageExtension()\n const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }));\n\n this.viewState = EditorState.create({\n doc: !this.multiline ? convertToSingleLine(this.value) : this.value,\n extensions: [\n basicSetup({\n highlightActiveLine: false,\n foldGutter: false,\n }),\n lineNumbersExtension,\n readOnlyExtension,\n restrictSingleLineExtension,\n customAutoCompletions,\n placeholderExtension,\n autocompletion(),\n language,\n EditorView.theme(Theme),\n EditorView.updateListener.of((v: ViewUpdate) => {\n if (v.docChanged) {\n this.debounce ? this.emitAfterTimeout({ value: this.view.state.doc.toString() }) : this.emit('nile-change', { value: this.view.state.doc.toString() })\n }\n }),\n EditorView.domEventHandlers({\n focus: () => this.dispatchEvent(new Event('nile-focus')),\n blur: () => this.dispatchEvent(new Event('nile-blur')),\n }),\n ],\n });\n return this.viewState\n }\n /**\n * Custom autocomplete handler for code editor suggestions\n * @param context CompletionContext from CodeMirror\n * @returns CompletionResult with suggestions or null if no suggestions\n */\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n const text = context.state.doc.sliceString(0, context.pos);\n const lastWord = text.split('\\n').at(-1)?.split(' ').at(-1) || '';\n const [textBeforeCursor, baseTextAfterSeperation] = splitStringAtLastSeparator(lastWord);\n \n return this.getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation) \n || this.getTopLevelSuggestions(context, textBeforeCursor);\n };\n\n /**\n * Gets nested property suggestions based on the current path\n * @param context CompletionContext from CodeMirror\n * @param textBeforeCursor Text before cursor position\n * @param baseTextAfterSeperation Text after the last separator (. or [)\n * @returns CompletionResult with nested suggestions or null\n */\n getNestedSuggestions(context: CompletionContext, textBeforeCursor: string, baseTextAfterSeperation: string) {\n // Return early if not a valid path or not ending with . or [\n if (!isValidPath(textBeforeCursor) || !['.', '['].includes(textBeforeCursor.at(-1)!)) {\n return null;\n }\n\n const path = parsePath(textBeforeCursor);\n if (!path) return null;\n\n const textAfterSeperation = baseTextAfterSeperation.replace(/[\"'\\[]/g, '');\n const isInString = textAfterSeperation !== baseTextAfterSeperation;\n const isBracket = textBeforeCursor.at(-1) === '[';\n\n // Return null if we're in a string after a dot\n if (textBeforeCursor.at(-1) === '.' && isInString) return null;\n\n // Get nested properties and filter by text after separation if it exists\n let resolved = resolveNestedProperties(this.customAutoCompletions, path);\n if (!resolved || typeof resolved !== 'object') return null;\n\n if (textAfterSeperation) {\n resolved = Object.fromEntries(\n Object.entries(resolved).filter(([key]) => \n key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())\n )\n );\n }\n\n return {\n from: context.pos - textAfterSeperation.length,\n options: Object.keys(resolved).map(key => ({\n label: key,\n type: 'property',\n info: `Key of ${path[path.length - 1]}`,\n apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) \n ? `'${key}'` \n : key,\n boost: 999\n }))\n };\n }\n\n /**\n * Gets top level suggestions based on custom completions and paths\n * @param context CompletionContext from CodeMirror\n * @param textBeforeCursor Text before cursor position\n * @returns CompletionResult with top level suggestions or null\n */\n getTopLevelSuggestions(context: CompletionContext,textBeforeCursor:string){\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (!baseMatch) return null;\n \n const optionsList = Object.keys(this.customAutoCompletions).filter(key => \n Object.keys(this.customAutoCompletions[key]).length && \n key.toLowerCase().startsWith(textBeforeCursor.toLowerCase())\n );\n \n const options=optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n if(this.customCompletionsPaths.length){\n this.customCompletionsPaths\n .filter(path=>path.toLocaleLowerCase().includes(textBeforeCursor.toLocaleLowerCase()))\n .map(path=>{\n options.push({\n label: ''+path,\n type: 'property',\n apply: ''+path,\n boost: 998\n })\n })\n }\n return {\n from: context.pos - baseMatch[1].length,\n options: options\n }\n }\n\n emitAfterTimeout(value:any){\n if(this.timeOut) clearTimeout(this.timeOut);\n this.timeOut=setTimeout(()=> this.emit('nile-change', value, false), this.debounceTimeout)\n }\n\n public insertBetweenCode=(text: string) => {\n const transaction = this.view.state.changeByRange(range => {\n const { from, to } = range;\n return { changes: { from:from, to, insert: text }, range };\n });\n this.view.dispatch(transaction);\n }\n\n singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension():Extension{\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\n case 'html':\n return htmlLang();\n default:\n return javascript(); \n }\n }\n\n getReadOnlyExtension() {\n return this.readonly ? EditorState.readOnly.of(true) : [];\n }\n\n getSingleLineExtension() {\n return !this.multiline ? EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n ) : [];\n }\n\n getPlaceholderExtension(){\n return this.placeholder ? placeholder(this.placeholder) : [];\n }\n\n restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n\n/**\n * Parses a string path into an array of keys representing nested object access\n * @param text The path string to parse (e.g. \"foo.bar[0].baz\")\n * @returns Array of keys if valid path, null otherwise\n * @example\n * parsePath(\"foo.bar[0]\") // returns [\"foo\", \"bar\", \"0\"]\n * parsePath(\"invalid\") // returns null\n */\nfunction parsePath(text: string) {\n const regex = /([a-zA-Z_$][\\w$]*)(\\[(?:[^\\]]+)\\]|\\.[a-zA-Z_$][\\w$]*)*/g;\n const matches = [...text.matchAll(regex)];\n if (matches.length > 0) {\n const base = matches[0][1]; // The base object name\n const keys = [base];\n // Extract keys from dot or bracket notation\n const pathMatches = text.match(/\\[(.*?)\\]|\\.(\\w+)/g) || [];\n for (const match of pathMatches) {\n if (match.startsWith('[')) {\n keys.push(match.slice(1, -1).replace(/['\"]/g, '')); // Remove brackets and quotes\n } else if (match.startsWith('.')) {\n keys.push(match.slice(1));\n }\n }\n return keys;\n }\n return null;\n};\n\n/**\n * Splits a path string at the last separator (. or [)\n * @param input The path string to split\n * @returns Array containing [path up to last separator, remainder after separator]\n * @example\n * splitStringAtLastSeparator(\"foo.bar[0]\") // returns [\"foo.bar[\", \"0\"]\n */\nfunction splitStringAtLastSeparator(input:string) {\n const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));\n if (lastSeparatorIndex === -1) return [input, ''];\n return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];\n}\n\n/**\n * Traverses an object using an array of keys to access nested properties\n * @param obj The object to traverse\n * @param keys Array of keys defining the path to the desired property\n * @returns The value at the specified path, or null if path is invalid\n * @example\n * resolveNestedProperties({foo: {bar: 123}}, [\"foo\", \"bar\"]) // returns 123\n */\nfunction resolveNestedProperties (obj:any, keys:any[]){\n return keys.reduce((acc, key) => {\n if (acc && typeof acc === 'object') {\n return acc[key];\n }\n return null;\n }, obj);\n};\n\n/**\n * Validates if a string represents a valid object path format\n * @param path The path string to validate\n * @returns Boolean indicating if path format is valid\n * @example\n * isValidPath(\"foo.bar[0]\") // returns true\n * isValidPath(\"foo..bar\") // returns false\n */\nfunction isValidPath(path: string) {\n // Regex to validate the format of the string\n const regex = /^([a-zA-Z_$][\\w$]*)(\\.[a-zA-Z_$][\\w$]*|\\[\\s*(['\"]?[a-zA-Z0-9_$]*['\"]?)\\s*\\])*([\\.\\[])?$/;\n // Test the string against the regex\n return regex.test(path);\n}\n\n/**\n * Converts multi-line code into a single line by removing line breaks and extra whitespace\n * @param code The code string to convert\n * @returns Single line version of the code\n * @example\n * convertToSingleLine(\"foo\\n bar\") // returns \"foo bar\"\n */\nfunction convertToSingleLine(code: string) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\n}"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-drawer.css.js","sourceRoot":"","sources":["../../../src/nile-drawer/nile-drawer.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4KxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit';\n\n/**\n * Drawer CSS\n */\nexport const styles = css`\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.
|
1
|
+
{"version":3,"file":"nile-drawer.css.js","sourceRoot":"","sources":["../../../src/nile-drawer/nile-drawer.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4KxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit';\n\n/**\n * Drawer CSS\n */\nexport const styles = css`\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.5rem;\n padding: 0 var(--header-spacing);\n }\n\n .drawer__header-actions nile-icon-button,\n .drawer__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .drawer__body {\n flex: 1 1 auto;\n display: block;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .drawer__footer {\n text-align: right;\n padding: var(--footer-spacing);\n }\n\n .drawer__footer ::slotted(nile-button:not(:last-of-type)) {\n margin-inline-end: 0.5rem;\n }\n\n .drawer:not(.drawer--has-footer) .drawer__footer {\n display: none;\n }\n\n .drawer__overlay {\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(240 3.8% 46.1% / 33%);\n pointer-events: all;\n }\n\n .drawer--contained .drawer__overlay {\n display: none;\n }\n\n .drawer__close:hover {\n cursor:pointer;\n }\n\n @media (forced-colors: active) {\n .drawer__panel {\n border: solid 1px hsl(0, 0%, 100%);\n }\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -49,7 +49,15 @@ let NileFormHelpText = class NileFormHelpText extends LitElement {
|
|
49
49
|
this.updateDisplayedText();
|
50
50
|
}
|
51
51
|
updateDisplayedText() {
|
52
|
-
|
52
|
+
if (this.isExpanded) {
|
53
|
+
this.displayedText = this.fullText;
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
const validConcatNumber = concatSentence(this.fullText, this.textLimit);
|
57
|
+
const truncatedText = this.fullText.slice(0, validConcatNumber);
|
58
|
+
const ellipsis = this.fullText.length > validConcatNumber ? '...' : '';
|
59
|
+
this.displayedText = `${truncatedText}${ellipsis}`;
|
60
|
+
}
|
53
61
|
}
|
54
62
|
/* #endregion */
|
55
63
|
/* #region Methods */
|
@@ -58,7 +66,7 @@ let NileFormHelpText = class NileFormHelpText extends LitElement {
|
|
58
66
|
* @slot This is a slot test
|
59
67
|
*/
|
60
68
|
render() {
|
61
|
-
const showMoreButton = this.fullText.length > this.textLimit
|
69
|
+
const showMoreButton = this.fullText.length > this.textLimit;
|
62
70
|
const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';
|
63
71
|
return html `
|
64
72
|
<div class="nile-form-help-text" part="container">
|
@@ -99,4 +107,26 @@ NileFormHelpText = __decorate([
|
|
99
107
|
], NileFormHelpText);
|
100
108
|
export { NileFormHelpText };
|
101
109
|
export default NileFormHelpText;
|
110
|
+
function concatSentence(sentence, n) {
|
111
|
+
if (n < 0 || n > sentence.length) {
|
112
|
+
throw new Error("Invalid value of n. It must be between 0 and the sentence length.");
|
113
|
+
}
|
114
|
+
// Adjust n if it falls in the middle of a word
|
115
|
+
if (sentence[n] !== " " && n !== 0 && n !== sentence.length) {
|
116
|
+
// Move left until the start of the word or the beginning of the sentence
|
117
|
+
let left = n;
|
118
|
+
while (left > 0 && sentence[left - 1] !== " ") {
|
119
|
+
left--;
|
120
|
+
}
|
121
|
+
// Move right until the end of the word or the end of the sentence
|
122
|
+
let right = n;
|
123
|
+
while (right < sentence.length && sentence[right] !== " ") {
|
124
|
+
right++;
|
125
|
+
}
|
126
|
+
// Adjust n to the closer boundary
|
127
|
+
n = (n - left <= right - n) ? left : right;
|
128
|
+
}
|
129
|
+
// Return the substring from the start to the adjusted n
|
130
|
+
return n;
|
131
|
+
}
|
102
132
|
//# sourceMappingURL=nile-form-help-text.js.map
|