@boostdev/design-system-components 0.1.1

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 (233) hide show
  1. package/AGENTS.md +72 -0
  2. package/README.md +396 -0
  3. package/dist/index.cjs +2273 -0
  4. package/dist/index.css +2543 -0
  5. package/dist/index.d.cts +453 -0
  6. package/dist/index.d.ts +453 -0
  7. package/dist/index.js +2221 -0
  8. package/package.json +143 -0
  9. package/src/components/interaction/Button/Button.module.css +136 -0
  10. package/src/components/interaction/Button/Button.spec.tsx +50 -0
  11. package/src/components/interaction/Button/Button.stories.tsx +43 -0
  12. package/src/components/interaction/Button/Button.tsx +68 -0
  13. package/src/components/interaction/Button/index.ts +1 -0
  14. package/src/components/interaction/Command/Command.module.css +128 -0
  15. package/src/components/interaction/Command/Command.spec.tsx +60 -0
  16. package/src/components/interaction/Command/Command.stories.tsx +35 -0
  17. package/src/components/interaction/Command/Command.tsx +161 -0
  18. package/src/components/interaction/Command/index.ts +2 -0
  19. package/src/components/interaction/Dialog/Dialog.module.css +39 -0
  20. package/src/components/interaction/Dialog/Dialog.spec.tsx +43 -0
  21. package/src/components/interaction/Dialog/Dialog.stories.tsx +36 -0
  22. package/src/components/interaction/Dialog/Dialog.tsx +42 -0
  23. package/src/components/interaction/Dialog/index.ts +1 -0
  24. package/src/components/interaction/Drawer/Drawer.module.css +98 -0
  25. package/src/components/interaction/Drawer/Drawer.spec.tsx +43 -0
  26. package/src/components/interaction/Drawer/Drawer.stories.tsx +46 -0
  27. package/src/components/interaction/Drawer/Drawer.tsx +71 -0
  28. package/src/components/interaction/Drawer/index.ts +1 -0
  29. package/src/components/interaction/DropdownMenu/DropdownMenu.module.css +68 -0
  30. package/src/components/interaction/DropdownMenu/DropdownMenu.spec.tsx +74 -0
  31. package/src/components/interaction/DropdownMenu/DropdownMenu.stories.tsx +68 -0
  32. package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +137 -0
  33. package/src/components/interaction/DropdownMenu/index.ts +1 -0
  34. package/src/components/interaction/Popover/Popover.module.css +39 -0
  35. package/src/components/interaction/Popover/Popover.spec.tsx +72 -0
  36. package/src/components/interaction/Popover/Popover.stories.tsx +47 -0
  37. package/src/components/interaction/Popover/Popover.tsx +78 -0
  38. package/src/components/interaction/Popover/index.ts +1 -0
  39. package/src/components/interaction/Rating/Rating.module.css +16 -0
  40. package/src/components/interaction/Rating/Rating.spec.tsx +30 -0
  41. package/src/components/interaction/Rating/Rating.stories.tsx +29 -0
  42. package/src/components/interaction/Rating/Rating.tsx +30 -0
  43. package/src/components/interaction/Rating/index.ts +1 -0
  44. package/src/components/interaction/Toast/Toast.module.css +48 -0
  45. package/src/components/interaction/Toast/Toast.spec.tsx +41 -0
  46. package/src/components/interaction/Toast/Toast.stories.tsx +57 -0
  47. package/src/components/interaction/Toast/Toast.tsx +64 -0
  48. package/src/components/interaction/Toast/index.ts +1 -0
  49. package/src/components/interaction/form/Checkbox/Checkbox.module.css +61 -0
  50. package/src/components/interaction/form/Checkbox/Checkbox.spec.tsx +39 -0
  51. package/src/components/interaction/form/Checkbox/Checkbox.stories.tsx +17 -0
  52. package/src/components/interaction/form/Checkbox/Checkbox.tsx +39 -0
  53. package/src/components/interaction/form/Checkbox/index.ts +1 -0
  54. package/src/components/interaction/form/Combobox/Combobox.module.css +104 -0
  55. package/src/components/interaction/form/Combobox/Combobox.spec.tsx +81 -0
  56. package/src/components/interaction/form/Combobox/Combobox.stories.tsx +25 -0
  57. package/src/components/interaction/form/Combobox/Combobox.tsx +182 -0
  58. package/src/components/interaction/form/Combobox/index.ts +1 -0
  59. package/src/components/interaction/form/FileInput/FileInput.module.css +79 -0
  60. package/src/components/interaction/form/FileInput/FileInput.spec.tsx +53 -0
  61. package/src/components/interaction/form/FileInput/FileInput.stories.tsx +17 -0
  62. package/src/components/interaction/form/FileInput/FileInput.tsx +99 -0
  63. package/src/components/interaction/form/FileInput/index.ts +1 -0
  64. package/src/components/interaction/form/FormInput/FormInput.module.css +37 -0
  65. package/src/components/interaction/form/FormInput/FormInput.spec.tsx +43 -0
  66. package/src/components/interaction/form/FormInput/FormInput.stories.tsx +17 -0
  67. package/src/components/interaction/form/FormInput/FormInput.tsx +47 -0
  68. package/src/components/interaction/form/FormInput/index.ts +1 -0
  69. package/src/components/interaction/form/NumberInput/NumberInput.module.css +78 -0
  70. package/src/components/interaction/form/NumberInput/NumberInput.spec.tsx +49 -0
  71. package/src/components/interaction/form/NumberInput/NumberInput.stories.tsx +17 -0
  72. package/src/components/interaction/form/NumberInput/NumberInput.tsx +106 -0
  73. package/src/components/interaction/form/NumberInput/index.ts +1 -0
  74. package/src/components/interaction/form/Radio/Radio.module.css +62 -0
  75. package/src/components/interaction/form/Radio/Radio.spec.tsx +38 -0
  76. package/src/components/interaction/form/Radio/Radio.stories.tsx +26 -0
  77. package/src/components/interaction/form/Radio/Radio.tsx +39 -0
  78. package/src/components/interaction/form/Radio/index.ts +1 -0
  79. package/src/components/interaction/form/Select/Select.module.css +64 -0
  80. package/src/components/interaction/form/Select/Select.spec.tsx +61 -0
  81. package/src/components/interaction/form/Select/Select.stories.tsx +24 -0
  82. package/src/components/interaction/form/Select/Select.tsx +72 -0
  83. package/src/components/interaction/form/Select/index.ts +1 -0
  84. package/src/components/interaction/form/Slider/Slider.module.css +99 -0
  85. package/src/components/interaction/form/Slider/Slider.spec.tsx +53 -0
  86. package/src/components/interaction/form/Slider/Slider.stories.tsx +18 -0
  87. package/src/components/interaction/form/Slider/Slider.tsx +71 -0
  88. package/src/components/interaction/form/Slider/index.ts +1 -0
  89. package/src/components/interaction/form/Switch/Switch.module.css +114 -0
  90. package/src/components/interaction/form/Switch/Switch.spec.tsx +48 -0
  91. package/src/components/interaction/form/Switch/Switch.stories.tsx +31 -0
  92. package/src/components/interaction/form/Switch/Switch.tsx +54 -0
  93. package/src/components/interaction/form/Switch/index.ts +1 -0
  94. package/src/components/interaction/form/Textarea/Textarea.module.css +44 -0
  95. package/src/components/interaction/form/Textarea/Textarea.spec.tsx +53 -0
  96. package/src/components/interaction/form/Textarea/Textarea.stories.tsx +18 -0
  97. package/src/components/interaction/form/Textarea/Textarea.tsx +44 -0
  98. package/src/components/interaction/form/Textarea/index.ts +1 -0
  99. package/src/components/interaction/form/atoms/InputContainer.module.css +9 -0
  100. package/src/components/interaction/form/atoms/InputContainer.tsx +9 -0
  101. package/src/components/interaction/form/atoms/Label.module.css +10 -0
  102. package/src/components/interaction/form/atoms/Label.tsx +15 -0
  103. package/src/components/interaction/form/atoms/Message.module.css +11 -0
  104. package/src/components/interaction/form/atoms/Message.tsx +17 -0
  105. package/src/components/layout/ButtonGroup/ButtonGroup.module.css +59 -0
  106. package/src/components/layout/ButtonGroup/ButtonGroup.spec.tsx +20 -0
  107. package/src/components/layout/ButtonGroup/ButtonGroup.stories.tsx +28 -0
  108. package/src/components/layout/ButtonGroup/ButtonGroup.tsx +17 -0
  109. package/src/components/layout/ButtonGroup/index.ts +1 -0
  110. package/src/components/layout/Card/Card.module.css +72 -0
  111. package/src/components/layout/Card/Card.spec.tsx +33 -0
  112. package/src/components/layout/Card/Card.stories.tsx +32 -0
  113. package/src/components/layout/Card/Card.tsx +45 -0
  114. package/src/components/layout/Card/index.ts +1 -0
  115. package/src/components/layout/IconWrapper/IconWrapper.module.css +24 -0
  116. package/src/components/layout/IconWrapper/IconWrapper.spec.tsx +19 -0
  117. package/src/components/layout/IconWrapper/IconWrapper.stories.tsx +22 -0
  118. package/src/components/layout/IconWrapper/IconWrapper.tsx +14 -0
  119. package/src/components/layout/IconWrapper/index.ts +1 -0
  120. package/src/components/layout/SectionHeader/SectionHeader.module.css +75 -0
  121. package/src/components/layout/SectionHeader/SectionHeader.spec.tsx +31 -0
  122. package/src/components/layout/SectionHeader/SectionHeader.stories.tsx +21 -0
  123. package/src/components/layout/SectionHeader/SectionHeader.tsx +32 -0
  124. package/src/components/layout/SectionHeader/index.ts +1 -0
  125. package/src/components/ui/Accordion/Accordion.module.css +87 -0
  126. package/src/components/ui/Accordion/Accordion.spec.tsx +78 -0
  127. package/src/components/ui/Accordion/Accordion.stories.tsx +34 -0
  128. package/src/components/ui/Accordion/Accordion.tsx +82 -0
  129. package/src/components/ui/Accordion/index.ts +1 -0
  130. package/src/components/ui/Alert/Alert.module.css +91 -0
  131. package/src/components/ui/Alert/Alert.spec.tsx +63 -0
  132. package/src/components/ui/Alert/Alert.stories.tsx +53 -0
  133. package/src/components/ui/Alert/Alert.tsx +54 -0
  134. package/src/components/ui/Alert/index.ts +1 -0
  135. package/src/components/ui/Avatar/Avatar.module.css +42 -0
  136. package/src/components/ui/Avatar/Avatar.spec.tsx +49 -0
  137. package/src/components/ui/Avatar/Avatar.stories.tsx +44 -0
  138. package/src/components/ui/Avatar/Avatar.tsx +45 -0
  139. package/src/components/ui/Avatar/index.ts +1 -0
  140. package/src/components/ui/Badge/Badge.module.css +46 -0
  141. package/src/components/ui/Badge/Badge.spec.tsx +19 -0
  142. package/src/components/ui/Badge/Badge.stories.tsx +29 -0
  143. package/src/components/ui/Badge/Badge.tsx +13 -0
  144. package/src/components/ui/Badge/index.ts +1 -0
  145. package/src/components/ui/Breadcrumb/Breadcrumb.module.css +50 -0
  146. package/src/components/ui/Breadcrumb/Breadcrumb.spec.tsx +44 -0
  147. package/src/components/ui/Breadcrumb/Breadcrumb.stories.tsx +48 -0
  148. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +41 -0
  149. package/src/components/ui/Breadcrumb/index.ts +1 -0
  150. package/src/components/ui/Calendar/Calendar.module.css +120 -0
  151. package/src/components/ui/Calendar/Calendar.spec.tsx +64 -0
  152. package/src/components/ui/Calendar/Calendar.stories.tsx +59 -0
  153. package/src/components/ui/Calendar/Calendar.tsx +184 -0
  154. package/src/components/ui/Calendar/index.ts +1 -0
  155. package/src/components/ui/Carousel/Carousel.module.css +66 -0
  156. package/src/components/ui/Carousel/Carousel.spec.tsx +29 -0
  157. package/src/components/ui/Carousel/Carousel.stories.tsx +30 -0
  158. package/src/components/ui/Carousel/Carousel.tsx +64 -0
  159. package/src/components/ui/Carousel/index.ts +1 -0
  160. package/src/components/ui/DescriptionList/DescriptionList.module.css +43 -0
  161. package/src/components/ui/DescriptionList/DescriptionList.spec.tsx +31 -0
  162. package/src/components/ui/DescriptionList/DescriptionList.stories.tsx +21 -0
  163. package/src/components/ui/DescriptionList/DescriptionList.tsx +30 -0
  164. package/src/components/ui/DescriptionList/index.ts +1 -0
  165. package/src/components/ui/Link/Link.module.css +64 -0
  166. package/src/components/ui/Link/Link.spec.tsx +43 -0
  167. package/src/components/ui/Link/Link.stories.tsx +55 -0
  168. package/src/components/ui/Link/Link.tsx +42 -0
  169. package/src/components/ui/Link/index.ts +1 -0
  170. package/src/components/ui/Loading/Loading.module.css +33 -0
  171. package/src/components/ui/Loading/Loading.spec.tsx +19 -0
  172. package/src/components/ui/Loading/Loading.stories.tsx +27 -0
  173. package/src/components/ui/Loading/Loading.tsx +15 -0
  174. package/src/components/ui/Loading/index.ts +1 -0
  175. package/src/components/ui/NotificationBanner/NotificationBanner.module.css +79 -0
  176. package/src/components/ui/NotificationBanner/NotificationBanner.spec.tsx +42 -0
  177. package/src/components/ui/NotificationBanner/NotificationBanner.stories.tsx +30 -0
  178. package/src/components/ui/NotificationBanner/NotificationBanner.tsx +45 -0
  179. package/src/components/ui/NotificationBanner/index.ts +1 -0
  180. package/src/components/ui/Pagination/Pagination.module.css +78 -0
  181. package/src/components/ui/Pagination/Pagination.spec.tsx +67 -0
  182. package/src/components/ui/Pagination/Pagination.stories.tsx +40 -0
  183. package/src/components/ui/Pagination/Pagination.tsx +87 -0
  184. package/src/components/ui/Pagination/index.ts +1 -0
  185. package/src/components/ui/Progress/Progress.module.css +51 -0
  186. package/src/components/ui/Progress/Progress.spec.tsx +55 -0
  187. package/src/components/ui/Progress/Progress.stories.tsx +30 -0
  188. package/src/components/ui/Progress/Progress.tsx +43 -0
  189. package/src/components/ui/Progress/index.ts +1 -0
  190. package/src/components/ui/ProgressCircle/ProgressCircle.module.css +40 -0
  191. package/src/components/ui/ProgressCircle/ProgressCircle.spec.tsx +34 -0
  192. package/src/components/ui/ProgressCircle/ProgressCircle.stories.tsx +18 -0
  193. package/src/components/ui/ProgressCircle/ProgressCircle.tsx +75 -0
  194. package/src/components/ui/ProgressCircle/index.ts +1 -0
  195. package/src/components/ui/Separator/Separator.module.css +23 -0
  196. package/src/components/ui/Separator/Separator.spec.tsx +30 -0
  197. package/src/components/ui/Separator/Separator.stories.tsx +40 -0
  198. package/src/components/ui/Separator/Separator.tsx +21 -0
  199. package/src/components/ui/Separator/index.ts +1 -0
  200. package/src/components/ui/Skeleton/Skeleton.module.css +24 -0
  201. package/src/components/ui/Skeleton/Skeleton.spec.tsx +19 -0
  202. package/src/components/ui/Skeleton/Skeleton.stories.tsx +25 -0
  203. package/src/components/ui/Skeleton/Skeleton.tsx +12 -0
  204. package/src/components/ui/Skeleton/index.ts +1 -0
  205. package/src/components/ui/SkipLink/SkipLink.module.css +30 -0
  206. package/src/components/ui/SkipLink/SkipLink.spec.tsx +24 -0
  207. package/src/components/ui/SkipLink/SkipLink.stories.tsx +24 -0
  208. package/src/components/ui/SkipLink/SkipLink.tsx +14 -0
  209. package/src/components/ui/SkipLink/index.ts +1 -0
  210. package/src/components/ui/Table/Table.module.css +111 -0
  211. package/src/components/ui/Table/Table.spec.tsx +69 -0
  212. package/src/components/ui/Table/Table.stories.tsx +53 -0
  213. package/src/components/ui/Table/Table.tsx +98 -0
  214. package/src/components/ui/Table/index.ts +1 -0
  215. package/src/components/ui/Tabs/Tabs.module.css +61 -0
  216. package/src/components/ui/Tabs/Tabs.spec.tsx +91 -0
  217. package/src/components/ui/Tabs/Tabs.stories.tsx +59 -0
  218. package/src/components/ui/Tabs/Tabs.tsx +100 -0
  219. package/src/components/ui/Tabs/index.ts +1 -0
  220. package/src/components/ui/Tooltip/Tooltip.module.css +69 -0
  221. package/src/components/ui/Tooltip/Tooltip.spec.tsx +46 -0
  222. package/src/components/ui/Tooltip/Tooltip.stories.tsx +69 -0
  223. package/src/components/ui/Tooltip/Tooltip.tsx +38 -0
  224. package/src/components/ui/Tooltip/index.ts +1 -0
  225. package/src/components/ui/Typography/Typography.module.css +41 -0
  226. package/src/components/ui/Typography/Typography.spec.tsx +39 -0
  227. package/src/components/ui/Typography/Typography.stories.tsx +31 -0
  228. package/src/components/ui/Typography/Typography.tsx +28 -0
  229. package/src/components/ui/Typography/index.ts +1 -0
  230. package/src/css/index.css +55 -0
  231. package/src/index.ts +54 -0
  232. package/src/test/setup.ts +1 -0
  233. package/src/typings.d.ts +4 -0
@@ -0,0 +1,184 @@
1
+ import { useState, useId, KeyboardEvent } from 'react';
2
+ import css from './Calendar.module.css';
3
+ import { cn } from '@boostdev/design-system-foundation';
4
+
5
+ const DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
6
+ const MONTHS = [
7
+ 'January', 'February', 'March', 'April', 'May', 'June',
8
+ 'July', 'August', 'September', 'October', 'November', 'December',
9
+ ];
10
+
11
+ interface CalendarProps {
12
+ value?: Date;
13
+ defaultValue?: Date;
14
+ min?: Date;
15
+ max?: Date;
16
+ onChange?: (date: Date) => void;
17
+ className?: string;
18
+ }
19
+
20
+ function isSameDay(a: Date, b: Date): boolean {
21
+ return a.getFullYear() === b.getFullYear() &&
22
+ a.getMonth() === b.getMonth() &&
23
+ a.getDate() === b.getDate();
24
+ }
25
+
26
+ function isOutOfRange(date: Date, min?: Date, max?: Date): boolean {
27
+ if (min && date < min) return true;
28
+ if (max && date > max) return true;
29
+ return false;
30
+ }
31
+
32
+ function getDaysInMonth(year: number, month: number): number {
33
+ return new Date(year, month + 1, 0).getDate();
34
+ }
35
+
36
+ function getFirstDayOfMonth(year: number, month: number): number {
37
+ return new Date(year, month, 1).getDay();
38
+ }
39
+
40
+ export function Calendar({ value, defaultValue, min, max, onChange, className }: Readonly<CalendarProps>) {
41
+ const today = new Date();
42
+ const controlled = value !== undefined;
43
+ const [internal, setInternal] = useState<Date | undefined>(defaultValue);
44
+ const selected = controlled ? value : internal;
45
+
46
+ const [viewYear, setViewYear] = useState(selected?.getFullYear() ?? today.getFullYear());
47
+ const [viewMonth, setViewMonth] = useState(selected?.getMonth() ?? today.getMonth());
48
+ const [focusedDay, setFocusedDay] = useState<number | undefined>();
49
+
50
+ const titleId = useId();
51
+ const daysInMonth = getDaysInMonth(viewYear, viewMonth);
52
+ const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
53
+
54
+ const navigate = (delta: number) => {
55
+ const d = new Date(viewYear, viewMonth + delta, 1);
56
+ setViewYear(d.getFullYear());
57
+ setViewMonth(d.getMonth());
58
+ setFocusedDay(undefined);
59
+ };
60
+
61
+ const selectDay = (day: number) => {
62
+ const date = new Date(viewYear, viewMonth, day);
63
+ if (isOutOfRange(date, min, max)) return;
64
+ if (!controlled) setInternal(date);
65
+ onChange?.(date);
66
+ };
67
+
68
+ const handleKeyDown = (e: KeyboardEvent<HTMLElement>, day: number) => {
69
+ const map: Record<string, number> = {
70
+ ArrowRight: 1, ArrowLeft: -1, ArrowDown: 7, ArrowUp: -7,
71
+ };
72
+ if (e.key in map) {
73
+ e.preventDefault();
74
+ const current = new Date(viewYear, viewMonth, day);
75
+ const next = new Date(current);
76
+ next.setDate(next.getDate() + map[e.key]);
77
+ setViewYear(next.getFullYear());
78
+ setViewMonth(next.getMonth());
79
+ setFocusedDay(next.getDate());
80
+ } else if (e.key === 'Home') {
81
+ e.preventDefault();
82
+ setFocusedDay(1);
83
+ } else if (e.key === 'End') {
84
+ e.preventDefault();
85
+ setFocusedDay(daysInMonth);
86
+ } else if (e.key === 'Enter' || e.key === ' ') {
87
+ e.preventDefault();
88
+ selectDay(day);
89
+ }
90
+ };
91
+
92
+ // Build grid: leading empty cells, then day cells
93
+ const cells: Array<{ day: number } | null> = [
94
+ ...Array.from({ length: firstDay }, () => null),
95
+ ...Array.from({ length: daysInMonth }, (_, i) => ({ day: i + 1 })),
96
+ ];
97
+ // Pad to complete last row
98
+ while (cells.length % 7 !== 0) cells.push(null);
99
+
100
+ return (
101
+ <div className={cn(css.calendar, className)} role="group" aria-labelledby={titleId}>
102
+ <div className={css.header}>
103
+ <button
104
+ type="button"
105
+ className={css.navBtn}
106
+ aria-label="Previous month"
107
+ onClick={() => navigate(-1)}
108
+ >
109
+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
110
+ <path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7" />
111
+ </svg>
112
+ </button>
113
+ <span id={titleId} className={css.monthYear} aria-live="polite">
114
+ {MONTHS[viewMonth]} {viewYear}
115
+ </span>
116
+ <button
117
+ type="button"
118
+ className={css.navBtn}
119
+ aria-label="Next month"
120
+ onClick={() => navigate(1)}
121
+ >
122
+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
123
+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />
124
+ </svg>
125
+ </button>
126
+ </div>
127
+
128
+ <table
129
+ className={css.grid}
130
+ role="grid"
131
+ aria-labelledby={titleId}
132
+ >
133
+ <thead>
134
+ <tr>
135
+ {DAYS.map(d => (
136
+ <th key={d} scope="col" abbr={d} className={css.weekday}>
137
+ {d}
138
+ </th>
139
+ ))}
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ {Array.from({ length: cells.length / 7 }, (_, row) => (
144
+ <tr key={row}>
145
+ {cells.slice(row * 7, row * 7 + 7).map((cell, col) => {
146
+ if (!cell) return <td key={col} className={css.empty} aria-hidden="true" />;
147
+
148
+ const date = new Date(viewYear, viewMonth, cell.day);
149
+ const isSelected = selected ? isSameDay(date, selected) : false;
150
+ const isToday = isSameDay(date, today);
151
+ const disabled = isOutOfRange(date, min, max);
152
+ const isFocused = focusedDay === cell.day;
153
+
154
+ return (
155
+ <td key={col} role="gridcell">
156
+ <button
157
+ type="button"
158
+ className={cn(
159
+ css.day,
160
+ isSelected && css.selected,
161
+ isToday && !isSelected && css.today,
162
+ disabled && css.disabled,
163
+ )}
164
+ aria-label={date.toLocaleDateString('en', { month: 'long', day: 'numeric', year: 'numeric' })}
165
+ aria-pressed={isSelected}
166
+ aria-current={isToday ? 'date' : undefined}
167
+ aria-disabled={disabled}
168
+ disabled={disabled}
169
+ tabIndex={isFocused || (!focusedDay && isSelected) || (!focusedDay && !selected && isToday) ? 0 : -1}
170
+ onClick={() => selectDay(cell.day)}
171
+ onKeyDown={e => handleKeyDown(e, cell.day)}
172
+ >
173
+ {cell.day}
174
+ </button>
175
+ </td>
176
+ );
177
+ })}
178
+ </tr>
179
+ ))}
180
+ </tbody>
181
+ </table>
182
+ </div>
183
+ );
184
+ }
@@ -0,0 +1 @@
1
+ export { Calendar } from './Calendar';
@@ -0,0 +1,66 @@
1
+ @layer component {
2
+ .carousel {
3
+ position: relative;
4
+ display: flex;
5
+ align-items: center;
6
+ gap: var(--space_xs);
7
+ }
8
+
9
+ .track {
10
+ display: flex;
11
+ gap: var(--space_m);
12
+ overflow-x: auto;
13
+ scroll-snap-type: x mandatory;
14
+ scrollbar-width: none;
15
+ flex: 1;
16
+ scroll-behavior: smooth;
17
+ }
18
+
19
+ .track::-webkit-scrollbar {
20
+ display: none;
21
+ }
22
+
23
+ .slide {
24
+ scroll-snap-align: start;
25
+ flex-shrink: 0;
26
+ }
27
+
28
+ .navBtn {
29
+ all: unset;
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ width: 2.5rem;
34
+ height: 2.5rem;
35
+ border-radius: 50%;
36
+ background-color: var(--color_bg);
37
+ border: 1px solid var(--color_on-bg);
38
+ color: var(--color_on-bg);
39
+ cursor: pointer;
40
+ flex-shrink: 0;
41
+ transition: var(--animation_transition);
42
+ box-shadow: var(--shadow_s);
43
+ }
44
+
45
+ .navBtn svg {
46
+ width: 1.25rem;
47
+ height: 1.25rem;
48
+ }
49
+
50
+ .navBtn:focus-visible {
51
+ outline: var(--outline_default);
52
+ outline-offset: var(--outline_offset);
53
+ }
54
+
55
+ @media (hover: hover) and (pointer: fine) {
56
+ .navBtn:hover {
57
+ background-color: var(--color_bg--subtle);
58
+ }
59
+ }
60
+
61
+ @media (prefers-reduced-motion: reduce) {
62
+ .track {
63
+ scroll-behavior: auto;
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,29 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { Carousel } from './Carousel';
3
+
4
+ const items = [<div key="1">Slide 1</div>, <div key="2">Slide 2</div>, <div key="3">Slide 3</div>];
5
+
6
+ describe('Carousel', () => {
7
+ it('renders a section with accessible label', () => {
8
+ render(<Carousel items={items} label="Featured items" />);
9
+ expect(screen.getByRole('region', { name: 'Featured items' })).toBeInTheDocument();
10
+ });
11
+
12
+ it('renders all slide items', () => {
13
+ render(<Carousel items={items} label="Slides" />);
14
+ expect(screen.getAllByRole('listitem')).toHaveLength(3);
15
+ });
16
+
17
+ it('renders prev and next navigation buttons', () => {
18
+ render(<Carousel items={items} label="Slides" />);
19
+ expect(screen.getByRole('button', { name: 'Previous' })).toBeInTheDocument();
20
+ expect(screen.getByRole('button', { name: 'Next' })).toBeInTheDocument();
21
+ });
22
+
23
+ it('renders slide content', () => {
24
+ render(<Carousel items={items} label="Slides" />);
25
+ expect(screen.getByText('Slide 1')).toBeInTheDocument();
26
+ expect(screen.getByText('Slide 2')).toBeInTheDocument();
27
+ expect(screen.getByText('Slide 3')).toBeInTheDocument();
28
+ });
29
+ });
@@ -0,0 +1,30 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Carousel } from './Carousel';
3
+
4
+ const meta = {
5
+ title: 'UI/Carousel',
6
+ component: Carousel,
7
+ tags: ['autodocs'],
8
+ } satisfies Meta<typeof Carousel>;
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+
13
+ const cardStyle: React.CSSProperties = {
14
+ width: '16rem',
15
+ height: '10rem',
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ background: 'var(--color_bg--subtle)',
20
+ borderRadius: '0.5rem',
21
+ fontSize: '1.5rem',
22
+ fontWeight: 600,
23
+ };
24
+
25
+ export const Default: Story = {
26
+ args: {
27
+ label: 'Featured slides',
28
+ items: [1, 2, 3, 4, 5].map(n => <div key={n} style={cardStyle}>Slide {n}</div>),
29
+ },
30
+ };
@@ -0,0 +1,64 @@
1
+ import { ReactNode, useRef, useId } from 'react';
2
+ import css from './Carousel.module.css';
3
+ import { cn } from '@boostdev/design-system-foundation';
4
+
5
+ interface CarouselProps {
6
+ items: ReactNode[];
7
+ label: string;
8
+ className?: string;
9
+ }
10
+
11
+ export function Carousel({ items, label, className }: Readonly<CarouselProps>) {
12
+ const trackRef = useRef<HTMLDivElement>(null);
13
+ const listId = useId();
14
+
15
+ const scroll = (direction: 'prev' | 'next') => {
16
+ if (!trackRef.current) return;
17
+ const { scrollLeft, clientWidth } = trackRef.current;
18
+ trackRef.current.scrollTo({
19
+ left: scrollLeft + (direction === 'next' ? clientWidth : -clientWidth),
20
+ behavior: 'smooth',
21
+ });
22
+ };
23
+
24
+ return (
25
+ <section aria-label={label} className={cn(css.carousel, className)}>
26
+ <button
27
+ type="button"
28
+ className={cn(css.navBtn, css['--prev'])}
29
+ aria-label="Previous"
30
+ aria-controls={listId}
31
+ onClick={() => scroll('prev')}
32
+ >
33
+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
34
+ <path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7" />
35
+ </svg>
36
+ </button>
37
+
38
+ <div
39
+ ref={trackRef}
40
+ id={listId}
41
+ role="list"
42
+ className={css.track}
43
+ >
44
+ {items.map((item, i) => (
45
+ <div key={i} role="listitem" className={css.slide}>
46
+ {item}
47
+ </div>
48
+ ))}
49
+ </div>
50
+
51
+ <button
52
+ type="button"
53
+ className={cn(css.navBtn, css['--next'])}
54
+ aria-label="Next"
55
+ aria-controls={listId}
56
+ onClick={() => scroll('next')}
57
+ >
58
+ <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
59
+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />
60
+ </svg>
61
+ </button>
62
+ </section>
63
+ );
64
+ }
@@ -0,0 +1 @@
1
+ export { Carousel } from './Carousel';
@@ -0,0 +1,43 @@
1
+ @layer component {
2
+ .list {
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: var(--space_s);
6
+ margin: 0;
7
+ padding: 0;
8
+ font-size: var(--font_size--body);
9
+ color: var(--color_on-bg);
10
+ }
11
+
12
+ .group {
13
+ display: flex;
14
+ flex-direction: column;
15
+ gap: var(--space_xxs);
16
+ }
17
+
18
+ .term {
19
+ font-weight: var(--font_weight--semibold);
20
+ color: var(--color_on-bg);
21
+ }
22
+
23
+ .details {
24
+ margin: 0;
25
+ color: var(--color_on-bg--muted);
26
+ }
27
+
28
+ /* Inline layout */
29
+ .--layout_inline .group {
30
+ display: grid;
31
+ grid-template-columns: minmax(8rem, 1fr) 2fr;
32
+ gap: var(--space_xs);
33
+ align-items: baseline;
34
+ }
35
+
36
+ .--layout_inline .term {
37
+ grid-column: 1;
38
+ }
39
+
40
+ .--layout_inline .details {
41
+ grid-column: 2;
42
+ }
43
+ }
@@ -0,0 +1,31 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { DescriptionList } from './DescriptionList';
3
+
4
+ const items = [
5
+ { term: 'Name', details: 'Alice' },
6
+ { term: 'Role', details: 'Admin' },
7
+ ];
8
+
9
+ describe('DescriptionList', () => {
10
+ it('renders a description list', () => {
11
+ render(<DescriptionList items={items} />);
12
+ expect(screen.getAllByRole('term')[0]).toHaveTextContent('Name');
13
+ });
14
+
15
+ it('renders all terms', () => {
16
+ render(<DescriptionList items={items} />);
17
+ expect(screen.getAllByRole('term')).toHaveLength(2);
18
+ });
19
+
20
+ it('renders all definitions', () => {
21
+ render(<DescriptionList items={items} />);
22
+ const definitions = screen.getAllByRole('definition');
23
+ expect(definitions[0]).toHaveTextContent('Alice');
24
+ expect(definitions[1]).toHaveTextContent('Admin');
25
+ });
26
+
27
+ it('renders multiple details for one term', () => {
28
+ render(<DescriptionList items={[{ term: 'Tags', details: ['React', 'TypeScript'] }]} />);
29
+ expect(screen.getAllByRole('definition')).toHaveLength(2);
30
+ });
31
+ });
@@ -0,0 +1,21 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { DescriptionList } from './DescriptionList';
3
+
4
+ const meta = {
5
+ title: 'UI/DescriptionList',
6
+ component: DescriptionList,
7
+ tags: ['autodocs'],
8
+ } satisfies Meta<typeof DescriptionList>;
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+
13
+ const items = [
14
+ { term: 'Full name', details: 'Alice Johnson' },
15
+ { term: 'Email', details: 'alice@example.com' },
16
+ { term: 'Role', details: 'Administrator' },
17
+ { term: 'Tags', details: ['React', 'TypeScript', 'Design Systems'] },
18
+ ];
19
+
20
+ export const Stacked: Story = { args: { items } };
21
+ export const Inline: Story = { args: { items, layout: 'inline' } };
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from 'react';
2
+ import css from './DescriptionList.module.css';
3
+ import { cn } from '@boostdev/design-system-foundation';
4
+
5
+ interface DescriptionItem {
6
+ term: ReactNode;
7
+ details: ReactNode | ReactNode[];
8
+ }
9
+
10
+ interface DescriptionListProps {
11
+ items: DescriptionItem[];
12
+ layout?: 'stacked' | 'inline';
13
+ className?: string;
14
+ }
15
+
16
+ export function DescriptionList({ items, layout = 'stacked', className }: Readonly<DescriptionListProps>) {
17
+ return (
18
+ <dl className={cn(css.list, css[`--layout_${layout}`], className)}>
19
+ {items.map((item, i) => (
20
+ <div key={i} className={css.group}>
21
+ <dt className={css.term}>{item.term}</dt>
22
+ {Array.isArray(item.details)
23
+ ? item.details.map((d, j) => <dd key={j} className={css.details}>{d}</dd>)
24
+ : <dd className={css.details}>{item.details}</dd>
25
+ }
26
+ </div>
27
+ ))}
28
+ </dl>
29
+ );
30
+ }
@@ -0,0 +1 @@
1
+ export { DescriptionList } from './DescriptionList';
@@ -0,0 +1,64 @@
1
+ @layer component {
2
+ .link {
3
+ --link_color: var(--color_interactive);
4
+ --link_color-hover: var(--color_blue--strong);
5
+
6
+ color: var(--link_color);
7
+ text-decoration: underline;
8
+ text-underline-offset: 0.2em;
9
+ transition: var(--animation_transition);
10
+ cursor: pointer;
11
+ }
12
+
13
+ .link:focus-visible {
14
+ outline: var(--outline_default);
15
+ outline-offset: var(--outline_offset);
16
+ border-radius: var(--border_radius--xs);
17
+ }
18
+
19
+ @media (hover: hover) and (pointer: fine) {
20
+ .link:hover {
21
+ --link_color: var(--link_color-hover);
22
+ }
23
+ }
24
+
25
+ .--variant_default {
26
+ --link_color: var(--color_interactive);
27
+ --link_color-hover: var(--color_blue--strong);
28
+ }
29
+
30
+ .--variant_subtle {
31
+ --link_color: var(--color_on-bg);
32
+ --link_color-hover: var(--color_interactive);
33
+ }
34
+
35
+ .--variant_standalone {
36
+ --link_color: var(--color_interactive);
37
+ --link_color-hover: var(--color_blue--strong);
38
+
39
+ display: inline-flex;
40
+ align-items: center;
41
+ gap: var(--space_xxs);
42
+ font-weight: var(--font_weight--semibold);
43
+ text-decoration: none;
44
+ }
45
+
46
+ @media (hover: hover) and (pointer: fine) {
47
+ .--variant_standalone:hover {
48
+ text-decoration: underline;
49
+ text-underline-offset: 0.2em;
50
+ }
51
+ }
52
+
53
+ .externalLabel {
54
+ position: absolute;
55
+ width: 1px;
56
+ height: 1px;
57
+ padding: 0;
58
+ margin: -1px;
59
+ overflow: hidden;
60
+ clip: rect(0, 0, 0, 0);
61
+ white-space: nowrap;
62
+ border-width: 0;
63
+ }
64
+ }
@@ -0,0 +1,43 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { Link } from './Link';
3
+
4
+ describe('Link', () => {
5
+ it('renders an anchor element', () => {
6
+ render(<Link href="/about">About</Link>);
7
+ expect(screen.getByRole('link', { name: 'About' })).toBeInTheDocument();
8
+ });
9
+
10
+ it('forwards the href', () => {
11
+ render(<Link href="/contact">Contact</Link>);
12
+ expect(screen.getByRole('link')).toHaveAttribute('href', '/contact');
13
+ });
14
+
15
+ it('renders children', () => {
16
+ render(<Link href="#">Click me</Link>);
17
+ expect(screen.getByText('Click me')).toBeInTheDocument();
18
+ });
19
+
20
+ it('adds target and rel for external links', () => {
21
+ render(<Link href="https://example.com" external>External</Link>);
22
+ const link = screen.getByRole('link');
23
+ expect(link).toHaveAttribute('target', '_blank');
24
+ expect(link).toHaveAttribute('rel', 'noreferrer noopener');
25
+ });
26
+
27
+ it('adds a visually hidden "(opens in new tab)" label for external links', () => {
28
+ render(<Link href="https://example.com" external>Visit us</Link>);
29
+ expect(screen.getByText('(opens in new tab)', { exact: false })).toBeInTheDocument();
30
+ });
31
+
32
+ it('does not add target or rel for internal links', () => {
33
+ render(<Link href="/internal">Internal</Link>);
34
+ const link = screen.getByRole('link');
35
+ expect(link).not.toHaveAttribute('target');
36
+ expect(link).not.toHaveAttribute('rel');
37
+ });
38
+
39
+ it('accepts a custom className', () => {
40
+ render(<Link href="#" className="custom">Link</Link>);
41
+ expect(screen.getByRole('link')).toHaveClass('custom');
42
+ });
43
+ });
@@ -0,0 +1,55 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Link } from './Link';
3
+
4
+ const meta = {
5
+ title: 'UI/Link',
6
+ component: Link,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ variant: { control: 'radio', options: ['default', 'subtle', 'standalone'] },
10
+ },
11
+ } satisfies Meta<typeof Link>;
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof meta>;
15
+
16
+ export const Default: Story = { args: { children: 'Read more', href: '#', variant: 'default' } };
17
+ export const Subtle: Story = { args: { children: 'Learn more', href: '#', variant: 'subtle' } };
18
+ export const Standalone: Story = { args: { children: 'View all products →', href: '#', variant: 'standalone' } };
19
+ export const External: Story = { args: { children: 'Visit our website', href: 'https://example.com', external: true } };
20
+
21
+ export const InlineUsage: Story = {
22
+ render: () => (
23
+ <p>
24
+ Read our <Link href="#">terms and conditions</Link> before signing up.
25
+ You can also visit our <Link href="https://example.com" external>partner site</Link>.
26
+ </p>
27
+ ),
28
+ };
29
+
30
+ export const AsButton: Story = {
31
+ render: () => (
32
+ <Link as="button" type="button" variant="default" onClick={() => alert('clicked')}>
33
+ Rendered as a button
34
+ </Link>
35
+ ),
36
+ };
37
+
38
+ export const AsSpan: Story = {
39
+ render: () => (
40
+ <Link as="span" variant="subtle">
41
+ Rendered as a span (no href)
42
+ </Link>
43
+ ),
44
+ };
45
+
46
+ export const AllVariants: Story = {
47
+ render: () => (
48
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
49
+ <Link href="#" variant="default">Default link</Link>
50
+ <Link href="#" variant="subtle">Subtle link</Link>
51
+ <Link href="#" variant="standalone">Standalone link →</Link>
52
+ <Link href="https://example.com" external>External link</Link>
53
+ </div>
54
+ ),
55
+ };