@ctrl-ui/react 0.8.2 → 0.8.5

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 (417) hide show
  1. package/README.md +32 -23
  2. package/dist/action-bar.d.ts +11 -12
  3. package/dist/activity.d.ts +24 -25
  4. package/dist/audio-recorder.d.ts +16 -16
  5. package/dist/audio-visualizer.d.ts +3 -4
  6. package/dist/audio-visualizer.js +1 -1
  7. package/dist/blocks/chat.d.ts +3 -4
  8. package/dist/blocks/chat.js +6 -3
  9. package/dist/blocks/coding-agent.d.ts +11 -12
  10. package/dist/blocks/coding-agent.js +10 -9
  11. package/dist/blocks/file-explorer-data.d.ts +11 -12
  12. package/dist/blocks/file-explorer.d.ts +3 -3
  13. package/dist/blocks/settings-data.d.ts +8 -9
  14. package/dist/blocks/settings.d.ts +4 -4
  15. package/dist/blocks/theme-toggle.d.ts +11 -12
  16. package/dist/blocks/theme-toggle.js +14 -4
  17. package/dist/chat-composer-attachment.d.ts +20 -21
  18. package/dist/chat-composer-attachment.js +24 -20
  19. package/dist/chat-composer-editor/extensions/mention.d.ts +5 -6
  20. package/dist/chat-composer-editor/extensions/mention.js +4 -0
  21. package/dist/chat-composer-editor/ghost.d.ts +3 -4
  22. package/dist/chat-composer-editor/schema.d.ts +2 -3
  23. package/dist/chat-composer-editor/serialize.d.ts +3 -4
  24. package/dist/chat-composer-editor/types.d.ts +5 -6
  25. package/dist/chat-composer-editor.d.ts +2 -3
  26. package/dist/chat-composer-editor.js +18 -4
  27. package/dist/chat-composer.d.ts +17 -18
  28. package/dist/chat-composer.js +14 -8
  29. package/dist/chat-layout.d.ts +17 -21
  30. package/dist/chat-layout.js +72 -86
  31. package/dist/chat-message.d.ts +19 -15
  32. package/dist/chat-message.js +19 -2
  33. package/dist/context-model.d.ts +7 -8
  34. package/dist/context.d.ts +21 -22
  35. package/dist/context.js +0 -2
  36. package/dist/control-props.d.ts +10 -11
  37. package/dist/control-variants.d.ts +6 -7
  38. package/dist/dynamic-notification-glass.d.ts +3 -4
  39. package/dist/dynamic-notification-liquid.d.ts +3 -4
  40. package/dist/dynamic-notification-siri-wave.d.ts +2 -3
  41. package/dist/dynamic-notification.d.ts +28 -29
  42. package/dist/email/email-brand.d.ts +60 -0
  43. package/dist/email/email-brand.js +101 -0
  44. package/dist/email/email-code.d.ts +18 -0
  45. package/dist/email/email-code.js +172 -0
  46. package/dist/email/email-footer.d.ts +63 -0
  47. package/dist/email/email-footer.js +98 -0
  48. package/dist/email/email.d.ts +62 -14
  49. package/dist/email/email.js +155 -24
  50. package/dist/email/length.d.ts +2 -3
  51. package/dist/email/templates.d.ts +56 -12
  52. package/dist/email/templates.js +314 -116
  53. package/dist/email/theme.d.ts +15 -8
  54. package/dist/email/theme.js +30 -8
  55. package/dist/environment-variables.d.ts +35 -36
  56. package/dist/extensions/create-track-highlight.d.ts +3 -4
  57. package/dist/extensions/supports-anchor-transitions.d.ts +2 -3
  58. package/dist/extensions/track-highlight.d.ts +3 -4
  59. package/dist/hooks/use-audio-recorder.d.ts +14 -15
  60. package/dist/hooks/use-chat-composer.d.ts +5 -6
  61. package/dist/hooks/use-chat-message.d.ts +8 -8
  62. package/dist/hooks/use-chat-message.js +1 -0
  63. package/dist/hooks/use-chat-thread-scroll.d.ts +8 -0
  64. package/dist/hooks/use-chat-thread-scroll.js +66 -0
  65. package/dist/hooks/use-color-area.d.ts +5 -6
  66. package/dist/hooks/use-copy-to-clipboard.d.ts +7 -8
  67. package/dist/hooks/use-dropzone.d.ts +11 -12
  68. package/dist/hooks/use-dynamic-notification.d.ts +6 -7
  69. package/dist/hooks/use-environment-variables.d.ts +9 -10
  70. package/dist/hooks/use-keyboard-navigation.d.ts +3 -0
  71. package/dist/hooks/use-keyboard-navigation.js +22 -0
  72. package/dist/hooks/use-mobile.d.ts +2 -3
  73. package/dist/hooks/use-textarea-trigger-menu.d.ts +2 -3
  74. package/dist/hooks/use-trigger-menu.d.ts +7 -8
  75. package/dist/hooks/use-user-ask.d.ts +11 -10
  76. package/dist/hooks/use-user-ask.js +56 -17
  77. package/dist/inline-attachment.d.ts +16 -17
  78. package/dist/inline-attachment.js +1 -1
  79. package/dist/inline-citation.d.ts +22 -23
  80. package/dist/knob-contracts/accordion-knobs.d.ts +3 -4
  81. package/dist/knob-contracts/accordion-knobs.js +1 -0
  82. package/dist/knob-contracts/action-bar-knobs.d.ts +3 -4
  83. package/dist/knob-contracts/action-bar-knobs.js +1 -1
  84. package/dist/knob-contracts/activity-knobs.d.ts +3 -4
  85. package/dist/knob-contracts/activity-knobs.js +2 -1
  86. package/dist/knob-contracts/alert-knobs.d.ts +3 -4
  87. package/dist/knob-contracts/alert-knobs.js +12 -1
  88. package/dist/knob-contracts/audio-recorder-knobs.d.ts +3 -4
  89. package/dist/knob-contracts/audio-visualizer-knobs.d.ts +3 -4
  90. package/dist/knob-contracts/audio-visualizer-knobs.js +1 -0
  91. package/dist/knob-contracts/avatar-knobs.d.ts +3 -4
  92. package/dist/knob-contracts/avatar-knobs.js +2 -1
  93. package/dist/knob-contracts/badge-knobs.d.ts +3 -4
  94. package/dist/knob-contracts/button-group-knobs.d.ts +3 -4
  95. package/dist/knob-contracts/button-knobs.d.ts +3 -4
  96. package/dist/knob-contracts/button-knobs.js +1 -0
  97. package/dist/knob-contracts/calendar-knobs.d.ts +3 -4
  98. package/dist/knob-contracts/card-knobs.d.ts +3 -4
  99. package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +3 -4
  100. package/dist/knob-contracts/chat-composer-attachment-knobs.js +5 -1
  101. package/dist/knob-contracts/chat-composer-knobs.d.ts +3 -4
  102. package/dist/knob-contracts/chat-composer-knobs.js +2 -0
  103. package/dist/knob-contracts/chat-layout-knobs.d.ts +3 -4
  104. package/dist/knob-contracts/chat-layout-knobs.js +2 -2
  105. package/dist/knob-contracts/chat-message-knobs.d.ts +3 -4
  106. package/dist/knob-contracts/chat-message-knobs.js +3 -1
  107. package/dist/knob-contracts/choice-knobs.d.ts +3 -4
  108. package/dist/knob-contracts/choice-knobs.js +2 -1
  109. package/dist/knob-contracts/code-diff-knobs.d.ts +3 -4
  110. package/dist/knob-contracts/code-diff-knobs.js +1 -0
  111. package/dist/knob-contracts/code-knobs.d.ts +3 -4
  112. package/dist/knob-contracts/code-knobs.js +3 -1
  113. package/dist/knob-contracts/collapsible-knobs.d.ts +3 -4
  114. package/dist/knob-contracts/color-picker-knobs.d.ts +3 -4
  115. package/dist/knob-contracts/context-knobs.d.ts +3 -4
  116. package/dist/knob-contracts/context-knobs.js +3 -0
  117. package/dist/knob-contracts/dockable-panel-knobs.d.ts +3 -4
  118. package/dist/knob-contracts/dockable-panel-knobs.js +1 -0
  119. package/dist/knob-contracts/dropzone-knobs.d.ts +3 -4
  120. package/dist/knob-contracts/dropzone-knobs.js +1 -0
  121. package/dist/knob-contracts/dynamic-notification-knobs.d.ts +3 -4
  122. package/dist/knob-contracts/empty-knobs.d.ts +3 -4
  123. package/dist/knob-contracts/empty-knobs.js +14 -1
  124. package/dist/knob-contracts/environment-variables-knobs.d.ts +3 -4
  125. package/dist/knob-contracts/environment-variables-knobs.js +2 -1
  126. package/dist/knob-contracts/field-knobs.d.ts +3 -4
  127. package/dist/knob-contracts/gradient-editor-knobs.d.ts +3 -4
  128. package/dist/knob-contracts/gradient-editor-knobs.js +3 -1
  129. package/dist/knob-contracts/infinite-canvas-knobs.d.ts +3 -4
  130. package/dist/knob-contracts/inline-attachment-knobs.d.ts +3 -4
  131. package/dist/knob-contracts/inline-attachment-knobs.js +6 -1
  132. package/dist/knob-contracts/inline-citation-knobs.d.ts +3 -4
  133. package/dist/knob-contracts/inline-citation-knobs.js +4 -1
  134. package/dist/knob-contracts/item-knobs.d.ts +3 -4
  135. package/dist/knob-contracts/kbd-knobs.d.ts +3 -4
  136. package/dist/knob-contracts/markdown-block-knobs.d.ts +3 -4
  137. package/dist/knob-contracts/markdown-block-knobs.js +2 -0
  138. package/dist/knob-contracts/markdown-knobs.d.ts +3 -4
  139. package/dist/knob-contracts/markdown-knobs.js +1 -0
  140. package/dist/knob-contracts/morphing-panel-knobs.d.ts +3 -4
  141. package/dist/knob-contracts/page-layout-knobs.d.ts +4 -0
  142. package/dist/knob-contracts/page-layout-knobs.js +15 -0
  143. package/dist/knob-contracts/pagination-knobs.d.ts +3 -4
  144. package/dist/knob-contracts/phone-input-knobs.d.ts +3 -4
  145. package/dist/knob-contracts/phone-input-knobs.js +1 -0
  146. package/dist/knob-contracts/popup-knobs.d.ts +3 -4
  147. package/dist/knob-contracts/progressive-blur-knobs.d.ts +3 -4
  148. package/dist/knob-contracts/progressive-blur-knobs.js +1 -0
  149. package/dist/knob-contracts/range-knobs.d.ts +3 -4
  150. package/dist/knob-contracts/resizable-knobs.d.ts +3 -4
  151. package/dist/knob-contracts/resizable-knobs.js +1 -0
  152. package/dist/knob-contracts/rich-tooltip-knobs.d.ts +3 -4
  153. package/dist/knob-contracts/scroll-area-knobs.d.ts +3 -4
  154. package/dist/knob-contracts/separator-knobs.d.ts +3 -4
  155. package/dist/knob-contracts/sidebar-knobs.d.ts +3 -4
  156. package/dist/knob-contracts/sidebar-knobs.js +1 -0
  157. package/dist/knob-contracts/skeleton-knobs.d.ts +3 -4
  158. package/dist/knob-contracts/skeleton-knobs.js +9 -1
  159. package/dist/knob-contracts/source-badge-knobs.d.ts +3 -4
  160. package/dist/knob-contracts/spinner-knobs.d.ts +3 -4
  161. package/dist/knob-contracts/stepper-knobs.d.ts +3 -4
  162. package/dist/knob-contracts/stepper-knobs.js +1 -0
  163. package/dist/knob-contracts/switch-knobs.d.ts +3 -4
  164. package/dist/knob-contracts/switch-knobs.js +7 -1
  165. package/dist/knob-contracts/table-knobs.d.ts +3 -4
  166. package/dist/knob-contracts/table-of-contents-knobs.d.ts +3 -4
  167. package/dist/knob-contracts/table-of-contents-knobs.js +25 -0
  168. package/dist/knob-contracts/tabs-knobs.d.ts +3 -4
  169. package/dist/knob-contracts/tabs-knobs.js +2 -1
  170. package/dist/knob-contracts/task-list-knobs.d.ts +3 -4
  171. package/dist/knob-contracts/task-list-knobs.js +5 -0
  172. package/dist/knob-contracts/thread-rail-knobs.d.ts +3 -4
  173. package/dist/knob-contracts/timeline-knobs.d.ts +3 -4
  174. package/dist/knob-contracts/toolbar-knobs.d.ts +3 -4
  175. package/dist/knob-contracts/toolbar-knobs.js +1 -0
  176. package/dist/knob-contracts/track-highlight-knobs.d.ts +3 -4
  177. package/dist/knob-contracts/transcript-divider-knobs.d.ts +3 -4
  178. package/dist/knob-contracts/tree-knobs.d.ts +3 -4
  179. package/dist/knob-contracts/user-ask-knobs.d.ts +3 -4
  180. package/dist/knob-contracts/user-ask-knobs.js +5 -0
  181. package/dist/lib/cn.d.ts +2 -3
  182. package/dist/lib/code-tokens.d.ts +12 -13
  183. package/dist/lib/color.d.ts +26 -27
  184. package/dist/lib/contrast.d.ts +12 -13
  185. package/dist/lib/diff.d.ts +14 -15
  186. package/dist/lib/dropzone-validation.d.ts +25 -26
  187. package/dist/lib/env-file.d.ts +12 -13
  188. package/dist/lib/format-audio-recorder-duration.d.ts +2 -3
  189. package/dist/lib/liquid-glass-optics.d.ts +2 -3
  190. package/dist/lib/phone-input-format.d.ts +3 -4
  191. package/dist/lib/phone-number.d.ts +8 -9
  192. package/dist/lib/trigger-detect.d.ts +4 -5
  193. package/dist/markdown-block.d.ts +11 -12
  194. package/dist/markdown-block.js +1 -1
  195. package/dist/scripts/contrast-eval.d.ts +16 -17
  196. package/dist/scripts/contrast-eval.js +13 -7
  197. package/dist/skin-provider.d.ts +14 -0
  198. package/dist/skin-provider.js +21 -0
  199. package/dist/skin.d.ts +14 -33
  200. package/dist/skin.js +3 -46
  201. package/dist/source-badge.d.ts +7 -8
  202. package/dist/styles/index.css +3 -5
  203. package/dist/styles/recipes/accordion.css +8 -2
  204. package/dist/styles/recipes/action-bar.css +40 -5
  205. package/dist/styles/recipes/activity.css +36 -3
  206. package/dist/styles/recipes/alert.css +97 -16
  207. package/dist/styles/recipes/audio-visualizer.css +8 -1
  208. package/dist/styles/recipes/avatar.css +17 -1
  209. package/dist/styles/recipes/badge.css +0 -1
  210. package/dist/styles/recipes/button-group.css +8 -0
  211. package/dist/styles/recipes/button.css +49 -8
  212. package/dist/styles/recipes/calendar.css +21 -6
  213. package/dist/styles/recipes/card.css +2 -0
  214. package/dist/styles/recipes/chat-composer-attachment.css +83 -54
  215. package/dist/styles/recipes/chat-composer.css +41 -22
  216. package/dist/styles/recipes/chat-layout.css +37 -54
  217. package/dist/styles/recipes/chat-message.css +78 -5
  218. package/dist/styles/recipes/choice.css +21 -2
  219. package/dist/styles/recipes/code-diff.css +9 -1
  220. package/dist/styles/recipes/code.css +64 -17
  221. package/dist/styles/recipes/collapsible.css +0 -3
  222. package/dist/styles/recipes/color-picker-details.css +1 -2
  223. package/dist/styles/recipes/color-picker-values.css +0 -4
  224. package/dist/styles/recipes/context.css +30 -18
  225. package/dist/styles/recipes/dockable-panel.css +8 -1
  226. package/dist/styles/recipes/dropzone.css +9 -2
  227. package/dist/styles/recipes/dynamic-notification-input.css +6 -0
  228. package/dist/styles/recipes/dynamic-notification.css +1 -0
  229. package/dist/styles/recipes/empty.css +118 -17
  230. package/dist/styles/recipes/environment-variables.css +9 -1
  231. package/dist/styles/recipes/field-parts.css +3 -6
  232. package/dist/styles/recipes/field.css +15 -5
  233. package/dist/styles/recipes/gradient-editor.css +33 -5
  234. package/dist/styles/recipes/inline-attachment.css +68 -20
  235. package/dist/styles/recipes/inline-citation.css +52 -10
  236. package/dist/styles/recipes/item.css +4 -2
  237. package/dist/styles/recipes/kbd.css +8 -0
  238. package/dist/styles/recipes/markdown-block.css +17 -2
  239. package/dist/styles/recipes/markdown.css +19 -0
  240. package/dist/styles/recipes/morphing-panel.css +1 -1
  241. package/dist/styles/recipes/page-layout.css +203 -0
  242. package/dist/styles/recipes/pagination.css +16 -4
  243. package/dist/styles/recipes/phone-input.css +8 -4
  244. package/dist/styles/recipes/popup-drawer.css +3 -1
  245. package/dist/styles/recipes/popup-lists.css +11 -0
  246. package/dist/styles/recipes/popup-toast.css +3 -29
  247. package/dist/styles/recipes/popup.css +10 -14
  248. package/dist/styles/recipes/progressive-blur.css +28 -7
  249. package/dist/styles/recipes/range.css +74 -3
  250. package/dist/styles/recipes/resizable.css +8 -10
  251. package/dist/styles/recipes/rich-tooltip.css +1 -4
  252. package/dist/styles/recipes/scroll-area.css +8 -2
  253. package/dist/styles/recipes/sidebar-menu.css +0 -6
  254. package/dist/styles/recipes/sidebar.css +56 -17
  255. package/dist/styles/recipes/skeleton.css +85 -3
  256. package/dist/styles/recipes/source-badge.css +20 -3
  257. package/dist/styles/recipes/stepper.css +8 -1
  258. package/dist/styles/recipes/switch.css +89 -17
  259. package/dist/styles/recipes/table-of-contents.css +211 -45
  260. package/dist/styles/recipes/table.css +0 -1
  261. package/dist/styles/recipes/tabs.css +35 -2
  262. package/dist/styles/recipes/task-list.css +68 -9
  263. package/dist/styles/recipes/thread-rail.css +19 -17
  264. package/dist/styles/recipes/toolbar.css +39 -4
  265. package/dist/styles/recipes/track-highlight.css +63 -5
  266. package/dist/styles/recipes/transcript-divider.css +1 -0
  267. package/dist/styles/recipes/tree.css +2 -0
  268. package/dist/styles/recipes/user-ask.css +65 -18
  269. package/dist/styles/theme.css +164 -138
  270. package/dist/surface-variants.d.ts +4 -5
  271. package/dist/task-list.d.ts +16 -17
  272. package/dist/thread-rail.d.ts +21 -22
  273. package/dist/thread-rail.js +1 -1
  274. package/dist/transcript-divider.d.ts +6 -7
  275. package/dist/ui/accordion.d.ts +10 -11
  276. package/dist/ui/alert-dialog.d.ts +11 -12
  277. package/dist/ui/alert-dialog.js +9 -7
  278. package/dist/ui/alert.d.ts +9 -10
  279. package/dist/ui/alert.js +3 -3
  280. package/dist/ui/aspect-ratio.d.ts +3 -4
  281. package/dist/ui/autocomplete.d.ts +19 -20
  282. package/dist/ui/autocomplete.js +6 -4
  283. package/dist/ui/avatar.d.ts +9 -10
  284. package/dist/ui/badge.d.ts +9 -10
  285. package/dist/ui/button-group.d.ts +7 -8
  286. package/dist/ui/button-group.js +3 -2
  287. package/dist/ui/button.d.ts +17 -18
  288. package/dist/ui/button.js +20 -5
  289. package/dist/ui/calendar.d.ts +3 -4
  290. package/dist/ui/card.d.ts +16 -17
  291. package/dist/ui/checkbox-group.d.ts +4 -5
  292. package/dist/ui/checkbox-group.js +3 -2
  293. package/dist/ui/checkbox.d.ts +3 -4
  294. package/dist/ui/code-diff.d.ts +8 -9
  295. package/dist/ui/code.d.ts +32 -23
  296. package/dist/ui/code.js +41 -20
  297. package/dist/ui/collapsible.d.ts +7 -8
  298. package/dist/ui/color-picker.d.ts +40 -41
  299. package/dist/ui/color-picker.js +8 -6
  300. package/dist/ui/combobox-disabled-selection.d.ts +3 -4
  301. package/dist/ui/combobox.d.ts +19 -20
  302. package/dist/ui/combobox.js +6 -4
  303. package/dist/ui/command.d.ts +22 -19
  304. package/dist/ui/command.js +63 -13
  305. package/dist/ui/context-menu.d.ts +30 -31
  306. package/dist/ui/context-menu.js +10 -7
  307. package/dist/ui/dialog.d.ts +13 -13
  308. package/dist/ui/dialog.js +11 -9
  309. package/dist/ui/dockable-panel-geometry.d.ts +7 -8
  310. package/dist/ui/dockable-panel.d.ts +21 -22
  311. package/dist/ui/drawer.d.ts +17 -18
  312. package/dist/ui/drawer.js +9 -8
  313. package/dist/ui/dropdown-menu.d.ts +32 -33
  314. package/dist/ui/dropdown-menu.js +6 -4
  315. package/dist/ui/dropzone.d.ts +24 -24
  316. package/dist/ui/dropzone.js +4 -1
  317. package/dist/ui/empty.d.ts +14 -14
  318. package/dist/ui/empty.js +3 -3
  319. package/dist/ui/field.d.ts +26 -27
  320. package/dist/ui/form.d.ts +4 -5
  321. package/dist/ui/gradient-editor.d.ts +16 -17
  322. package/dist/ui/gradient-editor.js +2 -2
  323. package/dist/ui/hover-card.d.ts +6 -7
  324. package/dist/ui/hover-card.js +6 -4
  325. package/dist/ui/infinite-canvas.d.ts +11 -12
  326. package/dist/ui/infinite-canvas.js +1 -0
  327. package/dist/ui/input-group.d.ts +6 -7
  328. package/dist/ui/input-otp.d.ts +7 -8
  329. package/dist/ui/input.d.ts +3 -4
  330. package/dist/ui/item.d.ts +20 -21
  331. package/dist/ui/kbd.d.ts +7 -5
  332. package/dist/ui/kbd.js +4 -2
  333. package/dist/ui/markdown-elements.d.ts +20 -21
  334. package/dist/ui/markdown.d.ts +5 -6
  335. package/dist/ui/menubar.d.ts +25 -26
  336. package/dist/ui/menubar.js +10 -7
  337. package/dist/ui/meter.d.ts +11 -12
  338. package/dist/ui/morphing-panel.d.ts +8 -9
  339. package/dist/ui/native-select.d.ts +3 -4
  340. package/dist/ui/native-select.js +1 -1
  341. package/dist/ui/navigation-menu.d.ts +17 -18
  342. package/dist/ui/navigation-menu.js +6 -4
  343. package/dist/ui/number-field.d.ts +15 -16
  344. package/dist/ui/number-field.js +1 -1
  345. package/dist/ui/page-layout.d.ts +44 -0
  346. package/dist/ui/page-layout.js +108 -0
  347. package/dist/ui/pagination.d.ts +10 -11
  348. package/dist/ui/phone-input.d.ts +5 -6
  349. package/dist/ui/phone-input.js +39 -36
  350. package/dist/ui/popover.d.ts +11 -12
  351. package/dist/ui/popover.js +6 -4
  352. package/dist/ui/progress.d.ts +11 -12
  353. package/dist/ui/progressive-blur.d.ts +4 -5
  354. package/dist/ui/radio-group.d.ts +5 -6
  355. package/dist/ui/resizable.d.ts +12 -13
  356. package/dist/ui/resizable.js +1 -1
  357. package/dist/ui/responsive-dialog.d.ts +11 -12
  358. package/dist/ui/rich-tooltip-tour.d.ts +5 -6
  359. package/dist/ui/rich-tooltip.d.ts +21 -23
  360. package/dist/ui/rich-tooltip.js +6 -6
  361. package/dist/ui/scroll-area.d.ts +7 -8
  362. package/dist/ui/scroll-area.js +9 -6
  363. package/dist/ui/select.d.ts +21 -14
  364. package/dist/ui/select.js +8 -5
  365. package/dist/ui/separator.d.ts +2 -3
  366. package/dist/ui/sheet.d.ts +8 -9
  367. package/dist/ui/sheet.js +9 -7
  368. package/dist/ui/sidebar-menu.d.ts +18 -19
  369. package/dist/ui/sidebar-menu.js +4 -3
  370. package/dist/ui/sidebar-provider.d.ts +32 -7
  371. package/dist/ui/sidebar-provider.js +82 -22
  372. package/dist/ui/sidebar-resize-rail.d.ts +8 -0
  373. package/dist/ui/sidebar-resize-rail.js +192 -0
  374. package/dist/ui/sidebar.d.ts +19 -13
  375. package/dist/ui/sidebar.js +120 -55
  376. package/dist/ui/skeleton.d.ts +7 -4
  377. package/dist/ui/skeleton.js +9 -2
  378. package/dist/ui/slider.d.ts +6 -5
  379. package/dist/ui/slider.js +16 -13
  380. package/dist/ui/spinner.d.ts +3 -4
  381. package/dist/ui/stepper.d.ts +22 -23
  382. package/dist/ui/switch.d.ts +3 -4
  383. package/dist/ui/switch.js +12 -1
  384. package/dist/ui/table-of-contents.d.ts +7 -8
  385. package/dist/ui/table-of-contents.js +4 -2
  386. package/dist/ui/table.d.ts +17 -18
  387. package/dist/ui/tabs.d.ts +14 -11
  388. package/dist/ui/textarea.d.ts +3 -4
  389. package/dist/ui/timeline.d.ts +18 -19
  390. package/dist/ui/toast.d.ts +9 -9
  391. package/dist/ui/toast.js +23 -16
  392. package/dist/ui/toggle.d.ts +5 -6
  393. package/dist/ui/toggle.js +3 -2
  394. package/dist/ui/toolbar.d.ts +15 -16
  395. package/dist/ui/toolbar.js +15 -4
  396. package/dist/ui/tooltip.d.ts +6 -13
  397. package/dist/ui/tooltip.js +8 -9
  398. package/dist/ui/tree.d.ts +18 -19
  399. package/dist/ui/tree.js +3 -2
  400. package/dist/ui/trigger-menu.d.ts +15 -16
  401. package/dist/ui/trigger-menu.js +6 -4
  402. package/dist/ui/use-switch-drag.d.ts +7 -0
  403. package/dist/ui/use-switch-drag.js +104 -0
  404. package/dist/user-ask.d.ts +28 -27
  405. package/dist/user-ask.js +38 -13
  406. package/package.json +17 -16
  407. package/dist/code-block-editor.d.ts +0 -59
  408. package/dist/code-block-editor.js +0 -250
  409. package/dist/knob-contracts/code-block-editor-knobs.d.ts +0 -5
  410. package/dist/knob-contracts/code-block-editor-knobs.js +0 -11
  411. package/dist/lib/code-block-shiki.d.ts +0 -9
  412. package/dist/lib/code-block-shiki.js +0 -6
  413. package/dist/skin.config.d.ts +0 -5
  414. package/dist/skin.config.js +0 -12
  415. package/dist/styles/recipes/code-block-editor.css +0 -136
  416. package/dist/styles/skin-theme.css +0 -137
  417. package/dist/styles/skin.css +0 -143
@@ -2,24 +2,23 @@ import { PopupKnobStyle } from "../knob-contracts/popup-knobs.js";
2
2
  import { CSSProperties, ComponentProps } from "react";
3
3
  import { Dialog } from "@base-ui/react/dialog";
4
4
  //#region src/ui/sheet.d.ts
5
- declare function Sheet(props: ComponentProps<typeof Dialog.Root>): import("react").JSX.Element;
6
- declare function SheetClose({ className, ...props }: ComponentProps<typeof Dialog.Close> & {
5
+ export declare function Sheet(props: ComponentProps<typeof Dialog.Root>): import("react").JSX.Element;
6
+ export declare function SheetClose({ className, ...props }: ComponentProps<typeof Dialog.Close> & {
7
7
  style?: CSSProperties & PopupKnobStyle;
8
8
  }): import("react").JSX.Element;
9
- type SheetContentProps = Omit<ComponentProps<typeof Dialog.Popup>, "style"> & {
9
+ export type SheetContentProps = Omit<ComponentProps<typeof Dialog.Popup>, "style"> & {
10
10
  style?: CSSProperties & PopupKnobStyle;
11
11
  } & {
12
12
  side?: "left" | "right";
13
13
  };
14
- declare function SheetContent({ className, children, side, ...props }: SheetContentProps): import("react").JSX.Element;
15
- declare function SheetHeader({ className, ...props }: ComponentProps<"div"> & {
14
+ export declare function SheetContent({ className, children, side, ...props }: SheetContentProps): import("react").JSX.Element;
15
+ export declare function SheetHeader({ className, ...props }: ComponentProps<"div"> & {
16
16
  style?: CSSProperties & PopupKnobStyle;
17
17
  }): import("react").JSX.Element;
18
- declare function SheetTitle({ className, ...props }: ComponentProps<typeof Dialog.Title> & {
18
+ export declare function SheetTitle({ className, ...props }: ComponentProps<typeof Dialog.Title> & {
19
19
  style?: CSSProperties & PopupKnobStyle;
20
20
  }): import("react").JSX.Element;
21
- declare function SheetDescription({ className, ...props }: ComponentProps<typeof Dialog.Description> & {
21
+ export declare function SheetDescription({ className, ...props }: ComponentProps<typeof Dialog.Description> & {
22
22
  style?: CSSProperties & PopupKnobStyle;
23
23
  }): import("react").JSX.Element;
24
- //#endregion
25
- export { Sheet, SheetClose, SheetContent, SheetContentProps, SheetDescription, SheetHeader, SheetTitle };
24
+ //#endregion
package/dist/ui/sheet.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
- import { skinEffects, skinId } from "../skin.js";
3
+ import { controlEffectsAttribute } from "../skin.js";
4
+ import { useSkin } from "../skin-provider.js";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { Dialog } from "@base-ui/react/dialog";
6
7
  //#region src/ui/sheet.tsx
@@ -18,25 +19,26 @@ function SheetClose({ className, ...props }) {
18
19
  });
19
20
  }
20
21
  function SheetContent({ className, children, side = "right", ...props }) {
22
+ const skin = useSkin();
21
23
  return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Backdrop, {
22
24
  "data-control-ui": "sheet",
23
25
  "data-popup-kind": "sheet",
24
26
  "data-slot": "backdrop",
25
27
  "data-control-family": "popup",
26
28
  "data-popup-part": "backdrop",
27
- "data-skin": skinId(),
28
- "data-effects": skinEffects(),
29
- className: "fixed inset-0 z-[70]"
29
+ "data-skin": skin.id,
30
+ "data-effects": controlEffectsAttribute(skin.effects),
31
+ className: "fixed inset-0 z-(--z-overlay)"
30
32
  }), /* @__PURE__ */ jsx(Dialog.Popup, {
31
- "data-skin": skinId(),
32
- "data-effects": skinEffects(),
33
+ "data-skin": skin.id,
34
+ "data-effects": controlEffectsAttribute(skin.effects),
33
35
  "data-control-ui": "sheet",
34
36
  "data-popup-kind": "sheet",
35
37
  "data-control-family": "popup",
36
38
  "data-slot": "content",
37
39
  "data-popup-part": "surface",
38
40
  "data-surface": "modal",
39
- className: cn("fixed inset-y-0 z-[71] flex h-full w-3/4 max-w-sm flex-col", side === "left" ? "left-0" : "right-0", className),
41
+ className: cn("fixed inset-y-0 z-(--z-modal) flex h-full w-3/4 max-w-sm flex-col", side === "left" ? "left-0" : "right-0", className),
40
42
  ...props,
41
43
  "data-side": side,
42
44
  children
@@ -2,26 +2,26 @@ import { HoverIndicator, RenderProp, SelectionIndicator } from "../control-props
2
2
  import { SidebarKnobStyle } from "../knob-contracts/sidebar-knobs.js";
3
3
  import { CSSProperties, ComponentProps, ReactNode } from "react";
4
4
  //#region src/ui/sidebar-menu.d.ts
5
- declare const sidebarMenuButtonVariants: readonly ["default", "outline"];
6
- type SidebarMenuButtonVariant = (typeof sidebarMenuButtonVariants)[number];
7
- declare const sidebarMenuButtonSizes: readonly ["default", "sm", "lg"];
8
- type SidebarMenuButtonSize = (typeof sidebarMenuButtonSizes)[number];
9
- type SidebarGroupLabelProps = Omit<ComponentProps<"div">, "style"> & {
5
+ export declare const sidebarMenuButtonVariants: readonly ["default", "outline"];
6
+ export type SidebarMenuButtonVariant = (typeof sidebarMenuButtonVariants)[number];
7
+ export declare const sidebarMenuButtonSizes: readonly ["default", "sm", "lg"];
8
+ export type SidebarMenuButtonSize = (typeof sidebarMenuButtonSizes)[number];
9
+ export type SidebarGroupLabelProps = Omit<ComponentProps<"div">, "style"> & {
10
10
  style?: CSSProperties & SidebarKnobStyle;
11
11
  } & {
12
12
  render?: RenderProp<ComponentProps<"div">>;
13
13
  };
14
- type SidebarGroupContentProps = Omit<ComponentProps<"div">, "style"> & {
14
+ export type SidebarGroupContentProps = Omit<ComponentProps<"div">, "style"> & {
15
15
  style?: CSSProperties & SidebarKnobStyle;
16
16
  };
17
- type SidebarMenuActionProps = Omit<ComponentProps<"button">, "style"> & {
17
+ export type SidebarMenuActionProps = Omit<ComponentProps<"button">, "style"> & {
18
18
  render?: RenderProp<ComponentProps<"button">>;
19
19
  showOnHover?: boolean;
20
20
  style?: CSSProperties & SidebarKnobStyle;
21
21
  };
22
- declare function SidebarGroupContent({ className, ...props }: SidebarGroupContentProps): import("react").JSX.Element;
23
- declare function SidebarMenuAction({ className, render, showOnHover, children, ...props }: SidebarMenuActionProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
24
- type SidebarMenuButtonProps = Omit<ComponentProps<"button">, "style"> & {
22
+ export declare function SidebarGroupContent({ className, ...props }: SidebarGroupContentProps): import("react").JSX.Element;
23
+ export declare function SidebarMenuAction({ className, render, showOnHover, children, ...props }: SidebarMenuActionProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
24
+ export type SidebarMenuButtonProps = Omit<ComponentProps<"button">, "style"> & {
25
25
  style?: CSSProperties & SidebarKnobStyle;
26
26
  } & {
27
27
  render?: RenderProp<ComponentProps<"button">>;
@@ -30,20 +30,19 @@ type SidebarMenuButtonProps = Omit<ComponentProps<"button">, "style"> & {
30
30
  variant?: SidebarMenuButtonVariant;
31
31
  size?: SidebarMenuButtonSize;
32
32
  };
33
- declare function SidebarGroup({ className, ...props }: ComponentProps<"div"> & {
33
+ export declare function SidebarGroup({ className, ...props }: ComponentProps<"div"> & {
34
34
  style?: CSSProperties & SidebarKnobStyle;
35
35
  }): import("react").JSX.Element;
36
- declare function SidebarGroupLabel({ className, render, children, ...props }: SidebarGroupLabelProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
37
- type SidebarSelectionIndicator = SelectionIndicator | HoverIndicator;
38
- declare function SidebarMenu({ className, indicator, style, children, ...props }: ComponentProps<"ul"> & {
36
+ export declare function SidebarGroupLabel({ className, render, children, ...props }: SidebarGroupLabelProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
37
+ export type SidebarSelectionIndicator = SelectionIndicator | HoverIndicator;
38
+ export declare function SidebarMenu({ className, indicator, style, children, ...props }: ComponentProps<"ul"> & {
39
39
  indicator?: SidebarSelectionIndicator;
40
40
  } & {
41
41
  style?: CSSProperties & SidebarKnobStyle;
42
42
  }): import("react").JSX.Element;
43
- declare function SidebarMenuItem({ className, ...props }: ComponentProps<"li"> & {
43
+ export declare function SidebarMenuItem({ className, ...props }: ComponentProps<"li"> & {
44
44
  style?: CSSProperties & SidebarKnobStyle;
45
45
  }): import("react").JSX.Element;
46
- declare function SidebarMenuButton({ render, isActive, variant, size, tooltip, className, children, ...props }: SidebarMenuButtonProps): import("react").JSX.Element;
47
- declare function SidebarMenuSub({ className, ...props }: ComponentProps<typeof SidebarMenu>): import("react").JSX.Element;
48
- //#endregion
49
- export { SidebarGroup, SidebarGroupContent, SidebarGroupContentProps, SidebarGroupLabel, SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, SidebarMenuActionProps, SidebarMenuButton, SidebarMenuButtonProps, SidebarMenuButtonSize, SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarSelectionIndicator, sidebarMenuButtonSizes, sidebarMenuButtonVariants };
46
+ export declare function SidebarMenuButton({ render, isActive, variant, size, tooltip, className, children, ...props }: SidebarMenuButtonProps): import("react").JSX.Element;
47
+ export declare function SidebarMenuSub({ className, ...props }: ComponentProps<typeof SidebarMenu>): import("react").JSX.Element;
48
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
- import { skinIndicator } from "../skin.js";
3
+ import { useSkin } from "../skin-provider.js";
4
4
  import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
5
5
  import { useSidebar } from "./sidebar-provider.js";
6
6
  import { TrackHighlight } from "../extensions/track-highlight.js";
@@ -65,7 +65,8 @@ function SidebarGroupLabel({ className, render, children, ...props }) {
65
65
  }
66
66
  const SidebarMenuContext = createContext("none");
67
67
  function SidebarMenu({ className, indicator, style, children, ...props }) {
68
- const resolvedIndicator = indicator ?? skinIndicator("sidebar") ?? "none";
68
+ const skin = useSkin();
69
+ const resolvedIndicator = indicator ?? skin.indicators?.sidebar ?? "none";
69
70
  const hasHighlight = resolvedIndicator !== "none";
70
71
  const list = /* @__PURE__ */ jsx("ul", {
71
72
  "data-control-ui": "sidebar",
@@ -101,7 +102,7 @@ function SidebarMenuItem({ className, ...props }) {
101
102
  ...props
102
103
  });
103
104
  }
104
- const sidebarMenuButtonClasses = cva("peer/menu-button flex w-full items-center overflow-hidden text-start group-data-[collapsible=icon]:px-0! disabled:pointer-events-none aria-disabled:pointer-events-none [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
105
+ const sidebarMenuButtonClasses = cva("peer/menu-button flex w-full items-center overflow-hidden text-start group-data-[collapsible=icon]:px-0! disabled:pointer-events-none aria-disabled:pointer-events-none [&>span]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
105
106
  variants: {
106
107
  variant: {
107
108
  default: null,
@@ -1,7 +1,7 @@
1
1
  import { SidebarKnobStyle } from "../knob-contracts/sidebar-knobs.js";
2
- import { CSSProperties, ComponentProps } from "react";
2
+ import { CSSProperties, ComponentProps, RefObject } from "react";
3
3
  //#region src/ui/sidebar-provider.d.ts
4
- type SidebarStyle = CSSProperties & SidebarKnobStyle & {
4
+ export type SidebarStyle = CSSProperties & SidebarKnobStyle & {
5
5
  "--sidebar-width"?: string;
6
6
  "--sidebar-width-icon"?: string;
7
7
  };
@@ -13,16 +13,41 @@ type SidebarContextProps = {
13
13
  setOpenMobile: (open: boolean) => void;
14
14
  isMobile: boolean;
15
15
  toggleSidebar: () => void;
16
+ width: number | undefined;
17
+ minWidth: number;
18
+ maxWidth: number;
19
+ setWidth: (width: number) => void;
16
20
  };
17
- declare function useSidebar(): SidebarContextProps;
18
- type SidebarProviderProps = Omit<ComponentProps<"div">, "style"> & {
21
+ type SidebarElements = {
22
+ wrapperRef: RefObject<HTMLDivElement | null>;
23
+ offcanvasRef: RefObject<HTMLDivElement | null>;
24
+ railRef: RefObject<HTMLElement | null>;
25
+ triggerRef: RefObject<HTMLButtonElement | null>;
26
+ };
27
+ export declare const SidebarSurfaceContext: import("react").Context<{
28
+ side: "left" | "right";
29
+ collapsible: "offcanvas" | "icon" | "none";
30
+ railContainer: HTMLDivElement | null;
31
+ } | null>;
32
+ export declare function useSidebarElements(): SidebarElements;
33
+ export declare function useSidebarSurface(): {
34
+ side: "left" | "right";
35
+ collapsible: "offcanvas" | "icon" | "none";
36
+ railContainer: HTMLDivElement | null;
37
+ };
38
+ export declare function useSidebar(): SidebarContextProps;
39
+ export type SidebarProviderProps = Omit<ComponentProps<"div">, "style"> & {
19
40
  defaultOpen?: boolean;
20
41
  open?: boolean;
21
42
  onOpenChange?: (open: boolean) => void;
43
+ defaultWidth?: number;
44
+ minWidth?: number;
45
+ maxWidth?: number;
46
+ width?: number;
47
+ onWidthChange?: (width: number) => void;
22
48
  persistOpen?: boolean;
23
49
  keyboardShortcut?: string | null;
24
50
  style?: SidebarStyle;
25
51
  };
26
- declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange, persistOpen, keyboardShortcut, ref, className, style, children, ...props }: SidebarProviderProps): import("react").JSX.Element;
27
- //#endregion
28
- export { SidebarProvider, SidebarProviderProps, SidebarStyle, useSidebar };
52
+ export declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange, defaultWidth, minWidth, maxWidth, width: widthProp, onWidthChange, persistOpen, keyboardShortcut, ref, className, style, children, ...props }: SidebarProviderProps): import("react").JSX.Element;
53
+ //#endregion
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
- import { skinSidebarWidth } from "../skin.js";
4
- import { TooltipProvider } from "./tooltip.js";
3
+ import { useSkin } from "../skin-provider.js";
5
4
  import { SIDEBAR_COOKIE_NAME } from "../control-props.js";
5
+ import { TooltipProvider } from "./tooltip.js";
6
6
  import { useIsMobile } from "../hooks/use-mobile.js";
7
- import { createContext, useContext, useEffect, useRef, useState } from "react";
7
+ import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
8
+ import { useRender } from "@base-ui/react/use-render";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
  //#region src/ui/sidebar-provider.tsx
10
11
  const SIDEBAR_COOKIE_MAX_AGE = 604800;
@@ -12,21 +13,71 @@ const SIDEBAR_WIDTH = "16rem";
12
13
  const SIDEBAR_WIDTH_ICON = "3rem";
13
14
  const SIDEBAR_KEYBOARD_SHORTCUT = "b";
14
15
  const SIDEBAR_MOBILE_BREAKPOINT = 1024;
16
+ const SidebarElementsContext = createContext(null);
17
+ const SidebarSurfaceContext = createContext(null);
18
+ function useSidebarElements() {
19
+ const elements = useContext(SidebarElementsContext);
20
+ if (!elements) throw new Error("Sidebar parts must be used within a SidebarProvider.");
21
+ return elements;
22
+ }
23
+ function useSidebarSurface() {
24
+ const surface = useContext(SidebarSurfaceContext);
25
+ if (!surface) throw new Error("SidebarRail must be used within a Sidebar.");
26
+ return surface;
27
+ }
28
+ function focusOutsideCollapsedContent({ offcanvasRef, railRef, triggerRef }) {
29
+ const container = offcanvasRef.current;
30
+ if (!container?.contains(document.activeElement)) return;
31
+ const target = railRef.current ?? triggerRef.current;
32
+ if (target) target.focus({ preventScroll: true });
33
+ else container.focus({ preventScroll: true });
34
+ }
15
35
  const SidebarContext = createContext(null);
16
36
  function useSidebar() {
17
37
  const context = useContext(SidebarContext);
18
38
  if (!context) throw new Error("useSidebar must be used within a SidebarProvider.");
19
39
  return context;
20
40
  }
21
- function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, persistOpen = true, keyboardShortcut = SIDEBAR_KEYBOARD_SHORTCUT, ref, className, style, children, ...props }) {
41
+ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, defaultWidth, minWidth = 224, maxWidth = 420, width: widthProp, onWidthChange, persistOpen = true, keyboardShortcut = SIDEBAR_KEYBOARD_SHORTCUT, ref, className, style, children, ...props }) {
42
+ const skin = useSkin();
22
43
  const isMobile = useIsMobile(SIDEBAR_MOBILE_BREAKPOINT);
23
44
  const [openMobile, setOpenMobile] = useState(false);
45
+ const wrapperRef = useRef(null);
46
+ const offcanvasRef = useRef(null);
47
+ const railRef = useRef(null);
48
+ const triggerRef = useRef(null);
49
+ const elements = {
50
+ wrapperRef,
51
+ offcanvasRef,
52
+ railRef,
53
+ triggerRef
54
+ };
55
+ const [internalWidth, setInternalWidth] = useState(defaultWidth);
56
+ function clampWidth(nextWidth) {
57
+ return Math.min(maxWidth, Math.max(minWidth, nextWidth));
58
+ }
59
+ const requestedWidth = widthProp ?? internalWidth;
60
+ const width = requestedWidth === void 0 ? void 0 : clampWidth(requestedWidth);
61
+ function setWidth(nextWidth) {
62
+ const clampedWidth = clampWidth(nextWidth);
63
+ if (widthProp === void 0) setInternalWidth(clampedWidth);
64
+ onWidthChange?.(clampedWidth);
65
+ }
24
66
  const [internalOpen, setInternalOpen] = useState(defaultOpen);
25
67
  const open = openProp ?? internalOpen;
68
+ useLayoutEffect(() => {
69
+ if (!open && !isMobile) focusOutsideCollapsedContent({
70
+ wrapperRef,
71
+ offcanvasRef,
72
+ railRef,
73
+ triggerRef
74
+ });
75
+ }, [open, isMobile]);
26
76
  const setOpen = (value) => {
27
77
  const openState = typeof value === "function" ? value(open) : value;
28
- if (onOpenChange) onOpenChange(openState);
29
- else setInternalOpen(openState);
78
+ if (!openState && !isMobile) focusOutsideCollapsedContent(elements);
79
+ if (openProp === void 0) setInternalOpen(openState);
80
+ onOpenChange?.(openState);
30
81
  if (persistOpen) document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
31
82
  };
32
83
  const toggleSidebar = () => isMobile ? setOpenMobile((prev) => !prev) : setOpen(!open);
@@ -52,29 +103,38 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, per
52
103
  isMobile,
53
104
  openMobile,
54
105
  setOpenMobile,
55
- toggleSidebar
106
+ toggleSidebar,
107
+ width,
108
+ setWidth,
109
+ minWidth,
110
+ maxWidth
56
111
  };
57
112
  const wrapperStyle = {
58
- "--sidebar-width": skinSidebarWidth() ?? SIDEBAR_WIDTH,
113
+ "--sidebar-width": skin.sidebarWidth ?? SIDEBAR_WIDTH,
59
114
  "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
60
- ...style
115
+ ...style,
116
+ ...width === void 0 ? {} : { "--sidebar-width": `${width}px` }
61
117
  };
118
+ const wrapper = useRender({
119
+ defaultTagName: "div",
120
+ ref: [ref ?? null, wrapperRef],
121
+ props: {
122
+ ...props,
123
+ "data-control-ui": "sidebar",
124
+ "data-control-family": "sidebar",
125
+ "data-slot": "wrapper",
126
+ style: wrapperStyle,
127
+ className: cn("group/sidebar-wrapper flex min-h-svh w-full", className),
128
+ children
129
+ }
130
+ });
62
131
  return /* @__PURE__ */ jsx(SidebarContext.Provider, {
63
132
  value: contextValue,
64
- children: /* @__PURE__ */ jsx(TooltipProvider, {
65
- delay: 0,
66
- children: /* @__PURE__ */ jsx("div", {
67
- ref,
68
- "data-control-ui": "sidebar",
69
- "data-control-family": "sidebar",
70
- "data-slot": "wrapper",
71
- style: wrapperStyle,
72
- className: cn("group/sidebar-wrapper flex min-h-svh w-full", className),
73
- ...props,
74
- children
75
- })
133
+ children: /* @__PURE__ */ jsx(SidebarElementsContext.Provider, {
134
+ value: elements,
135
+ children: /* @__PURE__ */ jsx(TooltipProvider, { children: wrapper })
76
136
  })
77
137
  });
78
138
  }
79
139
  //#endregion
80
- export { SidebarProvider, useSidebar };
140
+ export { SidebarProvider, SidebarSurfaceContext, useSidebar, useSidebarElements, useSidebarSurface };
@@ -0,0 +1,8 @@
1
+ import { SidebarKnobStyle } from "../knob-contracts/sidebar-knobs.js";
2
+ import { CSSProperties, ComponentProps } from "react";
3
+ //#region src/ui/sidebar-resize-rail.d.ts
4
+ export type SidebarResizeRailProps = ComponentProps<"div"> & {
5
+ style?: CSSProperties & SidebarKnobStyle;
6
+ };
7
+ export declare function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown, ...props }: SidebarResizeRailProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
8
+ //#endregion
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.js";
3
+ import { useSidebar, useSidebarElements, useSidebarSurface } from "./sidebar-provider.js";
4
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
5
+ import { useRender } from "@base-ui/react/use-render";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/ui/sidebar-resize-rail.tsx
8
+ const DRAG_THRESHOLD_PX = 5;
9
+ const KEYBOARD_STEP_PX = 10;
10
+ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown, ...props }) {
11
+ const { open, setOpen, setWidth, toggleSidebar, minWidth, maxWidth } = useSidebar();
12
+ const { wrapperRef, railRef } = useSidebarElements();
13
+ const { side, collapsible } = useSidebarSurface();
14
+ const widthMeasureRef = useRef(null);
15
+ const cancelGestureRef = useRef(null);
16
+ const draggedRef = useRef(false);
17
+ const [measuredWidth, setMeasuredWidth] = useState();
18
+ useLayoutEffect(() => {
19
+ const measure = widthMeasureRef.current;
20
+ if (!measure) return;
21
+ const updateMeasuredWidth = () => setMeasuredWidth(Math.round(measure.getBoundingClientRect().width));
22
+ updateMeasuredWidth();
23
+ const observer = new ResizeObserver(updateMeasuredWidth);
24
+ observer.observe(measure);
25
+ return () => observer.disconnect();
26
+ }, []);
27
+ useEffect(() => () => cancelGestureRef.current?.(), []);
28
+ function clampWidth(nextWidth) {
29
+ return Math.min(maxWidth, Math.max(minWidth, nextWidth));
30
+ }
31
+ function handlePointerDown(event) {
32
+ onPointerDown?.(event);
33
+ if (event.defaultPrevented || event.button !== 0) return;
34
+ const mountedWrapper = wrapperRef.current;
35
+ const measure = widthMeasureRef.current;
36
+ if (!mountedWrapper || !measure) return;
37
+ const wrapper = mountedWrapper;
38
+ event.preventDefault();
39
+ cancelGestureRef.current?.();
40
+ draggedRef.current = false;
41
+ const handle = event.currentTarget;
42
+ handle.focus({ preventScroll: true });
43
+ handle.setPointerCapture(event.pointerId);
44
+ const pointerId = event.pointerId;
45
+ const startX = event.clientX;
46
+ const wrapperBounds = wrapper.getBoundingClientRect();
47
+ const initialWidth = measure.getBoundingClientRect().width;
48
+ const previousWidth = wrapper.style.getPropertyValue("--sidebar-width");
49
+ const previousCursor = document.body.style.cursor;
50
+ const previousUserSelect = document.body.style.userSelect;
51
+ const controller = new AbortController();
52
+ let draftWidth = initialWidth;
53
+ const initiallyCollapsed = !open && collapsible !== "none";
54
+ let collapsedDuringDrag = initiallyCollapsed;
55
+ function restoreWidth() {
56
+ wrapper.style.setProperty("--sidebar-width", previousWidth);
57
+ }
58
+ function endGesture() {
59
+ controller.abort();
60
+ document.body.style.cursor = previousCursor;
61
+ document.body.style.userSelect = previousUserSelect;
62
+ wrapper.removeAttribute("data-resizing");
63
+ handle.removeAttribute("data-resizing");
64
+ if (handle.hasPointerCapture(pointerId)) handle.releasePointerCapture(pointerId);
65
+ cancelGestureRef.current = null;
66
+ }
67
+ function cancelGesture() {
68
+ endGesture();
69
+ restoreWidth();
70
+ draggedRef.current = false;
71
+ if (collapsedDuringDrag !== initiallyCollapsed) setOpen(open);
72
+ }
73
+ cancelGestureRef.current = cancelGesture;
74
+ function updateCollapse(cursorWidth) {
75
+ const shouldCollapse = collapsible !== "none" && cursorWidth < minWidth;
76
+ if (shouldCollapse !== collapsedDuringDrag) {
77
+ collapsedDuringDrag = shouldCollapse;
78
+ setOpen(!shouldCollapse);
79
+ }
80
+ return shouldCollapse;
81
+ }
82
+ function movePointer(pointer) {
83
+ if (pointer.pointerId !== pointerId) return;
84
+ const withinClickDistance = Math.abs(pointer.clientX - startX) <= DRAG_THRESHOLD_PX;
85
+ if (!draggedRef.current && withinClickDistance) return;
86
+ draggedRef.current = true;
87
+ document.body.style.cursor = "col-resize";
88
+ document.body.style.userSelect = "none";
89
+ wrapper.setAttribute("data-resizing", "true");
90
+ handle.setAttribute("data-resizing", "true");
91
+ const cursorWidth = side === "left" ? pointer.clientX - wrapperBounds.left : wrapperBounds.right - pointer.clientX;
92
+ if (updateCollapse(cursorWidth)) return;
93
+ draftWidth = clampWidth(cursorWidth);
94
+ wrapper.style.setProperty("--sidebar-width", `${draftWidth}px`);
95
+ }
96
+ function finishPointer(pointer) {
97
+ if (pointer.pointerId !== pointerId) return;
98
+ endGesture();
99
+ restoreWidth();
100
+ if (draggedRef.current && !collapsedDuringDrag) setWidth(draftWidth);
101
+ }
102
+ function cancelPointer(pointer) {
103
+ if (pointer.pointerId === pointerId) cancelGesture();
104
+ }
105
+ function cancelWithEscape(keyboard) {
106
+ if (keyboard.key !== "Escape") return;
107
+ keyboard.preventDefault();
108
+ cancelGesture();
109
+ }
110
+ window.addEventListener("pointermove", movePointer, { signal: controller.signal });
111
+ window.addEventListener("pointerup", finishPointer, { signal: controller.signal });
112
+ window.addEventListener("pointercancel", cancelPointer, { signal: controller.signal });
113
+ handle.addEventListener("lostpointercapture", cancelPointer, { signal: controller.signal });
114
+ window.addEventListener("blur", cancelGesture, { signal: controller.signal });
115
+ window.addEventListener("keydown", cancelWithEscape, { signal: controller.signal });
116
+ }
117
+ function handleClick(event) {
118
+ onClick?.(event);
119
+ if (event.defaultPrevented) return;
120
+ if (draggedRef.current) {
121
+ draggedRef.current = false;
122
+ return;
123
+ }
124
+ if (collapsible !== "none") toggleSidebar();
125
+ }
126
+ function resizeWithArrow(expand) {
127
+ if (isCollapsed) {
128
+ if (expand) setOpen(true);
129
+ return;
130
+ }
131
+ if (measuredWidth === void 0) return;
132
+ setWidth(clampWidth(measuredWidth + (expand ? KEYBOARD_STEP_PX : -10)));
133
+ }
134
+ function expandToWidth(nextWidth) {
135
+ if (collapsible !== "none") setOpen(true);
136
+ setWidth(nextWidth);
137
+ }
138
+ function handleKeyDown(event) {
139
+ onKeyDown?.(event);
140
+ if (event.defaultPrevented) return;
141
+ switch (event.key) {
142
+ case "Enter":
143
+ case " ":
144
+ event.preventDefault();
145
+ if (collapsible !== "none") toggleSidebar();
146
+ return;
147
+ case "Home":
148
+ case "End":
149
+ event.preventDefault();
150
+ expandToWidth(event.key === "Home" ? minWidth : maxWidth);
151
+ return;
152
+ case "ArrowLeft":
153
+ case "ArrowRight":
154
+ event.preventDefault();
155
+ resizeWithArrow(event.key === (side === "left" ? "ArrowRight" : "ArrowLeft"));
156
+ return;
157
+ }
158
+ }
159
+ const isCollapsed = !open && collapsible !== "none";
160
+ const widthDescription = measuredWidth === void 0 ? void 0 : `${measuredWidth} pixels`;
161
+ return useRender({
162
+ defaultTagName: "div",
163
+ ref: [ref ?? null, railRef],
164
+ props: {
165
+ ...props,
166
+ role: "separator",
167
+ "aria-orientation": "vertical",
168
+ "aria-label": props["aria-label"] ?? "Resize sidebar",
169
+ "aria-valuenow": isCollapsed ? 0 : measuredWidth,
170
+ "aria-valuemin": collapsible === "none" ? minWidth : 0,
171
+ "aria-valuemax": maxWidth,
172
+ "aria-valuetext": isCollapsed ? "collapsed" : widthDescription,
173
+ tabIndex: 0,
174
+ "data-control-ui": "sidebar",
175
+ "data-control-family": "sidebar",
176
+ "data-slot": "rail",
177
+ "data-resizable": "",
178
+ "data-resize-ready": measuredWidth === void 0 ? void 0 : "",
179
+ onPointerDown: handlePointerDown,
180
+ onClick: handleClick,
181
+ onKeyDown: handleKeyDown,
182
+ className: cn("absolute inset-y-0 z-20 hidden cursor-col-resize touch-pan-y outline-hidden group-data-[side=left]:-right-1 group-data-[side=right]:-left-1 group-data-[side=left]:group-data-[collapsible=offcanvas]:-right-2 group-data-[side=right]:group-data-[collapsible=offcanvas]:-left-2 lg:block", className),
183
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
184
+ ref: widthMeasureRef,
185
+ "aria-hidden": true,
186
+ className: "pointer-events-none invisible absolute w-(--sidebar-width)"
187
+ }), props.children] })
188
+ }
189
+ });
190
+ }
191
+ //#endregion
192
+ export { SidebarResizeRail };
@@ -1,31 +1,37 @@
1
1
  import { Button } from "./button.js";
2
2
  import { SidebarKnobStyle } from "../knob-contracts/sidebar-knobs.js";
3
+ import { SidebarLayout } from "../skin.js";
3
4
  import { SidebarGroup, SidebarGroupContent, SidebarGroupContentProps, SidebarGroupLabel, SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, SidebarMenuActionProps, SidebarMenuButton, SidebarMenuButtonProps, SidebarMenuButtonSize, SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarSelectionIndicator, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
4
5
  import { SidebarProvider, SidebarProviderProps, SidebarStyle, useSidebar } from "./sidebar-provider.js";
6
+ import { SidebarResizeRailProps } from "./sidebar-resize-rail.js";
5
7
  import { CSSProperties, ComponentProps } from "react";
6
8
  //#region src/ui/sidebar.d.ts
7
- type SidebarRailProps = Omit<ComponentProps<"button">, "style"> & {
9
+ export type SidebarRailProps = (Omit<ComponentProps<"button">, "style"> & {
10
+ resizable?: false;
8
11
  style?: CSSProperties & SidebarKnobStyle;
9
- };
10
- type SidebarInsetProps = Omit<ComponentProps<"main">, "style"> & {
12
+ }) | (SidebarResizeRailProps & {
13
+ resizable: true;
14
+ });
15
+ export type SidebarInsetProps = Omit<ComponentProps<"main">, "style"> & {
11
16
  style?: CSSProperties & SidebarKnobStyle;
12
17
  };
13
18
  type SidebarSurfaceStyle = CSSProperties & SidebarKnobStyle;
14
- declare function Sidebar({ side, variant, collapsible, ref, className, children, style, ...props }: Omit<ComponentProps<"div">, "style"> & {
19
+ export type SidebarProps = Omit<ComponentProps<"div">, "style"> & {
15
20
  side?: "left" | "right";
16
- variant?: "sidebar" | "floating" | "inset";
21
+ variant?: SidebarLayout;
17
22
  collapsible?: "offcanvas" | "icon" | "none";
18
23
  style?: SidebarSurfaceStyle;
19
- }): import("react").JSX.Element;
20
- declare function SidebarTrigger({ className, onClick, size, ...props }: ComponentProps<typeof Button>): import("react").JSX.Element;
21
- declare function SidebarRail({ className, ...props }: SidebarRailProps): import("react").JSX.Element;
22
- declare function SidebarInset({ className, ...props }: SidebarInsetProps): import("react").JSX.Element;
23
- declare function SidebarHeader({ className, ...props }: ComponentProps<"div"> & {
24
+ };
25
+ export declare function Sidebar({ side, collapsible, ...props }: SidebarProps): import("react").JSX.Element;
26
+ export declare function SidebarTrigger({ className, onClick, size, ref, ...props }: ComponentProps<typeof Button>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
27
+ export declare function SidebarRail(props: SidebarRailProps): any;
28
+ export declare function SidebarInset({ className, ...props }: SidebarInsetProps): import("react").JSX.Element;
29
+ export declare function SidebarHeader({ className, ...props }: ComponentProps<"div"> & {
24
30
  style?: CSSProperties & SidebarKnobStyle;
25
31
  }): import("react").JSX.Element;
26
- declare function SidebarFooter({ className, ...props }: ComponentProps<"div"> & {
32
+ export declare function SidebarFooter({ className, ...props }: ComponentProps<"div"> & {
27
33
  style?: CSSProperties & SidebarKnobStyle;
28
34
  }): import("react").JSX.Element;
29
- declare function SidebarContent({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
35
+ export declare function SidebarContent({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
30
36
  //#endregion
31
- export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, type SidebarGroupContentProps, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarHeader, SidebarInset, SidebarInsetProps, SidebarMenu, SidebarMenuAction, type SidebarMenuActionProps, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarRailProps, type SidebarSelectionIndicator, type SidebarStyle, SidebarTrigger, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
37
+ export { SidebarGroup, SidebarGroupContent, type SidebarGroupContentProps, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, type SidebarMenuActionProps, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarProvider, type SidebarProviderProps, type SidebarSelectionIndicator, type SidebarStyle, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };