@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
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { DeviceOnlyGate } from '../components/DeviceOnlyGate/DeviceOnlyGate';
3
+
4
+ const sampleContent = (
5
+ <div style={{ padding: 'var(--sv-space-4)' }}>
6
+ <p style={{ margin: 0, fontFamily: 'var(--sv-font-family)' }}>
7
+ The wrapped content — a wallet's card list, a health log, anything a `device-only` plugin
8
+ keeps entirely on-device.
9
+ </p>
10
+ </div>
11
+ );
12
+
13
+ const meta = {
14
+ title: 'Components/DeviceOnlyGate',
15
+ component: DeviceOnlyGate,
16
+ parameters: { layout: 'padded' },
17
+ } satisfies Meta<typeof DeviceOnlyGate>;
18
+
19
+ export default meta;
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ // `available` is the caller's own isDeviceOnlyTierAvailable() result — a
23
+ // real bridge-handshake check, not something this story can drive live, so
24
+ // it's passed directly as an arg here instead.
25
+ export const Available: Story = {
26
+ args: { children: sampleContent, available: true, surfaceName: 'Wallet' },
27
+ };
28
+
29
+ export const Restricted: Story = {
30
+ args: { children: sampleContent, available: false, surfaceName: 'Wallet' },
31
+ };
32
+
33
+ export const RestrictedGenericPhrasing: Story = {
34
+ args: { children: sampleContent, available: false },
35
+ };
@@ -0,0 +1,57 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { DeviceStorageKeyGate } from '../components/DeviceStorageKeyGate/DeviceStorageKeyGate';
3
+
4
+ const sampleContent = (
5
+ <div style={{ padding: 'var(--sv-space-4)' }}>
6
+ <p style={{ margin: 0, fontFamily: 'var(--sv-font-family)' }}>
7
+ The wrapped content — a notes list, a health log, anything a `device-only` plugin keeps
8
+ entirely on-device.
9
+ </p>
10
+ </div>
11
+ );
12
+
13
+ const setupAction = (
14
+ <a href="/account/security" style={{ color: 'var(--sv-color-accent)' }}>
15
+ Go to Account → Security
16
+ </a>
17
+ );
18
+
19
+ const meta = {
20
+ title: 'Components/DeviceStorageKeyGate',
21
+ component: DeviceStorageKeyGate,
22
+ parameters: { layout: 'padded' },
23
+ } satisfies Meta<typeof DeviceStorageKeyGate>;
24
+
25
+ export default meta;
26
+ type Story = StoryObj<typeof meta>;
27
+
28
+ // `status` is the caller's own getDeviceStorageKeyStatus() result — an OPFS
29
+ // read this story can't drive live, so it's passed directly as an arg here.
30
+ export const SetUp: Story = {
31
+ args: { children: sampleContent, status: 'set-up', surfaceName: 'Notes' },
32
+ };
33
+
34
+ export const NotSetUp: Story = {
35
+ args: {
36
+ children: sampleContent,
37
+ status: 'not-set-up',
38
+ surfaceName: 'Notes',
39
+ setupAction,
40
+ },
41
+ };
42
+
43
+ export const NotSetUpGenericPhrasing: Story = {
44
+ args: { children: sampleContent, status: 'not-set-up', setupAction },
45
+ };
46
+
47
+ export const Unsupported: Story = {
48
+ args: { children: sampleContent, status: 'unsupported', surfaceName: 'Notes' },
49
+ };
50
+
51
+ export const NoDeviceAuth: Story = {
52
+ args: { children: sampleContent, status: 'no-device-auth', surfaceName: 'Notes' },
53
+ };
54
+
55
+ export const Checking: Story = {
56
+ args: { children: sampleContent, status: 'checking', surfaceName: 'Notes' },
57
+ };
@@ -2,11 +2,17 @@ import { useState } from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react-vite';
3
3
  import { Card } from '../components/Card/Card';
4
4
  import {
5
+ useCarouselRouteSync,
5
6
  useCommitOnEnterOrBlur,
6
7
  useDoubleTapHandler,
7
8
  useIsMobile,
9
+ useIsOffline,
8
10
  useLongPress,
11
+ useOfflineTileState,
12
+ useResponsiveLayout,
9
13
  useSingleOrDoubleTap,
14
+ useSnapCarousel,
15
+ useSwipeReveal,
10
16
  } from '../hooks';
11
17
 
12
18
  // ---------------------------------------------------------------------------
@@ -331,6 +337,385 @@ function IsMobileDemo() {
331
337
  );
332
338
  }
333
339
 
340
+ function IsOfflineDemo() {
341
+ const isOffline = useIsOffline();
342
+ return (
343
+ <div
344
+ style={{
345
+ padding: 'var(--sv-space-4)',
346
+ borderRadius: 'var(--sv-radius-md)',
347
+ background: isOffline
348
+ ? 'var(--sv-color-warning-surface)'
349
+ : 'var(--sv-color-success-surface)',
350
+ color: isOffline ? 'var(--sv-color-warning-text)' : 'var(--sv-color-success-text)',
351
+ fontFamily: ff,
352
+ fontSize: 'var(--sv-font-size-sm)',
353
+ fontWeight: 600,
354
+ textAlign: 'center',
355
+ }}
356
+ >
357
+ useIsOffline() → {String(isOffline)} — toggle DevTools &gt; Network &gt; Offline (or your OS's
358
+ airplane mode) to see this flip.
359
+ </div>
360
+ );
361
+ }
362
+
363
+ function OfflineTileStateDemo() {
364
+ const [tier, setTier] = useState<'none' | 'offline-first' | 'device-only'>('device-only');
365
+ const [deviceOnlyAvailable, setDeviceOnlyAvailable] = useState(false);
366
+ const state = useOfflineTileState(tier === 'none' ? undefined : tier, deviceOnlyAvailable);
367
+
368
+ return (
369
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--sv-space-3)' }}>
370
+ <div
371
+ style={{ display: 'flex', gap: 'var(--sv-space-4)', alignItems: 'center', fontFamily: ff }}
372
+ >
373
+ <label style={{ fontSize: 'var(--sv-font-size-sm)' }}>
374
+ offline tier:{' '}
375
+ <select value={tier} onChange={(e) => setTier(e.target.value as typeof tier)}>
376
+ <option value="none">(none)</option>
377
+ <option value="offline-first">offline-first</option>
378
+ <option value="device-only">device-only</option>
379
+ </select>
380
+ </label>
381
+ <label style={{ fontSize: 'var(--sv-font-size-sm)' }}>
382
+ <input
383
+ type="checkbox"
384
+ checked={deviceOnlyAvailable}
385
+ onChange={(e) => setDeviceOnlyAvailable(e.target.checked)}
386
+ />{' '}
387
+ deviceOnlyAvailable
388
+ </label>
389
+ </div>
390
+ <div
391
+ style={{
392
+ padding: 'var(--sv-space-4)',
393
+ borderRadius: 'var(--sv-radius-md)',
394
+ background:
395
+ state === 'connectivity-dimmed'
396
+ ? 'var(--sv-color-warning-surface)'
397
+ : state === 'capability-restricted'
398
+ ? 'var(--sv-color-info-surface)'
399
+ : 'var(--sv-color-success-surface)',
400
+ color:
401
+ state === 'connectivity-dimmed'
402
+ ? 'var(--sv-color-warning-text)'
403
+ : state === 'capability-restricted'
404
+ ? 'var(--sv-color-info-text)'
405
+ : 'var(--sv-color-success-text)',
406
+ fontFamily: ff,
407
+ fontSize: 'var(--sv-font-size-sm)',
408
+ fontWeight: 600,
409
+ textAlign: 'center',
410
+ }}
411
+ >
412
+ useOfflineTileState() → {String(state)}
413
+ </div>
414
+ <p
415
+ style={{
416
+ margin: 0,
417
+ fontFamily: ff,
418
+ fontSize: 'var(--sv-font-size-xs)',
419
+ color: 'var(--sv-color-text-muted)',
420
+ }}
421
+ >
422
+ connectivity-dimmed also reacts live to DevTools &gt; Network &gt; Offline — try it with
423
+ tier set to (none).
424
+ </p>
425
+ </div>
426
+ );
427
+ }
428
+
429
+ function SwipeRevealDemo() {
430
+ const [open, setOpen] = useState(false);
431
+ const [events, setEvents] = useState<string[]>([]);
432
+ const log = (msg: string) =>
433
+ setEvents((e) => [...e, `${new Date().toLocaleTimeString()} — ${msg}`]);
434
+ const { rowRef, handlers } = useSwipeReveal({
435
+ revealWidth: 88,
436
+ open,
437
+ onOpen: () => {
438
+ setOpen(true);
439
+ log('opened');
440
+ },
441
+ onClose: () => {
442
+ setOpen(false);
443
+ log('closed');
444
+ },
445
+ });
446
+
447
+ return (
448
+ <div>
449
+ <div
450
+ style={{
451
+ position: 'relative',
452
+ overflow: 'hidden',
453
+ borderRadius: 'var(--sv-radius-md)',
454
+ border: '1px solid var(--sv-color-border)',
455
+ }}
456
+ >
457
+ <div
458
+ style={{
459
+ position: 'absolute',
460
+ inset: 0,
461
+ display: 'flex',
462
+ justifyContent: 'flex-end',
463
+ }}
464
+ >
465
+ <button
466
+ type="button"
467
+ onClick={() => {
468
+ setOpen(false);
469
+ log('Delete tapped');
470
+ }}
471
+ style={{
472
+ width: 88,
473
+ border: 'none',
474
+ background: 'var(--sv-color-error-surface)',
475
+ color: 'var(--sv-color-error-text)',
476
+ fontFamily: ff,
477
+ fontSize: 'var(--sv-font-size-sm)',
478
+ fontWeight: 600,
479
+ cursor: 'pointer',
480
+ }}
481
+ >
482
+ Delete
483
+ </button>
484
+ </div>
485
+ <div
486
+ ref={rowRef}
487
+ {...handlers}
488
+ style={{
489
+ position: 'relative',
490
+ padding: 'var(--sv-space-4)',
491
+ background: 'var(--sv-color-surface)',
492
+ fontFamily: ff,
493
+ fontSize: 'var(--sv-font-size-sm)',
494
+ color: 'var(--sv-color-text-primary)',
495
+ touchAction: 'pan-y',
496
+ transform: open ? 'translateX(-88px)' : undefined,
497
+ transition: 'transform 150ms ease-out',
498
+ }}
499
+ >
500
+ Drag me left to reveal Delete
501
+ </div>
502
+ </div>
503
+ <EventLog events={events} />
504
+ <Callout type="info">
505
+ Drag with a mouse in this preview, or touch on a real device/device toolbar. The hook only
506
+ writes an imperative transform during the drag itself — the CSS transition above only takes
507
+ over once the gesture resolves to open or closed on release.
508
+ </Callout>
509
+ </div>
510
+ );
511
+ }
512
+
513
+ function SnapCarouselDemo() {
514
+ const slides = ['Lists', 'Groceries', 'Errands'];
515
+ const [index, setIndex] = useState(0);
516
+ const [events, setEvents] = useState<string[]>([]);
517
+ const log = (msg: string) =>
518
+ setEvents((e) => [...e, `${new Date().toLocaleTimeString()} — ${msg}`]);
519
+ const { scrollRef, scrollToIndex } = useSnapCarousel({
520
+ itemCount: slides.length,
521
+ onSettle: (i) => {
522
+ setIndex(i);
523
+ log(`settled on slide ${i}`);
524
+ },
525
+ });
526
+
527
+ return (
528
+ <div>
529
+ <div
530
+ ref={scrollRef}
531
+ style={{
532
+ display: 'flex',
533
+ overflowX: 'auto',
534
+ scrollSnapType: 'x mandatory',
535
+ borderRadius: 'var(--sv-radius-md)',
536
+ border: '1px solid var(--sv-color-border)',
537
+ }}
538
+ >
539
+ {slides.map((label, i) => (
540
+ <div
541
+ key={label}
542
+ style={{
543
+ flex: '0 0 100%',
544
+ scrollSnapAlign: 'start',
545
+ padding: 'var(--sv-space-6)',
546
+ textAlign: 'center',
547
+ fontFamily: ff,
548
+ fontSize: 'var(--sv-font-size-sm)',
549
+ color: 'var(--sv-color-text-primary)',
550
+ background:
551
+ i === index ? 'var(--sv-color-surface-sunken)' : 'var(--sv-color-surface)',
552
+ }}
553
+ >
554
+ {label}
555
+ </div>
556
+ ))}
557
+ </div>
558
+ <div style={{ display: 'flex', gap: 'var(--sv-space-2)', marginTop: 'var(--sv-space-3)' }}>
559
+ {slides.map((label, i) => (
560
+ <button
561
+ key={label}
562
+ type="button"
563
+ onClick={() => scrollToIndex(i)}
564
+ style={{
565
+ padding: 'var(--sv-space-1) var(--sv-space-3)',
566
+ borderRadius: 'var(--sv-radius-md)',
567
+ border: '1px solid var(--sv-color-border)',
568
+ background: i === index ? 'var(--sv-color-accent)' : 'var(--sv-color-surface)',
569
+ color:
570
+ i === index ? 'var(--sv-color-text-on-accent)' : 'var(--sv-color-text-primary)',
571
+ fontFamily: ff,
572
+ fontSize: '0.75rem',
573
+ cursor: 'pointer',
574
+ }}
575
+ >
576
+ Slide {i}
577
+ </button>
578
+ ))}
579
+ </div>
580
+ <EventLog events={events} />
581
+ <Callout type="info">
582
+ Swipe or scroll the strip above horizontally, or use the buttons. Settle detection is
583
+ debounced (120ms default) rather than tied to the <code>scrollend</code> event, which
584
+ pre-17.4 iOS Safari/WKWebView doesn&apos;t support.
585
+ </Callout>
586
+ </div>
587
+ );
588
+ }
589
+
590
+ function ResponsiveLayoutDemo() {
591
+ const { isMobile, value } = useResponsiveLayout({
592
+ web: (
593
+ <div
594
+ style={{
595
+ padding: 'var(--sv-space-6)',
596
+ textAlign: 'center',
597
+ fontFamily: ff,
598
+ fontSize: 'var(--sv-font-size-sm)',
599
+ color: 'var(--sv-color-text-primary)',
600
+ }}
601
+ >
602
+ Web tree — a three-column layout, for example.
603
+ </div>
604
+ ),
605
+ mobile: (
606
+ <div
607
+ style={{
608
+ padding: 'var(--sv-space-6)',
609
+ textAlign: 'center',
610
+ fontFamily: ff,
611
+ fontSize: 'var(--sv-font-size-sm)',
612
+ color: 'var(--sv-color-text-primary)',
613
+ }}
614
+ >
615
+ Mobile tree — an entirely different component, not a CSS squeeze.
616
+ </div>
617
+ ),
618
+ });
619
+
620
+ return (
621
+ <div>
622
+ <div
623
+ style={{
624
+ borderRadius: 'var(--sv-radius-md)',
625
+ border: '1px solid var(--sv-color-border)',
626
+ background: 'var(--sv-color-surface)',
627
+ }}
628
+ >
629
+ {value}
630
+ </div>
631
+ <Callout type="info">
632
+ Currently showing the <strong>{isMobile ? 'mobile' : 'web'}</strong> tree. Resize the
633
+ Storybook viewport (or the toolbar&apos;s viewport picker) below 768px to see it swap — only
634
+ the active side is ever mounted, the other tree doesn&apos;t exist in the DOM at all.
635
+ </Callout>
636
+ </div>
637
+ );
638
+ }
639
+
640
+ function CarouselRouteSyncDemo() {
641
+ const PATHS = ['/tasks', '/tasks/starred', '/tasks/groceries'];
642
+ const LABELS = ['Lists', 'Starred', 'Groceries'];
643
+ const [pathname, setPathname] = useState(PATHS[0] as string);
644
+ const [events, setEvents] = useState<string[]>([]);
645
+ const log = (msg: string) =>
646
+ setEvents((e) => [...e, `${new Date().toLocaleTimeString()} — ${msg}`]);
647
+
648
+ const { activeIndex, onSettle } = useCarouselRouteSync({
649
+ indexForPathname: (p) => Math.max(0, PATHS.indexOf(p)),
650
+ pathForIndex: (i) => PATHS[i] ?? '/tasks',
651
+ pathname,
652
+ onNavigate: (path) => {
653
+ log(`onNavigate("${path}") — simulating router.replace`);
654
+ setPathname(path);
655
+ },
656
+ });
657
+
658
+ return (
659
+ <div>
660
+ <div style={{ display: 'flex', gap: 'var(--sv-space-2)', marginBottom: 'var(--sv-space-3)' }}>
661
+ {LABELS.map((label, i) => (
662
+ <button
663
+ key={label}
664
+ type="button"
665
+ onClick={() => {
666
+ log(`swipe settled on "${label}" (index ${i})`);
667
+ onSettle(i);
668
+ }}
669
+ style={{
670
+ padding: 'var(--sv-space-2) var(--sv-space-3)',
671
+ borderRadius: 'var(--sv-radius-md)',
672
+ border: '1px solid var(--sv-color-border)',
673
+ background: i === activeIndex ? 'var(--sv-color-accent)' : 'var(--sv-color-surface)',
674
+ color:
675
+ i === activeIndex
676
+ ? 'var(--sv-color-text-on-accent)'
677
+ : 'var(--sv-color-text-primary)',
678
+ fontFamily: ff,
679
+ fontSize: '0.8rem',
680
+ cursor: 'pointer',
681
+ }}
682
+ >
683
+ {label}
684
+ </button>
685
+ ))}
686
+ <button
687
+ type="button"
688
+ onClick={() => {
689
+ const other = PATHS[(activeIndex + 1) % PATHS.length] as string;
690
+ log(`external nav to "${other}" (e.g. a tapped <Link>, browser back/forward)`);
691
+ setPathname(other);
692
+ }}
693
+ style={{
694
+ padding: 'var(--sv-space-2) var(--sv-space-3)',
695
+ borderRadius: 'var(--sv-radius-md)',
696
+ border: '1px dashed var(--sv-color-border)',
697
+ background: 'var(--sv-color-surface)',
698
+ color: 'var(--sv-color-text-primary)',
699
+ fontFamily: ff,
700
+ fontSize: '0.8rem',
701
+ cursor: 'pointer',
702
+ }}
703
+ >
704
+ Simulate external nav
705
+ </button>
706
+ </div>
707
+ <EventLog events={events} />
708
+ <Callout type="info">
709
+ This demo fakes a router with local <code>useState</code> — in a real app, pass{' '}
710
+ <code>next/navigation</code>&apos;s <code>usePathname()</code> as <code>pathname</code> and{' '}
711
+ <code>router.replace</code> as <code>onNavigate</code>. Note the &quot;swipe settled&quot;
712
+ buttons never log a redundant external-nav resync afterwards — that&apos;s the isInternalNav
713
+ dance being handled internally.
714
+ </Callout>
715
+ </div>
716
+ );
717
+ }
718
+
334
719
  // ---------------------------------------------------------------------------
335
720
  // Main story component
336
721
  // ---------------------------------------------------------------------------
@@ -412,6 +797,104 @@ function InteractionHooksDoc() {
412
797
 
413
798
  const isMobile = useIsMobile(); // defaults to MOBILE_BREAKPOINT_PX (768)`}</CodeBlock>
414
799
  </section>
800
+
801
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
802
+ <SectionHeader
803
+ title="useIsOffline"
804
+ subtitle="SSR-safe navigator.onLine tracking, shared by OfflineBanner, the login page, and Console/Account's offline gate (research 0012)."
805
+ />
806
+ <Card padding="md">
807
+ <IsOfflineDemo />
808
+ </Card>
809
+ <CodeBlock>{`import { useIsOffline } from '@sovereignfs/ui';
810
+
811
+ const isOffline = useIsOffline();`}</CodeBlock>
812
+ </section>
813
+
814
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
815
+ <SectionHeader
816
+ title="useOfflineTileState"
817
+ subtitle="Which of the two app-tile states, if any, applies given a plugin's declared offline tier — connectivity-dimmed (no tier, offline right now) vs. capability-restricted (device-only, unavailable here), never conflated (research 0012)."
818
+ />
819
+ <Card padding="md">
820
+ <OfflineTileStateDemo />
821
+ </Card>
822
+ <CodeBlock>{`import { useOfflineTileState } from '@sovereignfs/ui';
823
+
824
+ // deviceOnlyAvailable comes from isDeviceOnlyTierAvailable() in
825
+ // @sovereignfs/sdk/device-client — passed in, not computed here, so
826
+ // @sovereignfs/ui never depends on @sovereignfs/sdk.
827
+ const state = useOfflineTileState(plugin.offline, deviceOnlyAvailable);
828
+ // 'connectivity-dimmed' | 'capability-restricted' | null`}</CodeBlock>
829
+ </section>
830
+
831
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
832
+ <SectionHeader
833
+ title="useSwipeReveal"
834
+ subtitle="Horizontal swipe-to-reveal for a row's Done/Delete actions — extracted from sovereign-tasks' two independent hand-rolled implementations (RFC 0079)."
835
+ />
836
+ <Card padding="md">
837
+ <SwipeRevealDemo />
838
+ </Card>
839
+ <CodeBlock>{`const { rowRef, handlers } = useSwipeReveal({
840
+ revealWidth: 88,
841
+ open,
842
+ onOpen: () => setOpen(true),
843
+ onClose: () => setOpen(false),
844
+ });
845
+ <div ref={rowRef} {...handlers} style={{ transform: open ? 'translateX(-88px)' : undefined }}>
846
+ Row content
847
+ </div>`}</CodeBlock>
848
+ </section>
849
+
850
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
851
+ <SectionHeader
852
+ title="useSnapCarousel"
853
+ subtitle="Debounced settled-slide detection over a native scroll-snap container — extracted from sovereign-tasks and sovereign-shopper's independently duplicated carousels (RFC 0079)."
854
+ />
855
+ <Card padding="md">
856
+ <SnapCarouselDemo />
857
+ </Card>
858
+ <CodeBlock>{`const { scrollRef, scrollToIndex } = useSnapCarousel({
859
+ itemCount: slides.length,
860
+ onSettle: (index) => setActiveIndex(index),
861
+ });
862
+ <div ref={scrollRef} style={{ display: 'flex', overflowX: 'auto', scrollSnapType: 'x mandatory' }}>
863
+ {slides.map((slide) => <div style={{ scrollSnapAlign: 'start' }}>{slide}</div>)}
864
+ </div>`}</CodeBlock>
865
+ </section>
866
+
867
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
868
+ <SectionHeader
869
+ title="useResponsiveLayout"
870
+ subtitle="Picks between a web and mobile value for the current viewport — formalizes the 'render an entirely different tree below a breakpoint' fork plugins have hand-rolled per plugin. See also the ResponsiveSurface component for the equivalent as plain JSX."
871
+ />
872
+ <Card padding="md">
873
+ <ResponsiveLayoutDemo />
874
+ </Card>
875
+ <CodeBlock>{`const { isMobile, value } = useResponsiveLayout({ web: <WebShell />, mobile: <MobileShell /> });
876
+ // or, as a component:
877
+ <ResponsiveSurface web={<WebShell />} mobile={<MobileShell />} />`}</CodeBlock>
878
+ </section>
879
+
880
+ <section style={{ marginBottom: 'var(--sv-space-10)' }}>
881
+ <SectionHeader
882
+ title="useCarouselRouteSync"
883
+ subtitle="Router-agnostic pathname↔slide-index sync for SwipableMobileCarousel — centralizes the isInternalNav dance both sovereign-tasks and sovereign-shopper hand-roll identically today."
884
+ />
885
+ <Card padding="md">
886
+ <CarouselRouteSyncDemo />
887
+ </Card>
888
+ <CodeBlock>{`const { activeIndex, onSettle } = useCarouselRouteSync({
889
+ indexForPathname: (p) => indexForPathname(p, lists), // your plugin's own logic, unchanged
890
+ pathForIndex: (i) => pathForIndex(i, lists),
891
+ pathname: usePathname(),
892
+ onNavigate: (path) => router.replace(path, { scroll: false }),
893
+ });
894
+ <SwipableMobileCarousel activeIndex={activeIndex} onSettle={onSettle} aria-label="Task lists">
895
+ ...
896
+ </SwipableMobileCarousel>`}</CodeBlock>
897
+ </section>
415
898
  </div>
416
899
  );
417
900
  }