@senvenli/react 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 (636) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/action/button-group.d.ts +26 -0
  4. package/dist/action/button-group.js +12 -0
  5. package/dist/action/button-group.js.map +1 -0
  6. package/dist/action/button.d.ts +42 -0
  7. package/dist/action/button.js +58 -0
  8. package/dist/action/button.js.map +1 -0
  9. package/dist/action/close-button.d.ts +12 -0
  10. package/dist/action/close-button.js +13 -0
  11. package/dist/action/close-button.js.map +1 -0
  12. package/dist/action/copy-button.d.ts +21 -0
  13. package/dist/action/copy-button.js +38 -0
  14. package/dist/action/copy-button.js.map +1 -0
  15. package/dist/action/fab.d.ts +29 -0
  16. package/dist/action/fab.js +57 -0
  17. package/dist/action/fab.js.map +1 -0
  18. package/dist/action/files.d.ts +70 -0
  19. package/dist/action/files.js +156 -0
  20. package/dist/action/files.js.map +1 -0
  21. package/dist/action/index.d.ts +23 -0
  22. package/dist/action/index.js +16 -0
  23. package/dist/action/index.js.map +1 -0
  24. package/dist/action/language-names.d.ts +19 -0
  25. package/dist/action/language-names.js +79 -0
  26. package/dist/action/language-names.js.map +1 -0
  27. package/dist/action/language-switcher.d.ts +57 -0
  28. package/dist/action/language-switcher.js +53 -0
  29. package/dist/action/language-switcher.js.map +1 -0
  30. package/dist/action/link-button.d.ts +57 -0
  31. package/dist/action/link-button.js +48 -0
  32. package/dist/action/link-button.js.map +1 -0
  33. package/dist/action/link.d.ts +24 -0
  34. package/dist/action/link.js +18 -0
  35. package/dist/action/link.js.map +1 -0
  36. package/dist/action/pressable.d.ts +40 -0
  37. package/dist/action/pressable.js +65 -0
  38. package/dist/action/pressable.js.map +1 -0
  39. package/dist/action/styles.d.ts +60 -0
  40. package/dist/action/styles.js +109 -0
  41. package/dist/action/styles.js.map +1 -0
  42. package/dist/action/theme-script.d.ts +12 -0
  43. package/dist/action/theme-script.js +23 -0
  44. package/dist/action/theme-script.js.map +1 -0
  45. package/dist/action/theme-switcher.d.ts +43 -0
  46. package/dist/action/theme-switcher.js +260 -0
  47. package/dist/action/theme-switcher.js.map +1 -0
  48. package/dist/action/theme-toggle.d.ts +43 -0
  49. package/dist/action/theme-toggle.js +259 -0
  50. package/dist/action/theme-toggle.js.map +1 -0
  51. package/dist/action/toggle.d.ts +44 -0
  52. package/dist/action/toggle.js +28 -0
  53. package/dist/action/toggle.js.map +1 -0
  54. package/dist/action/touch-target.d.ts +9 -0
  55. package/dist/action/touch-target.js +14 -0
  56. package/dist/action/touch-target.js.map +1 -0
  57. package/dist/charts/axis-width.d.ts +186 -0
  58. package/dist/charts/axis-width.js +1262 -0
  59. package/dist/charts/axis-width.js.map +1 -0
  60. package/dist/charts/bar-public.d.ts +16 -0
  61. package/dist/charts/bar-public.js +16 -0
  62. package/dist/charts/bar-public.js.map +1 -0
  63. package/dist/charts/chart-parts.d.ts +136 -0
  64. package/dist/charts/chart-parts.js +160 -0
  65. package/dist/charts/chart-parts.js.map +1 -0
  66. package/dist/charts/core-charts.d.ts +157 -0
  67. package/dist/charts/core-charts.js +505 -0
  68. package/dist/charts/core-charts.js.map +1 -0
  69. package/dist/charts/index.d.ts +12 -0
  70. package/dist/charts/index.js +8 -0
  71. package/dist/charts/index.js.map +1 -0
  72. package/dist/charts/list-charts.d.ts +124 -0
  73. package/dist/charts/list-charts.js +308 -0
  74. package/dist/charts/list-charts.js.map +1 -0
  75. package/dist/charts/more-charts.d.ts +138 -0
  76. package/dist/charts/more-charts.js +284 -0
  77. package/dist/charts/more-charts.js.map +1 -0
  78. package/dist/charts/report-charts.d.ts +138 -0
  79. package/dist/charts/report-charts.js +370 -0
  80. package/dist/charts/report-charts.js.map +1 -0
  81. package/dist/charts/value-tick.d.ts +178 -0
  82. package/dist/charts/value-tick.js +240 -0
  83. package/dist/charts/value-tick.js.map +1 -0
  84. package/dist/collection/data-table-url-hook.d.ts +34 -0
  85. package/dist/collection/data-table-url-hook.js +70 -0
  86. package/dist/collection/data-table-url-hook.js.map +1 -0
  87. package/dist/collection/data-table-url.d.ts +30 -0
  88. package/dist/collection/data-table-url.js +48 -0
  89. package/dist/collection/data-table-url.js.map +1 -0
  90. package/dist/collection/data-table.d.ts +112 -0
  91. package/dist/collection/data-table.js +188 -0
  92. package/dist/collection/data-table.js.map +1 -0
  93. package/dist/collection/grid-list-public.d.ts +18 -0
  94. package/dist/collection/grid-list-public.js +19 -0
  95. package/dist/collection/grid-list-public.js.map +1 -0
  96. package/dist/collection/grid-list.d.ts +73 -0
  97. package/dist/collection/grid-list.js +46 -0
  98. package/dist/collection/grid-list.js.map +1 -0
  99. package/dist/collection/index.d.ts +14 -0
  100. package/dist/collection/index.js +8 -0
  101. package/dist/collection/index.js.map +1 -0
  102. package/dist/collection/list.d.ts +61 -0
  103. package/dist/collection/list.js +38 -0
  104. package/dist/collection/list.js.map +1 -0
  105. package/dist/collection/selection-checkbox.d.ts +5 -0
  106. package/dist/collection/selection-checkbox.js +13 -0
  107. package/dist/collection/selection-checkbox.js.map +1 -0
  108. package/dist/collection/table.d.ts +91 -0
  109. package/dist/collection/table.js +183 -0
  110. package/dist/collection/table.js.map +1 -0
  111. package/dist/collection/tree.d.ts +31 -0
  112. package/dist/collection/tree.js +22 -0
  113. package/dist/collection/tree.js.map +1 -0
  114. package/dist/color/color.d.ts +87 -0
  115. package/dist/color/color.js +200 -0
  116. package/dist/color/color.js.map +1 -0
  117. package/dist/color/contrast.d.ts +34 -0
  118. package/dist/color/contrast.js +44 -0
  119. package/dist/color/contrast.js.map +1 -0
  120. package/dist/color/index.d.ts +4 -0
  121. package/dist/color/index.js +5 -0
  122. package/dist/color/index.js.map +1 -0
  123. package/dist/date/calendar.d.ts +71 -0
  124. package/dist/date/calendar.js +291 -0
  125. package/dist/date/calendar.js.map +1 -0
  126. package/dist/date/fields.d.ts +174 -0
  127. package/dist/date/fields.js +250 -0
  128. package/dist/date/fields.js.map +1 -0
  129. package/dist/date/index.d.ts +7 -0
  130. package/dist/date/index.js +6 -0
  131. package/dist/date/index.js.map +1 -0
  132. package/dist/date/month-grid.d.ts +31 -0
  133. package/dist/date/month-grid.js +115 -0
  134. package/dist/date/month-grid.js.map +1 -0
  135. package/dist/date/pickers.d.ts +118 -0
  136. package/dist/date/pickers.js +176 -0
  137. package/dist/date/pickers.js.map +1 -0
  138. package/dist/date/public.d.ts +25 -0
  139. package/dist/date/public.js +24 -0
  140. package/dist/date/public.js.map +1 -0
  141. package/dist/date/segments.d.ts +153 -0
  142. package/dist/date/segments.js +433 -0
  143. package/dist/date/segments.js.map +1 -0
  144. package/dist/defaults.d.ts +74 -0
  145. package/dist/defaults.js +100 -0
  146. package/dist/defaults.js.map +1 -0
  147. package/dist/density.d.ts +2 -0
  148. package/dist/density.js +2 -0
  149. package/dist/density.js.map +1 -0
  150. package/dist/display/avatar.d.ts +29 -0
  151. package/dist/display/avatar.js +71 -0
  152. package/dist/display/avatar.js.map +1 -0
  153. package/dist/display/badge.d.ts +65 -0
  154. package/dist/display/badge.js +99 -0
  155. package/dist/display/badge.js.map +1 -0
  156. package/dist/display/card.d.ts +72 -0
  157. package/dist/display/card.js +91 -0
  158. package/dist/display/card.js.map +1 -0
  159. package/dist/display/carousel.d.ts +47 -0
  160. package/dist/display/carousel.js +214 -0
  161. package/dist/display/carousel.js.map +1 -0
  162. package/dist/display/description-list.d.ts +25 -0
  163. package/dist/display/description-list.js +36 -0
  164. package/dist/display/description-list.js.map +1 -0
  165. package/dist/display/icon-aliases.d.ts +1 -0
  166. package/dist/display/icon-aliases.js +259 -0
  167. package/dist/display/icon-aliases.js.map +1 -0
  168. package/dist/display/icon-names.d.ts +4 -0
  169. package/dist/display/icon-names.js +2 -0
  170. package/dist/display/icon-names.js.map +1 -0
  171. package/dist/display/icon.d.ts +51 -0
  172. package/dist/display/icon.js +96 -0
  173. package/dist/display/icon.js.map +1 -0
  174. package/dist/display/image-crop.d.ts +106 -0
  175. package/dist/display/image-crop.js +117 -0
  176. package/dist/display/image-crop.js.map +1 -0
  177. package/dist/display/image-cropper.d.ts +68 -0
  178. package/dist/display/image-cropper.js +284 -0
  179. package/dist/display/image-cropper.js.map +1 -0
  180. package/dist/display/image-viewer.d.ts +54 -0
  181. package/dist/display/image-viewer.js +84 -0
  182. package/dist/display/image-viewer.js.map +1 -0
  183. package/dist/display/image.d.ts +26 -0
  184. package/dist/display/image.js +17 -0
  185. package/dist/display/image.js.map +1 -0
  186. package/dist/display/index.d.ts +29 -0
  187. package/dist/display/index.js +16 -0
  188. package/dist/display/index.js.map +1 -0
  189. package/dist/display/iso-chip.d.ts +19 -0
  190. package/dist/display/iso-chip.js +21 -0
  191. package/dist/display/iso-chip.js.map +1 -0
  192. package/dist/display/kbd.d.ts +11 -0
  193. package/dist/display/kbd.js +33 -0
  194. package/dist/display/kbd.js.map +1 -0
  195. package/dist/display/lozenge.d.ts +30 -0
  196. package/dist/display/lozenge.js +55 -0
  197. package/dist/display/lozenge.js.map +1 -0
  198. package/dist/display/scroll-area.d.ts +29 -0
  199. package/dist/display/scroll-area.js +95 -0
  200. package/dist/display/scroll-area.js.map +1 -0
  201. package/dist/display/separator.d.ts +13 -0
  202. package/dist/display/separator.js +24 -0
  203. package/dist/display/separator.js.map +1 -0
  204. package/dist/display/stat.d.ts +35 -0
  205. package/dist/display/stat.js +41 -0
  206. package/dist/display/stat.js.map +1 -0
  207. package/dist/display/timeline.d.ts +44 -0
  208. package/dist/display/timeline.js +111 -0
  209. package/dist/display/timeline.js.map +1 -0
  210. package/dist/display/typography.d.ts +37 -0
  211. package/dist/display/typography.js +53 -0
  212. package/dist/display/typography.js.map +1 -0
  213. package/dist/display/visually-hidden.d.ts +14 -0
  214. package/dist/display/visually-hidden.js +10 -0
  215. package/dist/display/visually-hidden.js.map +1 -0
  216. package/dist/feedback/banner.d.ts +46 -0
  217. package/dist/feedback/banner.js +157 -0
  218. package/dist/feedback/banner.js.map +1 -0
  219. package/dist/feedback/cooldown.d.ts +17 -0
  220. package/dist/feedback/cooldown.js +59 -0
  221. package/dist/feedback/cooldown.js.map +1 -0
  222. package/dist/feedback/empty-state.d.ts +35 -0
  223. package/dist/feedback/empty-state.js +39 -0
  224. package/dist/feedback/empty-state.js.map +1 -0
  225. package/dist/feedback/index.d.ts +12 -0
  226. package/dist/feedback/index.js +11 -0
  227. package/dist/feedback/index.js.map +1 -0
  228. package/dist/feedback/meter.d.ts +33 -0
  229. package/dist/feedback/meter.js +42 -0
  230. package/dist/feedback/meter.js.map +1 -0
  231. package/dist/feedback/motion.d.ts +9 -0
  232. package/dist/feedback/motion.js +57 -0
  233. package/dist/feedback/motion.js.map +1 -0
  234. package/dist/feedback/progress.d.ts +39 -0
  235. package/dist/feedback/progress.js +68 -0
  236. package/dist/feedback/progress.js.map +1 -0
  237. package/dist/feedback/skeleton.d.ts +48 -0
  238. package/dist/feedback/skeleton.js +61 -0
  239. package/dist/feedback/skeleton.js.map +1 -0
  240. package/dist/feedback/spinner.d.ts +19 -0
  241. package/dist/feedback/spinner.js +29 -0
  242. package/dist/feedback/spinner.js.map +1 -0
  243. package/dist/feedback/status-dot.d.ts +23 -0
  244. package/dist/feedback/status-dot.js +37 -0
  245. package/dist/feedback/status-dot.js.map +1 -0
  246. package/dist/form/countries.d.ts +34 -0
  247. package/dist/form/countries.js +273 -0
  248. package/dist/form/countries.js.map +1 -0
  249. package/dist/form/data-attributes.d.ts +11 -0
  250. package/dist/form/data-attributes.js +22 -0
  251. package/dist/form/data-attributes.js.map +1 -0
  252. package/dist/form/field-parts.d.ts +113 -0
  253. package/dist/form/field-parts.js +178 -0
  254. package/dist/form/field-parts.js.map +1 -0
  255. package/dist/form/field.d.ts +36 -0
  256. package/dist/form/field.js +65 -0
  257. package/dist/form/field.js.map +1 -0
  258. package/dist/form/files.d.ts +70 -0
  259. package/dist/form/files.js +156 -0
  260. package/dist/form/files.js.map +1 -0
  261. package/dist/form/form.d.ts +40 -0
  262. package/dist/form/form.js +74 -0
  263. package/dist/form/form.js.map +1 -0
  264. package/dist/form/image-crop.d.ts +106 -0
  265. package/dist/form/image-crop.js +117 -0
  266. package/dist/form/image-crop.js.map +1 -0
  267. package/dist/form/image-cropper.d.ts +68 -0
  268. package/dist/form/image-cropper.js +284 -0
  269. package/dist/form/image-cropper.js.map +1 -0
  270. package/dist/form/index.d.ts +24 -0
  271. package/dist/form/index.js +15 -0
  272. package/dist/form/index.js.map +1 -0
  273. package/dist/form/input-group.d.ts +63 -0
  274. package/dist/form/input-group.js +63 -0
  275. package/dist/form/input-group.js.map +1 -0
  276. package/dist/form/input-otp.d.ts +35 -0
  277. package/dist/form/input-otp.js +83 -0
  278. package/dist/form/input-otp.js.map +1 -0
  279. package/dist/form/input.d.ts +36 -0
  280. package/dist/form/input.js +41 -0
  281. package/dist/form/input.js.map +1 -0
  282. package/dist/form/number-field.d.ts +84 -0
  283. package/dist/form/number-field.js +81 -0
  284. package/dist/form/number-field.js.map +1 -0
  285. package/dist/form/otp-field.d.ts +37 -0
  286. package/dist/form/otp-field.js +116 -0
  287. package/dist/form/otp-field.js.map +1 -0
  288. package/dist/form/password-field.d.ts +61 -0
  289. package/dist/form/password-field.js +61 -0
  290. package/dist/form/password-field.js.map +1 -0
  291. package/dist/form/phone-field.d.ts +104 -0
  292. package/dist/form/phone-field.js +275 -0
  293. package/dist/form/phone-field.js.map +1 -0
  294. package/dist/form/phone-paste.d.ts +24 -0
  295. package/dist/form/phone-paste.js +40 -0
  296. package/dist/form/phone-paste.js.map +1 -0
  297. package/dist/form/phone.d.ts +159 -0
  298. package/dist/form/phone.js +309 -0
  299. package/dist/form/phone.js.map +1 -0
  300. package/dist/form/search-field.d.ts +29 -0
  301. package/dist/form/search-field.js +23 -0
  302. package/dist/form/search-field.js.map +1 -0
  303. package/dist/form/styles.d.ts +31 -0
  304. package/dist/form/styles.js +43 -0
  305. package/dist/form/styles.js.map +1 -0
  306. package/dist/form/text-area.d.ts +70 -0
  307. package/dist/form/text-area.js +93 -0
  308. package/dist/form/text-area.js.map +1 -0
  309. package/dist/form/text-field.d.ts +131 -0
  310. package/dist/form/text-field.js +59 -0
  311. package/dist/form/text-field.js.map +1 -0
  312. package/dist/form/validation.d.ts +145 -0
  313. package/dist/form/validation.js +136 -0
  314. package/dist/form/validation.js.map +1 -0
  315. package/dist/i18n.d.ts +438 -0
  316. package/dist/i18n.js +948 -0
  317. package/dist/i18n.js.map +1 -0
  318. package/dist/index.d.ts +9 -0
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -0
  321. package/dist/intl-locale.d.ts +30 -0
  322. package/dist/intl-locale.js +83 -0
  323. package/dist/intl-locale.js.map +1 -0
  324. package/dist/layers.d.ts +32 -0
  325. package/dist/layers.js +33 -0
  326. package/dist/layers.js.map +1 -0
  327. package/dist/layout/auth-form-layout.d.ts +71 -0
  328. package/dist/layout/auth-form-layout.js +61 -0
  329. package/dist/layout/auth-form-layout.js.map +1 -0
  330. package/dist/layout/auth-layout.d.ts +59 -0
  331. package/dist/layout/auth-layout.js +26 -0
  332. package/dist/layout/auth-layout.js.map +1 -0
  333. package/dist/layout/box.d.ts +26 -0
  334. package/dist/layout/box.js +16 -0
  335. package/dist/layout/box.js.map +1 -0
  336. package/dist/layout/grid.d.ts +27 -0
  337. package/dist/layout/grid.js +26 -0
  338. package/dist/layout/grid.js.map +1 -0
  339. package/dist/layout/index.d.ts +16 -0
  340. package/dist/layout/index.js +12 -0
  341. package/dist/layout/index.js.map +1 -0
  342. package/dist/layout/pressable.d.ts +40 -0
  343. package/dist/layout/pressable.js +65 -0
  344. package/dist/layout/pressable.js.map +1 -0
  345. package/dist/layout/reset-sent-card.d.ts +39 -0
  346. package/dist/layout/reset-sent-card.js +22 -0
  347. package/dist/layout/reset-sent-card.js.map +1 -0
  348. package/dist/layout/scroll-area.d.ts +29 -0
  349. package/dist/layout/scroll-area.js +95 -0
  350. package/dist/layout/scroll-area.js.map +1 -0
  351. package/dist/layout/section.d.ts +41 -0
  352. package/dist/layout/section.js +22 -0
  353. package/dist/layout/section.js.map +1 -0
  354. package/dist/layout/split.d.ts +50 -0
  355. package/dist/layout/split.js +35 -0
  356. package/dist/layout/split.js.map +1 -0
  357. package/dist/layout/stack.d.ts +44 -0
  358. package/dist/layout/stack.js +36 -0
  359. package/dist/layout/stack.js.map +1 -0
  360. package/dist/layout/tokens.d.ts +33 -0
  361. package/dist/layout/tokens.js +85 -0
  362. package/dist/layout/tokens.js.map +1 -0
  363. package/dist/layout/toolbar.d.ts +37 -0
  364. package/dist/layout/toolbar.js +334 -0
  365. package/dist/layout/toolbar.js.map +1 -0
  366. package/dist/navigate-context.d.ts +12 -0
  367. package/dist/navigate-context.js +13 -0
  368. package/dist/navigate-context.js.map +1 -0
  369. package/dist/navigation/accordion.d.ts +40 -0
  370. package/dist/navigation/accordion.js +33 -0
  371. package/dist/navigation/accordion.js.map +1 -0
  372. package/dist/navigation/bottom-nav.d.ts +29 -0
  373. package/dist/navigation/bottom-nav.js +48 -0
  374. package/dist/navigation/bottom-nav.js.map +1 -0
  375. package/dist/navigation/brand-link-context.d.ts +8 -0
  376. package/dist/navigation/brand-link-context.js +9 -0
  377. package/dist/navigation/brand-link-context.js.map +1 -0
  378. package/dist/navigation/breadcrumbs.d.ts +36 -0
  379. package/dist/navigation/breadcrumbs.js +51 -0
  380. package/dist/navigation/breadcrumbs.js.map +1 -0
  381. package/dist/navigation/dock.d.ts +27 -0
  382. package/dist/navigation/dock.js +47 -0
  383. package/dist/navigation/dock.js.map +1 -0
  384. package/dist/navigation/footer.d.ts +43 -0
  385. package/dist/navigation/footer.js +43 -0
  386. package/dist/navigation/footer.js.map +1 -0
  387. package/dist/navigation/index.d.ts +22 -0
  388. package/dist/navigation/index.js +17 -0
  389. package/dist/navigation/index.js.map +1 -0
  390. package/dist/navigation/language-names.d.ts +19 -0
  391. package/dist/navigation/language-names.js +79 -0
  392. package/dist/navigation/language-names.js.map +1 -0
  393. package/dist/navigation/language-switcher.d.ts +55 -0
  394. package/dist/navigation/language-switcher.js +53 -0
  395. package/dist/navigation/language-switcher.js.map +1 -0
  396. package/dist/navigation/nav-panel.d.ts +18 -0
  397. package/dist/navigation/nav-panel.js +51 -0
  398. package/dist/navigation/nav-panel.js.map +1 -0
  399. package/dist/navigation/navbar.d.ts +73 -0
  400. package/dist/navigation/navbar.js +64 -0
  401. package/dist/navigation/navbar.js.map +1 -0
  402. package/dist/navigation/page-header.d.ts +37 -0
  403. package/dist/navigation/page-header.js +50 -0
  404. package/dist/navigation/page-header.js.map +1 -0
  405. package/dist/navigation/pagination.d.ts +25 -0
  406. package/dist/navigation/pagination.js +51 -0
  407. package/dist/navigation/pagination.js.map +1 -0
  408. package/dist/navigation/panel-header.d.ts +37 -0
  409. package/dist/navigation/panel-header.js +50 -0
  410. package/dist/navigation/panel-header.js.map +1 -0
  411. package/dist/navigation/sidebar-script.d.ts +12 -0
  412. package/dist/navigation/sidebar-script.js +20 -0
  413. package/dist/navigation/sidebar-script.js.map +1 -0
  414. package/dist/navigation/sidebar.d.ts +149 -0
  415. package/dist/navigation/sidebar.js +332 -0
  416. package/dist/navigation/sidebar.js.map +1 -0
  417. package/dist/navigation/skip-link.d.ts +12 -0
  418. package/dist/navigation/skip-link.js +30 -0
  419. package/dist/navigation/skip-link.js.map +1 -0
  420. package/dist/navigation/stepper.d.ts +50 -0
  421. package/dist/navigation/stepper.js +96 -0
  422. package/dist/navigation/stepper.js.map +1 -0
  423. package/dist/navigation/tabs.d.ts +84 -0
  424. package/dist/navigation/tabs.js +118 -0
  425. package/dist/navigation/tabs.js.map +1 -0
  426. package/dist/navigation/toolbar.d.ts +37 -0
  427. package/dist/navigation/toolbar.js +334 -0
  428. package/dist/navigation/toolbar.js.map +1 -0
  429. package/dist/overlay/alert-dialog.d.ts +63 -0
  430. package/dist/overlay/alert-dialog.js +76 -0
  431. package/dist/overlay/alert-dialog.js.map +1 -0
  432. package/dist/overlay/command-palette.d.ts +53 -0
  433. package/dist/overlay/command-palette.js +130 -0
  434. package/dist/overlay/command-palette.js.map +1 -0
  435. package/dist/overlay/command.d.ts +53 -0
  436. package/dist/overlay/command.js +129 -0
  437. package/dist/overlay/command.js.map +1 -0
  438. package/dist/overlay/context-menu.d.ts +29 -0
  439. package/dist/overlay/context-menu.js +58 -0
  440. package/dist/overlay/context-menu.js.map +1 -0
  441. package/dist/overlay/dialog.d.ts +162 -0
  442. package/dist/overlay/dialog.js +174 -0
  443. package/dist/overlay/dialog.js.map +1 -0
  444. package/dist/overlay/drawer.d.ts +41 -0
  445. package/dist/overlay/drawer.js +114 -0
  446. package/dist/overlay/drawer.js.map +1 -0
  447. package/dist/overlay/floating.d.ts +142 -0
  448. package/dist/overlay/floating.js +226 -0
  449. package/dist/overlay/floating.js.map +1 -0
  450. package/dist/overlay/hover-card.d.ts +19 -0
  451. package/dist/overlay/hover-card.js +31 -0
  452. package/dist/overlay/hover-card.js.map +1 -0
  453. package/dist/overlay/index.d.ts +18 -0
  454. package/dist/overlay/index.js +12 -0
  455. package/dist/overlay/index.js.map +1 -0
  456. package/dist/overlay/overlay-base.d.ts +105 -0
  457. package/dist/overlay/overlay-base.js +250 -0
  458. package/dist/overlay/overlay-base.js.map +1 -0
  459. package/dist/overlay/overlay.d.ts +299 -0
  460. package/dist/overlay/overlay.js +558 -0
  461. package/dist/overlay/overlay.js.map +1 -0
  462. package/dist/overlay/toast.d.ts +58 -0
  463. package/dist/overlay/toast.js +145 -0
  464. package/dist/overlay/toast.js.map +1 -0
  465. package/dist/provider.d.ts +26 -0
  466. package/dist/provider.js +30 -0
  467. package/dist/provider.js.map +1 -0
  468. package/dist/selection/autocomplete.d.ts +54 -0
  469. package/dist/selection/autocomplete.js +122 -0
  470. package/dist/selection/autocomplete.js.map +1 -0
  471. package/dist/selection/checkbox.d.ts +56 -0
  472. package/dist/selection/checkbox.js +49 -0
  473. package/dist/selection/checkbox.js.map +1 -0
  474. package/dist/selection/choice-size.d.ts +26 -0
  475. package/dist/selection/choice-size.js +50 -0
  476. package/dist/selection/choice-size.js.map +1 -0
  477. package/dist/selection/choice-text.d.ts +21 -0
  478. package/dist/selection/choice-text.js +33 -0
  479. package/dist/selection/choice-text.js.map +1 -0
  480. package/dist/selection/combobox.d.ts +173 -0
  481. package/dist/selection/combobox.js +410 -0
  482. package/dist/selection/combobox.js.map +1 -0
  483. package/dist/selection/index.d.ts +20 -0
  484. package/dist/selection/index.js +13 -0
  485. package/dist/selection/index.js.map +1 -0
  486. package/dist/selection/list-box.d.ts +30 -0
  487. package/dist/selection/list-box.js +16 -0
  488. package/dist/selection/list-box.js.map +1 -0
  489. package/dist/selection/listbox.d.ts +44 -0
  490. package/dist/selection/listbox.js +49 -0
  491. package/dist/selection/listbox.js.map +1 -0
  492. package/dist/selection/match.d.ts +20 -0
  493. package/dist/selection/match.js +57 -0
  494. package/dist/selection/match.js.map +1 -0
  495. package/dist/selection/multi-select.d.ts +72 -0
  496. package/dist/selection/multi-select.js +138 -0
  497. package/dist/selection/multi-select.js.map +1 -0
  498. package/dist/selection/radio-card.d.ts +31 -0
  499. package/dist/selection/radio-card.js +29 -0
  500. package/dist/selection/radio-card.js.map +1 -0
  501. package/dist/selection/radio.d.ts +72 -0
  502. package/dist/selection/radio.js +64 -0
  503. package/dist/selection/radio.js.map +1 -0
  504. package/dist/selection/select-public.d.ts +19 -0
  505. package/dist/selection/select-public.js +24 -0
  506. package/dist/selection/select-public.js.map +1 -0
  507. package/dist/selection/select.d.ts +72 -0
  508. package/dist/selection/select.js +69 -0
  509. package/dist/selection/select.js.map +1 -0
  510. package/dist/selection/slider.d.ts +16 -0
  511. package/dist/selection/slider.js +44 -0
  512. package/dist/selection/slider.js.map +1 -0
  513. package/dist/selection/styles.d.ts +26 -0
  514. package/dist/selection/styles.js +78 -0
  515. package/dist/selection/styles.js.map +1 -0
  516. package/dist/selection/switch.d.ts +24 -0
  517. package/dist/selection/switch.js +27 -0
  518. package/dist/selection/switch.js.map +1 -0
  519. package/dist/selection/tag-group.d.ts +38 -0
  520. package/dist/selection/tag-group.js +45 -0
  521. package/dist/selection/tag-group.js.map +1 -0
  522. package/dist/tone.d.ts +6 -0
  523. package/dist/tone.js +2 -0
  524. package/dist/tone.js.map +1 -0
  525. package/dist/utils.d.ts +9 -0
  526. package/dist/utils.js +42 -0
  527. package/dist/utils.js.map +1 -0
  528. package/manifest/component.full.schema.json +391 -0
  529. package/manifest/component.schema.json +279 -0
  530. package/manifests/accordion.json +299 -0
  531. package/manifests/alert-dialog.json +261 -0
  532. package/manifests/area-chart.json +338 -0
  533. package/manifests/autocomplete.json +299 -0
  534. package/manifests/avatar.json +253 -0
  535. package/manifests/badge.json +288 -0
  536. package/manifests/banner.json +185 -0
  537. package/manifests/bar-chart.json +454 -0
  538. package/manifests/bar-list.json +262 -0
  539. package/manifests/bottom-nav.json +139 -0
  540. package/manifests/box.json +3450 -0
  541. package/manifests/breadcrumbs.json +199 -0
  542. package/manifests/button-group.json +2294 -0
  543. package/manifests/button.json +1211 -0
  544. package/manifests/calendar-heatmap.json +218 -0
  545. package/manifests/calendar.json +299 -0
  546. package/manifests/card.json +308 -0
  547. package/manifests/carousel.json +263 -0
  548. package/manifests/chart-parts.json +309 -0
  549. package/manifests/checkbox.json +998 -0
  550. package/manifests/close-button.json +1000 -0
  551. package/manifests/color-field.json +276 -0
  552. package/manifests/color-picker.json +161 -0
  553. package/manifests/color-swatch-picker.json +220 -0
  554. package/manifests/color-swatch.json +140 -0
  555. package/manifests/combobox.json +581 -0
  556. package/manifests/command.json +275 -0
  557. package/manifests/composed-chart.json +287 -0
  558. package/manifests/context-menu.json +148 -0
  559. package/manifests/copy-button.json +192 -0
  560. package/manifests/data-table.json +334 -0
  561. package/manifests/date-field.json +302 -0
  562. package/manifests/date-picker.json +472 -0
  563. package/manifests/description-list.json +201 -0
  564. package/manifests/dialog.json +322 -0
  565. package/manifests/donut-chart.json +264 -0
  566. package/manifests/drawer.json +211 -0
  567. package/manifests/empty-state.json +185 -0
  568. package/manifests/fab.json +172 -0
  569. package/manifests/field.json +209 -0
  570. package/manifests/file-upload.json +791 -0
  571. package/manifests/form.json +829 -0
  572. package/manifests/funnel-chart.json +223 -0
  573. package/manifests/gauge-chart.json +252 -0
  574. package/manifests/grid-list.json +335 -0
  575. package/manifests/grid.json +3482 -0
  576. package/manifests/heading.json +183 -0
  577. package/manifests/heatmap.json +265 -0
  578. package/manifests/hover-card.json +172 -0
  579. package/manifests/icon.json +201 -0
  580. package/manifests/image-cropper.json +295 -0
  581. package/manifests/image-viewer.json +198 -0
  582. package/manifests/image.json +193 -0
  583. package/manifests/index.json +2035 -0
  584. package/manifests/input-group.json +3571 -0
  585. package/manifests/input.json +1557 -0
  586. package/manifests/kbd.json +98 -0
  587. package/manifests/language-switcher.json +274 -0
  588. package/manifests/line-chart.json +342 -0
  589. package/manifests/link.json +867 -0
  590. package/manifests/list-box.json +213 -0
  591. package/manifests/menu.json +453 -0
  592. package/manifests/meter.json +145 -0
  593. package/manifests/navbar.json +281 -0
  594. package/manifests/otp-field.json +1029 -0
  595. package/manifests/page-header.json +164 -0
  596. package/manifests/pagination.json +181 -0
  597. package/manifests/popover.json +205 -0
  598. package/manifests/pressable.json +367 -0
  599. package/manifests/progress.json +282 -0
  600. package/manifests/radar-chart.json +229 -0
  601. package/manifests/radial-chart.json +195 -0
  602. package/manifests/radio.json +975 -0
  603. package/manifests/scatter-chart.json +277 -0
  604. package/manifests/scroll-area.json +127 -0
  605. package/manifests/section.json +169 -0
  606. package/manifests/select.json +474 -0
  607. package/manifests/separator.json +119 -0
  608. package/manifests/sidebar.json +584 -0
  609. package/manifests/skeleton.json +235 -0
  610. package/manifests/skip-link.json +89 -0
  611. package/manifests/slider.json +706 -0
  612. package/manifests/sparkline.json +208 -0
  613. package/manifests/spinner.json +105 -0
  614. package/manifests/split.json +6618 -0
  615. package/manifests/stack.json +3541 -0
  616. package/manifests/stat.json +192 -0
  617. package/manifests/stepper.json +279 -0
  618. package/manifests/switch.json +205 -0
  619. package/manifests/table.json +375 -0
  620. package/manifests/tabs.json +438 -0
  621. package/manifests/tag-group.json +264 -0
  622. package/manifests/text-area.json +1136 -0
  623. package/manifests/text.json +244 -0
  624. package/manifests/theme-switcher.json +152 -0
  625. package/manifests/time-field.json +284 -0
  626. package/manifests/timeline.json +196 -0
  627. package/manifests/toast.json +87 -0
  628. package/manifests/toggle-button.json +1489 -0
  629. package/manifests/toolbar.json +145 -0
  630. package/manifests/tooltip.json +181 -0
  631. package/manifests/tracker.json +192 -0
  632. package/manifests/tree.json +245 -0
  633. package/manifests/visually-hidden.json +114 -0
  634. package/package.json +117 -3
  635. package/styles/base.css +56 -0
  636. package/styles/theme.css +154 -0
@@ -0,0 +1,334 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Toolbar as AriaToolbar, useLocale } from "react-aria-components";
5
+ import { Button } from "../action/button.js";
6
+ import { clearSelectionLabel, selectedCountLabel } from "../i18n.js";
7
+ /**
8
+ * Controls that act on the view below it. One Tab stop: arrow keys move between the controls (mirrored
9
+ * in RTL). Put a `ToolbarSpacer` before the view and export controls to push them to the end.
10
+ * A text-editing control inside (a SearchField's input, a DateField's segments) keeps ←/→ for its caret
11
+ * and segments; at its edge (the caret at the start or end, the first or last segment) the arrow moves on
12
+ * to the next control, so every control stays reachable by the arrows. Arrowing into a date or time field
13
+ * lands on the segment nearest the way in: in RTL the visually nearest one, whatever the DOM order of its
14
+ * segments. A raw `type="number"` or
15
+ * `type="email"` input with a value has no readable caret and keeps ←/→ (Tab leaves it); prefer NumberField,
16
+ * or TextField with `inputMode`, inside a toolbar.
17
+ */
18
+ export function Toolbar({ children, "aria-label": label }) {
19
+ const ref = React.useRef(null);
20
+ const { toolbarProps } = useToolbarKeys(ref);
21
+ return (_jsx("div", { ref: ref, "data-slot": "toolbar", className: "flex flex-wrap items-center gap-ds-100 rounded-ds-large bg-ds-surface-raised px-ds-150 py-ds-100 shadow-ds-raised", "data-rac": "", "aria-label": label, ...toolbarProps, children: children }));
22
+ }
23
+ /*
24
+ * React Aria's Toolbar (react-aria-components) handles ←/→ in a capture listener on the toolbar and
25
+ * takes no key handler of its own, so it cannot leave the arrows to a text control inside it. This
26
+ * mirrors its useToolbar (horizontal): same role, arrows mirrored in RTL, no wrap, Tab leaving via the
27
+ * first/last control, focus restored on return. The one change: ←/→ on a text-editing target belong
28
+ * to that target until the caret or segment focus is at the target's edge in the arrow's direction.
29
+ */
30
+ // React Aria's focusable-element selector (isFocusable), so the arrows reach the same controls.
31
+ const FOCUSABLE = [
32
+ "input:not([disabled]):not([type=hidden])",
33
+ "select:not([disabled])",
34
+ "textarea:not([disabled])",
35
+ "button:not([disabled])",
36
+ "a[href]",
37
+ "area[href]",
38
+ "summary",
39
+ "iframe",
40
+ "object",
41
+ "embed",
42
+ "audio[controls]",
43
+ "video[controls]",
44
+ '[contenteditable]:not([contenteditable^="false"])',
45
+ "permission",
46
+ ]
47
+ .map((selector) => `${selector}:not([hidden])`)
48
+ .concat("[tabindex]:not([disabled]):not([hidden])")
49
+ .join(",");
50
+ /*
51
+ * React Aria's shadow-DOM-aware helpers (getActiveElement, nodeContains, getEventTarget in
52
+ * react-aria/private/utils/shadowdom) are not part of the public react-aria-components surface, and
53
+ * react-aria itself is not a dependency of this package, so they are mirrored here. React Aria only
54
+ * walks shadow roots when its shadowDOM flag is on; in the light DOM (the flag's default) these give
55
+ * exactly document.activeElement, Node.contains and event.target, as React Aria does.
56
+ */
57
+ function getActiveElement(doc = document) {
58
+ let active = doc.activeElement;
59
+ while (active?.shadowRoot?.activeElement)
60
+ active = active.shadowRoot.activeElement;
61
+ return active;
62
+ }
63
+ function nodeContains(node, other) {
64
+ if (!node || !other)
65
+ return false;
66
+ for (let current = other; current;) {
67
+ if (current === node)
68
+ return true;
69
+ const slot = current.assignedSlot;
70
+ // A slotted element continues from its slot (a slot itself walks up as usual).
71
+ if (typeof current.assignedElements !== "function" && slot?.parentNode)
72
+ current = slot.parentNode;
73
+ else if (current instanceof ShadowRoot)
74
+ current = current.host;
75
+ else
76
+ current = current.parentNode;
77
+ }
78
+ return false;
79
+ }
80
+ function getEventTarget(e) {
81
+ const target = e.target;
82
+ if (target instanceof Element && target.shadowRoot) {
83
+ const inner = e.nativeEvent.composedPath?.()[0];
84
+ if (inner instanceof Element)
85
+ return inner;
86
+ }
87
+ return target;
88
+ }
89
+ // Inputs that do not use ←/→ themselves: the toolbar always takes the arrows from them.
90
+ const ARROWLESS_INPUTS = new Set(["button", "submit", "reset", "checkbox", "image", "file", "color"]);
91
+ /*
92
+ * Inputs whose value ←/→ change, so the arrows always stay with them: React Aria's RadioGroup moves the
93
+ * selection between its radios and its Slider moves the thumb with ←/→ (no caret, so no edge).
94
+ */
95
+ const VALUE_ARROW_INPUTS = new Set(["radio", "range"]);
96
+ function isRtl(element, fallback) {
97
+ const computed = getComputedStyle(element).direction;
98
+ if (computed === "rtl" || computed === "ltr")
99
+ return computed === "rtl";
100
+ // jsdom resolves no `direction`; :dir() reads the dir attribute the same way the browser does.
101
+ try {
102
+ return element.matches(":dir(rtl)");
103
+ }
104
+ catch {
105
+ return fallback === "rtl";
106
+ }
107
+ }
108
+ /**
109
+ * The segment group (`role="group"`) of a date/time segment inside the toolbar, else undefined. Only
110
+ * segments step from their group: a text input is one element, and its group (the field frame) also holds
111
+ * controls of its own (a SearchField's clear button, InputActions) that the arrows should still reach.
112
+ */
113
+ function segmentGroup(target, toolbar) {
114
+ if (target.getAttribute("role") !== "spinbutton")
115
+ return undefined;
116
+ const group = target.closest('[role="group"]');
117
+ return group && group !== toolbar && toolbar.contains(group) ? group : undefined;
118
+ }
119
+ function isTabbable(element) {
120
+ return element.tabIndex >= 0;
121
+ }
122
+ /**
123
+ * True when the arrow key belongs to the target: a caret that can still move that way in a text input or
124
+ * textarea, a date/time segment with another segment that way, a radio or slider, or a contenteditable
125
+ * or textbox whose caret the toolbar cannot read. A non-collapsed selection always stays with the field.
126
+ * `direction` is the toolbar's (the locale's), as React Aria's date segments use it.
127
+ */
128
+ function keepsArrows(target, key, direction) {
129
+ const tag = target.tagName;
130
+ if (tag === "INPUT" || tag === "TEXTAREA") {
131
+ const field = target;
132
+ if (tag === "INPUT" && ARROWLESS_INPUTS.has(field.type))
133
+ return false;
134
+ if (tag === "INPUT" && VALUE_ARROW_INPUTS.has(field.type))
135
+ return true;
136
+ let start;
137
+ let end;
138
+ try {
139
+ start = field.selectionStart;
140
+ end = field.selectionEnd;
141
+ }
142
+ catch {
143
+ start = end = null;
144
+ }
145
+ /*
146
+ * number, email…: the browser exposes no caret (selectionStart is null), so the toolbar cannot tell
147
+ * an edge. Empty, there is no caret to move and the arrows move on; with a value the field keeps them,
148
+ * since taking them would leave no way to move the caret. Tab leaves such a field. The DS's own
149
+ * fields avoid this: NumberField is a text input, and TextField takes `inputMode` for e-mail.
150
+ */
151
+ if (start == null || end == null)
152
+ return field.value !== "";
153
+ if (start !== end)
154
+ return true;
155
+ // The caret's back key is ← in an LTR field and → in an RTL one: the field's own direction.
156
+ const back = isRtl(field, direction) ? key === "ArrowRight" : key === "ArrowLeft";
157
+ return back ? start > 0 : end < field.value.length;
158
+ }
159
+ const role = target.getAttribute("role");
160
+ if (role === "spinbutton") {
161
+ const group = target.closest('[role="group"]');
162
+ if (group)
163
+ return hasSegmentToward(group, target, key, direction);
164
+ return true;
165
+ }
166
+ if (role === "textbox" || role === "searchbox")
167
+ return true;
168
+ return target.closest('[contenteditable]:not([contenteditable^="false"])') != null;
169
+ }
170
+ /**
171
+ * Whether React Aria's date/time field would move to another segment for this arrow (useDatePickerGroup):
172
+ * in LTR the previous/next tabbable segment in DOM order; in RTL the nearest segment visually to that
173
+ * side (its bounding box), since RTL date and time segments are not laid out in DOM order.
174
+ */
175
+ function hasSegmentToward(group, segment, key, direction) {
176
+ const segments = Array.from(group.querySelectorAll(FOCUSABLE)).filter((element) => isTabbable(element) && isVisible(element));
177
+ if (direction === "rtl") {
178
+ const from = segment.getBoundingClientRect().x;
179
+ const sign = key === "ArrowRight" ? 1 : -1;
180
+ return segments.some((element) => element !== segment && Math.sign(element.getBoundingClientRect().x - from) === sign);
181
+ }
182
+ const index = segments.indexOf(segment);
183
+ if (index === -1)
184
+ return true;
185
+ return key === "ArrowLeft" ? index > 0 : index < segments.length - 1;
186
+ }
187
+ /**
188
+ * In RTL, the segment an arrow should land on when it moves INTO a date/time field: the one
189
+ * visually nearest the side focus enters from, by bounding box as `hasSegmentToward` reads it, since RTL
190
+ * segments need not be laid out in DOM order. A step toward the toolbar's end (`step` 1, ← in RTL) enters
191
+ * at the field's start side, the segment furthest toward the start; a step toward the start enters at its
192
+ * end side. Any other target, or segments without a layout (equal boxes), keep the DOM-order choice.
193
+ */
194
+ function entrySegment(next, toolbar, step) {
195
+ const group = segmentGroup(next, toolbar);
196
+ if (!group)
197
+ return next;
198
+ const segments = Array.from(group.querySelectorAll(FOCUSABLE)).filter((element) => isTabbable(element) && isVisible(element));
199
+ // In RTL the start side is the larger x: a step of 1 enters the field at its start side (largest x), -1 at its end side.
200
+ const enterAtStartSide = step === 1;
201
+ let best = next;
202
+ let bestX = next.getBoundingClientRect().x;
203
+ for (const element of segments) {
204
+ const x = element.getBoundingClientRect().x;
205
+ if (enterAtStartSide ? x > bestX : x < bestX) {
206
+ best = element;
207
+ bestX = x;
208
+ }
209
+ }
210
+ return best;
211
+ }
212
+ function isVisible(element) {
213
+ if (typeof element.checkVisibility === "function") {
214
+ return element.checkVisibility({ visibilityProperty: true }) && !element.closest("[data-react-aria-prevent-focus]");
215
+ }
216
+ for (let node = element; node; node = node.parentElement) {
217
+ if (node.hasAttribute("hidden") || node.hasAttribute("data-react-aria-prevent-focus"))
218
+ return false;
219
+ const { display, visibility } = getComputedStyle(node);
220
+ if (display === "none" || visibility === "hidden" || visibility === "collapse")
221
+ return false;
222
+ }
223
+ return true;
224
+ }
225
+ function focusables(root) {
226
+ return Array.from(root.querySelectorAll(FOCUSABLE)).filter((element) => !element.closest("[inert]") && isVisible(element));
227
+ }
228
+ function useToolbarKeys(ref) {
229
+ const { direction } = useLocale();
230
+ const [isInToolbar, setInToolbar] = React.useState(false);
231
+ React.useLayoutEffect(() => {
232
+ setInToolbar(!!ref.current?.parentElement?.closest('[role="toolbar"]'));
233
+ });
234
+ const lastFocused = React.useRef(null);
235
+ /*
236
+ * Moves to the next/previous control in DOM order from `from` (the focused element by default). `from` is
237
+ * a whole segment group when the arrow leaves a date/time field: the step starts after (or before) the
238
+ * group, never at a sibling segment, since in RTL the visual edge segment need not be the DOM-order edge
239
+ * (an `ar` TimeField or a `he-IL` date keeps DOM order; an `ar` date is reversed). Arrowing INTO such a
240
+ * field in RTL lands on its segment visually nearest the way in (`entrySegment`); LTR keeps DOM order.
241
+ * Plain focus(), as React Aria's focus manager does: the control scrolls into view.
242
+ */
243
+ const move = (step, from) => {
244
+ const root = ref.current;
245
+ if (!root)
246
+ return;
247
+ const all = focusables(root);
248
+ const active = from ?? getActiveElement();
249
+ let next;
250
+ if (!active || !nodeContains(root, active))
251
+ next = step === 1 ? all[0] : all[all.length - 1];
252
+ else if (step === 1) {
253
+ // FOLLOWING includes the group's own descendants: skip them.
254
+ next = all.find((el) => active.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING && !active.contains(el));
255
+ }
256
+ else
257
+ next = all.filter((el) => active.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING).pop();
258
+ // Into a date/time field in RTL: the segment nearest the side the arrow enters from, not the DOM-first one.
259
+ if (next && direction === "rtl")
260
+ next = entrySegment(next, root, step);
261
+ next?.focus();
262
+ };
263
+ const edge = (end) => {
264
+ const all = ref.current ? focusables(ref.current) : [];
265
+ (end === "first" ? all[0] : all[all.length - 1])?.focus();
266
+ };
267
+ const onKeyDownCapture = (e) => {
268
+ const target = getEventTarget(e);
269
+ // Portalled content (a popover opened from a control) is not the toolbar's.
270
+ if (!nodeContains(e.currentTarget, target))
271
+ return;
272
+ if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
273
+ if (keepsArrows(target, e.key, direction))
274
+ return;
275
+ const forward = e.key === "ArrowRight" ? 1 : -1;
276
+ move(direction === "rtl" ? -forward : forward, segmentGroup(target, e.currentTarget));
277
+ }
278
+ else if (e.key === "Tab") {
279
+ // Focus the first/last control and let the browser's Tab carry focus out from there.
280
+ lastFocused.current = getActiveElement();
281
+ edge(e.shiftKey ? "first" : "last");
282
+ return;
283
+ }
284
+ else
285
+ return;
286
+ // Keep nested action groups (and the field the arrow moved out of) from handling the arrows too.
287
+ e.stopPropagation();
288
+ e.preventDefault();
289
+ };
290
+ // Remember the control focus came from, and return to it when focus comes back into the toolbar.
291
+ const onBlurCapture = (e) => {
292
+ if (!nodeContains(e.currentTarget, e.relatedTarget) && !lastFocused.current)
293
+ lastFocused.current = getEventTarget(e);
294
+ };
295
+ const onFocusCapture = (e) => {
296
+ const last = lastFocused.current;
297
+ if (last && !nodeContains(e.currentTarget, e.relatedTarget) && nodeContains(ref.current, getEventTarget(e))) {
298
+ lastFocused.current = null;
299
+ last.focus?.();
300
+ }
301
+ };
302
+ return {
303
+ toolbarProps: {
304
+ role: isInToolbar ? "group" : "toolbar",
305
+ "aria-orientation": "horizontal",
306
+ "data-orientation": "horizontal",
307
+ onKeyDownCapture: isInToolbar ? undefined : onKeyDownCapture,
308
+ onFocusCapture: isInToolbar ? undefined : onFocusCapture,
309
+ onBlurCapture: isInToolbar ? undefined : onBlurCapture,
310
+ },
311
+ };
312
+ }
313
+ /** Pushes the controls after it to the toolbar's end. */
314
+ export function ToolbarSpacer() {
315
+ return _jsx("span", { "aria-hidden": true, "data-slot": "toolbar-spacer", className: "flex-1" });
316
+ }
317
+ /**
318
+ * Replaces the toolbar while rows are selected: the count, the bulk actions and a clear button, on
319
+ * `ds-background-neutral-bold`. One Tab stop with arrow keys inside, like the toolbar. Buttons in the bar
320
+ * are drawn transparent with inverse text whatever their variant: pass default (not primary) actions.
321
+ */
322
+ export function BulkBar({ selectedCount, actions, onClear, "aria-label": label }) {
323
+ const { locale } = useLocale();
324
+ const count = selectedCountLabel(locale, selectedCount);
325
+ const [spoken, setSpoken] = React.useState("");
326
+ React.useEffect(() => setSpoken(count), [count]);
327
+ return (_jsxs(AriaToolbar, { "aria-label": label, "data-slot": "bulk-bar", className: "flex flex-wrap items-center gap-ds-150 rounded-ds-large bg-ds-background-neutral-bold px-ds-150 py-ds-100 text-ds-text-inverse " +
328
+ // Buttons read on the dark bar: transparent with inverse text, the neutral pressed step on hover.
329
+ "[&_[data-slot=button]]:bg-transparent [&_[data-slot=button]]:text-ds-text-inverse " +
330
+ "[&_[data-slot=button][data-hovered]]:bg-ds-background-neutral-pressed [&_[data-slot=button][data-hovered]]:text-ds-text " +
331
+ "[&_[data-slot=button][data-pressed]]:bg-ds-background-neutral-pressed [&_[data-slot=button][data-pressed]]:text-ds-text " +
332
+ "[&_[data-slot=button][data-focus-visible]]:inset-ring-ds-text-inverse", children: [_jsx("span", { "data-slot": "bulk-bar-count", "aria-hidden": true, className: "text-body-strong tabular-nums", children: count }), _jsx("span", { "data-slot": "bulk-bar-announcer", role: "status", className: "sr-only", children: spoken }), actions, _jsx("span", { "aria-hidden": true, className: "flex-1" }), _jsx(Button, { size: "small", iconOnly: true, iconBefore: "x", "aria-label": clearSelectionLabel(locale), onPress: onClear })] }));
333
+ }
334
+ //# sourceMappingURL=toolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../src/navigation/toolbar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AASlE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,QA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ACvC,KAAC,MAAM,IAAC,IAAI,EAAC,OAAO,EAAC,QAAQ,QAAC,UAAU,EAAC,GAAG,gBAAa,mBAAmB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,GAAI,IAC9F,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Toolbar as AriaToolbar, useLocale } from \"react-aria-components\";\n\nimport { Button } from \"../action/button\";\nimport { clearSelectionLabel, selectedCountLabel } from \"../i18n\";\n\nexport type ToolbarProps = {\n /** Compact (32px) controls acting on the view below: search, filters, date range, view switch, export. */\n children: React.ReactNode;\n /** Names the toolbar (\"Order tools\"). */\n \"aria-label\": string;\n};\n\n/**\n * Controls that act on the view below it. One Tab stop: arrow keys move between the controls (mirrored\n * in RTL). Put a `ToolbarSpacer` before the view and export controls to push them to the end.\n * A text-editing control inside (a SearchField's input, a DateField's segments) keeps ←/→ for its caret\n * and segments; at its edge (the caret at the start or end, the first or last segment) the arrow moves on\n * to the next control, so every control stays reachable by the arrows. Arrowing into a date or time field\n * lands on the segment nearest the way in: in RTL the visually nearest one, whatever the DOM order of its\n * segments. A raw `type=\"number\"` or\n * `type=\"email\"` input with a value has no readable caret and keeps ←/→ (Tab leaves it); prefer NumberField,\n * or TextField with `inputMode`, inside a toolbar.\n */\nexport function Toolbar({ children, \"aria-label\": label }: ToolbarProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const { toolbarProps } = useToolbarKeys(ref);\n return (\n <div\n ref={ref}\n data-slot=\"toolbar\"\n className=\"flex flex-wrap items-center gap-ds-100 rounded-ds-large bg-ds-surface-raised px-ds-150 py-ds-100 shadow-ds-raised\"\n data-rac=\"\"\n aria-label={label}\n {...toolbarProps}\n >\n {children}\n </div>\n );\n}\n\n/*\n * React Aria's Toolbar (react-aria-components) handles ←/→ in a capture listener on the toolbar and\n * takes no key handler of its own, so it cannot leave the arrows to a text control inside it. This\n * mirrors its useToolbar (horizontal): same role, arrows mirrored in RTL, no wrap, Tab leaving via the\n * first/last control, focus restored on return. The one change: ←/→ on a text-editing target belong\n * to that target until the caret or segment focus is at the target's edge in the arrow's direction.\n */\n\n// React Aria's focusable-element selector (isFocusable), so the arrows reach the same controls.\nconst FOCUSABLE = [\n \"input:not([disabled]):not([type=hidden])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"a[href]\",\n \"area[href]\",\n \"summary\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"audio[controls]\",\n \"video[controls]\",\n '[contenteditable]:not([contenteditable^=\"false\"])',\n \"permission\",\n]\n .map((selector) => `${selector}:not([hidden])`)\n .concat(\"[tabindex]:not([disabled]):not([hidden])\")\n .join(\",\");\n\n/*\n * React Aria's shadow-DOM-aware helpers (getActiveElement, nodeContains, getEventTarget in\n * react-aria/private/utils/shadowdom) are not part of the public react-aria-components surface, and\n * react-aria itself is not a dependency of this package, so they are mirrored here. React Aria only\n * walks shadow roots when its shadowDOM flag is on; in the light DOM (the flag's default) these give\n * exactly document.activeElement, Node.contains and event.target, as React Aria does.\n */\nfunction getActiveElement(doc: Document = document): Element | null {\n let active = doc.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n return active;\n}\n\nfunction nodeContains(node: Node | null | undefined, other: Node | null | undefined): boolean {\n if (!node || !other) return false;\n for (let current: Node | null = other; current; ) {\n if (current === node) return true;\n const slot: HTMLSlotElement | null | undefined = (current as Element).assignedSlot;\n // A slotted element continues from its slot (a slot itself walks up as usual).\n if (typeof (current as HTMLSlotElement).assignedElements !== \"function\" && slot?.parentNode) current = slot.parentNode;\n else if (current instanceof ShadowRoot) current = current.host;\n else current = current.parentNode;\n }\n return false;\n}\n\nfunction getEventTarget(e: React.SyntheticEvent): Element {\n const target = e.target as Element;\n if (target instanceof Element && target.shadowRoot) {\n const inner = e.nativeEvent.composedPath?.()[0];\n if (inner instanceof Element) return inner;\n }\n return target;\n}\n\n// Inputs that do not use ←/→ themselves: the toolbar always takes the arrows from them.\nconst ARROWLESS_INPUTS = new Set([\"button\", \"submit\", \"reset\", \"checkbox\", \"image\", \"file\", \"color\"]);\n/*\n * Inputs whose value ←/→ change, so the arrows always stay with them: React Aria's RadioGroup moves the\n * selection between its radios and its Slider moves the thumb with ←/→ (no caret, so no edge).\n */\nconst VALUE_ARROW_INPUTS = new Set([\"radio\", \"range\"]);\n\nfunction isRtl(element: Element, fallback: \"ltr\" | \"rtl\") {\n const computed = getComputedStyle(element).direction;\n if (computed === \"rtl\" || computed === \"ltr\") return computed === \"rtl\";\n // jsdom resolves no `direction`; :dir() reads the dir attribute the same way the browser does.\n try {\n return element.matches(\":dir(rtl)\");\n } catch {\n return fallback === \"rtl\";\n }\n}\n\n/**\n * The segment group (`role=\"group\"`) of a date/time segment inside the toolbar, else undefined. Only\n * segments step from their group: a text input is one element, and its group (the field frame) also holds\n * controls of its own (a SearchField's clear button, InputActions) that the arrows should still reach.\n */\nfunction segmentGroup(target: Element, toolbar: Element): Element | undefined {\n if (target.getAttribute(\"role\") !== \"spinbutton\") return undefined;\n const group = target.closest('[role=\"group\"]');\n return group && group !== toolbar && toolbar.contains(group) ? group : undefined;\n}\n\nfunction isTabbable(element: HTMLElement) {\n return element.tabIndex >= 0;\n}\n\n/**\n * True when the arrow key belongs to the target: a caret that can still move that way in a text input or\n * textarea, a date/time segment with another segment that way, a radio or slider, or a contenteditable\n * or textbox whose caret the toolbar cannot read. A non-collapsed selection always stays with the field.\n * `direction` is the toolbar's (the locale's), as React Aria's date segments use it.\n */\nfunction keepsArrows(target: Element, key: \"ArrowLeft\" | \"ArrowRight\", direction: \"ltr\" | \"rtl\") {\n const tag = target.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\") {\n const field = target as HTMLInputElement | HTMLTextAreaElement;\n if (tag === \"INPUT\" && ARROWLESS_INPUTS.has(field.type)) return false;\n if (tag === \"INPUT\" && VALUE_ARROW_INPUTS.has(field.type)) return true;\n let start: number | null;\n let end: number | null;\n try {\n start = field.selectionStart;\n end = field.selectionEnd;\n } catch {\n start = end = null;\n }\n /*\n * number, email…: the browser exposes no caret (selectionStart is null), so the toolbar cannot tell\n * an edge. Empty, there is no caret to move and the arrows move on; with a value the field keeps them,\n * since taking them would leave no way to move the caret. Tab leaves such a field. The DS's own\n * fields avoid this: NumberField is a text input, and TextField takes `inputMode` for e-mail.\n */\n if (start == null || end == null) return field.value !== \"\";\n if (start !== end) return true;\n // The caret's back key is ← in an LTR field and → in an RTL one: the field's own direction.\n const back = isRtl(field, direction) ? key === \"ArrowRight\" : key === \"ArrowLeft\";\n return back ? start > 0 : end < field.value.length;\n }\n const role = target.getAttribute(\"role\");\n if (role === \"spinbutton\") {\n const group = target.closest('[role=\"group\"]');\n if (group) return hasSegmentToward(group, target as HTMLElement, key, direction);\n return true;\n }\n if (role === \"textbox\" || role === \"searchbox\") return true;\n return target.closest('[contenteditable]:not([contenteditable^=\"false\"])') != null;\n}\n\n/**\n * Whether React Aria's date/time field would move to another segment for this arrow (useDatePickerGroup):\n * in LTR the previous/next tabbable segment in DOM order; in RTL the nearest segment visually to that\n * side (its bounding box), since RTL date and time segments are not laid out in DOM order.\n */\nfunction hasSegmentToward(group: Element, segment: HTMLElement, key: \"ArrowLeft\" | \"ArrowRight\", direction: \"ltr\" | \"rtl\") {\n const segments = Array.from(group.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (element) => isTabbable(element) && isVisible(element),\n );\n if (direction === \"rtl\") {\n const from = segment.getBoundingClientRect().x;\n const sign = key === \"ArrowRight\" ? 1 : -1;\n return segments.some((element) => element !== segment && Math.sign(element.getBoundingClientRect().x - from) === sign);\n }\n const index = segments.indexOf(segment);\n if (index === -1) return true;\n return key === \"ArrowLeft\" ? index > 0 : index < segments.length - 1;\n}\n\n/**\n * In RTL, the segment an arrow should land on when it moves INTO a date/time field: the one\n * visually nearest the side focus enters from, by bounding box as `hasSegmentToward` reads it, since RTL\n * segments need not be laid out in DOM order. A step toward the toolbar's end (`step` 1, ← in RTL) enters\n * at the field's start side, the segment furthest toward the start; a step toward the start enters at its\n * end side. Any other target, or segments without a layout (equal boxes), keep the DOM-order choice.\n */\nfunction entrySegment(next: HTMLElement, toolbar: Element, step: 1 | -1): HTMLElement {\n const group = segmentGroup(next, toolbar);\n if (!group) return next;\n const segments = Array.from(group.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (element) => isTabbable(element) && isVisible(element),\n );\n // In RTL the start side is the larger x: a step of 1 enters the field at its start side (largest x), -1 at its end side.\n const enterAtStartSide = step === 1;\n let best = next;\n let bestX = next.getBoundingClientRect().x;\n for (const element of segments) {\n const x = element.getBoundingClientRect().x;\n if (enterAtStartSide ? x > bestX : x < bestX) {\n best = element;\n bestX = x;\n }\n }\n return best;\n}\n\nfunction isVisible(element: Element): boolean {\n if (typeof element.checkVisibility === \"function\") {\n return element.checkVisibility({ visibilityProperty: true }) && !element.closest(\"[data-react-aria-prevent-focus]\");\n }\n for (let node: Element | null = element; node; node = node.parentElement) {\n if (node.hasAttribute(\"hidden\") || node.hasAttribute(\"data-react-aria-prevent-focus\")) return false;\n const { display, visibility } = getComputedStyle(node);\n if (display === \"none\" || visibility === \"hidden\" || visibility === \"collapse\") return false;\n }\n return true;\n}\n\nfunction focusables(root: HTMLElement) {\n return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (element) => !element.closest(\"[inert]\") && isVisible(element),\n );\n}\n\nfunction useToolbarKeys(ref: React.RefObject<HTMLDivElement | null>) {\n const { direction } = useLocale();\n const [isInToolbar, setInToolbar] = React.useState(false);\n React.useLayoutEffect(() => {\n setInToolbar(!!ref.current?.parentElement?.closest('[role=\"toolbar\"]'));\n });\n const lastFocused = React.useRef<Element | null>(null);\n\n /*\n * Moves to the next/previous control in DOM order from `from` (the focused element by default). `from` is\n * a whole segment group when the arrow leaves a date/time field: the step starts after (or before) the\n * group, never at a sibling segment, since in RTL the visual edge segment need not be the DOM-order edge\n * (an `ar` TimeField or a `he-IL` date keeps DOM order; an `ar` date is reversed). Arrowing INTO such a\n * field in RTL lands on its segment visually nearest the way in (`entrySegment`); LTR keeps DOM order.\n * Plain focus(), as React Aria's focus manager does: the control scrolls into view.\n */\n const move = (step: 1 | -1, from?: Element) => {\n const root = ref.current;\n if (!root) return;\n const all = focusables(root);\n const active = from ?? getActiveElement();\n let next: HTMLElement | undefined;\n if (!active || !nodeContains(root, active)) next = step === 1 ? all[0] : all[all.length - 1];\n else if (step === 1) {\n // FOLLOWING includes the group's own descendants: skip them.\n next = all.find((el) => active.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING && !active.contains(el));\n } else next = all.filter((el) => active.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING).pop();\n // Into a date/time field in RTL: the segment nearest the side the arrow enters from, not the DOM-first one.\n if (next && direction === \"rtl\") next = entrySegment(next, root, step);\n next?.focus();\n };\n const edge = (end: \"first\" | \"last\") => {\n const all = ref.current ? focusables(ref.current) : [];\n (end === \"first\" ? all[0] : all[all.length - 1])?.focus();\n };\n\n const onKeyDownCapture = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const target = getEventTarget(e);\n // Portalled content (a popover opened from a control) is not the toolbar's.\n if (!nodeContains(e.currentTarget, target)) return;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") {\n if (keepsArrows(target, e.key, direction)) return;\n const forward = e.key === \"ArrowRight\" ? 1 : -1;\n move(direction === \"rtl\" ? (-forward as 1 | -1) : forward, segmentGroup(target, e.currentTarget));\n } else if (e.key === \"Tab\") {\n // Focus the first/last control and let the browser's Tab carry focus out from there.\n lastFocused.current = getActiveElement();\n edge(e.shiftKey ? \"first\" : \"last\");\n return;\n } else return;\n // Keep nested action groups (and the field the arrow moved out of) from handling the arrows too.\n e.stopPropagation();\n e.preventDefault();\n };\n // Remember the control focus came from, and return to it when focus comes back into the toolbar.\n const onBlurCapture = (e: React.FocusEvent<HTMLDivElement>) => {\n if (!nodeContains(e.currentTarget, e.relatedTarget) && !lastFocused.current) lastFocused.current = getEventTarget(e);\n };\n const onFocusCapture = (e: React.FocusEvent<HTMLDivElement>) => {\n const last = lastFocused.current;\n if (last && !nodeContains(e.currentTarget, e.relatedTarget) && nodeContains(ref.current, getEventTarget(e))) {\n lastFocused.current = null;\n (last as HTMLElement).focus?.();\n }\n };\n\n return {\n toolbarProps: {\n role: isInToolbar ? \"group\" : \"toolbar\",\n \"aria-orientation\": \"horizontal\" as const,\n \"data-orientation\": \"horizontal\",\n onKeyDownCapture: isInToolbar ? undefined : onKeyDownCapture,\n onFocusCapture: isInToolbar ? undefined : onFocusCapture,\n onBlurCapture: isInToolbar ? undefined : onBlurCapture,\n },\n };\n}\n\n/** Pushes the controls after it to the toolbar's end. */\nexport function ToolbarSpacer() {\n return <span aria-hidden data-slot=\"toolbar-spacer\" className=\"flex-1\" />;\n}\n\nexport type BulkBarProps = {\n /** How many rows are selected; announced as it changes. */\n selectedCount: number;\n /** The bulk actions (compact Buttons): \"Send reminder\", \"Export\". */\n actions: React.ReactNode;\n /** Clears the selection; the bar goes with it. */\n onClear: () => void;\n /** Names the bar (\"Selected orders\"). */\n \"aria-label\": string;\n};\n\n/**\n * Replaces the toolbar while rows are selected: the count, the bulk actions and a clear button, on\n * `ds-background-neutral-bold`. One Tab stop with arrow keys inside, like the toolbar. Buttons in the bar\n * are drawn transparent with inverse text whatever their variant: pass default (not primary) actions.\n */\nexport function BulkBar({ selectedCount, actions, onClear, \"aria-label\": label }: BulkBarProps) {\n const { locale } = useLocale();\n const count = selectedCountLabel(locale, selectedCount);\n const [spoken, setSpoken] = React.useState(\"\");\n React.useEffect(() => setSpoken(count), [count]);\n return (\n <AriaToolbar\n aria-label={label}\n data-slot=\"bulk-bar\"\n className={\n \"flex flex-wrap items-center gap-ds-150 rounded-ds-large bg-ds-background-neutral-bold px-ds-150 py-ds-100 text-ds-text-inverse \" +\n // Buttons read on the dark bar: transparent with inverse text, the neutral pressed step on hover.\n \"[&_[data-slot=button]]:bg-transparent [&_[data-slot=button]]:text-ds-text-inverse \" +\n \"[&_[data-slot=button][data-hovered]]:bg-ds-background-neutral-pressed [&_[data-slot=button][data-hovered]]:text-ds-text \" +\n \"[&_[data-slot=button][data-pressed]]:bg-ds-background-neutral-pressed [&_[data-slot=button][data-pressed]]:text-ds-text \" +\n \"[&_[data-slot=button][data-focus-visible]]:inset-ring-ds-text-inverse\"\n }\n >\n <span data-slot=\"bulk-bar-count\" aria-hidden className=\"text-body-strong tabular-nums\">\n {count}\n </span>\n {/* Mounted empty and filled after mount: a live region born with its text is usually not read, so the\n first count (0 → 1, the bar appearing) would go unannounced. */}\n <span data-slot=\"bulk-bar-announcer\" role=\"status\" className=\"sr-only\">\n {spoken}\n </span>\n {actions}\n <span aria-hidden className=\"flex-1\" />\n <Button size=\"small\" iconOnly iconBefore=\"x\" aria-label={clearSelectionLabel(locale)} onPress={onClear} />\n </AriaToolbar>\n );\n}\n"]}
@@ -0,0 +1,63 @@
1
+ import * as React from "react";
2
+ import { type WithMotion } from "../defaults.js";
3
+ import { type IconName } from "../display/icon.js";
4
+ import { type OpenProps } from "./overlay-base.js";
5
+ export type AlertDialogProps = OpenProps & {
6
+ /**
7
+ * `danger` (default: a delete, `trash-2`, a danger button), `warning` (`triangle-alert`, a primary button), or
8
+ * `neutral` for a confirm that neither destroys nor risks anything, such as reactivating an account
9
+ * (`info` on a neutral ground, a primary button).
10
+ */
11
+ tone?: "danger" | "warning" | "neutral";
12
+ /** The action as a question with the object's name: "PG AB 482 filodan silinsin mi?" */
13
+ title: React.ReactNode;
14
+ /** The consequence, and what to do first. */
15
+ children: React.ReactNode;
16
+ /** The verb again: "Delete item". */
17
+ confirmLabel: string;
18
+ /**
19
+ * The cancel button's text, and so its accessible name ("No, keep it"), in place of the library's "Cancel"
20
+ *. The app passes it already localized; the DS does not translate it. Left out (or `""`), the
21
+ * locale's "Cancel" renders and the DOM is unchanged. A long label wraps inside the button, which takes at
22
+ * most the footer's width; focus, Esc and the pending lock are the same either way.
23
+ */
24
+ cancelLabel?: string;
25
+ /**
26
+ * May be async: the button shows pending until it settles, and while it runs the dialog cannot be cancelled
27
+ * (the action is under way); it closes when the action succeeds and stays open when it fails.
28
+ */
29
+ onConfirm: () => void | Promise<void>;
30
+ /** For irreversible deletes: the text the user types before the button enables ("PG AB 482"). */
31
+ requireTypedConfirmation?: string;
32
+ /**
33
+ * Holds the confirm back while the app loads what it needs ("Loading linked orders"). The
34
+ * button keeps its name and stays in the dialog, disabled as with `requireTypedConfirmation`: it cannot be pressed
35
+ * (pointer, Enter or Space) and Tab passes it, so "Cancel" stays the one control; screen readers list it as
36
+ * unavailable. Say why in the description or in the element `aria-describedby` names. Esc and "Cancel" still work.
37
+ */
38
+ isConfirmDisabled?: boolean;
39
+ /**
40
+ * More of what the alert says, by id: an element the app renders, inside the alert (a Banner in its
41
+ * body) or outside it (a page notice). Added to the alert's own description in `aria-describedby`, after it, so
42
+ * the alert is announced with both when it opens.
43
+ */
44
+ "aria-describedby"?: string;
45
+ /** The field's label; "Type ORD-482 to confirm" by default. */
46
+ typedConfirmationLabel?: string;
47
+ /** Overrides the tone's icon (danger `trash-2`, warning `triangle-alert`). */
48
+ icon?: IconName;
49
+ /**
50
+ * Where focus goes when the alert closes and React Aria's return would leave it on the page or on the
51
+ * opener, as on Dialog. Needed when the element React Aria returns to is gone by the close: an alert
52
+ * opened from a menu whose trigger unmounts when it closes (pass a stable button), or a confirmed action that removes the row
53
+ * with its Menu (pass a stable element). Opened from a DS Menu item it is not needed: React Aria returns focus to
54
+ * the Menu button itself, and a ref naming another element does not override that. Read when the alert closes; if
55
+ * the app has already moved focus elsewhere on close, it stays there; if the ref is empty, focus returns as before.
56
+ * There is no `initialFocusRef`: the alert's controls are its own, and "Cancel" takes the first focus. Nor is there a
57
+ * `titleRef`: the alert is announced with its title and consequence when it opens (`aria-labelledby`,
58
+ * `aria-describedby`), and focus starts on the safe answer, never on its text.
59
+ */
60
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
61
+ };
62
+ /** AlertDialog with its own `motion` (auto, reduce or none); see AlertDialogBody for the component itself. */
63
+ export declare function AlertDialog({ motion, ...props }: AlertDialogProps & WithMotion): React.JSX.Element;
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Heading, useLocale } from "react-aria-components";
5
+ import { cn } from "../utils.js";
6
+ import { MotionScope } from "../defaults.js";
7
+ import { Button } from "../action/button.js";
8
+ import { IconGlyph } from "../display/icon.js";
9
+ import { TextField } from "../form/text-field.js";
10
+ import { cancelLabel as defaultCancelLabel, typeToConfirmLabel } from "../i18n.js";
11
+ import { DialogFrame, useOverlayOpen, useReturnFocus } from "./overlay-base.js";
12
+ const ALERT_ICON = {
13
+ danger: { name: "trash-2", className: "bg-ds-background-danger text-ds-icon-danger" },
14
+ warning: { name: "triangle-alert", className: "bg-ds-background-warning text-ds-icon-warning" },
15
+ neutral: { name: "info", className: "bg-ds-background-neutral text-ds-icon" },
16
+ };
17
+ /**
18
+ * Only with a custom `cancelLabel`: the cancel button may wrap its text and grow in height, at most
19
+ * as wide as the footer, so a long app label never overflows a 320px screen. The default "Cancel" is short and
20
+ * keeps the footer's classes unchanged, and so does a blank label (`" "`), which counts as unset. A word breaks only
21
+ * when it is too long for a line (`break-words`).
22
+ */
23
+ const CUSTOM_CANCEL_FOOTER = "[&>[data-slot=alert-dialog-cancel]]:h-auto [&>[data-slot=alert-dialog-cancel]]:min-h-ds-control [&>[data-slot=alert-dialog-cancel]]:max-w-full " +
24
+ "[&>[data-slot=alert-dialog-cancel]]:py-ds-075 [&>[data-slot=alert-dialog-cancel]]:whitespace-normal [&>[data-slot=alert-dialog-cancel]]:text-center " +
25
+ "[&>[data-slot=alert-dialog-cancel]]:break-words";
26
+ const ALERT_FOOTER = "flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-200";
27
+ function AlertContent({ tone = "danger", title, children, confirmLabel, cancelLabel, onConfirm, requireTypedConfirmation, typedConfirmationLabel, icon, returnFocusRef, isConfirmDisabled, descriptionId, close, pending, setPending, }) {
28
+ const { locale } = useLocale();
29
+ const cancel = React.useRef(null);
30
+ const [typed, setTyped] = React.useState("");
31
+ // "Cancel" first: the destructive button never has default focus.
32
+ React.useEffect(() => cancel.current?.focus(), []);
33
+ // Without the ref nothing runs, so React Aria returns focus to the opener as before.
34
+ useReturnFocus(returnFocusRef);
35
+ const ready = requireTypedConfirmation === undefined || typed.trim() === requireTypedConfirmation;
36
+ const confirm = async () => {
37
+ setPending(true);
38
+ let done = false;
39
+ try {
40
+ await onConfirm();
41
+ done = true;
42
+ }
43
+ catch {
44
+ // The action failed: the dialog stays open so the user can retry or cancel. Saying what went wrong
45
+ // (a Toast, an inline Banner) is the caller's, which knows the error.
46
+ }
47
+ finally {
48
+ setPending(false);
49
+ }
50
+ if (done)
51
+ close();
52
+ };
53
+ const glyph = ALERT_ICON[tone];
54
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "alert-dialog-header", className: "flex items-start gap-ds-200 px-ds-300 pt-ds-300", children: [_jsx("span", { "data-slot": "alert-dialog-icon", className: cn("grid size-10 shrink-0 place-items-center rounded-ds-full", glyph.className), children: _jsx(IconGlyph, { name: icon ?? glyph.name }) }), _jsxs("div", { "data-slot": "alert-dialog-text", className: "flex min-w-0 flex-col gap-ds-050", children: [_jsx(Heading, { slot: "title", "data-slot": "alert-dialog-title", className: "m-0 text-heading-medium", children: title }), _jsx("div", { id: descriptionId, "data-slot": "alert-dialog-description", className: "text-body text-ds-text-subtle", children: children })] })] }), requireTypedConfirmation !== undefined && (_jsx("div", { "data-slot": "alert-dialog-body", className: "px-ds-300 pt-ds-200", children: _jsx(TextField, { label: typedConfirmationLabel ?? typeToConfirmLabel(locale, requireTypedConfirmation), value: typed, onChange: setTyped, placeholder: requireTypedConfirmation, variant: "code", autoComplete: "off", isDisabled: pending }) })), _jsxs("div", { "data-slot": "alert-dialog-footer", className: cancelLabel?.trim() ? `${ALERT_FOOTER} ${CUSTOM_CANCEL_FOOTER}` : ALERT_FOOTER, children: [_jsx(Button, { ref: cancel, variant: "subtle", onPress: close, isDisabled: pending, "data-slot": "alert-dialog-cancel", children: cancelLabel?.trim() || defaultCancelLabel(locale) }), _jsx(Button, { variant: "primary", tone: tone === "danger" ? "danger" : "neutral", isDisabled: !ready || Boolean(isConfirmDisabled), isPending: pending, onPress: confirm, "data-slot": "alert-dialog-confirm", children: confirmLabel })] })] }));
55
+ }
56
+ /**
57
+ * Confirms an action that destroys data, costs money or cannot be undone (role="alertdialog"). Not closed
58
+ * by a scrim click; Esc cancels (not while the action runs); "Cancel" (or the app's `cancelLabel`) has the first focus. With
59
+ * `requireTypedConfirmation` the action enables only once the text is typed. If the action can be undone,
60
+ * skip it and offer "Undo" in a Toast. Opened from a menu whose trigger unmounts, or when the confirmed action
61
+ * removes the opener, pass `returnFocusRef` so focus has somewhere to go back to.
62
+ */
63
+ function AlertDialogBody({ isOpen, defaultOpen, onOpenChange, "aria-describedby": ariaDescribedBy, ...content }) {
64
+ const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
65
+ const descriptionId = React.useId();
66
+ const [pending, setPending] = React.useState(false);
67
+ const describedBy = ariaDescribedBy?.trim() ? `${descriptionId} ${ariaDescribedBy.trim()}` : descriptionId;
68
+ return (
69
+ // No scrim click (a stray tap must not answer it); Esc cancels, except while the action is running.
70
+ _jsx(DialogFrame, { size: "small", role: "alertdialog", isDismissable: false, escapeCloses: !pending, describedBy: describedBy, isOpen: state.isOpen, onClose: state.close, children: _jsx(AlertContent, { ...content, descriptionId: descriptionId, close: state.close, pending: pending, setPending: setPending }) }));
71
+ }
72
+ /** AlertDialog with its own `motion` (auto, reduce or none); see AlertDialogBody for the component itself. */
73
+ export function AlertDialog({ motion, ...props }) {
74
+ return (_jsx(MotionScope, { motion: motion, children: _jsx(AlertDialogBody, { ...props }) }));
75
+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AACH,SAAS,eAAe,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,GAAG,OAAO,EAAoB;IAC/H,MAAM,KAAK,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IACpC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;IAC3G,OAAO;IACL,oGAAoG;IACpG,KAAC,WAAW,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,aAAa,EAAC,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,YAC7J,KAAC,YAAY,OAAK,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAI,GAC7G,CACf,CAAC;AACJ,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAAiC;IAC7E,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,eAAe,OAAM,KAA0B,GAAI,GACxC,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Heading, useLocale } from \"react-aria-components\";\nimport { cn } from \"../utils\";\nimport { MotionScope, type WithMotion } from \"../defaults\";\nimport { Button } from \"../action/button\";\nimport { IconGlyph, type IconName } from \"../display/icon\";\nimport { TextField } from \"../form/text-field\";\nimport { cancelLabel as defaultCancelLabel, typeToConfirmLabel } from \"../i18n\";\nimport { DialogFrame, type OpenProps, useOverlayOpen, useReturnFocus } from \"./overlay-base\";\n\nexport type AlertDialogProps = OpenProps & {\n /**\n * `danger` (default: a delete, `trash-2`, a danger button), `warning` (`triangle-alert`, a primary button), or\n * `neutral` for a confirm that neither destroys nor risks anything, such as reactivating an account\n * (`info` on a neutral ground, a primary button).\n */\n tone?: \"danger\" | \"warning\" | \"neutral\";\n /** The action as a question with the object's name: \"PG AB 482 filodan silinsin mi?\" */\n title: React.ReactNode;\n /** The consequence, and what to do first. */\n children: React.ReactNode;\n /** The verb again: \"Delete item\". */\n confirmLabel: string;\n /**\n * The cancel button's text, and so its accessible name (\"No, keep it\"), in place of the library's \"Cancel\"\n *. The app passes it already localized; the DS does not translate it. Left out (or `\"\"`), the\n * locale's \"Cancel\" renders and the DOM is unchanged. A long label wraps inside the button, which takes at\n * most the footer's width; focus, Esc and the pending lock are the same either way.\n */\n cancelLabel?: string;\n /**\n * May be async: the button shows pending until it settles, and while it runs the dialog cannot be cancelled\n * (the action is under way); it closes when the action succeeds and stays open when it fails.\n */\n onConfirm: () => void | Promise<void>;\n /** For irreversible deletes: the text the user types before the button enables (\"PG AB 482\"). */\n requireTypedConfirmation?: string;\n /**\n * Holds the confirm back while the app loads what it needs (\"Loading linked orders\"). The\n * button keeps its name and stays in the dialog, disabled as with `requireTypedConfirmation`: it cannot be pressed\n * (pointer, Enter or Space) and Tab passes it, so \"Cancel\" stays the one control; screen readers list it as\n * unavailable. Say why in the description or in the element `aria-describedby` names. Esc and \"Cancel\" still work.\n */\n isConfirmDisabled?: boolean;\n /**\n * More of what the alert says, by id: an element the app renders, inside the alert (a Banner in its\n * body) or outside it (a page notice). Added to the alert's own description in `aria-describedby`, after it, so\n * the alert is announced with both when it opens.\n */\n \"aria-describedby\"?: string;\n /** The field's label; \"Type ORD-482 to confirm\" by default. */\n typedConfirmationLabel?: string;\n /** Overrides the tone's icon (danger `trash-2`, warning `triangle-alert`). */\n icon?: IconName;\n /**\n * Where focus goes when the alert closes and React Aria's return would leave it on the page or on the\n * opener, as on Dialog. Needed when the element React Aria returns to is gone by the close: an alert\n * opened from a menu whose trigger unmounts when it closes (pass a stable button), or a confirmed action that removes the row\n * with its Menu (pass a stable element). Opened from a DS Menu item it is not needed: React Aria returns focus to\n * the Menu button itself, and a ref naming another element does not override that. Read when the alert closes; if\n * the app has already moved focus elsewhere on close, it stays there; if the ref is empty, focus returns as before.\n * There is no `initialFocusRef`: the alert's controls are its own, and \"Cancel\" takes the first focus. Nor is there a\n * `titleRef`: the alert is announced with its title and consequence when it opens (`aria-labelledby`,\n * `aria-describedby`), and focus starts on the safe answer, never on its text.\n */\n returnFocusRef?: React.RefObject<HTMLElement | null>;\n};\n\nconst ALERT_ICON: Record<NonNullable<AlertDialogProps[\"tone\"]>, { name: IconName; className: string }> = {\n danger: { name: \"trash-2\", className: \"bg-ds-background-danger text-ds-icon-danger\" },\n warning: { name: \"triangle-alert\", className: \"bg-ds-background-warning text-ds-icon-warning\" },\n neutral: { name: \"info\", className: \"bg-ds-background-neutral text-ds-icon\" },\n};\n\n/**\n * Only with a custom `cancelLabel`: the cancel button may wrap its text and grow in height, at most\n * as wide as the footer, so a long app label never overflows a 320px screen. The default \"Cancel\" is short and\n * keeps the footer's classes unchanged, and so does a blank label (`\" \"`), which counts as unset. A word breaks only\n * when it is too long for a line (`break-words`).\n */\nconst CUSTOM_CANCEL_FOOTER =\n \"[&>[data-slot=alert-dialog-cancel]]:h-auto [&>[data-slot=alert-dialog-cancel]]:min-h-ds-control [&>[data-slot=alert-dialog-cancel]]:max-w-full \" +\n \"[&>[data-slot=alert-dialog-cancel]]:py-ds-075 [&>[data-slot=alert-dialog-cancel]]:whitespace-normal [&>[data-slot=alert-dialog-cancel]]:text-center \" +\n \"[&>[data-slot=alert-dialog-cancel]]:break-words\";\n\nconst ALERT_FOOTER = \"flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-200\";\n\nfunction AlertContent({\n tone = \"danger\", title, children, confirmLabel, cancelLabel, onConfirm, requireTypedConfirmation, typedConfirmationLabel, icon, returnFocusRef, isConfirmDisabled, descriptionId, close, pending, setPending,\n}: Omit<AlertDialogProps, keyof OpenProps | \"aria-describedby\"> & { descriptionId: string; close: () => void; pending: boolean; setPending: (pending: boolean) => void }) {\n const { locale } = useLocale();\n const cancel = React.useRef<HTMLButtonElement>(null);\n const [typed, setTyped] = React.useState(\"\");\n // \"Cancel\" first: the destructive button never has default focus.\n React.useEffect(() => cancel.current?.focus(), []);\n // Without the ref nothing runs, so React Aria returns focus to the opener as before.\n useReturnFocus(returnFocusRef);\n const ready = requireTypedConfirmation === undefined || typed.trim() === requireTypedConfirmation;\n const confirm = async () => {\n setPending(true);\n let done = false;\n try {\n await onConfirm();\n done = true;\n } catch {\n // The action failed: the dialog stays open so the user can retry or cancel. Saying what went wrong\n // (a Toast, an inline Banner) is the caller's, which knows the error.\n } finally {\n setPending(false);\n }\n if (done) close();\n };\n const glyph = ALERT_ICON[tone];\n return (\n <>\n <div data-slot=\"alert-dialog-header\" className=\"flex items-start gap-ds-200 px-ds-300 pt-ds-300\">\n <span data-slot=\"alert-dialog-icon\" className={cn(\"grid size-10 shrink-0 place-items-center rounded-ds-full\", glyph.className)}>\n <IconGlyph name={icon ?? glyph.name} />\n </span>\n <div data-slot=\"alert-dialog-text\" className=\"flex min-w-0 flex-col gap-ds-050\">\n <Heading slot=\"title\" data-slot=\"alert-dialog-title\" className=\"m-0 text-heading-medium\">{title}</Heading>\n <div id={descriptionId} data-slot=\"alert-dialog-description\" className=\"text-body text-ds-text-subtle\">{children}</div>\n </div>\n </div>\n {requireTypedConfirmation !== undefined && (\n <div data-slot=\"alert-dialog-body\" className=\"px-ds-300 pt-ds-200\">\n <TextField\n label={typedConfirmationLabel ?? typeToConfirmLabel(locale, requireTypedConfirmation)}\n value={typed}\n onChange={setTyped}\n placeholder={requireTypedConfirmation}\n variant=\"code\"\n autoComplete=\"off\"\n isDisabled={pending}\n />\n </div>\n )}\n <div data-slot=\"alert-dialog-footer\" className={cancelLabel?.trim() ? `${ALERT_FOOTER} ${CUSTOM_CANCEL_FOOTER}` : ALERT_FOOTER}>\n <Button ref={cancel} variant=\"subtle\" onPress={close} isDisabled={pending} data-slot=\"alert-dialog-cancel\">{cancelLabel?.trim() || defaultCancelLabel(locale)}</Button>\n <Button\n variant=\"primary\"\n tone={tone === \"danger\" ? \"danger\" : \"neutral\"}\n isDisabled={!ready || Boolean(isConfirmDisabled)}\n isPending={pending}\n onPress={confirm}\n data-slot=\"alert-dialog-confirm\"\n >\n {confirmLabel}\n </Button>\n </div>\n </>\n );\n}\n\n/**\n * Confirms an action that destroys data, costs money or cannot be undone (role=\"alertdialog\"). Not closed\n * by a scrim click; Esc cancels (not while the action runs); \"Cancel\" (or the app's `cancelLabel`) has the first focus. With\n * `requireTypedConfirmation` the action enables only once the text is typed. If the action can be undone,\n * skip it and offer \"Undo\" in a Toast. Opened from a menu whose trigger unmounts, or when the confirmed action\n * removes the opener, pass `returnFocusRef` so focus has somewhere to go back to.\n */\nfunction AlertDialogBody({ isOpen, defaultOpen, onOpenChange, \"aria-describedby\": ariaDescribedBy, ...content }: AlertDialogProps) {\n const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });\n const descriptionId = React.useId();\n const [pending, setPending] = React.useState(false);\n const describedBy = ariaDescribedBy?.trim() ? `${descriptionId} ${ariaDescribedBy.trim()}` : descriptionId;\n return (\n // No scrim click (a stray tap must not answer it); Esc cancels, except while the action is running.\n <DialogFrame size=\"small\" role=\"alertdialog\" isDismissable={false} escapeCloses={!pending} describedBy={describedBy} isOpen={state.isOpen} onClose={state.close}>\n <AlertContent {...content} descriptionId={descriptionId} close={state.close} pending={pending} setPending={setPending} />\n </DialogFrame>\n );\n}\n\n/** AlertDialog with its own `motion` (auto, reduce or none); see AlertDialogBody for the component itself. */\nexport function AlertDialog({ motion, ...props }: AlertDialogProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <AlertDialogBody {...(props as AlertDialogProps)} />\n </MotionScope>\n );\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import * as React from "react";
2
+ import { type IconName } from "../display/icon.js";
3
+ import { type LozengeTone } from "../display/lozenge.js";
4
+ export type CommandItem = {
5
+ id: string;
6
+ /** "Pro plan", "Create order". */
7
+ label: string;
8
+ /** Beside the label in mono: a code, an order number ("ORD-482"). */
9
+ detail?: string;
10
+ icon?: IconName;
11
+ /** A record's status ("Available", success). */
12
+ status?: {
13
+ label: string;
14
+ tone: LozengeTone;
15
+ };
16
+ /** An action's shortcut ("N"). */
17
+ shortcut?: string;
18
+ /** Extra words it is found by (a customer's phone number, an old name). */
19
+ keywords?: readonly string[];
20
+ /** Records come first, then actions, then pages; "action" items fill the "most used" list. */
21
+ kind?: "record" | "action" | "page";
22
+ };
23
+ export type CommandGroup = {
24
+ id: string;
25
+ title: string;
26
+ items: readonly CommandItem[];
27
+ };
28
+ export type CommandPaletteProps = {
29
+ isOpen?: boolean;
30
+ defaultOpen?: boolean;
31
+ onOpenChange?: (isOpen: boolean) => void;
32
+ /** Actions and pages, most used first; matched here, diacritic-insensitive. */
33
+ groups: readonly CommandGroup[];
34
+ /** Records found by the server (codes, order numbers, names, phones); shown before the groups. */
35
+ search?: (query: string, signal: AbortSignal) => Promise<readonly CommandGroup[]>;
36
+ /** Shown while the query is empty, above the five most used actions. */
37
+ recent?: readonly CommandItem[];
38
+ onSelect: (item: CommandItem) => void;
39
+ /** Bind ⌘K / Ctrl K to open and close it. */
40
+ shortcut?: boolean;
41
+ };
42
+ /**
43
+ * ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the
44
+ * blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on
45
+ * ds-background-selected, records with their status. Empty, it shows recent records and the five most used
46
+ * actions. Typing matches labels, codes and keywords without regard to case or accents ("durovic" finds
47
+ * "Đurović"), and asks `search` for records (the last answer stays while the next loads; a failed search says
48
+ * so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat
49
+ * across groups. When records arrive after the actions, the active row stays where it was (React Aria's
50
+ * Autocomplete keeps its virtual focus); arrows reach the records first in the list.
51
+ * Everything here must also be reachable through visible UI.
52
+ */
53
+ export declare function CommandPalette({ isOpen, defaultOpen, onOpenChange, groups, search, recent, onSelect, shortcut }: CommandPaletteProps): React.JSX.Element;