@medixdeck/ui 0.1.16 → 0.1.17
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 +155 -99
- package/dist/index.cjs +30 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +136 -109
- package/dist/index.js +14911 -6344
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/sw.js +3 -3
- package/package.json +17 -5
package/README.md
CHANGED
|
@@ -17,13 +17,7 @@ npm install @medixdeck/ui @chakra-ui/react react react-dom
|
|
|
17
17
|
## Quick start
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
|
-
import {
|
|
21
|
-
Button,
|
|
22
|
-
Logo,
|
|
23
|
-
MedixProvider,
|
|
24
|
-
Navbar,
|
|
25
|
-
useThemeMode,
|
|
26
|
-
} from "@medixdeck/ui";
|
|
20
|
+
import { Button, Logo, MedixProvider, Navbar, useThemeMode } from '@medixdeck/ui';
|
|
27
21
|
|
|
28
22
|
// Next.js App Router: mark this component "use client" when using hooks.
|
|
29
23
|
function ThemeToggle() {
|
|
@@ -34,7 +28,7 @@ function ThemeToggle() {
|
|
|
34
28
|
|
|
35
29
|
return (
|
|
36
30
|
<Button variant="solid" colorScheme="blue" onClick={toggleThemeMode}>
|
|
37
|
-
Switch to {themeMode ===
|
|
31
|
+
Switch to {themeMode === 'dark' ? 'light' : 'dark'} mode
|
|
38
32
|
</Button>
|
|
39
33
|
);
|
|
40
34
|
}
|
|
@@ -43,7 +37,7 @@ export function App() {
|
|
|
43
37
|
return (
|
|
44
38
|
<MedixProvider defaultColorMode="light">
|
|
45
39
|
<Navbar
|
|
46
|
-
navItems={[{ label:
|
|
40
|
+
navItems={[{ label: 'Docs', href: '#docs' }]}
|
|
47
41
|
ctaLabel="Talk to a Doctor"
|
|
48
42
|
ctaHref="/consult"
|
|
49
43
|
/>
|
|
@@ -56,17 +50,17 @@ export function App() {
|
|
|
56
50
|
|
|
57
51
|
## Public API index
|
|
58
52
|
|
|
59
|
-
| Area
|
|
60
|
-
|
|
|
61
|
-
| Provider + theme
|
|
62
|
-
| Primitive
|
|
63
|
-
| Form
|
|
64
|
-
| Layout
|
|
65
|
-
| Navigation
|
|
66
|
-
| Feedback
|
|
67
|
-
| Data display
|
|
68
|
-
| Healthcare
|
|
69
|
-
| Chakra re-exports | `Box`, `Flex`, `Grid`, `Stack`, `Text`, `Heading`, `Link`, `Image`, `Icon`, `Center`, `Wrap`, `WrapItem`, others in `lib/index.ts`
|
|
53
|
+
| Area | Exports |
|
|
54
|
+
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| Provider + theme | `MedixProvider`, `useThemeMode`, `useIsDarkMode`, `useColorScheme`, `system`, `medixConfig`, token exports |
|
|
56
|
+
| Primitive | `Button`, `IconButton`, `Badge`, `Avatar`, `AvatarGroup`, `Spinner`, `FullPageSpinner`, `Tag`, `Divider`, `Logo` |
|
|
57
|
+
| Form | `Input`, `SearchInput`, `Textarea`, `Select`, `Checkbox`, `RadioGroup`, `Switch`, `FormControl`, `OTPInput`, `PinInput`, `PhoneInput`, `DatePicker`, `DateRangePicker`, `Calendar`, `Combobox`, `FileUpload` |
|
|
58
|
+
| Layout | `Card`, `CardHeader`, `CardBody`, `CardFooter`, `StatCard`, `Container`, `SectionHeader`, `ThemeColorPalette`, `DashboardLayout`, `Footer` |
|
|
59
|
+
| Navigation | `Navbar`, `Breadcrumb`, `Tabs`, `Pagination`, `Stepper` |
|
|
60
|
+
| Feedback | `Alert`, `Skeleton`, `SkeletonText`, `SkeletonCard`, `Progress`, `Modal`, `Drawer`, `Tooltip`, `EmptyState`, `NotFoundPage`, `ServerErrorPage`, `Toaster`, `toast`, `dismissToast`, `CookieConsentBanner`, `PWAInstallPrompt` |
|
|
61
|
+
| Data display | `Accordion`, `TestimonialCard`, `BlogCard`, `DataTable` |
|
|
62
|
+
| Healthcare | `DoctorCard`, `VitalBadge`, `AppointmentCard` |
|
|
63
|
+
| Chakra re-exports | `Box`, `Flex`, `Grid`, `Stack`, `Text`, `Heading`, `Link`, `Image`, `Icon`, `Center`, `Wrap`, `WrapItem`, others in `lib/index.ts` |
|
|
70
64
|
|
|
71
65
|
## Design-system rules
|
|
72
66
|
|
|
@@ -79,7 +73,7 @@ export function App() {
|
|
|
79
73
|
## Theme hooks
|
|
80
74
|
|
|
81
75
|
```tsx
|
|
82
|
-
import { useIsDarkMode, useThemeMode } from
|
|
76
|
+
import { useIsDarkMode, useThemeMode } from '@medixdeck/ui';
|
|
83
77
|
|
|
84
78
|
function ThemeStatus() {
|
|
85
79
|
const { themeMode, themeSetting, setThemeMode, toggleThemeMode } = useThemeMode();
|
|
@@ -88,11 +82,11 @@ function ThemeStatus() {
|
|
|
88
82
|
return (
|
|
89
83
|
<>
|
|
90
84
|
<p>Resolved mode: {themeMode}</p>
|
|
91
|
-
<p>Following: {themeSetting ??
|
|
85
|
+
<p>Following: {themeSetting ?? 'system'}</p>
|
|
92
86
|
<p>Dark mode active: {String(isDarkMode)}</p>
|
|
93
|
-
<button onClick={() => setThemeMode(
|
|
94
|
-
<button onClick={() => setThemeMode(
|
|
95
|
-
<button onClick={() => setThemeMode(
|
|
87
|
+
<button onClick={() => setThemeMode('dark')}>Dark</button>
|
|
88
|
+
<button onClick={() => setThemeMode('light')}>Light</button>
|
|
89
|
+
<button onClick={() => setThemeMode('system')}>System</button>
|
|
96
90
|
<button onClick={toggleThemeMode}>Toggle</button>
|
|
97
91
|
</>
|
|
98
92
|
);
|
|
@@ -142,13 +136,73 @@ function Page() {
|
|
|
142
136
|
|
|
143
137
|
`useColorScheme(initialScheme?)` returns:
|
|
144
138
|
|
|
145
|
-
| Field
|
|
146
|
-
|
|
|
147
|
-
| `colorScheme`
|
|
148
|
-
| `setColorScheme`
|
|
149
|
-
| `toggleColorScheme` | `() => void`
|
|
150
|
-
| `isBlue`
|
|
151
|
-
| `isPurple`
|
|
139
|
+
| Field | Type | Description |
|
|
140
|
+
| ------------------- | -------------------- | -------------------------------- |
|
|
141
|
+
| `colorScheme` | `"blue" \| "purple"` | Currently active scheme |
|
|
142
|
+
| `setColorScheme` | `(scheme) => void` | Explicit setter |
|
|
143
|
+
| `toggleColorScheme` | `() => void` | Flips blue ↔ purple |
|
|
144
|
+
| `isBlue` | `boolean` | `true` when scheme is `"blue"` |
|
|
145
|
+
| `isPurple` | `boolean` | `true` when scheme is `"purple"` |
|
|
146
|
+
|
|
147
|
+
## Feedback & Overlays
|
|
148
|
+
|
|
149
|
+
### Toast Notifications
|
|
150
|
+
|
|
151
|
+
The MedixDeck UI includes a fully automated `Toast` system powered by Chakra UI v3's `createToaster` API, styled to match MedixDeck `Alert` components.
|
|
152
|
+
|
|
153
|
+
To use it, render the `<Toaster />` at the root of your application, and then use the `toast` helper to trigger notifications from anywhere.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { Toaster, toast } from '@medixdeck/ui';
|
|
157
|
+
|
|
158
|
+
function App() {
|
|
159
|
+
return (
|
|
160
|
+
<>
|
|
161
|
+
<Toaster />
|
|
162
|
+
<button onClick={() => toast.success('Changes saved successfully!')}>Save</button>
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The `toast` utility exposes `success`, `error`, `info`, and `warning` shorthand methods.
|
|
169
|
+
|
|
170
|
+
### Error Pages (404 & 500)
|
|
171
|
+
|
|
172
|
+
`NotFoundPage` and `ServerErrorPage` render beautifully styled full-screen error states. In the development environment (`process.env.NODE_ENV === "development"`), passing an `errorMessage` will render a technical code block. In production, this block is safely hidden to prevent data leakage.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<ServerErrorPage
|
|
176
|
+
errorMessage="TypeError: Cannot read properties of undefined (reading 'id')"
|
|
177
|
+
onAction={() => reset()}
|
|
178
|
+
/>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Data Display & Form Enhancements
|
|
182
|
+
|
|
183
|
+
### Accordion with HTML/Markdown
|
|
184
|
+
|
|
185
|
+
The `Accordion` supports passing rich text answers via the `answerType` prop. Use `"HTML"` (safely sanitized via `isomorphic-dompurify`) or `"MD"` (parsed via `react-markdown`).
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
<Accordion
|
|
189
|
+
answerType="MD"
|
|
190
|
+
items={[{ id: 'q1', question: 'Markdown Support?', answer: 'Yes, **boldly** so!' }]}
|
|
191
|
+
/>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Multiple Select
|
|
195
|
+
|
|
196
|
+
The `Select` component supports native multiple selection, returning arrays on change.
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
<Select
|
|
200
|
+
multiple
|
|
201
|
+
placeholder="Select specialties..."
|
|
202
|
+
options={[{ value: 'cardio', label: 'Cardiology' }]}
|
|
203
|
+
onChange={(values) => console.log(values)} // values is string | string[]
|
|
204
|
+
/>
|
|
205
|
+
```
|
|
152
206
|
|
|
153
207
|
## DashboardLayout
|
|
154
208
|
|
|
@@ -157,23 +211,23 @@ The full-screen authenticated application shell. Renders a fixed sidebar, sticky
|
|
|
157
211
|
### Basic usage
|
|
158
212
|
|
|
159
213
|
```tsx
|
|
160
|
-
import { DashboardLayout } from
|
|
214
|
+
import { DashboardLayout } from '@medixdeck/ui';
|
|
161
215
|
|
|
162
216
|
<DashboardLayout
|
|
163
217
|
colorScheme="purple"
|
|
164
|
-
user={{ name:
|
|
218
|
+
user={{ name: 'Dr. Okedi Williams', email: 'williams@medixdeck.com' }}
|
|
165
219
|
navGroups={[
|
|
166
220
|
{
|
|
167
221
|
items: [
|
|
168
|
-
{ label:
|
|
169
|
-
{ label:
|
|
222
|
+
{ label: 'Home', href: '/', isActive: true },
|
|
223
|
+
{ label: 'Messages', href: '/messages', badge: 6 },
|
|
170
224
|
],
|
|
171
225
|
},
|
|
172
226
|
{
|
|
173
|
-
groupLabel:
|
|
227
|
+
groupLabel: 'Account',
|
|
174
228
|
items: [
|
|
175
|
-
{ label:
|
|
176
|
-
{ label:
|
|
229
|
+
{ label: 'Profile', href: '/profile' },
|
|
230
|
+
{ label: 'Notifications', href: '/notifications', hasDot: true },
|
|
177
231
|
],
|
|
178
232
|
},
|
|
179
233
|
]}
|
|
@@ -181,7 +235,7 @@ import { DashboardLayout } from "@medixdeck/ui";
|
|
|
181
235
|
renderLink={(item, children) => <Link href={item.href}>{children}</Link>}
|
|
182
236
|
>
|
|
183
237
|
{/* page content */}
|
|
184
|
-
</DashboardLayout
|
|
238
|
+
</DashboardLayout>;
|
|
185
239
|
```
|
|
186
240
|
|
|
187
241
|
### Mobile bottom navigation (`mobileNavItems`)
|
|
@@ -189,28 +243,28 @@ import { DashboardLayout } from "@medixdeck/ui";
|
|
|
189
243
|
A fixed bottom tab bar (mobile only, hidden on `md+`). Uses `react-icons/lu` or any icon component.
|
|
190
244
|
|
|
191
245
|
```tsx
|
|
192
|
-
import { LuHouse, LuMessageCircle, LuUser } from
|
|
246
|
+
import { LuHouse, LuMessageCircle, LuUser } from 'react-icons/lu';
|
|
193
247
|
|
|
194
248
|
<DashboardLayout
|
|
195
249
|
mobileNavItems={[
|
|
196
|
-
{ label:
|
|
197
|
-
{ label:
|
|
198
|
-
{ label:
|
|
250
|
+
{ label: 'Home', href: '/', icon: <LuHouse size={22} />, isActive: true },
|
|
251
|
+
{ label: 'Messages', href: '/messages', icon: <LuMessageCircle size={22} />, badge: 6 },
|
|
252
|
+
{ label: 'Profile', href: '/profile', icon: <LuUser size={22} /> },
|
|
199
253
|
]}
|
|
200
254
|
>
|
|
201
255
|
{/* ... */}
|
|
202
|
-
</DashboardLayout
|
|
256
|
+
</DashboardLayout>;
|
|
203
257
|
```
|
|
204
258
|
|
|
205
259
|
`DashboardMobileNavItem` props:
|
|
206
260
|
|
|
207
|
-
| Prop
|
|
208
|
-
|
|
|
209
|
-
| `label`
|
|
210
|
-
| `href`
|
|
211
|
-
| `icon`
|
|
212
|
-
| `isActive` | `boolean`
|
|
213
|
-
| `badge`
|
|
261
|
+
| Prop | Type | Required | Description |
|
|
262
|
+
| ---------- | ----------- | -------- | -------------------------------------- |
|
|
263
|
+
| `label` | `string` | ✓ | Text below the icon |
|
|
264
|
+
| `href` | `string` | ✓ | Unique key + navigation target |
|
|
265
|
+
| `icon` | `ReactNode` | ✓ | Icon (22 × 22 px recommended) |
|
|
266
|
+
| `isActive` | `boolean` | — | Highlights the active tab |
|
|
267
|
+
| `badge` | `number` | — | Count bubble on icon (capped at `99+`) |
|
|
214
268
|
|
|
215
269
|
### Doctor score card (`scoreCard`)
|
|
216
270
|
|
|
@@ -219,12 +273,12 @@ Shown above the sidebar nav on **desktop only**. Only pass this prop for doctor-
|
|
|
219
273
|
```tsx
|
|
220
274
|
<DashboardLayout
|
|
221
275
|
scoreCard={{
|
|
222
|
-
name:
|
|
223
|
-
role:
|
|
224
|
-
avatarSrc:
|
|
225
|
-
tier:
|
|
276
|
+
name: 'Dr. Okedi Williams',
|
|
277
|
+
role: 'Cardiologist',
|
|
278
|
+
avatarSrc: '/dr-okedi.jpg', // optional — initials fallback
|
|
279
|
+
tier: 'gold', // "bronze" | "silver" | "gold" | "platinum" | "diamond"
|
|
226
280
|
medixScore: 847,
|
|
227
|
-
link:
|
|
281
|
+
link: '/doctor/profile', // optional — makes the card clickable
|
|
228
282
|
}}
|
|
229
283
|
>
|
|
230
284
|
{/* ... */}
|
|
@@ -233,13 +287,13 @@ Shown above the sidebar nav on **desktop only**. Only pass this prop for doctor-
|
|
|
233
287
|
|
|
234
288
|
Tier colours:
|
|
235
289
|
|
|
236
|
-
| Tier
|
|
237
|
-
|
|
|
238
|
-
| `bronze`
|
|
239
|
-
| `silver`
|
|
240
|
-
| `gold`
|
|
241
|
-
| `platinum` | `#0284C7`
|
|
242
|
-
| `diamond`
|
|
290
|
+
| Tier | Label colour | Avatar ring |
|
|
291
|
+
| ---------- | ------------ | ----------- |
|
|
292
|
+
| `bronze` | `#92400E` | `#D97706` |
|
|
293
|
+
| `silver` | `#475569` | `#94A3B8` |
|
|
294
|
+
| `gold` | `#D97706` | `#F59E0B` |
|
|
295
|
+
| `platinum` | `#0284C7` | `#38BDF8` |
|
|
296
|
+
| `diamond` | `#7C3AED` | `#A78BFA` |
|
|
243
297
|
|
|
244
298
|
### Greeting subtitle (`greetingSubtext`)
|
|
245
299
|
|
|
@@ -247,8 +301,11 @@ An optional second line below the greeting. The top bar expands from 64 px → 8
|
|
|
247
301
|
|
|
248
302
|
```tsx
|
|
249
303
|
<DashboardLayout
|
|
250
|
-
greetingSubtext={`${new Date().toLocaleDateString(
|
|
251
|
-
weekday:
|
|
304
|
+
greetingSubtext={`${new Date().toLocaleDateString('en-GB', {
|
|
305
|
+
weekday: 'long',
|
|
306
|
+
day: 'numeric',
|
|
307
|
+
month: 'long',
|
|
308
|
+
year: 'numeric',
|
|
252
309
|
})} · 8 consultations scheduled today`}
|
|
253
310
|
>
|
|
254
311
|
{/* ... */}
|
|
@@ -257,56 +314,55 @@ An optional second line below the greeting. The top bar expands from 64 px → 8
|
|
|
257
314
|
|
|
258
315
|
### All `DashboardLayout` props
|
|
259
316
|
|
|
260
|
-
| Prop
|
|
261
|
-
|
|
|
262
|
-
| `user`
|
|
263
|
-
| `navGroups`
|
|
264
|
-
| `colorScheme`
|
|
265
|
-
| `logo`
|
|
266
|
-
| `greeting`
|
|
267
|
-
| `greetingSubtext` | `string`
|
|
268
|
-
| `mobileNavItems`
|
|
269
|
-
| `scoreCard`
|
|
270
|
-
| `topBarSlot`
|
|
271
|
-
| `dropdownItems`
|
|
272
|
-
| `sidebarWidth`
|
|
273
|
-
| `renderLink`
|
|
274
|
-
| `onLogout`
|
|
317
|
+
| Prop | Type | Default | Description |
|
|
318
|
+
| ----------------- | ------------------------------- | ---------- | --------------------------------------------- |
|
|
319
|
+
| `user` | `DashboardUser` | — | Name, email, optional avatar |
|
|
320
|
+
| `navGroups` | `DashboardNavGroup[]` | — | Sidebar navigation tree |
|
|
321
|
+
| `colorScheme` | `"blue" \| "purple"` | `"blue"` | Brand accent colour |
|
|
322
|
+
| `logo` | `ReactNode` | `<Logo />` | Override the sidebar logo |
|
|
323
|
+
| `greeting` | `string` | auto | Override "Good morning / afternoon / evening" |
|
|
324
|
+
| `greetingSubtext` | `string` | — | Subtitle line below the greeting |
|
|
325
|
+
| `mobileNavItems` | `DashboardMobileNavItem[]` | — | Mobile bottom tab bar items |
|
|
326
|
+
| `scoreCard` | `DashboardScoreCardData` | — | Doctor identity card (desktop only) |
|
|
327
|
+
| `topBarSlot` | `ReactNode` | — | Slot right of greeting (search, bell, etc.) |
|
|
328
|
+
| `dropdownItems` | `DashboardDropdownItem[]` | — | Extra user dropdown items |
|
|
329
|
+
| `sidebarWidth` | `number` | `220` | Sidebar width in px |
|
|
330
|
+
| `renderLink` | `(item, children) => ReactNode` | `<a>` | Router integration |
|
|
331
|
+
| `onLogout` | `() => void` | — | Logout callback |
|
|
275
332
|
|
|
276
333
|
## Footer
|
|
277
334
|
|
|
278
335
|
The `Footer` component provides the core navigation layout for the bottom of pages. It features an optional compliance `certifications` row and a brandable `colorScheme`.
|
|
279
336
|
|
|
280
337
|
```tsx
|
|
281
|
-
import { Footer } from
|
|
338
|
+
import { Footer } from '@medixdeck/ui';
|
|
282
339
|
|
|
283
340
|
<Footer
|
|
284
341
|
colorScheme="purple"
|
|
285
342
|
certifications={[
|
|
286
|
-
{ name:
|
|
287
|
-
{ name:
|
|
288
|
-
{ name:
|
|
343
|
+
{ name: 'NDPR Compliant', href: 'https://nitda.gov.ng' },
|
|
344
|
+
{ name: 'MDCN Certified Platform', href: 'https://mdcn.gov.ng' },
|
|
345
|
+
{ name: 'ISO 27001', href: '#' },
|
|
289
346
|
]}
|
|
290
|
-
|
|
347
|
+
/>;
|
|
291
348
|
```
|
|
292
349
|
|
|
293
|
-
| Prop
|
|
294
|
-
|
|
|
295
|
-
| `colorScheme`
|
|
296
|
-
| `certifications` | `FooterCertification[]`
|
|
297
|
-
| `logo`
|
|
298
|
-
| `description`
|
|
299
|
-
| `sections`
|
|
300
|
-
| `socialLinks`
|
|
301
|
-
| `newsletter`
|
|
302
|
-
| `bottomLinks`
|
|
303
|
-
| `renderLink`
|
|
350
|
+
| Prop | Type | Default | Description |
|
|
351
|
+
| ---------------- | ------------------------------- | ---------- | ----------------------------------------------- |
|
|
352
|
+
| `colorScheme` | `"blue" \| "purple"` | `"blue"` | Brand accent colour for links and social icons |
|
|
353
|
+
| `certifications` | `FooterCertification[]` | — | Compliance badges displayed above the copyright |
|
|
354
|
+
| `logo` | `ReactNode` | `<Logo />` | Override the default logo |
|
|
355
|
+
| `description` | `string` | — | Short company bio |
|
|
356
|
+
| `sections` | `FooterSection[]` | — | Link columns |
|
|
357
|
+
| `socialLinks` | `SocialLink[]` | — | Social media URLs |
|
|
358
|
+
| `newsletter` | `NewsletterProps` | — | Email subscription form config |
|
|
359
|
+
| `bottomLinks` | `BottomLink[]` | — | Terms/Privacy links next to copyright |
|
|
360
|
+
| `renderLink` | `(item, children) => ReactNode` | `<a>` | Router integration |
|
|
304
361
|
|
|
305
362
|
## Theme color reference
|
|
306
363
|
|
|
307
|
-
|
|
308
364
|
```tsx
|
|
309
|
-
import { ThemeColorPalette } from
|
|
365
|
+
import { ThemeColorPalette } from '@medixdeck/ui';
|
|
310
366
|
|
|
311
367
|
export function DesignTokensPage() {
|
|
312
368
|
return <ThemeColorPalette mt="8" />;
|