@eagami/ui 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michal Wiraszka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,388 @@
1
+ # @eagami/ui
2
+
3
+ A lightweight, accessible Angular UI component library built on CSS custom properties. Zero runtime dependencies beyond Angular itself.
4
+
5
+ <p align="center">
6
+ <img src="logo.svg" alt="eagami-ui logo" width="150" />
7
+ </p>
8
+
9
+ ## Why @eagami/ui?
10
+
11
+ | | **@eagami/ui** | Angular Material | PrimeNG | ng-bootstrap | ng-zorro (Ant Design) |
12
+ |---|---|---|---|---|---|
13
+ | Approx. bundle (Button + Input, gzipped)¹ | ~8 KB | ~60 KB | ~35 KB | ~55 KB | ~120 KB |
14
+ | External CSS dependency | ❌ | ❌ | Optional | Bootstrap (~30 KB) | ❌ |
15
+ | CSS custom property theming | ✅ | Partial (MDC) | ✅ | ❌ (Sass vars) | ❌ |
16
+ | Signals-first API | ✅ | Partial | ❌ | ❌ | ❌ |
17
+ | `OnPush` by default | ✅ | Partial | ❌ | ❌ | ❌ |
18
+ | Runtime dependencies | 0 | CDK + animations | PrimeIcons² | Bootstrap CSS | CDK |
19
+
20
+ > ¹ All numbers are approximate and depend on configuration, tree-shaking, and Angular version. Measured with production builds and `@angular/build`.
21
+
22
+ > ² PrimeNG components are tree-shakable but PrimeIcons font (~50 KB) is typically included globally.
23
+
24
+ ## Requirements
25
+
26
+ - Angular 21+
27
+ - A CSS preprocessor that supports SCSS (standard with Angular CLI)
28
+
29
+ ## Installation
30
+
31
+ ```sh
32
+ npm install @eagami/ui
33
+ ```
34
+
35
+ ## Setup
36
+
37
+ ### 1. Import the global stylesheet
38
+
39
+ In `angular.json`:
40
+ ```json
41
+ "styles": ["node_modules/@eagami/ui/src/styles/eagami-ui.scss"]
42
+ ```
43
+
44
+ Or in your root `styles.scss`:
45
+ ```scss
46
+ @use '@eagami/ui/src/styles/eagami-ui';
47
+ ```
48
+
49
+ ### 2. Import components
50
+
51
+ Components are standalone — import only what you use:
52
+
53
+ ```ts
54
+ import { ButtonComponent, InputComponent, CheckboxComponent } from '@eagami/ui';
55
+
56
+ @Component({
57
+ imports: [ButtonComponent, InputComponent, CheckboxComponent],
58
+ ...
59
+ })
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ### Button
65
+
66
+ ```html
67
+ <ea-button variant="primary" (clicked)="onSave($event)">Save</ea-button>
68
+
69
+ <ea-button variant="secondary" size="sm" [disabled]="true">Cancel</ea-button>
70
+
71
+ <ea-button variant="danger" [loading]="isDeleting()">Delete</ea-button>
72
+ ```
73
+
74
+ **Inputs**
75
+
76
+ | Input | Type | Default | Description |
77
+ |---|---|---|---|
78
+ | `variant` | `primary \| secondary \| ghost \| danger` | `primary` | Visual style |
79
+ | `size` | `sm \| md \| lg` | `md` | Button size |
80
+ | `type` | `button \| submit \| reset` | `button` | Native button type |
81
+ | `disabled` | `boolean` | `false` | Disables the button |
82
+ | `loading` | `boolean` | `false` | Shows a spinner, disables interaction |
83
+ | `fullWidth` | `boolean` | `false` | Stretches to fill container |
84
+ | `aria-label` | `string` | — | Accessible label for icon-only buttons |
85
+
86
+ **Outputs**
87
+
88
+ | Output | Type | Description |
89
+ |---|---|---|
90
+ | `clicked` | `MouseEvent` | Emitted on click (not emitted when disabled or loading) |
91
+
92
+ ---
93
+
94
+ ### Input
95
+
96
+ ```html
97
+ <ea-input
98
+ label="Email"
99
+ type="email"
100
+ placeholder="you@example.com"
101
+ [(value)]="email" />
102
+
103
+ <ea-input
104
+ label="Password"
105
+ type="password"
106
+ hint="At least 8 characters"
107
+ [required]="true" />
108
+
109
+ <ea-input
110
+ label="Username"
111
+ error="This username is already taken"
112
+ [(value)]="username" />
113
+ ```
114
+
115
+ Works with Angular reactive forms and template-driven forms via `ControlValueAccessor`:
116
+
117
+ ```ts
118
+ // Reactive
119
+ this.form = this.fb.group({ email: ['', Validators.required] });
120
+ ```
121
+ ```html
122
+ <ea-input label="Email" formControlName="email" />
123
+ ```
124
+
125
+ **Inputs**
126
+
127
+ | Input | Type | Default | Description |
128
+ |---|---|---|---|
129
+ | `label` | `string` | — | Field label |
130
+ | `type` | `text \| email \| password \| number \| search \| tel \| url` | `text` | Input type |
131
+ | `placeholder` | `string` | `''` | Placeholder text |
132
+ | `size` | `sm \| md \| lg` | `md` | Field size |
133
+ | `status` | `default \| error \| success` | `default` | Visual validation state |
134
+ | `hint` | `string` | — | Helper text below the input |
135
+ | `error` | `string` | — | Error message (also sets status to `error`) |
136
+ | `disabled` | `boolean` | `false` | Disables the input |
137
+ | `readonly` | `boolean` | `false` | Makes the input read-only |
138
+ | `required` | `boolean` | `false` | Marks as required |
139
+
140
+ **Two-way binding**
141
+
142
+ | Binding | Type | Description |
143
+ |---|---|---|
144
+ | `[(value)]` | `string` | Two-way signal-based value binding |
145
+
146
+ ---
147
+
148
+ ### Checkbox
149
+
150
+ ```html
151
+ <ea-checkbox label="Accept terms" [(checked)]="accepted" />
152
+
153
+ <ea-checkbox label="Select all" [indeterminate]="true" />
154
+
155
+ <ea-checkbox label="Disabled" [disabled]="true" />
156
+ ```
157
+
158
+ Works with Angular forms via `ControlValueAccessor`.
159
+
160
+ **Inputs**
161
+
162
+ | Input | Type | Default | Description |
163
+ |---|---|---|---|
164
+ | `label` | `string` | — | Checkbox label |
165
+ | `size` | `sm \| md \| lg` | `md` | Checkbox size |
166
+ | `disabled` | `boolean` | `false` | Disables the checkbox |
167
+ | `required` | `boolean` | `false` | Marks as required |
168
+ | `indeterminate` | `boolean` | `false` | Shows indeterminate (minus) state |
169
+
170
+ **Two-way binding**
171
+
172
+ | Binding | Type | Description |
173
+ |---|---|---|
174
+ | `[(checked)]` | `boolean` | Two-way checked state |
175
+
176
+ **Outputs**
177
+
178
+ | Output | Type | Description |
179
+ |---|---|---|
180
+ | `changed` | `boolean` | Emitted when the checked state changes |
181
+
182
+ ---
183
+
184
+ ### Radio
185
+
186
+ Radio buttons are composed of a `ea-radio-group` wrapper and `ea-radio` items:
187
+
188
+ ```html
189
+ <ea-radio-group [(value)]="colour">
190
+ <ea-radio value="red" label="Red" />
191
+ <ea-radio value="green" label="Green" />
192
+ <ea-radio value="blue" label="Blue" />
193
+ </ea-radio-group>
194
+ ```
195
+
196
+ The group implements `ControlValueAccessor` for Angular forms integration.
197
+
198
+ **RadioGroup Inputs**
199
+
200
+ | Input | Type | Default | Description |
201
+ |---|---|---|---|
202
+ | `name` | `string` | auto | Shared name for all radios |
203
+ | `size` | `sm \| md \| lg` | `md` | Size of all radios |
204
+ | `orientation` | `vertical \| horizontal` | `vertical` | Layout direction |
205
+ | `disabled` | `boolean` | `false` | Disables all radios |
206
+
207
+ **RadioGroup Two-way binding**
208
+
209
+ | Binding | Type | Description |
210
+ |---|---|---|
211
+ | `[(value)]` | `string` | Currently selected value |
212
+
213
+ **Radio Inputs**
214
+
215
+ | Input | Type | Default | Description |
216
+ |---|---|---|---|
217
+ | `value` | `string` | *required* | Option value |
218
+ | `label` | `string` | — | Radio label |
219
+ | `disabled` | `boolean` | `false` | Disables this radio |
220
+
221
+ ---
222
+
223
+ ### Card
224
+
225
+ ```html
226
+ <ea-card variant="elevated">
227
+ <span slot="header">Card Title</span>
228
+ Body content goes here.
229
+ <span slot="footer">
230
+ <ea-button size="sm">Action</ea-button>
231
+ </span>
232
+ </ea-card>
233
+ ```
234
+
235
+ **Inputs**
236
+
237
+ | Input | Type | Default | Description |
238
+ |---|---|---|---|
239
+ | `variant` | `elevated \| outlined \| filled` | `elevated` | Visual style |
240
+ | `padding` | `none \| sm \| md \| lg` | `md` | Inner padding |
241
+ | `fullWidth` | `boolean` | `false` | Stretches to fill container |
242
+
243
+ **Content slots**
244
+
245
+ | Slot | Description |
246
+ |---|---|
247
+ | `[slot=header]` | Card header / title area |
248
+ | *(default)* | Card body content |
249
+ | `[slot=footer]` | Card footer / actions area |
250
+
251
+ Header and footer are hidden when empty.
252
+
253
+ ---
254
+
255
+ ### Dropdown
256
+
257
+ ```html
258
+ <ea-dropdown
259
+ label="Country"
260
+ placeholder="Select a country…"
261
+ [options]="countries"
262
+ [(value)]="selectedCountry" />
263
+ ```
264
+
265
+ Options are passed as an array of `{ value, label, disabled? }` objects. Supports keyboard navigation (arrow keys, Enter, Escape). Implements `ControlValueAccessor`.
266
+
267
+ **Inputs**
268
+
269
+ | Input | Type | Default | Description |
270
+ |---|---|---|---|
271
+ | `label` | `string` | — | Field label |
272
+ | `placeholder` | `string` | `'Select…'` | Placeholder text |
273
+ | `options` | `DropdownOption[]` | `[]` | Array of `{ value, label, disabled? }` |
274
+ | `size` | `sm \| md \| lg` | `md` | Trigger size |
275
+ | `disabled` | `boolean` | `false` | Disables the dropdown |
276
+ | `required` | `boolean` | `false` | Marks as required |
277
+ | `hint` | `string` | — | Helper text |
278
+ | `error` | `string` | — | Error message |
279
+
280
+ **Two-way binding**
281
+
282
+ | Binding | Type | Description |
283
+ |---|---|---|
284
+ | `[(value)]` | `string` | Selected option value |
285
+
286
+ **Outputs**
287
+
288
+ | Output | Type | Description |
289
+ |---|---|---|
290
+ | `changed` | `string` | Emitted when selection changes |
291
+
292
+ ---
293
+
294
+ ### Dialog
295
+
296
+ ```html
297
+ <ea-button (clicked)="isOpen = true">Open</ea-button>
298
+
299
+ <ea-dialog [(open)]="isOpen">
300
+ <span slot="header">Confirm Action</span>
301
+ <p>Are you sure you want to proceed?</p>
302
+ <span slot="footer">
303
+ <ea-button variant="secondary" (clicked)="isOpen = false">Cancel</ea-button>
304
+ <ea-button (clicked)="onConfirm()">Confirm</ea-button>
305
+ </span>
306
+ </ea-dialog>
307
+ ```
308
+
309
+ Uses the native `<dialog>` element with `showModal()` for proper focus trapping, backdrop, and accessibility.
310
+
311
+ **Inputs**
312
+
313
+ | Input | Type | Default | Description |
314
+ |---|---|---|---|
315
+ | `size` | `sm \| md \| lg \| full` | `md` | Dialog panel width |
316
+ | `closeOnBackdrop` | `boolean` | `true` | Close on backdrop click |
317
+ | `closeOnEscape` | `boolean` | `true` | Close on Escape key |
318
+ | `showClose` | `boolean` | `true` | Show the close (×) button |
319
+ | `aria-label` | `string` | — | Accessible label for the dialog |
320
+
321
+ **Two-way binding**
322
+
323
+ | Binding | Type | Description |
324
+ |---|---|---|
325
+ | `[(open)]` | `boolean` | Controls dialog visibility |
326
+
327
+ **Outputs**
328
+
329
+ | Output | Type | Description |
330
+ |---|---|---|
331
+ | `opened` | `void` | Emitted when the dialog opens |
332
+ | `closed` | `void` | Emitted when the dialog closes |
333
+
334
+ **Content slots**
335
+
336
+ | Slot | Description |
337
+ |---|---|
338
+ | `[slot=header]` | Dialog title |
339
+ | *(default)* | Dialog body |
340
+ | `[slot=footer]` | Dialog actions |
341
+
342
+ ---
343
+
344
+ ## Theming
345
+
346
+ All components use CSS custom properties. Override them after importing the stylesheet:
347
+
348
+ ```css
349
+ :root {
350
+ /* Brand colour — affects primary buttons, focus rings, etc. */
351
+ --color-brand-default: #7c3aed;
352
+ --color-brand-hover: #6d28d9;
353
+ --color-brand-active: #5b21b6;
354
+ --color-brand-subtle: #f5f3ff;
355
+ --color-brand-muted: #ede9fe;
356
+ }
357
+ ```
358
+
359
+ See [`src/styles/tokens/`](src/styles/tokens/) for the full token reference.
360
+
361
+ ---
362
+
363
+ ## Development
364
+
365
+ ```sh
366
+ # Install dependencies
367
+ pnpm install
368
+
369
+ # Run the sandbox dev app
370
+ pnpm sandbox
371
+
372
+ # Run Storybook (component explorer)
373
+ pnpm storybook
374
+
375
+ # Run tests
376
+ pnpm test
377
+
378
+ # Build the library
379
+ pnpm build
380
+ ```
381
+
382
+ ## Contributing
383
+
384
+ Issues and PRs are welcome. Please open an issue before submitting large changes.
385
+
386
+ ## License
387
+
388
+ MIT