@wireweave/core 1.0.0-beta.20260107130839 → 1.0.0-beta.20260107133417
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/index.cjs +0 -1
- package/dist/index.js +0 -1
- package/dist/parser.cjs +0 -1
- package/dist/parser.js +0 -1
- package/dist/renderer.cjs +0 -1
- package/dist/renderer.js +0 -1
- package/package.json +7 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parser.cjs.map +0 -1
- package/dist/parser.js.map +0 -1
- package/dist/renderer.cjs.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/src/ast/guards.ts +0 -361
- package/src/ast/index.ts +0 -9
- package/src/ast/types.ts +0 -661
- package/src/ast/utils.ts +0 -238
- package/src/grammar/wireframe.peggy +0 -677
- package/src/icons/lucide-icons.ts +0 -46422
- package/src/index.ts +0 -20
- package/src/parser/generated-parser.js +0 -5199
- package/src/parser/index.ts +0 -214
- package/src/renderer/html/base.ts +0 -186
- package/src/renderer/html/components.ts +0 -1092
- package/src/renderer/html/index.ts +0 -1608
- package/src/renderer/html/layout.ts +0 -392
- package/src/renderer/index.ts +0 -143
- package/src/renderer/styles-components.ts +0 -1232
- package/src/renderer/styles.ts +0 -382
- package/src/renderer/svg/index.ts +0 -1050
- package/src/renderer/types.ts +0 -173
- package/src/types/index.ts +0 -138
- package/src/viewport/index.ts +0 -17
- package/src/viewport/presets.ts +0 -181
|
@@ -1,677 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* wireweave Grammar - Core
|
|
3
|
-
*
|
|
4
|
-
* Peggy grammar for parsing wireframe DSL
|
|
5
|
-
* v1.0 - 36 components, black/white/gray style
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
// Helper: Create AST node with location info
|
|
10
|
-
function createNode(type, props = {}) {
|
|
11
|
-
return {
|
|
12
|
-
type,
|
|
13
|
-
...props,
|
|
14
|
-
loc: location()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Helper: Flatten array of attributes into object
|
|
19
|
-
// Renames 'type' to 'inputType' to avoid conflict with AST node type
|
|
20
|
-
function attrsToObject(attrs, renameType = false) {
|
|
21
|
-
if (!attrs || attrs.length === 0) return {};
|
|
22
|
-
const result = {};
|
|
23
|
-
for (const attr of attrs) {
|
|
24
|
-
if (renameType && attr.name === 'type') {
|
|
25
|
-
result.inputType = attr.value;
|
|
26
|
-
} else {
|
|
27
|
-
result[attr.name] = attr.value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// ============================================================
|
|
35
|
-
// Entry Point
|
|
36
|
-
// ============================================================
|
|
37
|
-
|
|
38
|
-
Document
|
|
39
|
-
= _ children:TopLevelElement* _ {
|
|
40
|
-
return createNode('Document', { children: children.filter(c => c !== null) });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
TopLevelElement
|
|
44
|
-
= Page
|
|
45
|
-
/ Comment { return null; }
|
|
46
|
-
|
|
47
|
-
// ============================================================
|
|
48
|
-
// Page
|
|
49
|
-
// ============================================================
|
|
50
|
-
|
|
51
|
-
Page
|
|
52
|
-
= "page" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
53
|
-
return createNode('Page', {
|
|
54
|
-
title: label || null,
|
|
55
|
-
...attrsToObject(attrs),
|
|
56
|
-
children
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ============================================================
|
|
61
|
-
// Children (Block Content)
|
|
62
|
-
// ============================================================
|
|
63
|
-
|
|
64
|
-
Children
|
|
65
|
-
= children:(Child _)* {
|
|
66
|
-
return children.map(c => c[0]).filter(c => c !== null);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
Child
|
|
70
|
-
= LayoutElement
|
|
71
|
-
/ ContainerElement
|
|
72
|
-
/ UIElement
|
|
73
|
-
/ Comment { return null; }
|
|
74
|
-
|
|
75
|
-
// ============================================================
|
|
76
|
-
// Layout Elements
|
|
77
|
-
// ============================================================
|
|
78
|
-
|
|
79
|
-
LayoutElement
|
|
80
|
-
= Header
|
|
81
|
-
/ Main
|
|
82
|
-
/ Footer
|
|
83
|
-
/ Sidebar
|
|
84
|
-
/ Row
|
|
85
|
-
/ Col
|
|
86
|
-
|
|
87
|
-
Header
|
|
88
|
-
= "header" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
89
|
-
return createNode('Header', {
|
|
90
|
-
...attrsToObject(attrs),
|
|
91
|
-
children
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
Main
|
|
96
|
-
= "main" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
97
|
-
return createNode('Main', {
|
|
98
|
-
...attrsToObject(attrs),
|
|
99
|
-
children
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
Footer
|
|
104
|
-
= "footer" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
105
|
-
return createNode('Footer', {
|
|
106
|
-
...attrsToObject(attrs),
|
|
107
|
-
children
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
Sidebar
|
|
112
|
-
= "sidebar" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
113
|
-
return createNode('Sidebar', {
|
|
114
|
-
...attrsToObject(attrs),
|
|
115
|
-
children
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
Row
|
|
120
|
-
= "row" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
121
|
-
return createNode('Row', {
|
|
122
|
-
...attrsToObject(attrs),
|
|
123
|
-
children
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Col
|
|
128
|
-
= "col" _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
129
|
-
return createNode('Col', {
|
|
130
|
-
...attrsToObject(attrs),
|
|
131
|
-
children
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ============================================================
|
|
136
|
-
// Container Elements
|
|
137
|
-
// ============================================================
|
|
138
|
-
|
|
139
|
-
ContainerElement
|
|
140
|
-
= Card
|
|
141
|
-
/ Modal
|
|
142
|
-
/ Drawer
|
|
143
|
-
/ Accordion
|
|
144
|
-
/ Section
|
|
145
|
-
|
|
146
|
-
Card
|
|
147
|
-
= "card" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
148
|
-
return createNode('Card', {
|
|
149
|
-
title: label || null,
|
|
150
|
-
...attrsToObject(attrs),
|
|
151
|
-
children
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
Modal
|
|
156
|
-
= "modal" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
157
|
-
return createNode('Modal', {
|
|
158
|
-
title: label || null,
|
|
159
|
-
...attrsToObject(attrs),
|
|
160
|
-
children
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
Drawer
|
|
165
|
-
= "drawer" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
166
|
-
return createNode('Drawer', {
|
|
167
|
-
title: label || null,
|
|
168
|
-
...attrsToObject(attrs),
|
|
169
|
-
children
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
Accordion
|
|
174
|
-
= "accordion" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
175
|
-
return createNode('Accordion', {
|
|
176
|
-
title: label || null,
|
|
177
|
-
...attrsToObject(attrs),
|
|
178
|
-
children
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
Section
|
|
183
|
-
= "section" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
184
|
-
return createNode('Section', {
|
|
185
|
-
title: label || null,
|
|
186
|
-
...attrsToObject(attrs),
|
|
187
|
-
children
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ============================================================
|
|
192
|
-
// UI Elements (Text, Title, Button, Input, etc.)
|
|
193
|
-
// ============================================================
|
|
194
|
-
|
|
195
|
-
UIElement
|
|
196
|
-
= Text
|
|
197
|
-
/ Title
|
|
198
|
-
/ Link
|
|
199
|
-
/ Button
|
|
200
|
-
/ Input
|
|
201
|
-
/ Textarea
|
|
202
|
-
/ Select
|
|
203
|
-
/ Checkbox
|
|
204
|
-
/ Radio
|
|
205
|
-
/ Switch
|
|
206
|
-
/ Slider
|
|
207
|
-
/ Image
|
|
208
|
-
/ Placeholder
|
|
209
|
-
/ Avatar
|
|
210
|
-
/ Badge
|
|
211
|
-
/ Icon
|
|
212
|
-
/ Table
|
|
213
|
-
/ List
|
|
214
|
-
/ Alert
|
|
215
|
-
/ Toast
|
|
216
|
-
/ Progress
|
|
217
|
-
/ Spinner
|
|
218
|
-
/ Tooltip
|
|
219
|
-
/ Popover
|
|
220
|
-
/ Dropdown
|
|
221
|
-
/ Nav
|
|
222
|
-
/ Tabs
|
|
223
|
-
/ Breadcrumb
|
|
224
|
-
/ Divider
|
|
225
|
-
|
|
226
|
-
// Text Components
|
|
227
|
-
Text
|
|
228
|
-
= "text" _ label:StringLiteral _ attrs:Attributes? {
|
|
229
|
-
return createNode('Text', {
|
|
230
|
-
content: label,
|
|
231
|
-
...attrsToObject(attrs)
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
Title
|
|
236
|
-
= "title" _ label:StringLiteral _ attrs:Attributes? {
|
|
237
|
-
return createNode('Title', {
|
|
238
|
-
content: label,
|
|
239
|
-
...attrsToObject(attrs)
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
Link
|
|
244
|
-
= "link" _ label:StringLiteral _ attrs:Attributes? {
|
|
245
|
-
return createNode('Link', {
|
|
246
|
-
content: label,
|
|
247
|
-
...attrsToObject(attrs)
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Button
|
|
252
|
-
Button
|
|
253
|
-
= "button" _ label:StringLiteral _ attrs:Attributes? {
|
|
254
|
-
return createNode('Button', {
|
|
255
|
-
content: label,
|
|
256
|
-
...attrsToObject(attrs)
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Input Components
|
|
261
|
-
Input
|
|
262
|
-
= "input" _ label:StringLiteral? _ attrs:Attributes? {
|
|
263
|
-
return createNode('Input', {
|
|
264
|
-
label: label || null,
|
|
265
|
-
...attrsToObject(attrs, true)
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
Textarea
|
|
270
|
-
= "textarea" _ label:StringLiteral? _ attrs:Attributes? {
|
|
271
|
-
return createNode('Textarea', {
|
|
272
|
-
label: label || null,
|
|
273
|
-
...attrsToObject(attrs)
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
Select
|
|
278
|
-
= "select" _ label:StringLiteral? _ options:Array? _ attrs:Attributes? {
|
|
279
|
-
return createNode('Select', {
|
|
280
|
-
label: label || null,
|
|
281
|
-
options: options || [],
|
|
282
|
-
...attrsToObject(attrs)
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
Checkbox
|
|
287
|
-
= "checkbox" _ label:StringLiteral? _ attrs:Attributes? {
|
|
288
|
-
return createNode('Checkbox', {
|
|
289
|
-
label: label || null,
|
|
290
|
-
...attrsToObject(attrs)
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
Radio
|
|
295
|
-
= "radio" _ label:StringLiteral? _ attrs:Attributes? {
|
|
296
|
-
return createNode('Radio', {
|
|
297
|
-
label: label || null,
|
|
298
|
-
...attrsToObject(attrs)
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
Switch
|
|
303
|
-
= "switch" _ label:StringLiteral? _ attrs:Attributes? {
|
|
304
|
-
return createNode('Switch', {
|
|
305
|
-
label: label || null,
|
|
306
|
-
...attrsToObject(attrs)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
Slider
|
|
311
|
-
= "slider" _ label:StringLiteral? _ attrs:Attributes? {
|
|
312
|
-
return createNode('Slider', {
|
|
313
|
-
label: label || null,
|
|
314
|
-
...attrsToObject(attrs)
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Display Components
|
|
319
|
-
Image
|
|
320
|
-
= "image" _ src:StringLiteral? _ attrs:Attributes? {
|
|
321
|
-
return createNode('Image', {
|
|
322
|
-
src: src || null,
|
|
323
|
-
...attrsToObject(attrs)
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
Placeholder
|
|
328
|
-
= "placeholder" _ label:StringLiteral? _ attrs:Attributes? {
|
|
329
|
-
return createNode('Placeholder', {
|
|
330
|
-
label: label || null,
|
|
331
|
-
...attrsToObject(attrs)
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
Avatar
|
|
336
|
-
= "avatar" _ label:StringLiteral? _ attrs:Attributes? {
|
|
337
|
-
return createNode('Avatar', {
|
|
338
|
-
name: label || null,
|
|
339
|
-
...attrsToObject(attrs)
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
Badge
|
|
344
|
-
= "badge" _ label:StringLiteral _ attrs:Attributes? {
|
|
345
|
-
return createNode('Badge', {
|
|
346
|
-
content: label,
|
|
347
|
-
...attrsToObject(attrs)
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
Icon
|
|
352
|
-
= "icon" _ name:StringLiteral _ attrs:Attributes? {
|
|
353
|
-
return createNode('Icon', {
|
|
354
|
-
name: name,
|
|
355
|
-
...attrsToObject(attrs)
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// Data Components
|
|
360
|
-
Table
|
|
361
|
-
= "table" _ attrs:Attributes? _ "{" _ rows:TableContent _ "}" {
|
|
362
|
-
return createNode('Table', {
|
|
363
|
-
...attrsToObject(attrs),
|
|
364
|
-
...rows
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
TableContent
|
|
369
|
-
= items:(TableRow _)* {
|
|
370
|
-
const columns = [];
|
|
371
|
-
const rows = [];
|
|
372
|
-
for (const item of items.map(i => i[0]).filter(i => i !== null)) {
|
|
373
|
-
if (item.type === 'columns') columns.push(...item.values);
|
|
374
|
-
else if (item.type === 'row') rows.push(item.values);
|
|
375
|
-
}
|
|
376
|
-
return { columns, rows };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
TableRow
|
|
380
|
-
= "columns" _ values:Array { return { type: 'columns', values }; }
|
|
381
|
-
/ "row" _ values:Array { return { type: 'row', values }; }
|
|
382
|
-
/ Comment { return null; }
|
|
383
|
-
|
|
384
|
-
List
|
|
385
|
-
= "list" _ items:Array? _ attrs:Attributes? _ block:ListBlock? {
|
|
386
|
-
return createNode('List', {
|
|
387
|
-
items: items || (block ? block : []),
|
|
388
|
-
...attrsToObject(attrs)
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
ListBlock
|
|
393
|
-
= "{" _ items:(ListItem _)* "}" {
|
|
394
|
-
return items.map(i => i[0]).filter(i => i !== null);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
ListItem
|
|
398
|
-
= "item" _ label:StringLiteral _ attrs:Attributes? _ nested:ListBlock? {
|
|
399
|
-
return {
|
|
400
|
-
content: label,
|
|
401
|
-
...attrsToObject(attrs),
|
|
402
|
-
children: nested || []
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
/ Comment { return null; }
|
|
406
|
-
|
|
407
|
-
// Feedback Components
|
|
408
|
-
Alert
|
|
409
|
-
= "alert" _ label:StringLiteral _ attrs:Attributes? {
|
|
410
|
-
return createNode('Alert', {
|
|
411
|
-
content: label,
|
|
412
|
-
...attrsToObject(attrs)
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
Toast
|
|
417
|
-
= "toast" _ label:StringLiteral _ attrs:Attributes? {
|
|
418
|
-
return createNode('Toast', {
|
|
419
|
-
content: label,
|
|
420
|
-
...attrsToObject(attrs)
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
Progress
|
|
425
|
-
= "progress" _ attrs:Attributes? {
|
|
426
|
-
return createNode('Progress', {
|
|
427
|
-
...attrsToObject(attrs)
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
Spinner
|
|
432
|
-
= "spinner" _ label:StringLiteral? _ attrs:Attributes? {
|
|
433
|
-
return createNode('Spinner', {
|
|
434
|
-
label: label || null,
|
|
435
|
-
...attrsToObject(attrs)
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// Overlay Components
|
|
440
|
-
Tooltip
|
|
441
|
-
= "tooltip" _ label:StringLiteral _ attrs:Attributes? {
|
|
442
|
-
return createNode('Tooltip', {
|
|
443
|
-
content: label,
|
|
444
|
-
...attrsToObject(attrs),
|
|
445
|
-
children: []
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
Popover
|
|
450
|
-
= "popover" _ label:StringLiteral? _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
451
|
-
return createNode('Popover', {
|
|
452
|
-
title: label || null,
|
|
453
|
-
...attrsToObject(attrs),
|
|
454
|
-
children
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
Dropdown
|
|
459
|
-
= "dropdown" _ attrs:Attributes? _ "{" _ items:DropdownContent _ "}" {
|
|
460
|
-
return createNode('Dropdown', {
|
|
461
|
-
...attrsToObject(attrs),
|
|
462
|
-
items
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
DropdownContent
|
|
467
|
-
= items:(DropdownItem _)* {
|
|
468
|
-
return items.map(i => i[0]).filter(i => i !== null);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
DropdownItem
|
|
472
|
-
= "item" _ label:StringLiteral _ attrs:Attributes? {
|
|
473
|
-
return { label, ...attrsToObject(attrs) };
|
|
474
|
-
}
|
|
475
|
-
/ "divider" { return { type: 'divider' }; }
|
|
476
|
-
/ Comment { return null; }
|
|
477
|
-
|
|
478
|
-
// Navigation Components
|
|
479
|
-
Nav
|
|
480
|
-
= "nav" _ items:Array? _ attrs:Attributes? {
|
|
481
|
-
return createNode('Nav', {
|
|
482
|
-
items: items || [],
|
|
483
|
-
...attrsToObject(attrs)
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
Tabs
|
|
488
|
-
= "tabs" _ items:Array? _ attrs:Attributes? _ block:TabsBlock? {
|
|
489
|
-
return createNode('Tabs', {
|
|
490
|
-
items: items || [],
|
|
491
|
-
...attrsToObject(attrs),
|
|
492
|
-
children: block || []
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
TabsBlock
|
|
497
|
-
= "{" _ tabs:(TabItem _)* "}" {
|
|
498
|
-
return tabs.map(t => t[0]).filter(t => t !== null);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
TabItem
|
|
502
|
-
= "tab" _ label:StringLiteral _ attrs:Attributes? _ "{" _ children:Children _ "}" {
|
|
503
|
-
return {
|
|
504
|
-
label,
|
|
505
|
-
...attrsToObject(attrs),
|
|
506
|
-
children
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
/ Comment { return null; }
|
|
510
|
-
|
|
511
|
-
Breadcrumb
|
|
512
|
-
= "breadcrumb" _ items:Array _ attrs:Attributes? {
|
|
513
|
-
return createNode('Breadcrumb', {
|
|
514
|
-
items: items,
|
|
515
|
-
...attrsToObject(attrs)
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// Divider
|
|
520
|
-
Divider
|
|
521
|
-
= "divider" _ attrs:Attributes? {
|
|
522
|
-
return createNode('Divider', {
|
|
523
|
-
...attrsToObject(attrs)
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// ============================================================
|
|
528
|
-
// Attributes
|
|
529
|
-
// ============================================================
|
|
530
|
-
|
|
531
|
-
Attributes
|
|
532
|
-
= attrs:Attribute+ { return attrs; }
|
|
533
|
-
|
|
534
|
-
Attribute
|
|
535
|
-
= _ name:AttributeName _ "=" _ value:AttributeValue {
|
|
536
|
-
return { name, value };
|
|
537
|
-
}
|
|
538
|
-
/ _ flag:AttributeName &(_ (ChildKeyword / AttributeName / "=" / "{" / "}" / "[" / "//" / "/*" / !.)) {
|
|
539
|
-
return { name: flag, value: true };
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// Attribute names - special handling for context-sensitive keywords
|
|
543
|
-
AttributeName
|
|
544
|
-
= !ChildKeyword name:Identifier { return name; }
|
|
545
|
-
|
|
546
|
-
// Keywords that start a child component (these cannot be attribute names)
|
|
547
|
-
// Note: 'placeholder', 'icon', 'title' are valid as attribute names
|
|
548
|
-
ChildKeyword
|
|
549
|
-
= ("page" / "header" / "main" / "footer" / "sidebar" / "row" / "col"
|
|
550
|
-
/ "card" / "modal" / "drawer" / "accordion" / "section"
|
|
551
|
-
/ "text" / "link" / "button"
|
|
552
|
-
/ "input" / "textarea" / "select" / "checkbox" / "radio" / "switch" / "slider"
|
|
553
|
-
/ "image" / "avatar" / "badge"
|
|
554
|
-
/ "table" / "columns" / "list" / "item"
|
|
555
|
-
/ "alert" / "toast" / "progress" / "spinner"
|
|
556
|
-
/ "tooltip" / "popover" / "dropdown" / "divider"
|
|
557
|
-
/ "nav" / "tabs" / "tab" / "breadcrumb") !IdentifierChar
|
|
558
|
-
|
|
559
|
-
IdentifierChar
|
|
560
|
-
= [a-zA-Z0-9_-]
|
|
561
|
-
|
|
562
|
-
AttributeValue
|
|
563
|
-
= StringLiteral
|
|
564
|
-
/ ValueWithUnit // Must come before Number to match "16px" before "16"
|
|
565
|
-
/ Number
|
|
566
|
-
/ Boolean
|
|
567
|
-
/ Identifier
|
|
568
|
-
/ Array
|
|
569
|
-
/ Object
|
|
570
|
-
|
|
571
|
-
// ============================================================
|
|
572
|
-
// Literals
|
|
573
|
-
// ============================================================
|
|
574
|
-
|
|
575
|
-
StringLiteral "string"
|
|
576
|
-
= '"' chars:DoubleStringChar* '"' { return chars.join(''); }
|
|
577
|
-
/ "'" chars:SingleStringChar* "'" { return chars.join(''); }
|
|
578
|
-
|
|
579
|
-
DoubleStringChar
|
|
580
|
-
= !'"' !"\\" char:. { return char; }
|
|
581
|
-
/ "\\" seq:EscapeSequence { return seq; }
|
|
582
|
-
|
|
583
|
-
SingleStringChar
|
|
584
|
-
= !"'" !"\\" char:. { return char; }
|
|
585
|
-
/ "\\" seq:EscapeSequence { return seq; }
|
|
586
|
-
|
|
587
|
-
EscapeSequence
|
|
588
|
-
= "n" { return "\n"; }
|
|
589
|
-
/ "r" { return "\r"; }
|
|
590
|
-
/ "t" { return "\t"; }
|
|
591
|
-
/ "\\" { return "\\"; }
|
|
592
|
-
/ '"' { return '"'; }
|
|
593
|
-
/ "'" { return "'"; }
|
|
594
|
-
|
|
595
|
-
Number "number"
|
|
596
|
-
= sign:"-"? digits:[0-9]+ decimal:("." [0-9]+)? {
|
|
597
|
-
const num = (sign || '') + digits.join('') + (decimal ? '.' + decimal[1].join('') : '');
|
|
598
|
-
return parseFloat(num);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
ValueWithUnit "value with unit"
|
|
602
|
-
= sign:"-"? digits:[0-9]+ decimal:("." [0-9]+)? unit:("px" / "%" / "em" / "rem" / "vh" / "vw") {
|
|
603
|
-
const num = (sign || '') + digits.join('') + (decimal ? '.' + decimal[1].join('') : '');
|
|
604
|
-
return { value: parseFloat(num), unit: unit };
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
Boolean "boolean"
|
|
608
|
-
= "true" { return true; }
|
|
609
|
-
/ "false" { return false; }
|
|
610
|
-
|
|
611
|
-
Identifier "identifier"
|
|
612
|
-
= head:[a-zA-Z_] tail:[a-zA-Z0-9_-]* {
|
|
613
|
-
return head + tail.join('');
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// ============================================================
|
|
617
|
-
// Collections
|
|
618
|
-
// ============================================================
|
|
619
|
-
|
|
620
|
-
Array
|
|
621
|
-
= "[" _ items:ArrayItems? _ "]" { return items || []; }
|
|
622
|
-
|
|
623
|
-
ArrayItems
|
|
624
|
-
= head:ArrayItem tail:(_ ","? _ ArrayItem)* (_ ",")? {
|
|
625
|
-
return [head, ...tail.map(t => t[3])];
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
ArrayItem
|
|
629
|
-
= StringLiteral
|
|
630
|
-
/ Number
|
|
631
|
-
/ Boolean
|
|
632
|
-
/ Object
|
|
633
|
-
/ Identifier
|
|
634
|
-
|
|
635
|
-
Object
|
|
636
|
-
= "{" _ props:ObjectProperties? _ "}" {
|
|
637
|
-
const result = {};
|
|
638
|
-
if (props) {
|
|
639
|
-
for (const p of props) {
|
|
640
|
-
result[p.name] = p.value;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
return result;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
ObjectProperties
|
|
647
|
-
= head:ObjectProperty tail:(_ ","? _ ObjectProperty)* {
|
|
648
|
-
return [head, ...tail.map(t => t[3])];
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
ObjectProperty
|
|
652
|
-
= name:Identifier _ "=" _ value:AttributeValue {
|
|
653
|
-
return { name, value };
|
|
654
|
-
}
|
|
655
|
-
/ name:Identifier {
|
|
656
|
-
return { name, value: true };
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// ============================================================
|
|
660
|
-
// Whitespace & Comments
|
|
661
|
-
// ============================================================
|
|
662
|
-
|
|
663
|
-
_ "whitespace"
|
|
664
|
-
= (Whitespace / Comment)*
|
|
665
|
-
|
|
666
|
-
Whitespace
|
|
667
|
-
= [ \t\n\r]+
|
|
668
|
-
|
|
669
|
-
Comment "comment"
|
|
670
|
-
= LineComment
|
|
671
|
-
/ BlockComment
|
|
672
|
-
|
|
673
|
-
LineComment
|
|
674
|
-
= "//" [^\n]* ("\n" / !.)
|
|
675
|
-
|
|
676
|
-
BlockComment
|
|
677
|
-
= "/*" (!"*/" .)* "*/"
|