@synthaxai/ui 1.0.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.
Files changed (185) hide show
  1. package/README.md +262 -0
  2. package/dist/app.css +2 -0
  3. package/dist/app.html +12 -0
  4. package/dist/data-display/DataTable/DataTable.svelte +773 -0
  5. package/dist/data-display/DataTable/DataTable.svelte.d.ts +120 -0
  6. package/dist/data-display/DataTable/DataTable.svelte.d.ts.map +1 -0
  7. package/dist/data-display/DataTable/index.d.ts +2 -0
  8. package/dist/data-display/DataTable/index.d.ts.map +1 -0
  9. package/dist/data-display/DataTable/index.js +1 -0
  10. package/dist/data-display/StatCard/StatCard.svelte +409 -0
  11. package/dist/data-display/StatCard/StatCard.svelte.d.ts +63 -0
  12. package/dist/data-display/StatCard/StatCard.svelte.d.ts.map +1 -0
  13. package/dist/data-display/StatCard/index.d.ts +2 -0
  14. package/dist/data-display/StatCard/index.d.ts.map +1 -0
  15. package/dist/data-display/StatCard/index.js +1 -0
  16. package/dist/data-display/index.d.ts +8 -0
  17. package/dist/data-display/index.d.ts.map +1 -0
  18. package/dist/data-display/index.js +7 -0
  19. package/dist/dialogs/ConfirmDialog/ConfirmDialog.svelte +693 -0
  20. package/dist/dialogs/ConfirmDialog/ConfirmDialog.svelte.d.ts +66 -0
  21. package/dist/dialogs/ConfirmDialog/ConfirmDialog.svelte.d.ts.map +1 -0
  22. package/dist/dialogs/ConfirmDialog/index.d.ts +2 -0
  23. package/dist/dialogs/ConfirmDialog/index.d.ts.map +1 -0
  24. package/dist/dialogs/ConfirmDialog/index.js +1 -0
  25. package/dist/dialogs/Modal/Modal.svelte +441 -0
  26. package/dist/dialogs/Modal/Modal.svelte.d.ts +69 -0
  27. package/dist/dialogs/Modal/Modal.svelte.d.ts.map +1 -0
  28. package/dist/dialogs/Modal/index.d.ts +2 -0
  29. package/dist/dialogs/Modal/index.d.ts.map +1 -0
  30. package/dist/dialogs/Modal/index.js +1 -0
  31. package/dist/dialogs/index.d.ts +8 -0
  32. package/dist/dialogs/index.d.ts.map +1 -0
  33. package/dist/dialogs/index.js +7 -0
  34. package/dist/feedback/Alert/Alert.svelte +565 -0
  35. package/dist/feedback/Alert/Alert.svelte.d.ts +60 -0
  36. package/dist/feedback/Alert/Alert.svelte.d.ts.map +1 -0
  37. package/dist/feedback/Alert/index.d.ts +2 -0
  38. package/dist/feedback/Alert/index.d.ts.map +1 -0
  39. package/dist/feedback/Alert/index.js +1 -0
  40. package/dist/feedback/EmptyState/EmptyState.svelte +377 -0
  41. package/dist/feedback/EmptyState/EmptyState.svelte.d.ts +63 -0
  42. package/dist/feedback/EmptyState/EmptyState.svelte.d.ts.map +1 -0
  43. package/dist/feedback/EmptyState/index.d.ts +2 -0
  44. package/dist/feedback/EmptyState/index.d.ts.map +1 -0
  45. package/dist/feedback/EmptyState/index.js +1 -0
  46. package/dist/feedback/ProgressBar/ProgressBar.svelte +585 -0
  47. package/dist/feedback/ProgressBar/ProgressBar.svelte.d.ts +68 -0
  48. package/dist/feedback/ProgressBar/ProgressBar.svelte.d.ts.map +1 -0
  49. package/dist/feedback/ProgressBar/index.d.ts +2 -0
  50. package/dist/feedback/ProgressBar/index.d.ts.map +1 -0
  51. package/dist/feedback/ProgressBar/index.js +1 -0
  52. package/dist/feedback/Skeleton/Skeleton.svelte +568 -0
  53. package/dist/feedback/Skeleton/Skeleton.svelte.d.ts +54 -0
  54. package/dist/feedback/Skeleton/Skeleton.svelte.d.ts.map +1 -0
  55. package/dist/feedback/Skeleton/index.d.ts +2 -0
  56. package/dist/feedback/Skeleton/index.d.ts.map +1 -0
  57. package/dist/feedback/Skeleton/index.js +1 -0
  58. package/dist/feedback/Spinner/Spinner.svelte +434 -0
  59. package/dist/feedback/Spinner/Spinner.svelte.d.ts +49 -0
  60. package/dist/feedback/Spinner/Spinner.svelte.d.ts.map +1 -0
  61. package/dist/feedback/Spinner/index.d.ts +2 -0
  62. package/dist/feedback/Spinner/index.d.ts.map +1 -0
  63. package/dist/feedback/Spinner/index.js +1 -0
  64. package/dist/feedback/Toast/Toast.svelte +587 -0
  65. package/dist/feedback/Toast/Toast.svelte.d.ts +55 -0
  66. package/dist/feedback/Toast/Toast.svelte.d.ts.map +1 -0
  67. package/dist/feedback/Toast/ToastContainer.svelte +168 -0
  68. package/dist/feedback/Toast/ToastContainer.svelte.d.ts +28 -0
  69. package/dist/feedback/Toast/ToastContainer.svelte.d.ts.map +1 -0
  70. package/dist/feedback/Toast/index.d.ts +4 -0
  71. package/dist/feedback/Toast/index.d.ts.map +1 -0
  72. package/dist/feedback/Toast/index.js +3 -0
  73. package/dist/feedback/Toast/toast-store.d.ts +72 -0
  74. package/dist/feedback/Toast/toast-store.d.ts.map +1 -0
  75. package/dist/feedback/Toast/toast-store.js +157 -0
  76. package/dist/feedback/index.d.ts +13 -0
  77. package/dist/feedback/index.d.ts.map +1 -0
  78. package/dist/feedback/index.js +12 -0
  79. package/dist/forms/Checkbox/Checkbox.svelte +404 -0
  80. package/dist/forms/Checkbox/Checkbox.svelte.d.ts +62 -0
  81. package/dist/forms/Checkbox/Checkbox.svelte.d.ts.map +1 -0
  82. package/dist/forms/Checkbox/index.d.ts +2 -0
  83. package/dist/forms/Checkbox/index.d.ts.map +1 -0
  84. package/dist/forms/Checkbox/index.js +1 -0
  85. package/dist/forms/FormField/FormField.svelte +299 -0
  86. package/dist/forms/FormField/FormField.svelte.d.ts +43 -0
  87. package/dist/forms/FormField/FormField.svelte.d.ts.map +1 -0
  88. package/dist/forms/FormField/index.d.ts +2 -0
  89. package/dist/forms/FormField/index.d.ts.map +1 -0
  90. package/dist/forms/FormField/index.js +1 -0
  91. package/dist/forms/RadioGroup/RadioGroup.svelte +418 -0
  92. package/dist/forms/RadioGroup/RadioGroup.svelte.d.ts +70 -0
  93. package/dist/forms/RadioGroup/RadioGroup.svelte.d.ts.map +1 -0
  94. package/dist/forms/RadioGroup/index.d.ts +2 -0
  95. package/dist/forms/RadioGroup/index.d.ts.map +1 -0
  96. package/dist/forms/RadioGroup/index.js +1 -0
  97. package/dist/forms/Select/Select.svelte +548 -0
  98. package/dist/forms/Select/Select.svelte.d.ts +74 -0
  99. package/dist/forms/Select/Select.svelte.d.ts.map +1 -0
  100. package/dist/forms/Select/index.d.ts +2 -0
  101. package/dist/forms/Select/index.d.ts.map +1 -0
  102. package/dist/forms/Select/index.js +1 -0
  103. package/dist/forms/TextInput/TextInput.svelte +628 -0
  104. package/dist/forms/TextInput/TextInput.svelte.d.ts +97 -0
  105. package/dist/forms/TextInput/TextInput.svelte.d.ts.map +1 -0
  106. package/dist/forms/TextInput/index.d.ts +2 -0
  107. package/dist/forms/TextInput/index.d.ts.map +1 -0
  108. package/dist/forms/TextInput/index.js +1 -0
  109. package/dist/forms/Textarea/Textarea.svelte +587 -0
  110. package/dist/forms/Textarea/Textarea.svelte.d.ts +71 -0
  111. package/dist/forms/Textarea/Textarea.svelte.d.ts.map +1 -0
  112. package/dist/forms/Textarea/index.d.ts +2 -0
  113. package/dist/forms/Textarea/index.d.ts.map +1 -0
  114. package/dist/forms/Textarea/index.js +1 -0
  115. package/dist/forms/index.d.ts +13 -0
  116. package/dist/forms/index.d.ts.map +1 -0
  117. package/dist/forms/index.js +12 -0
  118. package/dist/index.d.ts +37 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +65 -0
  121. package/dist/layout/Card/Card.svelte +316 -0
  122. package/dist/layout/Card/Card.svelte.d.ts +63 -0
  123. package/dist/layout/Card/Card.svelte.d.ts.map +1 -0
  124. package/dist/layout/Card/index.d.ts +2 -0
  125. package/dist/layout/Card/index.d.ts.map +1 -0
  126. package/dist/layout/Card/index.js +1 -0
  127. package/dist/layout/Container/Container.svelte +252 -0
  128. package/dist/layout/Container/Container.svelte.d.ts +50 -0
  129. package/dist/layout/Container/Container.svelte.d.ts.map +1 -0
  130. package/dist/layout/Container/index.d.ts +2 -0
  131. package/dist/layout/Container/index.d.ts.map +1 -0
  132. package/dist/layout/Container/index.js +1 -0
  133. package/dist/layout/index.d.ts +8 -0
  134. package/dist/layout/index.d.ts.map +1 -0
  135. package/dist/layout/index.js +7 -0
  136. package/dist/navigation/StepIndicator/StepIndicator.svelte +601 -0
  137. package/dist/navigation/StepIndicator/StepIndicator.svelte.d.ts +70 -0
  138. package/dist/navigation/StepIndicator/StepIndicator.svelte.d.ts.map +1 -0
  139. package/dist/navigation/StepIndicator/index.d.ts +2 -0
  140. package/dist/navigation/StepIndicator/index.d.ts.map +1 -0
  141. package/dist/navigation/StepIndicator/index.js +1 -0
  142. package/dist/navigation/index.d.ts +7 -0
  143. package/dist/navigation/index.d.ts.map +1 -0
  144. package/dist/navigation/index.js +6 -0
  145. package/dist/primitives/Badge/Badge.svelte +365 -0
  146. package/dist/primitives/Badge/Badge.svelte.d.ts +39 -0
  147. package/dist/primitives/Badge/Badge.svelte.d.ts.map +1 -0
  148. package/dist/primitives/Badge/index.d.ts +2 -0
  149. package/dist/primitives/Badge/index.d.ts.map +1 -0
  150. package/dist/primitives/Badge/index.js +1 -0
  151. package/dist/primitives/Button/Button.svelte +430 -0
  152. package/dist/primitives/Button/Button.svelte.d.ts +50 -0
  153. package/dist/primitives/Button/Button.svelte.d.ts.map +1 -0
  154. package/dist/primitives/Button/index.d.ts +2 -0
  155. package/dist/primitives/Button/index.d.ts.map +1 -0
  156. package/dist/primitives/Button/index.js +1 -0
  157. package/dist/primitives/index.d.ts +9 -0
  158. package/dist/primitives/index.d.ts.map +1 -0
  159. package/dist/primitives/index.js +8 -0
  160. package/dist/routes/+layout.svelte +12 -0
  161. package/dist/routes/+layout.svelte.d.ts +12 -0
  162. package/dist/routes/+layout.svelte.d.ts.map +1 -0
  163. package/dist/routes/+page.svelte +53 -0
  164. package/dist/routes/+page.svelte.d.ts +27 -0
  165. package/dist/routes/+page.svelte.d.ts.map +1 -0
  166. package/dist/styles/tokens.css +399 -0
  167. package/dist/types/index.d.ts +175 -0
  168. package/dist/types/index.d.ts.map +1 -0
  169. package/dist/types/index.js +7 -0
  170. package/dist/utils/accessibility.d.ts +103 -0
  171. package/dist/utils/accessibility.d.ts.map +1 -0
  172. package/dist/utils/accessibility.js +202 -0
  173. package/dist/utils/cn.d.ts +71 -0
  174. package/dist/utils/cn.d.ts.map +1 -0
  175. package/dist/utils/cn.js +61 -0
  176. package/dist/utils/form-styles.d.ts +76 -0
  177. package/dist/utils/form-styles.d.ts.map +1 -0
  178. package/dist/utils/form-styles.js +95 -0
  179. package/dist/utils/index.d.ts +10 -0
  180. package/dist/utils/index.d.ts.map +1 -0
  181. package/dist/utils/index.js +13 -0
  182. package/dist/utils/keyboard.d.ts +94 -0
  183. package/dist/utils/keyboard.d.ts.map +1 -0
  184. package/dist/utils/keyboard.js +179 -0
  185. package/package.json +119 -0
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # @synthaxai/ui — Component Library
2
+
3
+ Production-quality UI component library for Synthax healthcare applications.
4
+
5
+ ## Features
6
+
7
+ - **23 Components** — Comprehensive set of UI components for healthcare apps
8
+ - **Svelte 5** — Built with modern runes and snippets
9
+ - **TypeScript** — Full type definitions for all components
10
+ - **Accessible** — WCAG 2.1 AA compliant with screen reader support
11
+ - **Dark Mode** — Automatic theme support via CSS variables
12
+ - **Healthcare-Ready** — Designed for critical healthcare application requirements
13
+ - **463 Tests** — Comprehensive unit tests with Vitest
14
+ - **E2E Testing Ready** — All components support `testId` prop for Playwright/Cypress
15
+ - **Focus Management** — Proper focus restoration for modals and dialogs
16
+ - **Reduced Motion** — Respects `prefers-reduced-motion` user preference
17
+
18
+ ## Components
19
+
20
+ ### Primitives
21
+ - **Button** — Multi-variant with loading states and icon-only mode
22
+ - **Badge** — Status indicators with semantic colors
23
+
24
+ ### Forms
25
+ - **TextInput** — Text, email, password, tel input with validation
26
+ - **Textarea** — Multi-line input for clinical notes with auto-resize
27
+ - **Select** — Dropdown with grouped options support
28
+ - **Checkbox** — Accessible checkbox with indeterminate state
29
+ - **RadioGroup** — Accessible radio group with descriptions
30
+ - **FormField** — Wrapper for consistent form layouts
31
+
32
+ ### Feedback
33
+ - **Alert** — Inline/banner alerts with clinical type support
34
+ - **Toast** — Temporary notifications
35
+ - **Spinner** — Loading indicators
36
+ - **ProgressBar** — Determinate and indeterminate progress
37
+ - **Skeleton** — Loading placeholders with shimmer/pulse animations
38
+ - **EmptyState** — Empty data placeholders
39
+
40
+ ### Layout
41
+ - **Card** — Glass morphism cards with header/footer slots
42
+ - **Container** — Responsive content containers
43
+
44
+ ### Data Display
45
+ - **StatCard** — Dashboard statistics with trends
46
+ - **DataTable** — Sortable tables with mobile-responsive design
47
+
48
+ ### Navigation
49
+ - **StepIndicator** — Multi-step workflow progress
50
+
51
+ ### Dialogs
52
+ - **Modal** — Accessible modal with focus trap
53
+ - **ConfirmDialog** — Confirmation dialogs for critical actions
54
+
55
+ ## Structure
56
+
57
+ ```
58
+ src/
59
+ ├── index.ts # Main exports
60
+ ├── types/ # TypeScript type definitions
61
+ ├── utils/ # Utility functions (cn, keyboard, a11y)
62
+ ├── styles/ # Design tokens CSS
63
+ ├── primitives/ # Button, Badge
64
+ ├── forms/ # TextInput, Textarea, Select, Checkbox, RadioGroup, FormField
65
+ ├── feedback/ # Alert, Toast, Spinner, ProgressBar, Skeleton, EmptyState
66
+ ├── layout/ # Card, Container
67
+ ├── data-display/ # StatCard, DataTable
68
+ ├── navigation/ # StepIndicator
69
+ └── dialogs/ # Modal, ConfirmDialog
70
+ ```
71
+
72
+ ## Installation
73
+
74
+ ### For synthaxweb or other Synthax apps
75
+
76
+ Add the library as a local dependency in your `package.json`:
77
+
78
+ ```json
79
+ {
80
+ "dependencies": {
81
+ "@synthaxai/ui": "file:../ui/lib"
82
+ }
83
+ }
84
+ ```
85
+
86
+ Then install:
87
+
88
+ ```bash
89
+ pnpm install
90
+ ```
91
+
92
+ ### Peer Dependencies
93
+
94
+ The library requires:
95
+ - `svelte` ^5.0.0
96
+ - `lucide-svelte` ^0.400.0
97
+
98
+ ## Usage
99
+
100
+ ### 1. Import styles in your app's CSS
101
+
102
+ ```css
103
+ /* app.css */
104
+ @import '@synthaxai/ui/styles';
105
+ ```
106
+
107
+ ### 2. Use components in your Svelte files
108
+
109
+ ```svelte
110
+ <script>
111
+ import { Button, Card, TextInput } from '@synthaxai/ui';
112
+ </script>
113
+
114
+ <Card>
115
+ <TextInput label="Patient Name" bind:value={patientName} />
116
+ <Button variant="primary" onclick={handleSubmit}>Save</Button>
117
+ </Card>
118
+ ```
119
+
120
+ ### Import by category (tree-shaking friendly)
121
+
122
+ ```svelte
123
+ <script>
124
+ import { Button } from '@synthaxai/ui/primitives';
125
+ import { TextInput, Select } from '@synthaxai/ui/forms';
126
+ import { Modal } from '@synthaxai/ui/dialogs';
127
+ import { Alert } from '@synthaxai/ui/feedback';
128
+ </script>
129
+ ```
130
+
131
+ ### Using utilities
132
+
133
+ ```typescript
134
+ import { cn, announce, generateId } from '@synthaxai/ui/utils';
135
+
136
+ // Merge class names conditionally
137
+ const className = cn('base-class', isActive && 'active-class');
138
+
139
+ // Announce to screen readers
140
+ announce('Form submitted successfully');
141
+ ```
142
+
143
+ ## Development
144
+
145
+ ```bash
146
+ # Install dependencies
147
+ pnpm install
148
+
149
+ # Start dev server
150
+ pnpm dev
151
+
152
+ # Run tests
153
+ pnpm test
154
+
155
+ # Run tests in watch mode
156
+ pnpm test:watch
157
+
158
+ # Build the library
159
+ pnpm build
160
+
161
+ # Type check
162
+ pnpm check
163
+
164
+ # Lint (with Biome)
165
+ pnpm lint
166
+
167
+ # Lint and fix
168
+ pnpm lint:fix
169
+
170
+ # Format (with Biome)
171
+ pnpm format
172
+
173
+ # Check format
174
+ pnpm format:check
175
+
176
+ # Lint + format + organize imports
177
+ pnpm check:all
178
+ ```
179
+
180
+ ## E2E Testing Support
181
+
182
+ All interactive components support the `testId` prop for Playwright or Cypress selectors:
183
+
184
+ ```svelte
185
+ <Button testId="submit-button" onclick={handleSubmit}>Submit</Button>
186
+ <TextInput testId="patient-name" label="Patient Name" bind:value={name} />
187
+ <Modal testId="confirm-modal" open={isOpen} onclose={() => isOpen = false}>
188
+ ...
189
+ </Modal>
190
+ ```
191
+
192
+ In Playwright tests:
193
+
194
+ ```typescript
195
+ await page.getByTestId('submit-button').click();
196
+ await page.getByTestId('patient-name').fill('John Doe');
197
+ ```
198
+
199
+ ## Component Guidelines
200
+
201
+ Each component:
202
+
203
+ 1. **Is self-contained** — Own styles, types, and tests
204
+ 2. **Supports dark mode** — Uses CSS variables for theming
205
+ 3. **Is accessible** — Proper ARIA attributes and keyboard navigation
206
+ 4. **Is typed** — Exports TypeScript interfaces for all props
207
+ 5. **Is documented** — JSDoc comments and usage examples
208
+ 6. **Is tested** — Unit tests covering rendering, states, and accessibility
209
+ 7. **Supports E2E testing** — Optional `testId` prop for test selectors
210
+
211
+ ## Theme Support
212
+
213
+ The library supports light and dark themes in three modes:
214
+
215
+ ### 1. Automatic (System Preference)
216
+
217
+ By default, the library respects `prefers-color-scheme`:
218
+
219
+ ```css
220
+ /* Just import the styles - theme auto-detected */
221
+ @import '@synthaxai/ui/styles';
222
+ ```
223
+
224
+ ### 2. Explicit Theme Control
225
+
226
+ Set `data-theme` on the root element:
227
+
228
+ ```html
229
+ <!-- Force light mode -->
230
+ <html data-theme="light">
231
+
232
+ <!-- Force dark mode -->
233
+ <html data-theme="dark">
234
+ ```
235
+
236
+ ### 3. Toggle with JavaScript
237
+
238
+ ```javascript
239
+ // Toggle theme
240
+ function toggleTheme() {
241
+ const current = document.documentElement.dataset.theme;
242
+ document.documentElement.dataset.theme = current === 'dark' ? 'light' : 'dark';
243
+ }
244
+ ```
245
+
246
+ **Theme precedence:**
247
+ 1. `data-theme="dark"` → dark mode
248
+ 2. `data-theme="light"` → light mode
249
+ 3. No `data-theme` → follows system preference
250
+
251
+ ## Design System
252
+
253
+ The library follows Synthax's design system:
254
+
255
+ | Token | Value | Usage |
256
+ |-------|-------|-------|
257
+ | Primary | `#124545` | Brand color, CTAs |
258
+ | Radius (buttons) | `8px` | rounded-lg |
259
+ | Radius (cards) | `12px` | rounded-xl |
260
+ | Radius (modals) | `16px` | rounded-2xl |
261
+
262
+ See `src/styles/tokens.css` for all design tokens.
package/dist/app.css ADDED
@@ -0,0 +1,2 @@
1
+ @import 'tailwindcss';
2
+ @import './styles/tokens.css';
package/dist/app.html ADDED
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%sveltekit.assets%/favicon.png" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ %sveltekit.head%
8
+ </head>
9
+ <body data-sveltekit-preload-data="hover">
10
+ <div style="display: contents">%sveltekit.body%</div>
11
+ </body>
12
+ </html>