@trinityui/design-system 2.1.2 → 2.1.4

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 CHANGED
@@ -1,26 +1,97 @@
1
1
  # Trinity Design System
2
2
 
3
- Trinity Design System is an enterprise component platform built on MUI for [Trinity LifeSciences](https://trinitylifesciences.com).
3
+ Enterprise component platform built on **MUI v7** for [Trinity LifeSciences](https://trinitylifesciences.com). Provides 100+ accessible React components, a 3-tier design token system, 35+ AI-specific components, 17 chart types, 18 custom hooks, and a CSS-only package for non-React consumers.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@trinityui/design-system.svg)](https://www.npmjs.com/package/@trinityui/design-system)
6
6
  [![npm css package](https://img.shields.io/npm/v/@trinityui/design-system-css.svg)](https://www.npmjs.com/package/@trinityui/design-system-css)
7
7
  [![license](https://img.shields.io/npm/l/@trinityui/design-system.svg)](./LICENSE)
8
8
 
9
- It provides:
10
- - A React component library: `@trinityui/design-system`
11
- - A CSS-only package for non-React apps: `@trinityui/design-system-css`
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ - [Key Capabilities](#key-capabilities)
14
+ - [Architecture](#architecture)
15
+ - [Packages & Entry Points](#packages--entry-points)
16
+ - [Installation](#installation)
17
+ - [Quick Start](#quick-start)
18
+ - [Component Catalog](#component-catalog)
19
+ - [Navigation](#navigation-6-components)
20
+ - [Layout](#layout-7-components)
21
+ - [AI](#ai-35-components)
22
+ - [Data Display](#data-display-8-components)
23
+ - [Input & Forms](#input--forms-18-components)
24
+ - [Feedback](#feedback-7-components)
25
+ - [Charts](#charts-17-components)
26
+ - [Icon System](#icon-system)
27
+ - [Hooks](#hooks-18)
28
+ - [Accessibility](#accessibility)
29
+ - [Design Tokens](#design-tokens)
30
+ - [Theme Presets](#theme-presets)
31
+ - [CSS-Only Usage](#css-only-usage)
32
+ - [Storybook](#storybook)
33
+ - [Development](#development)
34
+ - [Documentation](#documentation)
35
+ - [License](#license)
36
+
37
+ ---
38
+
39
+ ## Key Capabilities
40
+
41
+ | Capability | Details |
42
+ |---|---|
43
+ | **100+ Components** | Navigation, layout, AI, data display, inputs, feedback, charts |
44
+ | **35+ AI Components** | InsightEngine, ChatThread, ChainOfThought, voice input, explainability, sources, personas |
45
+ | **17 Chart Types** | Line, bar, area, pie, donut, scatter, bubble, radial, gauge, composed, sparkline |
46
+ | **3-Tier Design Tokens** | Base → Semantic → Component tokens with CSS variable output |
47
+ | **Dark Mode** | Automatic light/dark themes with WCAG 2.1 AA color contrast |
48
+ | **3 Theme Presets** | CRM (compact), Portal (accessible), Analytics (data-viz) |
49
+ | **18 Custom Hooks** | Debounce, clipboard, breakpoints, focus trap, roving tabindex, and more |
50
+ | **TypeScript-First** | 200+ exports with full type definitions |
51
+ | **CSS-Only Package** | Angular, Vue, and static HTML support via CSS variables |
52
+ | **80+ Brand Assets** | Gradient icons, background images, logos |
53
+ | **Bundle Governance** | Size-limit enforced: core ≤50KB, main ≤200KB |
54
+ | **Accessibility** | axe-core testing, eslint-plugin-jsx-a11y, ARIA hooks, skip links, focus traps |
55
+
56
+ ---
12
57
 
13
58
  ## Architecture
14
59
 
15
- `Design Tokens` -> `Theme Layer` -> `React Components (@trinityui/design-system)` -> `React Consumer Apps`
16
- `Design Tokens` -> `CSS Variables Build` -> `CSS Package (@trinityui/design-system-css)` -> `Angular / Vue / Static Apps`
60
+ ```
61
+ ┌─────────────────────────────────────────────────────────────┐
62
+ │ Design Tokens (tokens.ts) │
63
+ │ Base → Semantic → Component (2,700 lines) │
64
+ └──────────────┬──────────────────────────┬────────────────────┘
65
+ │ │
66
+ ▼ ▼
67
+ ┌──────────────────────────┐ ┌─────────────────────────────────┐
68
+ │ MUI Theme Layer │ │ CSS Variables Build │
69
+ │ lightTheme / darkTheme │ │ generate-css-from-tokens.ts │
70
+ │ + 3 preset themes │ │ trinity.css / trinity-base.css │
71
+ └──────────┬───────────────┘ └──────────┬──────────────────────┘
72
+ │ │
73
+ ▼ ▼
74
+ ┌──────────────────────────┐ ┌─────────────────────────────────┐
75
+ │ @trinityui/design-system │ │ @trinityui/design-system-css │
76
+ │ React + MUI Components │ │ Angular / Vue / Static HTML │
77
+ └──────────────────────────┘ └─────────────────────────────────┘
78
+ ```
17
79
 
18
- ## Packages
80
+ ---
19
81
 
20
- | Package | Use Case |
21
- |---|---|
22
- | `@trinityui/design-system` | React + MUI applications |
23
- | `@trinityui/design-system-css` | Angular, Vue, static HTML, or any CSS-only integration |
82
+ ## Packages & Entry Points
83
+
84
+ | Package / Import | Exports | Use Case |
85
+ |---|---|---|
86
+ | `@trinityui/design-system` | 200+ | Full API — all components, hooks, tokens, utilities |
87
+ | `@trinityui/design-system/essentials` | 16 | Quick-start — theme + core components |
88
+ | `@trinityui/design-system/theme` | ~10 | Theme utilities only (tree-shakeable) |
89
+ | `@trinityui/design-system/tokens` | ~30 | Design tokens only (tree-shakeable) |
90
+ | `@trinityui/design-system/data-table` | 3 | DataTable + AG Grid Enterprise license setup |
91
+ | `@trinityui/design-system/css` | — | CSS file from the React package |
92
+ | `@trinityui/design-system-css` | — | Standalone CSS-only package for non-React apps |
93
+
94
+ ---
24
95
 
25
96
  ## Installation
26
97
 
@@ -30,7 +101,12 @@ It provides:
30
101
  pnpm add @trinityui/design-system react react-dom @mui/material @mui/icons-material @emotion/react @emotion/styled
31
102
  ```
32
103
 
33
- > Commercial licensing: For MUI, AG Grid, or Syncfusion license procurement/renewal, contact Arun Manoharan, Rahul Desai, or Sangeetha before production use.
104
+ **Optional dependencies** (install only if using these features):
105
+
106
+ ```bash
107
+ pnpm add recharts # Charts
108
+ pnpm add @mui/x-date-pickers dayjs # DatePicker
109
+ ```
34
110
 
35
111
  ### CSS-only package
36
112
 
@@ -38,7 +114,13 @@ pnpm add @trinityui/design-system react react-dom @mui/material @mui/icons-mater
38
114
  pnpm add @trinityui/design-system-css
39
115
  ```
40
116
 
41
- ## React Quick Start
117
+ > **Commercial licensing:** For MUI, AG Grid, or Syncfusion license procurement/renewal, contact Arun Manoharan, Rahul Desai, or Sangeetha before production use.
118
+
119
+ ---
120
+
121
+ ## Quick Start
122
+
123
+ ### 1. Wrap your app with the theme
42
124
 
43
125
  ```tsx
44
126
  import { ThemeProvider, CssBaseline } from '@mui/material';
@@ -54,206 +136,480 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
54
136
  }
55
137
  ```
56
138
 
57
- ## Import Strategy
139
+ ### 2. Import strategy
58
140
 
59
- Use MUI for standard UI primitives, and Trinity for domain-specific components and tokens.
141
+ Use **MUI** for standard UI primitives. Use **Trinity** for domain-specific components, tokens, and hooks.
60
142
 
61
143
  ```tsx
144
+ // MUI primitives
62
145
  import { Button, Card, TextField } from '@mui/material';
146
+
147
+ // Trinity components
63
148
  import { StatusIndicator, Toast, useToast } from '@trinityui/design-system';
64
149
  ```
65
150
 
66
- ## Async Autocomplete
151
+ ### 3. Dark mode
152
+
153
+ ```tsx
154
+ import { lightTheme, darkTheme } from '@trinityui/design-system';
155
+
156
+ <ThemeProvider theme={isDarkMode ? darkTheme : lightTheme}>
157
+ <CssBaseline />
158
+ <App />
159
+ </ThemeProvider>
160
+ ```
161
+
162
+ For the full getting-started guide, see [docs/QUICK_START.md](./docs/QUICK_START.md).
163
+
164
+ ---
165
+
166
+ ## Component Catalog
167
+
168
+ ### Navigation (6 components)
169
+
170
+ | Component | Import | Description |
171
+ |---|---|---|
172
+ | `TopNavHeader` | `@trinityui/design-system` | Primary navigation header with search, client switcher, and user menu |
173
+ | `TopNavWithSidebar` | `@trinityui/design-system` | Full layout with collapsible sidebar navigation |
174
+ | `Footer` | `@trinityui/design-system` | Page footer — light and dark variants, compact 40px height |
175
+ | `SearchBar` | `@trinityui/design-system` | Header search bar primitive with suggestion support |
176
+ | `ClientMenu` | `@trinityui/design-system` | Client/tenant switcher dropdown |
177
+ | `AppsMenu` | `@trinityui/design-system` | Application launcher grid menu |
178
+
179
+ Also exports: `TrinityLogo`, `UserMenu`, `HeaderActions`, and 14 navigation type definitions.
180
+
181
+ ---
182
+
183
+ ### Layout (7 components)
184
+
185
+ | Component | Import | Description |
186
+ |---|---|---|
187
+ | `AppLayout` | `@trinityui/design-system` | Primary app shell — nav + content + optional AI panel |
188
+ | `PageHeader` | `@trinityui/design-system` | Page header with breadcrumbs, title, and actions |
189
+ | `SplitPane` | `@trinityui/design-system` | Resizable split view (horizontal/vertical) |
190
+ | `DockLayout` | `@trinityui/design-system` | Dockable panel layout with configurable zones |
191
+ | `ResizablePanel` | `@trinityui/design-system` | Standalone resizable side panel |
192
+ | `InsightEnginePanel` | `@trinityui/design-system` | AI insight panel designed for AppLayout integration |
193
+ | `LandingPage` | `@trinityui/design-system` | Pre-built landing page template |
67
194
 
68
- `Autocomplete` supports asynchronous loading from either a callback (`dataSource`) or a URL (`url`), including infinite pagination on scroll.
195
+ Also exports: 3 page templates (`DashboardTemplate`, `ListDetailTemplate`, `SettingsTemplate`).
69
196
 
70
- ### Data source mode
197
+ ---
198
+
199
+ ### AI (35+ components)
200
+
201
+ The largest component category — a full suite for building AI-powered experiences.
202
+
203
+ #### AI Containers & Orchestration
204
+
205
+ | Component | Description |
206
+ |---|---|
207
+ | `InsightEngine` | Top-level AI experience orchestrator |
208
+ | `ChatThread` | Scrollable conversation thread with message grouping |
209
+ | `ChatHeader` | Chat view header with mode switching |
210
+ | `ChatHistoryList` | Navigable list of past conversations |
211
+
212
+ #### AI Input
213
+
214
+ | Component | Description |
215
+ |---|---|
216
+ | `InsightEngineInput` | Primary AI query input with context awareness |
217
+ | `AIVoiceOverlay` | Voice input overlay with transcription |
218
+ | `AIListeningIndicator` | Animated listening state indicator |
219
+ | `PredictiveTextInput` | AI-powered autocomplete text input (OpenAI-compatible) |
220
+ | `AIChatInput` | Lightweight chat input primitive |
221
+ | `AIQuickReply` | Quick-reply suggestion chips |
222
+
223
+ #### AI Rendering & Explainability
224
+
225
+ | Component | Description |
226
+ |---|---|
227
+ | `AIResponseRenderer` | Renders structured AI responses (text, tables, charts, actions) |
228
+ | `AITextBlock` | Styled text block for AI output with streaming support |
229
+ | `AIChainOfThought` | Multi-phase reasoning visualization (understand → plan → execute → output) |
230
+ | `AIExplainability` | Confidence scores and explainability panel |
231
+ | `AISource` / `AISourcesSection` / `AISourcesPanel` | Source citations — individual, grouped, and full panel views |
232
+ | `AIRelatedQuestions` | Suggested follow-up questions |
233
+
234
+ #### AI Messages & Avatars
235
+
236
+ | Component | Description |
237
+ |---|---|
238
+ | `AIMessage` | AI-authored message bubble with actions |
239
+ | `UserMessage` | User-authored message bubble |
240
+ | `AIChatMessage` | Lightweight chat message primitive |
241
+ | `AIAvatar` | AI bot avatar (animated) |
242
+ | `UserAvatar` | User avatar for chat contexts |
243
+ | `AILabel` | "AI-generated" badge/label (multiple sizes and variants) |
244
+
245
+ #### AI Actions & Layout
246
+
247
+ | Component | Description |
248
+ |---|---|
249
+ | `AISuggestedAction` / `AICircularAction` / `AIActionsGroup` | AI-suggested action buttons and groups |
250
+ | `AIContainer` | Themed container for AI content |
251
+ | `AIExpandableSection` | Collapsible section for AI detail panels |
252
+ | `AIPersonaCard` | AI persona/agent identity card |
253
+ | `GradientText` / `GradientIconBadge` | Visual flourishes for AI UI |
254
+ | `StatCard` | KPI stat card for AI dashboards |
255
+ | `AIShimmer` | Shimmer loading state for AI content |
256
+ | `AITypingIndicator` | Animated typing indicator |
257
+
258
+ All AI components import from `@trinityui/design-system`. AI-specific design tokens available via `aiTokens`.
259
+
260
+ ---
261
+
262
+ ### Data Display (8 components)
263
+
264
+ | Component | Import | Description |
265
+ |---|---|---|
266
+ | `DataTable` | `@trinityui/design-system/data-table` | AG Grid Enterprise powered — sorting, filtering, grouping, pivot, server-side row models |
267
+ | `SimpleTable` | `@trinityui/design-system` | Lightweight table for simple data (no AG Grid dependency) |
268
+ | `DataCard` | `@trinityui/design-system` | KPI/metric card with trend indicator and sparkline |
269
+ | `DiffViewer` | `@trinityui/design-system` | Side-by-side or unified diff viewer |
270
+ | `Timeline` | `@trinityui/design-system` | Vertical timeline with status indicators |
271
+ | `TreeView` | `@trinityui/design-system` | Hierarchical tree view with expansion and selection |
272
+ | `TransferList` | `@trinityui/design-system` | Dual-list transfer component with search and bulk actions |
273
+ | `StatusIndicator` / `StatusLegend` | `@trinityui/design-system` | Unified status display (success/warning/error/info) + legend |
274
+
275
+ **DataTable setup:**
71
276
 
72
277
  ```tsx
73
- import { Autocomplete, type AutocompleteAsyncRequest } from '@trinityui/design-system';
278
+ import { DataTable, setAgGridEnterpriseLicenseKey } from '@trinityui/design-system/data-table';
279
+
280
+ // Set license key once at app bootstrap
281
+ setAgGridEnterpriseLicenseKey('<YOUR_KEY>');
282
+ ```
283
+
284
+ ---
285
+
286
+ ### Input & Forms (18+ components)
287
+
288
+ | Component | Import | Description |
289
+ |---|---|---|
290
+ | `Autocomplete` | `@trinityui/design-system` | Full-featured autocomplete — async loading, pagination, sortable chips, virtualization |
291
+ | `VirtualizedAutocomplete` | `@trinityui/design-system` | Virtualized variant for large option lists |
292
+ | `Combobox` | `@trinityui/design-system` | Accessible combobox with keyboard navigation |
293
+ | `SearchInput` | `@trinityui/design-system` | Standalone search input with suggestion dropdown |
294
+ | `ClearableTextField` | `@trinityui/design-system` | Text field with integrated clear button |
295
+ | `ChipsInput` | `@trinityui/design-system` | Tag/chip entry input with validation |
296
+ | `MentionsInput` | `@trinityui/design-system` | @mention-enabled text input |
297
+ | `FileUpload` / `UploadDropZone` | `@trinityui/design-system` | Drag-and-drop file upload with progress |
298
+ | `RichTextEditor` | `@trinityui/design-system` | WYSIWYG rich text editor (Syncfusion) |
299
+ | `CommandPalette` | `@trinityui/design-system` | Cmd+K style command palette with fuzzy search |
300
+ | `FilterBar` | `@trinityui/design-system` | Multi-filter toolbar with presets and saved filters |
301
+ | `NestedMenu` | `@trinityui/design-system` | Multi-level nested menu |
302
+ | `Cron` | `@trinityui/design-system` | Visual cron expression builder |
303
+ | `Carousel` | `@trinityui/design-system` | Content carousel with transition effects |
304
+ | `Popper` | `@trinityui/design-system` | Positioning utility component |
305
+
306
+ #### Form Utilities
307
+
308
+ ```tsx
309
+ import { FormProvider, useForm, useFormField } from '@trinityui/design-system';
310
+
311
+ // Built-in validators
312
+ import { required, email, minLength, maxLength, pattern, min, max, custom } from '@trinityui/design-system';
313
+ ```
314
+
315
+ `FormProvider` gives you form state management with composable validation — no additional form library required.
316
+
317
+ #### Async Autocomplete Example
74
318
 
75
- type UserOption = { id: string; name: string; email: string };
319
+ ```tsx
320
+ import { Autocomplete, type AutocompleteAsyncRequest } from '@trinityui/design-system';
76
321
 
77
322
  const loadUsers = async ({ search, page, pageSize, signal }: AutocompleteAsyncRequest) => {
78
- const response = await fetch(`/api/users?q=${encodeURIComponent(search)}&page=${page}&pageSize=${pageSize}`, { signal });
79
- const data = await response.json();
80
- return {
81
- options: data.items as UserOption[],
82
- hasMore: data.hasMore as boolean,
83
- nextPage: page + 1,
84
- };
323
+ const res = await fetch(`/api/users?q=${encodeURIComponent(search)}&page=${page}&pageSize=${pageSize}`, { signal });
324
+ const data = await res.json();
325
+ return { options: data.items, hasMore: data.hasMore, nextPage: page + 1 };
85
326
  };
86
327
 
87
- <Autocomplete<UserOption, true, false, false>
328
+ <Autocomplete
88
329
  name="users"
89
330
  label="Users"
90
331
  options={[]}
91
332
  multiple
92
333
  value={[]}
93
- onHandleChange={(next) => setUsers(next as UserOption[])}
334
+ onHandleChange={(next) => setUsers(next)}
94
335
  labelProperty="name"
95
336
  valueProperty="id"
96
- optionValues={['name', 'email']}
97
- async={{
98
- dataSource: loadUsers,
99
- paginate: true,
100
- pageSize: 25,
101
- debounceMs: 250,
102
- minSearchLength: 1,
103
- }}
104
- />;
337
+ async={{ dataSource: loadUsers, paginate: true, pageSize: 25, debounceMs: 250 }}
338
+ />
105
339
  ```
106
340
 
107
- ## Sortable Multi-Select Autocomplete
108
-
109
- Enable `sortableSelected` to reorder selected chips.
110
- - Mouse: drag and drop chips.
111
- - Keyboard: `Ctrl/Cmd + Shift + Arrow` keys on a selected chip.
341
+ #### Predictive Text Input (OpenAI via Azure Function)
112
342
 
113
343
  ```tsx
114
- <Autocomplete<string, true, false, false>
115
- name="focus-areas"
116
- label="Focus Areas"
117
- options={['Oncology', 'Safety', 'AI', 'Regulatory']}
118
- multiple
119
- value={selected}
120
- onHandleChange={(next) => setSelected(next as string[])}
121
- sortableSelected
122
- virtualized={false}
123
- />;
344
+ import { PredictiveTextInput, createOpenAIPredictor } from '@trinityui/design-system';
345
+
346
+ const predictor = createOpenAIPredictor({ endpoint: '/api/predictive-text', maxSuggestions: 5 });
347
+
348
+ <PredictiveTextInput label="Prompt" value={value} onChange={setValue} onPredict={predictor} />
124
349
  ```
125
350
 
126
- ## Predictive Text Input (OpenAI via Azure Function)
351
+ See the [Azure Function template](./examples/azure-functions/predictive-text/) for the backend.
127
352
 
128
- Use `PredictiveTextInput` with `createOpenAIPredictor` and point it to your backend endpoint (for example, an Azure Function at `/api/predictive-text`).
353
+ ---
354
+
355
+ ### Feedback (7 components)
356
+
357
+ | Component | Import | Description |
358
+ |---|---|---|
359
+ | `Modal` | `@trinityui/design-system` | Modal dialog with size variants and accessible focus management |
360
+ | `ConfirmDialog` | `@trinityui/design-system` | Confirm/cancel dialog (also available via `useConfirmDialog` hook) |
361
+ | `ToastProvider` / `Toast` | `@trinityui/design-system` | Toast notification system (wrap app in `ToastProvider`, trigger via `useToast`) |
362
+ | `IllustratedMessage` | `@trinityui/design-system` | Empty state / error illustrated message |
363
+ | `Tour` | `@trinityui/design-system` | Guided product tour with step-by-step highlights |
364
+ | `GoToTop` | `@trinityui/design-system` | Scroll-to-top floating button |
365
+
366
+ ---
367
+
368
+ ### Charts (17 components)
369
+
370
+ All charts are Recharts-based with Trinity theming applied automatically.
371
+
372
+ | Component | Description |
373
+ |---|---|
374
+ | `LineChart` | Line/time-series chart |
375
+ | `BarChart` | Vertical/horizontal bar chart |
376
+ | `AreaChart` | Filled area chart |
377
+ | `PieChart` | Pie chart |
378
+ | `DonutChart` | Donut variant |
379
+ | `ScatterChart` | Scatter plot |
380
+ | `BubbleChart` | Bubble chart |
381
+ | `RadialBarChart` | Radial/polar bar chart |
382
+ | `GaugeChart` | Gauge/meter chart |
383
+ | `ComposedChart` | Mixed line + bar + area chart |
384
+ | `Sparkline` | Inline mini chart for data cards |
385
+ | `ChartWrapper` | Chart container with consistent sizing |
386
+ | `CustomTooltip` / `SimpleTooltip` | Chart tooltip components |
387
+ | `CustomLegend` / `InteractiveLegend` / `PieLegend` | Chart legend components |
388
+
389
+ All import from `@trinityui/design-system`. Full type definitions for `DataPoint`, `SeriesConfig`, `AxisConfig`, and chart-specific props.
390
+
391
+ ---
392
+
393
+ ### Icon System
129
394
 
130
395
  ```tsx
131
- import { PredictiveTextInput, createOpenAIPredictor } from '@trinityui/design-system';
396
+ import { Icon, IconProvider } from '@trinityui/design-system';
132
397
 
133
- const predictor = createOpenAIPredictor({
134
- endpoint: '/api/predictive-text',
135
- maxSuggestions: 5,
136
- });
137
-
138
- <PredictiveTextInput
139
- label="Prompt"
140
- value={value}
141
- onChange={setValue}
142
- onPredict={predictor}
143
- />;
398
+ // Wrap with IconProvider to set the active icon library
399
+ <IconProvider library="feather">
400
+ <Icon name="check" size="md" />
401
+ </IconProvider>
144
402
  ```
145
403
 
146
- Azure Function template:
147
- - [`examples/azure-functions/predictive-text/index.ts`](./examples/azure-functions/predictive-text/index.ts)
148
- - [`examples/azure-functions/predictive-text/README.md`](./examples/azure-functions/predictive-text/README.md)
404
+ Supports multiple icon libraries via `IconProvider`. Six intent-based sizes: `inline` (14px), `xs` (16px), `sm` (18px), `md` (20px), `lg` (24px), `display` (36px).
405
+
406
+ ---
149
407
 
150
- ### URL mode
408
+ ## Hooks (18)
409
+
410
+ All hooks import from `@trinityui/design-system`.
411
+
412
+ | Hook | Description |
413
+ |---|---|
414
+ | `useDebounce` | Debounce a value by delay |
415
+ | `useDebouncedCallback` | Returns a debounced callback function |
416
+ | `useClipboard` | Copy text to clipboard with success feedback |
417
+ | `useLocalStorage` | Persist state to `localStorage` with SSR safety |
418
+ | `useTrinityBreakpoints` | Responsive flags: `isMobile`, `isTablet`, `isDesktop`, `isLargeDesktop` |
419
+ | `useToggle` | Boolean toggle: `[value, toggle, setValue]` |
420
+ | `usePrevious` | Access the previous render's value |
421
+ | `useOnClickOutside` | Detect clicks outside a ref element |
422
+ | `useKeyPress` | Detect a specific key press |
423
+ | `useInterval` | Declarative `setInterval` with cleanup |
424
+ | `useFocusTrap` | Trap keyboard focus within a container (accessibility) |
425
+ | `useReducedMotion` | Detect `prefers-reduced-motion` user preference |
426
+ | `useAriaLive` | Manage ARIA live region announcements for screen readers |
427
+ | `useRovingTabIndex` | Arrow-key navigation for composite widgets |
428
+ | `useConfirmDialog` | Imperatively open confirmation dialogs |
429
+ | `useToast` | Show toast notifications (requires `ToastProvider`) |
430
+ | `useTrinityPalette` | Access Trinity semantic palette from the current theme |
431
+ | `useFlowAutoLayout` | Auto-layout for React Flow / XYFlow diagrams |
432
+
433
+ ---
434
+
435
+ ## Accessibility
436
+
437
+ Trinity targets **WCAG 2.1 AA** compliance. The system provides:
438
+
439
+ | Feature | Details |
440
+ |---|---|
441
+ | **Automated testing** | `vitest-axe` (axe-core) a11y tests, dedicated `test:a11y` script |
442
+ | **Linting** | `eslint-plugin-jsx-a11y` enforced across all components |
443
+ | **Storybook addon** | `@storybook/addon-a11y` for interactive accessibility auditing |
444
+ | **ARIA hooks** | `useFocusTrap`, `useAriaLive`, `useRovingTabIndex`, `useReducedMotion` |
445
+ | **Skip links** | `SkipLink` component for keyboard-first navigation |
446
+ | **Accessible colors** | `accessibleCombinations` — pre-validated WCAG AA text/background pairs |
447
+ | **Contrast utilities** | `getContrastRatio()`, `validateAccessibility()`, `meetsWCAG()` |
448
+ | **Visual hiding** | `VisuallyHidden` component for screen-reader-only content |
151
449
 
152
450
  ```tsx
153
- <Autocomplete<UserOption, true, false, false>
154
- name="users-url"
155
- label="Users"
156
- options={[]}
157
- multiple
158
- value={[]}
159
- onHandleChange={(next) => setUsers(next as UserOption[])}
160
- labelProperty="name"
161
- valueProperty="id"
162
- async={{
163
- url: '/api/users/search',
164
- method: 'GET',
165
- queryParam: 'q',
166
- pageParam: 'page',
167
- pageSizeParam: 'pageSize',
168
- paginate: true,
169
- mapResponse: (response) => {
170
- const data = response as { results: UserOption[]; hasMore: boolean };
171
- return { options: data.results, hasMore: data.hasMore };
172
- },
173
- }}
174
- />;
451
+ import { accessibleCombinations } from '@trinityui/design-system';
452
+
453
+ // Pre-validated WCAG AA pairs
454
+ <Box sx={{
455
+ backgroundColor: accessibleCombinations.whiteOnNavy.bg,
456
+ color: accessibleCombinations.whiteOnNavy.text,
457
+ }}>
458
+ Guaranteed 4.5:1+ contrast ratio
459
+ </Box>
175
460
  ```
176
461
 
177
- ## Entry Points
462
+ For the full accessibility guide and component checklist, see [docs/ACCESSIBILITY.md](./docs/ACCESSIBILITY.md) and [docs/COMPONENT_A11Y_CHECKLIST.md](./docs/COMPONENT_A11Y_CHECKLIST.md).
178
463
 
179
- | Import | Purpose |
180
- |---|---|
181
- | `@trinityui/design-system` | Full API |
182
- | `@trinityui/design-system/essentials` | Lean entry for common setup and core components |
183
- | `@trinityui/design-system/theme` | Theme-only exports |
184
- | `@trinityui/design-system/tokens` | Token-only exports |
185
- | `@trinityui/design-system/data-table` | DataTable exports (AG Grid powered) |
186
- | `@trinityui/design-system/css` | CSS file from the React package |
464
+ ---
187
465
 
188
- ## DataTable Entry
466
+ ## Design Tokens
189
467
 
190
- `DataTable` is intentionally isolated behind a subpath:
468
+ Trinity uses a **3-tier token architecture** (2,700+ lines) spanning colors, spacing, typography, shadows, motion, z-index, border radius, opacity, breakpoints, and effects.
469
+
470
+ ### Token Tiers
471
+
472
+ | Tier | Purpose | Example |
473
+ |---|---|---|
474
+ | **Base** | Raw primitive values | `baseTokens.colors.navy[900]` → `#050742` |
475
+ | **Semantic** | Contextual meaning | `semanticTokens.colors.interactive.primary` |
476
+ | **Component** | Component-level defaults | `componentTokens.card.borderRadius` → `12px` |
477
+
478
+ ### Token Coverage
479
+
480
+ | Category | What's included |
481
+ |---|---|
482
+ | **Colors** | 6 brand palettes (navy, purple, indigo, coral, azure, gray) with full shade ranges |
483
+ | **Semantic colors** | Brand, text (11 variants), background (8), surface (7), border (6), interactive (5), status (4 × 3) |
484
+ | **Spacing** | 20-step scale (0–32), component spacing, layout spacing with dimensions, density scale |
485
+ | **Typography** | 10 sizes, 6 weights, 6 line heights, 6 letter spacings, semantic scales (display/heading/body/label) |
486
+ | **Border radius** | 9-step scale (none → 9999px), semantic radius (button, input, card, modal, badge, avatar, chip, tooltip) |
487
+ | **Shadows** | 8 levels + semantic (card, dropdown, modal, button, input), effect-based (surface, dialog, inset) |
488
+ | **Motion** | 7 durations (fastest → slowest) + 7 easings (linear, bounce, elastic, etc.) |
489
+ | **Z-index** | 7 numeric levels + 7 semantic (dropdown, sticky, modal, tooltip) |
490
+ | **Effects** | Overlay, onDark states, focus rings, status indicators |
491
+
492
+ ### Usage
191
493
 
192
494
  ```tsx
193
- import { DataTable } from '@trinityui/design-system/data-table';
495
+ import { baseTokens, semanticTokens, componentTokens } from '@trinityui/design-system/tokens';
496
+ ```
497
+
498
+ All tokens are also available as CSS variables:
499
+
500
+ ```css
501
+ var(--trinity-color-navy-900) /* base */
502
+ var(--trinity-card-bg) /* semantic */
503
+ var(--trinity-switch-track-height) /* component */
194
504
  ```
195
505
 
196
- Set your AG Grid Enterprise license key once during app bootstrap:
506
+ For token usage rules, see [docs/TOKEN_USAGE_RULES.md](./docs/TOKEN_USAGE_RULES.md).
507
+
508
+ ---
509
+
510
+ ## Theme Presets
511
+
512
+ Three pre-configured theme presets for different product contexts:
513
+
514
+ | Preset | Light / Dark | Use Case |
515
+ |---|---|---|
516
+ | **CRM** | `crmLightTheme` / `crmDarkTheme` | Compact tables, dense forms, high information density |
517
+ | **Portal** | `portalLightTheme` / `portalDarkTheme` | Large touch targets, accessible sizing, customer-facing |
518
+ | **Analytics** | `analyticsLightTheme` / `analyticsDarkTheme` | Data visualization optimized, chart-friendly palette |
197
519
 
198
520
  ```tsx
199
- import { setAgGridEnterpriseLicenseKey } from '@trinityui/design-system/data-table';
521
+ import { crmLightTheme, crmDarkTheme } from '@trinityui/design-system';
200
522
 
201
- setAgGridEnterpriseLicenseKey('<AG_GRID_ENTERPRISE_LICENSE_KEY>');
523
+ <ThemeProvider theme={isDarkMode ? crmDarkTheme : crmLightTheme}>
524
+ <App />
525
+ </ThemeProvider>
202
526
  ```
203
527
 
204
- For AG Grid Enterprise licensing, coordinate with Arun Manoharan, Rahul Desai, or Sangeetha.
528
+ You can also create custom presets with `createTrinityThemePreset()`.
529
+
530
+ ---
205
531
 
206
532
  ## CSS-Only Usage
207
533
 
208
- ### Option 1: package CSS import
534
+ For Angular, Vue, or static HTML projects:
209
535
 
210
536
  ```css
537
+ /* Option 1: package import */
211
538
  @import '@trinityui/design-system-css';
212
- ```
213
-
214
- ### Option 2: direct file path
215
539
 
216
- ```html
217
- <link rel="stylesheet" href="node_modules/@trinityui/design-system-css/dist/trinity.css" />
540
+ /* Option 2: direct file path */
541
+ @import 'node_modules/@trinityui/design-system-css/dist/trinity.css';
218
542
  ```
219
543
 
220
- ### Dark mode
221
-
222
544
  ```html
545
+ <!-- Dark mode: add data-theme attribute -->
223
546
  <html data-theme="dark">
224
547
  ```
225
548
 
226
- ## Theming
549
+ All design tokens are exposed as `--trinity-*` CSS variables. See the [CSS package README](./packages/design-system-css/README.md) for the full variable reference.
227
550
 
228
- ```tsx
229
- import { lightTheme, darkTheme } from '@trinityui/design-system';
551
+ ---
552
+
553
+ ## Storybook
230
554
 
231
- const theme = isDarkMode ? darkTheme : lightTheme;
555
+ Interactive component documentation with live controls, dark mode toggle, and accessibility audits:
556
+
557
+ ```bash
558
+ pnpm run start # Opens at http://localhost:6006
232
559
  ```
233
560
 
561
+ 93 stories covering every component with:
562
+ - Live prop controls and variant previews
563
+ - Dark mode toggle for all components
564
+ - Accessibility audit panel (axe-core integration)
565
+ - Code examples with copy-to-clipboard
566
+ - Autodocs — auto-generated API documentation from TypeScript types
567
+
568
+ ---
569
+
234
570
  ## Development
235
571
 
236
572
  ```bash
237
- pnpm install
238
- pnpm run start
239
- pnpm run build
240
- pnpm run test
241
- pnpm run lint
573
+ pnpm install # Install dependencies
574
+ pnpm run start # Storybook dev server (:6006)
575
+ pnpm run dev # Vite dev server (:5173)
576
+ pnpm run build # TypeScript + Vite production build
577
+ pnpm run test # Run all tests
578
+ pnpm run test:a11y # Run accessibility tests only
579
+ pnpm run lint # ESLint
580
+ pnpm run lint:tokens # Token usage rule validation
581
+ pnpm run size # Check bundle size limits
242
582
  ```
243
583
 
244
- ## Release and Publishing
584
+ ### Release and Publishing
585
+
586
+ - Push to `main` triggers publish workflows for both `@trinityui/design-system` and `@trinityui/design-system-css`
587
+ - Version is auto-bumped if the current version is already published
588
+ - `CHANGELOG.md` is generated during the release workflow
245
589
 
246
- - Push to `main` triggers publish workflows for:
247
- - `@trinityui/design-system`
248
- - `@trinityui/design-system-css`
249
- - Version is auto-bumped if the current version is already published.
250
- - `CHANGELOG.md` is generated during release workflow.
590
+ ---
251
591
 
252
- ## Support Docs
592
+ ## Documentation
253
593
 
254
- - [MIGRATION.md](./MIGRATION.md)
255
- - [CONTRIBUTING.md](./CONTRIBUTING.md)
256
- - [CHANGELOG.md](./CHANGELOG.md)
594
+ | Document | Description |
595
+ |---|---|
596
+ | [Quick Start](./docs/QUICK_START.md) | 5-minute getting-started guide |
597
+ | [Developer Guide](./docs/DEVELOPER_GUIDE.md) | Comprehensive development reference |
598
+ | [Accessibility](./docs/ACCESSIBILITY.md) | WCAG 2.1 AA compliance guide |
599
+ | [Component A11y Checklist](./docs/COMPONENT_A11Y_CHECKLIST.md) | Per-component accessibility requirements |
600
+ | [Token Usage Rules](./docs/TOKEN_USAGE_RULES.md) | When and how to use each token tier |
601
+ | [Storybook Standards](./docs/STORYBOOK_STANDARDS.md) | Story authoring conventions |
602
+ | [Testing Strategy](./docs/TESTING_STRATEGY.md) | Unit, a11y, and visual regression testing |
603
+ | [MUI Compatibility](./docs/MUI_COMPATIBILITY.md) | MUI version support matrix |
604
+ | [Integrating into Existing Apps](./docs/TRINITY_EXISTING_APP.md) | Migration guide for existing projects |
605
+ | [New App Setup](./docs/TRINITY_NEW_APP.md) | Starting a new project with Trinity |
606
+ | [Component Picker](./docs/COMPONENT_PICKER.md) | Decision tree: which component to use |
607
+ | [Governance](./docs/GOVERNANCE.md) | Contribution process, RFC, and deprecation policy |
608
+ | [Migration](./MIGRATION.md) | Version migration guides |
609
+ | [Contributing](./CONTRIBUTING.md) | How to contribute |
610
+ | [Changelog](./CHANGELOG.md) | Release history |
611
+
612
+ ---
257
613
 
258
614
  ## License
259
615