@snatuva/primitives 0.0.4 β 0.0.6
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/README.md +132 -145
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,42 +1,50 @@
|
|
|
1
1
|
# @snatuva/primitives
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
and composability.
|
|
3
|
+
π **Signals-first Angular primitives library** for building scalable, reusable UI components.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Designed for modern Angular (v17+), this library provides low-level building blocks ("primitives") to help you create consistent, accessible, and high-performance UI systems.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
- Tooltip primitives
|
|
7
|
+
---
|
|
10
8
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
- **Headless**: no styling is imposed by the library.
|
|
14
|
-
- **Directive-first**: compose behavior into your own markup.
|
|
15
|
-
- **Scoped state**: each primitive root creates an isolated state scope.
|
|
16
|
-
- **Accessible by default**: ARIA semantics are wired into directives.
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
9
|
+
## π¦ Installation
|
|
19
10
|
|
|
20
11
|
```bash
|
|
21
12
|
npm install @snatuva/primitives
|
|
22
13
|
```
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
---
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
## β‘ Why this library?
|
|
18
|
+
|
|
19
|
+
Most Angular component libraries are:
|
|
20
|
+
|
|
21
|
+
* β Heavy and opinionated
|
|
22
|
+
* β Hard to customize
|
|
23
|
+
* β Not aligned with modern Angular (Signals, standalone)
|
|
24
|
+
|
|
25
|
+
**@snatuva/primitives focuses on:**
|
|
26
|
+
|
|
27
|
+
* β
Lightweight, composable primitives
|
|
28
|
+
* β
Signals-first architecture
|
|
29
|
+
* β
Standalone component support
|
|
30
|
+
* β
Tree-shakable design
|
|
31
|
+
* β
Clean API for enterprise scalability
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## π§© What are βPrimitivesβ?
|
|
36
|
+
|
|
37
|
+
Primitives are **low-level UI building blocks** (not full components).
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Instead of giving you a βready-made UIβ, this library gives:
|
|
40
|
+
|
|
41
|
+
* Flexible foundations
|
|
42
|
+
* Full control over styling and behavior
|
|
43
|
+
* Better reusability across projects
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Tabs Usage
|
|
40
48
|
|
|
41
49
|
### Directives
|
|
42
50
|
|
|
@@ -52,6 +60,19 @@ import {
|
|
|
52
60
|
- `apTabContent` β structural directive to conditionally render active panel content.
|
|
53
61
|
- Required input: `tabId: string`
|
|
54
62
|
|
|
63
|
+
### Import into your Angular app
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import {
|
|
67
|
+
TabsDirective,
|
|
68
|
+
TabListDirective,
|
|
69
|
+
TabTriggerDirective,
|
|
70
|
+
TabPanelDirective
|
|
71
|
+
} from '@snatuva/primitives';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
55
76
|
### Minimal usage
|
|
56
77
|
|
|
57
78
|
```html
|
|
@@ -73,144 +94,110 @@ import {
|
|
|
73
94
|
</div>
|
|
74
95
|
```
|
|
75
96
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- The first registered panel is selected by default.
|
|
79
|
-
- Selecting a disabled tab is ignored.
|
|
80
|
-
- When an active panel is removed, selection falls back to the next available panel.
|
|
81
|
-
|
|
82
|
-
### Accessibility (ARIA)
|
|
97
|
+
---
|
|
83
98
|
|
|
84
|
-
|
|
99
|
+
## π§ Core Concepts
|
|
85
100
|
|
|
86
|
-
|
|
87
|
-
- `apTabList` β `role="tablist"`
|
|
88
|
-
- `apTabTrigger` β `role="tab"`, `aria-selected="true|false"`, `aria-controls="[panel-id]"`, `tabindex` management
|
|
89
|
-
- `apTabPanel` β `role="tabpanel"`, `aria-labelledby="[trigger-id]"`, `aria-hidden="true|false"`, `id` auto-generated
|
|
101
|
+
### 1. Signals-first design
|
|
90
102
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
- <kbd>Arrow Down</kbd> / <kbd>Arrow Up</kbd> β Switch between tabs
|
|
94
|
-
- <kbd>Home</kbd> β Jump to first tab
|
|
95
|
-
- <kbd>End</kbd> β Jump to last tab
|
|
96
|
-
- <kbd>Tab</kbd> β Focus management with roving tabindex
|
|
103
|
+
* Uses Angular Signals for state management
|
|
104
|
+
* Minimal RxJS usage (only where necessary)
|
|
97
105
|
|
|
98
|
-
|
|
106
|
+
### 2. Standalone components
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
[apTabTrigger][aria-selected='true'] {
|
|
103
|
-
border-bottom: 2px solid #2196f3;
|
|
104
|
-
font-weight: bold;
|
|
105
|
-
}
|
|
108
|
+
* No NgModules required
|
|
109
|
+
* Easy integration in modern Angular apps
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
[apTabTrigger][aria-disabled='true'] {
|
|
109
|
-
opacity: 0.5;
|
|
110
|
-
cursor: not-allowed;
|
|
111
|
-
}
|
|
111
|
+
### 3. Composition over configuration
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
padding: 20px;
|
|
116
|
-
}
|
|
113
|
+
* Build your own components using primitives
|
|
114
|
+
* Avoid rigid APIs
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
[apTabPanel][aria-hidden='true'] {
|
|
120
|
-
display: none;
|
|
121
|
-
}
|
|
122
|
-
```
|
|
116
|
+
---
|
|
123
117
|
|
|
124
|
-
##
|
|
118
|
+
## βΏ Accessibility (A11y)
|
|
125
119
|
|
|
126
|
-
|
|
120
|
+
This library is designed with accessibility in mind:
|
|
127
121
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
* Semantic HTML by default
|
|
123
|
+
* Keyboard interaction support
|
|
124
|
+
* ARIA best practices
|
|
125
|
+
* Focus management patterns
|
|
131
126
|
|
|
132
|
-
|
|
127
|
+
---
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
<div apTooltip>
|
|
136
|
-
<!-- Automatically gets role="button", aria-describedby, aria-expanded, tabindex -->
|
|
137
|
-
<button apTooltipTrigger type="button">Hover or focus me</button>
|
|
138
|
-
|
|
139
|
-
<!-- Automatically gets role="tooltip" and unique id -->
|
|
140
|
-
<ng-template apTooltipContent>
|
|
141
|
-
<span>Helpful tooltip content</span>
|
|
142
|
-
</ng-template>
|
|
143
|
-
</div>
|
|
144
|
-
```
|
|
129
|
+
## π Project Structure
|
|
145
130
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
β
**Automatic - No manual configuration needed!**
|
|
154
|
-
|
|
155
|
-
**Built-in ARIA attributes:**
|
|
156
|
-
- `apTooltipContent` β `role="tooltip"`, unique `id` auto-generated
|
|
157
|
-
- `apTooltipTrigger` β `role="button"`, `aria-describedby="[tooltip-id]"`, `aria-expanded="true|false"`, `tabindex="0"`
|
|
158
|
-
|
|
159
|
-
**Built-in keyboard navigation:**
|
|
160
|
-
- <kbd>Enter</kbd> / <kbd>Space</kbd> β Open tooltip (if not already open)
|
|
161
|
-
- <kbd>Escape</kbd> β Close tooltip
|
|
162
|
-
- <kbd>Tab</kbd> β Move focus (closes tooltip automatically on blur)
|
|
163
|
-
- Mouse hover / Focus events β Auto show/hide
|
|
164
|
-
|
|
165
|
-
**Best Practices:**
|
|
166
|
-
- Use tooltips for supplemental information only.
|
|
167
|
-
- Don't rely on tooltips for critical information.
|
|
168
|
-
- Ensure tooltip content is concise and helpful.
|
|
169
|
-
|
|
170
|
-
**CSS Styling Example:**
|
|
171
|
-
|
|
172
|
-
```css
|
|
173
|
-
/* Style tooltip trigger */
|
|
174
|
-
[apTooltipTrigger] {
|
|
175
|
-
cursor: help;
|
|
176
|
-
text-decoration: underline dotted;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* Style tooltip content */
|
|
180
|
-
[apTooltipContent] {
|
|
181
|
-
background: #333;
|
|
182
|
-
color: #fff;
|
|
183
|
-
padding: 8px 12px;
|
|
184
|
-
border-radius: 4px;
|
|
185
|
-
font-size: 12px;
|
|
186
|
-
max-width: 200px;
|
|
187
|
-
z-index: 1000;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/* Add arrow pointer (optional) */
|
|
191
|
-
[apTooltipContent]::before {
|
|
192
|
-
content: '';
|
|
193
|
-
position: absolute;
|
|
194
|
-
bottom: -4px;
|
|
195
|
-
left: 50%;
|
|
196
|
-
transform: translateX(-50%);
|
|
197
|
-
width: 8px;
|
|
198
|
-
height: 8px;
|
|
199
|
-
background: #333;
|
|
200
|
-
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
|
|
201
|
-
}
|
|
131
|
+
```bash
|
|
132
|
+
projects/
|
|
133
|
+
primitives/
|
|
134
|
+
src/
|
|
135
|
+
lib/
|
|
136
|
+
public-api.ts
|
|
202
137
|
```
|
|
203
138
|
|
|
204
|
-
|
|
139
|
+
---
|
|
205
140
|
|
|
206
|
-
|
|
141
|
+
## π§ͺ Development
|
|
207
142
|
|
|
208
143
|
```bash
|
|
209
144
|
ng build primitives
|
|
210
145
|
```
|
|
211
146
|
|
|
212
|
-
|
|
147
|
+
---
|
|
213
148
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
149
|
+
## π Versioning
|
|
150
|
+
|
|
151
|
+
This project follows semantic versioning:
|
|
152
|
+
|
|
153
|
+
* PATCH β bug fixes
|
|
154
|
+
* MINOR β new features
|
|
155
|
+
* MAJOR β breaking changes
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## π€ Contributing
|
|
160
|
+
|
|
161
|
+
Contributions are welcome!
|
|
162
|
+
|
|
163
|
+
If you have ideas for:
|
|
164
|
+
|
|
165
|
+
* New primitives
|
|
166
|
+
* Performance improvements
|
|
167
|
+
* Accessibility enhancements
|
|
168
|
+
|
|
169
|
+
Feel free to open an issue or PR.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## π Roadmap
|
|
174
|
+
|
|
175
|
+
* [ ] Core primitives expansion
|
|
176
|
+
* [ ] Accessibility utilities
|
|
177
|
+
* [ ] CDK integrations
|
|
178
|
+
* [ ] Advanced composition patterns
|
|
179
|
+
* [ ] Documentation site
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## π¨βπ» Author
|
|
184
|
+
|
|
185
|
+
Developed by **Siva Sridhar Natuva**
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## β Support
|
|
190
|
+
|
|
191
|
+
If you find this useful:
|
|
192
|
+
|
|
193
|
+
* Star the repo β
|
|
194
|
+
* Share with Angular community
|
|
195
|
+
* Use it in your projects
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## π Keywords
|
|
200
|
+
|
|
201
|
+
Angular β’ Signals β’ UI Primitives β’ Component Library β’ Standalone Components β’ Design System
|
|
202
|
+
|
|
203
|
+
---
|