@medixdeck/ui 0.1.22 → 0.1.24

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
@@ -58,7 +58,7 @@ export function App() {
58
58
  | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
59
59
  | Provider + theme | `MedixProvider`, `useThemeMode`, `useIsDarkMode`, `useColorScheme`, `system`, `medixConfig`, token exports |
60
60
  | Primitive | `Button`, `IconButton`, `Badge`, `Avatar`, `AvatarGroup`, `Spinner`, `FullPageSpinner`, `Tag`, `Divider`, `Logo` |
61
- | Form | `Input`, `SearchInput`, `Textarea`, `Select`, `Checkbox`, `RadioGroup`, `Switch`, `FormControl`, `OTPInput`, `PinInput`, `PhoneInput`, `DatePicker`, `DateRangePicker`, `Calendar`, `Combobox`, `FileUpload`, `TagsInput`, `TagInput`, `RichTextInput`, `RichTextEditor` |
61
+ | Form | `Input`, `SearchInput`, `Textarea`, `Select`, `Checkbox`, `RadioGroup`, `Switch`, `FormControl`, `OTPInput`, `PinInput`, `PhoneInput`, `DatePicker`, `DateRangePicker`, `Calendar`, `Combobox`, `FileUpload`, `TagsInput`, `TagInput`, `clearTextareaDraft`, `getTextareaDraft`, `saveTextareaDraft`, `RichTextInput`, `RichTextEditor`, `clearRichTextDraft`, `getRichTextDraft`, `saveRichTextDraft` |
62
62
  | Layout | `Card`, `CardHeader`, `CardBody`, `CardFooter`, `StatCard`, `Container`, `SectionHeader`, `ThemeColorPalette`, `DashboardLayout`, `Footer` |
63
63
  | Navigation | `Navbar`, `Breadcrumb`, `Tabs`, `Pagination`, `Stepper` |
64
64
  | Feedback | `Alert`, `Skeleton`, `SkeletonText`, `SkeletonCard`, `Progress`, `Modal`, `Drawer`, `Tooltip`, `EmptyState`, `NotFoundPage`, `ServerErrorPage`, `Toaster`, `toast`, `dismissToast`, `CookieConsentBanner`, `PWAInstallPrompt` |
@@ -209,30 +209,80 @@ The `Select` component supports native multiple selection, returning arrays on c
209
209
  />
210
210
  ```
211
211
 
212
+ ### Textarea
213
+
214
+ Multi-line text input with character limit tracking, error states, and **automatic draft persistence to `localStorage`** across page refreshes (`persistDraft = true`).
215
+
216
+ ```tsx
217
+ import { Textarea, clearTextareaDraft } from '@medixdeck/ui';
218
+
219
+ function SymptomForm() {
220
+ const [symptoms, setSymptoms] = React.useState('');
221
+
222
+ const handleSubmit = async (e: React.FormEvent) => {
223
+ e.preventDefault();
224
+ await submitSymptoms(symptoms);
225
+ // Clear saved draft from localStorage after successful submission
226
+ clearTextareaDraft('patient-symptoms-input');
227
+ setSymptoms('');
228
+ };
229
+
230
+ return (
231
+ <form onSubmit={handleSubmit}>
232
+ <Textarea
233
+ storageKey="patient-symptoms-input"
234
+ placeholder="Describe your symptoms in detail…"
235
+ rows={4}
236
+ maxLength={500}
237
+ showCount
238
+ showDraftStatus // displays "Saving draft..." / "Draft saved" in footer
239
+ value={symptoms}
240
+ onChange={(e) => setSymptoms(e.target.value)}
241
+ />
242
+ <button type="submit">Submit</button>
243
+ </form>
244
+ );
245
+ }
246
+ ```
247
+
212
248
  ### Rich Text Input (`RichTextInput` / `RichTextEditor`)
213
249
 
214
- A fully-featured rich text editor powered by TipTap (ProseMirror). Supports headings, formatting, lists, links, alignment, custom color schemes, character limit tracking, and height boundaries (`minHeight`, `maxHeight`).
250
+ A fully-featured rich text editor powered by TipTap (ProseMirror). Supports headings, formatting, lists, links, alignment, custom color schemes, character limit tracking, height boundaries (`minHeight`, `maxHeight`), and **automatic draft persistence to `localStorage`** across page refreshes.
215
251
 
216
252
  Requires optional peer dependencies (`@tiptap/*`).
217
253
 
218
254
  ```tsx
219
- import { RichTextInput } from '@medixdeck/ui';
255
+ import { RichTextInput, clearRichTextDraft } from '@medixdeck/ui';
220
256
 
221
257
  function NotesForm() {
222
- const [content, setContent] = React.useState('<p>Initial clinical note...</p>');
258
+ const [content, setContent] = React.useState('');
259
+
260
+ const handleSubmit = async (e: React.FormEvent) => {
261
+ e.preventDefault();
262
+ await saveNotesToApi(content);
263
+ // Clear the saved draft from localStorage upon successful submission
264
+ clearRichTextDraft('clinical-notes-form');
265
+ setContent('');
266
+ };
223
267
 
224
268
  return (
225
- <RichTextInput
226
- label="Clinical Notes"
227
- value={content}
228
- onChange={setContent}
229
- colorScheme="purple"
230
- placeholder="Type clinical notes..."
231
- minHeight="180px"
232
- maxHeight="400px"
233
- showCharCount
234
- maxLength={1000}
235
- />
269
+ <form onSubmit={handleSubmit}>
270
+ <RichTextInput
271
+ storageKey="clinical-notes-form"
272
+ label="Clinical Notes"
273
+ value={content}
274
+ onChange={setContent}
275
+ colorScheme="purple"
276
+ placeholder="Type clinical notes..."
277
+ minHeight="180px"
278
+ maxHeight="400px"
279
+ persistDraft // defaults to true
280
+ showDraftStatus // displays "Saving draft..." / "Draft saved" in footer
281
+ showCharCount
282
+ maxLength={1000}
283
+ />
284
+ <button type="submit">Save Notes</button>
285
+ </form>
236
286
  );
237
287
  }
238
288
  ```
@@ -306,17 +356,17 @@ export function Header() {
306
356
 
307
357
  ### `NavItem` properties
308
358
 
309
- | Prop | Type | Description |
310
- |---|---|---|
311
- | `label` | `string` | Display text for the item |
312
- | `href` | `string` | Target URL (optional for dropdown triggers) |
313
- | `children` | `NavItem[]` | Nested items for desktop floating menus and mobile accordions |
314
- | `description` | `string` | Subtitle text displayed below label in dropdown items |
315
- | `icon` | `ReactNode` | Leading icon element |
316
- | `badge` | `string \| number \| ReactNode` | Status tag or count (e.g. `"Popular"`, `"NDPR"`) |
317
- | `isActive` | `boolean` | Highlights active route item |
318
- | `isExternal` | `boolean` | Opens link in a new tab with an external arrow icon |
319
- | `onClick` | `() => void` | Optional click callback |
359
+ | Prop | Type | Description |
360
+ | ------------- | ------------------------------- | ------------------------------------------------------------- |
361
+ | `label` | `string` | Display text for the item |
362
+ | `href` | `string` | Target URL (optional for dropdown triggers) |
363
+ | `children` | `NavItem[]` | Nested items for desktop floating menus and mobile accordions |
364
+ | `description` | `string` | Subtitle text displayed below label in dropdown items |
365
+ | `icon` | `ReactNode` | Leading icon element |
366
+ | `badge` | `string \| number \| ReactNode` | Status tag or count (e.g. `"Popular"`, `"NDPR"`) |
367
+ | `isActive` | `boolean` | Highlights active route item |
368
+ | `isExternal` | `boolean` | Opens link in a new tab with an external arrow icon |
369
+ | `onClick` | `() => void` | Optional click callback |
320
370
 
321
371
  ---
322
372
 
@@ -333,6 +383,7 @@ import { DashboardLayout } from '@medixdeck/ui';
333
383
  items: [
334
384
  { label: 'Home', href: '/', isActive: true },
335
385
  { label: 'Messages', href: '/messages', badge: 6 },
386
+ { label: 'My Schedule', href: '/schedule', isNew: true },
336
387
  ],
337
388
  },
338
389
  {
@@ -350,6 +401,19 @@ import { DashboardLayout } from '@medixdeck/ui';
350
401
  </DashboardLayout>;
351
402
  ```
352
403
 
404
+ `DashboardNavItem` props:
405
+
406
+ | Prop | Type | Required | Description |
407
+ | ---------- | -------------------- | -------- | ------------------------------------------------------------------------------------------- |
408
+ | `label` | `string` | ✓ | Display label for the sidebar link |
409
+ | `href` | `string` | ✓ | Identifier or URL passed to `renderLink` and used as unique key |
410
+ | `icon` | `ReactNode` | — | Optional icon element |
411
+ | `badge` | `number` | — | Numeric count badge displayed to the right of the label |
412
+ | `hasDot` | `boolean` | — | Red dot indicator for unread alerts or notifications |
413
+ | `isNew` | `boolean` | — | "NEW" pill badge matching the active `colorScheme` (`blue` or `purple`) |
414
+ | `isActive` | `boolean` | — | Marks this item as the active navigation route |
415
+ | `subItems` | `DashboardNavItem[]` | — | Nested sub-links that expand/collapse in an accordion menu |
416
+
353
417
  ### Mobile bottom navigation (`mobileNavItems`)
354
418
 
355
419
  A fixed bottom tab bar (mobile only, hidden on `md+`). Uses `react-icons/lu` or any icon component.
@@ -470,15 +534,15 @@ It is completely safe across SSR and CSR runtimes (Next.js App/Pages Router, Vit
470
534
 
471
535
  `DashboardEnvironmentBannerConfig` props:
472
536
 
473
- | Prop | Type | Default | Description |
474
- |---|---|---|---|
475
- | `environment` | `"auto" \| "production" \| "live" \| "sandbox" \| "test" \| "development" \| "staging" \| "preview"` | `"auto"` | Environment classification |
476
- | `badgeLabel` | `string` | auto | Uppercase badge label (e.g., `"SANDBOX ENVIRONMENT"`) |
477
- | `message` | `string` | auto | Descriptive warning / notice text |
478
- | `status` | `"warning" \| "info" \| "error" \| "neutral"` | auto | Visual color scheme (amber warning, blue info, red error) |
479
- | `action` | `ReactNode` | — | Action link or button on the right |
480
- | `dismissible` | `boolean` | `false` | Shows a close (✕) button |
481
- | `onDismiss` | `() => void` | — | Called when the close button is clicked |
537
+ | Prop | Type | Default | Description |
538
+ | ------------- | ---------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------------------- |
539
+ | `environment` | `"auto" \| "production" \| "live" \| "sandbox" \| "test" \| "development" \| "staging" \| "preview"` | `"auto"` | Environment classification |
540
+ | `badgeLabel` | `string` | auto | Uppercase badge label (e.g., `"SANDBOX ENVIRONMENT"`) |
541
+ | `message` | `string` | auto | Descriptive warning / notice text |
542
+ | `status` | `"warning" \| "info" \| "error" \| "neutral"` | auto | Visual color scheme (amber warning, blue info, red error) |
543
+ | `action` | `ReactNode` | — | Action link or button on the right |
544
+ | `dismissible` | `boolean` | `false` | Shows a close (✕) button |
545
+ | `onDismiss` | `() => void` | — | Called when the close button is clicked |
482
546
 
483
547
  ### Collapsible Sidebar (`collapsible`, `isCollapsed`, `onCollapseChange`)
484
548
 
@@ -491,14 +555,9 @@ On desktop (`md+`), `DashboardLayout` supports shrinking the sidebar into a comp
491
555
 
492
556
  ```tsx
493
557
  // 1. Uncontrolled with default expanded or collapsed
494
- <DashboardLayout
495
- collapsible={true}
496
- defaultCollapsed={false}
497
- user={user}
498
- navGroups={navGroups}
499
- >
558
+ <DashboardLayout collapsible={true} defaultCollapsed={false} user={user} navGroups={navGroups}>
500
559
  {children}
501
- </DashboardLayout>
560
+ </DashboardLayout>;
502
561
 
503
562
  // 2. Controlled collapse state
504
563
  function App() {
@@ -521,32 +580,32 @@ function App() {
521
580
 
522
581
  ### All `DashboardLayout` props
523
582
 
524
- | Prop | Type | Default | Description |
525
- | ------------------------ | ----------------------------------- | ---------- | --------------------------------------------- |
526
- | `user` | `DashboardUser` | — | Name, email, optional avatar |
527
- | `navGroups` | `DashboardNavGroup[]` | — | Sidebar navigation tree |
528
- | `collapsible` | `boolean` | `true` | Enables collapsible sidebar icon rail |
529
- | `defaultCollapsed` | `boolean` | `false` | Initial collapsed state (uncontrolled) |
530
- | `isCollapsed` | `boolean` | — | Controlled collapsed state |
531
- | `onCollapseChange` | `(collapsed: boolean) => void` | — | Fired when sidebar collapse state toggles |
532
- | `sidebarWidth` | `number` | `220` | Full sidebar width in px |
533
- | `collapsedSidebarWidth` | `number` | `68` | Compact icon rail width in px |
534
- | `collapseTogglePlacement`| `"sidebar-header" \| "topbar" \| "both" \| "none"` | `"sidebar-header"` | Placement of collapse/expand toggle buttons |
535
- | `collapsedLogo` | `ReactNode` | `<Logo type="icon" />` | Custom logo displayed in collapsed mode |
536
- | `colorScheme` | `"blue" \| "purple"` | `"blue"` | Brand accent colour |
537
- | `environment` | `DashboardEnvironment` | `"auto"` | Auto-detects test/sandbox/staging environments |
538
- | `showEnvironmentBanner` | `boolean` | auto | Force show (`true`) or suppress (`false`) banner |
539
- | `environmentBanner` | `DashboardEnvironmentBannerConfig` | — | Detailed banner message, action, & dismiss config |
540
- | `environmentBannerSlot` | `ReactNode` | — | Custom slot overriding the entire banner |
541
- | `logo` | `ReactNode` | `<Logo />` | Override the sidebar logo |
542
- | `greeting` | `string` | auto | Override "Good morning / afternoon / evening" |
543
- | `greetingSubtext` | `string` | — | Subtitle line below the greeting |
544
- | `mobileNavItems` | `DashboardMobileNavItem[]` | — | Mobile bottom tab bar items |
545
- | `scoreCard` | `DashboardScoreCardData` | — | Doctor identity card (desktop only) |
546
- | `topBarSlot` | `ReactNode` | — | Slot right of greeting (search, bell, etc.) |
547
- | `dropdownItems` | `DashboardDropdownItem[]` | — | Extra user dropdown items |
548
- | `renderLink` | `(item, children) => ReactNode` | `<a>` | Router integration |
549
- | `onLogout` | `() => void` | — | Logout callback |
583
+ | Prop | Type | Default | Description |
584
+ | ------------------------- | -------------------------------------------------- | ---------------------- | ------------------------------------------------- |
585
+ | `user` | `DashboardUser` | — | Name, email, optional avatar |
586
+ | `navGroups` | `DashboardNavGroup[]` | — | Sidebar navigation tree |
587
+ | `collapsible` | `boolean` | `true` | Enables collapsible sidebar icon rail |
588
+ | `defaultCollapsed` | `boolean` | `false` | Initial collapsed state (uncontrolled) |
589
+ | `isCollapsed` | `boolean` | — | Controlled collapsed state |
590
+ | `onCollapseChange` | `(collapsed: boolean) => void` | — | Fired when sidebar collapse state toggles |
591
+ | `sidebarWidth` | `number` | `220` | Full sidebar width in px |
592
+ | `collapsedSidebarWidth` | `number` | `68` | Compact icon rail width in px |
593
+ | `collapseTogglePlacement` | `"sidebar-header" \| "topbar" \| "both" \| "none"` | `"sidebar-header"` | Placement of collapse/expand toggle buttons |
594
+ | `collapsedLogo` | `ReactNode` | `<Logo type="icon" />` | Custom logo displayed in collapsed mode |
595
+ | `colorScheme` | `"blue" \| "purple"` | `"blue"` | Brand accent colour |
596
+ | `environment` | `DashboardEnvironment` | `"auto"` | Auto-detects test/sandbox/staging environments |
597
+ | `showEnvironmentBanner` | `boolean` | auto | Force show (`true`) or suppress (`false`) banner |
598
+ | `environmentBanner` | `DashboardEnvironmentBannerConfig` | — | Detailed banner message, action, & dismiss config |
599
+ | `environmentBannerSlot` | `ReactNode` | — | Custom slot overriding the entire banner |
600
+ | `logo` | `ReactNode` | `<Logo />` | Override the sidebar logo |
601
+ | `greeting` | `string` | auto | Override "Good morning / afternoon / evening" |
602
+ | `greetingSubtext` | `string` | — | Subtitle line below the greeting |
603
+ | `mobileNavItems` | `DashboardMobileNavItem[]` | — | Mobile bottom tab bar items |
604
+ | `scoreCard` | `DashboardScoreCardData` | — | Doctor identity card (desktop only) |
605
+ | `topBarSlot` | `ReactNode` | — | Slot right of greeting (search, bell, etc.) |
606
+ | `dropdownItems` | `DashboardDropdownItem[]` | — | Extra user dropdown items |
607
+ | `renderLink` | `(item, children) => ReactNode` | `<a>` | Router integration |
608
+ | `onLogout` | `() => void` | — | Logout callback |
550
609
 
551
610
  ## Footer
552
611