@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.
package/dist/index.js CHANGED
@@ -1,447 +1,598 @@
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
+
1
176
  // src/components.ts
2
177
  var ALL_COMPONENTS = [
3
- // Layout
178
+ // ============================================
179
+ // Layout Components
180
+ // ============================================
4
181
  {
5
182
  name: "page",
6
- description: "Page root container. Starting point for the entire layout.",
183
+ nodeType: "Page",
7
184
  category: "layout",
8
- attributes: ["title", "width", "height", "viewport", "device", "centered", "p", "px", "py", "pt", "pr", "pb", "pl", "m", "gap"],
185
+ attributes: [...COMMON_ATTRIBUTES, "title", "width", "height", "viewport", "device", "centered"],
9
186
  hasChildren: true,
187
+ description: "Root container for a wireframe page",
188
+ example: 'page "Dashboard" centered { ... }',
10
189
  validChildren: ["header", "main", "footer", "sidebar", "section", "nav", "row", "col", "card"],
11
- validParents: [],
12
- example: 'page "Dashboard" centered { ... }'
190
+ validParents: []
13
191
  },
14
192
  {
15
193
  name: "header",
16
- description: "Page header area. Place navigation, logo, etc.",
194
+ nodeType: "Header",
17
195
  category: "layout",
18
- attributes: ["p", "px", "py", "border", "gap", "justify", "align"],
196
+ attributes: [...COMMON_ATTRIBUTES, "border"],
19
197
  hasChildren: true,
20
- validParents: ["page"],
21
- example: "header p=4 border { ... }"
198
+ description: "Page header section",
199
+ example: "header h=56 border { ... }",
200
+ validParents: ["page"]
22
201
  },
23
202
  {
24
203
  name: "main",
25
- description: "Main content area. Place primary content here.",
204
+ nodeType: "Main",
26
205
  category: "layout",
27
- attributes: ["p", "px", "py", "gap"],
206
+ attributes: [...COMMON_ATTRIBUTES, "scroll"],
28
207
  hasChildren: true,
29
- validParents: ["page"],
30
- example: "main p=6 { ... }"
208
+ description: "Main content section",
209
+ example: "main p=6 scroll { ... }",
210
+ validParents: ["page"]
31
211
  },
32
212
  {
33
213
  name: "footer",
34
- description: "Page footer area. Place copyright, links, etc.",
214
+ nodeType: "Footer",
35
215
  category: "layout",
36
- attributes: ["p", "px", "py", "border", "gap"],
216
+ attributes: [...COMMON_ATTRIBUTES, "border"],
37
217
  hasChildren: true,
38
- validParents: ["page"],
39
- example: "footer p=4 border { ... }"
218
+ description: "Page footer section",
219
+ example: "footer h=48 border { ... }",
220
+ validParents: ["page"]
40
221
  },
41
222
  {
42
223
  name: "sidebar",
43
- description: "Sidebar area. Place auxiliary navigation or information.",
224
+ nodeType: "Sidebar",
44
225
  category: "layout",
45
- attributes: ["position", "w", "p", "px", "py", "gap"],
226
+ attributes: [...COMMON_ATTRIBUTES, "position", "border", "bg"],
46
227
  hasChildren: true,
47
- validParents: ["page"],
48
- example: "sidebar w=240 { ... }"
228
+ description: "Side navigation or content area",
229
+ example: "sidebar w=240 border { ... }",
230
+ validParents: ["page"]
49
231
  },
50
232
  {
51
233
  name: "section",
52
- description: "Section area. Logically group content.",
234
+ nodeType: "Section",
53
235
  category: "layout",
54
- attributes: ["title", "expanded", "p", "px", "py", "gap"],
236
+ attributes: [...COMMON_ATTRIBUTES, "title", "expanded"],
55
237
  hasChildren: true,
238
+ description: "Grouped content section",
56
239
  example: 'section "Settings" expanded { ... }'
57
240
  },
58
- // Grid
241
+ // ============================================
242
+ // Grid Components
243
+ // ============================================
59
244
  {
60
245
  name: "row",
61
- description: "Horizontal flex container. Arrange children horizontally.",
246
+ nodeType: "Row",
62
247
  category: "grid",
63
- attributes: ["gap", "justify", "align", "wrap", "direction", "flex", "p", "m", "mt", "mb"],
248
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
64
249
  hasChildren: true,
250
+ description: "Horizontal flex container",
65
251
  example: "row flex gap=4 justify=between { ... }"
66
252
  },
67
253
  {
68
254
  name: "col",
69
- description: "Vertical flex container or grid column.",
255
+ nodeType: "Col",
70
256
  category: "grid",
71
- attributes: ["span", "sm", "md", "lg", "xl", "order", "gap", "justify", "align", "p", "m", "w"],
257
+ attributes: [...COMMON_ATTRIBUTES, "sm", "md", "lg", "xl", "order", "border", "bg", "scroll"],
72
258
  hasChildren: true,
259
+ description: "Vertical flex container or grid column",
73
260
  example: "col span=6 md=4 { ... }"
74
261
  },
75
- // Container
262
+ // ============================================
263
+ // Container Components
264
+ // ============================================
76
265
  {
77
266
  name: "card",
78
- description: "Card component. Group and display content.",
267
+ nodeType: "Card",
79
268
  category: "container",
80
- attributes: ["title", "p", "shadow", "border", "gap"],
269
+ attributes: [...COMMON_ATTRIBUTES, "title", "shadow", "border", "rounded"],
81
270
  hasChildren: true,
271
+ description: "Card container with optional title",
82
272
  example: 'card "Settings" p=4 shadow=md { ... }'
83
273
  },
84
274
  {
85
275
  name: "modal",
86
- description: "Modal dialog. Display content on an overlay.",
276
+ nodeType: "Modal",
87
277
  category: "container",
88
- attributes: ["title", "w", "h", "p"],
278
+ attributes: [...COMMON_ATTRIBUTES, "title"],
89
279
  hasChildren: true,
280
+ description: "Modal dialog overlay",
90
281
  example: 'modal "Confirm" w=400 { ... }'
91
282
  },
92
283
  {
93
284
  name: "drawer",
94
- description: "Drawer panel. Slides in from the edge of the screen.",
285
+ nodeType: "Drawer",
95
286
  category: "container",
96
- attributes: ["title", "position", "p"],
287
+ attributes: [...COMMON_ATTRIBUTES, "title", "position"],
97
288
  hasChildren: true,
289
+ description: "Slide-in drawer panel",
98
290
  example: 'drawer "Menu" position=left { ... }'
99
291
  },
100
292
  {
101
293
  name: "accordion",
102
- description: "Accordion. Collapsible content panel.",
294
+ nodeType: "Accordion",
103
295
  category: "container",
104
- attributes: ["title", "p"],
296
+ attributes: [...COMMON_ATTRIBUTES, "title"],
105
297
  hasChildren: true,
298
+ description: "Collapsible sections container",
106
299
  example: 'accordion { section "FAQ 1" { ... } }'
107
300
  },
108
- // Text
301
+ // ============================================
302
+ // Text Components
303
+ // ============================================
109
304
  {
110
305
  name: "text",
111
- description: "Text element. Display plain text.",
306
+ nodeType: "Text",
112
307
  category: "text",
113
- attributes: ["size", "weight", "align", "muted", "m", "mt", "mb"],
308
+ attributes: [...COMMON_ATTRIBUTES, "size", "weight", "muted", "bold"],
114
309
  hasChildren: false,
310
+ description: "Text content",
115
311
  example: 'text "Hello World" size=lg weight=bold'
116
312
  },
117
313
  {
118
314
  name: "title",
119
- description: "Title element. Display h1-h6 headings.",
315
+ nodeType: "Title",
120
316
  category: "text",
121
- attributes: ["level", "size", "align", "m", "mt", "mb"],
317
+ attributes: [...COMMON_ATTRIBUTES, "level", "size"],
122
318
  hasChildren: false,
319
+ description: "Heading element (h1-h6)",
123
320
  example: 'title "Welcome" level=2'
124
321
  },
125
322
  {
126
323
  name: "link",
127
- description: "Link element. Display clickable hyperlink.",
324
+ nodeType: "Link",
128
325
  category: "text",
129
- attributes: ["href", "external"],
326
+ attributes: [...COMMON_ATTRIBUTES, "href", "external"],
130
327
  hasChildren: false,
328
+ description: "Hyperlink text",
131
329
  example: 'link "Learn more" href="/docs" external'
132
330
  },
133
- // Input
331
+ // ============================================
332
+ // Input Components
333
+ // ============================================
134
334
  {
135
335
  name: "input",
136
- description: "Input field. Accept text, email, password, etc.",
336
+ nodeType: "Input",
137
337
  category: "input",
138
- attributes: ["label", "inputType", "placeholder", "value", "disabled", "required", "readonly", "icon", "m", "mb"],
338
+ attributes: [...COMMON_ATTRIBUTES, "label", "inputType", "placeholder", "value", "disabled", "required", "readonly", "icon", "size", "rounded"],
139
339
  hasChildren: false,
340
+ description: "Text input field",
140
341
  example: 'input "Email" inputType=email placeholder="user@example.com" required'
141
342
  },
142
343
  {
143
344
  name: "textarea",
144
- description: "Multi-line input field. Accept long text.",
345
+ nodeType: "Textarea",
145
346
  category: "input",
146
- attributes: ["label", "placeholder", "value", "rows", "disabled", "required", "m", "mb"],
347
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "rows", "disabled", "required"],
147
348
  hasChildren: false,
349
+ description: "Multi-line text input",
148
350
  example: 'textarea "Description" rows=4 placeholder="Enter description..."'
149
351
  },
150
352
  {
151
353
  name: "select",
152
- description: "Dropdown select. Choose one from multiple options.",
354
+ nodeType: "Select",
153
355
  category: "input",
154
- attributes: ["label", "placeholder", "value", "disabled", "required", "m", "mb"],
356
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "disabled", "required"],
155
357
  hasChildren: false,
358
+ description: "Dropdown select",
156
359
  example: 'select "Country" ["USA", "Canada", "UK"] placeholder="Select..."'
157
360
  },
158
361
  {
159
362
  name: "checkbox",
160
- description: "Checkbox. Select true/false value.",
363
+ nodeType: "Checkbox",
161
364
  category: "input",
162
- attributes: ["label", "checked", "disabled", "m", "mb"],
365
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
163
366
  hasChildren: false,
367
+ description: "Checkbox input",
164
368
  example: 'checkbox "I agree to terms" checked'
165
369
  },
166
370
  {
167
371
  name: "radio",
168
- description: "Radio button. Select one within a group.",
372
+ nodeType: "Radio",
169
373
  category: "input",
170
- attributes: ["label", "name", "checked", "disabled", "m", "mb"],
374
+ attributes: [...COMMON_ATTRIBUTES, "label", "name", "checked", "disabled"],
171
375
  hasChildren: false,
376
+ description: "Radio button input",
172
377
  example: 'radio "Option A" name="choice" checked'
173
378
  },
174
379
  {
175
380
  name: "switch",
176
- description: "Toggle switch. Switch on/off state.",
381
+ nodeType: "Switch",
177
382
  category: "input",
178
- attributes: ["label", "checked", "disabled", "m", "mb"],
383
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
179
384
  hasChildren: false,
385
+ description: "Toggle switch",
180
386
  example: 'switch "Dark mode" checked'
181
387
  },
182
388
  {
183
389
  name: "slider",
184
- description: "Slider. Select a value within a range.",
390
+ nodeType: "Slider",
185
391
  category: "input",
186
- attributes: ["label", "min", "max", "value", "step", "disabled", "m", "mb"],
392
+ attributes: [...COMMON_ATTRIBUTES, "label", "min", "max", "value", "step", "disabled"],
187
393
  hasChildren: false,
394
+ description: "Range slider",
188
395
  example: 'slider "Volume" min=0 max=100 value=50'
189
396
  },
190
- // Button
191
397
  {
192
398
  name: "button",
193
- description: "Button element. Display clickable button.",
399
+ nodeType: "Button",
194
400
  category: "input",
195
- attributes: ["primary", "secondary", "outline", "ghost", "danger", "size", "icon", "disabled", "loading", "w"],
401
+ attributes: [...COMMON_ATTRIBUTES, "primary", "secondary", "outline", "ghost", "danger", "size", "icon", "disabled", "loading"],
196
402
  hasChildren: false,
403
+ description: "Clickable button",
197
404
  example: 'button "Submit" primary icon=send'
198
405
  },
199
- // Display
406
+ // ============================================
407
+ // Display Components
408
+ // ============================================
200
409
  {
201
410
  name: "image",
202
- description: "Image element. Display an image.",
411
+ nodeType: "Image",
203
412
  category: "display",
204
- attributes: ["src", "alt", "w", "h"],
413
+ attributes: [...COMMON_ATTRIBUTES, "src", "alt"],
205
414
  hasChildren: false,
415
+ description: "Image placeholder",
206
416
  example: "image w=200 h=150"
207
417
  },
208
418
  {
209
419
  name: "placeholder",
210
- description: "Placeholder. Image or content placeholder.",
420
+ nodeType: "Placeholder",
211
421
  category: "display",
212
- attributes: ["label", "w", "h"],
213
- hasChildren: false,
214
- example: 'placeholder "Banner Image" w=full h=200'
422
+ attributes: [...COMMON_ATTRIBUTES, "label"],
423
+ hasChildren: true,
424
+ description: "Generic placeholder",
425
+ example: 'placeholder "Banner Image" w=full h=200 { ... }'
215
426
  },
216
427
  {
217
428
  name: "avatar",
218
- description: "Avatar element. Display user profile image.",
429
+ nodeType: "Avatar",
219
430
  category: "display",
220
- attributes: ["name", "src", "size"],
431
+ attributes: [...COMMON_ATTRIBUTES, "name", "src", "size"],
221
432
  hasChildren: false,
433
+ description: "User avatar",
222
434
  example: 'avatar "John Doe" size=lg'
223
435
  },
224
436
  {
225
437
  name: "badge",
226
- description: "Badge element. Display status or count as a small label.",
438
+ nodeType: "Badge",
227
439
  category: "display",
228
- attributes: ["variant", "pill", "icon", "size"],
440
+ attributes: [...COMMON_ATTRIBUTES, "variant", "pill", "icon", "size"],
229
441
  hasChildren: false,
442
+ description: "Status badge",
230
443
  example: 'badge "New" variant=success pill'
231
444
  },
232
445
  {
233
446
  name: "icon",
234
- description: "Icon element. Display a Lucide icon.",
447
+ nodeType: "Icon",
235
448
  category: "display",
236
- attributes: ["name", "size", "muted"],
449
+ attributes: [...COMMON_ATTRIBUTES, "size", "muted"],
237
450
  hasChildren: false,
451
+ description: "Lucide icon",
238
452
  example: 'icon "settings" size=lg'
239
453
  },
240
- // Data
454
+ // ============================================
455
+ // Data Components
456
+ // ============================================
241
457
  {
242
458
  name: "table",
243
- description: "Table component. Display data in tabular format.",
459
+ nodeType: "Table",
244
460
  category: "data",
245
- attributes: ["striped", "bordered", "hover"],
461
+ attributes: [...COMMON_ATTRIBUTES, "striped", "bordered", "hover"],
246
462
  hasChildren: false,
463
+ description: "Data table",
247
464
  example: 'table striped bordered { columns ["Name", "Email"] row ["John", "john@example.com"] }'
248
465
  },
249
466
  {
250
467
  name: "list",
251
- description: "List component. Display items as a list.",
468
+ nodeType: "List",
252
469
  category: "data",
253
- attributes: ["ordered", "none", "gap"],
470
+ attributes: [...COMMON_ATTRIBUTES, "ordered", "none"],
254
471
  hasChildren: false,
472
+ description: "List of items",
255
473
  example: 'list ordered ["First", "Second", "Third"]'
256
474
  },
257
- // Feedback
475
+ // ============================================
476
+ // Feedback Components
477
+ // ============================================
258
478
  {
259
479
  name: "alert",
260
- description: "Alert element. Display a message to the user.",
480
+ nodeType: "Alert",
261
481
  category: "feedback",
262
- attributes: ["variant", "dismissible", "icon"],
482
+ attributes: [...COMMON_ATTRIBUTES, "variant", "dismissible", "icon"],
263
483
  hasChildren: false,
484
+ description: "Alert message",
264
485
  example: 'alert "Changes saved!" variant=success'
265
486
  },
266
487
  {
267
488
  name: "toast",
268
- description: "Toast notification. Display a temporary message.",
489
+ nodeType: "Toast",
269
490
  category: "feedback",
270
- attributes: ["position", "variant"],
491
+ attributes: [...COMMON_ATTRIBUTES, "position", "variant"],
271
492
  hasChildren: false,
493
+ description: "Toast notification",
272
494
  example: 'toast "Item deleted" position=bottom-right variant=danger'
273
495
  },
274
496
  {
275
497
  name: "progress",
276
- description: "Progress bar. Display progress status.",
498
+ nodeType: "Progress",
277
499
  category: "feedback",
278
- attributes: ["value", "max", "label", "indeterminate"],
500
+ attributes: [...COMMON_ATTRIBUTES, "value", "max", "label", "indeterminate"],
279
501
  hasChildren: false,
502
+ description: "Progress bar",
280
503
  example: 'progress value=75 label="Uploading..."'
281
504
  },
282
505
  {
283
506
  name: "spinner",
284
- description: "Loading spinner. Display loading status.",
507
+ nodeType: "Spinner",
285
508
  category: "feedback",
286
- attributes: ["label", "size"],
509
+ attributes: [...COMMON_ATTRIBUTES, "label", "size"],
287
510
  hasChildren: false,
511
+ description: "Loading spinner",
288
512
  example: "spinner size=lg"
289
513
  },
290
- // Overlay
514
+ // ============================================
515
+ // Overlay Components
516
+ // ============================================
291
517
  {
292
518
  name: "tooltip",
293
- description: "Tooltip element. Show additional info on hover.",
519
+ nodeType: "Tooltip",
294
520
  category: "overlay",
295
- attributes: ["position"],
296
- hasChildren: true,
521
+ attributes: [...COMMON_ATTRIBUTES, "position"],
522
+ hasChildren: false,
523
+ description: "Tooltip on hover",
297
524
  example: 'tooltip "More info" position=top { icon "help-circle" }'
298
525
  },
299
526
  {
300
527
  name: "popover",
301
- description: "Popover. Show additional content on click.",
528
+ nodeType: "Popover",
302
529
  category: "overlay",
303
- attributes: ["title"],
530
+ attributes: [...COMMON_ATTRIBUTES, "title"],
304
531
  hasChildren: true,
532
+ description: "Popover panel",
305
533
  example: 'popover "Details" { ... }'
306
534
  },
307
535
  {
308
536
  name: "dropdown",
309
- description: "Dropdown menu. Expand menu on click.",
537
+ nodeType: "Dropdown",
310
538
  category: "overlay",
311
- attributes: [],
539
+ attributes: [...COMMON_ATTRIBUTES],
312
540
  hasChildren: false,
541
+ description: "Dropdown menu",
313
542
  example: 'dropdown { item "Edit" icon=edit item "Delete" icon=trash danger }'
314
543
  },
315
- // Navigation
544
+ // ============================================
545
+ // Navigation Components
546
+ // ============================================
316
547
  {
317
548
  name: "nav",
318
- description: "Navigation area. Place menu items.",
549
+ nodeType: "Nav",
319
550
  category: "navigation",
320
- attributes: ["vertical", "gap"],
551
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
321
552
  hasChildren: false,
553
+ description: "Navigation menu",
322
554
  example: 'nav [{ label="Home" icon=home active }, { label="Settings" icon=settings }] vertical'
323
555
  },
324
556
  {
325
557
  name: "tabs",
326
- description: "Tabs component. Switch between multiple panels.",
558
+ nodeType: "Tabs",
327
559
  category: "navigation",
328
- attributes: ["active"],
560
+ attributes: [...COMMON_ATTRIBUTES, "active"],
329
561
  hasChildren: true,
562
+ description: "Tab navigation",
330
563
  example: 'tabs { tab "General" active { ... } tab "Advanced" { ... } }'
331
564
  },
332
565
  {
333
566
  name: "breadcrumb",
334
- description: "Breadcrumb. Display current location as a path.",
567
+ nodeType: "Breadcrumb",
335
568
  category: "navigation",
336
- attributes: [],
569
+ attributes: [...COMMON_ATTRIBUTES],
337
570
  hasChildren: false,
571
+ description: "Breadcrumb navigation",
338
572
  example: 'breadcrumb [{ label="Home" href="/" }, { label="Products" }, { label="Details" }]'
339
573
  },
340
- // Divider
574
+ // ============================================
575
+ // Divider Component
576
+ // ============================================
341
577
  {
342
578
  name: "divider",
343
- description: "Divider element. Visually separate content.",
344
- category: "display",
345
- attributes: ["m", "my", "mx"],
579
+ nodeType: "Divider",
580
+ category: "layout",
581
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
346
582
  hasChildren: false,
583
+ description: "Horizontal separator",
347
584
  example: "divider my=4"
348
585
  }
349
586
  ];
350
-
351
- // src/attributes.ts
352
- var ATTRIBUTES = [
353
- // Spacing
354
- { name: "p", description: "Padding. Set inner spacing.", values: "number", example: "p=4" },
355
- { name: "px", description: "Horizontal padding.", values: "number", example: "px=4" },
356
- { name: "py", description: "Vertical padding.", values: "number", example: "py=4" },
357
- { name: "pt", description: "Top padding.", values: "number", example: "pt=4" },
358
- { name: "pr", description: "Right padding.", values: "number", example: "pr=4" },
359
- { name: "pb", description: "Bottom padding.", values: "number", example: "pb=4" },
360
- { name: "pl", description: "Left padding.", values: "number", example: "pl=4" },
361
- { name: "m", description: "Margin. Set outer spacing.", values: "number", example: "m=4" },
362
- { name: "mx", description: 'Horizontal margin. Can be "auto" for centering.', values: "number", example: "mx=auto" },
363
- { name: "my", description: "Vertical margin.", values: "number", example: "my=4" },
364
- { name: "mt", description: "Top margin.", values: "number", example: "mt=4" },
365
- { name: "mr", description: "Right margin.", values: "number", example: "mr=4" },
366
- { name: "mb", description: "Bottom margin.", values: "number", example: "mb=4" },
367
- { name: "ml", description: "Left margin.", values: "number", example: "ml=4" },
368
- { name: "gap", description: "Gap between child elements.", values: "number", example: "gap=4" },
369
- // Grid Layout
370
- { name: "span", description: "Grid column width (1-12).", values: "number", example: "span=6" },
371
- { name: "sm", description: "Column width at 576px and above.", values: "number", example: "sm=6" },
372
- { name: "md", description: "Column width at 768px and above.", values: "number", example: "md=4" },
373
- { name: "lg", description: "Column width at 992px and above.", values: "number", example: "lg=3" },
374
- { name: "xl", description: "Column width at 1200px and above.", values: "number", example: "xl=2" },
375
- { name: "order", description: "Order within flex container.", values: "number", example: "order=1" },
376
- // Flex Layout
377
- { name: "flex", description: "Enable flexbox layout.", values: "boolean", example: "flex" },
378
- { name: "direction", description: "Flex direction.", values: ["row", "column", "row-reverse", "column-reverse"], example: "direction=column" },
379
- { name: "justify", description: "Main axis alignment.", values: ["start", "center", "end", "between", "around", "evenly"], example: "justify=center" },
380
- { name: "align", description: "Cross axis alignment.", values: ["start", "center", "end", "stretch", "baseline"], example: "align=center" },
381
- { name: "wrap", description: "Allow child elements to wrap.", values: "boolean", example: "wrap" },
382
- // Size
383
- { name: "width", description: "Width in pixels.", values: "number", example: "width=400" },
384
- { name: "height", description: "Height in pixels.", values: "number", example: "height=300" },
385
- { name: "w", description: "Width (full, auto, screen, fit, or number).", values: ["full", "auto", "screen", "fit"], example: "w=full" },
386
- { name: "h", description: "Height (full, auto, screen, or number).", values: ["full", "auto", "screen"], example: "h=full" },
387
- { name: "minW", description: "Minimum width.", values: "number", example: "minW=200" },
388
- { name: "maxW", description: "Maximum width.", values: "number", example: "maxW=600" },
389
- { name: "minH", description: "Minimum height.", values: "number", example: "minH=100" },
390
- { name: "maxH", description: "Maximum height.", values: "number", example: "maxH=400" },
391
- { name: "size", description: "Size preset.", values: ["xs", "sm", "md", "lg", "xl"], example: "size=lg" },
392
- { name: "viewport", description: 'Viewport size (e.g., "1440x900").', values: "string", example: 'viewport="1440x900"' },
393
- { name: "device", description: "Device preset.", values: ["iphone14", "iphone14pro", "desktop", "tablet"], example: 'device="iphone14"' },
394
- // Visual
395
- { name: "border", description: "Show border.", values: "boolean", example: "border" },
396
- { name: "shadow", description: "Box shadow.", values: ["none", "sm", "md", "lg", "xl"], example: "shadow=md" },
397
- { name: "position", description: "Position setting.", values: ["left", "right", "top", "bottom", "top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"], example: "position=left" },
398
- // Text
399
- { name: "level", description: "Heading level (1-6).", values: "number", example: "level=2" },
400
- { name: "weight", description: "Font weight.", values: ["normal", "medium", "semibold", "bold"], example: "weight=bold" },
401
- { name: "muted", description: "Muted style.", values: "boolean", example: "muted" },
402
- // Button variants
403
- { name: "primary", description: "Primary emphasis style.", values: "boolean", example: "primary" },
404
- { name: "secondary", description: "Secondary style.", values: "boolean", example: "secondary" },
405
- { name: "outline", description: "Outline style.", values: "boolean", example: "outline" },
406
- { name: "ghost", description: "Ghost/transparent style.", values: "boolean", example: "ghost" },
407
- { name: "danger", description: "Danger/delete style.", values: "boolean", example: "danger" },
408
- // Status variants
409
- { name: "variant", description: "Variant style.", values: ["default", "primary", "secondary", "success", "warning", "danger", "info"], example: "variant=success" },
410
- // Form
411
- { name: "inputType", description: "Input field type.", values: ["text", "email", "password", "number", "tel", "url", "search", "date"], example: "inputType=email" },
412
- { name: "placeholder", description: "Placeholder text.", values: "string", example: 'placeholder="Enter text"' },
413
- { name: "value", description: "Default value.", values: "string", example: 'value="default"' },
414
- { name: "label", description: "Label text.", values: "string", example: 'label="Name"' },
415
- { name: "required", description: "Required field.", values: "boolean", example: "required" },
416
- { name: "disabled", description: "Disabled state.", values: "boolean", example: "disabled" },
417
- { name: "readonly", description: "Read-only.", values: "boolean", example: "readonly" },
418
- { name: "checked", description: "Checked state.", values: "boolean", example: "checked" },
419
- { name: "loading", description: "Loading state.", values: "boolean", example: "loading" },
420
- { name: "name", description: "Form element name attribute.", values: "string", example: 'name="field"' },
421
- { name: "rows", description: "Number of textarea rows.", values: "number", example: "rows=4" },
422
- { name: "min", description: "Minimum value.", values: "number", example: "min=0" },
423
- { name: "max", description: "Maximum value.", values: "number", example: "max=100" },
424
- { name: "step", description: "Step increment.", values: "number", example: "step=1" },
425
- // Other
426
- { name: "title", description: "Title text.", values: "string", example: 'title="Title"' },
427
- { name: "centered", description: "Center alignment.", values: "boolean", example: "centered" },
428
- { name: "vertical", description: "Vertical orientation.", values: "boolean", example: "vertical" },
429
- { name: "expanded", description: "Expanded state.", values: "boolean", example: "expanded" },
430
- { name: "active", description: "Active state/index.", values: "number", example: "active=0" },
431
- { name: "href", description: "Link URL.", values: "string", example: 'href="/path"' },
432
- { name: "external", description: "External link.", values: "boolean", example: "external" },
433
- { name: "src", description: "Image source URL.", values: "string", example: 'src="/image.png"' },
434
- { name: "alt", description: "Alternative text.", values: "string", example: 'alt="Image"' },
435
- { name: "icon", description: "Icon name (Lucide icons).", values: "string", example: 'icon="home"' },
436
- { name: "pill", description: "Rounded pill badge.", values: "boolean", example: "pill" },
437
- { name: "dismissible", description: "Can be dismissed.", values: "boolean", example: "dismissible" },
438
- { name: "indeterminate", description: "Indeterminate state.", values: "boolean", example: "indeterminate" },
439
- { name: "striped", description: "Striped style.", values: "boolean", example: "striped" },
440
- { name: "bordered", description: "Bordered style.", values: "boolean", example: "bordered" },
441
- { name: "hover", description: "Hover effect.", values: "boolean", example: "hover" },
442
- { name: "ordered", description: "Ordered list.", values: "boolean", example: "ordered" },
443
- { name: "none", description: "No list style.", values: "boolean", example: "none" }
444
- ];
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
+ );
445
596
 
446
597
  // src/keywords.ts
447
598
  var CATEGORY_LABELS = {
@@ -547,10 +698,13 @@ var SPACING_SCALE = {
547
698
 
548
699
  // src/utils.ts
549
700
  function getComponent(name) {
550
- return ALL_COMPONENTS.find((c) => c.name === name.toLowerCase());
701
+ return COMPONENT_MAP.get(name.toLowerCase());
702
+ }
703
+ function getComponentByNodeType(nodeType) {
704
+ return NODE_TYPE_MAP.get(nodeType);
551
705
  }
552
706
  function getAttribute(name) {
553
- return ATTRIBUTES.find((a) => a.name === name);
707
+ return ATTRIBUTE_MAP.get(name);
554
708
  }
555
709
  function getValidChildren(componentName) {
556
710
  const component = getComponent(componentName);
@@ -575,29 +729,29 @@ function getComponentsByCategory(category) {
575
729
  return ALL_COMPONENTS.filter((c) => c.category === category);
576
730
  }
577
731
  function getAttributeTypeLabel(attr) {
578
- if (attr.values === "number") return "number";
579
- if (attr.values === "string") return "string";
580
- if (attr.values === "boolean") return "boolean";
581
- if (Array.isArray(attr.values)) {
732
+ if (attr.type === "boolean") return "boolean";
733
+ if (attr.type === "number") return "number";
734
+ if (attr.type === "string" || attr.type === "string[]") return "string";
735
+ if (attr.type === "enum" && attr.values) {
582
736
  const preview = attr.values.slice(0, 3).join(" | ");
583
737
  return attr.values.length > 3 ? `${preview}...` : preview;
584
738
  }
585
- return "";
739
+ return attr.type;
586
740
  }
587
741
  function formatAttributeValues(attr) {
588
- if (attr.values === "number") return "Type: number";
589
- if (attr.values === "string") return "Type: string";
590
- if (attr.values === "boolean") return "Type: boolean (can be omitted)";
591
- if (Array.isArray(attr.values)) {
742
+ if (attr.type === "number") return "Type: number";
743
+ if (attr.type === "string") return "Type: string";
744
+ if (attr.type === "boolean") return "Type: boolean (can be omitted)";
745
+ if (attr.type === "enum" && attr.values) {
592
746
  return `Values: ${attr.values.join(" | ")}`;
593
747
  }
594
- return "";
748
+ return `Type: ${attr.type}`;
595
749
  }
596
750
  function isComponent(word) {
597
- return ALL_COMPONENTS.some((c) => c.name === word.toLowerCase());
751
+ return COMPONENT_MAP.has(word.toLowerCase());
598
752
  }
599
753
  function isAttribute(word) {
600
- return ATTRIBUTES.some((a) => a.name === word);
754
+ return ATTRIBUTE_MAP.has(word);
601
755
  }
602
756
  function getComponentNames() {
603
757
  return ALL_COMPONENTS.map((c) => c.name);
@@ -605,19 +759,30 @@ function getComponentNames() {
605
759
  function getAttributeNames() {
606
760
  return ATTRIBUTES.map((a) => a.name);
607
761
  }
762
+ function getCategories() {
763
+ return [...new Set(ALL_COMPONENTS.map((c) => c.category))];
764
+ }
608
765
  export {
609
766
  ALL_COMPONENTS,
610
767
  ATTRIBUTES,
768
+ ATTRIBUTE_MAP,
611
769
  CATEGORY_LABELS,
770
+ COMMON_ATTRIBUTES,
612
771
  COMMON_NUMBERS,
772
+ COMPONENT_MAP,
773
+ NODE_TYPE_MAP,
613
774
  SPACING_SCALE,
775
+ VALID_ATTRIBUTE_NAMES,
776
+ VALID_COMPONENT_NAMES,
614
777
  VALUE_KEYWORDS,
615
778
  formatAttributeValues,
616
779
  getAttribute,
617
780
  getAttributeNames,
618
781
  getAttributeTypeLabel,
782
+ getCategories,
619
783
  getComponent,
620
784
  getComponentAttributes,
785
+ getComponentByNodeType,
621
786
  getComponentNames,
622
787
  getComponentsByCategory,
623
788
  getValidChildren,