@sovereignfs/ui 0.41.0 → 0.54.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 (256) hide show
  1. package/dist/Accordion.module.css +3 -0
  2. package/dist/Alert.module.css +62 -0
  3. package/dist/AspectRatio.module.css +15 -0
  4. package/dist/Badge.module.css +75 -9
  5. package/dist/Breadcrumb.module.css +49 -0
  6. package/dist/Button.module.css +12 -3
  7. package/dist/ButtonGroup.module.css +29 -0
  8. package/dist/Card.module.css +6 -0
  9. package/dist/Checkbox.module.css +3 -1
  10. package/dist/Collapsible.module.css +70 -0
  11. package/dist/Combobox.module.css +122 -0
  12. package/dist/Command.module.css +80 -0
  13. package/dist/ConfirmDialog.module.css +5 -1
  14. package/dist/DataTable.module.css +28 -0
  15. package/dist/DatePicker.module.css +6 -2
  16. package/dist/Dialog.module.css +3 -0
  17. package/dist/HoverCard.module.css +3 -0
  18. package/dist/Input.module.css +6 -1
  19. package/dist/Item.module.css +70 -0
  20. package/dist/Kbd.module.css +14 -0
  21. package/dist/Label.module.css +11 -0
  22. package/dist/LegalLinks.module.css +24 -0
  23. package/dist/Markdown.module.css +49 -0
  24. package/dist/Marker.module.css +33 -0
  25. package/dist/Menu.module.css +8 -1
  26. package/dist/Message.module.css +99 -0
  27. package/dist/MessageScroller.module.css +54 -0
  28. package/dist/MobileAppsDrawer.module.css +81 -0
  29. package/dist/MobileFooter.module.css +73 -0
  30. package/dist/MobileHeader.module.css +63 -0
  31. package/dist/NavigationMenu.module.css +53 -0
  32. package/dist/PageContainer.module.css +20 -0
  33. package/dist/Pagination.module.css +98 -0
  34. package/dist/Progress.module.css +20 -0
  35. package/dist/RadioGroup.module.css +88 -0
  36. package/dist/Resizable.module.css +70 -0
  37. package/dist/ScrollArea.module.css +20 -0
  38. package/dist/Select.module.css +7 -3
  39. package/dist/Slider.module.css +95 -0
  40. package/dist/SwipableMobileCarousel.module.css +55 -0
  41. package/dist/SwipableMobileCarouselDots.module.css +49 -0
  42. package/dist/SwipableMobileCarouselSlideParts.module.css +29 -0
  43. package/dist/Table.module.css +45 -0
  44. package/dist/Tabs.module.css +6 -1
  45. package/dist/Toggle.module.css +6 -1
  46. package/dist/Typography.module.css +47 -0
  47. package/dist/index.d.ts +1268 -8
  48. package/dist/index.js +3046 -975
  49. package/dist/tokens/primitives.css +47 -8
  50. package/package.json +13 -9
  51. package/src/components/Accordion/Accordion.module.css +3 -0
  52. package/src/components/Accordion/Accordion.stories.tsx +110 -0
  53. package/src/components/Accordion/Accordion.tsx +53 -0
  54. package/src/components/Accordion/__tests__/Accordion.test.tsx +61 -0
  55. package/src/components/Alert/Alert.module.css +62 -0
  56. package/src/components/Alert/Alert.stories.tsx +96 -0
  57. package/src/components/Alert/Alert.tsx +58 -0
  58. package/src/components/Alert/__tests__/Alert.test.tsx +75 -0
  59. package/src/components/AspectRatio/AspectRatio.module.css +15 -0
  60. package/src/components/AspectRatio/AspectRatio.stories.tsx +78 -0
  61. package/src/components/AspectRatio/AspectRatio.tsx +21 -0
  62. package/src/components/AspectRatio/__tests__/AspectRatio.test.tsx +27 -0
  63. package/src/components/Badge/Badge.module.css +75 -9
  64. package/src/components/Badge/Badge.stories.tsx +109 -1
  65. package/src/components/Badge/Badge.tsx +31 -9
  66. package/src/components/Badge/__tests__/Badge.test.tsx +26 -2
  67. package/src/components/Breadcrumb/Breadcrumb.module.css +49 -0
  68. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +47 -0
  69. package/src/components/Breadcrumb/Breadcrumb.tsx +57 -0
  70. package/src/components/Breadcrumb/__tests__/Breadcrumb.test.tsx +52 -0
  71. package/src/components/Button/Button.module.css +12 -3
  72. package/src/components/Button/Button.stories.tsx +3 -2
  73. package/src/components/Button/Button.tsx +1 -1
  74. package/src/components/Button/__tests__/Button.test.tsx +10 -0
  75. package/src/components/ButtonGroup/ButtonGroup.module.css +29 -0
  76. package/src/components/ButtonGroup/ButtonGroup.stories.tsx +57 -0
  77. package/src/components/ButtonGroup/ButtonGroup.tsx +27 -0
  78. package/src/components/ButtonGroup/__tests__/ButtonGroup.test.tsx +29 -0
  79. package/src/components/Card/Card.module.css +6 -0
  80. package/src/components/Checkbox/Checkbox.module.css +3 -1
  81. package/src/components/Collapsible/Collapsible.module.css +70 -0
  82. package/src/components/Collapsible/Collapsible.stories.tsx +62 -0
  83. package/src/components/Collapsible/Collapsible.tsx +66 -0
  84. package/src/components/Collapsible/__tests__/Collapsible.test.tsx +71 -0
  85. package/src/components/Combobox/Combobox.module.css +122 -0
  86. package/src/components/Combobox/Combobox.stories.tsx +79 -0
  87. package/src/components/Combobox/Combobox.tsx +186 -0
  88. package/src/components/Combobox/__tests__/Combobox.test.tsx +158 -0
  89. package/src/components/Command/Command.module.css +80 -0
  90. package/src/components/Command/Command.stories.tsx +104 -0
  91. package/src/components/Command/Command.tsx +168 -0
  92. package/src/components/Command/__tests__/Command.test.tsx +162 -0
  93. package/src/components/ConfirmDialog/ConfirmDialog.module.css +5 -1
  94. package/src/components/ContextMenu/ContextMenu.stories.tsx +81 -0
  95. package/src/components/ContextMenu/ContextMenu.tsx +100 -0
  96. package/src/components/ContextMenu/__tests__/ContextMenu.test.tsx +87 -0
  97. package/src/components/DataTable/DataTable.module.css +28 -0
  98. package/src/components/DataTable/DataTable.stories.tsx +74 -0
  99. package/src/components/DataTable/DataTable.tsx +154 -0
  100. package/src/components/DataTable/__tests__/DataTable.test.tsx +123 -0
  101. package/src/components/DatePicker/DatePicker.module.css +6 -2
  102. package/src/components/DeviceOnlyGate/DeviceOnlyGate.tsx +58 -0
  103. package/src/components/DeviceOnlyGate/__tests__/DeviceOnlyGate.test.tsx +45 -0
  104. package/src/components/DeviceStorageKeyGate/DeviceStorageKeyGate.tsx +100 -0
  105. package/src/components/DeviceStorageKeyGate/__tests__/DeviceStorageKeyGate.test.tsx +119 -0
  106. package/src/components/Dialog/Dialog.module.css +3 -0
  107. package/src/components/Dialog/Dialog.tsx +8 -59
  108. package/src/components/Drawer/Drawer.stories.tsx +44 -0
  109. package/src/components/Drawer/Drawer.tsx +18 -56
  110. package/src/components/Drawer/__tests__/Drawer.test.tsx +22 -0
  111. package/src/components/HoverCard/HoverCard.module.css +3 -0
  112. package/src/components/HoverCard/HoverCard.stories.tsx +66 -0
  113. package/src/components/HoverCard/HoverCard.tsx +111 -0
  114. package/src/components/HoverCard/__tests__/HoverCard.test.tsx +99 -0
  115. package/src/components/Icon/icons/circle-check.tsx +21 -0
  116. package/src/components/Icon/icons/circle-x.tsx +22 -0
  117. package/src/components/Icon/icons/index.ts +16 -0
  118. package/src/components/Icon/icons/menu.tsx +22 -0
  119. package/src/components/Icon/icons/smartphone.tsx +21 -0
  120. package/src/components/Input/Input.module.css +6 -1
  121. package/src/components/Item/Item.module.css +70 -0
  122. package/src/components/Item/Item.stories.tsx +62 -0
  123. package/src/components/Item/Item.tsx +54 -0
  124. package/src/components/Item/__tests__/Item.test.tsx +39 -0
  125. package/src/components/Kbd/Kbd.module.css +14 -0
  126. package/src/components/Kbd/Kbd.stories.tsx +32 -0
  127. package/src/components/Kbd/Kbd.tsx +12 -0
  128. package/src/components/Kbd/__tests__/Kbd.test.tsx +14 -0
  129. package/src/components/Label/Label.module.css +11 -0
  130. package/src/components/Label/Label.stories.tsx +40 -0
  131. package/src/components/Label/Label.tsx +24 -0
  132. package/src/components/Label/__tests__/Label.test.tsx +32 -0
  133. package/src/components/LegalLinks/LegalLinks.module.css +24 -0
  134. package/src/components/LegalLinks/LegalLinks.stories.tsx +22 -0
  135. package/src/components/LegalLinks/LegalLinks.tsx +40 -0
  136. package/src/components/Markdown/Markdown.module.css +49 -0
  137. package/src/components/Markdown/Markdown.stories.tsx +30 -0
  138. package/src/components/Markdown/Markdown.tsx +168 -0
  139. package/src/components/Marker/Marker.module.css +33 -0
  140. package/src/components/Marker/Marker.stories.tsx +39 -0
  141. package/src/components/Marker/Marker.tsx +34 -0
  142. package/src/components/Marker/__tests__/Marker.test.tsx +23 -0
  143. package/src/components/Menu/Menu.module.css +8 -1
  144. package/src/components/Menu/Menu.tsx +30 -8
  145. package/src/components/Menubar/Menubar.stories.tsx +52 -0
  146. package/src/components/Menubar/Menubar.tsx +42 -0
  147. package/src/components/Menubar/__tests__/Menubar.test.tsx +45 -0
  148. package/src/components/Message/Message.module.css +99 -0
  149. package/src/components/Message/Message.stories.tsx +79 -0
  150. package/src/components/Message/Message.tsx +41 -0
  151. package/src/components/Message/__tests__/Message.test.tsx +46 -0
  152. package/src/components/MessageScroller/MessageScroller.module.css +54 -0
  153. package/src/components/MessageScroller/MessageScroller.stories.tsx +84 -0
  154. package/src/components/MessageScroller/MessageScroller.tsx +72 -0
  155. package/src/components/MessageScroller/__tests__/MessageScroller.test.tsx +105 -0
  156. package/src/components/MobileAppsDrawer/MobileAppsDrawer.module.css +81 -0
  157. package/src/components/MobileAppsDrawer/MobileAppsDrawer.tsx +78 -0
  158. package/src/components/MobileAppsDrawer/__tests__/MobileAppsDrawer.test.tsx +80 -0
  159. package/src/components/MobileFooter/MobileFooter.module.css +73 -0
  160. package/src/components/MobileFooter/MobileFooter.stories.tsx +47 -0
  161. package/src/components/MobileFooter/MobileFooter.tsx +109 -0
  162. package/src/components/MobileFooter/__tests__/MobileFooter.test.tsx +71 -0
  163. package/src/components/MobileHeader/MobileHeader.module.css +63 -0
  164. package/src/components/MobileHeader/MobileHeader.stories.tsx +57 -0
  165. package/src/components/MobileHeader/MobileHeader.tsx +77 -0
  166. package/src/components/MobileHeader/__tests__/MobileHeader.test.tsx +58 -0
  167. package/src/components/NavTabs/NavTabs.tsx +39 -11
  168. package/src/components/NavigationMenu/NavigationMenu.module.css +53 -0
  169. package/src/components/NavigationMenu/NavigationMenu.stories.tsx +58 -0
  170. package/src/components/NavigationMenu/NavigationMenu.tsx +125 -0
  171. package/src/components/NavigationMenu/__tests__/NavigationMenu.test.tsx +93 -0
  172. package/src/components/OfflineGate/OfflineGate.tsx +44 -0
  173. package/src/components/OfflineGate/__tests__/OfflineGate.test.tsx +66 -0
  174. package/src/components/PageContainer/PageContainer.module.css +20 -0
  175. package/src/components/PageContainer/PageContainer.tsx +31 -0
  176. package/src/components/PageContainer/__tests__/PageContainer.test.tsx +37 -0
  177. package/src/components/PageHeader/PageHeader.tsx +16 -2
  178. package/src/components/Pagination/Pagination.module.css +98 -0
  179. package/src/components/Pagination/Pagination.stories.tsx +49 -0
  180. package/src/components/Pagination/Pagination.tsx +87 -0
  181. package/src/components/Pagination/__tests__/Pagination.test.tsx +56 -0
  182. package/src/components/Progress/Progress.module.css +20 -0
  183. package/src/components/Progress/Progress.stories.tsx +40 -0
  184. package/src/components/Progress/Progress.tsx +35 -0
  185. package/src/components/Progress/__tests__/Progress.test.tsx +31 -0
  186. package/src/components/RadioGroup/RadioGroup.module.css +88 -0
  187. package/src/components/RadioGroup/RadioGroup.stories.tsx +69 -0
  188. package/src/components/RadioGroup/RadioGroup.tsx +99 -0
  189. package/src/components/RadioGroup/__tests__/RadioGroup.test.tsx +59 -0
  190. package/src/components/Resizable/Resizable.module.css +70 -0
  191. package/src/components/Resizable/Resizable.stories.tsx +82 -0
  192. package/src/components/Resizable/Resizable.tsx +313 -0
  193. package/src/components/Resizable/__tests__/Resizable.test.tsx +128 -0
  194. package/src/components/ResponsiveSurface/ResponsiveSurface.tsx +24 -0
  195. package/src/components/ResponsiveSurface/__tests__/ResponsiveSurface.test.tsx +73 -0
  196. package/src/components/ScrollArea/ScrollArea.module.css +20 -0
  197. package/src/components/ScrollArea/ScrollArea.stories.tsx +57 -0
  198. package/src/components/ScrollArea/ScrollArea.tsx +27 -0
  199. package/src/components/ScrollArea/__tests__/ScrollArea.test.tsx +39 -0
  200. package/src/components/Select/Select.module.css +7 -3
  201. package/src/components/Sheet/Sheet.tsx +9 -51
  202. package/src/components/Slider/Slider.module.css +95 -0
  203. package/src/components/Slider/Slider.stories.tsx +64 -0
  204. package/src/components/Slider/Slider.tsx +77 -0
  205. package/src/components/Slider/__tests__/Slider.test.tsx +45 -0
  206. package/src/components/SwipableMobileCarousel/SwipableMobileCarousel.module.css +55 -0
  207. package/src/components/SwipableMobileCarousel/SwipableMobileCarousel.tsx +227 -0
  208. package/src/components/SwipableMobileCarousel/SwipableMobileCarouselSlide.tsx +35 -0
  209. package/src/components/SwipableMobileCarousel/SwipableMobileCarouselSlideBody.tsx +42 -0
  210. package/src/components/SwipableMobileCarousel/SwipableMobileCarouselSlideFooter.tsx +18 -0
  211. package/src/components/SwipableMobileCarousel/SwipableMobileCarouselSlideHeader.tsx +21 -0
  212. package/src/components/SwipableMobileCarousel/SwipableMobileCarouselSlideParts.module.css +29 -0
  213. package/src/components/SwipableMobileCarousel/__tests__/SwipableMobileCarousel.test.tsx +133 -0
  214. package/src/components/SwipableMobileCarousel/__tests__/SwipableMobileCarouselDevGuard.test.tsx +61 -0
  215. package/src/components/SwipableMobileCarousel/context.ts +13 -0
  216. package/src/components/SwipableMobileCarouselDots/SwipableMobileCarouselDots.module.css +49 -0
  217. package/src/components/SwipableMobileCarouselDots/SwipableMobileCarouselDots.tsx +62 -0
  218. package/src/components/SwipableMobileCarouselDots/__tests__/SwipableMobileCarouselDots.test.tsx +63 -0
  219. package/src/components/Table/Table.module.css +45 -0
  220. package/src/components/Table/Table.stories.tsx +125 -0
  221. package/src/components/Table/Table.tsx +51 -0
  222. package/src/components/Table/__tests__/Table.test.tsx +50 -0
  223. package/src/components/Tabs/Tabs.module.css +6 -1
  224. package/src/components/Toggle/Toggle.module.css +6 -1
  225. package/src/components/Typography/Typography.module.css +47 -0
  226. package/src/components/Typography/Typography.stories.tsx +62 -0
  227. package/src/components/Typography/Typography.tsx +30 -0
  228. package/src/components/Typography/__tests__/Typography.test.tsx +34 -0
  229. package/src/hooks/__tests__/useCarouselRouteSync.test.tsx +126 -0
  230. package/src/hooks/__tests__/useIsOffline.test.tsx +53 -0
  231. package/src/hooks/__tests__/useOfflineTileState.test.tsx +69 -0
  232. package/src/hooks/__tests__/useResponsiveLayout.test.tsx +87 -0
  233. package/src/hooks/__tests__/useSnapCarousel.test.tsx +93 -0
  234. package/src/hooks/__tests__/useSwipeReveal.test.tsx +110 -0
  235. package/src/hooks/index.ts +18 -0
  236. package/src/hooks/useCarouselRouteSync.ts +92 -0
  237. package/src/hooks/useIsOffline.ts +41 -0
  238. package/src/hooks/useOfflineTileState.ts +45 -0
  239. package/src/hooks/useResponsiveLayout.ts +36 -0
  240. package/src/hooks/useSnapCarousel.ts +79 -0
  241. package/src/hooks/useSwipeReveal.ts +107 -0
  242. package/src/index.ts +141 -3
  243. package/src/overlay-shell.ts +94 -0
  244. package/src/stories/DesignSystemOverview.stories.tsx +936 -3
  245. package/src/stories/DeviceOnlyGate.stories.tsx +35 -0
  246. package/src/stories/DeviceStorageKeyGate.stories.tsx +57 -0
  247. package/src/stories/InteractionHooks.stories.tsx +483 -0
  248. package/src/stories/MobilePatterns.stories.tsx +255 -4
  249. package/src/stories/NavTabs.stories.tsx +18 -0
  250. package/src/stories/OfflineGate.stories.tsx +42 -0
  251. package/src/stories/PageContainer.stories.tsx +37 -0
  252. package/src/stories/PageHeader.stories.tsx +11 -0
  253. package/src/stories/ResponsiveSurface.stories.tsx +47 -0
  254. package/src/stories/SwipableMobileCarousel.stories.tsx +304 -0
  255. package/src/stories/TokenGallery.stories.tsx +177 -16
  256. package/src/tokens/primitives.css +47 -8
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+
3
+ import { useContext, type ReactNode } from 'react';
4
+ import { CarouselSlideMountContext } from './context';
5
+
6
+ export interface SwipableMobileCarouselSlideProps {
7
+ /** Stable identity for this slide, independent of its position among
8
+ * siblings — required. This is what makes SwipableMobileCarousel's
9
+ * reorder-jump fix possible: a plain array index can't distinguish "this
10
+ * slide moved to position 2" from "this slide was removed and a
11
+ * different one is now at position 2." Reuse whatever id the caller
12
+ * already keys their `.map()` on (e.g. a list's own id). */
13
+ slideKey: string;
14
+ /** Accessible label surfaced to the default dots indicator (e.g.
15
+ * "Groceries"). Falls back to "Slide N of count" if omitted — omitting it
16
+ * logs a dev-mode warning, since every real slide usually has a title
17
+ * available synchronously already. */
18
+ label?: string;
19
+ /** SwipableMobileCarouselSlideHeader/Body/Footer, in any order/subset. */
20
+ children: ReactNode;
21
+ }
22
+
23
+ /**
24
+ * SwipableMobileCarouselSlide — a single slide of a SwipableMobileCarousel.
25
+ * Renders its children only while within the carousel's mount window (the
26
+ * active slide ± its configured prefetchDistance); outside that window it
27
+ * renders nothing, matching both sovereign-tasks and sovereign-shopper's
28
+ * existing "never fetch/render a non-neighbor slide" behavior, now
29
+ * centralized instead of hand-rolled per plugin.
30
+ */
31
+ export function SwipableMobileCarouselSlide({ children }: SwipableMobileCarouselSlideProps) {
32
+ const ctx = useContext(CarouselSlideMountContext);
33
+ if (!ctx?.isMounted) return null;
34
+ return <>{children}</>;
35
+ }
@@ -0,0 +1,42 @@
1
+ import type { ReactNode } from 'react';
2
+ import styles from './SwipableMobileCarouselSlideParts.module.css';
3
+
4
+ export interface SwipableMobileCarouselSlideBodyProps {
5
+ children: ReactNode;
6
+ /** While true, renders `loadingFallback` INSTEAD OF children — scoped to
7
+ * just this region, not the whole slide. This is what fixes the
8
+ * "whole slide blanks out, title included, until its own fetch resolves"
9
+ * bug: a caller renders `<SwipableMobileCarouselSlideHeader>` from
10
+ * already-known metadata unconditionally, and gates only this component's
11
+ * `loading` on the slower fetch — the natural way to compose
12
+ * Header/Body/Footer as siblings already produces that behavior, instead
13
+ * of gating the entire slide behind one boolean. */
14
+ loading?: boolean;
15
+ loadingFallback?: ReactNode;
16
+ className?: string;
17
+ }
18
+
19
+ const defaultLoadingFallback = <div className={styles.loading}>Loading…</div>;
20
+
21
+ /**
22
+ * SwipableMobileCarouselSlideBody — the scrollable region of a slide.
23
+ *
24
+ * Deliberately does not set `touch-action: pan-y` on its scroll container
25
+ * (see SwipableMobileCarouselSlideParts.module.css's `.body` rule) — that
26
+ * would intersect-to-empty against the carousel's own horizontal
27
+ * touch-action handling (docs/architecture-rules.md's touch-action
28
+ * intersection rule), breaking both the vertical scroll here and the
29
+ * horizontal swipe between slides.
30
+ */
31
+ export function SwipableMobileCarouselSlideBody({
32
+ children,
33
+ loading = false,
34
+ loadingFallback,
35
+ className,
36
+ }: SwipableMobileCarouselSlideBodyProps) {
37
+ return (
38
+ <div className={[styles.body, className].filter(Boolean).join(' ')}>
39
+ {loading ? (loadingFallback ?? defaultLoadingFallback) : children}
40
+ </div>
41
+ );
42
+ }
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ import styles from './SwipableMobileCarouselSlideParts.module.css';
3
+
4
+ export interface SwipableMobileCarouselSlideFooterProps {
5
+ children: ReactNode;
6
+ className?: string;
7
+ }
8
+
9
+ /**
10
+ * SwipableMobileCarouselSlideFooter — always renders its children, no
11
+ * loading concept. See SwipableMobileCarouselSlideHeader's doc comment.
12
+ */
13
+ export function SwipableMobileCarouselSlideFooter({
14
+ children,
15
+ className,
16
+ }: SwipableMobileCarouselSlideFooterProps) {
17
+ return <div className={[styles.footer, className].filter(Boolean).join(' ')}>{children}</div>;
18
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from 'react';
2
+ import styles from './SwipableMobileCarouselSlideParts.module.css';
3
+
4
+ export interface SwipableMobileCarouselSlideHeaderProps {
5
+ children: ReactNode;
6
+ className?: string;
7
+ }
8
+
9
+ /**
10
+ * SwipableMobileCarouselSlideHeader — always renders its children, no
11
+ * loading concept. Meant for content already known synchronously (a list's
12
+ * title, color, item count from data the caller already has) so it can
13
+ * render immediately even while SwipableMobileCarouselSlideBody's own
14
+ * content is still loading — see that component's doc comment.
15
+ */
16
+ export function SwipableMobileCarouselSlideHeader({
17
+ children,
18
+ className,
19
+ }: SwipableMobileCarouselSlideHeaderProps) {
20
+ return <div className={[styles.header, className].filter(Boolean).join(' ')}>{children}</div>;
21
+ }
@@ -0,0 +1,29 @@
1
+ .header,
2
+ .footer {
3
+ flex: 0 0 auto;
4
+ }
5
+
6
+ .body {
7
+ flex: 1 1 auto;
8
+ min-height: 0; /* allow shrinking inside the slide's flex column, so it can scroll instead of overflowing */
9
+ overflow-y: auto;
10
+ overflow-x: hidden;
11
+ /* Deliberately does NOT set touch-action: pan-y here. touch-action's
12
+ effective value is the INTERSECTION of this element's and every
13
+ ancestor's value (docs/architecture-rules.md) — the ancestor .scroller
14
+ (SwipableMobileCarousel.module.css) needs the horizontal swipe gesture,
15
+ so pan-y here ∩ that horizontal handling would resolve to neither axis
16
+ working natively. Relying on the browser's default touch-action (auto)
17
+ here lets native gesture arbitration between the two nested scrollers
18
+ sort out which axis wins per-gesture — don't "fix" perceived nested-
19
+ scroll jank by adding pan-y; it silently breaks horizontal swipe instead. */
20
+ }
21
+
22
+ .loading {
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ height: 100%;
27
+ color: var(--sv-color-text-subtle);
28
+ font-size: var(--sv-font-size-sm);
29
+ }
@@ -0,0 +1,133 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
4
+ import { SwipableMobileCarousel } from '../SwipableMobileCarousel';
5
+ import { SwipableMobileCarouselSlide } from '../SwipableMobileCarouselSlide';
6
+ import { SwipableMobileCarouselSlideHeader } from '../SwipableMobileCarouselSlideHeader';
7
+ import { SwipableMobileCarouselSlideBody } from '../SwipableMobileCarouselSlideBody';
8
+
9
+ // Same jsdom scroll polyfill/fake-timer setup as useSnapCarousel.test.tsx,
10
+ // since this component wraps that hook directly.
11
+ beforeEach(() => {
12
+ vi.useFakeTimers();
13
+ if (!Element.prototype.scrollTo) {
14
+ Element.prototype.scrollTo = vi.fn();
15
+ }
16
+ });
17
+
18
+ afterEach(() => {
19
+ vi.runOnlyPendingTimers();
20
+ vi.useRealTimers();
21
+ cleanup();
22
+ });
23
+
24
+ function setLayout(el: HTMLElement, clientWidth: number, scrollLeft: number) {
25
+ Object.defineProperty(el, 'clientWidth', { value: clientWidth, configurable: true });
26
+ Object.defineProperty(el, 'scrollLeft', { value: scrollLeft, configurable: true });
27
+ }
28
+
29
+ const KEYS = ['a', 'b', 'c', 'd', 'e'];
30
+
31
+ function FiveSlides({
32
+ activeIndex,
33
+ onSettle,
34
+ }: {
35
+ activeIndex: number;
36
+ onSettle: (i: number) => void;
37
+ }) {
38
+ return (
39
+ <SwipableMobileCarousel activeIndex={activeIndex} onSettle={onSettle} aria-label="Test slides">
40
+ {KEYS.map((key) => (
41
+ <SwipableMobileCarouselSlide key={key} slideKey={key} label={key}>
42
+ <SwipableMobileCarouselSlideHeader>{`header-${key}`}</SwipableMobileCarouselSlideHeader>
43
+ <SwipableMobileCarouselSlideBody>{`body-${key}`}</SwipableMobileCarouselSlideBody>
44
+ </SwipableMobileCarouselSlide>
45
+ ))}
46
+ </SwipableMobileCarousel>
47
+ );
48
+ }
49
+
50
+ describe('SwipableMobileCarousel', () => {
51
+ it('only mounts the active slide and its immediate neighbors (default prefetchDistance=1)', () => {
52
+ render(<FiveSlides activeIndex={2} onSettle={() => {}} />);
53
+ // active (c) and neighbors (b, d) are mounted
54
+ expect(screen.getByText('header-b')).toBeDefined();
55
+ expect(screen.getByText('header-c')).toBeDefined();
56
+ expect(screen.getByText('header-d')).toBeDefined();
57
+ // out-of-window slides (a, e) render nothing at all
58
+ expect(screen.queryByText('header-a')).toBeNull();
59
+ expect(screen.queryByText('body-a')).toBeNull();
60
+ expect(screen.queryByText('header-e')).toBeNull();
61
+ expect(screen.queryByText('body-e')).toBeNull();
62
+ });
63
+
64
+ it("SlideBody's loading prop only hides that region, not the Header", () => {
65
+ render(
66
+ <SwipableMobileCarousel activeIndex={0} onSettle={() => {}} aria-label="Test slides">
67
+ <SwipableMobileCarouselSlide slideKey="only" label="Only">
68
+ <SwipableMobileCarouselSlideHeader>the-title</SwipableMobileCarouselSlideHeader>
69
+ <SwipableMobileCarouselSlideBody loading>tasks-content</SwipableMobileCarouselSlideBody>
70
+ </SwipableMobileCarouselSlide>
71
+ </SwipableMobileCarousel>,
72
+ );
73
+ expect(screen.getByText('the-title')).toBeDefined();
74
+ expect(screen.queryByText('tasks-content')).toBeNull();
75
+ expect(screen.getByText('Loading…')).toBeDefined();
76
+ });
77
+
78
+ it('calls onSettle with the new index after a swipe settles', () => {
79
+ const onSettle = vi.fn();
80
+ render(<FiveSlides activeIndex={0} onSettle={onSettle} />);
81
+ const scroller = screen.getByRole('region', { name: 'Test slides' });
82
+ setLayout(scroller, 300, 300); // scrollLeft 300 / width 300 -> index 1
83
+ fireEvent.scroll(scroller);
84
+ act(() => void vi.advanceTimersByTime(120));
85
+ expect(onSettle).toHaveBeenCalledWith(1);
86
+ });
87
+
88
+ it('clicking a dot calls onSettle directly with that index', () => {
89
+ const onSettle = vi.fn();
90
+ render(<FiveSlides activeIndex={0} onSettle={onSettle} />);
91
+ const dots = screen.getAllByRole('tab');
92
+ const fourthDot = dots[3];
93
+ if (!fourthDot) throw new Error('expected a 4th dot');
94
+ setLayout(screen.getByRole('region', { name: 'Test slides' }), 300, 0);
95
+ fireEvent.click(fourthDot);
96
+ expect(onSettle).toHaveBeenCalledWith(3);
97
+ });
98
+
99
+ it('re-snaps and reports the new index when the active slide moves position (reorder-jump fix)', () => {
100
+ function Reorderable({ order, onSettle }: { order: string[]; onSettle: (i: number) => void }) {
101
+ return (
102
+ <SwipableMobileCarousel activeIndex={1} onSettle={onSettle} aria-label="Test slides">
103
+ {order.map((key) => (
104
+ <SwipableMobileCarouselSlide key={key} slideKey={key} label={key}>
105
+ <SwipableMobileCarouselSlideHeader>{`header-${key}`}</SwipableMobileCarouselSlideHeader>
106
+ </SwipableMobileCarouselSlide>
107
+ ))}
108
+ </SwipableMobileCarousel>
109
+ );
110
+ }
111
+ const onSettle = vi.fn();
112
+ const { rerender } = render(<Reorderable order={['a', 'b', 'c']} onSettle={onSettle} />);
113
+ const scroller = screen.getByRole('region', { name: 'Test slides' });
114
+ setLayout(scroller, 300, 0);
115
+ const spy = vi.spyOn(scroller, 'scrollTo');
116
+
117
+ // 'b' (index 1, active) moves to index 0.
118
+ rerender(<Reorderable order={['b', 'a', 'c']} onSettle={onSettle} />);
119
+
120
+ expect(onSettle).toHaveBeenCalledWith(0);
121
+ expect(spy).toHaveBeenCalledWith({ left: 0, behavior: 'instant' });
122
+ });
123
+
124
+ it('does not re-snap when slide order is unchanged', () => {
125
+ function Reorderable({ onSettle }: { onSettle: (i: number) => void }) {
126
+ return <FiveSlides activeIndex={2} onSettle={onSettle} />;
127
+ }
128
+ const onSettle = vi.fn();
129
+ const { rerender } = render(<Reorderable onSettle={onSettle} />);
130
+ rerender(<Reorderable onSettle={onSettle} />);
131
+ expect(onSettle).not.toHaveBeenCalled();
132
+ });
133
+ });
@@ -0,0 +1,61 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { cleanup, render } from '@testing-library/react';
4
+ import { SwipableMobileCarousel } from '../SwipableMobileCarousel';
5
+ import { SwipableMobileCarouselSlide } from '../SwipableMobileCarouselSlide';
6
+
7
+ beforeEach(() => {
8
+ if (!Element.prototype.scrollTo) {
9
+ Element.prototype.scrollTo = vi.fn();
10
+ }
11
+ });
12
+
13
+ afterEach(() => {
14
+ cleanup();
15
+ vi.restoreAllMocks();
16
+ });
17
+
18
+ function renderWithStrayChild() {
19
+ return render(
20
+ <SwipableMobileCarousel activeIndex={0} onSettle={() => {}} aria-label="Test slides">
21
+ <SwipableMobileCarouselSlide slideKey="a" label="A">
22
+ content
23
+ </SwipableMobileCarouselSlide>
24
+ {/* stray non-Slide child — shifts index math for anything after it */}
25
+ <div>oops</div>
26
+ <SwipableMobileCarouselSlide slideKey="b" label="B">
27
+ content
28
+ </SwipableMobileCarouselSlide>
29
+ </SwipableMobileCarousel>,
30
+ );
31
+ }
32
+
33
+ describe('SwipableMobileCarousel dev-mode child-type guard', () => {
34
+ it('warns via console.error in development, mentioning the offending child', () => {
35
+ const originalEnv = process.env.NODE_ENV;
36
+ vi.stubEnv('NODE_ENV', 'development');
37
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
38
+
39
+ expect(() => renderWithStrayChild()).not.toThrow();
40
+
41
+ expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('<div>'));
42
+ vi.stubEnv('NODE_ENV', originalEnv ?? 'test');
43
+ });
44
+
45
+ it('does not call console.error in production', () => {
46
+ const originalEnv = process.env.NODE_ENV;
47
+ vi.stubEnv('NODE_ENV', 'production');
48
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
49
+
50
+ expect(() => renderWithStrayChild()).not.toThrow();
51
+
52
+ expect(errorSpy).not.toHaveBeenCalled();
53
+ vi.stubEnv('NODE_ENV', originalEnv ?? 'test');
54
+ });
55
+
56
+ it('never throws, even with a stray child (a miscounted slide degrades, it does not crash)', () => {
57
+ vi.stubEnv('NODE_ENV', 'development');
58
+ vi.spyOn(console, 'error').mockImplementation(() => {});
59
+ expect(() => renderWithStrayChild()).not.toThrow();
60
+ });
61
+ });
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ import { createContext } from 'react';
4
+
5
+ export interface CarouselSlideMountContextValue {
6
+ /** Whether this slide is within the carousel's mount window (the active
7
+ * slide ± its configured prefetchDistance). Kept out of the main .tsx
8
+ * file for React Fast Refresh hygiene (a file exporting only components
9
+ * refreshes more reliably than one mixing components and plain values). */
10
+ isMounted: boolean;
11
+ }
12
+
13
+ export const CarouselSlideMountContext = createContext<CarouselSlideMountContextValue | null>(null);
@@ -0,0 +1,49 @@
1
+ .dots {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ gap: var(--sv-space-2);
6
+ }
7
+
8
+ .dot {
9
+ /* A 6px visible dot is too small a hit target on its own — the button's
10
+ real box is larger (20px) with the dot itself painted by ::before and
11
+ centered inside, so tap area grows without changing the visible dot
12
+ size or the row's gap-based spacing math. */
13
+ position: relative;
14
+ width: 20px;
15
+ height: 20px;
16
+ padding: 0;
17
+ border: none;
18
+ background: transparent;
19
+ cursor: pointer;
20
+ }
21
+
22
+ .dot::before {
23
+ content: '';
24
+ position: absolute;
25
+ top: 50%;
26
+ left: 50%;
27
+ width: 6px;
28
+ height: 6px;
29
+ border-radius: 50%;
30
+ background: var(--sv-color-border-strong);
31
+ transform: translate(-50%, -50%);
32
+ transition: background 0.15s ease;
33
+ }
34
+
35
+ .dot:focus-visible {
36
+ outline: 2px solid var(--sv-color-focus-ring);
37
+ outline-offset: 2px;
38
+ border-radius: 50%;
39
+ }
40
+
41
+ .dotActive::before {
42
+ background: var(--sv-color-text-primary);
43
+ }
44
+
45
+ @media (hover: hover) {
46
+ .dot:not(.dotActive):hover::before {
47
+ background: var(--sv-color-text-muted);
48
+ }
49
+ }
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ import styles from './SwipableMobileCarouselDots.module.css';
4
+
5
+ export interface SwipableMobileCarouselDotsProps {
6
+ count: number;
7
+ activeIndex: number;
8
+ onJump: (index: number) => void;
9
+ /** Per-dot accessible names, e.g. ["Lists", "Starred", "Groceries"]. Falls
10
+ * back to "Slide N of count" for any index without one. */
11
+ labels?: (string | undefined)[];
12
+ /** Labels the whole group — required, no generic fallback (mirrors
13
+ * SwipableMobileCarousel's own required aria-label). */
14
+ 'aria-label': string;
15
+ className?: string;
16
+ }
17
+
18
+ /**
19
+ * SwipableMobileCarouselDots — a real, tappable, labeled slide indicator.
20
+ * Standalone (not carousel-only): reusable anywhere a set of positions needs
21
+ * a dot indicator (e.g. an image gallery, an onboarding stepper), and is also
22
+ * SwipableMobileCarousel's default `renderIndicator`.
23
+ *
24
+ * Replaces the `aria-hidden`, non-interactive dots pattern both
25
+ * sovereign-tasks and sovereign-shopper currently hand-roll — every dot here
26
+ * is a real `role="tab"` button with its own accessible name, reachable by
27
+ * keyboard. No roving tabIndex/arrow-key handling: `Tabs` (this library's
28
+ * other `role="tablist"` component) has none either, so this stays
29
+ * consistent with it rather than gold-plating past its sibling.
30
+ */
31
+ export function SwipableMobileCarouselDots({
32
+ count,
33
+ activeIndex,
34
+ onJump,
35
+ labels,
36
+ 'aria-label': ariaLabel,
37
+ className,
38
+ }: SwipableMobileCarouselDotsProps) {
39
+ return (
40
+ <div
41
+ role="tablist"
42
+ aria-label={ariaLabel}
43
+ className={[styles.dots, className].filter(Boolean).join(' ')}
44
+ >
45
+ {Array.from({ length: count }, (_, i) => {
46
+ const active = i === activeIndex;
47
+ const label = labels?.[i] ?? `Slide ${i + 1} of ${count}`;
48
+ return (
49
+ <button
50
+ key={i}
51
+ type="button"
52
+ role="tab"
53
+ aria-selected={active}
54
+ aria-label={label}
55
+ className={[styles.dot, active ? styles.dotActive : ''].filter(Boolean).join(' ')}
56
+ onClick={() => onJump(i)}
57
+ />
58
+ );
59
+ })}
60
+ </div>
61
+ );
62
+ }
@@ -0,0 +1,63 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it, vi } from 'vitest';
3
+ import { cleanup, fireEvent, render, screen } from '@testing-library/react';
4
+ import { SwipableMobileCarouselDots } from '../SwipableMobileCarouselDots';
5
+
6
+ afterEach(cleanup);
7
+
8
+ describe('SwipableMobileCarouselDots', () => {
9
+ it('renders a tablist with one tab per count, none aria-hidden', () => {
10
+ render(
11
+ <SwipableMobileCarouselDots count={3} activeIndex={0} onJump={() => {}} aria-label="Lists" />,
12
+ );
13
+ const list = screen.getByRole('tablist', { name: 'Lists' });
14
+ expect(list.getAttribute('aria-hidden')).toBeNull();
15
+ const tabs = screen.getAllByRole('tab');
16
+ expect(tabs).toHaveLength(3);
17
+ tabs.forEach((tab) => expect(tab.getAttribute('aria-hidden')).toBeNull());
18
+ });
19
+
20
+ it('marks only the active dot as aria-selected', () => {
21
+ render(
22
+ <SwipableMobileCarouselDots count={3} activeIndex={1} onJump={() => {}} aria-label="Lists" />,
23
+ );
24
+ const tabs = screen.getAllByRole('tab');
25
+ expect(tabs[0]?.getAttribute('aria-selected')).toBe('false');
26
+ expect(tabs[1]?.getAttribute('aria-selected')).toBe('true');
27
+ expect(tabs[2]?.getAttribute('aria-selected')).toBe('false');
28
+ });
29
+
30
+ it('uses the provided per-dot labels, falling back to "Slide N of count"', () => {
31
+ render(
32
+ <SwipableMobileCarouselDots
33
+ count={3}
34
+ activeIndex={0}
35
+ onJump={() => {}}
36
+ labels={['Lists', undefined, 'Groceries']}
37
+ aria-label="Lists"
38
+ />,
39
+ );
40
+ expect(screen.getByRole('tab', { name: 'Lists' })).toBeDefined();
41
+ expect(screen.getByRole('tab', { name: 'Slide 2 of 3' })).toBeDefined();
42
+ expect(screen.getByRole('tab', { name: 'Groceries' })).toBeDefined();
43
+ });
44
+
45
+ it('clicking a dot calls onJump with its index', () => {
46
+ const onJump = vi.fn();
47
+ render(
48
+ <SwipableMobileCarouselDots count={3} activeIndex={0} onJump={onJump} aria-label="Lists" />,
49
+ );
50
+ const thirdTab = screen.getAllByRole('tab')[2];
51
+ if (!thirdTab) throw new Error('expected a 3rd tab');
52
+ fireEvent.click(thirdTab);
53
+ expect(onJump).toHaveBeenCalledWith(2);
54
+ });
55
+
56
+ it('every dot is a real, focusable button (not a decorative element)', () => {
57
+ render(
58
+ <SwipableMobileCarouselDots count={2} activeIndex={0} onJump={() => {}} aria-label="Lists" />,
59
+ );
60
+ const tabs = screen.getAllByRole('tab');
61
+ tabs.forEach((tab) => expect(tab.tagName).toBe('BUTTON'));
62
+ });
63
+ });
@@ -0,0 +1,45 @@
1
+ /* Horizontal scroll container — masked-edge fade + hidden scrollbar, same
2
+ technique as NavTabs. Always active (not gated to a narrow viewport):
3
+ unlike NavTabs' item count, a table's column count is content-driven and
4
+ can overflow at any screen size. */
5
+ .scrollContainer {
6
+ overflow-x: auto;
7
+ scrollbar-width: none;
8
+ -webkit-overflow-scrolling: touch;
9
+ mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
10
+ }
11
+
12
+ .scrollContainer::-webkit-scrollbar {
13
+ display: none;
14
+ }
15
+
16
+ .table {
17
+ width: 100%;
18
+ border-collapse: collapse;
19
+ font-size: var(--sv-font-size-sm);
20
+ }
21
+
22
+ .head .row {
23
+ border-bottom: 1px solid var(--sv-color-border-strong);
24
+ }
25
+
26
+ .body .row {
27
+ border-bottom: 1px solid var(--sv-color-border);
28
+ }
29
+
30
+ .body .row:last-child {
31
+ border-bottom: none;
32
+ }
33
+
34
+ .th {
35
+ padding: var(--sv-space-2) var(--sv-space-3);
36
+ text-align: left;
37
+ font-weight: var(--sv-font-weight-semibold);
38
+ color: var(--sv-color-text-muted);
39
+ white-space: nowrap;
40
+ }
41
+
42
+ .td {
43
+ padding: var(--sv-space-2) var(--sv-space-3);
44
+ color: var(--sv-color-text-primary);
45
+ }