xmlui 0.11.3 → 0.11.4
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/lib/{index-DSUDwtWN.js → index-Cq0EMm3L.js} +329 -315
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-DdH1iCH-.js → initMock-DCigV4Zh.js} +1 -1
- package/dist/lib/language-server-web-worker.js +1 -1
- package/dist/lib/language-server.js +1 -1
- package/dist/lib/{metadata-utils-D27cn-XB.js → metadata-utils-BiolWMg9.js} +5 -6
- package/dist/lib/{server-common-hq0poDwA.js → server-common-DyCHOk-z.js} +2674 -2642
- package/dist/lib/testing.js +1 -1
- package/dist/lib/{transform-Tooy42EB.js → transform-DHf9tQF7.js} +15 -1
- package/dist/lib/vite-xmlui-plugin/index.js +19 -2
- package/dist/lib/{xmlui-parser-BZZ430Wm.js → xmlui-parser-CHN3mADy.js} +1 -1
- package/dist/lib/xmlui-parser.d.ts +2 -0
- package/dist/lib/xmlui-parser.js +2 -2
- package/dist/lib/{xmlui-serializer-D9D2mQ8m.js → xmlui-serializer-CYNSHAlP.js} +1 -1
- package/dist/lib/xmlui.d.ts +2 -1
- package/dist/lib/xmlui.js +3 -3
- package/dist/metadata/{collectedComponentMetadata-C8Lr9TFe.js → collectedComponentMetadata-CLaDZhmc.js} +340 -311
- package/dist/metadata/{initMock-CWwgOjW_.js → initMock-Buqah4JF.js} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.js +1 -1
- package/dist/metadata/xmlui-metadata.umd.cjs +3 -3
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +113 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelList.js +2 -2
- package/dist/scripts/src/components/Charts/LabelList/LabelListNative.js +2 -2
- package/dist/scripts/src/components/Checkbox/Checkbox.js +6 -6
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +30 -99
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +57 -14
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +88 -17
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +9 -9
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +111 -86
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +6 -6
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +30 -28
- package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +1 -1
- package/dist/scripts/src/components/Select/Select.js +1 -1
- package/dist/scripts/src/components/Select/Select.spec.js +92 -0
- package/dist/scripts/src/components/Slider/Slider.js +5 -5
- package/dist/scripts/src/components/Slider/Slider.spec.js +63 -29
- package/dist/scripts/src/components/Splitter/Splitter.js +51 -2
- package/dist/scripts/src/components/Splitter/Splitter.spec.js +225 -0
- package/dist/scripts/src/components/Splitter/SplitterNative.js +14 -12
- package/dist/scripts/src/components/Switch/Switch.js +6 -6
- package/dist/scripts/src/components/Switch/Switch.spec.js +44 -46
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +94 -2
- package/dist/scripts/src/components/TextBox/TextBox.js +5 -3
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +92 -59
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +101 -25
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +5 -4
- package/dist/scripts/src/language-server/services/common/syntax-node-utilities.js +23 -31
- package/dist/scripts/src/language-server/services/format.js +223 -84
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +3 -2
- package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +16 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -2
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleDocumentFormatting = handleDocumentFormatting;
|
|
4
4
|
exports.format = format;
|
|
5
5
|
const xmlui_parser_1 = require("../../parsers/xmlui-parser");
|
|
6
|
-
const syntax_node_utilities_1 = require("./common/syntax-node-utilities");
|
|
7
6
|
function handleDocumentFormatting({ node, getText, options, offsetToPosition, }) {
|
|
8
7
|
const formatted = format(node, getText, options);
|
|
9
8
|
// If content is already formatted correctly, return empty array
|
|
@@ -24,21 +23,22 @@ function handleDocumentFormatting({ node, getText, options, offsetToPosition, })
|
|
|
24
23
|
}
|
|
25
24
|
class XmluiFormatter {
|
|
26
25
|
constructor(node, getText, options) {
|
|
26
|
+
this.maxConsecutiveNewlines = 2;
|
|
27
|
+
this.maxLineLength = 80;
|
|
27
28
|
this.newlineToken = "\n";
|
|
28
29
|
this.getText = getText;
|
|
29
30
|
this.startingNode = node;
|
|
30
31
|
this.indentationLvl = 0;
|
|
31
|
-
this.maxLineLength = 80;
|
|
32
32
|
this.tabSize = options.tabSize;
|
|
33
33
|
this.indentationToken = options.insertSpaces ? " ".repeat(options.tabSize) : "\t";
|
|
34
34
|
if (options.insertFinalNewline && !options.trimFinalNewlines) {
|
|
35
|
-
this.
|
|
36
|
-
return formatted.
|
|
35
|
+
this.trimRespectingOptions = (formatted) => {
|
|
36
|
+
return formatted.trim() + this.newlineToken;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
this.
|
|
41
|
-
return formatted.
|
|
40
|
+
this.trimRespectingOptions = (formatted) => {
|
|
41
|
+
return formatted.trim();
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -48,15 +48,12 @@ class XmluiFormatter {
|
|
|
48
48
|
formattedStr = this.getText(this.startingNode);
|
|
49
49
|
}
|
|
50
50
|
formattedStr = this.printContentListNode(this.startingNode);
|
|
51
|
-
formattedStr = this.
|
|
51
|
+
formattedStr = this.trimRespectingOptions(formattedStr);
|
|
52
52
|
return formattedStr;
|
|
53
53
|
}
|
|
54
54
|
printContentListNode(node) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
acc += this.getText(node);
|
|
58
|
-
return acc;
|
|
59
|
-
}
|
|
55
|
+
var _a;
|
|
56
|
+
let acc = "";
|
|
60
57
|
for (let i = 0; i < node.children.length; i++) {
|
|
61
58
|
const c = node.children[i];
|
|
62
59
|
const prevChild = i > 0 ? node.children[i - 1] : null;
|
|
@@ -64,39 +61,17 @@ class XmluiFormatter {
|
|
|
64
61
|
case xmlui_parser_1.SyntaxKind.CData:
|
|
65
62
|
case xmlui_parser_1.SyntaxKind.Script:
|
|
66
63
|
case xmlui_parser_1.SyntaxKind.ElementNode: {
|
|
67
|
-
|
|
68
|
-
const prevIsText = (prevChild === null || prevChild === void 0 ? void 0 : prevChild.kind) === xmlui_parser_1.SyntaxKind.TextNode;
|
|
69
|
-
if (comment) {
|
|
70
|
-
let commentInline = true;
|
|
71
|
-
if (this.hasNewlineTriviaBeforeComment(c)) {
|
|
72
|
-
commentInline = false;
|
|
73
|
-
}
|
|
74
|
-
else if (prevIsText) {
|
|
75
|
-
const prevText = this.getText(prevChild);
|
|
76
|
-
commentInline = !hasNewlineInTrailingWhitespace(prevText);
|
|
77
|
-
}
|
|
78
|
-
if (commentInline) {
|
|
79
|
-
if (acc.at(-1) === this.newlineToken) {
|
|
80
|
-
acc = acc.substring(0, acc.length - this.newlineToken.length);
|
|
81
|
-
}
|
|
82
|
-
acc += ` ${comment}${this.newlineToken}`;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
acc += this.indent(this.indentationLvl) + comment + this.newlineToken;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
acc += this.indent(this.indentationLvl);
|
|
64
|
+
acc += this.printTagLikeTriviaInContent(prevChild, c);
|
|
89
65
|
acc += this.printTagLike(c);
|
|
90
|
-
acc += this.newlineToken;
|
|
91
66
|
break;
|
|
92
67
|
}
|
|
93
68
|
case xmlui_parser_1.SyntaxKind.StringLiteral:
|
|
94
69
|
case xmlui_parser_1.SyntaxKind.TextNode: {
|
|
95
70
|
const formattedContent = this.printContentString(c);
|
|
96
71
|
if (formattedContent !== "") {
|
|
72
|
+
acc += this.newlineToken;
|
|
97
73
|
acc += this.indent(this.indentationLvl);
|
|
98
74
|
acc += formattedContent;
|
|
99
|
-
acc += this.newlineToken;
|
|
100
75
|
}
|
|
101
76
|
else {
|
|
102
77
|
acc.trimEnd();
|
|
@@ -106,17 +81,182 @@ class XmluiFormatter {
|
|
|
106
81
|
case xmlui_parser_1.SyntaxKind.ErrorNode:
|
|
107
82
|
acc += this.getText(c, false);
|
|
108
83
|
break;
|
|
109
|
-
case xmlui_parser_1.SyntaxKind.EndOfFileToken:
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
case xmlui_parser_1.SyntaxKind.EndOfFileToken: {
|
|
85
|
+
const collapsedTrivias = this.collapseBlankLines((_a = c.triviaBefore) !== null && _a !== void 0 ? _a : []);
|
|
86
|
+
acc += this.addWsToCollapsedTriviaInContentList(collapsedTrivias, prevChild);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
printTagLikeTriviaInContent(prevSibling, node) {
|
|
94
|
+
if (!prevSibling) {
|
|
95
|
+
return this.printTriviaBeforeFirstTaglikeInContent(node);
|
|
96
|
+
}
|
|
97
|
+
else if (prevSibling.isTagLike()) {
|
|
98
|
+
return this.printTriviaBetweenSiblingTaglikes(node, prevSibling);
|
|
99
|
+
}
|
|
100
|
+
else if (prevSibling.kind === xmlui_parser_1.SyntaxKind.TextNode ||
|
|
101
|
+
prevSibling.kind === xmlui_parser_1.SyntaxKind.StringLiteral) {
|
|
102
|
+
return this.printTriviaBetweenTextAndTaglike(prevSibling, node);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// prevSibling is an error node, treat is as any taglike
|
|
106
|
+
return this.printTriviaBetweenSiblingTaglikes(node, prevSibling);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
printTriviaBetweenTextAndTaglike(textNode, node) {
|
|
110
|
+
var _a;
|
|
111
|
+
let acc = "";
|
|
112
|
+
const trivias = (_a = node.getTriviaNodes()) !== null && _a !== void 0 ? _a : [];
|
|
113
|
+
const collapsedTrivias = this.collapseBlankLines(trivias);
|
|
114
|
+
acc += this.addWsToCollapsedTriviaInContentList(collapsedTrivias, textNode);
|
|
115
|
+
return acc;
|
|
116
|
+
}
|
|
117
|
+
printTriviaBeforeFirstTaglikeInContent(node) {
|
|
118
|
+
const triviaBetweenTaglikes = node.getTriviaNodes();
|
|
119
|
+
if (!triviaBetweenTaglikes) {
|
|
120
|
+
if (node.start === 0)
|
|
121
|
+
return "";
|
|
122
|
+
return this.newlineToken + this.indent(this.indentationLvl);
|
|
123
|
+
}
|
|
124
|
+
const collapsedTrivias = this.collapseBlankLines(triviaBetweenTaglikes);
|
|
125
|
+
let acc = this.addWsToCollapsedTriviaInContentList(collapsedTrivias, null);
|
|
126
|
+
return acc;
|
|
127
|
+
}
|
|
128
|
+
printTriviaBetweenSiblingTaglikes(node, prevNode) {
|
|
129
|
+
const triviaBetweenTaglikes = node.getTriviaNodes();
|
|
130
|
+
if (!triviaBetweenTaglikes) {
|
|
131
|
+
return this.newlineToken + this.indent(this.indentationLvl);
|
|
132
|
+
}
|
|
133
|
+
const collapsedTrivias = this.collapseBlankLines(triviaBetweenTaglikes);
|
|
134
|
+
let acc = this.addWsToCollapsedTriviaInContentList(collapsedTrivias, prevNode);
|
|
135
|
+
return acc;
|
|
136
|
+
}
|
|
137
|
+
/* Filters out trivias so that only comments and newline remain.
|
|
138
|
+
Respects the maximum permitted consecitive blank lines and throws out any extra consecutive newlines. */
|
|
139
|
+
collapseBlankLines(trivias) {
|
|
140
|
+
let consecutiveNewlines = 0;
|
|
141
|
+
const accTrivias = [];
|
|
142
|
+
for (let t of trivias) {
|
|
143
|
+
if (t.kind === xmlui_parser_1.SyntaxKind.NewLineTrivia) {
|
|
144
|
+
consecutiveNewlines++;
|
|
145
|
+
if (consecutiveNewlines <= this.maxConsecutiveNewlines) {
|
|
146
|
+
accTrivias.push(t);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else if (t.kind === xmlui_parser_1.SyntaxKind.CommentTrivia) {
|
|
150
|
+
consecutiveNewlines = 0;
|
|
151
|
+
accTrivias.push(t);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return accTrivias;
|
|
155
|
+
}
|
|
156
|
+
addWsToCollapsedTriviaInContentList(trivias, prevContentNode) {
|
|
157
|
+
var _a;
|
|
158
|
+
let newlinesAfterText = null;
|
|
159
|
+
let newlinesFromText = null;
|
|
160
|
+
let prevContentIsText = false;
|
|
161
|
+
let newlinesBeforeFirstComment = " ";
|
|
162
|
+
if (prevContentNode) {
|
|
163
|
+
prevContentIsText =
|
|
164
|
+
prevContentNode.kind === xmlui_parser_1.SyntaxKind.StringLiteral ||
|
|
165
|
+
prevContentNode.kind === xmlui_parser_1.SyntaxKind.TextNode;
|
|
166
|
+
if (prevContentIsText) {
|
|
167
|
+
const trailingNewlinesInText = newlinesInTrailingWhitespace(this.getText(prevContentNode));
|
|
168
|
+
newlinesAfterText = Math.min(trailingNewlinesInText, this.maxConsecutiveNewlines);
|
|
169
|
+
if (newlinesAfterText > 0) {
|
|
170
|
+
newlinesFromText = this.newlineToken.repeat(newlinesAfterText);
|
|
171
|
+
newlinesBeforeFirstComment = newlinesFromText + this.indent(this.indentationLvl);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
let acc = "";
|
|
176
|
+
let lastKeptTriviaIsComment = false;
|
|
177
|
+
for (let i = 0; i < trivias.length; i++) {
|
|
178
|
+
const t = trivias[i];
|
|
179
|
+
switch (t.kind) {
|
|
180
|
+
case xmlui_parser_1.SyntaxKind.CommentTrivia: {
|
|
181
|
+
if (i === 0) {
|
|
182
|
+
acc += newlinesBeforeFirstComment;
|
|
183
|
+
acc += this.getText(t);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
acc += this.indent(this.indentationLvl) + this.getText(t);
|
|
187
|
+
}
|
|
188
|
+
if (((_a = trivias[i + 1]) === null || _a === void 0 ? void 0 : _a.kind) === xmlui_parser_1.SyntaxKind.CommentTrivia) {
|
|
189
|
+
acc += this.newlineToken;
|
|
190
|
+
}
|
|
191
|
+
lastKeptTriviaIsComment = true;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case xmlui_parser_1.SyntaxKind.NewLineTrivia: {
|
|
195
|
+
acc += this.newlineToken;
|
|
196
|
+
lastKeptTriviaIsComment = false;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (lastKeptTriviaIsComment) {
|
|
202
|
+
acc += this.newlineToken;
|
|
203
|
+
}
|
|
204
|
+
else if (trivias.length === 0) {
|
|
205
|
+
acc += newlinesFromText !== null && newlinesFromText !== void 0 ? newlinesFromText : this.newlineToken;
|
|
206
|
+
}
|
|
207
|
+
acc += this.indent(this.indentationLvl);
|
|
208
|
+
return acc;
|
|
209
|
+
}
|
|
210
|
+
addWsToCollapsedCloseNodeStartTrivia(trivias, lastContentNode) {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
let newlinesAfterText = null;
|
|
213
|
+
let lastContentIsText = false;
|
|
214
|
+
if (lastContentNode) {
|
|
215
|
+
if (lastContentNode.kind === xmlui_parser_1.SyntaxKind.StringLiteral ||
|
|
216
|
+
lastContentNode.kind === xmlui_parser_1.SyntaxKind.TextNode) {
|
|
217
|
+
lastContentIsText = true;
|
|
218
|
+
const trailingNewlinesInText = newlinesInTrailingWhitespace(this.getText(lastContentNode));
|
|
219
|
+
newlinesAfterText = Math.min(trailingNewlinesInText, this.maxConsecutiveNewlines);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const contentEndsInNewlines = lastContentIsText && newlinesAfterText > 0;
|
|
223
|
+
let acc = "";
|
|
224
|
+
if (contentEndsInNewlines) {
|
|
225
|
+
acc += this.newlineToken.repeat(newlinesAfterText);
|
|
226
|
+
}
|
|
227
|
+
for (let i = 0; i < trivias.length; ++i) {
|
|
228
|
+
const t = trivias[i];
|
|
229
|
+
switch (t.kind) {
|
|
230
|
+
case xmlui_parser_1.SyntaxKind.CommentTrivia: {
|
|
231
|
+
if (i === 0 && ((lastContentIsText && newlinesAfterText === 0) || !lastContentIsText)) {
|
|
232
|
+
acc += " ";
|
|
233
|
+
acc += this.getText(t);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
acc += this.indent(this.indentationLvl + 1) + this.getText(t);
|
|
116
237
|
}
|
|
238
|
+
if (((_a = trivias[i + 1]) === null || _a === void 0 ? void 0 : _a.kind) === xmlui_parser_1.SyntaxKind.CommentTrivia) {
|
|
239
|
+
acc += this.newlineToken;
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case xmlui_parser_1.SyntaxKind.NewLineTrivia: {
|
|
244
|
+
acc += this.newlineToken;
|
|
117
245
|
break;
|
|
246
|
+
}
|
|
118
247
|
}
|
|
119
248
|
}
|
|
249
|
+
if (!lastContentNode && trivias.length === 0) {
|
|
250
|
+
// leave the closing tag on the same line
|
|
251
|
+
// when there's nothing inside it
|
|
252
|
+
}
|
|
253
|
+
else if (contentEndsInNewlines || ((_b = trivias.at(-1)) === null || _b === void 0 ? void 0 : _b.kind) === xmlui_parser_1.SyntaxKind.NewLineTrivia) {
|
|
254
|
+
acc += this.indent(this.indentationLvl);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
acc += this.newlineToken;
|
|
258
|
+
acc += this.indent(this.indentationLvl);
|
|
259
|
+
}
|
|
120
260
|
return acc;
|
|
121
261
|
}
|
|
122
262
|
printTagLike(node) {
|
|
@@ -134,37 +274,38 @@ class XmluiFormatter {
|
|
|
134
274
|
const hasContentList = contentListIdx !== -1;
|
|
135
275
|
const closeNodeStartIdx = node.children.findIndex((c) => c.kind === xmlui_parser_1.SyntaxKind.CloseNodeStart);
|
|
136
276
|
const hasCloseNodeStart = closeNodeStartIdx !== -1;
|
|
137
|
-
let
|
|
277
|
+
let nodesOfOpenTagNodeEndIdx;
|
|
138
278
|
if (hasContentList) {
|
|
139
|
-
|
|
279
|
+
nodesOfOpenTagNodeEndIdx = contentListIdx;
|
|
140
280
|
}
|
|
141
281
|
else if (hasCloseNodeStart) {
|
|
142
|
-
|
|
282
|
+
nodesOfOpenTagNodeEndIdx = closeNodeStartIdx;
|
|
143
283
|
}
|
|
144
284
|
else {
|
|
145
|
-
|
|
285
|
+
nodesOfOpenTagNodeEndIdx = node.children.length;
|
|
146
286
|
}
|
|
147
|
-
const
|
|
148
|
-
acc += this.printOpenTag(
|
|
287
|
+
const nodesOfOpenTagNode = node.children.slice(0, nodesOfOpenTagNodeEndIdx);
|
|
288
|
+
acc += this.printOpenTag(nodesOfOpenTagNode);
|
|
289
|
+
let lastContentNode = null;
|
|
149
290
|
if (hasContentList) {
|
|
150
291
|
const contentListNode = node.children[contentListIdx];
|
|
292
|
+
lastContentNode = contentListNode.children.at(-1);
|
|
151
293
|
++this.indentationLvl;
|
|
152
|
-
acc += this.newlineToken;
|
|
153
294
|
acc += this.printContentListNode(contentListNode);
|
|
154
295
|
--this.indentationLvl;
|
|
155
296
|
}
|
|
156
|
-
let
|
|
297
|
+
let nodesOfCloseTagNodeStartIdx;
|
|
157
298
|
if (hasCloseNodeStart) {
|
|
158
|
-
|
|
299
|
+
nodesOfCloseTagNodeStartIdx = closeNodeStartIdx;
|
|
159
300
|
}
|
|
160
301
|
else if (hasContentList) {
|
|
161
|
-
|
|
302
|
+
nodesOfCloseTagNodeStartIdx = contentListIdx + 1;
|
|
162
303
|
}
|
|
163
304
|
else {
|
|
164
|
-
|
|
305
|
+
nodesOfCloseTagNodeStartIdx = nodesOfOpenTagNodeEndIdx + 1;
|
|
165
306
|
}
|
|
166
|
-
const closeTagNodes = node.children.slice(
|
|
167
|
-
acc += this.printClosingTag(closeTagNodes,
|
|
307
|
+
const closeTagNodes = node.children.slice(nodesOfCloseTagNodeStartIdx);
|
|
308
|
+
acc += this.printClosingTag(closeTagNodes, lastContentNode);
|
|
168
309
|
return acc;
|
|
169
310
|
}
|
|
170
311
|
printOpenTag(tagChildren) {
|
|
@@ -192,21 +333,16 @@ class XmluiFormatter {
|
|
|
192
333
|
}
|
|
193
334
|
return acc;
|
|
194
335
|
}
|
|
195
|
-
printClosingTag(tagChildren,
|
|
336
|
+
printClosingTag(tagChildren, lastContentNode) {
|
|
337
|
+
var _a;
|
|
196
338
|
let acc = "";
|
|
197
339
|
for (let i = 0; i < tagChildren.length; ++i) {
|
|
198
340
|
const c = tagChildren[i];
|
|
199
341
|
switch (c.kind) {
|
|
200
342
|
case xmlui_parser_1.SyntaxKind.CloseNodeStart:
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
acc += this.newlineToken;
|
|
205
|
-
}
|
|
206
|
-
acc += this.indent(this.indentationLvl + 1);
|
|
207
|
-
acc += comment + this.newlineToken;
|
|
208
|
-
}
|
|
209
|
-
acc += this.indent(this.indentationLvl) + "</";
|
|
343
|
+
const collapsedTrivias = this.collapseBlankLines((_a = c.triviaBefore) !== null && _a !== void 0 ? _a : []);
|
|
344
|
+
acc += this.addWsToCollapsedCloseNodeStartTrivia(collapsedTrivias, lastContentNode);
|
|
345
|
+
acc += "</";
|
|
210
346
|
break;
|
|
211
347
|
case xmlui_parser_1.SyntaxKind.TagNameNode:
|
|
212
348
|
acc += this.printTagName(c);
|
|
@@ -224,20 +360,20 @@ class XmluiFormatter {
|
|
|
224
360
|
let acc = "";
|
|
225
361
|
let closingIsNodeClose = false;
|
|
226
362
|
let attrSegmentsFormatted = [];
|
|
227
|
-
let attrListOffsetInAcc;
|
|
228
363
|
let closingSegmentsFormatted = [];
|
|
229
|
-
let closingOffsetInAcc;
|
|
230
364
|
let attrsAlreadyMultiline = false;
|
|
231
365
|
for (let i = 0; i < nodes.length; ++i) {
|
|
232
366
|
const c = nodes[i];
|
|
233
367
|
switch (c.kind) {
|
|
234
368
|
case xmlui_parser_1.SyntaxKind.AttributeListNode:
|
|
235
369
|
attrSegmentsFormatted = this.printAttrList(c);
|
|
236
|
-
attrsAlreadyMultiline = c.children.some((attr) =>
|
|
237
|
-
|
|
370
|
+
attrsAlreadyMultiline = c.children.some((attr) => {
|
|
371
|
+
var _a;
|
|
372
|
+
return (_a = attr
|
|
373
|
+
.getTriviaNodes()) === null || _a === void 0 ? void 0 : _a.some((attrTrivia) => attrTrivia.kind === xmlui_parser_1.SyntaxKind.NewLineTrivia);
|
|
374
|
+
});
|
|
238
375
|
break;
|
|
239
376
|
case xmlui_parser_1.SyntaxKind.NodeClose: {
|
|
240
|
-
closingOffsetInAcc = acc.length;
|
|
241
377
|
closingIsNodeClose = true;
|
|
242
378
|
const comments = this.getCommentsSpaceJoined(c);
|
|
243
379
|
if (comments) {
|
|
@@ -249,7 +385,6 @@ class XmluiFormatter {
|
|
|
249
385
|
break;
|
|
250
386
|
}
|
|
251
387
|
case xmlui_parser_1.SyntaxKind.NodeEnd: {
|
|
252
|
-
closingOffsetInAcc = acc.length;
|
|
253
388
|
closingIsNodeClose = false;
|
|
254
389
|
const comments = this.getCommentsSpaceJoined(c);
|
|
255
390
|
if (comments) {
|
|
@@ -376,15 +511,12 @@ class XmluiFormatter {
|
|
|
376
511
|
printContentString(node) {
|
|
377
512
|
return this.getText(node, false).trim();
|
|
378
513
|
}
|
|
379
|
-
printEveryTrivia(node) {
|
|
380
|
-
var _a;
|
|
381
|
-
return ((_a = node.triviaBefore) !== null && _a !== void 0 ? _a : []).map((trivia) => this.getText(trivia)).join("");
|
|
382
|
-
}
|
|
383
514
|
indent(lvl) {
|
|
384
515
|
return this.indentationToken.repeat(lvl);
|
|
385
516
|
}
|
|
386
517
|
getComments(node) {
|
|
387
|
-
|
|
518
|
+
var _a;
|
|
519
|
+
const triviaNodes = (_a = node.getTriviaNodes()) !== null && _a !== void 0 ? _a : [];
|
|
388
520
|
return triviaNodes
|
|
389
521
|
.filter(({ kind }) => kind === xmlui_parser_1.SyntaxKind.CommentTrivia)
|
|
390
522
|
.map((comment) => this.getText(comment));
|
|
@@ -405,7 +537,10 @@ class XmluiFormatter {
|
|
|
405
537
|
* Check if comments have newlines before them
|
|
406
538
|
*/
|
|
407
539
|
hasNewlineTriviaBeforeComment(node) {
|
|
408
|
-
const triviaNodes =
|
|
540
|
+
const triviaNodes = node.getTriviaNodes();
|
|
541
|
+
if (!triviaNodes) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
409
544
|
for (let c of triviaNodes) {
|
|
410
545
|
if (c.kind === xmlui_parser_1.SyntaxKind.NewLineTrivia) {
|
|
411
546
|
return true;
|
|
@@ -419,12 +554,16 @@ class XmluiFormatter {
|
|
|
419
554
|
}
|
|
420
555
|
function format(node, getText, options) {
|
|
421
556
|
const formatter = new XmluiFormatter(node, getText, options);
|
|
422
|
-
|
|
423
|
-
return formattedString;
|
|
557
|
+
return formatter.format();
|
|
424
558
|
}
|
|
425
|
-
function
|
|
426
|
-
const lastNewlineIdx = text.lastIndexOf("\n");
|
|
559
|
+
function newlinesInTrailingWhitespace(text) {
|
|
427
560
|
const trimmedPrevText = text.trimEnd();
|
|
428
|
-
const
|
|
429
|
-
|
|
561
|
+
const trailingWhitespace = text.substring(trimmedPrevText.length);
|
|
562
|
+
let newlineCount = 0;
|
|
563
|
+
for (const c of trailingWhitespace) {
|
|
564
|
+
if (c === "\n") {
|
|
565
|
+
newlineCount++;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return newlineCount;
|
|
430
569
|
}
|
|
@@ -83,6 +83,9 @@ function parseXmlUiMarkup(text) {
|
|
|
83
83
|
case syntax_kind_1.SyntaxKind.OpenNodeStart:
|
|
84
84
|
parseOpeningTag();
|
|
85
85
|
break;
|
|
86
|
+
case syntax_kind_1.SyntaxKind.TextNode:
|
|
87
|
+
bumpAny();
|
|
88
|
+
break;
|
|
86
89
|
case syntax_kind_1.SyntaxKind.CloseNodeStart: {
|
|
87
90
|
const errNode = errNodeUntil(RECOVER_FILE);
|
|
88
91
|
errorAt(diagnostics_1.DIAGS.unexpectedCloseTag, errNode.pos, errNode.end);
|
|
@@ -493,11 +496,9 @@ function parseXmlUiMarkup(text) {
|
|
|
493
496
|
else {
|
|
494
497
|
pos = token.start;
|
|
495
498
|
}
|
|
496
|
-
let start = pos;
|
|
497
499
|
let triviaBefore = undefined;
|
|
498
500
|
if (leadingComments.length > 0) {
|
|
499
501
|
triviaBefore = leadingComments;
|
|
500
|
-
start = leadingComments[0].pos;
|
|
501
502
|
}
|
|
502
503
|
let kind = syntax_kind_1.SyntaxKind.TextNode;
|
|
503
504
|
let end = -1;
|
|
@@ -27,6 +27,11 @@ class Node {
|
|
|
27
27
|
isAttributeNode() {
|
|
28
28
|
return this.kind === syntax_kind_1.SyntaxKind.AttributeNode;
|
|
29
29
|
}
|
|
30
|
+
isTagLike() {
|
|
31
|
+
return (this.kind === syntax_kind_1.SyntaxKind.ElementNode ||
|
|
32
|
+
this.kind === syntax_kind_1.SyntaxKind.CData ||
|
|
33
|
+
this.kind == syntax_kind_1.SyntaxKind.Script);
|
|
34
|
+
}
|
|
30
35
|
isAttributeKeyNode() {
|
|
31
36
|
return this.kind === syntax_kind_1.SyntaxKind.AttributeKeyNode;
|
|
32
37
|
}
|
|
@@ -42,6 +47,17 @@ class Node {
|
|
|
42
47
|
findTokenAtPos(position) {
|
|
43
48
|
return (0, utils_1.findTokenAtPos)(this, position);
|
|
44
49
|
}
|
|
50
|
+
getTriviaNodes() {
|
|
51
|
+
if (this.pos === this.start) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
else if (this.triviaBefore) {
|
|
55
|
+
return this.triviaBefore;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return this.children[0].getTriviaNodes();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
45
61
|
}
|
|
46
62
|
exports.Node = Node;
|
|
47
63
|
class ElementNode extends Node {
|
|
@@ -1429,7 +1429,7 @@ declare type SpinnerProps = {
|
|
|
1429
1429
|
className?: string;
|
|
1430
1430
|
};
|
|
1431
1431
|
|
|
1432
|
-
declare const Splitter: ({ initialPrimarySize, minPrimarySize, maxPrimarySize, orientation, children, style, className, swapped, floating, splitterTemplate, resize, ...rest }: SplitterProps) => JSX_2.Element;
|
|
1432
|
+
declare const Splitter: ({ initialPrimarySize, minPrimarySize, maxPrimarySize, orientation, children, style, className, swapped, floating, splitterTemplate, resize, visibleChildCount, ...rest }: SplitterProps) => JSX_2.Element;
|
|
1433
1433
|
|
|
1434
1434
|
declare type SplitterProps = {
|
|
1435
1435
|
children: default_2.ReactNode[] | default_2.ReactNode;
|
|
@@ -1443,6 +1443,7 @@ declare type SplitterProps = {
|
|
|
1443
1443
|
initialPrimarySize?: string;
|
|
1444
1444
|
minPrimarySize?: string;
|
|
1445
1445
|
maxPrimarySize?: string;
|
|
1446
|
+
visibleChildCount?: number;
|
|
1446
1447
|
};
|
|
1447
1448
|
|
|
1448
1449
|
declare type SPREAD_EXPRESSION = typeof T_SPREAD_EXPRESSION;
|
|
@@ -1574,7 +1575,7 @@ declare const standaloneExports: {
|
|
|
1574
1575
|
autoFocus?: boolean;
|
|
1575
1576
|
contextualLabel?: string;
|
|
1576
1577
|
} & Pick<default_2.HTMLAttributes<HTMLButtonElement>, "className" | "aria-disabled" | "aria-label" | "aria-controls" | "aria-expanded" | "role" | "onFocus" | "onBlur" | "onClick" | "tabIndex" | "onMouseEnter" | "onMouseLeave"> & default_2.RefAttributes<HTMLButtonElement>>;
|
|
1577
|
-
Splitter: ({ initialPrimarySize, minPrimarySize, maxPrimarySize, orientation, children, style, className, swapped, floating, splitterTemplate, resize, ...rest }: {
|
|
1578
|
+
Splitter: ({ initialPrimarySize, minPrimarySize, maxPrimarySize, orientation, children, style, className, swapped, floating, splitterTemplate, resize, visibleChildCount, ...rest }: {
|
|
1578
1579
|
children: default_2.ReactNode[] | default_2.ReactNode;
|
|
1579
1580
|
style?: default_2.CSSProperties;
|
|
1580
1581
|
className?: string;
|
|
@@ -1586,6 +1587,7 @@ declare const standaloneExports: {
|
|
|
1586
1587
|
initialPrimarySize?: string;
|
|
1587
1588
|
minPrimarySize?: string;
|
|
1588
1589
|
maxPrimarySize?: string;
|
|
1590
|
+
visibleChildCount?: number;
|
|
1589
1591
|
}) => default_3.JSX.Element;
|
|
1590
1592
|
getColor: typeof xmluiExports.getColor;
|
|
1591
1593
|
TabItem: default_2.ForwardRefExoticComponent<Tab_2 & default_2.RefAttributes<HTMLDivElement>>;
|