@checkstack/ui 0.5.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/package.json +3 -10
- package/src/components/CodeEditor/CodeEditor.tsx +14 -420
- package/src/components/CodeEditor/MonacoEditor.tsx +530 -0
- package/src/components/CodeEditor/generateTypeDefinitions.ts +169 -0
- package/src/components/CodeEditor/index.ts +4 -3
- package/src/components/CodeEditor/templateUtils.test.ts +87 -0
- package/src/components/CodeEditor/templateUtils.ts +81 -0
- package/src/components/DynamicForm/FormField.tsx +13 -7
- package/src/components/DynamicForm/MultiTypeEditorField.tsx +33 -0
- package/src/components/DynamicForm/utils.ts +3 -0
- package/src/components/CodeEditor/languageSupport/enterBehavior.test.ts +0 -173
- package/src/components/CodeEditor/languageSupport/enterBehavior.ts +0 -35
- package/src/components/CodeEditor/languageSupport/index.ts +0 -22
- package/src/components/CodeEditor/languageSupport/json-utils.ts +0 -117
- package/src/components/CodeEditor/languageSupport/json.test.ts +0 -274
- package/src/components/CodeEditor/languageSupport/json.ts +0 -139
- package/src/components/CodeEditor/languageSupport/markdown-utils.ts +0 -65
- package/src/components/CodeEditor/languageSupport/markdown.test.ts +0 -245
- package/src/components/CodeEditor/languageSupport/markdown.ts +0 -134
- package/src/components/CodeEditor/languageSupport/types.ts +0 -48
- package/src/components/CodeEditor/languageSupport/xml-utils.ts +0 -94
- package/src/components/CodeEditor/languageSupport/xml.test.ts +0 -239
- package/src/components/CodeEditor/languageSupport/xml.ts +0 -116
- package/src/components/CodeEditor/languageSupport/yaml-utils.ts +0 -101
- package/src/components/CodeEditor/languageSupport/yaml.test.ts +0 -203
- package/src/components/CodeEditor/languageSupport/yaml.ts +0 -120
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { yaml } from "@codemirror/lang-yaml";
|
|
2
|
-
import { Decoration } from "@codemirror/view";
|
|
3
|
-
import type { LanguageSupport, DecorationRange } from "./types";
|
|
4
|
-
|
|
5
|
-
// Re-export pure utils for backwards compatibility
|
|
6
|
-
export {
|
|
7
|
-
isValidYamlTemplatePosition,
|
|
8
|
-
calculateYamlIndentation,
|
|
9
|
-
} from "./yaml-utils";
|
|
10
|
-
|
|
11
|
-
// Decoration marks for YAML syntax highlighting using inline styles
|
|
12
|
-
const yamlKeyMark = Decoration.mark({
|
|
13
|
-
attributes: { style: "color: hsl(210, 100%, 75%)" }, // Bright blue for better visibility
|
|
14
|
-
});
|
|
15
|
-
const yamlStringMark = Decoration.mark({
|
|
16
|
-
attributes: { style: "color: hsl(142.1, 76.2%, 36.3%)" },
|
|
17
|
-
});
|
|
18
|
-
const yamlNumberMark = Decoration.mark({
|
|
19
|
-
attributes: { style: "color: hsl(217.2, 91.2%, 59.8%)" },
|
|
20
|
-
});
|
|
21
|
-
const yamlBoolMark = Decoration.mark({
|
|
22
|
-
attributes: { style: "color: hsl(280, 65%, 60%)" },
|
|
23
|
-
});
|
|
24
|
-
const templateMark = Decoration.mark({
|
|
25
|
-
attributes: { style: "color: hsl(190, 70%, 50%); font-weight: 500" },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Build YAML + template decorations.
|
|
30
|
-
*/
|
|
31
|
-
function buildYamlDecorations(doc: string): DecorationRange[] {
|
|
32
|
-
const ranges: DecorationRange[] = [];
|
|
33
|
-
|
|
34
|
-
// Match templates first (highest priority)
|
|
35
|
-
const templateRegex = /\{\{[\w.[\]]*\}\}/g;
|
|
36
|
-
let match;
|
|
37
|
-
while ((match = templateRegex.exec(doc)) !== null) {
|
|
38
|
-
ranges.push({
|
|
39
|
-
from: match.index,
|
|
40
|
-
to: match.index + match[0].length,
|
|
41
|
-
decoration: templateMark,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Match YAML keys (word followed by colon)
|
|
46
|
-
const keyRegex = /^(\s*)([\w-]+):/gm;
|
|
47
|
-
while ((match = keyRegex.exec(doc)) !== null) {
|
|
48
|
-
const keyStart = match.index + match[1].length;
|
|
49
|
-
const keyEnd = keyStart + match[2].length;
|
|
50
|
-
ranges.push({
|
|
51
|
-
from: keyStart,
|
|
52
|
-
to: keyEnd,
|
|
53
|
-
decoration: yamlKeyMark,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Match quoted strings
|
|
58
|
-
const stringRegex = /(["'])(?:(?!\1)[^\\]|\\.)*\1/g;
|
|
59
|
-
while ((match = stringRegex.exec(doc)) !== null) {
|
|
60
|
-
ranges.push({
|
|
61
|
-
from: match.index,
|
|
62
|
-
to: match.index + match[0].length,
|
|
63
|
-
decoration: yamlStringMark,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Match numbers (standalone)
|
|
68
|
-
const numberRegex = /(?<=:\s+)-?\d+\.?\d*(?:\s|$)/g;
|
|
69
|
-
while ((match = numberRegex.exec(doc)) !== null) {
|
|
70
|
-
ranges.push({
|
|
71
|
-
from: match.index,
|
|
72
|
-
to: match.index + match[0].trim().length,
|
|
73
|
-
decoration: yamlNumberMark,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Match booleans
|
|
78
|
-
const boolRegex = /(?<=:\s+)(true|false|yes|no|on|off)(?:\s|$)/gi;
|
|
79
|
-
while ((match = boolRegex.exec(doc)) !== null) {
|
|
80
|
-
ranges.push({
|
|
81
|
-
from: match.index,
|
|
82
|
-
to: match.index + match[1].length,
|
|
83
|
-
decoration: yamlBoolMark,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Sort by position
|
|
88
|
-
ranges.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
89
|
-
|
|
90
|
-
// Remove overlaps (templates take priority)
|
|
91
|
-
const filtered: DecorationRange[] = [];
|
|
92
|
-
for (const range of ranges) {
|
|
93
|
-
const overlaps = filtered.some(
|
|
94
|
-
(existing) =>
|
|
95
|
-
(range.from >= existing.from && range.from < existing.to) ||
|
|
96
|
-
(range.to > existing.from && range.to <= existing.to),
|
|
97
|
-
);
|
|
98
|
-
if (!overlaps) {
|
|
99
|
-
filtered.push(range);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return filtered;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Import the pure utils for use in the language support object
|
|
107
|
-
import {
|
|
108
|
-
isValidYamlTemplatePosition,
|
|
109
|
-
calculateYamlIndentation,
|
|
110
|
-
} from "./yaml-utils";
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* YAML language support for CodeEditor with template expression handling.
|
|
114
|
-
*/
|
|
115
|
-
export const yamlLanguageSupport: LanguageSupport = {
|
|
116
|
-
extension: yaml(),
|
|
117
|
-
buildDecorations: buildYamlDecorations,
|
|
118
|
-
isValidTemplatePosition: isValidYamlTemplatePosition,
|
|
119
|
-
calculateIndentation: calculateYamlIndentation,
|
|
120
|
-
};
|