@justanarthur/modo-ui 2.0.0 → 2.2.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 (221) hide show
  1. package/blocks/desktop-shell/index.tsx +2 -1
  2. package/components/data-display/sparkline/examples.mdx +79 -0
  3. package/components/data-display/sparkline/index.tsx +158 -0
  4. package/components/data-display/sparkline/live-demo.tsx +36 -0
  5. package/components/feedback/meter/examples.mdx +25 -0
  6. package/components/feedback/meter/index.tsx +23 -7
  7. package/components/feedback/meter/timer-demo.tsx +37 -0
  8. package/components/inputs/checkbox/index.tsx +5 -0
  9. package/components/inputs/combobox/index.tsx +9 -4
  10. package/components/inputs/radio/index.tsx +5 -0
  11. package/components/inputs/select/index.tsx +23 -3
  12. package/components/inputs/slider/comfortable.tsx +10 -4
  13. package/components/inputs/slider/compact.tsx +153 -71
  14. package/components/inputs/slider/examples.mdx +24 -0
  15. package/components/inputs/slider/geometry.ts +18 -6
  16. package/components/inputs/slider/index.tsx +30 -8
  17. package/components/inputs/slider/value-display.tsx +16 -9
  18. package/components/inputs/switch/index.tsx +7 -2
  19. package/components/inputs/textarea/examples.mdx +19 -0
  20. package/components/inputs/textarea/index.tsx +42 -5
  21. package/components/navigation/sidebar/sidebar-group.tsx +2 -1
  22. package/components/navigation/sidebar/sidebar-menu-sub.tsx +2 -1
  23. package/components/navigation/sidebar/sidebar-shell.tsx +2 -1
  24. package/components/navigation/tree/index.tsx +2 -1
  25. package/components/overlays/dropdown/index.tsx +50 -8
  26. package/components/overlays/dropdown/submenu.tsx +41 -10
  27. package/components/overlays/tooltip/examples.mdx +13 -0
  28. package/components/overlays/tooltip/index.tsx +58 -16
  29. package/dist/base.css +4 -0
  30. package/dist/blocks/desktop-shell/index.js +28 -27
  31. package/dist/blocks/sidebar-app/index.js +38 -37
  32. package/dist/components/actions/button/index.js +4 -4
  33. package/dist/components/actions/copy/index.js +12 -12
  34. package/dist/components/containers/accordion/index.d.ts +1 -1
  35. package/dist/components/containers/accordion/index.js +16 -16
  36. package/dist/components/containers/card/index.js +14 -14
  37. package/dist/components/data-display/avatar/index.js +3 -3
  38. package/dist/components/data-display/badge/index.js +2 -2
  39. package/dist/components/data-display/diff/index.js +4 -4
  40. package/dist/components/data-display/list/index.js +3 -3
  41. package/dist/components/data-display/log-view/index.js +8 -8
  42. package/dist/components/data-display/markdown/index.js +15 -15
  43. package/dist/components/data-display/sparkline/index.d.ts +44 -0
  44. package/dist/components/data-display/sparkline/index.js +11 -0
  45. package/dist/components/data-display/table/index.js +9 -9
  46. package/dist/components/feedback/empty-state/index.js +3 -3
  47. package/dist/components/feedback/meter/index.d.ts +9 -1
  48. package/dist/components/feedback/meter/index.js +2 -2
  49. package/dist/components/feedback/progress/index.js +2 -2
  50. package/dist/components/inputs/checkbox/index.d.ts +2 -0
  51. package/dist/components/inputs/checkbox/index.js +13 -13
  52. package/dist/components/inputs/choice-list/index.js +10 -10
  53. package/dist/components/inputs/color-picker/index.js +22 -22
  54. package/dist/components/inputs/combobox/index.d.ts +1 -1
  55. package/dist/components/inputs/combobox/index.js +21 -21
  56. package/dist/components/inputs/date-time/calendar/index.js +9 -9
  57. package/dist/components/inputs/date-time/date-picker/index.js +28 -28
  58. package/dist/components/inputs/date-time/date-range-picker/index.js +28 -28
  59. package/dist/components/inputs/date-time/duration-picker/index.js +27 -27
  60. package/dist/components/inputs/date-time/month-picker/index.js +26 -26
  61. package/dist/components/inputs/date-time/time-picker/index.js +27 -27
  62. package/dist/components/inputs/editable-text/index.js +2 -2
  63. package/dist/components/inputs/field/index.js +5 -5
  64. package/dist/components/inputs/file-dropzone/index.js +8 -8
  65. package/dist/components/inputs/input/index.js +6 -6
  66. package/dist/components/inputs/key-value/index.js +12 -12
  67. package/dist/components/inputs/number-input/index.js +7 -7
  68. package/dist/components/inputs/radio/index.d.ts +2 -0
  69. package/dist/components/inputs/radio/index.js +12 -12
  70. package/dist/components/inputs/search/index.js +23 -23
  71. package/dist/components/inputs/select/index.d.ts +22 -4
  72. package/dist/components/inputs/select/index.js +22 -22
  73. package/dist/components/inputs/slider/index.d.ts +12 -3
  74. package/dist/components/inputs/slider/index.js +4 -4
  75. package/dist/components/inputs/switch/index.d.ts +2 -0
  76. package/dist/components/inputs/switch/index.js +9 -9
  77. package/dist/components/inputs/textarea/index.d.ts +8 -1
  78. package/dist/components/inputs/textarea/index.js +4 -4
  79. package/dist/components/navigation/breadcrumb/index.js +25 -25
  80. package/dist/components/navigation/navigation-menu/index.js +17 -17
  81. package/dist/components/navigation/pagination/index.js +16 -16
  82. package/dist/components/navigation/sidebar/index.js +26 -25
  83. package/dist/components/navigation/tabs/index.js +13 -13
  84. package/dist/components/navigation/tree/index.js +10 -9
  85. package/dist/components/overlays/alert-dialog/index.d.ts +3 -3
  86. package/dist/components/overlays/alert-dialog/index.js +15 -15
  87. package/dist/components/overlays/command/index.d.ts +1 -1
  88. package/dist/components/overlays/command/index.js +21 -21
  89. package/dist/components/overlays/context-menu/index.d.ts +20 -1
  90. package/dist/components/overlays/context-menu/index.js +25 -25
  91. package/dist/components/overlays/dialog/index.d.ts +3 -3
  92. package/dist/components/overlays/dialog/index.js +14 -14
  93. package/dist/components/overlays/dropdown/index.d.ts +30 -8
  94. package/dist/components/overlays/dropdown/index.js +24 -24
  95. package/dist/components/overlays/lightbox/index.js +12 -12
  96. package/dist/components/overlays/popover/index.d.ts +6 -6
  97. package/dist/components/overlays/popover/index.js +11 -11
  98. package/dist/components/overlays/preview-card/index.js +10 -10
  99. package/dist/components/overlays/sheet/index.d.ts +3 -3
  100. package/dist/components/overlays/sheet/index.js +15 -15
  101. package/dist/components/overlays/toast/index.d.ts +1 -1
  102. package/dist/components/overlays/toast/index.js +11 -11
  103. package/dist/components/overlays/tooltip/index.d.ts +35 -10
  104. package/dist/components/overlays/tooltip/index.js +8 -8
  105. package/dist/docs/index.js +18 -17
  106. package/dist/index.d.ts +330 -228
  107. package/dist/index.js +82 -77
  108. package/dist/lib/fluid-hover-highlight.js +4 -4
  109. package/dist/lib/focus-ring.js +2 -2
  110. package/dist/lib/goo-indicator.js +3 -3
  111. package/dist/lib/inert.d.ts +7 -0
  112. package/dist/lib/inert.js +6 -0
  113. package/dist/lib/morph-layers.js +4 -4
  114. package/dist/lib/morph-part.js +2 -2
  115. package/dist/lib/overlay.d.ts +20 -13
  116. package/dist/lib/overlay.js +5 -4
  117. package/dist/lib/popup-rows.js +2 -2
  118. package/dist/lib/popup-surface.js +7 -7
  119. package/dist/lib/scroll-column.js +6 -6
  120. package/dist/lib/slot.d.ts +5 -2
  121. package/dist/lib/slot.js +1 -1
  122. package/dist/lib/use-merge-split.js +4 -4
  123. package/dist/lib/use-morph.js +2 -2
  124. package/dist/preset.d.ts +1 -0
  125. package/dist/preset.js +1 -0
  126. package/dist/primitives/content/code/index.js +3 -3
  127. package/dist/primitives/layout/resizable/index.js +2 -2
  128. package/dist/primitives/layout/sortable/index.js +5 -5
  129. package/dist/primitives/systems/craft/index.js +3 -3
  130. package/dist/primitives/systems/fluid-hover/index.js +6 -6
  131. package/dist/primitives/systems/morph/index.js +14 -14
  132. package/dist/primitives/systems/motion/index.js +7 -7
  133. package/dist/primitives/systems/sizes/index.js +2 -2
  134. package/dist/shared/{components-280grw6q.js → components-09n5hgmx.js} +2 -2
  135. package/dist/shared/{components-1f3a7gmg.js → components-151vndgm.js} +3 -3
  136. package/dist/shared/{components-14wzcym0.js → components-16wx5av1.js} +6 -6
  137. package/dist/shared/{components-yf2gtq68.js → components-19e2wpxc.js} +9 -6
  138. package/dist/shared/{components-rzy6h7s4.js → components-1nqp7wqr.js} +1 -1
  139. package/dist/shared/components-2myjk2zf.js +8 -0
  140. package/dist/shared/{components-9rebr89j.js → components-2q0m4mxf.js} +2 -2
  141. package/dist/shared/{components-1asw2ph0.js → components-2zr49v82.js} +3 -3
  142. package/dist/shared/{components-wq9hrera.js → components-313rmbxy.js} +2 -2
  143. package/dist/shared/{components-0h2mng6m.js → components-31pkxwfz.js} +1 -1
  144. package/dist/shared/{components-w2at9ntm.js → components-3cvwrzc1.js} +3 -3
  145. package/dist/shared/{components-n0gbyp5a.js → components-4xd21p2p.js} +6 -6
  146. package/dist/shared/{components-t0c1rw40.js → components-7v6869ga.js} +1 -1
  147. package/dist/shared/{components-kwxye0an.js → components-7wjkag2j.js} +4 -2
  148. package/dist/shared/{components-fqsgd07c.js → components-85dz3xx3.js} +4 -4
  149. package/dist/shared/{components-3rvrdsa9.js → components-8qkd3659.js} +1 -1
  150. package/dist/shared/{components-me742146.js → components-8qwbwtv9.js} +5 -5
  151. package/dist/shared/{components-nxqrw789.js → components-90sfqz5t.js} +1 -1
  152. package/dist/shared/{components-b9bj65j3.js → components-90y8qwxv.js} +9 -9
  153. package/dist/shared/{components-g35n8tzm.js → components-95kp19zn.js} +1 -1
  154. package/dist/shared/{components-nhmgr5xc.js → components-9e5fpy3v.js} +14 -11
  155. package/dist/shared/{components-a1ms36qq.js → components-9hysh6d3.js} +1 -1
  156. package/dist/shared/{components-hcftn5r8.js → components-9s9vb2w0.js} +7 -4
  157. package/dist/shared/{components-vfreweq3.js → components-a3edrqpb.js} +3 -3
  158. package/dist/shared/{components-ee09xmkh.js → components-afj2ajea.js} +8 -5
  159. package/dist/shared/{components-ev0ytbqb.js → components-ajgwbabq.js} +4 -4
  160. package/dist/shared/{components-62510420.js → components-dr5c27yd.js} +6 -6
  161. package/dist/shared/{components-s90v3jpr.js → components-fqdh9ysk.js} +68 -19
  162. package/dist/shared/{components-2m2hg11x.js → components-gfw4zk8b.js} +8 -8
  163. package/dist/shared/{components-z0kz9rxj.js → components-gvwxswpr.js} +1 -1
  164. package/dist/shared/{components-p32aqk3q.js → components-h9se5cz5.js} +110 -73
  165. package/dist/shared/{components-464zs8v6.js → components-hbqyf35a.js} +41 -34
  166. package/dist/shared/{components-77gxngmc.js → components-jd21f3mb.js} +8 -8
  167. package/dist/shared/{components-xnkc892z.js → components-mamtvenk.js} +2 -2
  168. package/dist/shared/{components-1hga6pkn.js → components-mcnyaaep.js} +3 -3
  169. package/dist/shared/{components-h0x2pj2y.js → components-mpx3yq5c.js} +24 -10
  170. package/dist/shared/{components-j79a6jqa.js → components-nc8wggew.js} +3 -3
  171. package/dist/shared/{components-r5q9gdh4.js → components-nd3f803g.js} +7 -7
  172. package/dist/shared/{components-9ca0c92a.js → components-nehs80xd.js} +1 -1
  173. package/dist/shared/components-nw2k1pg9.js +98 -0
  174. package/dist/shared/{components-4t2cjav8.js → components-pgs3p035.js} +1 -1
  175. package/dist/shared/{components-91mmbrw3.js → components-ppc2dmxs.js} +2 -2
  176. package/dist/shared/{components-b2kjsn1s.js → components-qc1fae2s.js} +6 -6
  177. package/dist/shared/{components-fmyvz4r2.js → components-qd27dvgj.js} +6 -6
  178. package/dist/shared/{components-9z7bq8gn.js → components-qe8yp3vf.js} +3 -3
  179. package/dist/shared/{components-wx1dcp2n.js → components-qhk2m7fj.js} +2 -2
  180. package/dist/shared/{components-a1mwqxsv.js → components-qkt4h7x4.js} +8 -8
  181. package/dist/shared/{components-6rtawx8y.js → components-qs0cwe8p.js} +10 -10
  182. package/dist/shared/{components-y8m64zdw.js → components-r6ejdtpr.js} +3 -3
  183. package/dist/shared/{components-1bnf96sr.js → components-rj4nnqkz.js} +39 -11
  184. package/dist/shared/{components-gd8gmr6w.js → components-rmhdr4g1.js} +1 -1
  185. package/dist/shared/{components-e7zxwja1.js → components-rts2mggt.js} +1 -1
  186. package/dist/shared/{components-ta4e10mx.js → components-s25rehbv.js} +1 -1
  187. package/dist/shared/{components-chda6b23.js → components-sxstx1x7.js} +33 -4
  188. package/dist/shared/{components-b7p1pjcm.js → components-t4eb37vd.js} +2 -2
  189. package/dist/shared/{components-7xc2dne4.js → components-v3c3madd.js} +2 -2
  190. package/dist/shared/{components-22h8dvt1.js → components-v81eejq6.js} +3 -3
  191. package/dist/shared/{components-w1ysefg1.js → components-veaxns17.js} +2 -2
  192. package/dist/shared/{components-czvraaw9.js → components-vkrp4nb9.js} +4 -4
  193. package/dist/shared/{components-gsstwhtv.js → components-vv420geb.js} +6 -3
  194. package/dist/shared/{components-5xs8pkkj.js → components-w5p7mfb4.js} +1 -1
  195. package/dist/shared/{components-rgng034x.js → components-xvf8jcza.js} +25 -4
  196. package/dist/shared/{components-q7zk70tx.js → components-y07de1qv.js} +1 -1
  197. package/dist/shared/{components-0cpte6s1.js → components-yn8bw8tv.js} +11 -10
  198. package/dist/shared/{components-xa9fvd5b.js → components-z9gc2weg.js} +3 -3
  199. package/dist/shared/{components-twyj2y8c.js → components-zk1tj5za.js} +3 -3
  200. package/dist/shared/{components-hz6armxa.js → components-zktkxnzq.js} +7 -4
  201. package/dist/styles.css +10 -1
  202. package/dist/tailwind.css +1 -0
  203. package/dist/tokens.css +4 -0
  204. package/index.ts +1 -0
  205. package/lib/inert.ts +15 -0
  206. package/lib/overlay.tsx +49 -5
  207. package/lib/slot.tsx +9 -3
  208. package/package.json +7 -2
  209. package/tokens/colors.css +4 -0
  210. /package/dist/shared/{components-jw45ck66.js → components-02683eqd.js} +0 -0
  211. /package/dist/shared/{components-q0hs5rqn.js → components-6c52v58g.js} +0 -0
  212. /package/dist/shared/{components-y4gsk1jt.js → components-fa61vwag.js} +0 -0
  213. /package/dist/shared/{components-nz14rwtd.js → components-ffng9rpa.js} +0 -0
  214. /package/dist/shared/{components-7mj5wsv3.js → components-k9qbcmaa.js} +0 -0
  215. /package/dist/shared/{components-8pnvkrbw.js → components-mp7en54n.js} +0 -0
  216. /package/dist/shared/{components-h8v9nh5r.js → components-pbx77hzb.js} +0 -0
  217. /package/dist/shared/{components-c515d6xr.js → components-v1m0xjbw.js} +0 -0
  218. /package/dist/shared/{components-pa43g2r2.js → components-wddr0r6a.js} +0 -0
  219. /package/dist/shared/{components-ymq8tbq9.js → components-wqac4434.js} +0 -0
  220. /package/dist/shared/{components-m3vxpz2z.js → components-yy0a9b02.js} +0 -0
  221. /package/dist/shared/{components-92mvpt9h.js → components-zwgxvktt.js} +0 -0
@@ -12,6 +12,7 @@ import Sidebar from '../../components/navigation/sidebar'
12
12
  import { useSidebarShortcut } from '../../components/navigation/sidebar/sidebar-shortcut'
13
13
  import Tooltip from '../../components/overlays/tooltip'
14
14
  import { useIcon } from '../../lib/icon-context'
15
+ import { inertProps } from '../../lib/inert'
15
16
  import { useShape } from '../../lib/shape-context'
16
17
  import { type SizeVariant, useSize } from '../../lib/size-context'
17
18
  import { SURFACE_BG, SURFACE_SHADOW } from '../../lib/surface-classes'
@@ -336,7 +337,7 @@ export default function DesktopShell({
336
337
  )}
337
338
  />
338
339
  <Resizable.Panel defaultSize={defaultPaneSize} minSize={minPaneSize} maxSize={maxPaneSize} collapsible>
339
- <div {...(paneOpen ? {} : { inert: '' })} className="flex h-full min-w-0 flex-col">
340
+ <div {...inertProps(!paneOpen)} className="flex h-full min-w-0 flex-col">
340
341
  {right}
341
342
  </div>
342
343
  </Resizable.Panel>
@@ -0,0 +1,79 @@
1
+ import Sparkline from './index'
2
+ import LiveDemo from './live-demo'
3
+ import { SizeProvider } from '../../../primitives/systems/sizes'
4
+
5
+ # Trend
6
+
7
+ A row's trend in the surrounding text color; set the width with a class.
8
+
9
+ <div className="flex w-72 flex-col gap-3 text-body">
10
+ <div className="flex items-center gap-3">
11
+ <span className="w-16 shrink-0 text-muted-foreground">CPU</span>
12
+ <Sparkline className="flex-1" label="CPU, 38%" max={100} values={[12, 18, 15, 32, 41, 28, 35, 52, 47, 39, 44, 38]} />
13
+ <span className="w-10 shrink-0 text-right tabular-nums">38%</span>
14
+ </div>
15
+ <div className="flex items-center gap-3">
16
+ <span className="w-16 shrink-0 text-muted-foreground">Memory</span>
17
+ <Sparkline className="flex-1" label="Memory, 71%" max={100} values={[62, 63, 63, 65, 66, 66, 68, 69, 70, 70, 71, 71]} />
18
+ <span className="w-10 shrink-0 text-right tabular-nums">71%</span>
19
+ </div>
20
+ </div>
21
+
22
+ # Area
23
+
24
+ `area` washes under the line at 16% of its color.
25
+
26
+ <Sparkline className="w-48" area label="Requests per second, 212" values={[120, 160, 140, 190, 230, 180, 200, 260, 240, 212]} />
27
+
28
+ # Two series
29
+
30
+ `secondary` shares the scale in its own tone: network in and out.
31
+
32
+ <div className="flex w-72 flex-col gap-2">
33
+ <Sparkline
34
+ area
35
+ tone="info"
36
+ secondaryTone="success"
37
+ label="Network, 1.2 MB/s in, 0.4 MB/s out"
38
+ values={[0.4, 0.9, 2.1, 1.6, 0.8, 1.1, 2.4, 1.9, 1.2]}
39
+ secondary={[0.1, 0.2, 0.5, 0.3, 0.2, 0.6, 0.4, 0.3, 0.4]}
40
+ />
41
+ <div className="flex gap-4 text-caption text-muted-foreground">
42
+ <span className="text-status-info">In 1.2 MB/s</span>
43
+ <span className="text-status-success">Out 0.4 MB/s</span>
44
+ </div>
45
+ </div>
46
+
47
+ # Tones
48
+
49
+ The status hues, for a series that is running hot.
50
+
51
+ <div className="flex w-48 flex-col gap-2">
52
+ <Sparkline tone="success" label="Throughput, 96" values={[40, 62, 55, 78, 70, 88, 96]} />
53
+ <Sparkline tone="warning" label="Disk, 83%" values={[20, 28, 41, 47, 60, 74, 83]} max={100} />
54
+ <Sparkline tone="error" label="Errors, 21" values={[2, 3, 2, 8, 6, 14, 21]} />
55
+ </div>
56
+
57
+ # Live
58
+
59
+ A point a second into a 30-point window, from empty: a short history spans the whole width, and before two points there is a baseline.
60
+
61
+ <LiveDemo />
62
+
63
+ # Short histories
64
+
65
+ One point or none is a baseline; two points already span the width.
66
+
67
+ <div className="flex w-48 flex-col gap-3">
68
+ <Sparkline label="No data yet" values={[]} />
69
+ <Sparkline label="One sample" values={[40]} />
70
+ <Sparkline label="Two samples" values={[20, 60]} />
71
+ </div>
72
+
73
+ # Compact
74
+
75
+ In a compact region the line is 20px tall instead of 24px.
76
+
77
+ <SizeProvider size="compact">
78
+ <Sparkline className="w-40" area label="CPU, 38%" max={100} values={[12, 18, 15, 32, 41, 28, 35, 52, 47, 39, 44, 38]} />
79
+ </SizeProvider>
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Local addition (not part of Fluid Functionalism): a small trend line for a
3
+ * series of numbers, drawn as one SVG on `currentColor` and the status hues.
4
+ * The viewBox stretches to the element (`preserveAspectRatio="none"`) while
5
+ * the stroke keeps its width (`vector-effect: non-scaling-stroke`), so the
6
+ * points present always span the full width. Nothing animates: a new point
7
+ * re-renders the path.
8
+ */
9
+
10
+ 'use client'
11
+
12
+ import { forwardRef } from 'react'
13
+ import { type SizeVariant, useSize } from '../../../lib/size-context'
14
+ import { cn } from '../../../lib/utils'
15
+
16
+ type SparklineTone = 'current' | 'muted' | 'info' | 'success' | 'warning' | 'error'
17
+
18
+ // Literal tables: UnoCSS only generates the classes it can read whole.
19
+ const TONE: Record<SparklineTone, string> = {
20
+ current: '',
21
+ muted: 'text-muted-foreground',
22
+ info: 'text-status-info',
23
+ success: 'text-status-success',
24
+ warning: 'text-status-warning',
25
+ error: 'text-status-error',
26
+ }
27
+ const HEIGHT: Record<SizeVariant, string> = { default: 'h-6', compact: 'h-5' }
28
+
29
+ // The viewBox; the SVG stretches it to whatever box the element gets.
30
+ const W = 100
31
+ const H = 100
32
+
33
+ function points(series: number[], max: number): string {
34
+ const step = W / (series.length - 1)
35
+ return series.map((v, i) => `${i * step},${H - Math.min(Math.max(v / max, 0), 1) * H}`).join(' ')
36
+ }
37
+
38
+ interface SeriesProps {
39
+ series: number[]
40
+ max: number
41
+ tone: SparklineTone
42
+ area: boolean
43
+ }
44
+
45
+ function Series({ series, max, tone, area }: SeriesProps) {
46
+ const line = points(series, max)
47
+
48
+ return (
49
+ <g className={TONE[tone]}>
50
+ {area && <polygon points={`0,${H} ${line} ${W},${H}`} className="fill-current/16" />}
51
+ <polyline
52
+ points={line}
53
+ fill="none"
54
+ strokeWidth="1.5"
55
+ strokeLinejoin="round"
56
+ strokeLinecap="round"
57
+ vectorEffect="non-scaling-stroke"
58
+ className="stroke-current"
59
+ />
60
+ </g>
61
+ )
62
+ }
63
+
64
+ interface SparklineProps {
65
+ /** The series, oldest first. Its points span the full width however many there are. */
66
+ values: number[]
67
+ /** A second series drawn under the first on the same scale, such as network out beside network in. */
68
+ secondary?: number[]
69
+ /** The value at the top edge. Defaults to the largest value of both series. */
70
+ max?: number
71
+ /** What the line shows, read by screen readers as its name: say the latest value in it. */
72
+ label: string
73
+ /** The first series' color: the surrounding text color, or a status hue. Defaults to `'current'`. */
74
+ tone?: SparklineTone
75
+ /** The second series' color. Defaults to `'muted'`. */
76
+ secondaryTone?: SparklineTone
77
+ /** Fills under each line with a 16% wash of its color. Defaults to `false`. */
78
+ area?: boolean
79
+ /** Pins the height to one step of the size ladder (24px default, 20px compact). Defaults to the surrounding SizeProvider. */
80
+ size?: SizeVariant
81
+ /** Classes for the SVG: a width (it fills its container by default), a text color. */
82
+ className?: string
83
+ }
84
+
85
+ /**
86
+ * A small inline trend line for a series of numbers: CPU, memory, network
87
+ * traffic, request rates.
88
+ *
89
+ * The points present always stretch across the full width, so a short
90
+ * history reads as a whole line rather than a stub at one end, and the
91
+ * line keeps its stroke whatever box it gets. The scale runs from 0 to
92
+ * `max`, or to the largest value when there is none. A `secondary` series
93
+ * shares the scale in its own tone, and `area` washes under each line.
94
+ * Until a series has two points it shows a flat baseline.
95
+ *
96
+ * It draws in the first render with nothing to measure, so it renders on
97
+ * the server, and a new point simply redraws the path: nothing animates,
98
+ * so a line fed every second costs no frames in between. Its `label` is
99
+ * its accessible name.
100
+ *
101
+ * @example {@include ./examples.mdx}
102
+ */
103
+ const Sparkline = forwardRef<SVGSVGElement, SparklineProps>(
104
+ (
105
+ {
106
+ values,
107
+ secondary,
108
+ max: maxProp,
109
+ label,
110
+ tone = 'current',
111
+ secondaryTone = 'muted',
112
+ area = false,
113
+ size: sizeProp,
114
+ className,
115
+ },
116
+ ref,
117
+ ) => {
118
+ const size = useSize(sizeProp)
119
+ const max = maxProp ?? Math.max(...values, ...(secondary ?? []))
120
+ const scale = max > 0 ? max : 1
121
+ const drawn = values.length > 1
122
+
123
+ return (
124
+ <svg
125
+ ref={ref}
126
+ role="img"
127
+ aria-label={label}
128
+ viewBox={`0 0 ${W} ${H}`}
129
+ preserveAspectRatio="none"
130
+ className={cn('block w-full shrink-0 overflow-visible', HEIGHT[size.variant], className)}
131
+ >
132
+ {secondary && secondary.length > 1 && (
133
+ <Series series={secondary} max={scale} tone={secondaryTone} area={area} />
134
+ )}
135
+ {drawn ? (
136
+ <Series series={values} max={scale} tone={tone} area={area} />
137
+ ) : (
138
+ <line
139
+ x1="0"
140
+ y1={H}
141
+ x2={W}
142
+ y2={H}
143
+ strokeWidth="1.5"
144
+ vectorEffect="non-scaling-stroke"
145
+ className="stroke-current text-border"
146
+ />
147
+ )}
148
+ </svg>
149
+ )
150
+ },
151
+ )
152
+
153
+ Sparkline.displayName = 'Sparkline'
154
+
155
+ export type { SparklineProps, SparklineTone }
156
+ export { Sparkline }
157
+
158
+ export default Sparkline
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Local addition (not part of Fluid Functionalism): the docs stage of the
3
+ * Sparkline page's live example. It feeds a point a second into a 30-point
4
+ * window, from empty, so the example stays hook-free and shows a short
5
+ * history stretching across the width.
6
+ */
7
+
8
+ 'use client'
9
+
10
+ import { useEffect, useState } from 'react'
11
+ import Sparkline from './index'
12
+
13
+ const WINDOW = 30
14
+
15
+ function next(previous: number): number {
16
+ return Math.min(Math.max(previous + (Math.random() - 0.5) * 30, 2), 98)
17
+ }
18
+
19
+ export default function LiveDemo() {
20
+ const [cpu, setCpu] = useState<number[]>([])
21
+
22
+ useEffect(() => {
23
+ const id = setInterval(() => setCpu(prev => [...prev, next(prev.at(-1) ?? 30)].slice(-WINDOW)), 1000)
24
+ return () => clearInterval(id)
25
+ }, [])
26
+
27
+ const latest = Math.round(cpu.at(-1) ?? 0)
28
+
29
+ return (
30
+ <div className="flex w-64 items-center gap-3 text-body">
31
+ <span className="shrink-0 text-muted-foreground">CPU</span>
32
+ <Sparkline values={cpu} max={100} area label={`CPU, ${latest}%`} className="flex-1" />
33
+ <span className="w-10 shrink-0 text-right tabular-nums">{latest}%</span>
34
+ </div>
35
+ )
36
+ }
@@ -1,5 +1,6 @@
1
1
  import Meter from './index'
2
2
  import { SizeProvider } from '../../../primitives/systems/sizes'
3
+ import TimerDemo from './timer-demo'
3
4
 
4
5
  # Bar
5
6
 
@@ -40,6 +41,30 @@ A glyph for toolbars: the label is its accessible name only.
40
41
  <Meter variant="ring" label="Context" value={0.94} />
41
42
  </div>
42
43
 
44
+ # Ring sizes
45
+
46
+ A size class scales the ring past the inline glyph; its stroke scales with it.
47
+
48
+ <div className="flex items-center gap-4">
49
+ <Meter variant="ring" label="Upload" value={0.6} className="size-6" />
50
+ <Meter variant="ring" label="Upload" value={0.6} className="size-10" />
51
+ <Meter variant="ring" label="Upload" value={0.6} className="size-16" />
52
+ </div>
53
+
54
+ # Countdown
55
+
56
+ Children sit in the ring's centre, and a string child is what screen readers hear as the value. `animate={false}` lets a value that ticks every second step without a spring between ticks. A ring of time left passes `tone`, so a full ring isn't read as a spent budget.
57
+
58
+ <div className="flex items-center gap-4">
59
+ <Meter variant="ring" label="Focus timer" value={299} max={1500} tone="default" animate={false} className="size-16 text-caption">
60
+ 04:59
61
+ </Meter>
62
+ <Meter variant="ring" label="Break" value={50} max={300} tone="warning" animate={false} className="size-12 text-micro">
63
+ 0:50
64
+ </Meter>
65
+ <TimerDemo />
66
+ </div>
67
+
43
68
  # Line
44
69
 
45
70
  The bare bar for tight rows, such as a sidebar: stack two for a short and a long window.
@@ -3,7 +3,8 @@
3
3
  * share of a budget (usage, a rate limit, a context window), as a bar or a
4
4
  * ring, on Base UI's Meter (the `meter` role and its values). The bar's fill
5
5
  * slides in with `translateX` on `spring.moderate`, like Progress's, and turns
6
- * to the warning and error status hues as the budget runs out.
6
+ * to the warning and error status hues as the budget runs out. The ring's SVG
7
+ * fills its root, so a size class scales it, with content centred over it.
7
8
  */
8
9
 
9
10
  'use client'
@@ -29,7 +30,7 @@ const RING_FILL: Record<MeterTone, string> = {
29
30
  warning: 'text-status-warning',
30
31
  error: 'text-status-error',
31
32
  }
32
- const RING_SIZE: Record<SizeVariant, number> = { default: 16, compact: 14 }
33
+ const RING_SIZE: Record<SizeVariant, string> = { default: 'size-4', compact: 'size-3.5' }
33
34
  const CAPTION: Record<SizeVariant, string> = { default: 'text-caption', compact: 'text-caption-compact' }
34
35
 
35
36
  const enter = springEnter(spring.moderate)
@@ -59,9 +60,13 @@ interface MeterProps {
59
60
  tone?: MeterTone
60
61
  /** A share between 0 and 1 where a thin tick crosses the bar or the line: where an even spend would be by now, a soft limit. The ring ignores it. */
61
62
  marker?: number
63
+ /** Springs the fill to a new value. Turn it off for a value that advances on a clock (a countdown ticking every second), so the fill steps instead of repainting between ticks. Defaults to `true`. */
64
+ animate?: boolean
65
+ /** Content centred in the ring, such as a countdown's `04:59`; a string is also what screen readers hear as the value. The bar and the line ignore it. */
66
+ children?: ReactNode
62
67
  /** Pins the meter to one step of the size ladder (36px default, 28px compact). Defaults to the surrounding SizeProvider. */
63
68
  size?: SizeVariant
64
- /** Classes for the root. */
69
+ /** Classes for the root; on the ring a size class (`size-16`) scales it past the inline glyph. */
65
70
  className?: string
66
71
  }
67
72
 
@@ -80,6 +85,10 @@ interface MeterProps {
80
85
  * A `marker` draws a tick across the bar or the line at a share, such as
81
86
  * where an even spend would be by now, so the fill reads against time.
82
87
  *
88
+ * The ring also serves timers and countdowns: a size class scales it, its
89
+ * children sit in its centre, and `animate={false}` lets a value that ticks
90
+ * every second step without a spring between ticks.
91
+ *
83
92
  * @example {@include ./examples.mdx}
84
93
  */
85
94
  const Meter = forwardRef<HTMLDivElement, MeterProps>(
@@ -94,6 +103,8 @@ const Meter = forwardRef<HTMLDivElement, MeterProps>(
94
103
  errorAt = 0.9,
95
104
  tone: toneProp,
96
105
  marker,
106
+ animate = true,
107
+ children,
97
108
  size: sizeProp,
98
109
  className,
99
110
  },
@@ -103,14 +114,18 @@ const Meter = forwardRef<HTMLDivElement, MeterProps>(
103
114
  const reduceMotion = useReduceMotion()
104
115
  const share = Math.min(Math.max(value / max, 0), 1)
105
116
  const tone = toneProp ?? toneOf(share, warnAt, errorAt)
106
- const transition = reduceMotion ? { duration: 0 } : enter
117
+ const transition = reduceMotion || !animate ? { duration: 0 } : enter
107
118
  const root = { ref, value, max, 'aria-label': label }
108
119
 
109
120
  if (variant === 'ring') {
110
- const px = RING_SIZE[size.variant]
121
+ const valueText = typeof children === 'string' ? children : undefined
111
122
  return (
112
- <MeterPrimitive.Root {...root} className={cn('inline-flex shrink-0', className)}>
113
- <svg width={px} height={px} viewBox="0 0 20 20" aria-hidden="true" className="-rotate-90">
123
+ <MeterPrimitive.Root
124
+ {...root}
125
+ getAriaValueText={valueText === undefined ? undefined : () => valueText}
126
+ className={cn('relative inline-grid shrink-0 place-items-center', RING_SIZE[size.variant], className)}
127
+ >
128
+ <svg viewBox="0 0 20 20" aria-hidden="true" className="absolute inset-0 size-full -rotate-90">
114
129
  <circle cx="10" cy="10" r="7" fill="none" strokeWidth="2.5" className="stroke-current text-border" />
115
130
  <motion.circle
116
131
  cx="10"
@@ -125,6 +140,7 @@ const Meter = forwardRef<HTMLDivElement, MeterProps>(
125
140
  transition={transition}
126
141
  />
127
142
  </svg>
143
+ {children !== undefined && <span className="relative tabular-nums">{children}</span>}
128
144
  </MeterPrimitive.Root>
129
145
  )
130
146
  }
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Local addition (not part of Fluid Functionalism): the docs stage of the
3
+ * Meter page's countdown example. A ring counts a minute down once a second
4
+ * with `animate={false}`, and `tone` pinned so a full ring isn't read as a spent budget, so the example stays hook-free.
5
+ */
6
+
7
+ 'use client'
8
+
9
+ import { useEffect, useState } from 'react'
10
+ import Meter from './index'
11
+
12
+ const TOTAL = 60
13
+
14
+ export default function TimerDemo() {
15
+ const [left, setLeft] = useState(TOTAL)
16
+
17
+ useEffect(() => {
18
+ const id = setInterval(() => setLeft(prev => (prev > 0 ? prev - 1 : TOTAL)), 1000)
19
+ return () => clearInterval(id)
20
+ }, [])
21
+
22
+ const time = `0:${String(left).padStart(2, '0')}`
23
+
24
+ return (
25
+ <Meter
26
+ variant="ring"
27
+ label="Countdown"
28
+ value={left}
29
+ max={TOTAL}
30
+ tone="default"
31
+ animate={false}
32
+ className="size-16 text-caption"
33
+ >
34
+ {time}
35
+ </Meter>
36
+ )
37
+ }
@@ -164,6 +164,8 @@ interface CheckboxProps extends HTMLAttributes<HTMLDivElement> {
164
164
  disabled?: boolean
165
165
  /** Submits the checkbox under this name in a form, while checked. */
166
166
  name?: string
167
+ /** Must be checked before its form submits: the browser's validation (and an enclosing Field's) reports it missing. Defaults to `false`. */
168
+ required?: boolean
167
169
  /** The value submitted while checked. Defaults to `"on"`. */
168
170
  value?: string
169
171
  /** Pins the checkbox to one step of the size ladder (see Sizes). Defaults to the surrounding SizeProvider (a group's `size`). */
@@ -317,6 +319,7 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
317
319
  index: indexProp,
318
320
  disabled: disabledProp,
319
321
  name,
322
+ required,
320
323
  value,
321
324
  size,
322
325
  className,
@@ -385,6 +388,7 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
385
388
  onCheckedChange={onToggle}
386
389
  disabled={disabled}
387
390
  name={name}
391
+ required={required}
388
392
  value={value}
389
393
  {...hover}
390
394
  className={cn(
@@ -435,6 +439,7 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
435
439
  indeterminate={indeterminate}
436
440
  disabled={disabled}
437
441
  name={name}
442
+ required={required}
438
443
  value={value}
439
444
  onCheckedChange={onToggle}
440
445
  tabIndex={-1}
@@ -80,7 +80,7 @@ interface ComboboxProps {
80
80
  filter?: ((item: ComboboxItemData, query: string) => boolean) | null
81
81
  /** Controlled query, the field's text. Pair with `onQueryChange`. */
82
82
  query?: string
83
- /** Initial query, for an uncontrolled field. Defaults to `""`. */
83
+ /** Initial query, for an uncontrolled field. Defaults to the picked item's label in a single field, else `""`. */
84
84
  defaultQuery?: string
85
85
  /** Called with the field's text on every keystroke, and when a pick, a clear or a close rewrites it; Base UI's details tell them apart (`details.reason === 'input-change'` for typing). */
86
86
  onQueryChange?: (query: string, details: ComboboxRootChangeEventDetails) => void
@@ -168,7 +168,7 @@ const Combobox = Object.assign(
168
168
  onOpenChange,
169
169
  filter,
170
170
  query: queryProp,
171
- defaultQuery = '',
171
+ defaultQuery,
172
172
  onQueryChange,
173
173
  loading = false,
174
174
  loadingLabel = 'Loading…',
@@ -194,8 +194,13 @@ const Combobox = Object.assign(
194
194
  const [values, setValues] = useControllableState<string[]>(controlledValues, toValues(defaultValue))
195
195
  // Base UI owns the field's text unless the caller does; this mirrors it either way.
196
196
  const queryDetails = useRef<ComboboxRootChangeEventDetails | null>(null)
197
- const [inputValue, setInputValue] = useControllableState(queryProp, defaultQuery, next =>
198
- onQueryChange?.(next, queryDetails.current as ComboboxRootChangeEventDetails),
197
+ // Left unset, Base UI fills a single field with the picked item's label; the mirror starts there too.
198
+ const picked =
199
+ isMultiple || defaultQuery !== undefined ? undefined : items.find(item => itemValue(item) === values[0])
200
+ const [inputValue, setInputValue] = useControllableState(
201
+ queryProp,
202
+ defaultQuery ?? (picked ? itemLabel(picked) : ''),
203
+ next => onQueryChange?.(next, queryDetails.current as ComboboxRootChangeEventDetails),
199
204
  )
200
205
  const [highlight, setHighlight] = useState<Highlight | null>(null)
201
206
  // Items the create row made while no consumer owns the list.
@@ -78,6 +78,8 @@ interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect
78
78
  onValueChange?: (value: string) => void
79
79
  /** Submits the selected row's `value` under this name in a form (value mode). */
80
80
  name?: string
81
+ /** A row must be picked before the form submits: the browser's validation (and an enclosing Field's) reports it missing. Defaults to `false`. */
82
+ required?: boolean
81
83
  /** Disables every row. Defaults to `false`. */
82
84
  disabled?: boolean
83
85
  /** Pins the group's rows to one step of the size ladder (default 36px, compact 28px). Defaults to the surrounding SizeProvider. */
@@ -96,6 +98,7 @@ const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
96
98
  defaultValue,
97
99
  onValueChange: onValueChangeProp,
98
100
  name,
101
+ required,
99
102
  disabled = false,
100
103
  size,
101
104
  className,
@@ -164,6 +167,7 @@ const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
164
167
  value={value ?? null}
165
168
  onValueChange={v => setValue(v as string)}
166
169
  name={name}
170
+ required={required}
167
171
  disabled={disabled}
168
172
  className={cn('flex flex-col gap-2', className)}
169
173
  {...props}
@@ -207,6 +211,7 @@ const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
207
211
  value={value ?? null}
208
212
  onValueChange={v => setValue(v as string)}
209
213
  name={name}
214
+ required={required}
210
215
  disabled={disabled}
211
216
  render={content}
212
217
  />
@@ -32,6 +32,7 @@ import type { IconComponent } from '../../../lib/icon-context'
32
32
  import { useMergeRefs } from '../../../lib/merge-refs'
33
33
  import {
34
34
  type AnchorProps,
35
+ type CollisionProps,
35
36
  OverlayContext,
36
37
  positionerProps,
37
38
  useOverlay,
@@ -269,7 +270,11 @@ SelectTrigger.displayName = 'SelectTrigger'
269
270
 
270
271
  type SelectPopupProps = ComponentProps<typeof SelectPrimitive.Popup>
271
272
 
272
- interface SelectContentProps extends AnchorProps, MorphProps, Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
273
+ interface SelectContentProps
274
+ extends AnchorProps,
275
+ CollisionProps,
276
+ MorphProps,
277
+ Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
273
278
  /** Where focus goes when the popup closes: a ref, `false` to leave it, `true` for the default, or a function of how it closed. Defaults to the trigger. */
274
279
  finalFocus?: SelectPopupProps['finalFocus']
275
280
  /** Additional classes for the menu container. */
@@ -284,6 +289,10 @@ const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
284
289
  side,
285
290
  align,
286
291
  sideOffset,
292
+ alignOffset,
293
+ collisionPadding,
294
+ collisionBoundary,
295
+ positionerClassName,
287
296
  container,
288
297
  finalFocus,
289
298
  from,
@@ -335,7 +344,17 @@ const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
335
344
  <SelectPrimitive.Portal container={usePortalContainer(container)}>
336
345
  <SelectPrimitive.Positioner
337
346
  {...positionerProps(
338
- { side, align, sideOffset, effect, hideSource },
347
+ {
348
+ side,
349
+ align,
350
+ sideOffset,
351
+ alignOffset,
352
+ collisionPadding,
353
+ collisionBoundary,
354
+ positionerClassName,
355
+ effect,
356
+ hideSource,
357
+ },
339
358
  { side: 'bottom', align: 'start', sideOffset: 6 },
340
359
  )}
341
360
  alignItemWithTrigger={false}
@@ -492,7 +511,8 @@ const SelectSeparator = PopupSeparator
492
511
  * look included: childless it keeps the value slot and chevron, with
493
512
  * children those are its whole body.
494
513
  * - `Select.Value` — the value slot: the picked row's label, else the muted `placeholder`.
495
- * - `Select.Content` — the popup: `side`, `align`, `sideOffset`, `container`, `finalFocus` and the
514
+ * - `Select.Content` — the popup: `side`, `align`, `sideOffset`, `alignOffset`, `collisionPadding`,
515
+ * `collisionBoundary`, `positionerClassName`, `container`, `finalFocus` and the
496
516
  * morph options `from`, `effect`, `hideSource`, `tier`.
497
517
  * - `Select.Item` — one row: `value`, optional `index`, `textValue`, `icon`, `disabled`;
498
518
  * its children are the label.