@lostgradient/cinder 0.25.1 → 0.26.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 (263) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/components.json +13 -6
  3. package/dist/components/alert-dialog/index.js +2 -2
  4. package/dist/components/approval-card/index.js +2 -2
  5. package/dist/components/area-chart/index.js +2 -2
  6. package/dist/components/autocomplete/index.js +2 -2
  7. package/dist/components/avatar-group/index.js +2 -2
  8. package/dist/components/backdrop/index.js +2 -2
  9. package/dist/components/bar-chart/index.js +2 -2
  10. package/dist/components/button/button.css +1 -1
  11. package/dist/components/checkbox/index.js +2 -2
  12. package/dist/components/code-block/index.js +2 -2
  13. package/dist/components/color-field/index.js +2 -2
  14. package/dist/components/combobox/index.js +2 -2
  15. package/dist/components/command-menu/index.js +2 -2
  16. package/dist/components/command-palette/command-palette.css +50 -46
  17. package/dist/components/command-palette/index.js +2 -2
  18. package/dist/components/confirm-dialog/index.js +2 -2
  19. package/dist/components/context-menu/index.js +2 -2
  20. package/dist/components/data-table/index.js +2 -2
  21. package/dist/components/date-picker/index.js +2 -2
  22. package/dist/components/date-range-field/index.js +2 -2
  23. package/dist/components/drawer/index.js +2 -2
  24. package/dist/components/dropdown/index.js +2 -2
  25. package/dist/components/dropdown-menu/index.js +2 -2
  26. package/dist/components/find-bar/find-bar.css +9 -1
  27. package/dist/components/focus-trap/index.js +2 -2
  28. package/dist/components/form-field/index.js +2 -2
  29. package/dist/components/hover-card/index.js +2 -2
  30. package/dist/components/inline-confirm/index.js +2 -2
  31. package/dist/components/input/index.js +2 -2
  32. package/dist/components/input/input.css +95 -6
  33. package/dist/components/invocation-rule-builder/index.js +2 -2
  34. package/dist/components/json-editor/index.js +2 -2
  35. package/dist/components/json-schema-editor/index.js +4 -4
  36. package/dist/components/key-value-editor/index.css +1 -1
  37. package/dist/components/line-chart/index.js +2 -2
  38. package/dist/components/matrix-chart/index.js +2 -2
  39. package/dist/components/menu-bar/index.js +3 -3
  40. package/dist/components/modal/index.js +2 -2
  41. package/dist/components/modal-region/index.css +1 -1
  42. package/dist/components/multi-select/index.js +2 -2
  43. package/dist/components/navigation-bar/index.js +2 -2
  44. package/dist/components/parameter-field/index.js +2 -2
  45. package/dist/components/permission-matrix/index.js +2 -2
  46. package/dist/components/policy-lock/index.js +2 -2
  47. package/dist/components/popover/index.js +2 -2
  48. package/dist/components/radio-group/index.js +2 -2
  49. package/dist/components/schedule-builder/index.js +2 -2
  50. package/dist/components/schema-form/index.js +2 -2
  51. package/dist/components/scroll-area/index.js +2 -2
  52. package/dist/components/select/index.js +2 -2
  53. package/dist/components/selection-popover/index.js +2 -2
  54. package/dist/components/share-card/index.js +2 -2
  55. package/dist/components/sidebar/index.js +2 -2
  56. package/dist/components/speed-dial/index.js +2 -2
  57. package/dist/components/statistic-group/index.js +2 -2
  58. package/dist/components/statistic-group/statistic-group.css +116 -66
  59. package/dist/components/table/index.js +2 -2
  60. package/dist/components/textarea/index.js +2 -2
  61. package/dist/components/time-field/index.js +2 -2
  62. package/dist/components/time-field/time-field.css +9 -8
  63. package/dist/components/toast-region/index.js +2 -2
  64. package/dist/components/tooltip/index.js +2 -2
  65. package/dist/components/transfer-list/index.js +2 -2
  66. package/dist/components/virtual-list/_internal/adaptive-overscan.d.ts +87 -0
  67. package/dist/components/virtual-list/_internal/edge-proximity.d.ts +75 -0
  68. package/dist/components/virtual-list/_internal/frame-scheduler.d.ts +76 -0
  69. package/dist/components/virtual-list/_internal/geometry.d.ts +170 -0
  70. package/dist/components/virtual-list/_internal/list-semantics.d.ts +93 -0
  71. package/dist/components/virtual-list/_internal/measurement-window.d.ts +125 -0
  72. package/dist/components/virtual-list/_internal/reverse-order.d.ts +87 -0
  73. package/dist/components/virtual-list/_internal/scroll-restoration.d.ts +98 -0
  74. package/dist/components/virtual-list/_internal/sticky-items.d.ts +48 -0
  75. package/dist/components/virtual-list/_internal/virtual-list-measurement-store.svelte.d.ts +69 -0
  76. package/dist/components/virtual-list/index.d.ts +1 -1
  77. package/dist/components/virtual-list/index.js +2 -2
  78. package/dist/components/virtual-list/virtual-list.css +153 -0
  79. package/dist/components/virtual-list/virtual-list.schema.js +69 -6
  80. package/dist/components/virtual-list/virtual-list.svelte.d.ts +11 -8
  81. package/dist/components/virtual-list/virtual-list.types.d.ts +177 -4
  82. package/dist/index.browser.css +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +18 -18
  85. package/dist/server/components/alert-dialog/index.js +1 -1
  86. package/dist/server/components/approval-card/index.js +1 -1
  87. package/dist/server/components/area-chart/index.js +1 -1
  88. package/dist/server/components/autocomplete/index.js +1 -1
  89. package/dist/server/components/avatar-group/index.js +1 -1
  90. package/dist/server/components/backdrop/index.js +1 -1
  91. package/dist/server/components/bar-chart/index.js +1 -1
  92. package/dist/server/components/checkbox/index.js +1 -1
  93. package/dist/server/components/code-block/index.js +1 -1
  94. package/dist/server/components/color-field/index.js +1 -1
  95. package/dist/server/components/combobox/index.js +1 -1
  96. package/dist/server/components/command-menu/index.js +1 -1
  97. package/dist/server/components/command-palette/index.js +2 -2
  98. package/dist/server/components/confirm-dialog/index.js +1 -1
  99. package/dist/server/components/context-menu/index.js +1 -1
  100. package/dist/server/components/data-table/index.js +1 -1
  101. package/dist/server/components/date-picker/index.js +1 -1
  102. package/dist/server/components/date-range-field/index.js +1 -1
  103. package/dist/server/components/drawer/index.js +1 -1
  104. package/dist/server/components/dropdown/index.js +1 -1
  105. package/dist/server/components/dropdown-menu/index.js +2 -2
  106. package/dist/server/components/focus-trap/index.js +1 -1
  107. package/dist/server/components/form-field/index.js +1 -1
  108. package/dist/server/components/hover-card/index.js +1 -1
  109. package/dist/server/components/inline-confirm/index.js +1 -1
  110. package/dist/server/components/input/index.js +1 -1
  111. package/dist/server/components/invocation-rule-builder/index.js +1 -1
  112. package/dist/server/components/json-editor/index.js +1 -1
  113. package/dist/server/components/json-schema-editor/index.js +1 -1
  114. package/dist/server/components/line-chart/index.js +1 -1
  115. package/dist/server/components/matrix-chart/index.js +1 -1
  116. package/dist/server/components/menu-bar/index.js +2 -2
  117. package/dist/server/components/modal/index.js +1 -1
  118. package/dist/server/components/multi-select/index.js +1 -1
  119. package/dist/server/components/navigation-bar/index.js +2 -2
  120. package/dist/server/components/parameter-field/index.js +1 -1
  121. package/dist/server/components/permission-matrix/index.js +1 -1
  122. package/dist/server/components/policy-lock/index.js +1 -1
  123. package/dist/server/components/popover/index.js +1 -1
  124. package/dist/server/components/radio-group/index.js +1 -1
  125. package/dist/server/components/schedule-builder/index.js +1 -1
  126. package/dist/server/components/schema-form/index.js +1 -1
  127. package/dist/server/components/scroll-area/index.js +1 -1
  128. package/dist/server/components/select/index.js +1 -1
  129. package/dist/server/components/selection-popover/index.js +1 -1
  130. package/dist/server/components/share-card/index.js +1 -1
  131. package/dist/server/components/sidebar/index.js +1 -1
  132. package/dist/server/components/speed-dial/index.js +2 -2
  133. package/dist/server/components/statistic-group/index.js +1 -1
  134. package/dist/server/components/table/index.js +1 -1
  135. package/dist/server/components/textarea/index.js +1 -1
  136. package/dist/server/components/time-field/index.js +1 -1
  137. package/dist/server/components/toast-region/index.js +1 -1
  138. package/dist/server/components/tooltip/index.js +1 -1
  139. package/dist/server/components/transfer-list/index.js +1 -1
  140. package/dist/server/components/virtual-list/index.js +2 -2
  141. package/dist/server/index.js +2 -2
  142. package/dist/server/{index.server-skq0f5sr.js → index.server-0jw25w9w.js} +1 -1
  143. package/dist/server/index.server-0kk20wvp.js +4 -0
  144. package/dist/server/{index.server-fzsqdajc.js → index.server-2awq6q9m.js} +1 -1
  145. package/dist/server/{index.server-e4hmhaeh.js → index.server-3xwvw6w2.js} +3 -3
  146. package/dist/server/{index.server-95h7xy01.js → index.server-428dh2t9.js} +2 -2
  147. package/dist/server/{index.server-jd88r74m.js → index.server-5dq66aja.js} +2 -2
  148. package/dist/server/{index.server-dvwfhf77.js → index.server-5s94r0kk.js} +2 -2
  149. package/dist/server/{index.server-qv6z5ta3.js → index.server-80qgcjnm.js} +1 -1
  150. package/dist/server/{index.server-7k2732ky.js → index.server-81abtrsw.js} +1 -1
  151. package/dist/server/{index.server-csmqnx5w.js → index.server-83q1gv2c.js} +1 -1
  152. package/dist/server/{index.server-qw8k9rjg.js → index.server-8fyav10d.js} +1 -1
  153. package/dist/server/{index.server-4dgjj4k1.js → index.server-8h5caecr.js} +2 -2
  154. package/dist/server/{index.server-emyqytmm.js → index.server-90n8sd9e.js} +1 -1
  155. package/dist/server/{index.server-0xrdyzvh.js → index.server-99penx1m.js} +1 -1
  156. package/dist/server/{index.server-p94j3jah.js → index.server-9g9d15z1.js} +1 -1
  157. package/dist/server/{index.server-xp9hkc81.js → index.server-9kbdx511.js} +1 -1
  158. package/dist/server/index.server-a2yhk45s.js +3 -0
  159. package/dist/server/{index.server-g8d2m2tk.js → index.server-acq55gjs.js} +1 -1
  160. package/dist/server/{index.server-ewze54tv.js → index.server-afjftjmr.js} +1 -1
  161. package/dist/server/{index.server-ejyye4gv.js → index.server-bfed6a8a.js} +1 -1
  162. package/dist/server/{index.server-z5ng08q2.js → index.server-c1746s0z.js} +1 -1
  163. package/dist/server/{index.server-gt1tfc1w.js → index.server-dmeztywe.js} +1 -1
  164. package/dist/server/{index.server-kzsppq0n.js → index.server-dyj3jdx9.js} +1 -1
  165. package/dist/server/index.server-dz92zvx6.js +4 -0
  166. package/dist/server/{index.server-3md8kdcr.js → index.server-e6682k08.js} +1 -1
  167. package/dist/server/{index.server-t1pshh65.js → index.server-ewkv461x.js} +1 -1
  168. package/dist/server/{index.server-zfgwhtmp.js → index.server-fa449wd3.js} +1 -1
  169. package/dist/server/{index.server-1kgwayct.js → index.server-fhfypmgw.js} +1 -1
  170. package/dist/server/{index.server-s4z8hsby.js → index.server-ge4adxs2.js} +1 -1
  171. package/dist/server/{index.server-68xyfsg3.js → index.server-gggkq22y.js} +2 -2
  172. package/dist/server/{index.server-acgwdamx.js → index.server-j52rbk57.js} +1 -1
  173. package/dist/server/{index.server-z0nwftx6.js → index.server-jm89hxfb.js} +1 -1
  174. package/dist/server/{index.server-xa98r8p2.js → index.server-jw0v64se.js} +1 -1
  175. package/dist/server/index.server-m321p69g.js +3 -0
  176. package/dist/server/{index.server-xyervw3d.js → index.server-m7q2tc41.js} +1 -1
  177. package/dist/server/{index.server-tnrxy86j.js → index.server-mak7dmj2.js} +1 -1
  178. package/dist/server/{index.server-n5g5h5k1.js → index.server-mw5r2524.js} +1 -1
  179. package/dist/server/{index.server-caf7s6m7.js → index.server-nwq1cg55.js} +1 -1
  180. package/dist/server/{index.server-3wdvs0wr.js → index.server-p423fy4q.js} +2 -2
  181. package/dist/server/{index.server-ks7fvwxt.js → index.server-prk5syj2.js} +1 -1
  182. package/dist/server/{index.server-6w9fp018.js → index.server-q4hytsq3.js} +1 -1
  183. package/dist/server/{index.server-5w2qw8fm.js → index.server-q597a1ck.js} +1 -1
  184. package/dist/server/{index.server-fz1pkvda.js → index.server-qgne9v2w.js} +1 -1
  185. package/dist/server/{index.server-1f2app32.js → index.server-rvdavf92.js} +1 -1
  186. package/dist/server/index.server-rwq20a22.js +3 -0
  187. package/dist/server/{index.server-0rvmnrw2.js → index.server-s9tjs45r.js} +1 -1
  188. package/dist/server/{index.server-cm2prec7.js → index.server-sqgxyfsw.js} +1 -1
  189. package/dist/server/{index.server-v6777tgn.js → index.server-t761nwvb.js} +1 -1
  190. package/dist/server/index.server-tbds8nwq.js +4 -0
  191. package/dist/server/index.server-tyhta5n3.js +3 -0
  192. package/dist/server/{index.server-yw7rah51.js → index.server-v5dxham4.js} +1 -1
  193. package/dist/server/index.server-va98cpyf.js +3 -0
  194. package/dist/server/index.server-vq1k69xt.js +3 -0
  195. package/dist/server/{index.server-egd355s6.js → index.server-wnf9btp7.js} +2 -2
  196. package/dist/server/{index.server-sjcbaztf.js → index.server-y3zgdtbv.js} +1 -1
  197. package/dist/server/{index.server-4tjtgzf9.js → index.server-y6vtbmyj.js} +1 -1
  198. package/dist/server/{index.server-2p2mjzzb.js → index.server-zff2qp1v.js} +1 -1
  199. package/dist/server/tokens/registry.generated.js +2 -2
  200. package/dist/tokens/registry.generated.js +2 -2
  201. package/package.json +2 -2
  202. package/src/_internal/form-field-frame.svelte +5 -0
  203. package/src/_internal/overlay.ts +14 -1
  204. package/src/components/_internal/create-command-list-state.svelte.ts +4 -0
  205. package/src/components/button/button.css +1 -1
  206. package/src/components/command-menu/command-menu.svelte +63 -7
  207. package/src/components/command-palette/command-palette.css +50 -46
  208. package/src/components/command-palette/command-palette.svelte +68 -78
  209. package/src/components/dropdown/dropdown.svelte +73 -18
  210. package/src/components/dropdown-menu/dropdown-menu.svelte +63 -7
  211. package/src/components/find-bar/find-bar.css +9 -1
  212. package/src/components/input/input.css +95 -6
  213. package/src/components/input/input.svelte +44 -81
  214. package/src/components/menu-bar/menu-bar.svelte +12 -1
  215. package/src/components/multi-select/multi-select.svelte +7 -0
  216. package/src/components/navigation-bar/navigation-bar.svelte +82 -6
  217. package/src/components/selection-popover/selection-popover.svelte +24 -10
  218. package/src/components/share-card/share-card.svelte +24 -44
  219. package/src/components/speed-dial/speed-dial.svelte +23 -5
  220. package/src/components/statistic-group/statistic-group.css +116 -66
  221. package/src/components/statistic-group/statistic-group.examples.json +6 -0
  222. package/src/components/statistic-group/statistic-group.svelte +13 -1
  223. package/src/components/time-field/time-field.css +9 -8
  224. package/src/components/toast-region/toast-region.svelte +9 -0
  225. package/src/components/virtual-list/_internal/adaptive-overscan.ts +248 -0
  226. package/src/components/virtual-list/_internal/edge-proximity.ts +130 -0
  227. package/src/components/virtual-list/_internal/frame-scheduler.ts +136 -0
  228. package/src/components/virtual-list/_internal/geometry.ts +236 -0
  229. package/src/components/virtual-list/_internal/list-semantics.ts +151 -0
  230. package/src/components/virtual-list/_internal/measurement-window.ts +300 -0
  231. package/src/components/virtual-list/_internal/reverse-order.ts +146 -0
  232. package/src/components/virtual-list/_internal/scroll-restoration.ts +209 -0
  233. package/src/components/virtual-list/_internal/sticky-items.ts +111 -0
  234. package/src/components/virtual-list/_internal/virtual-list-measurement-store.svelte.ts +145 -0
  235. package/src/components/virtual-list/index.ts +7 -1
  236. package/src/components/virtual-list/virtual-list.css +153 -0
  237. package/src/components/virtual-list/virtual-list.examples.json +42 -0
  238. package/src/components/virtual-list/virtual-list.schema.json +53 -3
  239. package/src/components/virtual-list/virtual-list.schema.ts +64 -3
  240. package/src/components/virtual-list/virtual-list.svelte +1527 -36
  241. package/src/components/virtual-list/virtual-list.types.ts +181 -4
  242. package/src/index.ts +3 -0
  243. package/src/styles/tokens-base.css +29 -21
  244. package/src/tokens/cinder.resolver.json +8 -0
  245. package/src/tokens/index.json +1 -1
  246. package/src/tokens/registry.generated.json +29 -3
  247. package/src/tokens/registry.generated.ts +31 -3
  248. package/src/tokens/resolved/dark-reduced-motion.json +46 -16
  249. package/src/tokens/resolved/dark.json +46 -16
  250. package/src/tokens/resolved/light-reduced-motion.json +47 -17
  251. package/src/tokens/resolved/light.json +47 -17
  252. package/src/tokens/sets/semantic.tokens.json +120 -30
  253. package/src/tokens/themes/dark.tokens.json +115 -19
  254. package/src/tokens/themes/light.tokens.json +51 -3
  255. package/dist/server/index.server-191cnacw.js +0 -3
  256. package/dist/server/index.server-25dqx151.js +0 -3
  257. package/dist/server/index.server-77jyqvbv.js +0 -4
  258. package/dist/server/index.server-bgjrzr70.js +0 -3
  259. package/dist/server/index.server-khsp90vh.js +0 -3
  260. package/dist/server/index.server-ryk2pgbe.js +0 -4
  261. package/dist/server/index.server-tajr81bm.js +0 -3
  262. package/dist/server/index.server-vjzcrw3d.js +0 -4
  263. package/dist/server/index.server-zg3fx1n1.js +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lostgradient/cinder",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "description": "A Svelte 5 component library and design system focused on accessibility, theming, and per-component tree-shaking.",
5
5
  "keywords": [
6
6
  "svelte",
@@ -6506,7 +6506,7 @@
6506
6506
  ],
6507
6507
  "dependencies": {
6508
6508
  "@floating-ui/dom": "1.7.6",
6509
- "@lostgradient/markdown": "^0.4.0",
6509
+ "@lostgradient/markdown": "^0.5.0",
6510
6510
  "@shikijs/engine-oniguruma": "^3.21.0",
6511
6511
  "@shikijs/types": "^3.21.0",
6512
6512
  "@tanstack/virtual-core": "^3.17.1",
@@ -66,8 +66,13 @@ const context = {
66
66
  </label>
67
67
  {/if}
68
68
 
69
+ <!-- `data-cinder-full-width` mirrors the frame's own marker onto the wrapper:
70
+ ancestors that detect a full-width control by direct child (access-gate.css's
71
+ `:has(> .cinder-form-field > [data-cinder-full-width])`) keep matching when
72
+ the control sits inside this wrapper instead of directly in the frame. -->
69
73
  {#if needsControlWrapper}<div
70
74
  class={classNames('cinder-form-field__control', controlClass)}
75
+ data-cinder-full-width={fullWidth ? '' : undefined}
71
76
  data-leading={controlLeading ? '' : undefined}
72
77
  data-trailing={controlTrailing ? '' : undefined}
73
78
  data-native-date={controlNativeDate ? '' : undefined}
@@ -17,6 +17,8 @@
17
17
 
18
18
  /// <reference lib="dom" />
19
19
 
20
+ import { flushSync } from 'svelte';
21
+
20
22
  /**
21
23
  * Z-index layer constants. Mirror the `--cinder-z-*` CSS custom properties.
22
24
  * Components should prefer the CSS variables in stylesheets; these JS constants
@@ -132,7 +134,18 @@ function onEscapeKeydown(event: KeyboardEvent): void {
132
134
  // the topmost handler's call, so we pass the event through and let it decide
133
135
  // (a nested popup that owns Escape calls event.preventDefault(); a plain
134
136
  // overlay that's fine letting native dialog ESC also fire does not).
135
- handler(event);
137
+ //
138
+ // `handler` is invoked via a plain `window.addEventListener` callback, not
139
+ // one of Svelte's own event-delegated listeners, so state writes inside it
140
+ // (e.g. `open = false`) wouldn't otherwise flush to the DOM — or release
141
+ // this handler's own stack entry via its owning `$effect`'s cleanup — until
142
+ // the next microtask. `flushSync` forces that update (and this handler's
143
+ // release, if it closes synchronously) to land within this same keydown
144
+ // dispatch, so a second Escape immediately after reaches the next handler
145
+ // down the stack rather than the one that just closed.
146
+ flushSync(() => {
147
+ handler(event);
148
+ });
136
149
  }
137
150
 
138
151
  /**
@@ -66,7 +66,11 @@ export class CommandListState {
66
66
  const releaseEscape = pushEscapeHandler((event) => {
67
67
  if (!options.isOpen() || event?.key !== 'Escape')
68
68
  return;
69
+ // Uniform swallow-at-the-top (CIN-428): consume with both
70
+ // preventDefault() and stopPropagation() so a lower escape-stack
71
+ // overlay never reacts to the same keystroke.
69
72
  event.preventDefault();
73
+ event.stopPropagation();
70
74
  options.onDismiss(true);
71
75
  });
72
76
  const handlePointerDown = (event) => {
@@ -469,7 +469,7 @@
469
469
 
470
470
  /* Ring replaces the border while focused rather than stacking on it — the two
471
471
  * together read as one heavier shape than either was designed to be. The
472
- * variants that paint an opaque resting border (secondary, and the icon-only
472
+ * variants that paint a resting border (secondary, and the icon-only
473
473
  * ghost pair) all carry the same (0,2,0) specificity as `:focus-visible`, so
474
474
  * this has to sit AFTER them in source order to win the cascade. Keep it below
475
475
  * the `:active` block for the same reason. */
@@ -7,6 +7,7 @@ import { getCaretRect } from './caret-rect.svelte.ts';
7
7
  import { computeGhostOverlayFontStyle, createInlineCompletionState, } from './command-menu-inline-completion.svelte.ts';
8
8
  import { on } from 'svelte/events';
9
9
  import { createAnchoredOverlay } from '../../_internal/anchored-overlay.svelte.ts';
10
+ import { pushEscapeHandler } from '../../_internal/overlay.ts';
10
11
  import { isRightToLeftElement } from '../../_internal/text-direction.ts';
11
12
  import { classNames } from '../../utilities/class-names.ts';
12
13
  import { setCommandListContext } from '../_internal/command-list-context.ts';
@@ -268,16 +269,72 @@ function dismiss({ latch = false } = {}) {
268
269
  function isModifiedKey(event) {
269
270
  return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
270
271
  }
272
+ // Escape ownership (CIN-427).
273
+ //
274
+ // Two-stage: first Escape dismisses inline ghost text without closing the
275
+ // menu; only a second Escape (ghost already hidden) falls through to
276
+ // dismiss the menu itself. This is the single place that logic lives —
277
+ // both the anchor's own keydown listener below AND the escape-stack
278
+ // registration further down call this same function, so there is exactly
279
+ // one implementation of the two-stage semantics regardless of where focus
280
+ // sits when Escape is pressed.
281
+ function handleEscape(event) {
282
+ if (!open)
283
+ return;
284
+ if (event && (event.isComposing || event.keyCode === 229))
285
+ return;
286
+ if (inlineCompletion.dismissGhostText()) {
287
+ event?.preventDefault();
288
+ event?.stopPropagation();
289
+ return;
290
+ }
291
+ dismiss({ latch: true });
292
+ event?.preventDefault();
293
+ event?.stopPropagation();
294
+ }
295
+ // The stack handler is the top-most Escape consumer for the entire open
296
+ // session, including with focus OUTSIDE the anchor — unlike the old
297
+ // anchor-scoped-only keydown listener below, `pushEscapeHandler` receives
298
+ // every window keydown regardless of focus location. That is a deliberate
299
+ // behavior change: Escape now dismisses the menu even when focus has moved
300
+ // elsewhere on the page while it's open.
301
+ //
302
+ // Depend on `hasAnchor` (a boolean), not `anchor` itself: a host that
303
+ // replaces one non-null anchor with another (e.g. swapping which
304
+ // textarea/input owns the menu) while `open` stays true must NOT tear down
305
+ // and re-push this registration — doing so would move it above any
306
+ // overlay that opened in the meantime, so a later Escape would dismiss
307
+ // this (visually lower) menu first instead of that newer, higher overlay.
308
+ // Only an actual null<->non-null transition should change registration —
309
+ // matching the menu's own render condition, which cares about presence,
310
+ // not identity.
311
+ const hasAnchor = $derived(anchor != null);
312
+ $effect(() => {
313
+ // Matches the menu's own render condition (`mounted && open && anchor`,
314
+ // line ~487): when a host clears or unmounts `anchor` while `open` stays
315
+ // true, nothing renders, so this stack entry must not either — otherwise
316
+ // it silently swallows Escape for a menu that's no longer visible,
317
+ // blocking whatever overlay is actually on screen beneath it.
318
+ if (!open || !hasAnchor)
319
+ return;
320
+ const releaseEscape = pushEscapeHandler(handleEscape);
321
+ return releaseEscape;
322
+ });
271
323
  function handleKeydown(event) {
272
324
  if (!open)
273
325
  return;
274
326
  const isComposingEvent = event.isComposing || event.keyCode === 229;
275
- // Escape's first stage: dismiss the ghost text without closing the
276
- // menu. Only a second Escape (ghost already hidden) falls through to
277
- // the existing listbox Escape-dismiss latch below.
278
- if (!isComposingEvent && event.key === 'Escape' && inlineCompletion.dismissGhostText()) {
279
- event.preventDefault();
280
- event.stopPropagation();
327
+ // Escape: fallback path. In a real browser the capture-phase
328
+ // escape-stack listener (installed by the $effect above) runs first,
329
+ // already ran the two-stage `handleEscape` logic, and called
330
+ // preventDefault()/stopPropagation() — so `event.defaultPrevented` is
331
+ // true here and this bails without re-running the logic. This branch
332
+ // only does real work when the stack listener never ran (SSR/no-window
333
+ // environments where `pushEscapeHandler` installed nothing).
334
+ if (!isComposingEvent && event.key === 'Escape') {
335
+ if (event.defaultPrevented)
336
+ return;
337
+ handleEscape(event);
281
338
  return;
282
339
  }
283
340
  // ArrowRight at the field end and unmodified Tab accept the ghost
@@ -303,7 +360,6 @@ function handleKeydown(event) {
303
360
  commandList.handleKeydown({
304
361
  event,
305
362
  onEnter: activateItemById,
306
- onEscape: () => dismiss({ latch: true }),
307
363
  ignoreModifiedNavigation: true,
308
364
  });
309
365
  }
@@ -15,10 +15,17 @@
15
15
  border: none;
16
16
  background: transparent;
17
17
  color: var(--cinder-text-default);
18
- /* The dialog's default overflow: auto produces a scroll container whose
19
- box ignores the inner panel's border-radius, so child backgrounds bleed
20
- past the rounded corners. Clip at the dialog level too. */
21
- overflow: hidden;
18
+ /* `overflow: visible`, not `hidden` — the panel (below) is the clipping
19
+ boundary, matching modal.css's `.cinder-modal`/`.cinder-modal__panel`
20
+ split (see OVERLAY-POLICY.md's "Portal root" section: "its content panel
21
+ remains the clipping boundary for ordinary modal content"). The panel
22
+ already clips its own children via its own `overflow: hidden` and
23
+ `border-radius`, so nothing bleeds past the rounded corners. Keeping
24
+ `overflow: hidden` here instead would clip the panel's own
25
+ enter/exit `translate` motion at the dialog's box — round 1 review
26
+ caught this exact regression once the enter/exit motion moved from the
27
+ dialog itself (this element) onto the panel. */
28
+ overflow: visible;
22
29
  border-radius: var(--cinder-radius-lg);
23
30
  /* Anchor near the top of the viewport — top-layer elements use fixed
24
31
  positioning relative to the viewport. z-index is intentionally absent:
@@ -56,6 +63,17 @@
56
63
  box-shadow:
57
64
  0 4px 6px -1px color-mix(in oklch, var(--cinder-text-default) 8%, transparent),
58
65
  0 10px 15px -3px color-mix(in oklch, var(--cinder-text-default) 12%, transparent);
66
+ /* Symmetric enter/exit motion — see "Reduced motion — panel enter/exit
67
+ transition" below for the exit half and the OVERLAY-POLICY.md citation.
68
+ No resting `translate` here (matching modal.css's panel): a non-`none`
69
+ transform value, even a no-op `0 0`, establishes a CSS containing
70
+ block, which would break `position: fixed` for any descendant portaled
71
+ surface for the whole time the palette is open. `none` transitions
72
+ to/from a real value fine. */
73
+ opacity: 1;
74
+ transition:
75
+ opacity var(--cinder-duration-normal) var(--cinder-ease-standard),
76
+ translate var(--cinder-duration-normal) var(--cinder-ease-spring);
59
77
  }
60
78
 
61
79
  /* ----------------------------------------
@@ -186,50 +204,36 @@
186
204
  * duplicating rules. The import is placed outside the @layer block above. */
187
205
 
188
206
  /* ----------------------------------------
189
- * Reduced motion — panel enter animation
190
- * ---------------------------------------- */
191
-
192
- @keyframes cinder-command-palette-enter {
193
- from {
207
+ * Panel enter/exit transition
208
+ * ----------------------------------------
209
+ * OVERLAY-POLICY.md, "Transition lifecycle" > "Awaiting completion vs.
210
+ * destroy-on-close": every overlay that animates in must animate out
211
+ * symmetrically and await transition completion before unmount. This
212
+ * replaces the former `animation`/`@keyframes` enter (and the
213
+ * `dialog.close()`-immediately exit asymmetry that named Command Palette in
214
+ * "Known deviations") with `transition`-driven styles the shared
215
+ * `waitForTransitionCompletion` helper can actually detect —
216
+ * `transitionend` never fires for a CSS `animation`. Transition properties
217
+ * are named explicitly (never `all`) per that section's "Only after that
218
+ * callback..." clause: with `all`, the helper cannot enumerate tracked
219
+ * properties and would resolve on whichever property's `transitionend`
220
+ * happens to fire first, even if others are still transitioning. Reduced
221
+ * motion needs no separate override here — `--cinder-duration-*` tokens
222
+ * already collapse to `0ms` under both the media query and the
223
+ * `data-cinder-reduced-motion`/`data-reduced-motion` attribute overrides
224
+ * (tokens-base.css), which is exactly what
225
+ * `waitForTransitionCompletion` reads to resolve immediately. */
226
+
227
+ .cinder-command-palette__panel[data-cinder-closing] {
228
+ opacity: 0;
229
+ translate: 0 -0.75rem;
230
+ pointer-events: none;
231
+ }
232
+
233
+ @starting-style {
234
+ .cinder-command-palette__panel {
194
235
  opacity: 0;
195
236
  translate: 0 -0.75rem;
196
237
  }
197
- to {
198
- opacity: 1;
199
- translate: 0 0;
200
- }
201
- }
202
-
203
- @media (prefers-reduced-motion: no-preference) {
204
- :root:not([data-cinder-reduced-motion='true']) .cinder-command-palette {
205
- animation: cinder-command-palette-enter var(--cinder-duration-normal)
206
- var(--cinder-ease-spring) forwards;
207
- }
208
- }
209
-
210
- :root:is([data-cinder-reduced-motion='false'], [data-reduced-motion='off'])
211
- .cinder-command-palette {
212
- animation: cinder-command-palette-enter var(--cinder-duration-normal) var(--cinder-ease-spring)
213
- forwards;
214
- }
215
-
216
- @keyframes cinder-command-palette-fade {
217
- from {
218
- opacity: 0;
219
- }
220
- to {
221
- opacity: 1;
222
- }
223
- }
224
-
225
- @media (prefers-reduced-motion: reduce) {
226
- :root:not([data-cinder-reduced-motion='false']):not([data-reduced-motion='off'])
227
- .cinder-command-palette {
228
- animation: cinder-command-palette-fade var(--cinder-duration-fast) linear forwards;
229
- }
230
- }
231
-
232
- :root[data-cinder-reduced-motion='true'] .cinder-command-palette {
233
- animation: cinder-command-palette-fade var(--cinder-duration-fast) linear forwards !important;
234
238
  }
235
239
  }
@@ -3,12 +3,12 @@ export {};
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
- import { onDestroy } from 'svelte';
7
- import { captureFocus, pushEscapeHandler } from '../../_internal/overlay.ts';
6
+ import { onDestroy, tick } from 'svelte';
8
7
  import { classNames } from '../../utilities/class-names.ts';
9
- import { restoreFocusTo } from '../../utilities/focus.ts';
8
+ import { useReducedMotion } from '../../utilities/use-reduced-motion.svelte.ts';
10
9
  import { setCommandListContext } from '../_internal/command-list-context.ts';
11
10
  import { createCommandListState } from '../_internal/create-command-list-state.svelte.ts';
11
+ import { createSlidingDialogState } from '../_internal/create-sliding-dialog-state.svelte.ts';
12
12
  let { open = $bindable(false), placeholder = 'Search…', label = 'Command palette', query = $bindable(''), onClose, triggerRef = null, items, empty, footer, class: className, } = $props();
13
13
  // ── IDs ──────────────────────────────────────────────────────────────────
14
14
  const baseId = $props.id();
@@ -16,95 +16,78 @@ const listboxId = `${baseId}-listbox`;
16
16
  const inputId = `${baseId}-input`;
17
17
  // ── DOM refs ─────────────────────────────────────────────────────────────
18
18
  let dialogElement = $state();
19
+ let panelElement = $state();
19
20
  let inputElement = $state();
20
- // ── Hydration guard ───────────────────────────────────────────────────────
21
- // `mounted` is false during SSR. The dialog is rendered only when mounted
22
- // (client) or when already open (SSR open=true). Matching modal.svelte.
23
- let mounted = $state(false);
24
- $effect(() => {
25
- mounted = true;
26
- });
27
- // ── Focus capture ─────────────────────────────────────────────────────────
28
- let capturedFocus = null;
21
+ const reducedMotion = useReducedMotion();
29
22
  const commandList = createCommandListState(listboxId);
30
23
  $effect(() => {
31
24
  // Track query so this re-runs on every query change.
32
25
  void query;
33
26
  commandList.refreshRegistrationsReady();
34
27
  });
35
- // ── Escape stack ──────────────────────────────────────────────────────────
36
- let releaseEscape = null;
37
- // ── Focus restoration ─────────────────────────────────────────────────────
38
- function returnFocus() {
39
- // Iterate candidates so a disconnected `triggerRef` falls through to
40
- // capturedFocus. Matches the modal/drawer/popover pattern; without this
41
- // a removed trigger would silently drop focus on the floor.
42
- const candidates = [triggerRef, capturedFocus];
43
- for (const candidate of candidates) {
44
- if (restoreFocusTo(candidate))
45
- break;
46
- }
47
- capturedFocus = null;
48
- }
49
- // ── Close ─────────────────────────────────────────────────────────────────
50
- // Single authoritative close path. All close triggers (Escape stack,
51
- // backdrop click, `close` event, programmatic open=false) route through here.
52
- // The `isClosing` flag prevents double-invocation: setting `open = false`
53
- // schedules the lifecycle $effect, which calls closePalette() again from the
54
- // else branch. The flag ensures that second call is a no-op.
55
- let isClosing = false;
56
- function closePalette() {
57
- if (isClosing)
58
- return;
59
- if (!open && !dialogElement?.open)
60
- return;
61
- isClosing = true;
62
- open = false;
63
- releaseEscape?.();
64
- releaseEscape = null;
65
- if (dialogElement?.open)
66
- dialogElement.close();
67
- returnFocus();
68
- onClose?.();
69
- isClosing = false;
70
- }
71
- // ── Open/close lifecycle ──────────────────────────────────────────────────
72
- $effect(() => {
73
- if (!dialogElement)
74
- return;
75
- if (open && !dialogElement.open) {
28
+ // ── Sliding-dialog lifecycle ────────────────────────────────────────────
29
+ // Adopts SlidingDialogState (the same mechanism Modal and Drawer use)
30
+ // rather than hand-rolling an exit lifecycle. Per OVERLAY-POLICY.md,
31
+ // "Transition lifecycle" > "The contract": the component renders
32
+ // data-cinder-closing on its animated panel for the full duration of the
33
+ // exit transition, and the shared waitForTransitionCompletion helper (used
34
+ // internally by SlidingDialogState) — not a fixed timeout — decides when
35
+ // the panel actually unmounts and the native dialog closes. This also
36
+ // gives the palette the counted lockBodyScroll() acquisition/release and
37
+ // the hydrated-gated SSR pattern it previously lacked (both tracked as
38
+ // OVERLAY-POLICY.md deviations under CIN-426, alongside this lifecycle
39
+ // gap itself).
40
+ const dialogState = createSlidingDialogState({
41
+ getOpen: () => open,
42
+ setOpen: (nextOpen) => {
43
+ open = nextOpen;
44
+ },
45
+ getDialogElement: () => dialogElement,
46
+ getPanelElement: () => panelElement,
47
+ getReducedMotion: () => reducedMotion.current,
48
+ getTriggerRef: () => triggerRef,
49
+ onOpen: () => {
76
50
  query = '';
77
51
  commandList.resetActiveItem();
78
- capturedFocus = captureFocus();
79
- dialogElement.showModal();
80
- inputElement?.focus();
81
- releaseEscape = pushEscapeHandler(closePalette);
82
- }
83
- else if (!open && dialogElement.open) {
84
- // Programmatic close: open was set to false externally.
85
- // closePalette handles everything; call it to ensure focus is restored.
86
- closePalette();
87
- }
52
+ // Deferred: the panel subtree (and the inputElement binding) has not
53
+ // flushed yet in the same effect that first sets renderPanel — mirrors
54
+ // focusDialogBodyUnlessAutofocused's own tick() deferral for
55
+ // Modal/Drawer in create-sliding-dialog-state.svelte.ts.
56
+ void tick().then(() => {
57
+ if (!open)
58
+ return;
59
+ inputElement?.focus();
60
+ });
61
+ },
62
+ onClosed: () => onClose?.(),
63
+ });
64
+ $effect(() => {
65
+ dialogState.markHydrated();
66
+ });
67
+ $effect(() => {
68
+ dialogState.syncOpenState();
88
69
  });
89
- // Release escape handler on component destroy to prevent leaks.
90
70
  onDestroy(() => {
91
- releaseEscape?.();
92
- releaseEscape = null;
71
+ dialogState.destroy();
93
72
  });
94
73
  // ── Dialog event handlers ─────────────────────────────────────────────────
95
- // The native <dialog> fires `cancel` before `close` when Escape is pressed.
96
- // Prevent the native cancel so our escape-stack handler is the sole close path.
74
+ // Matches modal.svelte's oncancel wiring: the native <dialog> fires
75
+ // `cancel` before `close` when Escape is pressed. Prevent the browser's
76
+ // own dialog-closing behavior so the sole close path is
77
+ // dialogState.requestClose() → the exit transition → the real `close`
78
+ // event → dialogState.handleClose().
97
79
  function handleCancel(event) {
98
- event.preventDefault();
80
+ dialogState.handleNativeCancel(event);
99
81
  }
100
- // The `close` event fires when the dialog actually closes (any path).
82
+ // The `close` event fires when the native dialog actually closes (any
83
+ // path) — SlidingDialogState.handleClose() is the single place that
84
+ // releases the scroll lock and escape-stack registration, restores focus,
85
+ // and reports completion via onClosed.
101
86
  function handleClose() {
102
- closePalette();
87
+ dialogState.handleClose();
103
88
  }
104
89
  function handleBackdropClick(event) {
105
- if (event.target === dialogElement) {
106
- closePalette();
107
- }
90
+ dialogState.handleBackdropClick(event);
108
91
  }
109
92
  // ── Keyboard routing ──────────────────────────────────────────────────────
110
93
  function handleKeydown(event) {
@@ -123,10 +106,12 @@ $effect(() => {
123
106
  });
124
107
  // ── Context ───────────────────────────────────────────────────────────────
125
108
  setCommandListContext(commandList.createContext());
126
- const showEmpty = $derived(mounted && commandList.registrationsReady && commandList.registrations.length === 0);
109
+ const showEmpty = $derived(dialogState.hydrated &&
110
+ commandList.registrationsReady &&
111
+ commandList.registrations.length === 0);
127
112
  </script>
128
113
 
129
- {#if mounted || open}
114
+ {#if dialogState.hydrated}
130
115
  <dialog
131
116
  bind:this={dialogElement}
132
117
  class="cinder-command-palette"
@@ -136,8 +121,13 @@ const showEmpty = $derived(mounted && commandList.registrationsReady && commandL
136
121
  onclose={handleClose}
137
122
  onclick={handleBackdropClick}
138
123
  >
139
- {#if open}
140
- <div class={classNames('cinder-command-palette__panel', className)}>
124
+ {#if dialogState.renderPanel}
125
+ <div
126
+ bind:this={panelElement}
127
+ class={classNames('cinder-command-palette__panel', className)}
128
+ data-cinder-closing={dialogState.isClosing ? '' : undefined}
129
+ inert={dialogState.isClosing}
130
+ >
141
131
  <div class="cinder-command-palette__search">
142
132
  <svg
143
133
  class="cinder-command-palette__search-icon"
@@ -5,6 +5,7 @@ export {};
5
5
  <script lang="ts">
6
6
  import { onDestroy } from 'svelte';
7
7
  import { createAnchoredOverlayExitState } from '../../_internal/anchored-overlay-exit.svelte.ts';
8
+ import { pushEscapeHandler } from '../../_internal/overlay.ts';
8
9
  import { createClickOutside } from '../../utilities/attachments.ts';
9
10
  import { classNames } from '../../utilities/class-names.ts';
10
11
  import { useReducedMotion } from '../../utilities/use-reduced-motion.svelte.ts';
@@ -103,24 +104,79 @@ $effect(() => {
103
104
  CSS.supports('position-anchor: --x') &&
104
105
  CSS.supports('top: anchor(bottom)');
105
106
  });
106
- function handleKeydown(event) {
107
- // The inner DropdownMenu's keydown handler closes the menu and calls
108
- // preventDefault. When defaultPrevented is true, the menu already
109
- // handled this keystroke — skip to avoid a second close+focus pass.
110
- // Svelte 5 delegates onkeydown to the document, so the child handler
111
- // runs first when the event path traverses the menu element.
112
- if (event.defaultPrevented)
113
- return;
114
- if (event.key === 'Escape' && open) {
115
- open = false;
116
- }
117
- else if (event.key === 'Escape' && compoundOpen) {
118
- // Compound fallback path: focus was outside the menu (e.g. on the
119
- // trigger), so the menu's onkeydown never fired. Close from here.
120
- closeCompoundMenu();
121
- focusCompoundTrigger();
122
- }
107
+ // Escape ownership (CIN-428).
108
+ //
109
+ // Compound / modern branch (`compoundOpen`): covered transitively — the
110
+ // inner DropdownMenu registers its own escape-stack handler unconditionally
111
+ // on `context.isOpen`, which here reads `compoundOpen`, so it fires
112
+ // regardless of where focus sits (including on the trigger). No fallback
113
+ // handling is needed here anymore.
114
+ //
115
+ // Legacy `usesLegacySnippetApi` branch has two sub-branches sharing the
116
+ // `open` prop, each registering directly below: the non-popover
117
+ // `exitState.renderPanel` fallback gets a straightforward registration
118
+ // that dismisses; the native `supportsPopover` branch registers WITHOUT
119
+ // calling `preventDefault()` so the browser's own `popover="auto"`
120
+ // light-dismiss keeps working, and its `ontoggle` handler keeps `open` in
121
+ // sync once the browser actually closes it.
122
+ // Same element the aria-expanded effect above resolves: the legacy
123
+ // snippet API has no bound trigger reference (unlike `compoundTriggerElement`),
124
+ // so the first focusable descendant of the consumer-supplied `trigger`
125
+ // snippet's wrapper is the closest thing to one.
126
+ function resolveLegacyTriggerElement() {
127
+ return (triggerWrapper?.querySelector('button, a, [tabindex]:not([tabindex="-1"]), input, select') ?? null);
128
+ }
129
+ function dismissLegacyFallbackMenu(event) {
130
+ event?.preventDefault();
131
+ event?.stopPropagation();
132
+ open = false;
133
+ // Matches the compound fallback's `dismissMenu()` (dropdown-menu.svelte):
134
+ // this branch fully owns the close (no native light-dismiss to defer
135
+ // to), so restore focus to the trigger unconditionally, the same as
136
+ // dropdown.a11y.md's Escape-returns-focus-to-trigger contract requires —
137
+ // otherwise, when focus had tabbed outside the open menu before Escape,
138
+ // it's left on whatever was outside instead.
139
+ resolveLegacyTriggerElement()?.focus();
123
140
  }
141
+ $effect(() => {
142
+ if (!usesLegacySnippetApi || supportsPopover || !open)
143
+ return;
144
+ const releaseEscape = pushEscapeHandler(dismissLegacyFallbackMenu);
145
+ return releaseEscape;
146
+ });
147
+ // NOTE: `supportsPopover` is almost certainly `false` under happy-dom (no
148
+ // `showPopover`/CSS Anchor Positioning support in the test DOM — see the
149
+ // NOTE atop dropdown.test.ts), so this sub-branch cannot be meaningfully
150
+ // unit-tested in this repo's suite today. Registering here still matters
151
+ // in a real browser: without an entry on the stack while this popover is
152
+ // open, a LOWER escape-stack overlay would incorrectly react to the same
153
+ // Escape keystroke (our LIFO stack only ever invokes the top-most
154
+ // handler). The callback never calls `preventDefault()` — the browser's
155
+ // native close-request path for the top-layer popover is left completely
156
+ // alone — but it DOES call `stopPropagation()`: the two are independent
157
+ // (propagation only controls whether the event keeps reaching other
158
+ // listeners in its path; only `preventDefault()` cancels the browser's own
159
+ // default action), so this keeps a focused descendant's own keydown
160
+ // listener, or a page-level Escape handler, from also reacting to the same
161
+ // keystroke while this top-most overlay is supposed to own it.
162
+ $effect(() => {
163
+ if (!usesLegacySnippetApi || !supportsPopover || !open)
164
+ return;
165
+ const releaseEscape = pushEscapeHandler((event) => {
166
+ event?.stopPropagation();
167
+ // Native focus restoration only returns focus to the invoker if focus
168
+ // was still *inside* the popover at the moment it closes; if focus had
169
+ // already moved outside before Escape, native restoration doesn't
170
+ // apply, leaving focus on the unrelated element instead of the
171
+ // trigger — contrary to dropdown.a11y.md:14's Escape contract. Restore
172
+ // it ourselves in that case only, the same conditional restoration the
173
+ // compound branch's (dropdown-menu.svelte) native-popover handler uses.
174
+ if (menuElement && !menuElement.contains(document.activeElement)) {
175
+ resolveLegacyTriggerElement()?.focus();
176
+ }
177
+ });
178
+ return releaseEscape;
179
+ });
124
180
  const dismissOnOutsideClick = $derived(createClickOutside({
125
181
  handler: () => {
126
182
  open = false;
@@ -180,7 +236,6 @@ onDestroy(() => {
180
236
  {id}
181
237
  class={classNames('cinder-dropdown', customClassName)}
182
238
  data-cinder-placement={placement}
183
- onkeydown={handleKeydown}
184
239
  {@attach dismissOnOutsideClick}
185
240
  {...rest}
186
241
  >