@archytechtor/ui 0.0.0-stage → 0.1.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 (449) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -2
  3. package/dist/components/accordion/accordion.d.ts +25 -0
  4. package/dist/components/accordion/accordion.js +88 -0
  5. package/dist/components/accordion/index.d.ts +3 -0
  6. package/dist/components/accordion/index.js +1 -0
  7. package/dist/components/accordion/types.d.ts +39 -0
  8. package/dist/components/alert/alert.d.ts +25 -0
  9. package/dist/components/alert/alert.js +59 -0
  10. package/dist/components/alert/index.d.ts +3 -0
  11. package/dist/components/alert/index.js +3 -0
  12. package/dist/components/alert/types.d.ts +32 -0
  13. package/dist/components/alert/types.js +19 -0
  14. package/dist/components/alert-dialog/alert-dialog.d.ts +73 -0
  15. package/dist/components/alert-dialog/alert-dialog.js +170 -0
  16. package/dist/components/alert-dialog/index.d.ts +3 -0
  17. package/dist/components/alert-dialog/index.js +1 -0
  18. package/dist/components/alert-dialog/types.d.ts +80 -0
  19. package/dist/components/aspect-ratio/aspect-ratio.d.ts +8 -0
  20. package/dist/components/aspect-ratio/aspect-ratio.js +20 -0
  21. package/dist/components/aspect-ratio/index.d.ts +3 -0
  22. package/dist/components/aspect-ratio/index.js +1 -0
  23. package/dist/components/aspect-ratio/types.d.ts +8 -0
  24. package/dist/components/attachment/attachment.d.ts +57 -0
  25. package/dist/components/attachment/attachment.js +139 -0
  26. package/dist/components/attachment/index.d.ts +3 -0
  27. package/dist/components/attachment/index.js +3 -0
  28. package/dist/components/attachment/types.d.ts +79 -0
  29. package/dist/components/attachment/types.js +43 -0
  30. package/dist/components/avatar/avatar.d.ts +39 -0
  31. package/dist/components/avatar/avatar.js +88 -0
  32. package/dist/components/avatar/index.d.ts +3 -0
  33. package/dist/components/avatar/index.js +3 -0
  34. package/dist/components/avatar/types.d.ts +54 -0
  35. package/dist/components/avatar/types.js +21 -0
  36. package/dist/components/badge/badge.d.ts +7 -0
  37. package/dist/components/badge/badge.js +23 -0
  38. package/dist/components/badge/index.d.ts +3 -0
  39. package/dist/components/badge/index.js +3 -0
  40. package/dist/components/badge/types.d.ts +21 -0
  41. package/dist/components/badge/types.js +26 -0
  42. package/dist/components/breadcrumb/breadcrumb.d.ts +43 -0
  43. package/dist/components/breadcrumb/breadcrumb.js +115 -0
  44. package/dist/components/breadcrumb/index.d.ts +3 -0
  45. package/dist/components/breadcrumb/index.js +1 -0
  46. package/dist/components/breadcrumb/types.d.ts +36 -0
  47. package/dist/components/bubble/bubble.d.ts +25 -0
  48. package/dist/components/bubble/bubble.js +69 -0
  49. package/dist/components/bubble/index.d.ts +3 -0
  50. package/dist/components/bubble/index.js +3 -0
  51. package/dist/components/bubble/types.d.ts +51 -0
  52. package/dist/components/bubble/types.js +60 -0
  53. package/dist/components/button/button.d.ts +7 -0
  54. package/dist/components/button/button.js +155 -0
  55. package/dist/components/button/index.d.ts +4 -0
  56. package/dist/components/button/index.js +4 -0
  57. package/dist/components/button/types.d.ts +80 -0
  58. package/dist/components/button/types.js +99 -0
  59. package/dist/components/button/use-hold-to-confirm.d.ts +25 -0
  60. package/dist/components/button/use-hold-to-confirm.js +161 -0
  61. package/dist/components/button-group/button-group.d.ts +20 -0
  62. package/dist/components/button-group/button-group.js +62 -0
  63. package/dist/components/button-group/index.d.ts +3 -0
  64. package/dist/components/button-group/index.js +3 -0
  65. package/dist/components/button-group/types.d.ts +30 -0
  66. package/dist/components/button-group/types.js +19 -0
  67. package/dist/components/calendar/calendar.d.ts +15 -0
  68. package/dist/components/calendar/calendar.js +157 -0
  69. package/dist/components/calendar/index.d.ts +3 -0
  70. package/dist/components/calendar/index.js +1 -0
  71. package/dist/components/calendar/types.d.ts +21 -0
  72. package/dist/components/card/card.d.ts +43 -0
  73. package/dist/components/card/card.js +97 -0
  74. package/dist/components/card/index.d.ts +3 -0
  75. package/dist/components/card/index.js +3 -0
  76. package/dist/components/card/types.d.ts +44 -0
  77. package/dist/components/card/types.js +19 -0
  78. package/dist/components/carousel/carousel.d.ts +36 -0
  79. package/dist/components/carousel/carousel.js +190 -0
  80. package/dist/components/carousel/index.d.ts +3 -0
  81. package/dist/components/carousel/index.js +1 -0
  82. package/dist/components/carousel/types.d.ts +79 -0
  83. package/dist/components/chart/chart.d.ts +35 -0
  84. package/dist/components/chart/chart.js +212 -0
  85. package/dist/components/chart/index.d.ts +3 -0
  86. package/dist/components/chart/index.js +1 -0
  87. package/dist/components/chart/types.d.ts +89 -0
  88. package/dist/components/chart/types.js +7 -0
  89. package/dist/components/checkbox/checkbox.d.ts +7 -0
  90. package/dist/components/checkbox/checkbox.js +31 -0
  91. package/dist/components/checkbox/index.d.ts +3 -0
  92. package/dist/components/checkbox/index.js +1 -0
  93. package/dist/components/checkbox/types.d.ts +25 -0
  94. package/dist/components/code-block/code-block.d.ts +49 -0
  95. package/dist/components/code-block/code-block.js +188 -0
  96. package/dist/components/code-block/highlighter.d.ts +15 -0
  97. package/dist/components/code-block/highlighter.js +123 -0
  98. package/dist/components/code-block/index.d.ts +5 -0
  99. package/dist/components/code-block/index.js +5 -0
  100. package/dist/components/code-block/types.d.ts +94 -0
  101. package/dist/components/code-block/types.js +38 -0
  102. package/dist/components/code-block/use-highlighted-code.d.ts +9 -0
  103. package/dist/components/code-block/use-highlighted-code.js +67 -0
  104. package/dist/components/collapsible/collapsible.d.ts +19 -0
  105. package/dist/components/collapsible/collapsible.js +44 -0
  106. package/dist/components/collapsible/index.d.ts +3 -0
  107. package/dist/components/collapsible/index.js +1 -0
  108. package/dist/components/collapsible/types.d.ts +26 -0
  109. package/dist/components/combobox/combobox.d.ts +104 -0
  110. package/dist/components/combobox/combobox.js +365 -0
  111. package/dist/components/combobox/index.d.ts +3 -0
  112. package/dist/components/combobox/index.js +1 -0
  113. package/dist/components/combobox/types.d.ts +229 -0
  114. package/dist/components/command/command.d.ts +55 -0
  115. package/dist/components/command/command.js +179 -0
  116. package/dist/components/command/index.d.ts +3 -0
  117. package/dist/components/command/index.js +1 -0
  118. package/dist/components/command/types.d.ts +69 -0
  119. package/dist/components/context-menu/context-menu.d.ts +92 -0
  120. package/dist/components/context-menu/context-menu.js +270 -0
  121. package/dist/components/context-menu/index.d.ts +3 -0
  122. package/dist/components/context-menu/index.js +1 -0
  123. package/dist/components/context-menu/types.d.ts +138 -0
  124. package/dist/components/data-table/data-table-features.d.ts +21 -0
  125. package/dist/components/data-table/data-table-features.js +22 -0
  126. package/dist/components/data-table/data-table.d.ts +69 -0
  127. package/dist/components/data-table/data-table.js +283 -0
  128. package/dist/components/data-table/index.d.ts +4 -0
  129. package/dist/components/data-table/index.js +3 -0
  130. package/dist/components/data-table/types.d.ts +63 -0
  131. package/dist/components/date-input/date-input.d.ts +7 -0
  132. package/dist/components/date-input/date-input.js +147 -0
  133. package/dist/components/date-input/index.d.ts +3 -0
  134. package/dist/components/date-input/index.js +1 -0
  135. package/dist/components/date-input/types.d.ts +27 -0
  136. package/dist/components/date-picker/date-picker.d.ts +7 -0
  137. package/dist/components/date-picker/date-picker.js +74 -0
  138. package/dist/components/date-picker/index.d.ts +3 -0
  139. package/dist/components/date-picker/index.js +1 -0
  140. package/dist/components/date-picker/types.d.ts +38 -0
  141. package/dist/components/date-range-picker/date-range-picker.d.ts +7 -0
  142. package/dist/components/date-range-picker/date-range-picker.js +89 -0
  143. package/dist/components/date-range-picker/index.d.ts +3 -0
  144. package/dist/components/date-range-picker/index.js +1 -0
  145. package/dist/components/date-range-picker/types.d.ts +43 -0
  146. package/dist/components/dialog/dialog.d.ts +61 -0
  147. package/dist/components/dialog/dialog.js +160 -0
  148. package/dist/components/dialog/index.d.ts +3 -0
  149. package/dist/components/dialog/index.js +1 -0
  150. package/dist/components/dialog/types.d.ts +68 -0
  151. package/dist/components/drawer/drawer.d.ts +69 -0
  152. package/dist/components/drawer/drawer.js +245 -0
  153. package/dist/components/drawer/index.d.ts +3 -0
  154. package/dist/components/drawer/index.js +1 -0
  155. package/dist/components/drawer/types.d.ts +93 -0
  156. package/dist/components/dropdown-menu/dropdown-menu.d.ts +92 -0
  157. package/dist/components/dropdown-menu/dropdown-menu.js +268 -0
  158. package/dist/components/dropdown-menu/index.d.ts +3 -0
  159. package/dist/components/dropdown-menu/index.js +1 -0
  160. package/dist/components/dropdown-menu/types.d.ts +143 -0
  161. package/dist/components/empty/empty.d.ts +37 -0
  162. package/dist/components/empty/empty.js +84 -0
  163. package/dist/components/empty/index.d.ts +3 -0
  164. package/dist/components/empty/index.js +3 -0
  165. package/dist/components/empty/types.d.ts +39 -0
  166. package/dist/components/empty/types.js +13 -0
  167. package/dist/components/expanded-card/expanded-card.d.ts +43 -0
  168. package/dist/components/expanded-card/expanded-card.js +352 -0
  169. package/dist/components/expanded-card/index.d.ts +3 -0
  170. package/dist/components/expanded-card/index.js +1 -0
  171. package/dist/components/expanded-card/types.d.ts +52 -0
  172. package/dist/components/field/field.d.ts +62 -0
  173. package/dist/components/field/field.js +173 -0
  174. package/dist/components/field/index.d.ts +3 -0
  175. package/dist/components/field/index.js +3 -0
  176. package/dist/components/field/types.d.ts +81 -0
  177. package/dist/components/field/types.js +21 -0
  178. package/dist/components/form/form.d.ts +49 -0
  179. package/dist/components/form/form.js +136 -0
  180. package/dist/components/form/index.d.ts +3 -0
  181. package/dist/components/form/index.js +1 -0
  182. package/dist/components/form/types.d.ts +59 -0
  183. package/dist/components/hover-card/hover-card.d.ts +19 -0
  184. package/dist/components/hover-card/hover-card.js +63 -0
  185. package/dist/components/hover-card/index.d.ts +3 -0
  186. package/dist/components/hover-card/index.js +1 -0
  187. package/dist/components/hover-card/types.d.ts +27 -0
  188. package/dist/components/image-gallery/image-gallery.d.ts +8 -0
  189. package/dist/components/image-gallery/image-gallery.js +294 -0
  190. package/dist/components/image-gallery/index.d.ts +4 -0
  191. package/dist/components/image-gallery/index.js +3 -0
  192. package/dist/components/image-gallery/masonry.d.ts +11 -0
  193. package/dist/components/image-gallery/masonry.js +62 -0
  194. package/dist/components/image-gallery/types.d.ts +80 -0
  195. package/dist/components/input/index.d.ts +3 -0
  196. package/dist/components/input/index.js +1 -0
  197. package/dist/components/input/input.d.ts +7 -0
  198. package/dist/components/input/input.js +18 -0
  199. package/dist/components/input/types.d.ts +28 -0
  200. package/dist/components/input-group/index.d.ts +3 -0
  201. package/dist/components/input-group/index.js +3 -0
  202. package/dist/components/input-group/input-group.d.ts +37 -0
  203. package/dist/components/input-group/input-group.js +103 -0
  204. package/dist/components/input-group/types.d.ts +64 -0
  205. package/dist/components/input-group/types.js +31 -0
  206. package/dist/components/input-otp/index.d.ts +3 -0
  207. package/dist/components/input-otp/index.js +1 -0
  208. package/dist/components/input-otp/input-otp.d.ts +25 -0
  209. package/dist/components/input-otp/input-otp.js +76 -0
  210. package/dist/components/input-otp/types.d.ts +43 -0
  211. package/dist/components/item/index.d.ts +3 -0
  212. package/dist/components/item/index.js +3 -0
  213. package/dist/components/item/item.d.ts +61 -0
  214. package/dist/components/item/item.js +149 -0
  215. package/dist/components/item/types.d.ts +75 -0
  216. package/dist/components/item/types.js +48 -0
  217. package/dist/components/kbd/index.d.ts +3 -0
  218. package/dist/components/kbd/index.js +1 -0
  219. package/dist/components/kbd/kbd.d.ts +13 -0
  220. package/dist/components/kbd/kbd.js +30 -0
  221. package/dist/components/kbd/types.d.ts +9 -0
  222. package/dist/components/label/index.d.ts +3 -0
  223. package/dist/components/label/index.js +1 -0
  224. package/dist/components/label/label.d.ts +7 -0
  225. package/dist/components/label/label.js +17 -0
  226. package/dist/components/label/types.d.ts +8 -0
  227. package/dist/components/loader/index.d.ts +3 -0
  228. package/dist/components/loader/index.js +3 -0
  229. package/dist/components/loader/loader.d.ts +8 -0
  230. package/dist/components/loader/loader.js +386 -0
  231. package/dist/components/loader/types.d.ts +27 -0
  232. package/dist/components/loader/types.js +58 -0
  233. package/dist/components/marker/index.d.ts +3 -0
  234. package/dist/components/marker/index.js +3 -0
  235. package/dist/components/marker/marker.d.ts +19 -0
  236. package/dist/components/marker/marker.js +51 -0
  237. package/dist/components/marker/types.d.ts +30 -0
  238. package/dist/components/marker/types.js +16 -0
  239. package/dist/components/menubar/index.d.ts +3 -0
  240. package/dist/components/menubar/index.js +1 -0
  241. package/dist/components/menubar/menubar.d.ts +98 -0
  242. package/dist/components/menubar/menubar.js +284 -0
  243. package/dist/components/menubar/types.d.ts +146 -0
  244. package/dist/components/message/index.d.ts +3 -0
  245. package/dist/components/message/index.js +1 -0
  246. package/dist/components/message/message.d.ts +37 -0
  247. package/dist/components/message/message.js +83 -0
  248. package/dist/components/message/types.d.ts +32 -0
  249. package/dist/components/message-scroller/index.d.ts +4 -0
  250. package/dist/components/message-scroller/index.js +3 -0
  251. package/dist/components/message-scroller/message-scroller-primitive.d.ts +21 -0
  252. package/dist/components/message-scroller/message-scroller-primitive.js +1349 -0
  253. package/dist/components/message-scroller/message-scroller.d.ts +39 -0
  254. package/dist/components/message-scroller/message-scroller.js +103 -0
  255. package/dist/components/message-scroller/types.d.ts +107 -0
  256. package/dist/components/money-input/index.d.ts +3 -0
  257. package/dist/components/money-input/index.js +1 -0
  258. package/dist/components/money-input/money-input.d.ts +7 -0
  259. package/dist/components/money-input/money-input.js +143 -0
  260. package/dist/components/money-input/types.d.ts +20 -0
  261. package/dist/components/morph-image/index.d.ts +3 -0
  262. package/dist/components/morph-image/index.js +3 -0
  263. package/dist/components/morph-image/morph-image.d.ts +8 -0
  264. package/dist/components/morph-image/morph-image.js +155 -0
  265. package/dist/components/morph-image/types.d.ts +38 -0
  266. package/dist/components/morph-image/types.js +18 -0
  267. package/dist/components/native-select/index.d.ts +3 -0
  268. package/dist/components/native-select/index.js +3 -0
  269. package/dist/components/native-select/native-select.d.ts +20 -0
  270. package/dist/components/native-select/native-select.js +57 -0
  271. package/dist/components/native-select/types.d.ts +52 -0
  272. package/dist/components/native-select/types.js +23 -0
  273. package/dist/components/navigation-menu/index.d.ts +3 -0
  274. package/dist/components/navigation-menu/index.js +3 -0
  275. package/dist/components/navigation-menu/navigation-menu.d.ts +50 -0
  276. package/dist/components/navigation-menu/navigation-menu.js +145 -0
  277. package/dist/components/navigation-menu/types.d.ts +79 -0
  278. package/dist/components/navigation-menu/types.js +15 -0
  279. package/dist/components/number-stepper/index.d.ts +3 -0
  280. package/dist/components/number-stepper/index.js +3 -0
  281. package/dist/components/number-stepper/number-stepper.d.ts +9 -0
  282. package/dist/components/number-stepper/number-stepper.js +223 -0
  283. package/dist/components/number-stepper/types.d.ts +47 -0
  284. package/dist/components/number-stepper/types.js +174 -0
  285. package/dist/components/pagination/index.d.ts +3 -0
  286. package/dist/components/pagination/index.js +1 -0
  287. package/dist/components/pagination/pagination.d.ts +43 -0
  288. package/dist/components/pagination/pagination.js +121 -0
  289. package/dist/components/pagination/types.d.ts +37 -0
  290. package/dist/components/phone-input/index.d.ts +3 -0
  291. package/dist/components/phone-input/index.js +1 -0
  292. package/dist/components/phone-input/phone-input.d.ts +7 -0
  293. package/dist/components/phone-input/phone-input.js +54 -0
  294. package/dist/components/phone-input/types.d.ts +12 -0
  295. package/dist/components/popover/index.d.ts +3 -0
  296. package/dist/components/popover/index.js +1 -0
  297. package/dist/components/popover/popover.d.ts +37 -0
  298. package/dist/components/popover/popover.js +100 -0
  299. package/dist/components/popover/types.d.ts +51 -0
  300. package/dist/components/progress/index.d.ts +3 -0
  301. package/dist/components/progress/index.js +1 -0
  302. package/dist/components/progress/progress.d.ts +32 -0
  303. package/dist/components/progress/progress.js +100 -0
  304. package/dist/components/progress/types.d.ts +31 -0
  305. package/dist/components/questionnaire/index.d.ts +3 -0
  306. package/dist/components/questionnaire/index.js +1 -0
  307. package/dist/components/questionnaire/questionnaire-primitive.js +1563 -0
  308. package/dist/components/questionnaire/questionnaire.d.ts +91 -0
  309. package/dist/components/questionnaire/questionnaire.js +315 -0
  310. package/dist/components/questionnaire/types.d.ts +203 -0
  311. package/dist/components/radio-group/index.d.ts +3 -0
  312. package/dist/components/radio-group/index.js +1 -0
  313. package/dist/components/radio-group/radio-group.d.ts +13 -0
  314. package/dist/components/radio-group/radio-group.js +44 -0
  315. package/dist/components/radio-group/types.d.ts +33 -0
  316. package/dist/components/reorder-list/index.d.ts +3 -0
  317. package/dist/components/reorder-list/index.js +1 -0
  318. package/dist/components/reorder-list/reorder-list.d.ts +19 -0
  319. package/dist/components/reorder-list/reorder-list.js +279 -0
  320. package/dist/components/reorder-list/types.d.ts +65 -0
  321. package/dist/components/resizable/index.d.ts +3 -0
  322. package/dist/components/resizable/index.js +1 -0
  323. package/dist/components/resizable/resizable.d.ts +19 -0
  324. package/dist/components/resizable/resizable.js +44 -0
  325. package/dist/components/resizable/types.d.ts +89 -0
  326. package/dist/components/scroll-area/index.d.ts +3 -0
  327. package/dist/components/scroll-area/index.js +1 -0
  328. package/dist/components/scroll-area/scroll-area.d.ts +13 -0
  329. package/dist/components/scroll-area/scroll-area.js +47 -0
  330. package/dist/components/scroll-area/types.d.ts +19 -0
  331. package/dist/components/select/index.d.ts +3 -0
  332. package/dist/components/select/index.js +1 -0
  333. package/dist/components/select/select.d.ts +61 -0
  334. package/dist/components/select/select.js +183 -0
  335. package/dist/components/select/types.d.ts +100 -0
  336. package/dist/components/separator/index.d.ts +3 -0
  337. package/dist/components/separator/index.js +1 -0
  338. package/dist/components/separator/separator.d.ts +7 -0
  339. package/dist/components/separator/separator.js +20 -0
  340. package/dist/components/separator/types.d.ts +9 -0
  341. package/dist/components/sheet/index.d.ts +3 -0
  342. package/dist/components/sheet/index.js +1 -0
  343. package/dist/components/sheet/sheet.d.ts +61 -0
  344. package/dist/components/sheet/sheet.js +155 -0
  345. package/dist/components/sheet/types.d.ts +69 -0
  346. package/dist/components/sidebar/index.d.ts +3 -0
  347. package/dist/components/sidebar/index.js +3 -0
  348. package/dist/components/sidebar/sidebar.d.ts +145 -0
  349. package/dist/components/sidebar/sidebar.js +550 -0
  350. package/dist/components/sidebar/types.d.ts +186 -0
  351. package/dist/components/sidebar/types.js +42 -0
  352. package/dist/components/sidebar/use-mobile.js +21 -0
  353. package/dist/components/skeleton/index.d.ts +3 -0
  354. package/dist/components/skeleton/index.js +1 -0
  355. package/dist/components/skeleton/skeleton.d.ts +8 -0
  356. package/dist/components/skeleton/skeleton.js +18 -0
  357. package/dist/components/skeleton/types.d.ts +5 -0
  358. package/dist/components/slider/index.d.ts +3 -0
  359. package/dist/components/slider/index.js +1 -0
  360. package/dist/components/slider/slider.d.ts +7 -0
  361. package/dist/components/slider/slider.js +106 -0
  362. package/dist/components/slider/types.d.ts +39 -0
  363. package/dist/components/spinner/index.d.ts +3 -0
  364. package/dist/components/spinner/index.js +1 -0
  365. package/dist/components/spinner/spinner.d.ts +7 -0
  366. package/dist/components/spinner/spinner.js +21 -0
  367. package/dist/components/spinner/types.d.ts +8 -0
  368. package/dist/components/switch/index.d.ts +3 -0
  369. package/dist/components/switch/index.js +3 -0
  370. package/dist/components/switch/switch.d.ts +7 -0
  371. package/dist/components/switch/switch.js +32 -0
  372. package/dist/components/switch/types.d.ts +37 -0
  373. package/dist/components/switch/types.js +23 -0
  374. package/dist/components/table/index.d.ts +3 -0
  375. package/dist/components/table/index.js +1 -0
  376. package/dist/components/table/table.d.ts +49 -0
  377. package/dist/components/table/table.js +112 -0
  378. package/dist/components/table/types.d.ts +33 -0
  379. package/dist/components/tabs/index.d.ts +3 -0
  380. package/dist/components/tabs/index.js +3 -0
  381. package/dist/components/tabs/tabs.d.ts +25 -0
  382. package/dist/components/tabs/tabs.js +81 -0
  383. package/dist/components/tabs/types.d.ts +61 -0
  384. package/dist/components/tabs/types.js +18 -0
  385. package/dist/components/textarea/index.d.ts +3 -0
  386. package/dist/components/textarea/index.js +1 -0
  387. package/dist/components/textarea/textarea.d.ts +7 -0
  388. package/dist/components/textarea/textarea.js +17 -0
  389. package/dist/components/textarea/types.d.ts +26 -0
  390. package/dist/components/toast/index.d.ts +3 -0
  391. package/dist/components/toast/index.js +1 -0
  392. package/dist/components/toast/toast.d.ts +63 -0
  393. package/dist/components/toast/toast.js +321 -0
  394. package/dist/components/toast/types.d.ts +120 -0
  395. package/dist/components/toggle/index.d.ts +3 -0
  396. package/dist/components/toggle/index.js +3 -0
  397. package/dist/components/toggle/toggle.d.ts +7 -0
  398. package/dist/components/toggle/toggle.js +32 -0
  399. package/dist/components/toggle/types.d.ts +35 -0
  400. package/dist/components/toggle/types.js +37 -0
  401. package/dist/components/toggle-group/index.d.ts +3 -0
  402. package/dist/components/toggle-group/index.js +1 -0
  403. package/dist/components/toggle-group/toggle-group.d.ts +13 -0
  404. package/dist/components/toggle-group/toggle-group.js +88 -0
  405. package/dist/components/toggle-group/types.d.ts +52 -0
  406. package/dist/components/tooltip/index.d.ts +3 -0
  407. package/dist/components/tooltip/index.js +1 -0
  408. package/dist/components/tooltip/tooltip.d.ts +25 -0
  409. package/dist/components/tooltip/tooltip.js +79 -0
  410. package/dist/components/tooltip/types.d.ts +48 -0
  411. package/dist/components/trace/index.d.ts +3 -0
  412. package/dist/components/trace/index.js +1 -0
  413. package/dist/components/trace/trace.d.ts +52 -0
  414. package/dist/components/trace/trace.js +132 -0
  415. package/dist/components/trace/types.d.ts +54 -0
  416. package/dist/components/typography/index.d.ts +3 -0
  417. package/dist/components/typography/index.js +3 -0
  418. package/dist/components/typography/types.d.ts +29 -0
  419. package/dist/components/typography/types.js +25 -0
  420. package/dist/components/typography/typography.d.ts +7 -0
  421. package/dist/components/typography/typography.js +40 -0
  422. package/dist/components/video-player/index.d.ts +6 -0
  423. package/dist/components/video-player/index.js +5 -0
  424. package/dist/components/video-player/types.d.ts +143 -0
  425. package/dist/components/video-player/use-video-player.js +319 -0
  426. package/dist/components/video-player/video-player-context.d.ts +45 -0
  427. package/dist/components/video-player/video-player-context.js +15 -0
  428. package/dist/components/video-player/video-player-controls.d.ts +38 -0
  429. package/dist/components/video-player/video-player-controls.js +226 -0
  430. package/dist/components/video-player/video-player-overlay.d.ts +13 -0
  431. package/dist/components/video-player/video-player-overlay.js +113 -0
  432. package/dist/components/video-player/video-player.d.ts +8 -0
  433. package/dist/components/video-player/video-player.js +139 -0
  434. package/dist/index.d.ts +244 -0
  435. package/dist/index.js +114 -0
  436. package/dist/lib/floating.d.ts +44 -0
  437. package/dist/lib/focus-source.js +51 -0
  438. package/dist/lib/format.d.ts +67 -0
  439. package/dist/lib/format.js +130 -0
  440. package/dist/lib/locale.d.ts +104 -0
  441. package/dist/lib/locale.js +103 -0
  442. package/dist/lib/part-props.d.ts +15 -0
  443. package/dist/lib/use-controllable-state.js +22 -0
  444. package/dist/lib/utils.d.ts +9 -0
  445. package/dist/lib/utils.js +16 -0
  446. package/dist/styles/index.css +126 -0
  447. package/dist/styles/theme.css +80 -0
  448. package/dist/styles/utilities.css +553 -0
  449. package/package.json +89 -3
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { cn } from "../../lib/utils.js";
3
+ import { CheckIcon, MinusIcon } from "lucide-react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Checkbox } from "@base-ui/react/checkbox";
6
+ // src/components/checkbox/checkbox.tsx
7
+ /**
8
+ * Флажок: отметить или снять отметку
9
+ * @param props - пропсы флажка
10
+ * @returns элемент с role=checkbox
11
+ */
12
+ function Checkbox$1({ className, onCheckedChange, ...props }) {
13
+ const classes = cn("peer", "relative", "flex", "size-4", "shrink-0", "items-center", "justify-center", "rounded-[4px]", "border", "border-input", "transition-colors", "outline-none", "group-has-disabled/field:opacity-50", "keyboard:group-has-[:focus-visible]/field-label:ring-0", "keyboard:group-has-[:focus-visible]/field-label:not-data-checked:border-input", "after:absolute", "after:-inset-x-3", "after:-inset-y-2", "focus-visible:border-ring", "focus-visible:ring-3", "focus-visible:ring-ring/50", "data-disabled:cursor-not-allowed", "data-disabled:opacity-50", "aria-invalid:border-destructive", "aria-invalid:ring-3", "aria-invalid:ring-destructive/20", "aria-invalid:aria-checked:border-primary", "aria-invalid:aria-[checked=mixed]:border-primary", "dark:bg-input/30", "dark:aria-invalid:border-destructive/50", "dark:aria-invalid:ring-destructive/40", "data-checked:border-primary", "data-checked:bg-primary", "data-checked:text-primary-foreground", "dark:data-checked:bg-primary", "keyboard:group-has-[:focus-visible]/field-label:data-checked:border-primary", "data-indeterminate:border-primary", "data-indeterminate:bg-primary", "data-indeterminate:text-primary-foreground", "dark:data-indeterminate:bg-primary", "keyboard:group-has-[:focus-visible]/field-label:data-indeterminate:border-primary", className);
14
+ /**
15
+ * Флажок переключили: наружу только состояние
16
+ * @param checked - отмечен ли
17
+ */
18
+ const handleCheckedChange = (checked) => onCheckedChange?.(checked);
19
+ return /* @__PURE__ */ jsx(Checkbox.Root, {
20
+ "data-slot": "checkbox",
21
+ className: classes,
22
+ onCheckedChange: handleCheckedChange,
23
+ ...props,
24
+ children: /* @__PURE__ */ jsxs(Checkbox.Indicator, {
25
+ "data-slot": "checkbox-indicator",
26
+ className: "group/checkbox-indicator grid place-content-center text-current transition-none [&>svg]:size-3.5",
27
+ children: [/* @__PURE__ */ jsx(CheckIcon, { className: "group-data-indeterminate/checkbox-indicator:hidden" }), /* @__PURE__ */ jsx(MinusIcon, { className: "hidden group-data-indeterminate/checkbox-indicator:block" })]
28
+ })
29
+ });
30
+ }
31
+ export { Checkbox$1 as Checkbox };
@@ -0,0 +1,3 @@
1
+ import { CheckboxPropsT } from "./types.js";
2
+ import { Checkbox } from "./checkbox.js";
3
+ export { Checkbox, type CheckboxPropsT };
@@ -0,0 +1 @@
1
+ export { Checkbox } from "./checkbox.js";
@@ -0,0 +1,25 @@
1
+ import { PartPropsT } from "../../lib/part-props.js";
2
+ import { Checkbox } from "@base-ui/react/checkbox";
3
+ /**
4
+ * Пропсы флажка
5
+ */
6
+ export type CheckboxPropsT = PartPropsT<Omit<Checkbox.Root.Props, 'onCheckedChange' | 'children'>> & {
7
+ /** Отмечен ли флажок — контролируемый режим, вместе с onCheckedChange */
8
+ checked?: boolean;
9
+ /** Отмечен ли флажок при первом рендере — неконтролируемый режим */
10
+ defaultChecked?: boolean;
11
+ /** Частично отмечен: черта вместо галочки, например у «выбрать все», когда выбрана часть */
12
+ indeterminate?: boolean;
13
+ /** Флажок отметили или сняли: новое состояние */
14
+ onCheckedChange?: (checked: boolean) => void;
15
+ /** Отключённое состояние: флажок не переключается */
16
+ disabled?: boolean;
17
+ /** Обязательное поле: форма не отправится, пока флажок не отмечен */
18
+ required?: boolean;
19
+ /** Имя поля при отправке формы */
20
+ name?: string;
21
+ /** Значение при отправке формы, по умолчанию on */
22
+ value?: string;
23
+ /** Ошибка: красная рамка и объявление скринридеру, что значение неверное */
24
+ 'aria-invalid'?: boolean;
25
+ };
@@ -0,0 +1,49 @@
1
+ import { CodeBlockActionsPropsT, CodeBlockContentPropsT, CodeBlockCopyButtonPropsT, CodeBlockFooterPropsT, CodeBlockHeaderPropsT, CodeBlockLinePropsT, CodeBlockPropsT, CodeBlockTitlePropsT } from "./types.js";
2
+ /**
3
+ * Блок кода: код или вывод терминала с шапкой и действиями
4
+ * @param props - пропсы блока
5
+ * @returns блок кода
6
+ */
7
+ export declare function CodeBlock({ className, variant, size, ...props }: CodeBlockPropsT): import("react").JSX.Element;
8
+ /**
9
+ * Шапка блока кода: заголовок и действия
10
+ * @param props - пропсы шапки
11
+ * @returns шапка
12
+ */
13
+ export declare function CodeBlockHeader({ className, ...props }: CodeBlockHeaderPropsT): import("react").JSX.Element;
14
+ /**
15
+ * Заголовок блока кода: имя файла, иконка
16
+ * @param props - пропсы заголовка
17
+ * @returns заголовок в одну строку
18
+ */
19
+ export declare function CodeBlockTitle({ className, ...props }: CodeBlockTitlePropsT): import("react").JSX.Element;
20
+ /**
21
+ * Действия блока кода: в шапке — справа, прямо в блоке — плавают в углу и появляются при наведении
22
+ * @param props - пропсы действий
23
+ * @returns блок действий
24
+ */
25
+ export declare function CodeBlockActions({ className, ...props }: CodeBlockActionsPropsT): import("react").JSX.Element;
26
+ /**
27
+ * Кнопка копирования: копирует value и на 2 секунды показывает галочку
28
+ * @param props - пропсы кнопки
29
+ * @returns кнопка и объявление для скринридера
30
+ */
31
+ export declare function CodeBlockCopyButton({ value, variant, size, copyLabel, copiedLabel, className, onClick, ...props }: CodeBlockCopyButtonPropsT): import("react").JSX.Element;
32
+ /**
33
+ * Содержимое блока кода: <pre> с прокруткой, фокусируется с клавиатуры для прокрутки стрелками
34
+ * @param props - пропсы содержимого
35
+ * @returns код
36
+ */
37
+ export declare function CodeBlockContent({ className, children, style, wrap, lineNumbers, startLine, ...props }: CodeBlockContentPropsT): import("react").JSX.Element;
38
+ /**
39
+ * Строка кода: номер строки и отметка изменения рисуются псевдоэлементами
40
+ * @param props - пропсы строки
41
+ * @returns строка
42
+ */
43
+ export declare function CodeBlockLine({ className, variant, children, ...props }: CodeBlockLinePropsT): import("react").JSX.Element;
44
+ /**
45
+ * Подвал блока кода: кнопка «Показать полностью», подпись
46
+ * @param props - пропсы подвала
47
+ * @returns подвал
48
+ */
49
+ export declare function CodeBlockFooter({ className, ...props }: CodeBlockFooterPropsT): import("react").JSX.Element;
@@ -0,0 +1,188 @@
1
+ "use client";
2
+ import { cn } from "../../lib/utils.js";
3
+ import { texts } from "../../lib/locale.js";
4
+ import { Button } from "../button/button.js";
5
+ import { codeBlockLineVariants, codeBlockVariants } from "./types.js";
6
+ import { CheckIcon, CopyIcon } from "lucide-react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { useEffect, useState } from "react";
9
+ // src/components/code-block/code-block.tsx
10
+ /** Сколько миллисекунд показывать отметку «Скопировано» */
11
+ const COPIED_TIMEOUT = 2e3;
12
+ /**
13
+ * Блок кода: код или вывод терминала с шапкой и действиями
14
+ * @param props - пропсы блока
15
+ * @returns блок кода
16
+ */
17
+ function CodeBlock({ className, variant = "default", size = "default", ...props }) {
18
+ const classes = cn(codeBlockVariants({ variant }), className);
19
+ return /* @__PURE__ */ jsx("div", {
20
+ "data-slot": "code-block",
21
+ "data-variant": variant,
22
+ "data-size": size,
23
+ className: classes,
24
+ ...props
25
+ });
26
+ }
27
+ /**
28
+ * Шапка блока кода: заголовок и действия
29
+ * @param props - пропсы шапки
30
+ * @returns шапка
31
+ */
32
+ function CodeBlockHeader({ className, ...props }) {
33
+ const classes = cn("flex", "min-w-0", "shrink-0", "items-center", "gap-2", "px-3", "pt-3", "text-muted-foreground", "*:has-[>[data-slot=code-block-title]]:min-w-0", "group-data-[variant=destructive]/code-block:text-destructive", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:pt-2.5", className);
34
+ return /* @__PURE__ */ jsx("div", {
35
+ "data-slot": "code-block-header",
36
+ className: classes,
37
+ ...props
38
+ });
39
+ }
40
+ /**
41
+ * Заголовок блока кода: имя файла, иконка
42
+ * @param props - пропсы заголовка
43
+ * @returns заголовок в одну строку
44
+ */
45
+ function CodeBlockTitle({ className, ...props }) {
46
+ const classes = cn("min-w-0", "truncate", "font-sans", "text-sm", "font-medium", "text-foreground", "group-data-[variant=destructive]/code-block:text-destructive", "group-data-[size=sm]/code-block:text-xs", "[&_svg]:pointer-events-none", "[&_svg]:inline-block", "[&_svg]:align-middle", "*:[svg]:me-1.5", "[&_svg:not([class*=size-])]:size-3.5", className);
47
+ return /* @__PURE__ */ jsx("div", {
48
+ "data-slot": "code-block-title",
49
+ className: classes,
50
+ ...props
51
+ });
52
+ }
53
+ /**
54
+ * Действия блока кода: в шапке — справа, прямо в блоке — плавают в углу и появляются при наведении
55
+ * @param props - пропсы действий
56
+ * @returns блок действий
57
+ */
58
+ function CodeBlockActions({ className, ...props }) {
59
+ const classes = cn("ms-auto", "-my-1", "-me-1.5", "flex", "shrink-0", "items-center", "gap-1", "[[data-slot=code-block]>&]:absolute", "[[data-slot=code-block]>&]:end-2", "[[data-slot=code-block]>&]:top-2", "[[data-slot=code-block]>&]:z-10", "[[data-slot=code-block]>&]:m-0", "[[data-slot=code-block]>&]:opacity-0", "[[data-slot=code-block]>&]:transition-opacity", "[[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100", "[[data-slot=code-block]>&]:group-hover/code-block:opacity-100", "[[data-slot=code-block]>&]:pointer-coarse:opacity-100", "group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5", "group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5", "[[data-slot=code-block]>&]:*:[button]:bg-background", "[[data-slot=code-block]>&]:*:[button]:ring-1", "[[data-slot=code-block]>&]:*:[button]:ring-foreground/10", className);
60
+ return /* @__PURE__ */ jsx("div", {
61
+ "data-slot": "code-block-actions",
62
+ className: classes,
63
+ ...props
64
+ });
65
+ }
66
+ /**
67
+ * Кнопка копирования: копирует value и на 2 секунды показывает галочку
68
+ * @param props - пропсы кнопки
69
+ * @returns кнопка и объявление для скринридера
70
+ */
71
+ function CodeBlockCopyButton({ value, variant = "ghost", size = "icon-xs", copyLabel = texts.copy, copiedLabel = texts.copied, className, onClick, ...props }) {
72
+ const [isCopied, setCopied] = useState(false);
73
+ useEffect(() => {
74
+ if (!isCopied) return;
75
+ const timeout = setTimeout(() => setCopied(false), COPIED_TIMEOUT);
76
+ return () => clearTimeout(timeout);
77
+ }, [isCopied]);
78
+ /**
79
+ * Нажатие: вызвать onClick и скопировать значение
80
+ * @param event - событие нажатия
81
+ */
82
+ const copyValue = (event) => {
83
+ onClick?.(event);
84
+ navigator.clipboard.writeText(value).then(() => setCopied(true)).catch(() => void 0);
85
+ };
86
+ const label = isCopied ? copiedLabel : copyLabel;
87
+ const announcement = isCopied ? copiedLabel : "";
88
+ const icon = isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {});
89
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
90
+ "data-slot": "code-block-copy-button",
91
+ "data-copied": isCopied || void 0,
92
+ variant,
93
+ size,
94
+ "aria-label": label,
95
+ className,
96
+ onClick: copyValue,
97
+ ...props,
98
+ children: icon
99
+ }), /* @__PURE__ */ jsx("span", {
100
+ "aria-live": "polite",
101
+ className: "sr-only",
102
+ children: announcement
103
+ })] });
104
+ }
105
+ /**
106
+ * Пустая ли строка: пустая строка хранит перевод строки, чтобы при копировании выделения
107
+ * пустые строки не терялись
108
+ * @param children - содержимое строки
109
+ * @returns true, если содержимого нет
110
+ */
111
+ function isEmptyLine(children) {
112
+ if (children === void 0 || children === null || children === "") return true;
113
+ return Array.isArray(children) && children.length === 0;
114
+ }
115
+ /**
116
+ * Разбить текст на строки кода, чтобы показать номера строк
117
+ * @param text - код
118
+ * @returns строки
119
+ */
120
+ function splitLines(text) {
121
+ const lines = [];
122
+ text.replace(/\n$/, "").split("\n").forEach((row, index) => {
123
+ lines.push(/* @__PURE__ */ jsx(CodeBlockLine, { children: row }, index));
124
+ });
125
+ return lines;
126
+ }
127
+ /**
128
+ * Содержимое блока кода: <pre> с прокруткой, фокусируется с клавиатуры для прокрутки стрелками
129
+ * @param props - пропсы содержимого
130
+ * @returns код
131
+ */
132
+ function CodeBlockContent({ className, children, style, wrap = false, lineNumbers = false, startLine = 1, ...props }) {
133
+ const classes = cn("min-h-0", "min-w-0", "overflow-auto", "px-3", "py-3", "text-start", "font-mono", "leading-relaxed", "outline-none", "scroll-fade-x", "[scrollbar-width:thin]", "data-wrap:scroll-fade-y", "data-wrap:wrap-break-word", "data-wrap:whitespace-pre-wrap", "group-has-data-[slot=code-block-header]/code-block:pt-2", "group-has-data-[slot=code-block-footer]/code-block:pb-2", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:py-2.5", "group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5", className);
134
+ const codeClasses = cn("grid", "min-h-lh", "min-w-max", "content-start", "in-data-numbered:grid-cols-[auto_1fr]", "in-data-wrap:min-w-0");
135
+ const counterReset = `line ${startLine - 1}`;
136
+ const content = lineNumbers && typeof children === "string" ? splitLines(children) : children;
137
+ return /* @__PURE__ */ jsx("pre", {
138
+ "data-slot": "code-block-content",
139
+ "data-wrap": wrap || void 0,
140
+ "data-numbered": lineNumbers || void 0,
141
+ tabIndex: 0,
142
+ style: {
143
+ counterReset,
144
+ ...style
145
+ },
146
+ className: classes,
147
+ ...props,
148
+ children: /* @__PURE__ */ jsx("code", {
149
+ "data-slot": "code-block-code",
150
+ className: codeClasses,
151
+ children: content
152
+ })
153
+ });
154
+ }
155
+ /**
156
+ * Строка кода: номер строки и отметка изменения рисуются псевдоэлементами
157
+ * @param props - пропсы строки
158
+ * @returns строка
159
+ */
160
+ function CodeBlockLine({ className, variant = "default", children, ...props }) {
161
+ const classes = cn(codeBlockLineVariants({ variant }), className);
162
+ const content = isEmptyLine(children) ? "\n" : children;
163
+ return /* @__PURE__ */ jsx("span", {
164
+ "data-slot": "code-block-line",
165
+ "data-variant": variant,
166
+ className: classes,
167
+ ...props,
168
+ children: /* @__PURE__ */ jsx("span", {
169
+ "data-slot": "code-block-line-content",
170
+ className: "min-w-0",
171
+ children: content
172
+ })
173
+ });
174
+ }
175
+ /**
176
+ * Подвал блока кода: кнопка «Показать полностью», подпись
177
+ * @param props - пропсы подвала
178
+ * @returns подвал
179
+ */
180
+ function CodeBlockFooter({ className, ...props }) {
181
+ const classes = cn("flex", "min-w-0", "shrink-0", "items-center", "gap-2", "px-3", "pb-3", "text-muted-foreground", "group-data-[size=sm]/code-block:px-2.5", "group-data-[size=sm]/code-block:pb-2.5", className);
182
+ return /* @__PURE__ */ jsx("div", {
183
+ "data-slot": "code-block-footer",
184
+ className: classes,
185
+ ...props
186
+ });
187
+ }
188
+ export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle };
@@ -0,0 +1,15 @@
1
+ import { CodeHighlighterI } from "./types.js";
2
+ import { ReactNode } from "react";
3
+ /**
4
+ * Загрузить язык и вернуть подсветку для него
5
+ * @param language - имя языка: ts, tsx, json, bash, ansi…
6
+ * @returns подсветка или null для языка не из списка
7
+ */
8
+ export declare function loadHighlighter(language: string): Promise<CodeHighlighterI | null>;
9
+ /**
10
+ * Подсветить код целиком
11
+ * @param code - код
12
+ * @param language - имя языка
13
+ * @returns по узлу React на строку или null для языка не из списка
14
+ */
15
+ export declare function highlightCode(code: string, language: string): Promise<ReactNode[] | null>;
@@ -0,0 +1,123 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createHighlighterCore } from "shiki/core";
3
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
4
+ // src/components/code-block/highlighter.tsx
5
+ /** Поддерживаемые языки: каждый загружается при первом использовании */
6
+ const languages = {
7
+ bash: () => import("shiki/langs/shellscript.mjs"),
8
+ css: () => import("shiki/langs/css.mjs"),
9
+ diff: () => import("shiki/langs/diff.mjs"),
10
+ html: () => import("shiki/langs/html.mjs"),
11
+ javascript: () => import("shiki/langs/javascript.mjs"),
12
+ json: () => import("shiki/langs/json.mjs"),
13
+ jsx: () => import("shiki/langs/jsx.mjs"),
14
+ markdown: () => import("shiki/langs/markdown.mjs"),
15
+ python: () => import("shiki/langs/python.mjs"),
16
+ sql: () => import("shiki/langs/sql.mjs"),
17
+ tsx: () => import("shiki/langs/tsx.mjs"),
18
+ typescript: () => import("shiki/langs/typescript.mjs"),
19
+ yaml: () => import("shiki/langs/yaml.mjs")
20
+ };
21
+ /** Другие имена языков */
22
+ const aliases = {
23
+ js: "javascript",
24
+ md: "markdown",
25
+ py: "python",
26
+ sh: "bash",
27
+ shell: "bash",
28
+ shellscript: "bash",
29
+ ts: "typescript",
30
+ yml: "yaml",
31
+ zsh: "bash"
32
+ };
33
+ let highlighterPromise;
34
+ /**
35
+ * Получить общий экземпляр shiki со светлой и тёмной темой
36
+ * @returns экземпляр shiki
37
+ */
38
+ function getHighlighter() {
39
+ highlighterPromise ??= createHighlighterCore({
40
+ themes: [import("shiki/themes/one-light.mjs"), import("shiki/themes/one-dark-pro.mjs")],
41
+ langs: [],
42
+ engine: createJavaScriptRegexEngine({ forgiving: true })
43
+ });
44
+ return highlighterPromise;
45
+ }
46
+ /**
47
+ * Найти язык по имени или псевдониму
48
+ * @param language - имя языка
49
+ * @returns язык, ansi или null, если язык не поддерживается
50
+ */
51
+ function getLanguage(language) {
52
+ const name = language.toLowerCase();
53
+ if (name === "ansi") return name;
54
+ if (name in languages) return name;
55
+ return aliases[name] ?? null;
56
+ }
57
+ /**
58
+ * Отрисовать строку токенов: цвет светлой и тёмной темы в CSS-переменных
59
+ * @param line - токены строки
60
+ * @returns узлы строки
61
+ */
62
+ function renderLine(line) {
63
+ const nodes = [];
64
+ line.forEach((token, index) => {
65
+ nodes.push(/* @__PURE__ */ jsx("span", {
66
+ style: token.htmlStyle,
67
+ className: "text-(--shiki-light) dark:text-(--shiki-dark)",
68
+ children: token.content
69
+ }, index));
70
+ });
71
+ return nodes;
72
+ }
73
+ /**
74
+ * Загрузить язык и вернуть подсветку для него
75
+ * @param language - имя языка: ts, tsx, json, bash, ansi…
76
+ * @returns подсветка или null для языка не из списка
77
+ */
78
+ async function loadHighlighter(language) {
79
+ const lang = getLanguage(language);
80
+ if (lang === null) return null;
81
+ const shiki = await getHighlighter();
82
+ if (lang !== "ansi" && !shiki.getLoadedLanguages().includes(lang)) await shiki.loadLanguage(languages[lang]);
83
+ /**
84
+ * Подсветить код
85
+ * @param code - код
86
+ * @param state - состояние грамматики, с которого продолжить
87
+ * @returns строки и состояние грамматики после последней
88
+ */
89
+ const highlight = (code, state) => {
90
+ /**
91
+ * Разбить текст на токены
92
+ * @param text - текст
93
+ * @returns строки токенов
94
+ */
95
+ const tokenize = (text) => shiki.codeToTokens(text, {
96
+ lang,
97
+ themes: {
98
+ light: "one-light",
99
+ dark: "one-dark-pro"
100
+ },
101
+ defaultColor: false,
102
+ grammarState: state
103
+ }).tokens;
104
+ const tokens = lang === "ansi" ? code.split("\n").flatMap((line) => tokenize(line)) : tokenize(code);
105
+ return {
106
+ lines: tokens.map(renderLine),
107
+ state: shiki.getLastGrammarState(tokens)
108
+ };
109
+ };
110
+ return { highlight };
111
+ }
112
+ /**
113
+ * Подсветить код целиком
114
+ * @param code - код
115
+ * @param language - имя языка
116
+ * @returns по узлу React на строку или null для языка не из списка
117
+ */
118
+ async function highlightCode(code, language) {
119
+ const highlighter = await loadHighlighter(language);
120
+ if (highlighter === null) return null;
121
+ return highlighter.highlight(code).lines;
122
+ }
123
+ export { highlightCode, loadHighlighter };
@@ -0,0 +1,5 @@
1
+ import { CodeBlockActionsPropsT, CodeBlockContentPropsT, CodeBlockCopyButtonPropsT, CodeBlockFooterPropsT, CodeBlockHeaderPropsT, CodeBlockLinePropsT, CodeBlockPropsT, CodeBlockTitlePropsT, CodeHighlighterI, HighlightResultI, codeBlockLineVariants, codeBlockVariants } from "./types.js";
2
+ import { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle } from "./code-block.js";
3
+ import { highlightCode, loadHighlighter } from "./highlighter.js";
4
+ import { useHighlightedCode } from "./use-highlighted-code.js";
5
+ export { CodeBlock, CodeBlockActions, type CodeBlockActionsPropsT, CodeBlockContent, type CodeBlockContentPropsT, CodeBlockCopyButton, type CodeBlockCopyButtonPropsT, CodeBlockFooter, type CodeBlockFooterPropsT, CodeBlockHeader, type CodeBlockHeaderPropsT, CodeBlockLine, type CodeBlockLinePropsT, type CodeBlockPropsT, CodeBlockTitle, type CodeBlockTitlePropsT, type CodeHighlighterI, type HighlightResultI, codeBlockLineVariants, codeBlockVariants, highlightCode, loadHighlighter, useHighlightedCode };
@@ -0,0 +1,5 @@
1
+ import { codeBlockLineVariants, codeBlockVariants } from "./types.js";
2
+ import { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle } from "./code-block.js";
3
+ import { highlightCode, loadHighlighter } from "./highlighter.js";
4
+ import { useHighlightedCode } from "./use-highlighted-code.js";
5
+ export { CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle, codeBlockLineVariants, codeBlockVariants, highlightCode, loadHighlighter, useHighlightedCode };
@@ -0,0 +1,94 @@
1
+ import { ButtonPropsT } from "../button/types.js";
2
+ import { VariantProps } from "class-variance-authority";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ import { GrammarState } from "shiki/core";
5
+ /**
6
+ * Стили блока кода: обычный или блок ошибки
7
+ */
8
+ export declare const codeBlockVariants: (props?: ({
9
+ variant?: "default" | "destructive" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ /**
12
+ * Стили строки кода: обычная, подсвеченная, добавленная или удалённая
13
+ */
14
+ export declare const codeBlockLineVariants: (props?: ({
15
+ variant?: "default" | "added" | "removed" | "highlighted" | null | undefined;
16
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
17
+ /**
18
+ * Вариант оформления блока кода
19
+ */
20
+ export type CodeBlockVariantsT = VariantProps<typeof codeBlockVariants>;
21
+ /**
22
+ * Вариант строки кода
23
+ */
24
+ export type CodeBlockLineVariantsT = VariantProps<typeof codeBlockLineVariants>;
25
+ /**
26
+ * Пропсы блока кода
27
+ */
28
+ export type CodeBlockPropsT = ComponentProps<'div'> & {
29
+ /** Оформление: default — обычный код, destructive — вывод ошибки */
30
+ variant?: CodeBlockVariantsT['variant'];
31
+ /** Размер: default или sm — мельче шрифт и отступы */
32
+ size?: 'default' | 'sm';
33
+ };
34
+ /**
35
+ * Пропсы шапки блока кода
36
+ */
37
+ export type CodeBlockHeaderPropsT = ComponentProps<'div'>;
38
+ /**
39
+ * Пропсы заголовка блока кода
40
+ */
41
+ export type CodeBlockTitlePropsT = ComponentProps<'div'>;
42
+ /**
43
+ * Пропсы действий блока кода
44
+ */
45
+ export type CodeBlockActionsPropsT = ComponentProps<'div'>;
46
+ /**
47
+ * Пропсы кнопки копирования
48
+ */
49
+ export type CodeBlockCopyButtonPropsT = ButtonPropsT & {
50
+ /** Текст, который копируется в буфер обмена */
51
+ value: string;
52
+ /** Подпись кнопки для скринридера, по умолчанию «Копировать» */
53
+ copyLabel?: string;
54
+ /** Подпись после копирования и объявление для скринридера, по умолчанию «Скопировано» */
55
+ copiedLabel?: string;
56
+ };
57
+ /**
58
+ * Пропсы содержимого блока кода
59
+ */
60
+ export type CodeBlockContentPropsT = ComponentProps<'pre'> & {
61
+ /** Переносить длинные строки вместо горизонтальной прокрутки */
62
+ wrap?: boolean;
63
+ /** Показывать номера строк */
64
+ lineNumbers?: boolean;
65
+ /** Номер первой строки, по умолчанию 1 */
66
+ startLine?: number;
67
+ };
68
+ /**
69
+ * Пропсы строки кода
70
+ */
71
+ export type CodeBlockLinePropsT = ComponentProps<'span'> & {
72
+ /** Оформление: default, highlighted — подсвечена, added — добавлена (+), removed — удалена (−) */
73
+ variant?: CodeBlockLineVariantsT['variant'];
74
+ };
75
+ /**
76
+ * Пропсы подвала блока кода
77
+ */
78
+ export type CodeBlockFooterPropsT = ComponentProps<'div'>;
79
+ /**
80
+ * Результат подсветки
81
+ * @property lines - по узлу React на строку
82
+ * @property state - состояние грамматики после последней строки: продолжить подсветку с того же места
83
+ */
84
+ export interface HighlightResultI {
85
+ lines: ReactNode[];
86
+ state?: GrammarState;
87
+ }
88
+ /**
89
+ * Подсветка для одного языка
90
+ * @property highlight - подсветить код, продолжая с состояния грамматики
91
+ */
92
+ export interface CodeHighlighterI {
93
+ highlight: (code: string, state?: GrammarState) => HighlightResultI;
94
+ }
@@ -0,0 +1,38 @@
1
+ import { cva } from "class-variance-authority";
2
+ // src/components/code-block/types.ts
3
+ /**
4
+ * Стили блока кода: обычный или блок ошибки
5
+ */
6
+ const codeBlockVariants = cva([
7
+ "group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm",
8
+ "data-[size=sm]:text-xs",
9
+ "keyboard:has-[>[data-slot=code-block-content]:focus-visible]:ring-3",
10
+ "keyboard:has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50"
11
+ ], {
12
+ variants: { variant: {
13
+ default: "bg-muted text-foreground ring-1 ring-foreground/5 dark:ring-foreground/10",
14
+ destructive: ["bg-destructive/5 text-destructive ring-1 ring-destructive/15", "dark:bg-destructive/10 dark:ring-destructive/20"]
15
+ } },
16
+ defaultVariants: { variant: "default" }
17
+ });
18
+ /**
19
+ * Стили строки кода: обычная, подсвеченная, добавленная или удалённая
20
+ */
21
+ const codeBlockLineVariants = cva([
22
+ "relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5",
23
+ "after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none",
24
+ "in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3",
25
+ "in-data-numbered:[counter-increment:line]",
26
+ "in-data-numbered:before:min-w-6 in-data-numbered:before:text-end in-data-numbered:before:text-muted-foreground",
27
+ "in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none",
28
+ "in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']"
29
+ ], {
30
+ variants: { variant: {
31
+ default: "",
32
+ added: "bg-foreground/5 after:content-['+']",
33
+ removed: "bg-destructive/10 after:text-destructive after:content-['−']",
34
+ highlighted: "bg-foreground/5"
35
+ } },
36
+ defaultVariants: { variant: "default" }
37
+ });
38
+ export { codeBlockLineVariants, codeBlockVariants };
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+ /**
3
+ * Подсветить код по строкам. Пока язык загружается — строки без подсветки.
4
+ * При потоковом коде подсвечиваются только новые строки, начиная с состояния последней
5
+ * @param value - код
6
+ * @param language - имя языка: ts, tsx, json, bash, ansi…
7
+ * @returns по узлу React на строку — для CodeBlockLine
8
+ */
9
+ export declare function useHighlightedCode(value: string, language: string): ReactNode[];