fvn-ui 0.1.0-alpha.2 → 0.1.0-alpha.20

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.
Files changed (39) hide show
  1. package/AGENTS.md +149 -0
  2. package/LLM.md +866 -0
  3. package/README.md +97 -9
  4. package/RULES.md +240 -0
  5. package/package.json +12 -5
  6. package/src/fvn-ui/LLM.md +600 -117
  7. package/src/fvn-ui/browser.js +3 -4
  8. package/src/fvn-ui/components/avatar.css +1 -0
  9. package/src/fvn-ui/components/button.css +6 -1
  10. package/src/fvn-ui/components/button.js +3 -1
  11. package/src/fvn-ui/components/card.css +8 -0
  12. package/src/fvn-ui/components/card.js +4 -4
  13. package/src/fvn-ui/components/collapsible.js +2 -2
  14. package/src/fvn-ui/components/confirm.js +3 -3
  15. package/src/fvn-ui/components/dashboard.js +1 -1
  16. package/src/fvn-ui/components/dialog.css +5 -2
  17. package/src/fvn-ui/components/dialog.js +79 -84
  18. package/src/fvn-ui/components/draggable.css +64 -0
  19. package/src/fvn-ui/components/draggable.js +203 -0
  20. package/src/fvn-ui/components/editable.css +55 -0
  21. package/src/fvn-ui/components/editable.js +178 -0
  22. package/src/fvn-ui/components/index.js +56 -22
  23. package/src/fvn-ui/components/input.css +11 -4
  24. package/src/fvn-ui/components/input.js +25 -9
  25. package/src/fvn-ui/components/label.css +2 -0
  26. package/src/fvn-ui/components/select.css +12 -0
  27. package/src/fvn-ui/components/select.js +7 -3
  28. package/src/fvn-ui/components/svg.css +1 -0
  29. package/src/fvn-ui/components/svg.js +46 -18
  30. package/src/fvn-ui/components/switch.css +1 -0
  31. package/src/fvn-ui/components/tabs.css +14 -2
  32. package/src/fvn-ui/components/tabs.js +6 -5
  33. package/src/fvn-ui/components/text.css +17 -1
  34. package/src/fvn-ui/components/text.js +19 -1
  35. package/src/fvn-ui/components/toggle.css +1 -0
  36. package/src/fvn-ui/dom.js +92 -63
  37. package/src/fvn-ui/index.js +23 -5
  38. package/src/fvn-ui/style.css +57 -68
  39. package/dist/fvn-ui.js +0 -5
package/AGENTS.md ADDED
@@ -0,0 +1,149 @@
1
+ # fvn-ui — AI Agent Instructions
2
+
3
+ > **For AI assistants**: This file contains instructions for working with fvn-ui.
4
+ > See `LLM.md` in this package for complete API documentation and examples.
5
+
6
+ ## Quick Start
7
+
8
+ ```js
9
+ import { ui } from 'fvn-ui'
10
+
11
+ // All components available via ui namespace
12
+ ui.button({ label: 'Click me', variant: 'primary' })
13
+ ui.input({ label: 'Name', placeholder: 'Enter name...' })
14
+ ui.switch({ label: 'Enable feature' })
15
+ ui.card({ title: 'Card', content: [...] })
16
+ ```
17
+
18
+ ## Critical Rules
19
+
20
+ 1. **Always use `ui.` namespace** — Import `{ ui }` not individual components
21
+ 2. **Labels on all inputs** — Every input/select needs a `label` prop
22
+ 3. **Use layout helpers** — `ui.row()` and `ui.col()` for structure
23
+ 4. **One primary button** — Only one `variant: 'primary'` per view
24
+ 5. **Switch for booleans** — Use `ui.switch()` not checkbox for on/off settings
25
+ 6. **Placeholder not value** — Use `placeholder` for hints, not `value`
26
+ 7. **Zero custom CSS** — fvn-ui provides complete styling (see below)
27
+
28
+ ## ⚠️ Styling Philosophy — CRITICAL
29
+
30
+ **fvn-ui provides complete styling. Do NOT add custom CSS unless absolutely necessary.**
31
+
32
+ ### When Custom CSS is Needed
33
+ - Drag-and-drop visual states (`.dragging`, `.drag-over`)
34
+ - Custom interactive behaviors not in fvn-ui
35
+ - App-level layout constraints (e.g., `max-width` on dashboard)
36
+
37
+ ### When Custom CSS is NOT Needed
38
+ - Backgrounds, borders, shadows → use `ui.card()` or `border` prop
39
+ - Spacing/gaps → use `gap` prop on `row()`/`col()`
40
+ - Centering → use `center: true` prop
41
+ - Full-width elements → use `grow: true` prop
42
+ - Padding → use `padding` prop
43
+ - Hover/focus states → fvn-ui components include these
44
+ - Dark mode → fvn-ui handles automatically
45
+
46
+ ### Anti-Patterns
47
+
48
+ ❌ **Wrong — CSS for layout:**
49
+ ```css
50
+ .my-container { display: flex; justify-content: center; }
51
+ ```
52
+ ```js
53
+ ui.el('div', { class: 'my-container' }, [...])
54
+ ```
55
+
56
+ ✅ **Correct — Use layout props:**
57
+ ```js
58
+ ui.col({ center: true }, [...])
59
+ ```
60
+
61
+ ❌ **Wrong — CSS for backgrounds/borders:**
62
+ ```css
63
+ .toolbar { background: #f9fafb; border: 1px solid #e5e7eb; }
64
+ ```
65
+
66
+ ✅ **Correct — Use card or clean layout:**
67
+ ```js
68
+ ui.row({ gap: 2 }, [...]) // Clean, no background needed
69
+ ui.card({ content: [...] }) // When you need a bordered container
70
+ ```
71
+
72
+ ### Minimal CSS Template
73
+
74
+ ```css
75
+ /* Only add what fvn-ui cannot do */
76
+ .ui-dashboard { max-width: 1000px; margin: 0 auto; }
77
+
78
+ /* Custom interactive states */
79
+ .draggable.dragging { opacity: 0.5; }
80
+ .draggable.drag-over { border-style: dashed; }
81
+ ```
82
+
83
+ ## Component Selection
84
+
85
+ | Need | Use |
86
+ |------|-----|
87
+ | On/off setting | `ui.switch({ label })` |
88
+ | Agreement/terms | `ui.checkbox({ label })` |
89
+ | 2-5 options | `ui.radio({ items: [...] })` |
90
+ | 6+ options | `ui.select({ options: [...] })` |
91
+ | Short text | `ui.input({ label })` |
92
+ | Long text | `ui.input({ label, rows: 4 })` |
93
+ | Action | `ui.button({ label, onClick })` |
94
+
95
+ ## Layout Pattern
96
+
97
+ ```js
98
+ ui.card({
99
+ title: 'Form',
100
+ content: ui.col({ gap: 4 }, [
101
+ ui.input({ label: 'Field 1' }),
102
+ ui.input({ label: 'Field 2' }),
103
+ ui.row({ gap: 2, justify: 'end' }, [
104
+ ui.button({ label: 'Cancel', variant: 'ghost' }),
105
+ ui.button({ label: 'Save', variant: 'primary' })
106
+ ])
107
+ ])
108
+ })
109
+
110
+ // Inputs in a row (grow: true makes row stretch to full width)
111
+ ui.row({ grow: true }, [
112
+ ui.input({ label: 'First' }),
113
+ ui.input({ label: 'Last' })
114
+ ])
115
+
116
+ // Vertically center content in a column
117
+ ui.col({ center: true }, [
118
+ ui.avatar({ name: 'John' })
119
+ ])
120
+ ```
121
+
122
+ ## Layout Shorthands
123
+
124
+ | Prop | Effect |
125
+ |------|--------|
126
+ | `grow: true` | Stretch to fill available space |
127
+ | `center: true` | Center content (justify for col, align for row) |
128
+ | `distribute: 'equal'` | Children share space equally |
129
+
130
+ ## Custom Icons
131
+
132
+ Extend with icons from [Lucide](https://lucide.dev/icons) or [Feather](https://feathericons.com):
133
+
134
+ ```js
135
+ // Add icons using SVG inner content (no <svg> wrapper)
136
+ ui.svg.extend({
137
+ github: '<path d="M15 22v-4a4.8..."/>',
138
+ custom: '<circle cx="12" cy="12" r="10"/>'
139
+ })
140
+
141
+ ui.button({ icon: 'github' }) // Now works
142
+ ui.svg.list() // Get all icon names
143
+ ```
144
+
145
+ ## Full Documentation
146
+
147
+ For complete API reference, examples, and patterns, read:
148
+ - **LLM.md** — Full component documentation in this package
149
+ - **README.md** — Installation and usage overview