@slipstream-ui/core 0.3.0 → 0.5.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 (181) hide show
  1. package/dist/index.d.mts +957 -56
  2. package/dist/index.d.ts +957 -56
  3. package/dist/index.js +2554 -777
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +2524 -777
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/manifests/app-shell.manifest.json +206 -0
  8. package/dist/manifests/auth-layout.manifest.json +99 -0
  9. package/dist/manifests/autocomplete.manifest.json +53 -5
  10. package/dist/manifests/badge.manifest.json +20 -3
  11. package/dist/manifests/breadcrumb.manifest.json +6 -0
  12. package/dist/manifests/button.manifest.json +20 -2
  13. package/dist/manifests/card.manifest.json +53 -6
  14. package/dist/manifests/confirm-dialog.manifest.json +132 -0
  15. package/dist/manifests/data-table.manifest.json +50 -0
  16. package/dist/manifests/date-picker.manifest.json +87 -0
  17. package/dist/manifests/dialog.manifest.json +56 -4
  18. package/dist/manifests/drawer.manifest.json +25 -4
  19. package/dist/manifests/empty-state.manifest.json +108 -0
  20. package/dist/manifests/file-upload.manifest.json +103 -0
  21. package/dist/manifests/filter-bar.manifest.json +100 -0
  22. package/dist/manifests/link.manifest.json +106 -0
  23. package/dist/manifests/menu.manifest.json +13 -1
  24. package/dist/manifests/metric-card.manifest.json +105 -0
  25. package/dist/manifests/page-header.manifest.json +124 -0
  26. package/dist/manifests/pagination.manifest.json +68 -34
  27. package/dist/manifests/password-input.manifest.json +75 -0
  28. package/dist/manifests/prose.manifest.json +75 -0
  29. package/dist/manifests/search.manifest.json +41 -9
  30. package/dist/manifests/section-heading.manifest.json +108 -0
  31. package/dist/manifests/select-menu.manifest.json +142 -0
  32. package/dist/manifests/select.manifest.json +55 -12
  33. package/dist/manifests/site-footer.manifest.json +94 -0
  34. package/dist/manifests/site-header.manifest.json +130 -0
  35. package/dist/manifests/stepper.manifest.json +95 -0
  36. package/dist/manifests/table-card.manifest.json +123 -0
  37. package/dist/manifests/table-of-contents.manifest.json +87 -0
  38. package/dist/manifests/time-picker.manifest.json +86 -0
  39. package/dist/manifests/timeline.manifest.json +69 -0
  40. package/dist/manifests/toast.manifest.json +101 -25
  41. package/package.json +2 -2
  42. package/src/components/alert/Alert.tsx +2 -2
  43. package/src/components/app-shell/AppShell.test.tsx +148 -0
  44. package/src/components/app-shell/AppShell.tsx +266 -0
  45. package/src/components/app-shell/index.ts +1 -0
  46. package/src/components/auth-layout/AuthLayout.test.tsx +34 -0
  47. package/src/components/auth-layout/AuthLayout.tsx +47 -0
  48. package/src/components/auth-layout/index.ts +1 -0
  49. package/src/components/autocomplete/Autocomplete.test.tsx +53 -0
  50. package/src/components/autocomplete/Autocomplete.tsx +160 -41
  51. package/src/components/badge/Badge.test.tsx +35 -0
  52. package/src/components/badge/Badge.tsx +16 -4
  53. package/src/components/breadcrumb/Breadcrumb.test.tsx +16 -0
  54. package/src/components/breadcrumb/Breadcrumb.tsx +10 -5
  55. package/src/components/button/Button.test.tsx +67 -0
  56. package/src/components/button/Button.tsx +37 -3
  57. package/src/components/button-group/ButtonGroup.test.tsx +6 -8
  58. package/src/components/button-group/ButtonGroup.tsx +17 -9
  59. package/src/components/card/Card.test.tsx +14 -0
  60. package/src/components/card/Card.tsx +15 -8
  61. package/src/components/confirm-dialog/ConfirmDialog.test.tsx +46 -0
  62. package/src/components/confirm-dialog/ConfirmDialog.tsx +86 -0
  63. package/src/components/confirm-dialog/index.ts +1 -0
  64. package/src/components/data-table/DataTable.test.tsx +92 -0
  65. package/src/components/data-table/DataTable.tsx +98 -7
  66. package/src/components/date-picker/DatePicker.test.tsx +30 -0
  67. package/src/components/date-picker/DatePicker.tsx +57 -0
  68. package/src/components/date-picker/index.ts +1 -0
  69. package/src/components/dialog/Dialog.test.tsx +71 -1
  70. package/src/components/dialog/Dialog.tsx +116 -23
  71. package/src/components/dialog/index.ts +1 -2
  72. package/src/components/drawer/Drawer.test.tsx +59 -0
  73. package/src/components/drawer/Drawer.tsx +49 -8
  74. package/src/components/empty-state/EmptyState.test.tsx +30 -0
  75. package/src/components/empty-state/EmptyState.tsx +48 -0
  76. package/src/components/empty-state/index.ts +1 -0
  77. package/src/components/file-upload/FileUpload.test.tsx +43 -0
  78. package/src/components/file-upload/FileUpload.tsx +143 -0
  79. package/src/components/file-upload/index.ts +1 -0
  80. package/src/components/filter-bar/FilterBar.test.tsx +32 -0
  81. package/src/components/filter-bar/FilterBar.tsx +71 -0
  82. package/src/components/filter-bar/index.ts +1 -0
  83. package/src/components/input/Input.tsx +1 -0
  84. package/src/components/input-group/InputGroup.test.tsx +6 -3
  85. package/src/components/input-group/InputGroup.tsx +9 -6
  86. package/src/components/link/Link.test.tsx +60 -0
  87. package/src/components/link/Link.tsx +85 -0
  88. package/src/components/link/index.ts +1 -0
  89. package/src/components/menu/Menu.test.tsx +21 -0
  90. package/src/components/menu/Menu.tsx +8 -3
  91. package/src/components/metric-card/MetricCard.test.tsx +28 -0
  92. package/src/components/metric-card/MetricCard.tsx +54 -0
  93. package/src/components/metric-card/index.ts +1 -0
  94. package/src/components/page-header/PageHeader.test.tsx +48 -0
  95. package/src/components/page-header/PageHeader.tsx +53 -0
  96. package/src/components/page-header/index.ts +1 -0
  97. package/src/components/pagination/Pagination.test.tsx +33 -0
  98. package/src/components/pagination/Pagination.tsx +69 -18
  99. package/src/components/password-input/PasswordInput.test.tsx +29 -0
  100. package/src/components/password-input/PasswordInput.tsx +41 -0
  101. package/src/components/password-input/index.ts +1 -0
  102. package/src/components/prose/Prose.test.tsx +35 -0
  103. package/src/components/prose/Prose.tsx +61 -0
  104. package/src/components/prose/index.ts +1 -0
  105. package/src/components/search/Search.test.tsx +16 -0
  106. package/src/components/search/Search.tsx +11 -2
  107. package/src/components/section-heading/SectionHeading.test.tsx +32 -0
  108. package/src/components/section-heading/SectionHeading.tsx +54 -0
  109. package/src/components/section-heading/index.ts +1 -0
  110. package/src/components/select/Select.test.tsx +40 -1
  111. package/src/components/select/Select.tsx +54 -14
  112. package/src/components/select/index.ts +1 -1
  113. package/src/components/select-menu/SelectMenu.test.tsx +105 -0
  114. package/src/components/select-menu/SelectMenu.tsx +368 -0
  115. package/src/components/select-menu/index.ts +1 -0
  116. package/src/components/site-footer/SiteFooter.test.tsx +30 -0
  117. package/src/components/site-footer/SiteFooter.tsx +79 -0
  118. package/src/components/site-footer/index.ts +1 -0
  119. package/src/components/site-header/SiteHeader.test.tsx +53 -0
  120. package/src/components/site-header/SiteHeader.tsx +124 -0
  121. package/src/components/site-header/index.ts +1 -0
  122. package/src/components/stepper/Stepper.test.tsx +35 -0
  123. package/src/components/stepper/Stepper.tsx +91 -0
  124. package/src/components/stepper/index.ts +1 -0
  125. package/src/components/switch/Switch.test.tsx +10 -0
  126. package/src/components/switch/Switch.tsx +8 -3
  127. package/src/components/table-card/TableCard.test.tsx +59 -0
  128. package/src/components/table-card/TableCard.tsx +48 -0
  129. package/src/components/table-card/index.ts +1 -0
  130. package/src/components/table-of-contents/TableOfContents.test.tsx +31 -0
  131. package/src/components/table-of-contents/TableOfContents.tsx +100 -0
  132. package/src/components/table-of-contents/index.ts +1 -0
  133. package/src/components/textarea/Textarea.tsx +1 -0
  134. package/src/components/time-picker/TimePicker.test.tsx +30 -0
  135. package/src/components/time-picker/TimePicker.tsx +56 -0
  136. package/src/components/time-picker/index.ts +1 -0
  137. package/src/components/timeline/Timeline.test.tsx +26 -0
  138. package/src/components/timeline/Timeline.tsx +53 -0
  139. package/src/components/timeline/index.ts +1 -0
  140. package/src/components/toast/Toast.test.tsx +5 -0
  141. package/src/components/toast/Toast.tsx +2 -16
  142. package/src/components/toast/Toaster.test.tsx +84 -0
  143. package/src/components/toast/Toaster.tsx +116 -0
  144. package/src/components/toast/index.ts +4 -0
  145. package/src/components/toast/toast-store.ts +117 -0
  146. package/src/index.ts +21 -0
  147. package/src/manifests/app-shell.manifest.json +206 -0
  148. package/src/manifests/auth-layout.manifest.json +99 -0
  149. package/src/manifests/autocomplete.manifest.json +53 -5
  150. package/src/manifests/badge.manifest.json +20 -3
  151. package/src/manifests/breadcrumb.manifest.json +6 -0
  152. package/src/manifests/button.manifest.json +20 -2
  153. package/src/manifests/card.manifest.json +53 -6
  154. package/src/manifests/confirm-dialog.manifest.json +132 -0
  155. package/src/manifests/data-table.manifest.json +50 -0
  156. package/src/manifests/date-picker.manifest.json +87 -0
  157. package/src/manifests/dialog.manifest.json +56 -4
  158. package/src/manifests/drawer.manifest.json +25 -4
  159. package/src/manifests/empty-state.manifest.json +108 -0
  160. package/src/manifests/file-upload.manifest.json +103 -0
  161. package/src/manifests/filter-bar.manifest.json +100 -0
  162. package/src/manifests/link.manifest.json +106 -0
  163. package/src/manifests/menu.manifest.json +13 -1
  164. package/src/manifests/metric-card.manifest.json +105 -0
  165. package/src/manifests/page-header.manifest.json +124 -0
  166. package/src/manifests/pagination.manifest.json +68 -34
  167. package/src/manifests/password-input.manifest.json +75 -0
  168. package/src/manifests/prose.manifest.json +75 -0
  169. package/src/manifests/search.manifest.json +41 -9
  170. package/src/manifests/section-heading.manifest.json +108 -0
  171. package/src/manifests/select-menu.manifest.json +142 -0
  172. package/src/manifests/select.manifest.json +55 -12
  173. package/src/manifests/site-footer.manifest.json +94 -0
  174. package/src/manifests/site-header.manifest.json +130 -0
  175. package/src/manifests/stepper.manifest.json +95 -0
  176. package/src/manifests/table-card.manifest.json +123 -0
  177. package/src/manifests/table-of-contents.manifest.json +87 -0
  178. package/src/manifests/time-picker.manifest.json +86 -0
  179. package/src/manifests/timeline.manifest.json +69 -0
  180. package/src/manifests/toast.manifest.json +101 -25
  181. package/src/test/tailwind-v4.test.ts +103 -0
@@ -0,0 +1,53 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+
4
+ export type PageHeaderProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ title: string;
6
+ description?: string;
7
+ /** Breadcrumbs/eyebrow above the title. */
8
+ breadcrumbs?: React.ReactNode;
9
+ /** Right-aligned actions (buttons, menus). */
10
+ actions?: React.ReactNode;
11
+ /** Small slot under the title row (tabs, filters). */
12
+ children?: React.ReactNode;
13
+ /** Eyebrow/kicker above the title (category, date, overline). */
14
+ eyebrow?: React.ReactNode;
15
+ /** Heading scale — 'hero' is for marketing landing pages. */
16
+ size?: 'sm' | 'md' | 'lg' | 'hero';
17
+ /** Text alignment; hero marketing pages often center. */
18
+ align?: 'left' | 'center';
19
+ };
20
+
21
+ const sizeClasses: Record<NonNullable<PageHeaderProps['size']>, string> = {
22
+ sm: 'text-xl',
23
+ md: 'text-2xl',
24
+ lg: 'text-3xl',
25
+ hero: 'text-4xl sm:text-5xl lg:text-[3.4rem] lg:leading-[1.1]',
26
+ };
27
+
28
+ /**
29
+ * Standard page heading block: optional breadcrumbs, title, description and
30
+ * a right-aligned action cluster. Pages stop inventing their own spacing
31
+ * and heading hierarchy.
32
+ */
33
+ export const PageHeader = React.forwardRef<HTMLDivElement, PageHeaderProps>(function PageHeader(
34
+ { title, description, breadcrumbs, actions, eyebrow, size = 'md', align = 'left', className, children, ...props },
35
+ ref
36
+ ) {
37
+ return (
38
+ <div ref={ref} className={cn('flex flex-col gap-2', align === 'center' && 'items-center text-center', className)} {...props}>
39
+ {breadcrumbs && <div className="text-sm text-muted-foreground">{breadcrumbs}</div>}
40
+ {eyebrow && (
41
+ <p className="text-xs font-medium uppercase tracking-wide text-primary">{eyebrow}</p>
42
+ )}
43
+ <div className={cn('flex w-full flex-wrap items-start justify-between gap-3', align === 'center' && 'justify-center')}>
44
+ <div className={cn('min-w-0', align === 'center' && 'flex flex-col items-center')}>
45
+ <h1 className={cn('font-semibold tracking-tight', sizeClasses[size])}>{title}</h1>
46
+ {description && <p className="mt-2 max-w-2xl text-base text-muted-foreground">{description}</p>}
47
+ </div>
48
+ {actions && <div className="flex shrink-0 items-center gap-2">{actions}</div>}
49
+ </div>
50
+ {children && <div className="mt-2">{children}</div>}
51
+ </div>
52
+ );
53
+ });
@@ -0,0 +1 @@
1
+ export * from './PageHeader';
@@ -88,3 +88,36 @@ describe('Pagination boundaries and icons', () => {
88
88
  expect(screen.getByRole('button', { name: 'Last page' })).toHaveTextContent('⏭');
89
89
  });
90
90
  });
91
+
92
+
93
+ describe('Pagination contracts and summary', () => {
94
+ it('accepts currentPage/totalPages aliases', () => {
95
+ render(<Pagination currentPage={3} totalPages={5} />);
96
+ expect(screen.getByRole('button', { name: 'Page 3' })).toHaveAttribute('aria-current', 'page');
97
+ expect(screen.getByRole('button', { name: 'Page 5' })).toBeInTheDocument();
98
+ });
99
+
100
+ it('derives the page count and renders a summary from total/pageSize', () => {
101
+ render(<Pagination page={2} pageSize={25} total={312} itemLabel="students" />);
102
+ expect(screen.getByText('Showing 26–50 of 312 students')).toBeInTheDocument();
103
+ expect(screen.getByRole('button', { name: 'Page 13' })).toBeInTheDocument();
104
+ });
105
+
106
+ it('can hide the summary explicitly', () => {
107
+ render(<Pagination page={1} pageSize={10} total={40} showSummary={false} />);
108
+ expect(screen.queryByText(/Showing/)).not.toBeInTheDocument();
109
+ });
110
+
111
+ it('falls back to a page summary when totals are absent', () => {
112
+ render(<Pagination page={2} currentPage={2} pageSize={10} total={40} itemLabel="rows" />);
113
+ expect(screen.getByText('Showing 11–20 of 40 rows')).toBeInTheDocument();
114
+ });
115
+ });
116
+
117
+ describe('localized labels', () => {
118
+ it('uses the landmark and control overrides', () => {
119
+ render(<Pagination page={1} pageCount={3} labels={{ pagination: 'Pagination FR', next: 'Suivant' }} />);
120
+ expect(screen.getByRole('navigation', { name: 'Pagination FR' })).toBeInTheDocument();
121
+ expect(screen.getByRole('button', { name: 'Suivant' })).toBeInTheDocument();
122
+ });
123
+ });
@@ -15,10 +15,22 @@ export type PaginationIcons = {
15
15
  };
16
16
 
17
17
  export type PaginationProps = React.HTMLAttributes<HTMLElement> & {
18
- /** Current page number (1-based). */
19
- page: number;
20
- /** Total number of pages. */
21
- pageCount: number;
18
+ /** Current page number (1-based). Alias: currentPage. */
19
+ page?: number;
20
+ /** Total number of pages. Alias: totalPages (or derived from total/pageSize). */
21
+ pageCount?: number;
22
+ /** Alias for page (migration-friendly). */
23
+ currentPage?: number;
24
+ /** Alias for pageCount. */
25
+ totalPages?: number;
26
+ /** Rows per page — with `total`, enables the item-count summary. */
27
+ pageSize?: number;
28
+ /** Total item count — with `pageSize`, enables the summary and derives pageCount. */
29
+ total?: number;
30
+ /** Noun used in the summary ("Showing 26–50 of 312 classes"). Default "items". */
31
+ itemLabel?: string;
32
+ /** Force the summary on/off; defaults to on when total and pageSize are set. */
33
+ showSummary?: boolean;
22
34
  /** Called with the new page number. */
23
35
  onPageChange?: (page: number) => void;
24
36
  /** How many page buttons to show around the current page (default 1). */
@@ -31,6 +43,15 @@ export type PaginationProps = React.HTMLAttributes<HTMLElement> & {
31
43
  showLast?: boolean;
32
44
  /** Replace the default ‹ › « » glyphs. */
33
45
  icons?: PaginationIcons;
46
+ /** Localized landmark and control labels. */
47
+ labels?: {
48
+ pagination?: string;
49
+ first?: string;
50
+ previous?: string;
51
+ next?: string;
52
+ last?: string;
53
+ page?: (page: number) => string;
54
+ };
34
55
  };
35
56
 
36
57
  const controlClass =
@@ -38,27 +59,39 @@ const controlClass =
38
59
 
39
60
  /**
40
61
  * Numeric pagination with prev/next and optional boundary jumps. Renders
41
- * as a nav landmark with aria-current="page" on the active button. Each
42
- * control is a real <button> with an accessible name; glyphs are
43
- * swappable and each boundary button can be shown or hidden independently
44
- * (e.g. hide — instead of disabling — once you reach the list edge).
62
+ * as a nav landmark with aria-current="page" on the active button. Accepts
63
+ * either page/pageCount or the currentPage/totalPages aliases, and can
64
+ * derive the page count (plus a "Showing X–Y of Z" summary) from
65
+ * total/pageSize.
45
66
  */
46
67
  const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
47
68
  (
48
69
  {
49
- page,
50
- pageCount,
70
+ page: pageProp,
71
+ pageCount: pageCountProp,
72
+ currentPage,
73
+ totalPages,
74
+ pageSize,
75
+ total,
76
+ itemLabel = 'items',
77
+ showSummary,
51
78
  onPageChange,
52
79
  siblings = 1,
53
80
  showBoundaries = false,
54
81
  showFirst,
55
82
  showLast,
56
83
  icons,
84
+ labels,
57
85
  className,
58
86
  ...props
59
87
  },
60
88
  ref
61
89
  ) => {
90
+ const page = pageProp ?? currentPage ?? 1;
91
+ const derivedPageCount =
92
+ total !== undefined && pageSize !== undefined && pageSize > 0 ? Math.ceil(total / pageSize) : undefined;
93
+ const pageCount = Math.max(1, pageCountProp ?? totalPages ?? derivedPageCount ?? 1);
94
+
62
95
  // Build the page number list with ellipsis markers.
63
96
  const pages: (number | 'ellipsis')[] = [];
64
97
  const start = Math.max(2, page - siblings);
@@ -73,11 +106,16 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
73
106
  const withFirst = showFirst ?? showBoundaries;
74
107
  const withLast = showLast ?? showBoundaries;
75
108
 
76
- return (
109
+ const summaryEnabled = showSummary ?? (total !== undefined && pageSize !== undefined);
110
+ const rangeStart = pageSize !== undefined ? (page - 1) * pageSize + 1 : undefined;
111
+ const rangeEnd =
112
+ pageSize !== undefined && total !== undefined ? Math.min(total, page * pageSize) : undefined;
113
+
114
+ const nav = (
77
115
  <nav
78
116
  ref={ref}
79
- aria-label="Pagination"
80
- className={cn('flex items-center justify-center gap-1', className)}
117
+ aria-label={labels?.pagination ?? 'Pagination'}
118
+ className={cn('flex items-center justify-center gap-1', summaryEnabled ? undefined : className)}
81
119
  {...props}
82
120
  >
83
121
  {withFirst && (
@@ -85,7 +123,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
85
123
  type="button"
86
124
  onClick={() => onPageChange?.(1)}
87
125
  disabled={page <= 1}
88
- aria-label="First page"
126
+ aria-label={labels?.first ?? 'First page'}
89
127
  className={controlClass}
90
128
  >
91
129
  {icons?.first ?? '«'}
@@ -95,7 +133,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
95
133
  type="button"
96
134
  onClick={() => onPageChange?.(page - 1)}
97
135
  disabled={page <= 1}
98
- aria-label="Previous page"
136
+ aria-label={labels?.previous ?? 'Previous page'}
99
137
  className={controlClass}
100
138
  >
101
139
  {icons?.previous ?? '‹'}
@@ -115,7 +153,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
115
153
  type="button"
116
154
  onClick={() => onPageChange?.(entry)}
117
155
  aria-current={entry === page ? 'page' : undefined}
118
- aria-label={`Page ${entry}`}
156
+ aria-label={labels?.page?.(entry) ?? `Page ${entry}`}
119
157
  className={cn(
120
158
  'inline-flex h-8 w-8 items-center justify-center rounded-md border text-sm transition-colors',
121
159
  'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
@@ -132,7 +170,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
132
170
  type="button"
133
171
  onClick={() => onPageChange?.(page + 1)}
134
172
  disabled={page >= pageCount}
135
- aria-label="Next page"
173
+ aria-label={labels?.next ?? 'Next page'}
136
174
  className={controlClass}
137
175
  >
138
176
  {icons?.next ?? '›'}
@@ -142,7 +180,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
142
180
  type="button"
143
181
  onClick={() => onPageChange?.(pageCount)}
144
182
  disabled={page >= pageCount}
145
- aria-label="Last page"
183
+ aria-label={labels?.last ?? 'Last page'}
146
184
  className={controlClass}
147
185
  >
148
186
  {icons?.last ?? '»'}
@@ -150,6 +188,19 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
150
188
  )}
151
189
  </nav>
152
190
  );
191
+
192
+ if (!summaryEnabled) return nav;
193
+
194
+ return (
195
+ <div className={cn('flex flex-wrap items-center justify-between gap-3', className)}>
196
+ <p className="text-sm text-muted-foreground">
197
+ {rangeStart !== undefined && rangeEnd !== undefined && total !== undefined
198
+ ? `Showing ${rangeStart}–${rangeEnd} of ${total} ${itemLabel}`
199
+ : `Page ${page} of ${pageCount}`}
200
+ </p>
201
+ {nav}
202
+ </div>
203
+ );
153
204
  }
154
205
  );
155
206
  Pagination.displayName = 'Pagination';
@@ -0,0 +1,29 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { axe } from 'jest-axe';
4
+ import { describe, expect, it } from 'vitest';
5
+ import { PasswordInput } from './PasswordInput';
6
+
7
+ describe('PasswordInput', () => {
8
+ it('toggles visibility with an accessible pressed button', async () => {
9
+ const user = userEvent.setup();
10
+ render(<PasswordInput aria-label="Password" defaultValue="hunter2" />);
11
+ const input = screen.getByLabelText('Password');
12
+ expect(input).toHaveAttribute('type', 'password');
13
+ const toggle = screen.getByRole('button', { name: 'Show password' });
14
+ expect(toggle).toHaveAttribute('aria-pressed', 'false');
15
+ await user.click(toggle);
16
+ expect(input).toHaveAttribute('type', 'text');
17
+ expect(screen.getByRole('button', { name: 'Hide password' })).toHaveAttribute('aria-pressed', 'true');
18
+ });
19
+
20
+ it('supports custom toggle labels', () => {
21
+ render(<PasswordInput aria-label="Passphrase" showLabel="Reveal" hideLabel="Conceal" />);
22
+ expect(screen.getByRole('button', { name: 'Reveal' })).toBeInTheDocument();
23
+ });
24
+
25
+ it('has no accessibility violations', async () => {
26
+ const { container } = render(<PasswordInput aria-label="Password" />);
27
+ expect(await axe(container)).toHaveNoViolations();
28
+ });
29
+ });
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { cn } from '../../utils/cn';
5
+ import { Button } from '../button/Button';
6
+ import { Input, type InputProps } from '../input/Input';
7
+
8
+ export type PasswordInputProps = Omit<InputProps, 'type'> & {
9
+ /** Accessible labels for the visibility toggle. */
10
+ showLabel?: string;
11
+ hideLabel?: string;
12
+ };
13
+
14
+ /**
15
+ * Password field with a show/hide toggle. The toggle is a real button with
16
+ * pressed state, so keyboard and screen-reader users can reveal the value
17
+ * without losing the focused field.
18
+ */
19
+ export const PasswordInput = React.forwardRef<HTMLInputElement, PasswordInputProps>(function PasswordInput(
20
+ { className, showLabel = 'Show password', hideLabel = 'Hide password', ...props },
21
+ ref
22
+ ) {
23
+ const [visible, setVisible] = React.useState(false);
24
+
25
+ return (
26
+ <div className={cn('relative flex items-center', className)}>
27
+ <Input ref={ref} type={visible ? 'text' : 'password'} className="pr-24" {...props} />
28
+ <Button
29
+ type="button"
30
+ variant="ghost"
31
+ size="sm"
32
+ aria-pressed={visible}
33
+ aria-label={visible ? hideLabel : showLabel}
34
+ onClick={() => setVisible((current) => !current)}
35
+ className="absolute right-1 h-8 px-2 text-xs text-muted-foreground hover:text-foreground"
36
+ >
37
+ {visible ? 'Hide' : 'Show'}
38
+ </Button>
39
+ </div>
40
+ );
41
+ });
@@ -0,0 +1 @@
1
+ export * from './PasswordInput';
@@ -0,0 +1,35 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { axe } from 'jest-axe';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { Prose } from './Prose';
5
+
6
+ describe('Prose', () => {
7
+ it('styles rendered markdown elements', () => {
8
+ const { container } = render(
9
+ <Prose>
10
+ <h2>Heading</h2>
11
+ <p>Body <a href="/x">link</a> <code>inline()</code></p>
12
+ <ul><li>one</li></ul>
13
+ <pre><code>const x = 1;</code></pre>
14
+ <blockquote>quote</blockquote>
15
+ <table><thead><tr><th>H</th></tr></thead><tbody><tr><td>C</td></tr></tbody></table>
16
+ </Prose>
17
+ );
18
+ const root = container.firstChild as HTMLElement;
19
+ expect(root.className).toContain('[&_h2]:font-semibold');
20
+ expect(root.className).toContain('[&_pre]:overflow-x-auto');
21
+ expect(root.className).toContain('[&_table]:w-full');
22
+ expect(screen.getByRole('heading', { name: 'Heading' })).toBeInTheDocument();
23
+ expect(screen.getByRole('link', { name: 'link' })).toBeInTheDocument();
24
+ });
25
+
26
+ it('supports size presets', () => {
27
+ const { container } = render(<Prose size="lg"><p>x</p></Prose>);
28
+ expect((container.firstChild as HTMLElement).className).toContain('text-lg');
29
+ });
30
+
31
+ it('has no accessibility violations', async () => {
32
+ const { container } = render(<Prose><h2>Title</h2><p>Copy</p></Prose>);
33
+ expect(await axe(container)).toHaveNoViolations();
34
+ });
35
+ });
@@ -0,0 +1,61 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+
4
+ export type ProseProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ /** Type scale. Default 'md'. */
6
+ size?: 'sm' | 'md' | 'lg';
7
+ };
8
+
9
+ const sizeClasses: Record<NonNullable<ProseProps['size']>, string> = {
10
+ sm: 'text-sm [&_h2]:text-xl [&_h3]:text-lg',
11
+ md: 'text-base [&_h2]:text-2xl [&_h3]:text-xl',
12
+ lg: 'text-lg [&_h2]:text-3xl [&_h3]:text-2xl',
13
+ };
14
+
15
+ /**
16
+ * Long-form content typography for rendered markdown/MDX output.
17
+ *
18
+ * Self-contained (no @tailwindcss/typography dependency): element styles ride
19
+ * on child selectors, so any MDX/remark renderer can drop its output inside.
20
+ * Keeps the content pipeline (Shiki, KaTeX, Mermaid) untouched.
21
+ */
22
+ export const Prose = React.forwardRef<HTMLDivElement, ProseProps>(function Prose(
23
+ { size = 'md', className, ...props },
24
+ ref
25
+ ) {
26
+ return (
27
+ <div
28
+ ref={ref}
29
+ className={cn(
30
+ 'max-w-none text-foreground',
31
+ sizeClasses[size],
32
+ // Headings
33
+ '[&_h1]:mb-4 [&_h1]:mt-10 [&_h1]:scroll-mt-24 [&_h1]:text-3xl [&_h1]:font-bold [&_h1]:tracking-tight',
34
+ '[&_h2]:mb-3 [&_h2]:mt-9 [&_h2]:scroll-mt-24 [&_h2]:font-semibold [&_h2]:tracking-tight',
35
+ '[&_h3]:mb-2 [&_h3]:mt-7 [&_h3]:scroll-mt-24 [&_h3]:font-semibold',
36
+ '[&_h4]:mb-2 [&_h4]:mt-6 [&_h4]:scroll-mt-24 [&_h4]:font-semibold',
37
+ // Body copy
38
+ '[&_p]:my-4 [&_p]:leading-7',
39
+ '[&_a]:text-primary [&_a]:underline [&_a]:decoration-primary/40 [&_a]:underline-offset-4 hover:[&_a]:decoration-primary',
40
+ '[&_strong]:font-semibold [&_strong]:text-foreground [&_em]:italic',
41
+ '[&_ul]:my-4 [&_ul]:list-disc [&_ul]:space-y-1.5 [&_ul]:pl-6',
42
+ '[&_ol]:my-4 [&_ol]:list-decimal [&_ol]:space-y-1.5 [&_ol]:pl-6',
43
+ '[&_li]:leading-7 [&_li>p]:my-0',
44
+ '[&_blockquote]:my-6 [&_blockquote]:border-l-2 [&_blockquote]:border-primary/40 [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:text-muted-foreground',
45
+ // Code
46
+ '[&_code]:rounded [&_code]:bg-muted [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.875em]',
47
+ '[&_pre]:my-5 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/50 [&_pre]:p-4',
48
+ '[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-sm',
49
+ // Media, rules, tables
50
+ '[&_hr]:my-8 [&_hr]:border-border',
51
+ '[&_img]:my-6 [&_img]:rounded-lg [&_img]:border [&_img]:border-border',
52
+ '[&_figure]:my-6 [&_figcaption]:mt-2 [&_figcaption]:text-center [&_figcaption]:text-xs [&_figcaption]:text-muted-foreground',
53
+ '[&_table]:my-6 [&_table]:w-full [&_table]:border-collapse [&_table]:text-sm',
54
+ '[&_th]:border-b [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:text-left [&_th]:font-semibold',
55
+ '[&_td]:border-b [&_td]:border-border [&_td]:px-3 [&_td]:py-2',
56
+ className
57
+ )}
58
+ {...props}
59
+ />
60
+ );
61
+ });
@@ -0,0 +1 @@
1
+ export * from './Prose';
@@ -70,3 +70,19 @@ describe('Search', () => {
70
70
  expect(await axe(container)).toHaveNoViolations();
71
71
  });
72
72
  });
73
+
74
+
75
+ describe('Search controlled value', () => {
76
+ it('follows the controlled value and clears when set to null', () => {
77
+ const options = [
78
+ { value: 'a', label: 'Alpha' },
79
+ { value: 'b', label: 'Beta' },
80
+ ];
81
+ const { rerender } = render(<Search options={options} value="a" aria-label="Pick" />);
82
+ expect(screen.getByRole('combobox')).toHaveValue('Alpha');
83
+ rerender(<Search options={options} value="b" aria-label="Pick" />);
84
+ expect(screen.getByRole('combobox')).toHaveValue('Beta');
85
+ rerender(<Search options={options} value={null} aria-label="Pick" />);
86
+ expect(screen.getByRole('combobox')).toHaveValue('');
87
+ });
88
+ });
@@ -18,6 +18,8 @@ export type SearchOption = {
18
18
  export type SearchProps = {
19
19
  /** The full option set; filtered client-side as the user types. */
20
20
  options: SearchOption[];
21
+ /** Controlled selected value (display follows it). null clears the selection. */
22
+ value?: string | null;
21
23
  /** Initially selected option value. Selection is reported via onValueChange. */
22
24
  defaultValue?: string;
23
25
  /** Called with the selected option's value. */
@@ -41,6 +43,7 @@ export type SearchProps = {
41
43
  */
42
44
  export function Search({
43
45
  options,
46
+ value,
44
47
  defaultValue,
45
48
  onValueChange,
46
49
  placeholder = 'Search…',
@@ -51,12 +54,18 @@ export function Search({
51
54
  className,
52
55
  'aria-label': ariaLabel,
53
56
  }: SearchProps) {
57
+ const activeValue = value === undefined ? defaultValue : value ?? undefined;
54
58
  const selected = React.useMemo(
55
- () => options.find((option) => option.value === defaultValue),
56
- [options, defaultValue]
59
+ () => options.find((option) => option.value === activeValue),
60
+ [options, activeValue]
57
61
  );
58
62
  const [query, setQuery] = React.useState(selected?.label ?? '');
59
63
 
64
+ // Controlled usage: follow the parent's value (including external clears).
65
+ React.useEffect(() => {
66
+ if (value !== undefined) setQuery(selected?.label ?? '');
67
+ }, [value, selected]);
68
+
60
69
  const filtered = React.useMemo(() => {
61
70
  if (!query.trim()) return options;
62
71
  const q = query.trim().toLowerCase();
@@ -0,0 +1,32 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { axe } from 'jest-axe';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { SectionHeading } from './SectionHeading';
5
+
6
+ describe('SectionHeading', () => {
7
+ it('renders eyebrow, title, description and actions at the requested level', () => {
8
+ render(
9
+ <SectionHeading
10
+ eyebrow="Components"
11
+ title="Built for agents"
12
+ description="Every component ships a spec."
13
+ level={3}
14
+ actions={<a href="/docs">All docs</a>}
15
+ />
16
+ );
17
+ expect(screen.getByText('Components')).toBeInTheDocument();
18
+ expect(screen.getByRole('heading', { level: 3, name: 'Built for agents' })).toBeInTheDocument();
19
+ expect(screen.getByText('Every component ships a spec.')).toBeInTheDocument();
20
+ expect(screen.getByRole('link', { name: 'All docs' })).toBeInTheDocument();
21
+ });
22
+
23
+ it('supports centered hero sizes', () => {
24
+ render(<SectionHeading title="Centered" align="center" size="lg" />);
25
+ expect(screen.getByRole('heading', { name: 'Centered' })).toHaveClass('text-3xl');
26
+ });
27
+
28
+ it('has no accessibility violations', async () => {
29
+ const { container } = render(<SectionHeading title="Section" description="Copy" />);
30
+ expect(await axe(container)).toHaveNoViolations();
31
+ });
32
+ });
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+
4
+ export type SectionHeadingProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ title: string;
6
+ description?: string;
7
+ /** Kicker above the title (category, step, overline). */
8
+ eyebrow?: React.ReactNode;
9
+ /** Right-aligned actions (link to all, buttons). */
10
+ actions?: React.ReactNode;
11
+ /** Heading level rendered for the title (default h2). */
12
+ level?: 2 | 3 | 4;
13
+ align?: 'left' | 'center';
14
+ size?: 'sm' | 'md' | 'lg';
15
+ };
16
+
17
+ const sizeClasses: Record<NonNullable<SectionHeadingProps['size']>, string> = {
18
+ sm: 'text-lg',
19
+ md: 'text-2xl',
20
+ lg: 'text-3xl',
21
+ };
22
+
23
+ /**
24
+ * Marketing/content section heading: eyebrow, title, description and an
25
+ * actions slot, with heading level and alignment control. Complements
26
+ * PageHeader (which owns the page's single h1).
27
+ */
28
+ export const SectionHeading = React.forwardRef<HTMLDivElement, SectionHeadingProps>(function SectionHeading(
29
+ { title, description, eyebrow, actions, level = 2, align = 'left', size = 'md', className, ...props },
30
+ ref
31
+ ) {
32
+ const Heading = `h${level}` as 'h2' | 'h3' | 'h4';
33
+
34
+ return (
35
+ <div
36
+ ref={ref}
37
+ className={cn(
38
+ 'flex flex-col gap-2',
39
+ align === 'center' ? 'items-center text-center' : 'sm:flex-row sm:items-end sm:justify-between',
40
+ className
41
+ )}
42
+ {...props}
43
+ >
44
+ <div className={cn('min-w-0', align === 'center' && 'flex flex-col items-center')}>
45
+ {eyebrow && <p className="mb-1 text-xs font-medium uppercase tracking-wide text-primary">{eyebrow}</p>}
46
+ <Heading className={cn('font-semibold tracking-tight', sizeClasses[size])}>{title}</Heading>
47
+ {description && (
48
+ <p className={cn('mt-2 max-w-2xl text-muted-foreground', align === 'center' ? 'mx-auto' : '')}>{description}</p>
49
+ )}
50
+ </div>
51
+ {actions && <div className="flex shrink-0 items-center gap-2">{actions}</div>}
52
+ </div>
53
+ );
54
+ });
@@ -0,0 +1 @@
1
+ export * from './SectionHeading';
@@ -29,7 +29,7 @@ describe('Select', () => {
29
29
  const user = userEvent.setup();
30
30
  const onChange = vi.fn();
31
31
  function Controlled() {
32
- const [value, setValue] = useState('default');
32
+ const [value, setValue] = useState<string | string[]>('default');
33
33
  return (
34
34
  <Select
35
35
  options={options}
@@ -59,3 +59,42 @@ describe('Select', () => {
59
59
  expect(await axe(container)).toHaveNoViolations();
60
60
  });
61
61
  });
62
+
63
+
64
+ describe('Select groups, placeholder and multiple', () => {
65
+ it('renders optgroups with headings', () => {
66
+ render(
67
+ <Select
68
+ label="Plan"
69
+ placeholder="Choose a plan"
70
+ groups={[
71
+ { label: 'Individual', options: [{ value: 'free', label: 'Free' }, { value: 'pro', label: 'Pro' }] },
72
+ { label: 'Business', options: [{ value: 'team', label: 'Team' }] },
73
+ ]}
74
+ />
75
+ );
76
+ const groups = screen.getAllByRole('group');
77
+ expect(groups).toHaveLength(2);
78
+ expect(groups[0]).toHaveAttribute('label', 'Individual');
79
+ expect(screen.getByRole('option', { name: 'Choose a plan' })).toBeDisabled();
80
+ });
81
+
82
+ it('supports native multi-select with a string[] contract', async () => {
83
+ const user = userEvent.setup();
84
+ const onChange = vi.fn();
85
+ render(
86
+ <Select
87
+ label="Channels"
88
+ multiple
89
+ value={['email']}
90
+ onChange={onChange}
91
+ options={[
92
+ { value: 'email', label: 'Email' },
93
+ { value: 'slack', label: 'Slack' },
94
+ ]}
95
+ />
96
+ );
97
+ await user.selectOptions(screen.getByRole('listbox', { name: 'Channels' }), ['slack']);
98
+ expect(onChange).toHaveBeenLastCalledWith(['email', 'slack']);
99
+ });
100
+ });