@zyncat/ui 0.20.0 → 0.21.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 (281) hide show
  1. package/dist/alert.js +6 -6
  2. package/dist/badge.css +20 -11
  3. package/dist/badge.js +100 -2
  4. package/dist/badge.js.map +1 -1
  5. package/dist/{bloom-HV23M4AW.js → bloom-5MZXLNKG.js} +23 -5
  6. package/dist/bloom-5MZXLNKG.js.map +1 -0
  7. package/dist/button.js +2 -2
  8. package/dist/{chunk-JINATP4N.js → chunk-2W7FOMWE.js} +7 -8
  9. package/dist/chunk-2W7FOMWE.js.map +1 -0
  10. package/dist/{chunk-LNAV5E7S.js → chunk-3HE7N3UK.js} +7 -3
  11. package/dist/chunk-3HE7N3UK.js.map +1 -0
  12. package/dist/{chunk-UKPX3RIP.js → chunk-47OMFFIB.js} +3 -3
  13. package/dist/{chunk-UKPX3RIP.js.map → chunk-47OMFFIB.js.map} +1 -1
  14. package/dist/chunk-4M5FMCFJ.js +16 -0
  15. package/dist/chunk-4M5FMCFJ.js.map +1 -0
  16. package/dist/chunk-6BY5G7BI.js +122 -0
  17. package/dist/chunk-6BY5G7BI.js.map +1 -0
  18. package/dist/{chunk-RLNCRDAL.js → chunk-AOEO2LCZ.js} +4 -4
  19. package/dist/{chunk-RLNCRDAL.js.map → chunk-AOEO2LCZ.js.map} +1 -1
  20. package/dist/{chunk-BRKGYLEQ.js → chunk-AQMR7ZYO.js} +8 -3
  21. package/dist/chunk-AQMR7ZYO.js.map +1 -0
  22. package/dist/{chunk-N43NDSME.js → chunk-AXZBD7LY.js} +6 -3
  23. package/dist/chunk-AXZBD7LY.js.map +1 -0
  24. package/dist/{chunk-V6QAAOA5.js → chunk-BWGK3OD6.js} +9 -6
  25. package/dist/chunk-BWGK3OD6.js.map +1 -0
  26. package/dist/{chunk-VQFILXQN.js → chunk-CYZKPUCG.js} +70 -8
  27. package/dist/chunk-CYZKPUCG.js.map +1 -0
  28. package/dist/{chunk-AIAPXRCI.js → chunk-DEZIQTBW.js} +176 -103
  29. package/dist/chunk-DEZIQTBW.js.map +1 -0
  30. package/dist/{tide-DJZMDAFT.js → chunk-DVLKB3CZ.js} +15 -12
  31. package/dist/chunk-DVLKB3CZ.js.map +1 -0
  32. package/dist/{chunk-F64Z42PJ.js → chunk-GM7IPTTT.js} +5 -6
  33. package/dist/chunk-GM7IPTTT.js.map +1 -0
  34. package/dist/chunk-ITW5UCVU.js +24 -0
  35. package/dist/chunk-ITW5UCVU.js.map +1 -0
  36. package/dist/{chunk-TDHLZY6I.js → chunk-JQZ3FTHP.js} +77 -18
  37. package/dist/chunk-JQZ3FTHP.js.map +1 -0
  38. package/dist/{chunk-PXQBJMPJ.js → chunk-LC6NQQER.js} +3 -3
  39. package/dist/{chunk-PXQBJMPJ.js.map → chunk-LC6NQQER.js.map} +1 -1
  40. package/dist/{chunk-M2KGLH2G.js → chunk-LV442ZOR.js} +10 -10
  41. package/dist/{chunk-M2KGLH2G.js.map → chunk-LV442ZOR.js.map} +1 -1
  42. package/dist/{chunk-F2TB3TT6.js → chunk-PNFFK5HY.js} +4 -4
  43. package/dist/{chunk-F2TB3TT6.js.map → chunk-PNFFK5HY.js.map} +1 -1
  44. package/dist/{chunk-2YGHPQ66.js → chunk-Q5N24VII.js} +2 -2
  45. package/dist/{chunk-2YGHPQ66.js.map → chunk-Q5N24VII.js.map} +1 -1
  46. package/dist/{chunk-XKDR22VE.js → chunk-SPFHWHJ6.js} +8 -4
  47. package/dist/chunk-SPFHWHJ6.js.map +1 -0
  48. package/dist/{chunk-TRPAKUIB.js → chunk-TBIY5YR5.js} +8 -8
  49. package/dist/{chunk-TRPAKUIB.js.map → chunk-TBIY5YR5.js.map} +1 -1
  50. package/dist/chunk-TXJQUN7C.js +108 -0
  51. package/dist/chunk-TXJQUN7C.js.map +1 -0
  52. package/dist/{chunk-VZXML7EH.js → chunk-V4ZN5RD4.js} +12 -3
  53. package/dist/chunk-V4ZN5RD4.js.map +1 -0
  54. package/dist/{chunk-VJXP256V.js → chunk-ZSP4ZTII.js} +7 -7
  55. package/dist/{chunk-VJXP256V.js.map → chunk-ZSP4ZTII.js.map} +1 -1
  56. package/dist/confetti.js +1 -1
  57. package/dist/crossfade-XFZLFLT7.js +91 -0
  58. package/dist/crossfade-XFZLFLT7.js.map +1 -0
  59. package/dist/date-field.js +20 -18
  60. package/dist/date-field.js.map +1 -1
  61. package/dist/date-picker.css +0 -1
  62. package/dist/date-range-field.js +22 -20
  63. package/dist/date-range-field.js.map +1 -1
  64. package/dist/datetime-field.js +21 -19
  65. package/dist/datetime-field.js.map +1 -1
  66. package/dist/dialog.js +9 -9
  67. package/dist/dropdown.css +12 -9
  68. package/dist/dropdown.js +37 -20
  69. package/dist/dropdown.js.map +1 -1
  70. package/dist/emoji-picker.js +14 -14
  71. package/dist/flow-field.js +1 -1
  72. package/dist/glide.js +2 -2
  73. package/dist/instagram-feed.js +2 -2
  74. package/dist/lens.js +1 -1
  75. package/dist/menu-surface.css +81 -7
  76. package/dist/modal.js +8 -8
  77. package/dist/morphing-text.js +1 -1
  78. package/dist/motion-devtools.js +3 -3
  79. package/dist/motion.js +9 -0
  80. package/dist/motion.js.map +1 -0
  81. package/dist/multi-select.js +34 -16
  82. package/dist/multi-select.js.map +1 -1
  83. package/dist/number-field.js +2 -2
  84. package/dist/odometer.css +16 -10
  85. package/dist/odometer.js +105 -72
  86. package/dist/odometer.js.map +1 -1
  87. package/dist/otp-field.js +17 -9
  88. package/dist/otp-field.js.map +1 -1
  89. package/dist/pagination.js +4 -4
  90. package/dist/{paint-CJQCM6ZO.js → paint-NLTI6TEF.js} +5 -3
  91. package/dist/paint-NLTI6TEF.js.map +1 -0
  92. package/dist/popover.js +9 -9
  93. package/dist/radio-group.css +8 -4
  94. package/dist/radio-group.js +5 -5
  95. package/dist/select.css +33 -6
  96. package/dist/select.js +25 -12
  97. package/dist/select.js.map +1 -1
  98. package/dist/sheet.js +9 -9
  99. package/dist/support-rail.js +11 -11
  100. package/dist/table.css +8 -3
  101. package/dist/table.js +7 -7
  102. package/dist/tabs.css +19 -5
  103. package/dist/tabs.js +7 -5
  104. package/dist/tabs.js.map +1 -1
  105. package/dist/tag.js +4 -4
  106. package/dist/textarea.css +13 -1
  107. package/dist/textarea.js +36 -23
  108. package/dist/textarea.js.map +1 -1
  109. package/dist/theme-grid.js +5 -5
  110. package/dist/theme-switcher.js +14 -14
  111. package/dist/{theme-transition-VGLPZDJI.js → theme-transition-FDF2REFD.js} +27 -7
  112. package/dist/theme-transition-FDF2REFD.js.map +1 -0
  113. package/dist/theme-transition.css +49 -0
  114. package/dist/theme.js +2 -2
  115. package/dist/theme.js.map +1 -1
  116. package/dist/tide-AGGMQEJV.js +4 -0
  117. package/dist/tide-AGGMQEJV.js.map +1 -0
  118. package/dist/tiktok.js +2 -2
  119. package/dist/time-field.js +5 -3
  120. package/dist/time-field.js.map +1 -1
  121. package/dist/toast.js +7 -7
  122. package/dist/toggle-tag.js +2 -2
  123. package/dist/toggle.js +4 -15
  124. package/dist/toggle.js.map +1 -1
  125. package/dist/tooltip.js +6 -7
  126. package/dist/tooltip.js.map +1 -1
  127. package/dist/trigger.css +0 -1
  128. package/dist/types/components/composites/date-picker/DateField.d.ts +1 -1
  129. package/dist/types/components/composites/date-picker/DateRangeField.d.ts +1 -1
  130. package/dist/types/components/composites/date-picker/DateTimeField.d.ts +1 -1
  131. package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -1
  132. package/dist/types/components/composites/date-picker/field-shell.d.ts +5 -1
  133. package/dist/types/components/composites/dropdown/Dropdown.d.ts +13 -2
  134. package/dist/types/components/composites/dropdown/types.d.ts +5 -2
  135. package/dist/types/components/composites/select/MultiSelect.d.ts +23 -3
  136. package/dist/types/components/composites/select/Select.d.ts +20 -4
  137. package/dist/types/components/composites/select/core/index.d.ts +2 -1
  138. package/dist/types/components/composites/select/core/menu.d.ts +8 -5
  139. package/dist/types/components/composites/select/core/panel.d.ts +6 -4
  140. package/dist/types/components/composites/select/core/trigger.d.ts +7 -2
  141. package/dist/types/components/composites/select/core/types.d.ts +9 -0
  142. package/dist/types/components/composites/select/core/use-listbox.d.ts +5 -3
  143. package/dist/types/components/composites/tabs/Tabs.d.ts +4 -1
  144. package/dist/types/components/expressive/odometer/Odometer.d.ts +1 -1
  145. package/dist/types/components/expressive/odometer/roll.d.ts +20 -0
  146. package/dist/types/components/expressive/theme-transition/scene.d.ts +3 -0
  147. package/dist/types/components/internal/menu/highlight.d.ts +9 -1
  148. package/dist/types/components/internal/menu/menu-row.d.ts +4 -0
  149. package/dist/types/components/internal/menu/use-anchor-width.d.ts +2 -0
  150. package/dist/types/components/internal/overlay/layer.d.ts +5 -8
  151. package/dist/types/components/internal/overlay/track-anchor.d.ts +5 -0
  152. package/dist/types/components/internal/utils/activation.d.ts +1 -0
  153. package/dist/types/components/primitives/badge/Badge.d.ts +17 -8
  154. package/dist/types/components/primitives/badge/morph-label.d.ts +3 -0
  155. package/dist/types/components/primitives/badge/use-glint-on-change.d.ts +2 -0
  156. package/dist/types/components/primitives/input/OtpField.d.ts +2 -2
  157. package/dist/types/components/primitives/textarea/Textarea.d.ts +2 -2
  158. package/dist/types/components/primitives/textarea/char-meter.d.ts +6 -0
  159. package/dist/types/components/primitives/toggle/switch-glyph.d.ts +6 -0
  160. package/dist/types/motion/crossfade.d.ts +3 -0
  161. package/dist/types/motion/element.d.ts +6 -3
  162. package/dist/types/motion/flip.d.ts +8 -2
  163. package/dist/types/motion/motion.d.ts +7 -0
  164. package/dist/types/theme-scope.d.ts +5 -0
  165. package/dist/types/tokens/component-styles.generated.d.ts +0 -2
  166. package/dist/types/tokens/theme-tokens.generated.d.ts +37 -31
  167. package/dist/typing-lines.js +1 -1
  168. package/dist/youtube.js +2 -2
  169. package/package.json +6 -11
  170. package/skills/zyncat-ui/SKILL.md +2 -2
  171. package/skills/zyncat-ui/references/components.md +3 -4
  172. package/skills/zyncat-ui/references/theming.md +3 -3
  173. package/src/components/composites/date-picker/DateField.tsx +2 -0
  174. package/src/components/composites/date-picker/DateRangeField.tsx +2 -0
  175. package/src/components/composites/date-picker/DateTimeField.tsx +2 -0
  176. package/src/components/composites/date-picker/TimeField.tsx +2 -0
  177. package/src/components/composites/date-picker/date-picker.css +0 -1
  178. package/src/components/composites/date-picker/field-shell.tsx +14 -1
  179. package/src/components/composites/dropdown/Dropdown.tsx +20 -3
  180. package/src/components/composites/dropdown/Dropdown.usage.md +2 -0
  181. package/src/components/composites/dropdown/dropdown.css +12 -9
  182. package/src/components/composites/dropdown/menu-panel.tsx +28 -13
  183. package/src/components/composites/dropdown/types.ts +5 -2
  184. package/src/components/composites/select/MultiSelect.tsx +56 -5
  185. package/src/components/composites/select/MultiSelect.usage.md +10 -0
  186. package/src/components/composites/select/Select.tsx +32 -2
  187. package/src/components/composites/select/Select.usage.md +13 -1
  188. package/src/components/composites/select/core/index.ts +2 -1
  189. package/src/components/composites/select/core/menu.tsx +28 -15
  190. package/src/components/composites/select/core/panel.tsx +57 -52
  191. package/src/components/composites/select/core/trigger.tsx +44 -11
  192. package/src/components/composites/select/core/types.ts +10 -0
  193. package/src/components/composites/select/core/use-listbox.ts +77 -31
  194. package/src/components/composites/select/select.css +33 -6
  195. package/src/components/composites/table/table.css +8 -3
  196. package/src/components/composites/tabs/Tabs.tsx +5 -0
  197. package/src/components/composites/tabs/tabs.css +19 -5
  198. package/src/components/composites/tooltip/tooltip-host.tsx +1 -1
  199. package/src/components/expressive/odometer/Odometer.tsx +45 -92
  200. package/src/components/expressive/odometer/Odometer.usage.md +2 -2
  201. package/src/components/expressive/odometer/odometer.css +16 -10
  202. package/src/components/expressive/odometer/roll.ts +94 -0
  203. package/src/components/expressive/theme-transition/bloom.ts +22 -2
  204. package/src/components/expressive/theme-transition/paint.ts +2 -0
  205. package/src/components/expressive/theme-transition/scene.ts +3 -0
  206. package/src/components/expressive/theme-transition/theme-transition.css +49 -0
  207. package/src/components/expressive/theme-transition/theme-transition.ts +21 -1
  208. package/src/components/expressive/theme-transition/tide.ts +15 -10
  209. package/src/components/internal/menu/highlight.ts +20 -2
  210. package/src/components/internal/menu/menu-row.tsx +36 -8
  211. package/src/components/internal/menu/menu-surface.css +81 -7
  212. package/src/components/internal/menu/use-anchor-width.ts +26 -0
  213. package/src/components/internal/overlay/layer.tsx +11 -23
  214. package/src/components/internal/overlay/position.ts +17 -6
  215. package/src/components/internal/overlay/track-anchor.ts +69 -0
  216. package/src/components/internal/overlay/trigger.css +0 -1
  217. package/src/components/internal/utils/activation.ts +5 -0
  218. package/src/components/primitives/badge/Badge.tsx +38 -15
  219. package/src/components/primitives/badge/Badge.usage.md +12 -5
  220. package/src/components/primitives/badge/badge.css +20 -11
  221. package/src/components/primitives/badge/morph-label.tsx +71 -0
  222. package/src/components/primitives/badge/use-glint-on-change.ts +16 -0
  223. package/src/components/primitives/input/OtpField.tsx +17 -9
  224. package/src/components/primitives/radio-group/radio-group.css +8 -4
  225. package/src/components/primitives/textarea/Textarea.tsx +20 -24
  226. package/src/components/primitives/textarea/char-meter.tsx +34 -0
  227. package/src/components/primitives/textarea/textarea.css +13 -1
  228. package/src/components/primitives/toggle/Toggle.tsx +3 -12
  229. package/src/components/primitives/toggle/switch-glyph.tsx +25 -0
  230. package/src/engine/flip.ts +5 -1
  231. package/src/motion/crossfade.ts +97 -0
  232. package/src/motion/element.tsx +10 -7
  233. package/src/motion/flip.ts +62 -23
  234. package/src/motion/glide.tsx +5 -0
  235. package/src/motion/motion.ts +7 -0
  236. package/src/motion/motion.usage.md +34 -0
  237. package/src/motion/presence.tsx +4 -0
  238. package/src/motion/use-motion.ts +8 -3
  239. package/src/theme-scope.ts +19 -0
  240. package/src/tokens/base.css +7 -0
  241. package/src/tokens/color.css +17 -15
  242. package/src/tokens/component-styles.generated.ts +0 -2
  243. package/src/tokens/dark.css +3 -0
  244. package/src/tokens/decisions.css +5 -3
  245. package/src/tokens/semantic.css +12 -6
  246. package/src/tokens/spacing.css +3 -3
  247. package/src/tokens/theme-tokens.generated.ts +37 -31
  248. package/tailwind.css +2 -0
  249. package/dist/bloom-HV23M4AW.js.map +0 -1
  250. package/dist/chunk-2DNKZ57E.js +0 -72
  251. package/dist/chunk-2DNKZ57E.js.map +0 -1
  252. package/dist/chunk-AIAPXRCI.js.map +0 -1
  253. package/dist/chunk-BRKGYLEQ.js.map +0 -1
  254. package/dist/chunk-F64Z42PJ.js.map +0 -1
  255. package/dist/chunk-JINATP4N.js.map +0 -1
  256. package/dist/chunk-LNAV5E7S.js.map +0 -1
  257. package/dist/chunk-N43NDSME.js.map +0 -1
  258. package/dist/chunk-RJENXXTI.js +0 -93
  259. package/dist/chunk-RJENXXTI.js.map +0 -1
  260. package/dist/chunk-RW2A4M2Q.js +0 -57
  261. package/dist/chunk-RW2A4M2Q.js.map +0 -1
  262. package/dist/chunk-TDHLZY6I.js.map +0 -1
  263. package/dist/chunk-V6QAAOA5.js.map +0 -1
  264. package/dist/chunk-VDOBLABP.js +0 -38
  265. package/dist/chunk-VDOBLABP.js.map +0 -1
  266. package/dist/chunk-VQFILXQN.js.map +0 -1
  267. package/dist/chunk-VZXML7EH.js.map +0 -1
  268. package/dist/chunk-XKDR22VE.js.map +0 -1
  269. package/dist/count-badge.js +0 -13
  270. package/dist/count-badge.js.map +0 -1
  271. package/dist/paint-CJQCM6ZO.js.map +0 -1
  272. package/dist/status-badge.js +0 -72
  273. package/dist/status-badge.js.map +0 -1
  274. package/dist/theme-transition-VGLPZDJI.js.map +0 -1
  275. package/dist/tide-DJZMDAFT.js.map +0 -1
  276. package/dist/types/components/primitives/badge/CountBadge.d.ts +0 -8
  277. package/dist/types/components/primitives/badge/StatusBadge.d.ts +0 -15
  278. package/src/components/primitives/badge/CountBadge.tsx +0 -20
  279. package/src/components/primitives/badge/CountBadge.usage.md +0 -13
  280. package/src/components/primitives/badge/StatusBadge.tsx +0 -113
  281. package/src/components/primitives/badge/StatusBadge.usage.md +0 -14
@@ -15,56 +15,74 @@ import {
15
15
  import { sharedSlot } from '../shared-slot';
16
16
  import { UIMotion } from '../tokens/motion-tokens';
17
17
 
18
- export type FlipTuning = FlipOptions;
18
+ export interface FlipTuning extends FlipOptions {
19
+ /** Keep the element that last held the `layoutId` on screen through the handoff: a copy of it takes the same path and fades out while this one fades in. */
20
+ crossfade?: boolean;
21
+ }
22
+
23
+ const SAME_BOX_PX = 0.5;
19
24
 
20
25
  const sharedOwner = sharedSlot('motion.flip-owner@1', () => new Map<string, HTMLElement>());
21
26
 
27
+ let loadedCrossfade: typeof import('./crossfade') | null = null;
28
+
29
+ const loadCrossfade = (): void => {
30
+ if (!loadedCrossfade) void import('./crossfade').then((module) => (loadedCrossfade = module));
31
+ };
32
+
22
33
  const usable = (box: Box | null): box is Box => !!box && box.width > 0 && box.height > 0;
23
34
 
35
+ const sameBox = (a: Box, b: Box): boolean =>
36
+ (['left', 'top', 'width', 'height'] as const).every((side) => Math.abs(a[side] - b[side]) < SAME_BOX_PX);
37
+
24
38
  export function useFlip<T extends HTMLElement>(
25
39
  sharedId: string | null,
26
40
  tuning: FlipTuning = {},
27
- enabled = true,
28
- ): RefObject<T | null> {
41
+ inPlace: boolean,
42
+ ): { ref: RefObject<T | null>; play: () => void } {
29
43
  const ref = useRef<T | null>(null);
30
44
  const playing = useRef<{ play: Playback; el: T } | null>(null);
31
45
  const interrupted = useRef<Box | null>(null);
32
- const { size, timing } = tuning;
33
- const lastCommitted = enabled && sharedId === null && ref.current ? measure(ref.current) : null;
46
+ const origin = useRef<Box | null>(null);
47
+ const latest = useRef(tuning);
48
+ latest.current = tuning;
49
+ const { size, timing, crossfade } = tuning;
50
+ const enabled = inPlace || sharedId !== null;
51
+ const lastCommitted = ref.current && (inPlace || playing.current) ? measure(ref.current) : null;
34
52
 
35
53
  useLayoutEffect(() => {
36
54
  const el = ref.current;
37
55
  if (!el || !enabled) return;
56
+ if (crossfade) loadCrossfade();
38
57
  const live = playing.current;
39
- let from: Box | null;
40
- if (sharedId === null) from = lastCommitted;
41
- else if (live && live.el === el) from = measure(el);
42
- else if (interrupted.current) from = interrupted.current;
43
- else from = sharedOwner.get(sharedId) === el ? null : readShared(sharedId);
58
+ const midFlight = live?.el === el;
59
+ const moved = !!lastCommitted && !sameBox(lastCommitted, measure(el));
60
+ if (midFlight && !moved) return;
61
+ let from = moved ? lastCommitted : null;
62
+ if (sharedId !== null && !midFlight) {
63
+ if (interrupted.current) from = interrupted.current;
64
+ else if (sharedOwner.get(sharedId) !== el) from = readShared(sharedId);
65
+ }
44
66
  live?.play.stop();
67
+ playing.current = null;
68
+ interrupted.current = null;
45
69
  if (sharedId !== null) {
46
70
  keepShared(sharedId, measure(el));
47
71
  sharedOwner.set(sharedId, el);
48
72
  }
49
- const next = usable(from) && !UIMotion.reduced ? flip(el, from, { size, timing }) : null;
50
- playing.current = next ? { play: next, el } : null;
51
- interrupted.current = next ? from : null;
52
- next?.finished.then(() => {
53
- if (playing.current?.play === next) {
54
- playing.current = null;
55
- interrupted.current = null;
56
- }
57
- });
73
+ origin.current = from;
58
74
  });
59
75
 
60
76
  useLayoutEffect(() => {
61
- if (!enabled || sharedId === null) return;
77
+ if (sharedId === null) return;
62
78
  return () => {
63
79
  const live = playing.current;
64
80
  let box: Box | null = live ? measure(live.el) : null;
81
+ if (!usable(box)) box = ref.current ? measure(ref.current) : null;
82
+ if (latest.current.crossfade && loadedCrossfade && ref.current && usable(box) && !UIMotion.reduced)
83
+ loadedCrossfade.keep(sharedId, ref.current, box, latest.current);
65
84
  live?.play.stop();
66
85
  playing.current = null;
67
- if (!usable(box)) box = ref.current ? measure(ref.current) : null;
68
86
  if (usable(box)) keepShared(sharedId, box);
69
87
  const mine = readShared(sharedId);
70
88
  queueMicrotask(() => {
@@ -73,7 +91,28 @@ export function useFlip<T extends HTMLElement>(
73
91
  if (owner && !owner.isConnected) sharedOwner.delete(sharedId);
74
92
  });
75
93
  };
76
- }, [sharedId, enabled]);
94
+ }, [sharedId]);
95
+
96
+ const play = () => {
97
+ const el = ref.current;
98
+ const from = origin.current;
99
+ origin.current = null;
100
+ if (!el || !usable(from) || UIMotion.reduced) return;
101
+ const handoff =
102
+ sharedId !== null && crossfade && loadedCrossfade
103
+ ? loadedCrossfade.play(sharedId, el, from, { timing })
104
+ : undefined;
105
+ const next = handoff === undefined ? flip(el, from, { size, timing }) : handoff;
106
+ if (!next) return;
107
+ playing.current = { play: next, el };
108
+ interrupted.current = from;
109
+ next.finished.then(() => {
110
+ if (playing.current?.play === next) {
111
+ playing.current = null;
112
+ interrupted.current = null;
113
+ }
114
+ });
115
+ };
77
116
 
78
- return ref;
117
+ return { ref, play };
79
118
  }
@@ -28,6 +28,7 @@ function layoutBox(target: HTMLElement, container: HTMLElement): Box | null {
28
28
  export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null>) {
29
29
  const ref = useRef<HTMLSpanElement | null>(null);
30
30
  const visible = useRef(false);
31
+ const tracked = useRef<HTMLElement | null>(null);
31
32
 
32
33
  const enter = useCallback(
33
34
  (target: HTMLElement | null) => {
@@ -38,7 +39,10 @@ export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null
38
39
  if (!at) return;
39
40
  const motion = motionFor(box);
40
41
  const was = measure(pill);
42
+ const arrived = tracked.current !== target;
43
+ tracked.current = target;
41
44
  set(pill, { x: [at.left], y: [at.top], width: [at.width], height: [at.height] });
45
+ if (!arrived) return;
42
46
  animate(pill, { opacity: [1], timing: { duration: motion.dur.fast, ease: motion.ease.standard } });
43
47
  const glided = visible.current && !motion.reduced && was.width > 0 && was.height > 0;
44
48
  visible.current = true;
@@ -49,6 +53,7 @@ export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null
49
53
 
50
54
  const leave = useCallback(() => {
51
55
  visible.current = false;
56
+ tracked.current = null;
52
57
  if (!ref.current) return;
53
58
  const motion = motionFor(containerRef.current);
54
59
  animate(ref.current, { opacity: [0], timing: { duration: motion.dur.fast, ease: motion.ease.exit } });
@@ -0,0 +1,7 @@
1
+ export type { Layer, Playback } from '../engine';
2
+ export { Motion, type MotionProps } from './element';
3
+ export type { FlipTuning } from './flip';
4
+ export { usePresence, type PresenceState } from './presence-context';
5
+ export { Presence, type PresenceProps } from './presence';
6
+ export { popIn, popOut, slideIn } from './presets';
7
+ export { useMotion, type MotionSpec, type MotionSpecs, type Plays } from './use-motion';
@@ -0,0 +1,34 @@
1
+ # Motion / Presence - @zyncat/ui/motion
2
+
3
+ Group: primitives
4
+
5
+ The React layer over the engine: animate an element you render, and hold a leaving one mounted until its exit finishes.
6
+
7
+ `<Motion>` renders the tag in `as` and plays `animate` on mount, then again whenever `deps` change.
8
+ `exit` plays when a parent `<Presence>` drops the child, which stays mounted until it finishes - a
9
+ child with no `exit` is dropped at once. `layout` and `layoutId` FLIP the box from where it last was
10
+ instead of animating a value. Every spec is a `Layer`, a `Layer[]`, or a function returning the
11
+ `Playback`s to wait on.
12
+
13
+ `<Presence>` needs keyed children; `mode="wait"` holds the entering child back until the outgoing one
14
+ has left, and `initial={false}` skips the entrance for children present at its own first paint.
15
+
16
+ `useMotion(ref, specs)` is the same machinery for an element you hold a ref to but do not render.
17
+ `usePresence()` reads whether the current child is leaving. `popIn` / `popOut` / `slideIn` are the
18
+ named presets - feed them `UIMotion.scale` and `UIMotion.dist` from `@zyncat/ui/motion-tokens`, never
19
+ literals.
20
+
21
+ ```tsx
22
+ <Presence mode="wait" onExitComplete={clearStep}>
23
+ {step && (
24
+ <Motion
25
+ key={step.id}
26
+ animate={popIn(UIMotion.scale.panel, UIMotion.t.enter)}
27
+ exit={popOut(UIMotion.scale.panel, UIMotion.t.exit)}
28
+ deps={[step.id]}
29
+ >
30
+ {step.body}
31
+ </Motion>
32
+ )}
33
+ </Presence>
34
+ ```
@@ -103,6 +103,10 @@ export function Presence({ children, initial = true, mode = 'sync', onExitComple
103
103
 
104
104
  const leaving = shown.some((entry) => entry.exiting);
105
105
 
106
+ useEffect(() => {
107
+ bornAtMount.current.clear();
108
+ }, []);
109
+
106
110
  useEffect(() => {
107
111
  if (wasExiting.current && !leaving) complete.current?.();
108
112
  wasExiting.current = leaving;
@@ -16,6 +16,9 @@ export function run(spec: MotionSpec | undefined, el: HTMLElement): Playback[] {
16
16
  return [Array.isArray(spec) ? animate(el, ...spec) : animate(el, spec)];
17
17
  }
18
18
 
19
+ const sameDeps = (a: unknown[], b: unknown[]): boolean =>
20
+ a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
21
+
19
22
  const allSettled = (plays: Playback[]): Promise<void> =>
20
23
  plays.length ? Promise.all(plays.map((play) => play.finished)).then((): void => {}) : Promise.resolve();
21
24
 
@@ -34,7 +37,7 @@ export interface MotionSpecs {
34
37
  export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, initial, deps }: MotionSpecs): void {
35
38
  const presence = usePresence();
36
39
  const playing = useRef<Playback[]>([]);
37
- const mounted = useRef(false);
40
+ const ran = useRef<unknown[] | null>(null);
38
41
  const exiting = useRef(false);
39
42
  const spec = useRef({ animate, exit, initial });
40
43
  spec.current = { animate, exit, initial };
@@ -57,9 +60,11 @@ export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, i
57
60
 
58
61
  useLayoutEffect(() => {
59
62
  const el = ref.current;
60
- const atMount = !mounted.current;
61
- mounted.current = true;
62
63
  if (!el) return;
64
+ const current = deps ?? [];
65
+ const previous = ran.current;
66
+ ran.current = current;
67
+ const atMount = !previous || sameDeps(previous, current);
63
68
  if (atMount && (spec.current.initial ?? presence.initial) === false) return;
64
69
  stop();
65
70
  playing.current = run(spec.current.animate, el);
@@ -0,0 +1,19 @@
1
+ const nearestTheme = (el: Element | null | undefined, attr: string): string | null =>
2
+ el?.closest(`[${attr}]`)?.getAttribute(attr) ?? null;
3
+
4
+ const themeDifferingFromPage = (scope: Element | null | undefined, attr: string): string | undefined => {
5
+ const own = nearestTheme(scope, attr);
6
+ return own !== null && own !== nearestTheme(document.body, attr) ? own : undefined;
7
+ };
8
+
9
+ export interface InheritedThemeAttrs {
10
+ 'data-theme'?: string;
11
+ 'data-polarity'?: string;
12
+ }
13
+
14
+ export function inheritedThemeAttrs(scope: Element | null | undefined): InheritedThemeAttrs {
15
+ return {
16
+ 'data-theme': themeDifferingFromPage(scope, 'data-theme'),
17
+ 'data-polarity': themeDifferingFromPage(scope, 'data-polarity'),
18
+ };
19
+ }
@@ -63,6 +63,13 @@
63
63
  outline-color: var(--ring-color-accent);
64
64
  }
65
65
 
66
+ /* Both rules above skip tabindex="-1", so a programmatic focus target - a listbox scroller, a menu
67
+ surface, a modal panel - would otherwise fall through to the UA outline. Its indicator is the
68
+ active descendant, not the container. */
69
+ :where([tabindex='-1']):focus {
70
+ outline: none;
71
+ }
72
+
66
73
  /* Chrome forces both at paint time, so neither color nor background-color reaches them. */
67
74
  :is(:autofill, :-webkit-autofill) {
68
75
  -webkit-text-fill-color: var(--text-strong);
@@ -4,25 +4,27 @@
4
4
  :root,
5
5
  [data-theme],
6
6
  [data-polarity] {
7
- /* The top of the ramp, not pure white: it carries --neutral like every rung below it. */
8
- --gray-0: oklch(from var(--neutral) 0.995 0.002 h);
9
- --gray-50: oklch(from var(--neutral) 0.984 0.003 h);
10
- --gray-100: oklch(from var(--neutral) 0.97 0.004 h);
11
- --gray-150: oklch(from var(--neutral) 0.954 0.005 h);
12
- --gray-200: oklch(from var(--neutral) 0.924 0.006 h);
13
- --gray-300: oklch(from var(--neutral) 0.874 0.007 h);
14
- --gray-400: oklch(from var(--neutral) 0.765 0.009 h);
15
- --gray-500: oklch(from var(--neutral) 0.642 0.011 h);
16
- --gray-600: oklch(from var(--neutral) 0.532 0.012 h);
17
- --gray-700: oklch(from var(--neutral) 0.422 0.012 h);
18
- --gray-800: oklch(from var(--neutral) 0.305 0.01 h);
19
- --gray-900: oklch(from var(--neutral) 0.225 0.008 h);
20
- --gray-950: oklch(from var(--neutral) 0.165 0.007 h);
7
+ /* Stripe's neutral ramp, rung for rung: --neutral is its midpoint, and every step holds that
8
+ hue's distance from it, so a new --neutral carries the whole ramp with it. The top rung is
9
+ pure white - the only rung Stripe leaves untinted. */
10
+ --gray-0: oklch(from var(--neutral) 1 0 h);
11
+ --gray-50: oklch(from var(--neutral) 0.978 0.0034 calc(h - 12.4));
12
+ --gray-100: oklch(from var(--neutral) 0.948 0.0052 calc(h - 12.4));
13
+ --gray-150: oklch(from var(--neutral) 0.889 0.0105 calc(h - 12.3));
14
+ --gray-200: oklch(from var(--neutral) 0.83 0.0165 calc(h - 6.4));
15
+ --gray-300: oklch(from var(--neutral) 0.742 0.0226 calc(h - 1.1));
16
+ --gray-400: oklch(from var(--neutral) 0.651 0.0247 calc(h + 0.4));
17
+ --gray-500: oklch(from var(--neutral) 0.553 0.031 h);
18
+ --gray-600: oklch(from var(--neutral) 0.466 0.0267 calc(h + 11.4));
19
+ --gray-700: oklch(from var(--neutral) 0.392 0.0226 calc(h + 11.6));
20
+ --gray-800: oklch(from var(--neutral) 0.317 0.0214 calc(h + 21.1));
21
+ --gray-900: oklch(from var(--neutral) 0.226 0.0194 calc(h + 20));
22
+ --gray-950: oklch(from var(--neutral) 0.181 0.0185 calc(h + 19.2));
21
23
  }
22
24
 
23
25
  :root,
24
26
  [data-polarity='light'] {
25
27
  /* Cool near-black on the white canvas. */
26
- --shadow-rgb: 15 22 25;
28
+ --shadow-rgb: 16 17 26;
27
29
  }
28
30
  }
@@ -109,8 +109,6 @@ export interface OdometerStyle extends CSSProperties {
109
109
  '--odometer-gap'?: string | number;
110
110
  /** `--odometer-ink` - Digit ink. Default: `var(--text-strong)`. */
111
111
  '--odometer-ink'?: string | number;
112
- /** `--odometer-accent` - The tint digits take while they roll fast. Default: `var(--accent)`. */
113
- '--odometer-accent'?: string | number;
114
112
  /** `--odometer-separator-ink` - The thousands separator. Default: `var(--text-muted)`. */
115
113
  '--odometer-separator-ink'?: string | number;
116
114
  /** `--odometer-size` - Digit size. Default: `var(--size-display)`. */
@@ -24,6 +24,9 @@
24
24
  --border-default: oklch(from var(--neutral) 0.315 0.009 h);
25
25
  --border-strong: oklch(from var(--neutral) 0.4 0.011 h);
26
26
 
27
+ --bg-hover: color-mix(in oklab, var(--text-secondary) 6%, transparent);
28
+ --bg-press: color-mix(in oklab, var(--text-secondary) 10%, transparent);
29
+
27
30
  --shadow-rgb: 0 0 0;
28
31
  --shadow-strength: 3.5;
29
32
  --sheen-strength: 0.2;
@@ -4,15 +4,17 @@
4
4
  :root,
5
5
  [data-theme='default'] {
6
6
  /* The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. */
7
- --accent: oklch(0.63 0.118 198);
7
+ --accent: oklch(0.7 0.118 198);
8
8
  /* Positive status - its subtle, text and wash follow. */
9
9
  --success: oklch(0.548 0.122 152);
10
10
  /* Caution - its subtle, text and wash follow. */
11
11
  --warning: oklch(0.7 0.142 75);
12
12
  /* Destructive actions and errors - the danger button ladder, ring, subtle, text and wash follow. */
13
13
  --danger: oklch(0.545 0.196 27);
14
- /* The gray ramp's hue - the accent by default, so chrome shares its temperature. */
15
- --neutral: var(--accent);
14
+ /* The middle of the gray ramp - every rung holds its hue distance from this one, so moving it
15
+ retints the whole ramp. Stripe's gray-500 lightness and chroma over the accent's hue, so the
16
+ grays carry the brand temperature; give it a literal hue for a ramp that does not follow. */
17
+ --neutral: oklch(from var(--accent) 0.553 0.031 h);
16
18
  /* Roundness - every --radius-<step> is a fixed ratio of it, 0 squaring every corner. */
17
19
  --radius: 0.5rem;
18
20
  /* The body face - every --type-* bundle follows. The package loads no webfont; point this at yours. */
@@ -23,9 +23,16 @@
23
23
  /* The ink on a strong-ink fill - the canvas colour in either polarity. */
24
24
  --text-inverse: var(--gray-0);
25
25
 
26
- --border-subtle: var(--gray-150);
27
- --border-default: var(--gray-200);
28
- --border-strong: var(--gray-300);
26
+ /* One rung lighter than the ink roles: Stripe hangs its hairline on gray-150, not gray-200. */
27
+ --border-subtle: var(--gray-100);
28
+ --border-default: var(--gray-150);
29
+ --border-strong: var(--gray-200);
30
+
31
+ /* Stripe's slate rung at the alpha that lands its hover face exactly on the canvas: translucent,
32
+ so a tinted surface still shows through instead of being covered. Held at the ramp's distance
33
+ from --neutral, so a retint carries the hover with it. */
34
+ --bg-hover: oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.246);
35
+ --bg-press: oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.291);
29
36
  }
30
37
 
31
38
  :root,
@@ -45,9 +52,8 @@
45
52
  /* The ink on a hue fill - the ramp's lightest rung in either polarity. */
46
53
  --text-on-accent: var(--gray-0);
47
54
 
48
- /* Translucent washes of the ink, never opaque near-whites. */
49
- --neutral-wash: color-mix(in oklab, var(--text-secondary) 6%, transparent);
50
- --neutral-wash-press: color-mix(in oklab, var(--text-secondary) 10%, transparent);
55
+ --neutral-wash: var(--bg-hover);
56
+ --neutral-wash-press: var(--bg-press);
51
57
 
52
58
  /* The accent's hue one step down - repoint it for a hue of its own. */
53
59
  --info: var(--accent-hover);
@@ -16,9 +16,9 @@
16
16
 
17
17
  --measure-prose: 38rem;
18
18
 
19
- --control-height-sm: 1.75rem;
20
- --control-height: 2rem;
21
- --control-height-lg: 2.3rem;
19
+ --control-height-sm: 1.85rem;
20
+ --control-height: 2.25rem;
21
+ --control-height-lg: 2.5rem;
22
22
  --control-box: 1.125rem;
23
23
  --control-switch: 1.25rem; /* the switch track - the one control size off the scale */
24
24
 
@@ -24,6 +24,10 @@ export interface ColorBgTokens {
24
24
  inset?: string | number;
25
25
  /** `--bg-overlay`. Default: `color-mix(in oklab, var(--gray-900) 44%, transparent)`. Dark: `oklch(from var(--neutral) 0.06 0.004 h / 0.64)`. */
26
26
  overlay?: string | number;
27
+ /** `--bg-hover` - Stripe's slate rung at the alpha that lands its hover face exactly on the canvas: translucent, so a tinted surface still shows through instead of being covered. Held at the ramp's distance from --neutral, so a retint carries the hover with it. Default: `oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.246)`. Dark: `color-mix(in oklab, var(--text-secondary) 6%, transparent)`. */
28
+ hover?: string | number;
29
+ /** `--bg-press`. Default: `oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.291)`. Dark: `color-mix(in oklab, var(--text-secondary) 10%, transparent)`. */
30
+ press?: string | number;
27
31
  }
28
32
 
29
33
  /** Ink, from strong to disabled, and the faces on a fill. */
@@ -46,19 +50,19 @@ export interface ColorTextTokens {
46
50
 
47
51
  /** Hairlines, from subtle to strong. */
48
52
  export interface ColorBorderTokens {
49
- /** `--border-subtle`. Default: `var(--gray-150)`. Dark: `oklch(from var(--neutral) 0.265 0.008 h)`. */
53
+ /** `--border-subtle` - One rung lighter than the ink roles: Stripe hangs its hairline on gray-150, not gray-200. Default: `var(--gray-100)`. Dark: `oklch(from var(--neutral) 0.265 0.008 h)`. */
50
54
  subtle?: string | number;
51
- /** `--border-default`. Default: `var(--gray-200)`. Dark: `oklch(from var(--neutral) 0.315 0.009 h)`. */
55
+ /** `--border-default`. Default: `var(--gray-150)`. Dark: `oklch(from var(--neutral) 0.315 0.009 h)`. */
52
56
  default?: string | number;
53
- /** `--border-strong`. Default: `var(--gray-300)`. Dark: `oklch(from var(--neutral) 0.4 0.011 h)`. */
57
+ /** `--border-strong`. Default: `var(--gray-200)`. Dark: `oklch(from var(--neutral) 0.4 0.011 h)`. */
54
58
  strong?: string | number;
55
59
  }
56
60
 
57
61
  /** The hues, and the neutral roles a light or dark theme sets directly. */
58
62
  export interface ColorTokens {
59
- /** `--accent` - The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. Default: `oklch(0.63 0.118 198)`. */
63
+ /** `--accent` - The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. Default: `oklch(0.7 0.118 198)`. */
60
64
  accent?: string | number;
61
- /** `--neutral` - The gray ramp's hue - the accent by default, so chrome shares its temperature. Default: `var(--accent)`. */
65
+ /** `--neutral` - The middle of the gray ramp - every rung holds its hue distance from this one, so moving it retints the whole ramp. Stripe's gray-500 lightness and chroma over the accent's hue, so the grays carry the brand temperature; give it a literal hue for a ramp that does not follow. Default: `oklch(from var(--accent) 0.553 0.031 h)`. */
62
66
  neutral?: string | number;
63
67
  /** `--success` - Positive status - its subtle, text and wash follow. Default: `oklch(0.548 0.122 152)`. */
64
68
  success?: string | number;
@@ -284,8 +288,6 @@ export interface OdometerTokens {
284
288
  gap?: string | number;
285
289
  /** `--odometer-ink` - Digit ink. Default: `var(--text-strong)`. */
286
290
  ink?: string | number;
287
- /** `--odometer-accent` - The tint digits take while they roll fast. Default: `var(--accent)`. */
288
- accent?: string | number;
289
291
  /** `--odometer-separator-ink` - The thousands separator. Default: `var(--text-muted)`. */
290
292
  separatorInk?: string | number;
291
293
  /** `--odometer-size` - Digit size. Default: `var(--size-display)`. */
@@ -409,7 +411,7 @@ export interface ComponentTokens {
409
411
  * `custom` in a theme and behind the `style` prop of every component.
410
412
  */
411
413
  export interface TokenProperties {
412
- /** `--accent` - The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. Default: `oklch(0.63 0.118 198)`. */
414
+ /** `--accent` - The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. Default: `oklch(0.7 0.118 198)`. */
413
415
  '--accent'?: string | number;
414
416
  /** `--success` - Positive status - its subtle, text and wash follow. Default: `oklch(0.548 0.122 152)`. */
415
417
  '--success'?: string | number;
@@ -417,7 +419,7 @@ export interface TokenProperties {
417
419
  '--warning'?: string | number;
418
420
  /** `--danger` - Destructive actions and errors - the danger button ladder, ring, subtle, text and wash follow. Default: `oklch(0.545 0.196 27)`. */
419
421
  '--danger'?: string | number;
420
- /** `--neutral` - The gray ramp's hue - the accent by default, so chrome shares its temperature. Default: `var(--accent)`. */
422
+ /** `--neutral` - The middle of the gray ramp - every rung holds its hue distance from this one, so moving it retints the whole ramp. Stripe's gray-500 lightness and chroma over the accent's hue, so the grays carry the brand temperature; give it a literal hue for a ramp that does not follow. Default: `oklch(from var(--accent) 0.553 0.031 h)`. */
421
423
  '--neutral'?: string | number;
422
424
  /** `--radius` - Roundness - every --radius-<step> is a fixed ratio of it, 0 squaring every corner. Default: `0.5rem`. */
423
425
  '--radius'?: string | number;
@@ -425,33 +427,33 @@ export interface TokenProperties {
425
427
  '--font-body'?: string | number;
426
428
  /** `--font-code` - The code face - --type-code follows. The package loads no webfont; point this at yours. Default: `ui-monospace, 'SF Mono', 'Menlo', monospace`. */
427
429
  '--font-code'?: string | number;
428
- /** `--gray-0` - The top of the ramp, not pure white: it carries --neutral like every rung below it. Default: `oklch(from var(--neutral) 0.995 0.002 h)`. Re-derived on every theme root. */
430
+ /** `--gray-0` - Stripe's neutral ramp, rung for rung: --neutral is its midpoint, and every step holds that hue's distance from it, so a new --neutral carries the whole ramp with it. The top rung is pure white - the only rung Stripe leaves untinted. Default: `oklch(from var(--neutral) 1 0 h)`. Re-derived on every theme root. */
429
431
  '--gray-0'?: string | number;
430
- /** `--gray-50`. Default: `oklch(from var(--neutral) 0.984 0.003 h)`. Re-derived on every theme root. */
432
+ /** `--gray-50`. Default: `oklch(from var(--neutral) 0.978 0.0034 calc(h - 12.4))`. Re-derived on every theme root. */
431
433
  '--gray-50'?: string | number;
432
- /** `--gray-100`. Default: `oklch(from var(--neutral) 0.97 0.004 h)`. Re-derived on every theme root. */
434
+ /** `--gray-100`. Default: `oklch(from var(--neutral) 0.948 0.0052 calc(h - 12.4))`. Re-derived on every theme root. */
433
435
  '--gray-100'?: string | number;
434
- /** `--gray-150`. Default: `oklch(from var(--neutral) 0.954 0.005 h)`. Re-derived on every theme root. */
436
+ /** `--gray-150`. Default: `oklch(from var(--neutral) 0.889 0.0105 calc(h - 12.3))`. Re-derived on every theme root. */
435
437
  '--gray-150'?: string | number;
436
- /** `--gray-200`. Default: `oklch(from var(--neutral) 0.924 0.006 h)`. Re-derived on every theme root. */
438
+ /** `--gray-200`. Default: `oklch(from var(--neutral) 0.83 0.0165 calc(h - 6.4))`. Re-derived on every theme root. */
437
439
  '--gray-200'?: string | number;
438
- /** `--gray-300`. Default: `oklch(from var(--neutral) 0.874 0.007 h)`. Re-derived on every theme root. */
440
+ /** `--gray-300`. Default: `oklch(from var(--neutral) 0.742 0.0226 calc(h - 1.1))`. Re-derived on every theme root. */
439
441
  '--gray-300'?: string | number;
440
- /** `--gray-400`. Default: `oklch(from var(--neutral) 0.765 0.009 h)`. Re-derived on every theme root. */
442
+ /** `--gray-400`. Default: `oklch(from var(--neutral) 0.651 0.0247 calc(h + 0.4))`. Re-derived on every theme root. */
441
443
  '--gray-400'?: string | number;
442
- /** `--gray-500`. Default: `oklch(from var(--neutral) 0.642 0.011 h)`. Re-derived on every theme root. */
444
+ /** `--gray-500`. Default: `oklch(from var(--neutral) 0.553 0.031 h)`. Re-derived on every theme root. */
443
445
  '--gray-500'?: string | number;
444
- /** `--gray-600`. Default: `oklch(from var(--neutral) 0.532 0.012 h)`. Re-derived on every theme root. */
446
+ /** `--gray-600`. Default: `oklch(from var(--neutral) 0.466 0.0267 calc(h + 11.4))`. Re-derived on every theme root. */
445
447
  '--gray-600'?: string | number;
446
- /** `--gray-700`. Default: `oklch(from var(--neutral) 0.422 0.012 h)`. Re-derived on every theme root. */
448
+ /** `--gray-700`. Default: `oklch(from var(--neutral) 0.392 0.0226 calc(h + 11.6))`. Re-derived on every theme root. */
447
449
  '--gray-700'?: string | number;
448
- /** `--gray-800`. Default: `oklch(from var(--neutral) 0.305 0.01 h)`. Re-derived on every theme root. */
450
+ /** `--gray-800`. Default: `oklch(from var(--neutral) 0.317 0.0214 calc(h + 21.1))`. Re-derived on every theme root. */
449
451
  '--gray-800'?: string | number;
450
- /** `--gray-900`. Default: `oklch(from var(--neutral) 0.225 0.008 h)`. Re-derived on every theme root. */
452
+ /** `--gray-900`. Default: `oklch(from var(--neutral) 0.226 0.0194 calc(h + 20))`. Re-derived on every theme root. */
451
453
  '--gray-900'?: string | number;
452
- /** `--gray-950`. Default: `oklch(from var(--neutral) 0.165 0.007 h)`. Re-derived on every theme root. */
454
+ /** `--gray-950`. Default: `oklch(from var(--neutral) 0.181 0.0185 calc(h + 19.2))`. Re-derived on every theme root. */
453
455
  '--gray-950'?: string | number;
454
- /** `--shadow-rgb` - Cool near-black on the white canvas. Default: `15 22 25`. Dark: `0 0 0`. */
456
+ /** `--shadow-rgb` - Cool near-black on the white canvas. Default: `16 17 26`. Dark: `0 0 0`. */
455
457
  '--shadow-rgb'?: string | number;
456
458
  /** `--weight-regular`. Default: `400`. */
457
459
  '--weight-regular'?: string | number;
@@ -551,11 +553,11 @@ export interface TokenProperties {
551
553
  '--space-10'?: string | number;
552
554
  /** `--measure-prose`. Default: `38rem`. */
553
555
  '--measure-prose'?: string | number;
554
- /** `--control-height-sm`. Default: `1.75rem`. */
556
+ /** `--control-height-sm`. Default: `1.85rem`. */
555
557
  '--control-height-sm'?: string | number;
556
- /** `--control-height`. Default: `2rem`. */
558
+ /** `--control-height`. Default: `2.25rem`. */
557
559
  '--control-height'?: string | number;
558
- /** `--control-height-lg`. Default: `2.3rem`. */
560
+ /** `--control-height-lg`. Default: `2.5rem`. */
559
561
  '--control-height-lg'?: string | number;
560
562
  /** `--control-box`. Default: `1.125rem`. */
561
563
  '--control-box'?: string | number;
@@ -723,12 +725,16 @@ export interface TokenProperties {
723
725
  '--text-disabled'?: string | number;
724
726
  /** `--text-inverse` - The ink on a strong-ink fill - the canvas colour in either polarity. Default: `var(--gray-0)`. Dark: `oklch(from var(--neutral) 0.165 0.006 h)`. */
725
727
  '--text-inverse'?: string | number;
726
- /** `--border-subtle`. Default: `var(--gray-150)`. Dark: `oklch(from var(--neutral) 0.265 0.008 h)`. */
728
+ /** `--border-subtle` - One rung lighter than the ink roles: Stripe hangs its hairline on gray-150, not gray-200. Default: `var(--gray-100)`. Dark: `oklch(from var(--neutral) 0.265 0.008 h)`. */
727
729
  '--border-subtle'?: string | number;
728
- /** `--border-default`. Default: `var(--gray-200)`. Dark: `oklch(from var(--neutral) 0.315 0.009 h)`. */
730
+ /** `--border-default`. Default: `var(--gray-150)`. Dark: `oklch(from var(--neutral) 0.315 0.009 h)`. */
729
731
  '--border-default'?: string | number;
730
- /** `--border-strong`. Default: `var(--gray-300)`. Dark: `oklch(from var(--neutral) 0.4 0.011 h)`. */
732
+ /** `--border-strong`. Default: `var(--gray-200)`. Dark: `oklch(from var(--neutral) 0.4 0.011 h)`. */
731
733
  '--border-strong'?: string | number;
734
+ /** `--bg-hover` - Stripe's slate rung at the alpha that lands its hover face exactly on the canvas: translucent, so a tinted surface still shows through instead of being covered. Held at the ramp's distance from --neutral, so a retint carries the hover with it. Default: `oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.246)`. Dark: `color-mix(in oklab, var(--text-secondary) 6%, transparent)`. */
735
+ '--bg-hover'?: string | number;
736
+ /** `--bg-press`. Default: `oklch(from var(--neutral) 0.896 0.0186 calc(h - 9.7) / 0.291)`. Dark: `color-mix(in oklab, var(--text-secondary) 10%, transparent)`. */
737
+ '--bg-press'?: string | number;
732
738
  /** `--accent-fill` - The resting face of a filled control. Default: `var(--accent)`. Dark: `oklch(from var(--accent) calc(l - 0.06) calc(c - 0.01) h)`. Re-derived on every theme root. */
733
739
  '--accent-fill'?: string | number;
734
740
  /** `--accent-lift`. Default: `oklch(from var(--accent) calc(l + 0.075) calc(c - 0.006) h)`. Re-derived on every theme root. */
@@ -749,9 +755,9 @@ export interface TokenProperties {
749
755
  '--text-accent'?: string | number;
750
756
  /** `--text-on-accent` - The ink on a hue fill - the ramp's lightest rung in either polarity. Default: `var(--gray-0)`. Re-derived on every theme root. */
751
757
  '--text-on-accent'?: string | number;
752
- /** `--neutral-wash` - Translucent washes of the ink, never opaque near-whites. Default: `color-mix(in oklab, var(--text-secondary) 6%, transparent)`. Re-derived on every theme root. */
758
+ /** `--neutral-wash`. Default: `var(--bg-hover)`. Re-derived on every theme root. */
753
759
  '--neutral-wash'?: string | number;
754
- /** `--neutral-wash-press`. Default: `color-mix(in oklab, var(--text-secondary) 10%, transparent)`. Re-derived on every theme root. */
760
+ /** `--neutral-wash-press`. Default: `var(--bg-press)`. Re-derived on every theme root. */
755
761
  '--neutral-wash-press'?: string | number;
756
762
  /** `--info` - The accent's hue one step down - repoint it for a hue of its own. Default: `var(--accent-hover)`. Re-derived on every theme root. */
757
763
  '--info'?: string | number;
package/tailwind.css CHANGED
@@ -21,6 +21,8 @@
21
21
  --background-color-muted: var(--bg-muted);
22
22
  --background-color-inset: var(--bg-inset);
23
23
  --background-color-overlay: var(--bg-overlay);
24
+ --background-color-hover: var(--bg-hover);
25
+ --background-color-press: var(--bg-press);
24
26
 
25
27
  /* Ink - text-<role>; the body ink is text-default because text-body is the type role */
26
28
  --text-color-strong: var(--text-strong);
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/expressive/theme-transition/bloom.ts"],"names":[],"mappings":";;;AAEA,IAAM,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,EAAM,SAAS,GAAA,EAAI;AAChD,IAAM,UAAA,GAAa,CAAA;AACnB,IAAM,WAAA,GAAc,GAAA;AACpB,IAAM,YAAA,GAAe,IAAA;AACrB,IAAM,IAAA,GAAO,IAAA;AACb,IAAM,SAAA,GAAY,CAAA;AAClB,IAAM,UAAA,GAAa,CAAA;AACnB,IAAM,QAAA,GAAW,IAAA;AACjB,IAAM,WAAA,GAAc,CAAA;AACpB,IAAM,SAAA,GAAY,IAAA;AAClB,IAAM,cAAA,GAAiB,GAAA;AACvB,IAAM,UAAA,GAAsF;AAAA,EAC1F,CAAC,CAAA,EAAG,IAAA,EAAM,GAAA,EAAK,GAAG,CAAA;AAAA,EAClB,CAAC,CAAA,EAAG,IAAA,EAAM,GAAA,EAAK,IAAI,CAAA;AAAA,EACnB,CAAC,CAAA,EAAG,KAAA,EAAO,GAAA,EAAK,GAAG;AACrB,CAAA;AASA,IAAM,KAAA,GAAQ,CAAC,KAAA,EAAe,GAAA,EAAa,UAAkB,IAAA,MAA2B;AAAA,EACtF,QAAA;AAAA,EACA,WAAW,CAAA,GAAI,GAAA;AAAA,EACf,MAAA,EAAQ,CAAC,KAAA,KAAU,CAAA,GAAK,GAAA,IAAO,IAAI,IAAA,CAAK,GAAA,CAAI,KAA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AA,EACrG,CAAA;AACA,EAAA,OAAO,EAAE,QAAA,EAAU,QAAA,CAAS,IAAI,CAAA,EAAG,KAAA,EAAO,MAAA,CAAO,QAAA,CAAS,IAAI,CAAA,EAAG,SAAA,EAAW,MAAM,CAAA,EAAE;AACtF","file":"bloom-HV23M4AW.js","sourcesContent":["import { clamp, easeInOut, easeOut, sample, SAMPLE_MS, TAU, type BloomShape, type EffectFactory } from './scene';\n\nconst DURATION = { polarity: 1400, palette: 620 };\nconst MAX_RELIEF = 2;\nconst DEEPEST_CUT = 0.7;\nconst COVER_MARGIN = 1.02;\nconst SPIN = 0.35;\nconst HEX_SIDES = 6;\nconst STAR_LOBES = 8;\nconst STAR_CUT = 0.38;\nconst PETAL_LOBES = 5;\nconst PETAL_CUT = 0.26;\nconst CURVE_VERTICES = 120;\nconst BLOB_WAVES: readonly [lobes: number, depth: number, phase: number, drift: number][] = [\n [2, 0.09, 0.6, 1.1],\n [3, 0.07, 2.4, -0.8],\n [5, 0.045, 4.1, 1.7],\n];\n\ninterface Outline {\n vertices: number;\n innermost: number;\n radial(theta: number, progress: number): number;\n turn(progress: number): number;\n}\n\nconst lobed = (lobes: number, cut: number, vertices: number, spin: number): Outline => ({\n vertices,\n innermost: 1 - cut,\n radial: (theta) => 1 - (cut * (1 - Math.cos(lobes * theta))) / 2,\n turn: (progress) => spin * progress,\n});\n\nconst OUTLINES: Record<Exclude<BloomShape, 'circle'>, (relief: number) => Outline> = {\n hexagon: (relief) => ({\n vertices: HEX_SIDES,\n innermost: Math.cos(Math.PI / HEX_SIDES),\n radial: () => 1,\n turn: (progress) => Math.PI / HEX_SIDES + SPIN * relief * progress,\n }),\n star: (relief) => lobed(STAR_LOBES, clamp(STAR_CUT * relief, 0, DEEPEST_CUT), STAR_LOBES * 2, SPIN * relief),\n petal: (relief) => lobed(PETAL_LOBES, clamp(PETAL_CUT * relief, 0, DEEPEST_CUT), CURVE_VERTICES, SPIN * relief),\n blob: (relief) => {\n const swell = Math.min(relief, DEEPEST_CUT / BLOB_WAVES.reduce((sum, [, depth]) => sum + depth, 0));\n return {\n vertices: CURVE_VERTICES,\n innermost: 1 - BLOB_WAVES.reduce((sum, [, depth]) => sum + depth * swell, 0),\n radial: (theta, progress) =>\n BLOB_WAVES.reduce(\n (r, [lobes, depth, phase, drift]) => r + depth * swell * Math.sin(lobes * theta + phase + drift * progress),\n 1,\n ),\n turn: () => 0,\n };\n },\n};\n\nconst polygonAt = (outline: Outline, reach: number, progress: number, ox: number, oy: number) => {\n const turn = outline.turn(progress);\n const points: string[] = [];\n for (let i = 0; i < outline.vertices; i++) {\n const theta = (i / outline.vertices) * TAU;\n const r = reach * outline.radial(theta, progress);\n const a = theta + turn;\n points.push(`${(ox + Math.cos(a) * r).toFixed(1)}px ${(oy + Math.sin(a) * r).toFixed(1)}px`);\n }\n return `polygon(${points.join(', ')})`;\n};\n\nexport const bloom: EffectFactory = (scene) => {\n const { width: W, height: H, originX: ox, originY: oy, kind, shape } = scene;\n const relief = clamp(scene.intensity, 0, MAX_RELIEF);\n const farthest = Math.max(\n Math.hypot(ox, oy),\n Math.hypot(W - ox, oy),\n Math.hypot(ox, H - oy),\n Math.hypot(W - ox, H - oy),\n );\n const ease = kind === 'polarity' ? easeInOut : easeOut;\n const outline = shape === 'circle' ? null : OUTLINES[shape](relief);\n const reach = (farthest * COVER_MARGIN) / (outline?.innermost ?? 1);\n const at = ` at ${ox.toFixed(1)}px ${oy.toFixed(1)}px)`;\n const clipAt = (p: number) => {\n const e = ease(p);\n return outline ? polygonAt(outline, reach * e, e, ox, oy) : `circle(${(reach * e).toFixed(1)}px${at}`;\n };\n return { duration: DURATION[kind], clips: sample(DURATION[kind], SAMPLE_MS, clipAt) };\n};\n"]}