@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.
Files changed (2) hide show
  1. package/README.md +132 -145
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,42 +1,50 @@
1
1
  # @snatuva/primitives
2
2
 
3
- Headless, directive-first Angular UI primitives focused on behavior, accessibility,
4
- and composability.
3
+ πŸš€ **Signals-first Angular primitives library** for building scalable, reusable UI components.
5
4
 
6
- This library currently includes:
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
- - Tabs primitives
9
- - Tooltip primitives
7
+ ---
10
8
 
11
- ## Philosophy
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
- ## Exports
15
+ ---
25
16
 
26
- ```ts
27
- import {
28
- TabsDirective,
29
- TabListDirective,
30
- TabTriggerDirective,
31
- TabPanelDirective,
32
- TabContentDirective,
33
- TooltipDirective,
34
- TooltipTriggerDirective,
35
- TooltipContentDirective,
36
- } from '@snatuva/primitives';
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
- ## Tabs
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
- ### Behavior notes
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
- βœ… **Automatic - No manual configuration needed!**
99
+ ## 🧠 Core Concepts
85
100
 
86
- **Built-in ARIA attributes:**
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
- **Built-in keyboard navigation:**
92
- - <kbd>Arrow Right</kbd> / <kbd>Arrow Left</kbd> β€” Switch between tabs
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
- **CSS Styling Example:**
106
+ ### 2. Standalone components
99
107
 
100
- ```css
101
- /* Target active tab */
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
- /* Target disabled tab */
108
- [apTabTrigger][aria-disabled='true'] {
109
- opacity: 0.5;
110
- cursor: not-allowed;
111
- }
111
+ ### 3. Composition over configuration
112
112
 
113
- /* Style tab panels */
114
- [apTabPanel] {
115
- padding: 20px;
116
- }
113
+ * Build your own components using primitives
114
+ * Avoid rigid APIs
117
115
 
118
- /* Hide inactive panels */
119
- [apTabPanel][aria-hidden='true'] {
120
- display: none;
121
- }
122
- ```
116
+ ---
123
117
 
124
- ## Tooltip
118
+ ## β™Ώ Accessibility (A11y)
125
119
 
126
- ### Directives
120
+ This library is designed with accessibility in mind:
127
121
 
128
- - `apTooltip` β€” root tooltip scope/state provider.
129
- - `apTooltipTrigger` β€” element that opens/closes tooltip on pointer/focus interactions.
130
- - `apTooltipContent` β€” template for tooltip content.
122
+ * Semantic HTML by default
123
+ * Keyboard interaction support
124
+ * ARIA best practices
125
+ * Focus management patterns
131
126
 
132
- ### Minimal usage
127
+ ---
133
128
 
134
- ```html
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
- ### Behavior notes
147
-
148
- - Opens on `mouseenter` and `focus`.
149
- - Closes on `mouseleave`, `blur`, or <kbd>Escape</kbd>.
150
-
151
- ### Accessibility (ARIA)
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
- ## Development
139
+ ---
205
140
 
206
- ### Build library
141
+ ## πŸ§ͺ Development
207
142
 
208
143
  ```bash
209
144
  ng build primitives
210
145
  ```
211
146
 
212
- ### Run tests
147
+ ---
213
148
 
214
- ```bash
215
- ng test
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
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snatuva/primitives",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.2",
6
6
  "@angular/core": "^21.0.2",