@wireweave/language-data 1.0.2 → 1.1.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.
@@ -0,0 +1,1191 @@
1
+ // src/attributes.ts
2
+ var COMMON_ATTRIBUTES = [
3
+ // Spacing
4
+ "p",
5
+ "px",
6
+ "py",
7
+ "pt",
8
+ "pr",
9
+ "pb",
10
+ "pl",
11
+ "m",
12
+ "mx",
13
+ "my",
14
+ "mt",
15
+ "mr",
16
+ "mb",
17
+ "ml",
18
+ "gap",
19
+ // Size
20
+ "w",
21
+ "h",
22
+ "minW",
23
+ "maxW",
24
+ "minH",
25
+ "maxH",
26
+ // Flex
27
+ "flex",
28
+ "direction",
29
+ "justify",
30
+ "align",
31
+ "wrap",
32
+ // Grid
33
+ "span",
34
+ // Position
35
+ "x",
36
+ "y"
37
+ ];
38
+ var ATTRIBUTES = [
39
+ // ============================================
40
+ // Spacing Attributes
41
+ // ============================================
42
+ { name: "p", type: "number", description: "Padding (all sides)", example: "p=4" },
43
+ { name: "px", type: "number", description: "Horizontal padding", example: "px=4" },
44
+ { name: "py", type: "number", description: "Vertical padding", example: "py=4" },
45
+ { name: "pt", type: "number", description: "Top padding", example: "pt=4" },
46
+ { name: "pr", type: "number", description: "Right padding", example: "pr=4" },
47
+ { name: "pb", type: "number", description: "Bottom padding", example: "pb=4" },
48
+ { name: "pl", type: "number", description: "Left padding", example: "pl=4" },
49
+ { name: "m", type: "number", description: "Margin (all sides)", example: "m=4" },
50
+ { name: "mx", type: "string", description: 'Horizontal margin (number or "auto")', example: "mx=auto" },
51
+ { name: "my", type: "number", description: "Vertical margin", example: "my=4" },
52
+ { name: "mt", type: "number", description: "Top margin", example: "mt=4" },
53
+ { name: "mr", type: "number", description: "Right margin", example: "mr=4" },
54
+ { name: "mb", type: "number", description: "Bottom margin", example: "mb=4" },
55
+ { name: "ml", type: "number", description: "Left margin", example: "ml=4" },
56
+ { name: "gap", type: "number", description: "Gap between children", example: "gap=4" },
57
+ // ============================================
58
+ // Size Attributes
59
+ // ============================================
60
+ { name: "w", type: "string", description: 'Width (number, "full", "auto", "screen", "fit")', example: "w=full" },
61
+ { name: "h", type: "string", description: 'Height (number, "full", "auto", "screen")', example: "h=full" },
62
+ { name: "width", type: "number", description: "Width in pixels (page only)", example: "width=400" },
63
+ { name: "height", type: "number", description: "Height in pixels (page only)", example: "height=300" },
64
+ { name: "minW", type: "number", description: "Minimum width", example: "minW=200" },
65
+ { name: "maxW", type: "number", description: "Maximum width", example: "maxW=600" },
66
+ { name: "minH", type: "number", description: "Minimum height", example: "minH=100" },
67
+ { name: "maxH", type: "number", description: "Maximum height", example: "maxH=400" },
68
+ // ============================================
69
+ // Flex/Grid Layout Attributes
70
+ // ============================================
71
+ { name: "flex", type: "boolean", description: "Enable flexbox", example: "flex" },
72
+ { name: "direction", type: "enum", values: ["row", "column", "row-reverse", "column-reverse"], description: "Flex direction", example: "direction=column" },
73
+ { name: "justify", type: "enum", values: ["start", "center", "end", "between", "around", "evenly"], description: "Main axis alignment", example: "justify=center" },
74
+ { name: "align", type: "enum", values: ["start", "center", "end", "stretch", "baseline"], description: "Cross axis alignment", example: "align=center" },
75
+ { name: "wrap", type: "boolean", description: "Enable flex wrap", example: "wrap" },
76
+ { name: "span", type: "number", description: "Grid column span (1-12)", example: "span=6" },
77
+ { name: "sm", type: "number", description: "Responsive span at 576px+", example: "sm=6" },
78
+ { name: "md", type: "number", description: "Responsive span at 768px+", example: "md=4" },
79
+ { name: "lg", type: "number", description: "Responsive span at 992px+", example: "lg=3" },
80
+ { name: "xl", type: "number", description: "Responsive span at 1200px+", example: "xl=2" },
81
+ { name: "order", type: "number", description: "Flex order", example: "order=1" },
82
+ // ============================================
83
+ // Position Attributes
84
+ // ============================================
85
+ { name: "x", type: "number", description: "Horizontal position", example: "x=100" },
86
+ { name: "y", type: "number", description: "Vertical position", example: "y=50" },
87
+ { name: "position", type: "enum", values: ["left", "right", "top", "bottom", "top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"], description: "Position preset", example: "position=left" },
88
+ // ============================================
89
+ // Visual Attributes
90
+ // ============================================
91
+ { name: "border", type: "boolean", description: "Show border", example: "border" },
92
+ { name: "rounded", type: "boolean", description: "Apply border radius", example: "rounded" },
93
+ { name: "shadow", type: "enum", values: ["none", "sm", "md", "lg", "xl"], description: "Box shadow", example: "shadow=md" },
94
+ { name: "bg", type: "enum", values: ["muted", "primary", "secondary"], description: "Background variant", example: "bg=muted" },
95
+ // ============================================
96
+ // Text Attributes
97
+ // ============================================
98
+ { name: "size", type: "enum", values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"], description: "Size preset", example: "size=lg" },
99
+ { name: "weight", type: "enum", values: ["normal", "medium", "semibold", "bold"], description: "Font weight", example: "weight=bold" },
100
+ { name: "level", type: "number", description: "Heading level (1-6)", example: "level=2" },
101
+ { name: "muted", type: "boolean", description: "Muted/dimmed style", example: "muted" },
102
+ { name: "bold", type: "boolean", description: "Bold text", example: "bold" },
103
+ // ============================================
104
+ // Button Variant Attributes
105
+ // ============================================
106
+ { name: "primary", type: "boolean", description: "Primary style", example: "primary" },
107
+ { name: "secondary", type: "boolean", description: "Secondary style", example: "secondary" },
108
+ { name: "outline", type: "boolean", description: "Outline style", example: "outline" },
109
+ { name: "ghost", type: "boolean", description: "Ghost/transparent style", example: "ghost" },
110
+ { name: "danger", type: "boolean", description: "Danger/destructive style", example: "danger" },
111
+ // ============================================
112
+ // Status Variant Attributes
113
+ // ============================================
114
+ { name: "variant", type: "enum", values: ["default", "primary", "secondary", "success", "warning", "danger", "info"], description: "Status variant", example: "variant=success" },
115
+ // ============================================
116
+ // Form Attributes
117
+ // ============================================
118
+ { name: "inputType", type: "enum", values: ["text", "email", "password", "number", "tel", "url", "search", "date"], description: "Input field type", example: "inputType=email" },
119
+ { name: "placeholder", type: "string", description: "Placeholder text", example: 'placeholder="Enter text"' },
120
+ { name: "value", type: "string", description: "Default value", example: 'value="default"' },
121
+ { name: "label", type: "string", description: "Field label", example: 'label="Name"' },
122
+ { name: "name", type: "string", description: "Form field name", example: 'name="field"' },
123
+ { name: "required", type: "boolean", description: "Required field", example: "required" },
124
+ { name: "disabled", type: "boolean", description: "Disabled state", example: "disabled" },
125
+ { name: "readonly", type: "boolean", description: "Read-only state", example: "readonly" },
126
+ { name: "checked", type: "boolean", description: "Checked state", example: "checked" },
127
+ { name: "loading", type: "boolean", description: "Loading state", example: "loading" },
128
+ { name: "rows", type: "number", description: "Textarea rows", example: "rows=4" },
129
+ { name: "min", type: "number", description: "Minimum value", example: "min=0" },
130
+ { name: "max", type: "number", description: "Maximum value", example: "max=100" },
131
+ { name: "step", type: "number", description: "Step increment", example: "step=1" },
132
+ // ============================================
133
+ // Content Attributes
134
+ // ============================================
135
+ { name: "title", type: "string", description: "Title text", example: 'title="Title"' },
136
+ { name: "src", type: "string", description: "Source URL", example: 'src="/image.png"' },
137
+ { name: "alt", type: "string", description: "Alt text", example: 'alt="Image"' },
138
+ { name: "href", type: "string", description: "Link URL", example: 'href="/path"' },
139
+ { name: "icon", type: "string", description: "Icon name", example: 'icon="home"' },
140
+ { name: "external", type: "boolean", description: "External link", example: "external" },
141
+ // ============================================
142
+ // State Attributes
143
+ // ============================================
144
+ { name: "active", type: "number", description: "Active index", example: "active=0" },
145
+ { name: "expanded", type: "boolean", description: "Expanded state", example: "expanded" },
146
+ { name: "centered", type: "boolean", description: "Center content", example: "centered" },
147
+ { name: "vertical", type: "boolean", description: "Vertical orientation", example: "vertical" },
148
+ { name: "scroll", type: "boolean", description: "Enable scrolling", example: "scroll" },
149
+ // ============================================
150
+ // Feedback Attributes
151
+ // ============================================
152
+ { name: "dismissible", type: "boolean", description: "Can be dismissed", example: "dismissible" },
153
+ { name: "indeterminate", type: "boolean", description: "Indeterminate state", example: "indeterminate" },
154
+ { name: "pill", type: "boolean", description: "Pill/rounded style", example: "pill" },
155
+ // ============================================
156
+ // Data Attributes
157
+ // ============================================
158
+ { name: "striped", type: "boolean", description: "Striped rows", example: "striped" },
159
+ { name: "bordered", type: "boolean", description: "Full borders", example: "bordered" },
160
+ { name: "hover", type: "boolean", description: "Hover effect", example: "hover" },
161
+ { name: "ordered", type: "boolean", description: "Ordered list", example: "ordered" },
162
+ { name: "none", type: "boolean", description: "No list markers", example: "none" },
163
+ // ============================================
164
+ // Page/Viewport Attributes
165
+ // ============================================
166
+ { name: "viewport", type: "string", description: 'Viewport size (e.g., "1440x900")', example: 'viewport="1440x900"' },
167
+ { name: "device", type: "string", description: "Device preset", example: 'device="iphone14"' }
168
+ ];
169
+ var ATTRIBUTE_MAP = new Map(
170
+ ATTRIBUTES.map((attr) => [attr.name, attr])
171
+ );
172
+ var VALID_ATTRIBUTE_NAMES = new Set(
173
+ ATTRIBUTES.map((attr) => attr.name)
174
+ );
175
+
176
+ // src/components.ts
177
+ var ALL_COMPONENTS = [
178
+ // ============================================
179
+ // Layout Components
180
+ // ============================================
181
+ {
182
+ name: "page",
183
+ nodeType: "Page",
184
+ category: "layout",
185
+ attributes: [...COMMON_ATTRIBUTES, "title", "width", "height", "viewport", "device", "centered"],
186
+ hasChildren: true,
187
+ description: "Root container for a wireframe page",
188
+ example: 'page "Dashboard" centered { ... }',
189
+ validChildren: ["header", "main", "footer", "sidebar", "section", "nav", "row", "col", "card"],
190
+ validParents: []
191
+ },
192
+ {
193
+ name: "header",
194
+ nodeType: "Header",
195
+ category: "layout",
196
+ attributes: [...COMMON_ATTRIBUTES, "border"],
197
+ hasChildren: true,
198
+ description: "Page header section",
199
+ example: "header h=56 border { ... }",
200
+ validParents: ["page"]
201
+ },
202
+ {
203
+ name: "main",
204
+ nodeType: "Main",
205
+ category: "layout",
206
+ attributes: [...COMMON_ATTRIBUTES, "scroll"],
207
+ hasChildren: true,
208
+ description: "Main content section",
209
+ example: "main p=6 scroll { ... }",
210
+ validParents: ["page"]
211
+ },
212
+ {
213
+ name: "footer",
214
+ nodeType: "Footer",
215
+ category: "layout",
216
+ attributes: [...COMMON_ATTRIBUTES, "border"],
217
+ hasChildren: true,
218
+ description: "Page footer section",
219
+ example: "footer h=48 border { ... }",
220
+ validParents: ["page"]
221
+ },
222
+ {
223
+ name: "sidebar",
224
+ nodeType: "Sidebar",
225
+ category: "layout",
226
+ attributes: [...COMMON_ATTRIBUTES, "position", "border", "bg"],
227
+ hasChildren: true,
228
+ description: "Side navigation or content area",
229
+ example: "sidebar w=240 border { ... }",
230
+ validParents: ["page"]
231
+ },
232
+ {
233
+ name: "section",
234
+ nodeType: "Section",
235
+ category: "layout",
236
+ attributes: [...COMMON_ATTRIBUTES, "title", "expanded"],
237
+ hasChildren: true,
238
+ description: "Grouped content section",
239
+ example: 'section "Settings" expanded { ... }'
240
+ },
241
+ // ============================================
242
+ // Grid Components
243
+ // ============================================
244
+ {
245
+ name: "row",
246
+ nodeType: "Row",
247
+ category: "grid",
248
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
249
+ hasChildren: true,
250
+ description: "Horizontal flex container",
251
+ example: "row flex gap=4 justify=between { ... }"
252
+ },
253
+ {
254
+ name: "col",
255
+ nodeType: "Col",
256
+ category: "grid",
257
+ attributes: [...COMMON_ATTRIBUTES, "sm", "md", "lg", "xl", "order", "border", "bg", "scroll"],
258
+ hasChildren: true,
259
+ description: "Vertical flex container or grid column",
260
+ example: "col span=6 md=4 { ... }"
261
+ },
262
+ // ============================================
263
+ // Container Components
264
+ // ============================================
265
+ {
266
+ name: "card",
267
+ nodeType: "Card",
268
+ category: "container",
269
+ attributes: [...COMMON_ATTRIBUTES, "title", "shadow", "border", "rounded"],
270
+ hasChildren: true,
271
+ description: "Card container with optional title",
272
+ example: 'card "Settings" p=4 shadow=md { ... }'
273
+ },
274
+ {
275
+ name: "modal",
276
+ nodeType: "Modal",
277
+ category: "container",
278
+ attributes: [...COMMON_ATTRIBUTES, "title"],
279
+ hasChildren: true,
280
+ description: "Modal dialog overlay",
281
+ example: 'modal "Confirm" w=400 { ... }'
282
+ },
283
+ {
284
+ name: "drawer",
285
+ nodeType: "Drawer",
286
+ category: "container",
287
+ attributes: [...COMMON_ATTRIBUTES, "title", "position"],
288
+ hasChildren: true,
289
+ description: "Slide-in drawer panel",
290
+ example: 'drawer "Menu" position=left { ... }'
291
+ },
292
+ {
293
+ name: "accordion",
294
+ nodeType: "Accordion",
295
+ category: "container",
296
+ attributes: [...COMMON_ATTRIBUTES, "title"],
297
+ hasChildren: true,
298
+ description: "Collapsible sections container",
299
+ example: 'accordion { section "FAQ 1" { ... } }'
300
+ },
301
+ // ============================================
302
+ // Text Components
303
+ // ============================================
304
+ {
305
+ name: "text",
306
+ nodeType: "Text",
307
+ category: "text",
308
+ attributes: [...COMMON_ATTRIBUTES, "size", "weight", "muted", "bold"],
309
+ hasChildren: false,
310
+ description: "Text content",
311
+ example: 'text "Hello World" size=lg weight=bold'
312
+ },
313
+ {
314
+ name: "title",
315
+ nodeType: "Title",
316
+ category: "text",
317
+ attributes: [...COMMON_ATTRIBUTES, "level", "size"],
318
+ hasChildren: false,
319
+ description: "Heading element (h1-h6)",
320
+ example: 'title "Welcome" level=2'
321
+ },
322
+ {
323
+ name: "link",
324
+ nodeType: "Link",
325
+ category: "text",
326
+ attributes: [...COMMON_ATTRIBUTES, "href", "external"],
327
+ hasChildren: false,
328
+ description: "Hyperlink text",
329
+ example: 'link "Learn more" href="/docs" external'
330
+ },
331
+ // ============================================
332
+ // Input Components
333
+ // ============================================
334
+ {
335
+ name: "input",
336
+ nodeType: "Input",
337
+ category: "input",
338
+ attributes: [...COMMON_ATTRIBUTES, "label", "inputType", "placeholder", "value", "disabled", "required", "readonly", "icon", "size", "rounded"],
339
+ hasChildren: false,
340
+ description: "Text input field",
341
+ example: 'input "Email" inputType=email placeholder="user@example.com" required'
342
+ },
343
+ {
344
+ name: "textarea",
345
+ nodeType: "Textarea",
346
+ category: "input",
347
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "rows", "disabled", "required"],
348
+ hasChildren: false,
349
+ description: "Multi-line text input",
350
+ example: 'textarea "Description" rows=4 placeholder="Enter description..."'
351
+ },
352
+ {
353
+ name: "select",
354
+ nodeType: "Select",
355
+ category: "input",
356
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "disabled", "required"],
357
+ hasChildren: false,
358
+ description: "Dropdown select",
359
+ example: 'select "Country" ["USA", "Canada", "UK"] placeholder="Select..."'
360
+ },
361
+ {
362
+ name: "checkbox",
363
+ nodeType: "Checkbox",
364
+ category: "input",
365
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
366
+ hasChildren: false,
367
+ description: "Checkbox input",
368
+ example: 'checkbox "I agree to terms" checked'
369
+ },
370
+ {
371
+ name: "radio",
372
+ nodeType: "Radio",
373
+ category: "input",
374
+ attributes: [...COMMON_ATTRIBUTES, "label", "name", "checked", "disabled"],
375
+ hasChildren: false,
376
+ description: "Radio button input",
377
+ example: 'radio "Option A" name="choice" checked'
378
+ },
379
+ {
380
+ name: "switch",
381
+ nodeType: "Switch",
382
+ category: "input",
383
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
384
+ hasChildren: false,
385
+ description: "Toggle switch",
386
+ example: 'switch "Dark mode" checked'
387
+ },
388
+ {
389
+ name: "slider",
390
+ nodeType: "Slider",
391
+ category: "input",
392
+ attributes: [...COMMON_ATTRIBUTES, "label", "min", "max", "value", "step", "disabled"],
393
+ hasChildren: false,
394
+ description: "Range slider",
395
+ example: 'slider "Volume" min=0 max=100 value=50'
396
+ },
397
+ {
398
+ name: "button",
399
+ nodeType: "Button",
400
+ category: "input",
401
+ attributes: [...COMMON_ATTRIBUTES, "primary", "secondary", "outline", "ghost", "danger", "size", "icon", "disabled", "loading"],
402
+ hasChildren: false,
403
+ description: "Clickable button",
404
+ example: 'button "Submit" primary icon=send'
405
+ },
406
+ // ============================================
407
+ // Display Components
408
+ // ============================================
409
+ {
410
+ name: "image",
411
+ nodeType: "Image",
412
+ category: "display",
413
+ attributes: [...COMMON_ATTRIBUTES, "src", "alt"],
414
+ hasChildren: false,
415
+ description: "Image placeholder",
416
+ example: "image w=200 h=150"
417
+ },
418
+ {
419
+ name: "placeholder",
420
+ nodeType: "Placeholder",
421
+ category: "display",
422
+ attributes: [...COMMON_ATTRIBUTES, "label"],
423
+ hasChildren: true,
424
+ description: "Generic placeholder",
425
+ example: 'placeholder "Banner Image" w=full h=200 { ... }'
426
+ },
427
+ {
428
+ name: "avatar",
429
+ nodeType: "Avatar",
430
+ category: "display",
431
+ attributes: [...COMMON_ATTRIBUTES, "name", "src", "size"],
432
+ hasChildren: false,
433
+ description: "User avatar",
434
+ example: 'avatar "John Doe" size=lg'
435
+ },
436
+ {
437
+ name: "badge",
438
+ nodeType: "Badge",
439
+ category: "display",
440
+ attributes: [...COMMON_ATTRIBUTES, "variant", "pill", "icon", "size"],
441
+ hasChildren: false,
442
+ description: "Status badge",
443
+ example: 'badge "New" variant=success pill'
444
+ },
445
+ {
446
+ name: "icon",
447
+ nodeType: "Icon",
448
+ category: "display",
449
+ attributes: [...COMMON_ATTRIBUTES, "size", "muted"],
450
+ hasChildren: false,
451
+ description: "Lucide icon",
452
+ example: 'icon "settings" size=lg'
453
+ },
454
+ // ============================================
455
+ // Data Components
456
+ // ============================================
457
+ {
458
+ name: "table",
459
+ nodeType: "Table",
460
+ category: "data",
461
+ attributes: [...COMMON_ATTRIBUTES, "striped", "bordered", "hover"],
462
+ hasChildren: false,
463
+ description: "Data table",
464
+ example: 'table striped bordered { columns ["Name", "Email"] row ["John", "john@example.com"] }'
465
+ },
466
+ {
467
+ name: "list",
468
+ nodeType: "List",
469
+ category: "data",
470
+ attributes: [...COMMON_ATTRIBUTES, "ordered", "none"],
471
+ hasChildren: false,
472
+ description: "List of items",
473
+ example: 'list ordered ["First", "Second", "Third"]'
474
+ },
475
+ // ============================================
476
+ // Feedback Components
477
+ // ============================================
478
+ {
479
+ name: "alert",
480
+ nodeType: "Alert",
481
+ category: "feedback",
482
+ attributes: [...COMMON_ATTRIBUTES, "variant", "dismissible", "icon"],
483
+ hasChildren: false,
484
+ description: "Alert message",
485
+ example: 'alert "Changes saved!" variant=success'
486
+ },
487
+ {
488
+ name: "toast",
489
+ nodeType: "Toast",
490
+ category: "feedback",
491
+ attributes: [...COMMON_ATTRIBUTES, "position", "variant"],
492
+ hasChildren: false,
493
+ description: "Toast notification",
494
+ example: 'toast "Item deleted" position=bottom-right variant=danger'
495
+ },
496
+ {
497
+ name: "progress",
498
+ nodeType: "Progress",
499
+ category: "feedback",
500
+ attributes: [...COMMON_ATTRIBUTES, "value", "max", "label", "indeterminate"],
501
+ hasChildren: false,
502
+ description: "Progress bar",
503
+ example: 'progress value=75 label="Uploading..."'
504
+ },
505
+ {
506
+ name: "spinner",
507
+ nodeType: "Spinner",
508
+ category: "feedback",
509
+ attributes: [...COMMON_ATTRIBUTES, "label", "size"],
510
+ hasChildren: false,
511
+ description: "Loading spinner",
512
+ example: "spinner size=lg"
513
+ },
514
+ // ============================================
515
+ // Overlay Components
516
+ // ============================================
517
+ {
518
+ name: "tooltip",
519
+ nodeType: "Tooltip",
520
+ category: "overlay",
521
+ attributes: [...COMMON_ATTRIBUTES, "position"],
522
+ hasChildren: false,
523
+ description: "Tooltip on hover",
524
+ example: 'tooltip "More info" position=top { icon "help-circle" }'
525
+ },
526
+ {
527
+ name: "popover",
528
+ nodeType: "Popover",
529
+ category: "overlay",
530
+ attributes: [...COMMON_ATTRIBUTES, "title"],
531
+ hasChildren: true,
532
+ description: "Popover panel",
533
+ example: 'popover "Details" { ... }'
534
+ },
535
+ {
536
+ name: "dropdown",
537
+ nodeType: "Dropdown",
538
+ category: "overlay",
539
+ attributes: [...COMMON_ATTRIBUTES],
540
+ hasChildren: false,
541
+ description: "Dropdown menu",
542
+ example: 'dropdown { item "Edit" icon=edit item "Delete" icon=trash danger }'
543
+ },
544
+ // ============================================
545
+ // Navigation Components
546
+ // ============================================
547
+ {
548
+ name: "nav",
549
+ nodeType: "Nav",
550
+ category: "navigation",
551
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
552
+ hasChildren: false,
553
+ description: "Navigation menu",
554
+ example: 'nav [{ label="Home" icon=home active }, { label="Settings" icon=settings }] vertical'
555
+ },
556
+ {
557
+ name: "tabs",
558
+ nodeType: "Tabs",
559
+ category: "navigation",
560
+ attributes: [...COMMON_ATTRIBUTES, "active"],
561
+ hasChildren: true,
562
+ description: "Tab navigation",
563
+ example: 'tabs { tab "General" active { ... } tab "Advanced" { ... } }'
564
+ },
565
+ {
566
+ name: "breadcrumb",
567
+ nodeType: "Breadcrumb",
568
+ category: "navigation",
569
+ attributes: [...COMMON_ATTRIBUTES],
570
+ hasChildren: false,
571
+ description: "Breadcrumb navigation",
572
+ example: 'breadcrumb [{ label="Home" href="/" }, { label="Products" }, { label="Details" }]'
573
+ },
574
+ // ============================================
575
+ // Divider Component
576
+ // ============================================
577
+ {
578
+ name: "divider",
579
+ nodeType: "Divider",
580
+ category: "layout",
581
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
582
+ hasChildren: false,
583
+ description: "Horizontal separator",
584
+ example: "divider my=4"
585
+ }
586
+ ];
587
+ var COMPONENT_MAP = new Map(
588
+ ALL_COMPONENTS.map((comp) => [comp.name, comp])
589
+ );
590
+ var NODE_TYPE_MAP = new Map(
591
+ ALL_COMPONENTS.map((comp) => [comp.nodeType, comp])
592
+ );
593
+ var VALID_COMPONENT_NAMES = new Set(
594
+ ALL_COMPONENTS.map((comp) => comp.name)
595
+ );
596
+
597
+ // src/keywords.ts
598
+ var CATEGORY_LABELS = {
599
+ layout: "Layout",
600
+ container: "Container",
601
+ grid: "Grid",
602
+ text: "Text",
603
+ input: "Input",
604
+ display: "Display",
605
+ data: "Data",
606
+ feedback: "Feedback",
607
+ overlay: "Overlay",
608
+ navigation: "Navigation"
609
+ };
610
+ var VALUE_KEYWORDS = [
611
+ // Booleans
612
+ "true",
613
+ "false",
614
+ // Button variants
615
+ "primary",
616
+ "secondary",
617
+ "outline",
618
+ "ghost",
619
+ // Status variants
620
+ "success",
621
+ "danger",
622
+ "warning",
623
+ "info",
624
+ "default",
625
+ // Sizes
626
+ "xs",
627
+ "sm",
628
+ "md",
629
+ "lg",
630
+ "xl",
631
+ "base",
632
+ "2xl",
633
+ "3xl",
634
+ // Flex alignment
635
+ "start",
636
+ "center",
637
+ "end",
638
+ "between",
639
+ "around",
640
+ "evenly",
641
+ "stretch",
642
+ "baseline",
643
+ // Positions
644
+ "left",
645
+ "right",
646
+ "top",
647
+ "bottom",
648
+ "top-left",
649
+ "top-center",
650
+ "top-right",
651
+ "bottom-left",
652
+ "bottom-center",
653
+ "bottom-right",
654
+ // Sizing
655
+ "full",
656
+ "auto",
657
+ "screen",
658
+ "fit",
659
+ // Font weights
660
+ "normal",
661
+ "medium",
662
+ "semibold",
663
+ "bold",
664
+ // Input types
665
+ "text",
666
+ "email",
667
+ "password",
668
+ "number",
669
+ "tel",
670
+ "url",
671
+ "search",
672
+ "date",
673
+ // Flex direction
674
+ "row",
675
+ "column",
676
+ "row-reverse",
677
+ "column-reverse",
678
+ // List
679
+ "none",
680
+ "nowrap"
681
+ ];
682
+
683
+ // src/utils.ts
684
+ function getComponent(name) {
685
+ return COMPONENT_MAP.get(name.toLowerCase());
686
+ }
687
+ function getAttribute(name) {
688
+ return ATTRIBUTE_MAP.get(name);
689
+ }
690
+ function getValidChildren(componentName) {
691
+ const component = getComponent(componentName);
692
+ if (!component || !component.hasChildren) return [];
693
+ if (component.validChildren === void 0) {
694
+ return ALL_COMPONENTS.filter((c) => c.name !== "page");
695
+ }
696
+ return component.validChildren.map((name) => getComponent(name)).filter((c) => c !== void 0);
697
+ }
698
+ function getComponentAttributes(componentName) {
699
+ const component = getComponent(componentName);
700
+ if (!component) return ATTRIBUTES;
701
+ return ATTRIBUTES.filter((attr) => component.attributes.includes(attr.name));
702
+ }
703
+
704
+ // src/codemirror/language.ts
705
+ var COMPONENT_NAMES = ALL_COMPONENTS.map((c) => c.name);
706
+ var ATTRIBUTE_NAMES = ATTRIBUTES.map((a) => a.name);
707
+ var VALUE_KEYWORDS2 = [
708
+ // Sizes
709
+ "xs",
710
+ "sm",
711
+ "md",
712
+ "lg",
713
+ "xl",
714
+ "2xl",
715
+ "3xl",
716
+ // Weights
717
+ "thin",
718
+ "light",
719
+ "normal",
720
+ "medium",
721
+ "semibold",
722
+ "bold",
723
+ "extrabold",
724
+ // Alignments
725
+ "left",
726
+ "center",
727
+ "right",
728
+ "start",
729
+ "end",
730
+ "top",
731
+ "middle",
732
+ "bottom",
733
+ "between",
734
+ "around",
735
+ "evenly",
736
+ "stretch",
737
+ // Directions
738
+ "horizontal",
739
+ "vertical",
740
+ // Variants
741
+ "primary",
742
+ "secondary",
743
+ "outline",
744
+ "ghost",
745
+ "link",
746
+ "danger",
747
+ "info",
748
+ "success",
749
+ "warning",
750
+ "error",
751
+ // Boolean
752
+ "true",
753
+ "false",
754
+ // Devices
755
+ "mobile",
756
+ "tablet",
757
+ "desktop",
758
+ // Input types
759
+ "text",
760
+ "email",
761
+ "password",
762
+ "number",
763
+ "tel",
764
+ "url",
765
+ "search",
766
+ "date"
767
+ ];
768
+ function createTokenizer() {
769
+ return {
770
+ token(stream) {
771
+ if (stream.eatSpace()) return null;
772
+ if (stream.match("//")) {
773
+ stream.skipToEnd();
774
+ return "comment";
775
+ }
776
+ if (stream.match(/"[^"]*"/)) {
777
+ return "string";
778
+ }
779
+ if (stream.match(/\d+/)) {
780
+ return "number";
781
+ }
782
+ for (const kw of COMPONENT_NAMES) {
783
+ if (stream.match(new RegExp(`^${kw}\\b`))) {
784
+ return "keyword";
785
+ }
786
+ }
787
+ for (const attr of ATTRIBUTE_NAMES) {
788
+ if (stream.match(new RegExp(`^${attr}\\b`))) {
789
+ return "propertyName";
790
+ }
791
+ }
792
+ for (const val of VALUE_KEYWORDS2) {
793
+ if (stream.match(new RegExp(`^${val}\\b`))) {
794
+ return "atom";
795
+ }
796
+ }
797
+ if (stream.match(/[=]/)) {
798
+ return "operator";
799
+ }
800
+ if (stream.match(/[{}[\]()]/)) {
801
+ return "bracket";
802
+ }
803
+ stream.next();
804
+ return null;
805
+ }
806
+ };
807
+ }
808
+ function getLanguageConfig() {
809
+ return {
810
+ commentTokens: { line: "//" },
811
+ closeBrackets: { brackets: ["(", "[", "{", '"'] },
812
+ indentOnInput: /^\s*\}$/
813
+ };
814
+ }
815
+
816
+ // src/codemirror/completion.ts
817
+ function getCategoryLabel(category) {
818
+ return CATEGORY_LABELS[category] || category;
819
+ }
820
+ function findParentComponent(text, pos) {
821
+ let braceCount = 0;
822
+ for (let i = pos - 1; i >= 0; i--) {
823
+ if (text[i] === "}") braceCount++;
824
+ if (text[i] === "{") {
825
+ braceCount--;
826
+ if (braceCount < 0) {
827
+ const beforeBrace = text.substring(0, i);
828
+ const match = beforeBrace.match(/(\w+)(?:\s+"[^"]*")?\s*$/);
829
+ return match ? match[1] : null;
830
+ }
831
+ }
832
+ }
833
+ return null;
834
+ }
835
+ function createCompletionSource() {
836
+ return (context) => {
837
+ const { state, pos } = context;
838
+ const line = state.doc.lineAt(pos);
839
+ const textBefore = state.doc.sliceString(line.from, pos);
840
+ const fullText = state.doc.toString();
841
+ const wordMatch = textBefore.match(/(\w*)$/);
842
+ const word = wordMatch ? wordMatch[1] : "";
843
+ const from = pos - word.length;
844
+ const options = [];
845
+ const attrMatch = textBefore.match(/(\w+)\s*=\s*$/);
846
+ if (attrMatch) {
847
+ const attrName = attrMatch[1];
848
+ const attr = getAttribute(attrName);
849
+ if (attr && attr.type === "enum" && attr.values) {
850
+ attr.values.forEach((value) => {
851
+ options.push({
852
+ label: value,
853
+ type: "enum",
854
+ detail: `value for ${attrName}`
855
+ });
856
+ });
857
+ } else if (attr?.type === "number") {
858
+ [1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {
859
+ options.push({
860
+ label: String(n),
861
+ type: "constant",
862
+ detail: "number"
863
+ });
864
+ });
865
+ }
866
+ if (options.length > 0) {
867
+ return { from, options };
868
+ }
869
+ }
870
+ if (textBefore.match(/^\s*\w*$/) || textBefore.match(/\{\s*\w*$/)) {
871
+ const parentComponent = findParentComponent(fullText, pos);
872
+ const validChildren = parentComponent ? getValidChildren(parentComponent) : [];
873
+ const validChildNames = new Set(validChildren.map((c) => c.name));
874
+ const isRootLevel = !parentComponent;
875
+ ALL_COMPONENTS.forEach((comp) => {
876
+ const isValidInContext = isRootLevel ? comp.name === "page" : validChildNames.size === 0 || validChildNames.has(comp.name);
877
+ options.push({
878
+ label: comp.name,
879
+ type: isValidInContext ? "class" : "type",
880
+ detail: isValidInContext ? `${getCategoryLabel(comp.category)} (recommended)` : getCategoryLabel(comp.category),
881
+ info: comp.description,
882
+ boost: isValidInContext ? 10 : 0,
883
+ apply: comp.hasChildren ? `${comp.name} {
884
+
885
+ }` : comp.name
886
+ });
887
+ });
888
+ return { from, options };
889
+ }
890
+ const componentMatch = textBefore.match(/(\w+)(?:\s+"[^"]*")?\s+(\w*)$/);
891
+ if (componentMatch) {
892
+ const compName = componentMatch[1];
893
+ const component = getComponent(compName);
894
+ if (component) {
895
+ const attrs = getComponentAttributes(compName);
896
+ attrs.forEach((attr) => {
897
+ let apply = attr.name;
898
+ if (attr.type === "string") {
899
+ apply = `${attr.name}=""`;
900
+ } else if (attr.type === "number" || attr.type === "enum") {
901
+ apply = `${attr.name}=`;
902
+ }
903
+ options.push({
904
+ label: attr.name,
905
+ type: "property",
906
+ detail: attr.type,
907
+ info: attr.description,
908
+ apply
909
+ });
910
+ });
911
+ } else {
912
+ ATTRIBUTES.forEach((attr) => {
913
+ let apply = attr.name;
914
+ if (attr.type === "string") {
915
+ apply = `${attr.name}=""`;
916
+ } else if (attr.type === "number" || attr.type === "enum") {
917
+ apply = `${attr.name}=`;
918
+ }
919
+ options.push({
920
+ label: attr.name,
921
+ type: "property",
922
+ detail: attr.type,
923
+ info: attr.description,
924
+ apply
925
+ });
926
+ });
927
+ }
928
+ return { from, options };
929
+ }
930
+ ALL_COMPONENTS.forEach((comp) => {
931
+ options.push({
932
+ label: comp.name,
933
+ type: "class",
934
+ detail: getCategoryLabel(comp.category),
935
+ info: comp.description,
936
+ apply: comp.hasChildren ? `${comp.name} {
937
+
938
+ }` : comp.name
939
+ });
940
+ });
941
+ return { from, options };
942
+ };
943
+ }
944
+
945
+ // src/codemirror/hover.ts
946
+ function getCategoryLabel2(category) {
947
+ return CATEGORY_LABELS[category] || category;
948
+ }
949
+ function getWordAt(text, pos) {
950
+ let from = pos;
951
+ let to = pos;
952
+ while (from > 0 && /\w/.test(text[from - 1])) from--;
953
+ while (to < text.length && /\w/.test(text[to])) to++;
954
+ if (from === to) return null;
955
+ return {
956
+ word: text.slice(from, to),
957
+ from,
958
+ to
959
+ };
960
+ }
961
+ function createHoverTooltipSource() {
962
+ return (view, pos, _side) => {
963
+ const { state } = view;
964
+ const text = state.doc.toString();
965
+ const wordInfo = getWordAt(text, pos);
966
+ if (!wordInfo) return null;
967
+ const { word, from, to } = wordInfo;
968
+ const component = getComponent(word);
969
+ if (component) {
970
+ return {
971
+ pos: from,
972
+ end: to,
973
+ above: true,
974
+ create() {
975
+ const dom = document.createElement("div");
976
+ dom.className = "cm-tooltip-hover";
977
+ dom.innerHTML = `
978
+ <div style="padding: 8px 12px; max-width: 400px;">
979
+ <div style="font-weight: bold; margin-bottom: 4px;">
980
+ ${component.name}
981
+ <span style="opacity: 0.7; font-weight: normal; font-size: 0.9em;">
982
+ (${getCategoryLabel2(component.category)})
983
+ </span>
984
+ </div>
985
+ <div style="margin-bottom: 8px; opacity: 0.9;">${component.description}</div>
986
+ ${component.example ? `<code style="display: block; padding: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; font-size: 0.85em; white-space: pre;">${component.example}</code>` : ""}
987
+ <div style="margin-top: 8px; font-size: 0.85em; opacity: 0.7;">
988
+ Attributes: ${component.attributes.join(", ")}
989
+ </div>
990
+ </div>
991
+ `;
992
+ return { dom };
993
+ }
994
+ };
995
+ }
996
+ const attribute = getAttribute(word);
997
+ if (attribute) {
998
+ let valueInfo = "";
999
+ if (attribute.type === "number") {
1000
+ valueInfo = "Type: number";
1001
+ } else if (attribute.type === "string") {
1002
+ valueInfo = "Type: string";
1003
+ } else if (attribute.type === "boolean") {
1004
+ valueInfo = "Type: boolean";
1005
+ } else if (attribute.type === "enum" && attribute.values) {
1006
+ valueInfo = `Values: ${attribute.values.join(" | ")}`;
1007
+ }
1008
+ return {
1009
+ pos: from,
1010
+ end: to,
1011
+ above: true,
1012
+ create() {
1013
+ const dom = document.createElement("div");
1014
+ dom.className = "cm-tooltip-hover";
1015
+ dom.innerHTML = `
1016
+ <div style="padding: 8px 12px; max-width: 400px;">
1017
+ <div style="font-weight: bold; margin-bottom: 4px;">
1018
+ ${attribute.name}
1019
+ <span style="opacity: 0.7; font-weight: normal; font-size: 0.9em;">(attribute)</span>
1020
+ </div>
1021
+ <div style="margin-bottom: 4px; opacity: 0.9;">${attribute.description}</div>
1022
+ ${valueInfo ? `<div style="font-size: 0.85em; opacity: 0.8; font-family: monospace;">${valueInfo}</div>` : ""}
1023
+ ${attribute.example ? `<div style="margin-top: 4px; font-size: 0.85em; opacity: 0.7;">Example: <code>${attribute.example}</code></div>` : ""}
1024
+ </div>
1025
+ `;
1026
+ return { dom };
1027
+ }
1028
+ };
1029
+ }
1030
+ if (VALUE_KEYWORDS.includes(word)) {
1031
+ const relatedAttrs = ATTRIBUTES.filter(
1032
+ (a) => a.type === "enum" && a.values?.includes(word)
1033
+ );
1034
+ if (relatedAttrs.length > 0) {
1035
+ return {
1036
+ pos: from,
1037
+ end: to,
1038
+ above: true,
1039
+ create() {
1040
+ const dom = document.createElement("div");
1041
+ dom.className = "cm-tooltip-hover";
1042
+ dom.innerHTML = `
1043
+ <div style="padding: 8px 12px; max-width: 300px;">
1044
+ <div style="font-weight: bold; margin-bottom: 4px;">
1045
+ ${word}
1046
+ <span style="opacity: 0.7; font-weight: normal; font-size: 0.9em;">(value)</span>
1047
+ </div>
1048
+ <div style="font-size: 0.9em; opacity: 0.8;">
1049
+ Used in: ${relatedAttrs.map((a) => a.name).join(", ")}
1050
+ </div>
1051
+ </div>
1052
+ `;
1053
+ return { dom };
1054
+ }
1055
+ };
1056
+ }
1057
+ }
1058
+ return null;
1059
+ };
1060
+ }
1061
+
1062
+ // src/codemirror/linting.ts
1063
+ function validateCode(text) {
1064
+ const diagnostics = [];
1065
+ const lines = text.split("\n");
1066
+ let braceStack = [];
1067
+ let hasPage = false;
1068
+ let currentPos = 0;
1069
+ for (let lineNum = 0; lineNum < lines.length; lineNum++) {
1070
+ const line = lines[lineNum];
1071
+ const lineStart = currentPos;
1072
+ if (line.trim().startsWith("//")) {
1073
+ currentPos += line.length + 1;
1074
+ continue;
1075
+ }
1076
+ const pageMatch = line.match(/^\s*page\b/);
1077
+ if (pageMatch) {
1078
+ if (hasPage) {
1079
+ const matchStart = lineStart + line.indexOf("page");
1080
+ diagnostics.push({
1081
+ from: matchStart,
1082
+ to: matchStart + 4,
1083
+ severity: "error",
1084
+ message: "Only one page component is allowed."
1085
+ });
1086
+ }
1087
+ hasPage = true;
1088
+ }
1089
+ const componentMatch = line.match(/^\s*(\w+)(?:\s|{|")/);
1090
+ if (componentMatch) {
1091
+ const compName = componentMatch[1];
1092
+ if (!getComponent(compName) && !["true", "false"].includes(compName)) {
1093
+ const beforeMatch = line.substring(0, componentMatch.index);
1094
+ if (!beforeMatch.match(/=\s*$/)) {
1095
+ const matchStart = lineStart + (componentMatch.index || 0);
1096
+ diagnostics.push({
1097
+ from: matchStart,
1098
+ to: matchStart + compName.length,
1099
+ severity: "warning",
1100
+ message: `Unknown component: "${compName}"`
1101
+ });
1102
+ }
1103
+ }
1104
+ }
1105
+ const attrRegex = /\b(\w+)\s*=/g;
1106
+ let attrMatch;
1107
+ while ((attrMatch = attrRegex.exec(line)) !== null) {
1108
+ const attrName = attrMatch[1];
1109
+ if (!getAttribute(attrName) && !getComponent(attrName)) {
1110
+ const matchStart = lineStart + attrMatch.index;
1111
+ diagnostics.push({
1112
+ from: matchStart,
1113
+ to: matchStart + attrName.length,
1114
+ severity: "warning",
1115
+ message: `Unknown attribute: "${attrName}"`
1116
+ });
1117
+ }
1118
+ }
1119
+ for (let col = 0; col < line.length; col++) {
1120
+ if (line[col] === "{") {
1121
+ const beforeBrace = line.substring(0, col);
1122
+ const compMatch = beforeBrace.match(/(\w+)(?:\s+"[^"]*")?\s*$/);
1123
+ braceStack.push({
1124
+ line: lineNum,
1125
+ col,
1126
+ pos: lineStart + col,
1127
+ component: compMatch ? compMatch[1] : void 0
1128
+ });
1129
+ } else if (line[col] === "}") {
1130
+ if (braceStack.length === 0) {
1131
+ diagnostics.push({
1132
+ from: lineStart + col,
1133
+ to: lineStart + col + 1,
1134
+ severity: "error",
1135
+ message: "Unmatched closing brace"
1136
+ });
1137
+ } else {
1138
+ braceStack.pop();
1139
+ }
1140
+ }
1141
+ }
1142
+ const quotes = line.match(/"/g);
1143
+ if (quotes && quotes.length % 2 !== 0) {
1144
+ diagnostics.push({
1145
+ from: lineStart,
1146
+ to: lineStart + line.length,
1147
+ severity: "error",
1148
+ message: "Unclosed string"
1149
+ });
1150
+ }
1151
+ currentPos += line.length + 1;
1152
+ }
1153
+ for (const brace of braceStack) {
1154
+ diagnostics.push({
1155
+ from: brace.pos,
1156
+ to: brace.pos + 1,
1157
+ severity: "error",
1158
+ message: `Unclosed brace${brace.component ? ` (${brace.component})` : ""}`
1159
+ });
1160
+ }
1161
+ if (!hasPage && text.trim()) {
1162
+ diagnostics.push({
1163
+ from: 0,
1164
+ to: 0,
1165
+ severity: "info",
1166
+ message: "Consider starting with a page component."
1167
+ });
1168
+ }
1169
+ return diagnostics;
1170
+ }
1171
+ function createLinter() {
1172
+ return (view) => {
1173
+ const text = view.state.doc.toString();
1174
+ const diagnostics = validateCode(text);
1175
+ return diagnostics.map((d) => ({
1176
+ from: d.from,
1177
+ to: d.to,
1178
+ severity: d.severity,
1179
+ message: d.message
1180
+ }));
1181
+ };
1182
+ }
1183
+ export {
1184
+ createCompletionSource,
1185
+ createHoverTooltipSource,
1186
+ createLinter,
1187
+ createTokenizer,
1188
+ getLanguageConfig,
1189
+ validateCode
1190
+ };
1191
+ //# sourceMappingURL=index.js.map