gravitas-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.
@@ -0,0 +1,493 @@
1
+ # Gravitas UI Component Migration Spec For AI Agents
2
+
3
+ This document is intended for an AI agent that is modifying an Angular
4
+ application to replace existing UI controls with Gravitas UI components.
5
+
6
+ Use this as an execution contract, not as general product documentation.
7
+
8
+ ## Objective
9
+
10
+ Replace application-level UI primitives and repeated Bootstrap-based component
11
+ markup with Gravitas UI components, while preserving behavior, forms
12
+ integration, accessibility, and application-specific business logic.
13
+
14
+ The target library is `gravitas-ui`, an Angular standalone component library
15
+ for Bootstrap-based enterprise applications.
16
+
17
+ ## Required Runtime Assumptions
18
+
19
+ Before replacing any components, confirm all of the following:
20
+
21
+ 1. The target application is an Angular application.
22
+ 2. The target application can consume standalone Angular components.
23
+ 3. The target application can install the following packages:
24
+ - `gravitas-ui`
25
+ - `bootstrap`
26
+ 4. The application shell can load global CSS exactly once.
27
+
28
+ If any of these are false, stop and report the constraint instead of applying a
29
+ partial migration.
30
+
31
+ ## Required Package And Global Setup
32
+
33
+ The consumer application must have these runtime dependencies:
34
+
35
+ - `@angular/common`
36
+ - `@angular/core`
37
+ - `@angular/forms`
38
+ - `bootstrap`
39
+ - `gravitas-ui`
40
+
41
+ The application must load these global styles once at the shell level:
42
+
43
+ ```ts
44
+ import 'bootstrap/dist/css/bootstrap.min.css';
45
+ import 'gravitas-ui/styles/gravitas.css';
46
+ ```
47
+
48
+ Optional shell-level theming:
49
+
50
+ ```html
51
+ <html data-gv-theme="light" data-gv-density="comfortable">
52
+ ```
53
+
54
+ Do not migrate components if Gravitas CSS is not loaded globally. Many Gravitas
55
+ components intentionally depend on shared token and theme layers.
56
+
57
+ ## Migration Principles
58
+
59
+ Apply these rules consistently:
60
+
61
+ 1. Replace repeated UI patterns with Gravitas components, not one-off markup.
62
+ 2. Preserve application behavior before optimizing implementation details.
63
+ 3. Preserve bindings, event handlers, validators, and reactive-form wiring.
64
+ 4. Prefer Gravitas component APIs over carrying forward Bootstrap utility markup
65
+ inside component internals.
66
+ 5. Keep layout utilities only when they are application-layout concerns, not
67
+ component concerns.
68
+ 6. Do not rewrite unrelated business logic while migrating markup.
69
+ 7. Do not assume there is a Gravitas replacement for every custom widget.
70
+ 8. Leave unsupported or highly bespoke controls in place and report them.
71
+
72
+ ## Safe Migration Order
73
+
74
+ Migrate in this order to reduce risk:
75
+
76
+ 1. Global setup and imports
77
+ 2. Buttons and icon actions
78
+ 3. Text inputs and textareas
79
+ 4. Selects, checkboxes, radios, and switches
80
+ 5. Alerts, badges, avatars, dividers, loaders, and empty states
81
+ 6. Cards and simple overlays
82
+ 7. Tabs and tables
83
+ 8. Dropdowns and tooltips
84
+ 9. Cleanup of old local component wrappers and dead styles
85
+
86
+ ## Standalone Imports
87
+
88
+ Import only the Gravitas symbols actually used by a given Angular component.
89
+
90
+ Primary exports:
91
+
92
+ - `Button`
93
+ - `IconButton`
94
+ - `InputComponent`
95
+ - `Select`
96
+ - `Textarea`
97
+ - `Checkbox`
98
+ - `Radio`
99
+ - `Switch`
100
+ - `FormField`
101
+ - `Card`
102
+ - `Modal`
103
+ - `Tabs`
104
+ - `TabList`
105
+ - `Tab`
106
+ - `TabPanels`
107
+ - `TabPanel`
108
+ - `Table`
109
+ - `Dropdown`
110
+ - `DropdownTriggerDirective`
111
+ - `DropdownMenuDirective`
112
+ - `Badge`
113
+ - `Alert`
114
+ - `Avatar`
115
+ - `Divider`
116
+ - `Loader`
117
+ - `Skeleton`
118
+ - `Empty`
119
+ - `Toasts`
120
+ - `ToastService`
121
+ - `GvTooltipDirective`
122
+ - `GvTooltipPanelComponent`
123
+
124
+ Example:
125
+
126
+ ```ts
127
+ import { Button, InputComponent, Select } from 'gravitas-ui';
128
+ ```
129
+
130
+ Do not import the entire library into every feature component if only one or
131
+ two components are needed.
132
+
133
+ ## Component Replacement Map
134
+
135
+ Use this mapping as the default replacement strategy.
136
+
137
+ ### Buttons
138
+
139
+ Replace these patterns with `gv-button`:
140
+
141
+ - `<button class="btn ...">`
142
+ - `<a class="btn ...">` used as an action trigger
143
+ - local wrapper components that only normalize button variants
144
+
145
+ Typical migration:
146
+
147
+ ```html
148
+ <button class="btn btn-primary" (click)="save()">Save</button>
149
+ ```
150
+
151
+ to:
152
+
153
+ ```html
154
+ <gv-button variant="primary" (click)="save()">Save</gv-button>
155
+ ```
156
+
157
+ Map semantics carefully:
158
+
159
+ - preserve `type="submit"` on form submit actions
160
+ - preserve `disabled`
161
+ - map loading states to `loading`
162
+ - map full-width button wrappers to `fullWidth`
163
+
164
+ Use `gv-icon-button` for icon-only actions instead of a naked Bootstrap button
165
+ with an icon child.
166
+
167
+ ### Text Inputs
168
+
169
+ Replace standard text-like controls with `gv-input`:
170
+
171
+ - `<input class="form-control">`
172
+ - local text-input wrapper components
173
+ - form fields with helper or error text manually rendered below the input
174
+
175
+ Preserve:
176
+
177
+ - `formControl`, `formControlName`, or `ngModel`
178
+ - `type`
179
+ - `placeholder`
180
+ - `readonly`
181
+ - `required`
182
+ - `disabled`
183
+ - `id`
184
+ - validation messaging
185
+
186
+ Use component inputs instead of separate surrounding markup where possible:
187
+
188
+ - `label`
189
+ - `hint` or `helperText`
190
+ - `error`
191
+
192
+ If the field uses prefix or suffix UI, prefer `gv-input` with the component's
193
+ supported affix pattern rather than recreating `input-group` markup.
194
+
195
+ ### Textareas
196
+
197
+ Replace `<textarea class="form-control">` patterns with `gv-textarea`.
198
+
199
+ Preserve:
200
+
201
+ - `rows`
202
+ - `placeholder`
203
+ - `readonly`
204
+ - `required`
205
+ - `disabled`
206
+ - form bindings
207
+ - character count logic when present
208
+
209
+ Use the Gravitas props for field-level copy:
210
+
211
+ - `label`
212
+ - `description`
213
+ - `helperText`
214
+ - `error`
215
+ - `maxLength`
216
+
217
+ ### Selects
218
+
219
+ Replace native or custom select wrappers with `gv-select` when the behavior is
220
+ within the existing Gravitas component contract.
221
+
222
+ Use `gv-select` for:
223
+
224
+ - simple native selects
225
+ - single-select dropdowns
226
+ - multi-selects already modeled as option arrays
227
+
228
+ Do not force migration if the existing control has advanced async search,
229
+ virtual scrolling, grouped keyboard behavior, or highly custom rendering that
230
+ Gravitas does not currently support.
231
+
232
+ Preserve:
233
+
234
+ - selected value binding
235
+ - option identity
236
+ - placeholder text
237
+ - disabled state
238
+ - validation state
239
+
240
+ ### Checkboxes, Radios, And Switches
241
+
242
+ Replace these with Gravitas field primitives:
243
+
244
+ - `<input type="checkbox">` -> `gv-checkbox`
245
+ - `<input type="radio">` -> `gv-radio`
246
+ - settings toggles -> `gv-switch`
247
+
248
+ Preserve:
249
+
250
+ - form bindings
251
+ - `name`
252
+ - `required`
253
+ - `disabled`
254
+ - helper and error messaging
255
+
256
+ Prefer `gv-switch` only for true binary toggle semantics. Do not replace
257
+ acknowledgement checkboxes with switches.
258
+
259
+ ### Form Shells
260
+
261
+ Use `gv-form-field` only when you need a shared field shell around a control
262
+ that is not already self-rendering.
263
+
264
+ Do not wrap Gravitas self-rendering controls in `gv-form-field` if the control
265
+ already supports:
266
+
267
+ - `label`
268
+ - `description`
269
+ - `helperText`
270
+ - `error`
271
+
272
+ This includes `gv-input`, `gv-select`, `gv-textarea`, `gv-checkbox`,
273
+ `gv-radio`, and `gv-switch`.
274
+
275
+ ### Cards
276
+
277
+ Replace ad hoc card shells or Bootstrap cards with `gv-card` when the card is a
278
+ content container rather than a highly custom page layout region.
279
+
280
+ Use Gravitas card inputs for:
281
+
282
+ - `title`
283
+ - `subtitle`
284
+ - `interactive`
285
+ - `disabled`
286
+ - `fullHeight`
287
+
288
+ Keep application layout wrappers outside the card.
289
+
290
+ ### Alerts
291
+
292
+ Replace inline alert banners with `gv-alert`.
293
+
294
+ Map status tone to `variant`:
295
+
296
+ - success
297
+ - warning
298
+ - danger
299
+ - info
300
+ - neutral if needed
301
+
302
+ Preserve dismiss behavior using the component's `dismissible` input and
303
+ `dismissed` output.
304
+
305
+ ### Badges
306
+
307
+ Replace status pills and counters with `gv-badge`.
308
+
309
+ Use the component API instead of carrying over manual utility classes for:
310
+
311
+ - semantic tone
312
+ - size
313
+ - pill treatment
314
+ - dot treatment
315
+
316
+ ### Tabs
317
+
318
+ Replace ad hoc tab implementations with the Gravitas tab primitives:
319
+
320
+ ```html
321
+ <gv-tabs [(value)]="activeTab">
322
+ <gv-tab-list>
323
+ <gv-tab value="overview">Overview</gv-tab>
324
+ <gv-tab value="activity">Activity</gv-tab>
325
+ </gv-tab-list>
326
+ <gv-tab-panels>
327
+ <gv-tab-panel value="overview">...</gv-tab-panel>
328
+ <gv-tab-panel value="activity">...</gv-tab-panel>
329
+ </gv-tab-panels>
330
+ </gv-tabs>
331
+ ```
332
+
333
+ Use `value` as the canonical selected-tab state. Do not try to preserve custom
334
+ CSS-only tab state hacks.
335
+
336
+ ### Tables
337
+
338
+ Replace repeated admin table wrappers with `gv-table` when the screen fits the
339
+ library's table model: column config, row data, client-side filtering, loading,
340
+ empty state, and pagination.
341
+
342
+ Do not automatically migrate:
343
+
344
+ - deeply custom row templates
345
+ - server-driven virtualized grids
346
+ - tree tables
347
+ - row grouping systems
348
+ - drag-and-drop grid interactions
349
+
350
+ Those require a deliberate design decision.
351
+
352
+ ### Modal
353
+
354
+ Replace simple Bootstrap modal wrappers with `gv-modal` when the interaction is
355
+ a standard dialog flow. Preserve open state, close handlers, focus management
356
+ expectations, and action buttons.
357
+
358
+ Do not auto-migrate complex workflow modals without checking that Gravitas
359
+ supports the required composition.
360
+
361
+ ### Dropdown
362
+
363
+ Use `gv-dropdown` with the Gravitas trigger and menu directives for standard
364
+ action menus.
365
+
366
+ Do not replace feature-rich menu systems blindly if they depend on unsupported
367
+ keyboard or nested-menu behavior.
368
+
369
+ ### Tooltip
370
+
371
+ Replace title-attribute or ad hoc tooltip logic with the Gravitas tooltip
372
+ directive when behavior is simple and local:
373
+
374
+ ```html
375
+ <button [gvTooltip]="'Refresh data'">...</button>
376
+ ```
377
+
378
+ Preserve placement and trigger behavior where supported.
379
+
380
+ ### Empty, Loader, Skeleton, Avatar, Divider, Toasts
381
+
382
+ These should replace repeated presentational patterns when the app currently
383
+ duplicates them:
384
+
385
+ - empty state sections -> `gv-empty`
386
+ - inline or overlay loading indicators -> `gv-loader`
387
+ - placeholder loading blocks -> `gv-skeleton`
388
+ - user initials/photo chips -> `gv-avatar`
389
+ - decorative section separators -> `gv-divider`
390
+ - application toast container and notifications -> `gv-toasts` + `ToastService`
391
+
392
+ ## Form Integration Rules
393
+
394
+ Gravitas field controls are designed to work with Angular forms.
395
+
396
+ When migrating forms:
397
+
398
+ 1. Preserve `formControlName`, `[formControl]`, or `[(ngModel)]`.
399
+ 2. Preserve validators and async validators.
400
+ 3. Preserve touched, dirty, and disabled behavior.
401
+ 4. Move error display into component inputs where possible.
402
+ 5. Do not duplicate error text below a Gravitas control after migration.
403
+
404
+ If an existing wrapper component contains form logic beyond rendering, migrate
405
+ that logic carefully before deleting the wrapper.
406
+
407
+ ## Accessibility Rules
408
+
409
+ During migration, preserve or improve:
410
+
411
+ - explicit labels
412
+ - `id` and `for` relationships
413
+ - disabled semantics
414
+ - button types
415
+ - keyboard focus order
416
+ - aria-labels for icon-only actions
417
+
418
+ If the old implementation relied on placeholder text as a label, convert it to
419
+ a real label during migration where possible.
420
+
421
+ ## Bootstrap Rules
422
+
423
+ Bootstrap is still part of the supported runtime environment.
424
+
425
+ Keep Bootstrap for:
426
+
427
+ - grid and layout utilities
428
+ - spacing utilities at page-layout level
429
+ - app shell structure already built on Bootstrap
430
+
431
+ Remove or reduce Bootstrap when it is being used to fake component styling,
432
+ such as:
433
+
434
+ - `btn`, `btn-*`
435
+ - `form-control`
436
+ - `form-select`
437
+ - `input-group`
438
+ - repeated badge or alert utility combinations
439
+
440
+ The migration target is not "remove Bootstrap". The target is "stop building
441
+ application components out of raw Bootstrap primitives when Gravitas already
442
+ owns that pattern".
443
+
444
+ ## What Not To Auto-Replace
445
+
446
+ Stop and report instead of guessing if you encounter:
447
+
448
+ - third-party data grids
449
+ - date pickers without a Gravitas equivalent
450
+ - autocomplete or typeahead widgets with async behavior
451
+ - rich text editors
452
+ - multi-step workflow modals with embedded routing logic
453
+ - controls with custom keyboard interaction contracts
454
+ - components with strong brand or product-specific rendering requirements
455
+
456
+ Only replace these if the library has an explicit supported equivalent or the
457
+ user asks for a custom migration.
458
+
459
+ ## Refactor Cleanup After Replacement
460
+
461
+ After successful component migration, clean up:
462
+
463
+ - dead local wrapper components
464
+ - obsolete Bootstrap component classes
465
+ - duplicated helper/error markup
466
+ - redundant SCSS written only to restyle Bootstrap controls
467
+ - no-longer-used imports
468
+
469
+ Do not delete application-specific layout or business styling that remains
470
+ relevant.
471
+
472
+ ## Expected Output From The AI Agent
473
+
474
+ When completing a migration, report:
475
+
476
+ 1. Which screens or components were migrated
477
+ 2. Which Gravitas components were introduced
478
+ 3. Which legacy wrappers or styles were removed
479
+ 4. Which controls were intentionally left unmigrated
480
+ 5. Any required follow-up work, especially unsupported widgets
481
+
482
+ ## Minimal Success Criteria
483
+
484
+ A migration is considered successful only if:
485
+
486
+ 1. The application still builds
487
+ 2. Forms still work
488
+ 3. Existing user flows still work
489
+ 4. Gravitas global CSS is loaded correctly
490
+ 5. Replaced components use Gravitas imports and APIs directly
491
+ 6. Old Bootstrap component styling markup has been materially reduced
492
+
493
+ If these criteria are not met, do not present the migration as complete.