se-design 1.0.75 → 1.0.76-dev2

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 (484) hide show
  1. package/dist/assets/style.css +1 -1
  2. package/dist/components/AccessibleDiv/index.d.ts +24 -0
  3. package/dist/components/Checkbox/index.d.ts +12 -0
  4. package/dist/components/CustomAccordion/index.d.ts +1 -0
  5. package/dist/components/CustomModal/index.d.ts +15 -12
  6. package/dist/components/DatePicker/useDatePickerA11y.d.ts +50 -0
  7. package/dist/components/Dropdown/index.d.ts +15 -0
  8. package/dist/components/DropdownWithInputTags/index.d.ts +1 -0
  9. package/dist/components/Icon/index.d.ts +8 -2
  10. package/dist/components/InputWithIcon/index.d.ts +9 -1
  11. package/dist/components/LabelChip/index.d.ts +1 -0
  12. package/dist/components/Modal/index.d.ts +1 -0
  13. package/dist/components/PhoneInput/index.d.ts +13 -5
  14. package/dist/components/Popover/index.d.ts +2 -0
  15. package/dist/components/SidebarOverlay/index.d.ts +8 -0
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/index.js +144 -133
  18. package/dist/index.js.map +1 -1
  19. package/dist/index10.js +23 -59
  20. package/dist/index10.js.map +1 -1
  21. package/dist/index100.js +1 -1
  22. package/dist/index100.js.map +1 -1
  23. package/dist/index101.js +1 -1
  24. package/dist/index101.js.map +1 -1
  25. package/dist/index102.js +2 -2
  26. package/dist/index102.js.map +1 -1
  27. package/dist/index103.js +2 -2
  28. package/dist/index103.js.map +1 -1
  29. package/dist/index104.js +1 -1
  30. package/dist/index104.js.map +1 -1
  31. package/dist/index105.js +1 -1
  32. package/dist/index105.js.map +1 -1
  33. package/dist/index106.js +1 -1
  34. package/dist/index106.js.map +1 -1
  35. package/dist/index107.js +2 -2
  36. package/dist/index107.js.map +1 -1
  37. package/dist/index108.js +2 -2
  38. package/dist/index108.js.map +1 -1
  39. package/dist/index109.js +2 -2
  40. package/dist/index109.js.map +1 -1
  41. package/dist/index11.js +70 -63
  42. package/dist/index11.js.map +1 -1
  43. package/dist/index110.js +2 -2
  44. package/dist/index110.js.map +1 -1
  45. package/dist/index111.js +1 -1
  46. package/dist/index111.js.map +1 -1
  47. package/dist/index112.js +1 -1
  48. package/dist/index112.js.map +1 -1
  49. package/dist/index113.js +2 -2
  50. package/dist/index113.js.map +1 -1
  51. package/dist/index114.js +2 -2
  52. package/dist/index114.js.map +1 -1
  53. package/dist/index115.js +1 -1
  54. package/dist/index115.js.map +1 -1
  55. package/dist/index116.js +1 -1
  56. package/dist/index116.js.map +1 -1
  57. package/dist/index117.js +1 -1
  58. package/dist/index117.js.map +1 -1
  59. package/dist/index118.js +2 -2
  60. package/dist/index118.js.map +1 -1
  61. package/dist/index119.js +1 -1
  62. package/dist/index119.js.map +1 -1
  63. package/dist/index12.js +68 -33
  64. package/dist/index12.js.map +1 -1
  65. package/dist/index120.js +2 -2
  66. package/dist/index120.js.map +1 -1
  67. package/dist/index121.js +2 -2
  68. package/dist/index121.js.map +1 -1
  69. package/dist/index122.js +2 -2
  70. package/dist/index122.js.map +1 -1
  71. package/dist/index123.js +2 -2
  72. package/dist/index123.js.map +1 -1
  73. package/dist/index124.js +2 -2
  74. package/dist/index124.js.map +1 -1
  75. package/dist/index125.js +2 -2
  76. package/dist/index125.js.map +1 -1
  77. package/dist/index126.js +1 -1
  78. package/dist/index126.js.map +1 -1
  79. package/dist/index127.js +1 -1
  80. package/dist/index127.js.map +1 -1
  81. package/dist/index128.js +1 -1
  82. package/dist/index128.js.map +1 -1
  83. package/dist/index129.js +1 -1
  84. package/dist/index129.js.map +1 -1
  85. package/dist/index13.js +48 -14
  86. package/dist/index13.js.map +1 -1
  87. package/dist/index130.js +2 -2
  88. package/dist/index130.js.map +1 -1
  89. package/dist/index131.js +2 -2
  90. package/dist/index131.js.map +1 -1
  91. package/dist/index132.js +1 -1
  92. package/dist/index132.js.map +1 -1
  93. package/dist/index133.js +1 -1
  94. package/dist/index133.js.map +1 -1
  95. package/dist/index134.js +2 -2
  96. package/dist/index134.js.map +1 -1
  97. package/dist/index135.js +1 -1
  98. package/dist/index135.js.map +1 -1
  99. package/dist/index136.js +1 -1
  100. package/dist/index136.js.map +1 -1
  101. package/dist/index137.js +1 -1
  102. package/dist/index137.js.map +1 -1
  103. package/dist/index138.js +1 -1
  104. package/dist/index138.js.map +1 -1
  105. package/dist/index139.js +1 -1
  106. package/dist/index139.js.map +1 -1
  107. package/dist/index14.js +15 -9
  108. package/dist/index14.js.map +1 -1
  109. package/dist/index140.js +1 -1
  110. package/dist/index140.js.map +1 -1
  111. package/dist/index141.js +2 -2
  112. package/dist/index141.js.map +1 -1
  113. package/dist/index142.js +1 -1
  114. package/dist/index142.js.map +1 -1
  115. package/dist/index143.js +2 -2
  116. package/dist/index143.js.map +1 -1
  117. package/dist/index144.js +2 -2
  118. package/dist/index144.js.map +1 -1
  119. package/dist/index145.js +1 -1
  120. package/dist/index145.js.map +1 -1
  121. package/dist/index146.js +2 -2
  122. package/dist/index146.js.map +1 -1
  123. package/dist/index147.js +2 -2
  124. package/dist/index147.js.map +1 -1
  125. package/dist/index148.js +1 -1
  126. package/dist/index148.js.map +1 -1
  127. package/dist/index149.js +1 -1
  128. package/dist/index149.js.map +1 -1
  129. package/dist/index15.js +10 -218
  130. package/dist/index15.js.map +1 -1
  131. package/dist/index150.js +2 -2
  132. package/dist/index150.js.map +1 -1
  133. package/dist/index151.js +2 -2
  134. package/dist/index151.js.map +1 -1
  135. package/dist/index152.js +1 -1
  136. package/dist/index152.js.map +1 -1
  137. package/dist/index153.js +2 -2
  138. package/dist/index153.js.map +1 -1
  139. package/dist/index154.js +2 -2
  140. package/dist/index154.js.map +1 -1
  141. package/dist/index155.js +1 -1
  142. package/dist/index155.js.map +1 -1
  143. package/dist/index156.js +1 -1
  144. package/dist/index156.js.map +1 -1
  145. package/dist/index157.js +1 -1
  146. package/dist/index157.js.map +1 -1
  147. package/dist/index158.js +1 -1
  148. package/dist/index158.js.map +1 -1
  149. package/dist/index159.js +1 -1
  150. package/dist/index159.js.map +1 -1
  151. package/dist/index16.js +220 -60
  152. package/dist/index16.js.map +1 -1
  153. package/dist/index160.js +1 -1
  154. package/dist/index160.js.map +1 -1
  155. package/dist/index161.js +1 -1
  156. package/dist/index161.js.map +1 -1
  157. package/dist/index162.js +1 -1
  158. package/dist/index162.js.map +1 -1
  159. package/dist/index163.js +1 -1
  160. package/dist/index163.js.map +1 -1
  161. package/dist/index164.js +1 -1
  162. package/dist/index164.js.map +1 -1
  163. package/dist/index165.js +1 -1
  164. package/dist/index165.js.map +1 -1
  165. package/dist/index166.js +1 -1
  166. package/dist/index166.js.map +1 -1
  167. package/dist/index167.js +1 -1
  168. package/dist/index167.js.map +1 -1
  169. package/dist/index168.js +1 -1
  170. package/dist/index168.js.map +1 -1
  171. package/dist/index169.js +1 -1
  172. package/dist/index169.js.map +1 -1
  173. package/dist/index17.js +60 -99
  174. package/dist/index17.js.map +1 -1
  175. package/dist/index170.js +1 -1
  176. package/dist/index170.js.map +1 -1
  177. package/dist/index171.js +1 -1
  178. package/dist/index171.js.map +1 -1
  179. package/dist/index172.js +1 -1
  180. package/dist/index172.js.map +1 -1
  181. package/dist/index173.js +2 -2
  182. package/dist/index173.js.map +1 -1
  183. package/dist/index174.js +1 -1
  184. package/dist/index174.js.map +1 -1
  185. package/dist/index175.js +1 -1
  186. package/dist/index175.js.map +1 -1
  187. package/dist/index176.js +1 -1
  188. package/dist/index176.js.map +1 -1
  189. package/dist/index177.js +2 -2
  190. package/dist/index177.js.map +1 -1
  191. package/dist/index178.js +1 -1
  192. package/dist/index178.js.map +1 -1
  193. package/dist/index179.js +1 -1
  194. package/dist/index179.js.map +1 -1
  195. package/dist/index18.js +95 -282
  196. package/dist/index18.js.map +1 -1
  197. package/dist/index180.js +2 -2
  198. package/dist/index180.js.map +1 -1
  199. package/dist/index181.js +1 -1
  200. package/dist/index181.js.map +1 -1
  201. package/dist/index182.js +1 -1
  202. package/dist/index182.js.map +1 -1
  203. package/dist/index183.js +1 -1
  204. package/dist/index183.js.map +1 -1
  205. package/dist/index184.js +2 -2
  206. package/dist/index184.js.map +1 -1
  207. package/dist/index185.js +1 -1
  208. package/dist/index185.js.map +1 -1
  209. package/dist/index186.js +1 -1
  210. package/dist/index186.js.map +1 -1
  211. package/dist/index187.js +2 -2
  212. package/dist/index187.js.map +1 -1
  213. package/dist/index188.js +1 -1
  214. package/dist/index188.js.map +1 -1
  215. package/dist/index189.js +2 -2
  216. package/dist/index189.js.map +1 -1
  217. package/dist/index19.js +323 -16
  218. package/dist/index19.js.map +1 -1
  219. package/dist/index190.js +2 -149
  220. package/dist/index190.js.map +1 -1
  221. package/dist/index191.js +2 -9
  222. package/dist/index191.js.map +1 -1
  223. package/dist/index192.js +2 -6
  224. package/dist/index192.js.map +1 -1
  225. package/dist/index193.js +2 -5
  226. package/dist/index193.js.map +1 -1
  227. package/dist/index194.js +2 -40
  228. package/dist/index194.js.map +1 -1
  229. package/dist/index195.js +2 -59
  230. package/dist/index195.js.map +1 -1
  231. package/dist/index196.js +2 -23
  232. package/dist/index196.js.map +1 -1
  233. package/dist/index197.js +152 -0
  234. package/dist/index197.js.map +1 -0
  235. package/dist/index198.js +12 -0
  236. package/dist/index198.js.map +1 -0
  237. package/dist/index199.js +5 -23
  238. package/dist/index199.js.map +1 -1
  239. package/dist/index20.js +15 -31
  240. package/dist/index20.js.map +1 -1
  241. package/dist/index200.js +8 -0
  242. package/dist/index200.js.map +1 -0
  243. package/dist/index201.js +36 -80
  244. package/dist/index201.js.map +1 -1
  245. package/dist/index206.js +26 -0
  246. package/dist/index206.js.map +1 -0
  247. package/dist/index207.js +71 -0
  248. package/dist/index207.js.map +1 -0
  249. package/dist/index21.js +33 -61
  250. package/dist/index21.js.map +1 -1
  251. package/dist/{index210.js → index215.js} +1 -1
  252. package/dist/{index210.js.map → index215.js.map} +1 -1
  253. package/dist/index22.js +57 -76
  254. package/dist/index22.js.map +1 -1
  255. package/dist/{index218.js → index223.js} +1 -1
  256. package/dist/{index218.js.map → index223.js.map} +1 -1
  257. package/dist/{index221.js → index226.js} +2 -2
  258. package/dist/{index221.js.map → index226.js.map} +1 -1
  259. package/dist/index23.js +83 -21
  260. package/dist/index23.js.map +1 -1
  261. package/dist/index235.js +171 -8
  262. package/dist/index235.js.map +1 -1
  263. package/dist/index236.js +3 -9
  264. package/dist/index236.js.map +1 -1
  265. package/dist/index238.js +18 -169
  266. package/dist/index238.js.map +1 -1
  267. package/dist/index239.js +10 -11
  268. package/dist/index239.js.map +1 -1
  269. package/dist/index24.js +20 -222
  270. package/dist/index24.js.map +1 -1
  271. package/dist/index240.js +8 -4
  272. package/dist/index240.js.map +1 -1
  273. package/dist/index241.js +4 -5
  274. package/dist/index241.js.map +1 -1
  275. package/dist/index242.js +168 -36
  276. package/dist/index242.js.map +1 -1
  277. package/dist/index243.js +11 -2
  278. package/dist/index243.js.map +1 -1
  279. package/dist/index244.js +5 -7
  280. package/dist/index244.js.map +1 -1
  281. package/dist/index245.js +5 -326
  282. package/dist/index245.js.map +1 -1
  283. package/dist/index246.js +36 -48
  284. package/dist/index246.js.map +1 -1
  285. package/dist/index247.js +2 -2
  286. package/dist/index248.js +7 -75
  287. package/dist/index248.js.map +1 -1
  288. package/dist/index249.js +308 -74
  289. package/dist/index249.js.map +1 -1
  290. package/dist/index25.js +299 -43
  291. package/dist/index25.js.map +1 -1
  292. package/dist/index250.js +45 -47
  293. package/dist/index250.js.map +1 -1
  294. package/dist/index251.js +2 -8
  295. package/dist/index251.js.map +1 -1
  296. package/dist/index252.js +75 -4
  297. package/dist/index252.js.map +1 -1
  298. package/dist/index253.js +89 -48
  299. package/dist/index253.js.map +1 -1
  300. package/dist/index254.js +52 -2
  301. package/dist/index254.js.map +1 -1
  302. package/dist/index255.js +8 -2
  303. package/dist/index255.js.map +1 -1
  304. package/dist/index256.js +8 -0
  305. package/dist/index256.js.map +1 -0
  306. package/dist/index257.js +55 -0
  307. package/dist/index257.js.map +1 -0
  308. package/dist/index258.js +5 -0
  309. package/dist/index258.js.map +1 -0
  310. package/dist/index259.js +5 -0
  311. package/dist/index259.js.map +1 -0
  312. package/dist/index26.js +48 -23
  313. package/dist/index26.js.map +1 -1
  314. package/dist/index27.js +21 -81
  315. package/dist/index27.js.map +1 -1
  316. package/dist/index28.js +101 -138
  317. package/dist/index28.js.map +1 -1
  318. package/dist/index29.js +139 -128
  319. package/dist/index29.js.map +1 -1
  320. package/dist/index3.js +57 -98
  321. package/dist/index3.js.map +1 -1
  322. package/dist/index30.js +133 -69
  323. package/dist/index30.js.map +1 -1
  324. package/dist/index31.js +67 -96
  325. package/dist/index31.js.map +1 -1
  326. package/dist/index32.js +96 -71
  327. package/dist/index32.js.map +1 -1
  328. package/dist/index33.js +70 -38
  329. package/dist/index33.js.map +1 -1
  330. package/dist/index34.js +40 -71
  331. package/dist/index34.js.map +1 -1
  332. package/dist/index35.js +67 -82
  333. package/dist/index35.js.map +1 -1
  334. package/dist/index36.js +99 -54
  335. package/dist/index36.js.map +1 -1
  336. package/dist/index37.js +53 -280
  337. package/dist/index37.js.map +1 -1
  338. package/dist/index38.js +283 -70
  339. package/dist/index38.js.map +1 -1
  340. package/dist/index39.js +69 -80
  341. package/dist/index39.js.map +1 -1
  342. package/dist/index4.js +102 -42
  343. package/dist/index4.js.map +1 -1
  344. package/dist/index40.js +82 -32
  345. package/dist/index40.js.map +1 -1
  346. package/dist/index41.js +26 -44
  347. package/dist/index41.js.map +1 -1
  348. package/dist/index42.js +45 -67
  349. package/dist/index42.js.map +1 -1
  350. package/dist/index43.js +65 -49
  351. package/dist/index43.js.map +1 -1
  352. package/dist/index44.js +53 -139
  353. package/dist/index44.js.map +1 -1
  354. package/dist/index45.js +132 -179
  355. package/dist/index45.js.map +1 -1
  356. package/dist/index46.js +194 -35
  357. package/dist/index46.js.map +1 -1
  358. package/dist/index47.js +34 -29
  359. package/dist/index47.js.map +1 -1
  360. package/dist/index48.js +31 -145
  361. package/dist/index48.js.map +1 -1
  362. package/dist/index49.js +131 -70
  363. package/dist/index49.js.map +1 -1
  364. package/dist/index5.js +40 -315
  365. package/dist/index5.js.map +1 -1
  366. package/dist/index50.js +80 -371
  367. package/dist/index50.js.map +1 -1
  368. package/dist/index51.js +451 -91
  369. package/dist/index51.js.map +1 -1
  370. package/dist/index52.js +98 -38
  371. package/dist/index52.js.map +1 -1
  372. package/dist/index53.js +35 -35
  373. package/dist/index53.js.map +1 -1
  374. package/dist/index54.js +35 -90
  375. package/dist/index54.js.map +1 -1
  376. package/dist/index55.js +89 -159
  377. package/dist/index55.js.map +1 -1
  378. package/dist/index56.js +157 -143
  379. package/dist/index56.js.map +1 -1
  380. package/dist/index57.js +149 -33
  381. package/dist/index57.js.map +1 -1
  382. package/dist/index58.js +33 -86
  383. package/dist/index58.js.map +1 -1
  384. package/dist/index59.js +80 -113
  385. package/dist/index59.js.map +1 -1
  386. package/dist/index6.js +323 -43
  387. package/dist/index6.js.map +1 -1
  388. package/dist/index60.js +114 -62
  389. package/dist/index60.js.map +1 -1
  390. package/dist/index61.js +62 -147
  391. package/dist/index61.js.map +1 -1
  392. package/dist/index62.js +146 -312
  393. package/dist/index62.js.map +1 -1
  394. package/dist/index63.js +317 -44
  395. package/dist/index63.js.map +1 -1
  396. package/dist/index64.js +44 -143
  397. package/dist/index64.js.map +1 -1
  398. package/dist/index65.js +145 -12
  399. package/dist/index65.js.map +1 -1
  400. package/dist/index66.js +10 -44
  401. package/dist/index66.js.map +1 -1
  402. package/dist/index67.js +42 -15
  403. package/dist/index67.js.map +1 -1
  404. package/dist/index68.js +76 -48
  405. package/dist/index68.js.map +1 -1
  406. package/dist/index69.js +18 -58
  407. package/dist/index69.js.map +1 -1
  408. package/dist/index7.js +44 -51
  409. package/dist/index7.js.map +1 -1
  410. package/dist/index70.js +66 -5
  411. package/dist/index70.js.map +1 -1
  412. package/dist/index71.js +25 -7
  413. package/dist/index71.js.map +1 -1
  414. package/dist/index72.js +105 -0
  415. package/dist/index72.js.map +1 -0
  416. package/dist/index73.js +62 -2
  417. package/dist/index73.js.map +1 -1
  418. package/dist/index74.js +21 -2
  419. package/dist/index74.js.map +1 -1
  420. package/dist/index75.js +5 -2
  421. package/dist/index75.js.map +1 -1
  422. package/dist/index76.js +54 -2
  423. package/dist/index76.js.map +1 -1
  424. package/dist/index77.js +24 -2
  425. package/dist/index77.js.map +1 -1
  426. package/dist/index78.js +9 -2
  427. package/dist/index78.js.map +1 -1
  428. package/dist/index8.js +48 -85
  429. package/dist/index8.js.map +1 -1
  430. package/dist/index80.js +2 -2
  431. package/dist/index80.js.map +1 -1
  432. package/dist/index81.js +2 -2
  433. package/dist/index81.js.map +1 -1
  434. package/dist/index82.js +1 -1
  435. package/dist/index82.js.map +1 -1
  436. package/dist/index83.js +2 -2
  437. package/dist/index83.js.map +1 -1
  438. package/dist/index84.js +1 -1
  439. package/dist/index84.js.map +1 -1
  440. package/dist/index85.js +1 -1
  441. package/dist/index85.js.map +1 -1
  442. package/dist/index86.js +1 -1
  443. package/dist/index86.js.map +1 -1
  444. package/dist/index87.js +1 -1
  445. package/dist/index87.js.map +1 -1
  446. package/dist/index88.js +1 -1
  447. package/dist/index88.js.map +1 -1
  448. package/dist/index89.js +1 -1
  449. package/dist/index89.js.map +1 -1
  450. package/dist/index9.js +91 -27
  451. package/dist/index9.js.map +1 -1
  452. package/dist/index90.js +1 -1
  453. package/dist/index90.js.map +1 -1
  454. package/dist/index91.js +1 -1
  455. package/dist/index91.js.map +1 -1
  456. package/dist/index92.js +1 -1
  457. package/dist/index92.js.map +1 -1
  458. package/dist/index93.js +1 -1
  459. package/dist/index93.js.map +1 -1
  460. package/dist/index94.js +1 -1
  461. package/dist/index94.js.map +1 -1
  462. package/dist/index95.js +1 -1
  463. package/dist/index95.js.map +1 -1
  464. package/dist/index96.js +1 -1
  465. package/dist/index96.js.map +1 -1
  466. package/dist/index97.js +1 -1
  467. package/dist/index97.js.map +1 -1
  468. package/dist/index98.js +1 -1
  469. package/dist/index98.js.map +1 -1
  470. package/dist/index99.js +1 -1
  471. package/dist/index99.js.map +1 -1
  472. package/package.json +1 -1
  473. package/dist/index230.js +0 -7
  474. package/dist/index230.js.map +0 -1
  475. package/dist/index232.js +0 -25
  476. package/dist/index232.js.map +0 -1
  477. package/dist/index233.js +0 -57
  478. package/dist/index233.js.map +0 -1
  479. package/dist/index234.js +0 -22
  480. package/dist/index234.js.map +0 -1
  481. package/dist/index237.js +0 -8
  482. package/dist/index237.js.map +0 -1
  483. package/dist/index79.js +0 -5
  484. package/dist/index79.js.map +0 -1
package/dist/index68.js CHANGED
@@ -1,59 +1,87 @@
1
- import * as c from "react";
2
- function R({
3
- itemIds: n,
4
- tabIndex: i = 0,
5
- defaultFocusedId: l,
6
- orientation: o = "horizontal",
7
- cols: u,
1
+ import { useRef as u, useCallback as f, useEffect as P } from "react";
2
+ import { useComboboxNavigation as y } from "./index76.js";
3
+ import { useDismissOnFocusOut as R } from "./index77.js";
4
+ function M({
5
+ items: l,
6
+ isOpen: t,
7
+ onOpenChange: s,
8
+ onSelect: g,
9
+ listboxId: n,
8
10
  loop: h = !0,
9
- onFocusChange: x
11
+ disabled: x = !1,
12
+ optionSelector: b = '[role="option"]',
13
+ hasItems: c
10
14
  }) {
11
- const [a, g] = c.useState(l || n[0] || ""), b = c.useRef({});
12
- c.useEffect(() => {
13
- if (n.length > 0 && !n.includes(a)) {
14
- const e = l || n[0] || "";
15
- g(e);
15
+ const d = u(null), r = u(!1), i = u(!1), m = c !== void 0 ? c : l.length > 0, a = f(() => {
16
+ s(!1);
17
+ }, [s]);
18
+ P(() => {
19
+ t || (r.current = !1);
20
+ }, [t]);
21
+ const e = y({
22
+ items: l,
23
+ isOpen: t,
24
+ onSelect: g,
25
+ onClose: a,
26
+ onOpen: () => s(!0),
27
+ loop: h,
28
+ disabled: x,
29
+ listboxRef: d,
30
+ optionSelector: b
31
+ }), p = R({
32
+ onFocusOut: a,
33
+ onEscape: a,
34
+ disabled: !t
35
+ }), v = {
36
+ ...p,
37
+ onBlurCapture: (o) => {
38
+ if (!r.current) {
39
+ if (i.current) {
40
+ i.current = !1;
41
+ return;
42
+ }
43
+ p.onBlurCapture(o);
44
+ }
16
45
  }
17
- }, [n, a, l]);
18
- const k = c.useCallback((e) => {
19
- g(e), x?.(e);
20
- }, [x]), v = c.useCallback((e, t = 1) => {
21
- if (n.length === 0) return;
22
- const f = n.indexOf(a), s = Math.max(0, f);
23
- let r = s;
24
- switch (e) {
25
- case "first":
26
- r = 0;
27
- break;
28
- case "last":
29
- r = n.length - 1;
30
- break;
31
- case "prev":
32
- h ? r = (s - t + n.length) % n.length : r = Math.max(0, s - t);
33
- break;
34
- case "next":
35
- h ? r = (s + t) % n.length : r = Math.min(n.length - 1, s + t);
36
- break;
46
+ }, I = {
47
+ role: "combobox",
48
+ "aria-expanded": t && m,
49
+ "aria-haspopup": "listbox",
50
+ "aria-controls": t ? n : void 0,
51
+ "aria-autocomplete": "list",
52
+ "aria-activedescendant": e.highlightedIndex >= 0 ? e.getOptionId(n, e.highlightedIndex) : void 0,
53
+ onKeyDown: (o) => {
54
+ o.key === "Tab" && (i.current = !0), e.handleKeyDown(o);
37
55
  }
38
- const w = n[r];
39
- w && b.current[w]?.focus();
40
- }, [n, a, h]), y = c.useCallback((e) => ({
41
- ref: (t) => {
42
- b.current[e] = t;
56
+ }, w = {
57
+ id: n,
58
+ role: "listbox",
59
+ ref: d,
60
+ onMouseDownCapture: (o) => {
61
+ r.current = !0;
43
62
  },
44
- tabIndex: a === e ? i : -1,
45
- onFocus: () => k(e)
46
- }), [a, i, k]), p = c.useCallback((e) => {
47
- let t = null, f = 1;
48
- e.key === "Home" ? t = "first" : e.key === "End" ? t = "last" : (o !== "vertical" && (e.key === "ArrowLeft" ? t = "prev" : e.key === "ArrowRight" && (t = "next")), !t && o !== "horizontal" && (e.key === "ArrowUp" ? t = "prev" : e.key === "ArrowDown" && (t = "next"), t && u && (f = u))), t && (e.preventDefault(), e.stopPropagation(), v(t, f));
49
- }, [o, u, v]);
63
+ onMouseUpCapture: (o) => {
64
+ r.current = !1;
65
+ },
66
+ onMouseLeave: (o) => {
67
+ r.current = !1;
68
+ }
69
+ }, C = f((o, D = !1) => ({
70
+ id: e.getOptionId(n, o),
71
+ role: "option",
72
+ "aria-selected": D
73
+ }), [e.getOptionId, n]);
50
74
  return {
51
- setFocusedId: k,
52
- handleKeyDown: p,
53
- getRovingItemProps: y
75
+ containerProps: v,
76
+ inputProps: I,
77
+ listboxProps: w,
78
+ getOptionProps: C,
79
+ highlightedIndex: e.highlightedIndex,
80
+ setHighlightedIndex: e.setHighlightedIndex,
81
+ getOptionId: e.getOptionId
54
82
  };
55
83
  }
56
84
  export {
57
- R as useRovingFocus
85
+ M as useCombobox
58
86
  };
59
87
  //# sourceMappingURL=index68.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index68.js","sources":["../src/utils/a11y/useRovingFocus.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type RovingDirection = 'prev' | 'next' | 'first' | 'last';\n\nexport interface UseRovingFocusOptions {\n /**\n * Array of item IDs in order\n */\n itemIds: string[];\n\n /**\n * The tabIndex to apply to the currently focused item in the roving group.\n * Defaults to 0 \n */\n tabIndex?: number;\n\n /**\n * Initial focused item ID. Defaults to first item.\n */\n defaultFocusedId?: string;\n\n /**\n * Orientation for arrow key mapping.\n * - horizontal: ArrowLeft/ArrowRight\n * - vertical: ArrowUp/ArrowDown\n * - grid: all four arrow keys (Left/Right move by 1, Up/Down move by `cols`)\n */\n orientation?: 'horizontal' | 'vertical' | 'grid';\n\n /**\n * Number of columns in the grid. Required when orientation is 'grid'.\n * ArrowUp/ArrowDown navigate by this many items in the flat itemIds array.\n */\n cols?: number;\n\n /**\n * Whether navigation wraps around at ends. Defaults to true.\n */\n loop?: boolean;\n\n /**\n * Callback when focus changes\n */\n onFocusChange?: (id: string) => void;\n}\n\nexport interface RovingItemProps {\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n onFocus: () => void;\n}\n\nexport interface UseRovingFocusReturn {\n /**\n * Set focused item ID manually\n */\n setFocusedId: (id: string) => void;\n\n /**\n * Keyboard handler for arrow/Home/End navigation.\n * Attach to each item's onKeyDown.\n */\n handleKeyDown: (e: React.KeyboardEvent) => void;\n\n /**\n * Get props for an item in the roving focus group (ref + tabIndex)\n */\n getRovingItemProps: (id: string) => RovingItemProps;\n}\n\n/**\n * Hook for managing roving focus pattern (roving tabindex).\n * Reusable for composite widgets: tabs, toolbars, menus, listboxes, radio groups, grids.\n *\n * @example\n * // 1D (toolbar/tabs):\n * const { getRovingItemProps, handleKeyDown } = useRovingFocus({\n * itemIds: ['tab1', 'tab2', 'tab3'],\n * orientation: 'horizontal'\n * });\n *\n * // 2D (grid — flat itemIds, cols for row-jump math):\n * const { getRovingItemProps, handleKeyDown } = useRovingFocus({\n * itemIds: ['r0c0', 'r0c1', 'r0c2', 'r1c0', 'r1c1', 'r1c2'],\n * orientation: 'grid',\n * cols: 3\n * });\n *\n * // In render:\n * <button {...getRovingItemProps('tab1')} onKeyDown={handleKeyDown}>Tab 1</button>\n */\nexport function useRovingFocus({\n itemIds,\n tabIndex = 0,\n defaultFocusedId,\n orientation = 'horizontal',\n cols,\n loop = true,\n onFocusChange\n}: UseRovingFocusOptions): UseRovingFocusReturn {\n const [focusedId, setFocusedIdState] = React.useState<string>(\n defaultFocusedId || itemIds[0] || ''\n );\n\n const itemRefs = React.useRef<Record<string, HTMLElement | null>>({});\n\n // Sync focusedId if itemIds change and current focusedId is no longer valid\n React.useEffect(() => {\n if (itemIds.length > 0 && !itemIds.includes(focusedId)) {\n const newFocusedId = defaultFocusedId || itemIds[0] || '';\n setFocusedIdState(newFocusedId);\n }\n }, [itemIds, focusedId, defaultFocusedId]);\n\n const setFocusedId = React.useCallback(\n (id: string) => {\n setFocusedIdState(id);\n onFocusChange?.(id);\n },\n [onFocusChange]\n );\n\n const moveFocus = React.useCallback(\n (direction: RovingDirection, step: number = 1) => {\n if (itemIds.length === 0) return;\n\n const currentIdx = itemIds.indexOf(focusedId);\n const safeIdx = Math.max(0, currentIdx);\n let nextIdx = safeIdx;\n\n switch (direction) {\n case 'first':\n nextIdx = 0;\n break;\n case 'last':\n nextIdx = itemIds.length - 1;\n break;\n case 'prev':\n if (loop) {\n nextIdx = (safeIdx - step + itemIds.length) % itemIds.length;\n } else {\n nextIdx = Math.max(0, safeIdx - step);\n }\n break;\n case 'next':\n if (loop) {\n nextIdx = (safeIdx + step) % itemIds.length;\n } else {\n nextIdx = Math.min(itemIds.length - 1, safeIdx + step);\n }\n break;\n }\n\n const nextId = itemIds[nextIdx];\n if (!nextId) return;\n\n itemRefs.current[nextId]?.focus();\n },\n [itemIds, focusedId, loop]\n );\n\n const getRovingItemProps = React.useCallback(\n (id: string): RovingItemProps => ({\n ref: (el: HTMLElement | null) => {\n itemRefs.current[id] = el;\n },\n tabIndex: focusedId === id ? tabIndex : -1,\n onFocus: () => setFocusedId(id)\n }),\n [focusedId, tabIndex, setFocusedId]\n );\n\n // Keyboard handler for arrow/Home/End navigation\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n let direction: RovingDirection | null = null;\n let step = 1;\n\n if (e.key === 'Home') {\n direction = 'first';\n } else if (e.key === 'End') {\n direction = 'last';\n } else {\n // Horizontal axis (Left/Right) — active for 'horizontal' and 'grid'\n if (orientation !== 'vertical') {\n if (e.key === 'ArrowLeft') direction = 'prev';\n else if (e.key === 'ArrowRight') direction = 'next';\n }\n // Vertical axis (Up/Down) — active for 'vertical' and 'grid'\n if (!direction && orientation !== 'horizontal') {\n if (e.key === 'ArrowUp') direction = 'prev';\n else if (e.key === 'ArrowDown') direction = 'next';\n if (direction && cols) step = cols;\n }\n }\n\n if (direction) {\n e.preventDefault();\n e.stopPropagation();\n moveFocus(direction, step);\n }\n },\n [orientation, cols, moveFocus]\n );\n\n return {\n setFocusedId,\n handleKeyDown,\n getRovingItemProps\n };\n}\n"],"names":["React","useRovingFocus","itemIds","tabIndex","defaultFocusedId","orientation","cols","loop","onFocusChange","focusedId","setFocusedIdState","useState","itemRefs","useRef","useEffect","length","includes","newFocusedId","setFocusedId","useCallback","id","moveFocus","direction","step","currentIdx","indexOf","safeIdx","Math","max","nextIdx","min","nextId","current","focus","getRovingItemProps","ref","el","onFocus","handleKeyDown","e","key","preventDefault","stopPropagation"],"mappings":"AA2FO,YAAAA,OAAA;AAAA,SAASC,EAAe;AAAA,EAC7BC,SAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,kBAAAA;AAAAA,EACAC,aAAAA,IAAc;AAAA,EACdC,MAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACPC,eAAAA;AACqB,GAAyB;AACxC,QAAA,CAACC,GAAWC,CAAiB,IAAIV,EAAMW,SAC3CP,KAAoBF,EAAQ,CAAC,KAAK,EACpC,GAEMU,IAAWZ,EAAMa,OAA2C,CAAE,CAAA;AAGpEb,EAAAA,EAAMc,UAAU,MAAM;AACpB,QAAIZ,EAAQa,SAAS,KAAK,CAACb,EAAQc,SAASP,CAAS,GAAG;AACtD,YAAMQ,IAAeb,KAAoBF,EAAQ,CAAC,KAAK;AACvDQ,MAAAA,EAAkBO,CAAY;AAAA,IAChC;AAAA,EACC,GAAA,CAACf,GAASO,GAAWL,CAAgB,CAAC;AAEzC,QAAMc,IAAelB,EAAMmB,YACzB,CAACC,MAAe;AACdV,IAAAA,EAAkBU,CAAE,GACpBZ,IAAgBY,CAAE;AAAA,EAAA,GAEpB,CAACZ,CAAa,CAChB,GAEMa,IAAYrB,EAAMmB,YACtB,CAACG,GAA4BC,IAAe,MAAM;AAC5CrB,QAAAA,EAAQa,WAAW,EAAG;AAEpBS,UAAAA,IAAatB,EAAQuB,QAAQhB,CAAS,GACtCiB,IAAUC,KAAKC,IAAI,GAAGJ,CAAU;AACtC,QAAIK,IAAUH;AAEd,YAAQJ,GAAS;AAAA,MACf,KAAK;AACO,QAAAO,IAAA;AACV;AAAA,MACF,KAAK;AACHA,QAAAA,IAAU3B,EAAQa,SAAS;AAC3B;AAA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AC/B;AAEO,SAAA;AAAA,IACLH,cAAAA;AAAAA,IACAoB,eAAAA;AAAAA,IACAJ,oBAAAA;AAAAA,EAAAA;AAEJ;"}
1
+ {"version":3,"file":"index68.js","sources":["../src/utils/a11y/useCombobox.ts"],"sourcesContent":["import { useRef, useCallback, useEffect } from 'react';\nimport type { RefObject } from 'react';\nimport { useComboboxNavigation } from './useComboboxNavigation';\nimport { useDismissOnFocusOut } from './useDismissOnFocusOut';\nimport type { UseDismissOnFocusOutReturn } from './useDismissOnFocusOut';\n\nexport interface UseComboboxOptions<T = any> {\n /**\n * Array of items to navigate through\n */\n items: T[];\n \n /**\n * Whether the dropdown is currently open\n */\n isOpen: boolean;\n \n /**\n * Callback to change the open state\n */\n onOpenChange: (open: boolean) => void;\n \n /**\n * Callback when an item is selected (Enter key)\n */\n onSelect: (item: T, index: number) => void;\n \n /**\n * Stable ID for the listbox element\n */\n listboxId: string;\n \n /**\n * Whether to wrap around at the ends of the list.\n * Default: true\n */\n loop?: boolean;\n \n /**\n * Whether keyboard navigation is disabled\n * (e.g., for custom rendered content)\n */\n disabled?: boolean;\n \n /**\n * CSS selector for option elements (default: '[role=\"option\"]')\n */\n optionSelector?: string;\n \n /**\n * Whether the listbox has any items to show\n * Used for aria-expanded logic\n * Default: items.length > 0\n */\n hasItems?: boolean;\n}\n\nexport interface UseComboboxReturn {\n /**\n * Props to spread on the container element (handles dismiss on focus out)\n */\n containerProps: UseDismissOnFocusOutReturn<HTMLElement>;\n \n /**\n * Props to spread on the combobox input element\n */\n inputProps: {\n role: 'combobox';\n 'aria-expanded': boolean;\n 'aria-haspopup': 'listbox';\n 'aria-controls': string | undefined;\n 'aria-autocomplete': 'list';\n 'aria-activedescendant': string | undefined;\n onKeyDown: (e: React.KeyboardEvent) => void;\n };\n \n /**\n * Props to spread on the listbox element\n */\n listboxProps: {\n id: string;\n role: 'listbox';\n ref: RefObject<HTMLDivElement | null>;\n onMouseDownCapture: (e: React.MouseEvent) => void;\n onMouseUpCapture: (e: React.MouseEvent) => void;\n onMouseLeave: (e: React.MouseEvent) => void;\n };\n \n /**\n * Generate props for an option element at the given index\n * @param selected - Whether this option is the currently selected/chosen value (not keyboard highlight)\n */\n getOptionProps: (index: number, selected?: boolean) => {\n id: string;\n role: 'option';\n 'aria-selected': boolean;\n };\n \n /**\n * Currently highlighted index (-1 if none)\n */\n highlightedIndex: number;\n \n /**\n * Set the highlighted index manually\n */\n setHighlightedIndex: (index: number | ((prev: number) => number)) => void;\n \n /**\n * Generate stable ID for an option\n */\n getOptionId: (listboxId: string, index: number) => string;\n}\n\n/**\n * Comprehensive hook for implementing WAI-ARIA combobox pattern.\n * \n * Combines:\n * - Keyboard navigation (Arrow Up/Down, Enter, Escape, Tab)\n * - Focus management and dismissal\n * - ARIA attributes for accessibility\n * - Auto-scroll highlighted item into view\n * \n * This hook provides a complete, batteries-included solution for building\n * accessible combobox components (autocomplete, select, search with suggestions, etc.)\n * \n * @example Basic usage\n * ```tsx\n * const MyCombobox = () => {\n * const [isOpen, setIsOpen] = useState(false);\n * const [items, setItems] = useState(['Apple', 'Banana', 'Cherry']);\n * \n * const {\n * containerProps,\n * inputProps,\n * listboxProps,\n * getOptionProps,\n * highlightedIndex\n * } = useCombobox({\n * items,\n * isOpen,\n * onOpenChange: setIsOpen,\n * onSelect: (item) => console.log('Selected:', item),\n * listboxId: 'my-listbox'\n * });\n * \n * return (\n * <div {...containerProps}>\n * <input {...inputProps} />\n * {isOpen && (\n * <div {...listboxProps}>\n * {items.map((item, i) => (\n * <div key={i} {...getOptionProps(i)}>\n * {item}\n * </div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * };\n * ```\n * \n * @example With custom ARIA labels and handlers\n * ```tsx\n * const MySearchBox = () => {\n * const [query, setQuery] = useState('');\n * const [suggestions, setSuggestions] = useState([]);\n * const [isOpen, setIsOpen] = useState(false);\n * \n * const { containerProps, inputProps, listboxProps, getOptionProps } = useCombobox({\n * items: suggestions,\n * isOpen,\n * onOpenChange: setIsOpen,\n * onSelect: (suggestion) => {\n * setQuery(suggestion);\n * setIsOpen(false);\n * },\n * listboxId: 'search-suggestions'\n * });\n * \n * return (\n * <div {...containerProps}>\n * <input\n * {...inputProps}\n * value={query}\n * onChange={(e) => setQuery(e.target.value)}\n * aria-label=\"Search\"\n * />\n * {isOpen && suggestions.length > 0 && (\n * <div {...listboxProps} aria-label=\"Search suggestions\">\n * {suggestions.map((suggestion, i) => (\n * <div\n * key={i}\n * {...getOptionProps(i)}\n * onClick={() => {\n * setQuery(suggestion);\n * setIsOpen(false);\n * }}\n * >\n * {suggestion}\n * </div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * };\n * ```\n */\nexport function useCombobox<T = any>({\n items,\n isOpen,\n onOpenChange,\n onSelect,\n listboxId,\n loop = true,\n disabled = false,\n optionSelector = '[role=\"option\"]',\n hasItems\n}: UseComboboxOptions<T>): UseComboboxReturn {\n const listboxRef = useRef<HTMLDivElement | null>(null);\n const pointerDownInListboxRef = useRef(false);\n const tabKeyPressedRef = useRef(false);\n \n // Determine if we should show as expanded\n const shouldShowExpanded = hasItems !== undefined ? hasItems : items.length > 0;\n \n // Close dropdown callback\n const closeDropdown = useCallback(() => {\n onOpenChange(false);\n }, [onOpenChange]);\n\n // Ensure pointer state doesn't get stuck when listbox unmounts\n useEffect(() => {\n if (!isOpen) {\n pointerDownInListboxRef.current = false;\n }\n }, [isOpen]);\n \n // Keyboard navigation with aria-activedescendant\n const navigation = useComboboxNavigation<T>({\n items,\n isOpen,\n onSelect,\n onClose: closeDropdown,\n onOpen: () => onOpenChange(true),\n loop,\n disabled,\n listboxRef,\n optionSelector\n });\n \n // Focus out / Escape dismissal\n const dismissHandlers = useDismissOnFocusOut({\n onFocusOut: closeDropdown,\n onEscape: closeDropdown,\n disabled: !isOpen\n });\n\n const containerProps: UseDismissOnFocusOutReturn<HTMLElement> = {\n ...dismissHandlers,\n onBlurCapture: (e) => {\n // Clicking inside a listbox option can blur the input (relatedTarget is null),\n // which would dismiss before the click handler runs. Prevent that.\n if (pointerDownInListboxRef.current) return;\n \n // Tab key pressed - let Tab handler close dropdown, skip blur detection\n if (tabKeyPressedRef.current) {\n tabKeyPressedRef.current = false;\n return;\n }\n \n dismissHandlers.onBlurCapture(e);\n }\n };\n \n // Build input props\n const inputProps = {\n role: 'combobox' as const,\n 'aria-expanded': isOpen && shouldShowExpanded,\n 'aria-haspopup': 'listbox' as const,\n 'aria-controls': isOpen ? listboxId : undefined,\n 'aria-autocomplete': 'list' as const,\n 'aria-activedescendant': \n navigation.highlightedIndex >= 0 \n ? navigation.getOptionId(listboxId, navigation.highlightedIndex) \n : undefined,\n onKeyDown: (e: React.KeyboardEvent) => {\n // Set flag when Tab is pressed (before blur fires)\n if (e.key === 'Tab') {\n tabKeyPressedRef.current = true;\n }\n navigation.handleKeyDown(e);\n }\n };\n \n // Build listbox props\n const listboxProps = {\n id: listboxId,\n role: 'listbox' as const,\n ref: listboxRef,\n onMouseDownCapture: (_e: React.MouseEvent) => {\n pointerDownInListboxRef.current = true;\n },\n onMouseUpCapture: (_e: React.MouseEvent) => {\n pointerDownInListboxRef.current = false;\n },\n onMouseLeave: (_e: React.MouseEvent) => {\n pointerDownInListboxRef.current = false;\n }\n };\n \n // Option props generator\n const getOptionProps = useCallback(\n (index: number, selected: boolean = false) => ({\n id: navigation.getOptionId(listboxId, index),\n role: 'option' as const,\n 'aria-selected': selected\n }),\n [navigation.getOptionId, listboxId]\n );\n \n return {\n containerProps,\n inputProps,\n listboxProps,\n getOptionProps,\n highlightedIndex: navigation.highlightedIndex,\n setHighlightedIndex: navigation.setHighlightedIndex,\n getOptionId: navigation.getOptionId\n };\n}\n"],"names":["useRef","useCallback","useEffect","useComboboxNavigation","useDismissOnFocusOut","useCombobox","items","isOpen","onOpenChange","onSelect","listboxId","loop","disabled","optionSelector","hasItems","listboxRef","pointerDownInListboxRef","tabKeyPressedRef","shouldShowExpanded","undefined","length","closeDropdown","current","navigation","onClose","onOpen","dismissHandlers","onFocusOut","onEscape","containerProps","onBlurCapture","e","inputProps","role","highlightedIndex","getOptionId","onKeyDown","key","handleKeyDown","listboxProps","id","ref","onMouseDownCapture","_e","onMouseUpCapture","onMouseLeave","getOptionProps","index","selected","setHighlightedIndex"],"mappings":"AAkNO,SAAA,UAAAA,GAAA,eAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,yBAAAC,SAAA;AAAA,SAAA,wBAAAC,SAAA;AAAA,SAASC,EAAqB;AAAA,EACnCC,OAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACPC,UAAAA,IAAW;AAAA,EACXC,gBAAAA,IAAiB;AAAA,EACjBC,UAAAA;AACqB,GAAsB;AAC3C,QAAMC,IAAaf,EAA8B,IAAI,GAC/CgB,IAA0BhB,EAAO,EAAK,GACtCiB,IAAmBjB,EAAO,EAAK,GAG/BkB,IAAqBJ,MAAaK,SAAYL,IAAWR,EAAMc,SAAS,GAGxEC,IAAgBpB,EAAY,MAAM;AACtCO,IAAAA,EAAa,EAAK;AAAA,EACpB,GAAG,CAACA,CAAY,CAAC;AAGjBN,EAAAA,EAAU,MAAM;AACd,IAAKK,MACHS,EAAwBM,UAAU;AAAA,EAEtC,GAAG,CAACf,CAAM,CAAC;AAGX,QAAMgB,IAAapB,EAAyB;AAAA,IAC1CG,OAAAA;AAAAA,IACAC,QAAAA;AAAAA,IACAE,UAAAA;AAAAA,IACAe,SAASH;AAAAA,IACTI,QAAQA,MAAMjB,EAAa,EAAI;AAAA,IAC/BG,MAAAA;AAAAA,IACAC,UAAAA;AAAAA,IACAG,YAAAA;AAAAA,IACAF,gBAAAA;AAAAA,EAAAA,CACD,GAGKa,IAAkBtB,EAAqB;AAAA,IAC3CuB,YAAYN;AAAAA,IACZO,UAAUP;AAAAA,IACVT,UAAU,CAACL;AAAAA,EAAAA,CACZ,GAEKsB,IAA0D;AAAA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IACAZ,kBAAkBX,EAAWW;AAAAA,IAC7Be,qBAAqB1B,EAAW0B;AAAAA,IAChCd,aAAaZ,EAAWY;AAAAA,EAAAA;AAE5B;"}
package/dist/index69.js CHANGED
@@ -1,62 +1,22 @@
1
- import { useCallback as b } from "react";
2
- import { useRovingFocus as y } from "./index68.js";
3
- const l = (r, t) => `tab${t ? `-${t}` : ""}-${r}`, s = (r, t) => `panel${t ? `-${t}` : ""}-${r}`, R = (r, t) => ({
4
- id: s(r, t),
5
- role: "tabpanel",
6
- "aria-labelledby": l(r, t)
7
- });
8
- function w({
9
- itemIds: r,
10
- orientation: t = "horizontal",
11
- activeItem: n,
12
- idBase: e = "",
13
- includePanelLinks: u = !0,
14
- externalPanelId: a
15
- }) {
16
- const {
17
- setFocusedId: f,
18
- handleKeyDown: p,
19
- getRovingItemProps: c
20
- } = y({
21
- itemIds: r,
22
- defaultFocusedId: n,
23
- orientation: t,
24
- loop: !0
25
- }), g = b((o) => {
26
- const {
27
- ref: T,
28
- tabIndex: $,
29
- onFocus: x
30
- } = c(o), F = n === o;
31
- return {
32
- ref: T,
33
- tabIndex: $,
34
- onFocus: x,
35
- id: l(o, e),
36
- ...u && {
37
- "aria-controls": a ?? s(o, e)
38
- },
39
- "aria-selected": F,
40
- role: "tab"
41
- };
42
- }, [n, c, e, u, a]), P = b((o) => ({
43
- id: s(o, e),
44
- role: "tabpanel",
45
- "aria-labelledby": l(o, e)
46
- }), [e]);
47
- return {
48
- getTabProps: g,
49
- getPanelProps: P,
50
- setFocusedTabId: f,
51
- handleKeyDown: p,
52
- getPanelId: (o) => s(o, e),
53
- getTabId: (o) => l(o, e)
54
- };
1
+ import { useRef as u, useEffect as i } from "react";
2
+ function f(n, {
3
+ targetSelector: r = "#main-content h1",
4
+ fallbackId: c = "main-content"
5
+ } = {}) {
6
+ const t = u(!0);
7
+ i(() => {
8
+ if (t.current) {
9
+ t.current = !1;
10
+ return;
11
+ }
12
+ const o = requestAnimationFrame(() => {
13
+ const e = document.querySelector(r) || document.getElementById(c);
14
+ e && (e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus());
15
+ });
16
+ return () => cancelAnimationFrame(o);
17
+ }, n);
55
18
  }
56
19
  export {
57
- s as getPanelId,
58
- l as getTabId,
59
- R as getTabPanelProps,
60
- w as useTabsA11y
20
+ f as useFocusManagement
61
21
  };
62
22
  //# sourceMappingURL=index69.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index69.js","sources":["../src/utils/a11y/useTabsA11y.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useRovingFocus } from './useRovingFocus';\n\nexport const getTabId = (itemId: string, idBase: string) => {\n const suffix = idBase ? `-${idBase}` : '';\n return `tab${suffix}-${itemId}`;\n};\n\nexport const getPanelId = (itemId: string, idBase: string) => {\n const suffix = idBase ? `-${idBase}` : '';\n return `panel${suffix}-${itemId}`;\n};\n\nexport const getTabPanelProps = (tabId: string, idBase: string) => ({\n id: getPanelId(tabId, idBase),\n role: 'tabpanel' as const,\n 'aria-labelledby': getTabId(tabId, idBase)\n});\n\ninterface UseTabsA11yProps {\n itemIds: string[];\n orientation?: 'horizontal' | 'vertical';\n activeItem: string;\n idBase?: string;\n includePanelLinks?: boolean; // Set to false when consumer manages their own panels externally\n externalPanelId?: string; // When set, all tabs point aria-controls to this single external panel id\n}\n\ninterface TabA11yProps {\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n onFocus: () => void;\n id: string;\n 'aria-controls'?: string;\n 'aria-selected': boolean;\n role: 'tab';\n}\n\ninterface PanelA11yProps {\n id: string;\n role: 'tabpanel';\n 'aria-labelledby': string;\n}\n\n/**\n * Hook for managing Tabs (NavigationBar) focus and ARIA props.\n * Handles roving tabindex pattern and generates tab-specific ARIA attributes.\n * \n * @example\n * const itemIds = useMemo(() => navigationItems.map(item => item.id), [navigationItems]);\n * const { getTabProps, setFocusedTabId, handleKeyDown } = useTabsA11y({\n * itemIds,\n * activeNavigationItem: 'tab-1',\n * orientation: 'horizontal',\n * idBase: 'settings'\n * });\n */\nexport function useTabsA11y({\n itemIds,\n orientation = 'horizontal',\n activeItem,\n idBase = '',\n includePanelLinks = true,\n externalPanelId\n}: UseTabsA11yProps) {\n const {\n setFocusedId: setFocusedTabId,\n handleKeyDown,\n getRovingItemProps\n } = useRovingFocus({\n itemIds,\n defaultFocusedId: activeItem,\n orientation,\n loop: true\n });\n\n /**\n * Get all props needed for a tab button.\n * Combines roving focus props (ref, tabIndex) with tab-specific ARIA attributes.\n */\n const getTabProps = useCallback((itemId: string): TabA11yProps => {\n const { ref, tabIndex, onFocus } = getRovingItemProps(itemId);\n const isSelected = activeItem === itemId;\n\n return {\n ref,\n tabIndex,\n onFocus,\n id: getTabId(itemId, idBase),\n ...(includePanelLinks && { 'aria-controls': externalPanelId ?? getPanelId(itemId, idBase) }),\n 'aria-selected': isSelected,\n role: 'tab'\n };\n }, [activeItem, getRovingItemProps, idBase, includePanelLinks, externalPanelId]);\n\n /**\n * Get all props needed for a tab panel.\n * Provides ARIA attributes to associate the panel with its tab.\n */\n const getPanelProps = useCallback((itemId: string): PanelA11yProps => {\n return {\n id: getPanelId(itemId, idBase),\n role: 'tabpanel',\n 'aria-labelledby': getTabId(itemId, idBase)\n };\n }, [idBase]);\n\n return {\n getTabProps,\n getPanelProps,\n setFocusedTabId,\n handleKeyDown,\n getPanelId: (itemId: string) => getPanelId(itemId, idBase),\n getTabId: (itemId: string) => getTabId(itemId, idBase)\n };\n}\n\n"],"names":["getTabId","itemId","idBase","getPanelId","getTabPanelProps","tabId","id","role","useTabsA11y","itemIds","orientation","activeItem","includePanelLinks","externalPanelId","setFocusedId","setFocusedTabId","handleKeyDown","getRovingItemProps","useRovingFocus","defaultFocusedId","loop","getTabProps","useCallback","ref","tabIndex","onFocus","isSelected","getPanelProps"],"mappings":"AAGaA,SAAAA,eAAAA,SAAAA;AAAAA,SAAAA,kBAAAA,SAAAA;AAAAA,MAAAA,IAAWA,CAACC,GAAgBC,MAEhC,MADQA,I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,MAAM;AAAA,IACN,mBAAmBP,EAASC,GAAQC,CAAM;AAAA,EAAA,IAE3C,CAACA,CAAM,CAAC;AAEJ,SAAA;AAAA,IACLmB,aAAAA;AAAAA,IACAM,eAAAA;AAAAA,IACAZ,iBAAAA;AAAAA,IACAC,eAAAA;AAAAA,IACAb,YAAYA,CAACF,MAAmBE,EAAWF,GAAQC,CAAM;AAAA,IACzDF,UAAUA,CAACC,MAAmBD,EAASC,GAAQC,CAAM;AAAA,EAAA;AAEzD;"}
1
+ {"version":3,"file":"index69.js","sources":["../src/utils/a11y/useFocusManagement.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { DependencyList } from 'react';\n\nexport interface UseFocusManagementOptions {\n /**\n * CSS selector to query the primary focus target.\n * Default: 'h1'\n */\n targetSelector?: string;\n /**\n * Fallback element id if selector target is not found.\n * Default: 'main-content'\n */\n fallbackId?: string;\n}\n\n/**\n * Generic focus management hook for route/state driven UI transitions.\n * Useful for both route changes and in-page multi-step wizards.\n * \n * Always skips first render and uses animation frame for safe DOM timing.\n */\nexport function useFocusManagement(\n dependencies: DependencyList,\n {\n targetSelector = '#main-content h1',\n fallbackId = 'main-content'\n }: UseFocusManagementOptions = {}\n): void {\n const isFirstRender = useRef(true);\n\n useEffect(() => {\n // Always skip first render\n if (isFirstRender.current) {\n isFirstRender.current = false;\n return;\n }\n\n const focusTarget = () => {\n const el = (document.querySelector(targetSelector) || document.getElementById(fallbackId)) as HTMLElement;\n if (el) {\n if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', '-1');\n el.focus();\n }\n };\n\n // Always use animation frame for safe DOM timing\n const rafId = requestAnimationFrame(focusTarget);\n return () => cancelAnimationFrame(rafId);\n }, dependencies);\n}\n"],"names":["useFocusManagement","dependencies","targetSelector","fallbackId","isFirstRender","useRef","useEffect","current","rafId","requestAnimationFrame","focusTarget","el","document","querySelector","getElementById","hasAttribute","setAttribute","focus","cancelAnimationFrame"],"mappings":";AAsBO,SAASA,EACdC,GACA;AAAA,EACEC,gBAAAA,IAAiB;AAAA,EACjBC,YAAAA,IAAa;AACY,IAAI,IACzB;AACN,QAAMC,IAAgBC,EAAO,EAAI;AAEjCC,EAAAA,EAAU,MAAM;AAEd,QAAIF,EAAcG,SAAS;AACzBH,MAAAA,EAAcG,UAAU;AACxB;AAAA,IACF;AAWA,UAAMC,IAAQC,sBATMC,MAAM;AACxB,YAAMC,IAAMC,SAASC,cAAcX,CAAc,KAAKU,SAASE,eAAeX,CAAU;AACxF,MAAIQ,MACGA,EAAGI,aAAa,UAAU,KAAGJ,EAAGK,aAAa,YAAY,IAAI,GAClEL,EAAGM,MAAAA;AAAAA,IAEP,CAG+C;AAC/C,WAAO,MAAMC,qBAAqBV,CAAK;AAAA,EACzC,GAAGP,CAAY;AACjB;"}
package/dist/index7.js CHANGED
@@ -1,56 +1,49 @@
1
- import t, { useState as u } from "react";
2
- import { MenuList as d } from "./index17.js";
3
- function l() {
4
- return l = Object.assign ? Object.assign.bind() : function(o) {
5
- for (var e = 1; e < arguments.length; e++) {
6
- var n = arguments[e];
7
- for (var a in n) ({}).hasOwnProperty.call(n, a) && (o[a] = n[a]);
1
+ import s, { useState as h, useCallback as i } from "react";
2
+ import "./index72.js";
3
+ import { isElementVisible as p } from "./index198.js";
4
+ const x = ({
5
+ skipLinks: n,
6
+ className: c = ""
7
+ }) => {
8
+ const [r, u] = h(n), l = i(() => {
9
+ const t = n.filter((e) => {
10
+ const o = document.getElementById(e.id);
11
+ return p(o);
12
+ });
13
+ u(t);
14
+ }, [n]), a = i(() => {
15
+ l();
16
+ }, [l]), d = i((t) => {
17
+ const e = document.getElementById(t);
18
+ if (e) {
19
+ const o = document.getElementById("main-header") || document.querySelector("header");
20
+ if (e === o) {
21
+ e.focus();
22
+ return;
23
+ }
24
+ const f = o ? o.offsetHeight : 0, m = e.getBoundingClientRect().top + window.scrollY - f - 16;
25
+ window.scrollTo({
26
+ top: m,
27
+ behavior: "smooth"
28
+ }), e.focus({
29
+ preventScroll: !0
30
+ });
8
31
  }
9
- return o;
10
- }, l.apply(null, arguments);
11
- }
12
- const g = (o) => {
13
- const {
14
- label: e,
15
- onDropdownClick: n = () => {
16
- },
17
- menuItems: a = [],
18
- automationId: s = "",
19
- ...i
20
- } = o, [r, m] = u(!1), c = () => {
21
- m(!r), n();
22
- };
23
- return /* @__PURE__ */ t.createElement("div", {
24
- className: "se-design-split-button flex items-center relative",
25
- "data-automation-id": s
26
- }, /* @__PURE__ */ t.createElement("button", l({
27
- type: "button",
28
- className: "px-8 py-2.5 rounded-l text-sm bg-[var(--color-blue-500)] text-[var(--color-white)] border-r border-[var(--color-white)]"
29
- }, i), e), /* @__PURE__ */ t.createElement("button", {
30
- type: "button",
31
- className: "bg-[var(--color-blue-500)] rounded-r",
32
- onClick: c,
33
- "data-automation-id": "split-button-dropdown-button"
34
- }, /* @__PURE__ */ t.createElement("svg", {
35
- className: `${r ? "rotate-180" : ""} transition-all`,
36
- width: "35",
37
- height: "40",
38
- viewBox: "0 0 35 40",
39
- fill: "none",
40
- xmlns: "http://www.w3.org/2000/svg"
41
- }, /* @__PURE__ */ t.createElement("path", {
42
- d: "M0 0H32C33.6569 0 35 1.34315 35 3V37C35 38.6569 33.6569 40 32 40H0V0Z",
43
- fill: "transparent"
44
- }), /* @__PURE__ */ t.createElement("path", {
45
- d: "M18 23.5L14 19.5L22 19.5L18 23.5Z",
46
- fill: "white"
47
- }))), r && /* @__PURE__ */ t.createElement("div", {
48
- className: "absolute top-full mt-1 w-max"
49
- }, /* @__PURE__ */ t.createElement(d, {
50
- items: a
51
- })));
32
+ }, []);
33
+ return n.length === 0 ? null : /* @__PURE__ */ s.createElement("div", {
34
+ className: `se-design-skip-links-bar relative w-full h-0 overflow-hidden p-0 flex items-center justify-center bg-[var(--color-blue-50)] transition-[height] duration-300 ease-out focus-within:h-auto focus-within:py-1 focus-within:px-2 ${c}`,
35
+ onFocus: a
36
+ }, r.map((t) => /* @__PURE__ */ s.createElement("a", {
37
+ key: t.id,
38
+ href: `#${t.id}`,
39
+ className: "absolute -left-[9999px] [clip:rect(0,0,0,0)] no-underline text-[var(--color-blue-500)] text-md py-1 px-2.5 rounded capitalize focus:static focus:left-auto focus:[clip:auto] focus:outline-none focus-visible:!outline-none hover:text-[var(--color-blue-600)] hover:bg-[var(--color-blue-200)]",
40
+ onClick: (e) => {
41
+ e.preventDefault(), d(t.id);
42
+ }
43
+ }, t.label)));
52
44
  };
53
45
  export {
54
- g as SplitButton
46
+ x as SkipLinksBar,
47
+ x as default
55
48
  };
56
49
  //# sourceMappingURL=index7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index7.js","sources":["../src/components/SplitButton/index.tsx"],"sourcesContent":["import React, { FC, useState } from 'react';\nimport { MenuItemProps } from 'src/components/MenuItem';\nimport { MenuList } from 'src/components/MenuList';\n\nexport interface SplitButtonProps {\n /**\n * Button contents\n */\n label: string;\n /**\n * Optional click handler\n */\n onClick?: () => void;\n /**\n * Optional click handler for dropdown\n */\n onDropdownClick?: () => void;\n menuItems?: MenuItemProps[];\n /**\n * Automation ID for testing\n */\n automationId?: string;\n}\n\nexport const SplitButton: FC<SplitButtonProps> = (props) => {\n const { label, onDropdownClick = () => {}, menuItems = [], automationId = '', ...remainingProps } = props;\n const [isOpen, setIsOpen] = useState(false);\n\n const handleDropdownClick = () => {\n setIsOpen(!isOpen);\n onDropdownClick();\n };\n\n return (\n <div className={'se-design-split-button flex items-center relative'} data-automation-id={automationId}>\n <button\n type=\"button\"\n className=\"px-8 py-2.5 rounded-l text-sm bg-[var(--color-blue-500)] text-[var(--color-white)] border-r border-[var(--color-white)]\"\n {...remainingProps}\n >\n {label}\n </button>\n <button type=\"button\" className=\"bg-[var(--color-blue-500)] rounded-r\" onClick={handleDropdownClick} data-automation-id=\"split-button-dropdown-button\">\n <svg\n className={`${isOpen ? 'rotate-180' : ''} transition-all`}\n width=\"35\"\n height=\"40\"\n viewBox=\"0 0 35 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M0 0H32C33.6569 0 35 1.34315 35 3V37C35 38.6569 33.6569 40 32 40H0V0Z\" fill=\"transparent\" />\n <path d=\"M18 23.5L14 19.5L22 19.5L18 23.5Z\" fill=\"white\" />\n </svg>\n </button>\n {isOpen && (\n <div className=\"absolute top-full mt-1 w-max\">\n <MenuList items={menuItems} />\n </div>\n )}\n </div>\n );\n};\n"],"names":["SplitButton","props","label","onDropdownClick","menuItems","automationId","remainingProps","isOpen","setIsOpen","useState","handleDropdownClick","React","createElement","className","_extends","type","onClick","width","height","viewBox","fill","xmlns","d","MenuList","items"],"mappings":";;;;;;;;;;;AAwBO,MAAMA,IAAqCC,CAAUA,MAAA;AACpD,QAAA;AAAA,IAAEC,OAAAA;AAAAA,IAAOC,iBAAAA,IAAkBA,MAAM;AAAA,IAAC;AAAA,IAAGC,WAAAA,IAAY,CAAE;AAAA,IAAEC,cAAAA,IAAe;AAAA,IAAI,GAAGC;AAAAA,EAAmBL,IAAAA,GAC9F,CAACM,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAsBA,MAAM;AAChCF,IAAAA,EAAU,CAACD,CAAM,GACDJ;EAAA;AAIhBQ,SAAAA,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IAAKC,WAAW;AAAA,IAAqD,sBAAoBR;AAAAA,EACvFM,GAAAA,gBAAAA,EAAAC,cAAA,UAAAE,EAAA;AAAA,IACEC,MAAK;AAAA,IACLF,WAAU;AAAA,EAAA,GACNP,CAAc,GAEjBJ,CACK,GACRS,gBAAAA,EAAAC,cAAA,UAAA;AAAA,IAAQG,MAAK;AAAA,IAASF,WAAU;AAAA,IAAuCG,SAASN;AAAAA,IAAqB,sBAAmB;AAAA,EAAA,GACtHE,gBAAAA,EAAAA,cAAA,OAAA;AAAA,IACEC,WAAW,GAAGN,IAAS,eAAe,EAAE;AAAA,IACxCU,OAAM;AAAA,IACNC,QAAO;AAAA,IACPC,SAAQ;AAAA,IACRC,MAAK;AAAA,IACLC,OAAM;AAAA,EAAA,GAENT,gBAAAA,EAAAA,cAAA,QAAA;AAAA,IAAMU,GAAE;AAAA,IAAwEF,MAAK;AAAA,EAAA,CAAe,GACpGR,gBAAAA,EAAAA,cAAA,QAAA;AAAA,IAAMU,GAAE;AAAA,IAAoCF,MAAK;AAAA,EAAS,CAAA,CACvD,CACC,GACPb,KACCI,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IAAKC,WAAU;AAAA,EAAA,GACbD,gBAAAA,EAAAA,cAACW,GAAQ;AAAA,IAACC,OAAOpB;AAAAA,EAAY,CAAA,CAC1B,CAEJ;AAET;"}
1
+ {"version":3,"file":"index7.js","sources":["../src/components/SkipLinksBar/index.tsx"],"sourcesContent":["import React, { useState, useCallback } from 'react';\nimport { isElementVisible } from '../../utils/a11y';\n\nexport interface SkipLink {\n id: string; \n label: string;\n}\n\nexport interface SkipLinksBarProps {\n skipLinks: SkipLink[]; // Required: array of skip targets\n className?: string; \n}\n\nexport const SkipLinksBar: React.FC<SkipLinksBarProps> = ({\n skipLinks,\n className = '',\n}) => {\n const [visibleLinks, setVisibleLinks] = useState<SkipLink[]>(skipLinks);\n\n // Check which target elements exist in DOM AND are visible\n const checkVisibleLinks = useCallback(() => {\n const existing = skipLinks.filter(link => {\n const element = document.getElementById(link.id);\n return isElementVisible(element);\n });\n setVisibleLinks(existing);\n }, [skipLinks]);\n\n // Only check on focus — by the time user tabs in, all child routes have rendered\n const handleContainerFocus = useCallback(() => {\n checkVisibleLinks();\n }, [checkVisibleLinks]);\n\n const handleSkipLinkClick = useCallback((targetId: string) => {\n const targetElement = document.getElementById(targetId);\n if (targetElement) {\n // Find sticky/fixed header that should be accounted for\n const header = document.getElementById('main-header')||document.querySelector('header');\n \n // If target is the header itself, just focus it (it's already at top)\n if (targetElement === header) {\n targetElement.focus();\n return;\n }\n \n const headerHeight = header ? header.offsetHeight : 0;\n \n // Scroll with offset to avoid content being hidden behind sticky headers\n const elementPosition = targetElement.getBoundingClientRect().top + window.scrollY;\n const offsetPosition = elementPosition - headerHeight - 16; // 16px padding for breathing room\n \n window.scrollTo({\n top: offsetPosition,\n behavior: 'smooth'\n });\n \n targetElement.focus({ preventScroll: true });\n }\n }, []);\n\n if (skipLinks.length === 0) {\n return null;\n }\n\n return (\n <div\n className={`se-design-skip-links-bar relative w-full h-0 overflow-hidden p-0 flex items-center justify-center bg-[var(--color-blue-50)] transition-[height] duration-300 ease-out focus-within:h-auto focus-within:py-1 focus-within:px-2 ${className}`}\n onFocus={handleContainerFocus}\n >\n {visibleLinks.map((link) => (\n <a\n key={link.id}\n href={`#${link.id}`}\n className=\"absolute -left-[9999px] [clip:rect(0,0,0,0)] no-underline text-[var(--color-blue-500)] text-md py-1 px-2.5 rounded capitalize focus:static focus:left-auto focus:[clip:auto] focus:outline-none focus-visible:!outline-none hover:text-[var(--color-blue-600)] hover:bg-[var(--color-blue-200)]\"\n onClick={(e) => {\n e.preventDefault();\n handleSkipLinkClick(link.id);\n }}\n >\n {link.label}\n </a>\n ))}\n </div>\n );\n};\n\nexport default SkipLinksBar;\n"],"names":["SkipLinksBar","skipLinks","className","visibleLinks","setVisibleLinks","useState","checkVisibleLinks","useCallback","existing","filter","link","element","document","getElementById","id","isElementVisible","handleContainerFocus","handleSkipLinkClick","targetId","targetElement","header","querySelector","focus","headerHeight","offsetHeight","offsetPosition","getBoundingClientRect","top","window","scrollY","scrollTo","behavior","preventScroll","length","React","createElement","onFocus","map","key","href","onClick","e","preventDefault","label"],"mappings":";;;AAaO,MAAMA,IAA4CA,CAAC;AAAA,EACxDC,WAAAA;AAAAA,EACAC,WAAAA,IAAY;AACd,MAAM;AACJ,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAqBJ,CAAS,GAGhEK,IAAoBC,EAAY,MAAM;AAC1C,UAAMC,IAAWP,EAAUQ,OAAOC,CAAAA,MAAQ;AACxC,YAAMC,IAAUC,SAASC,eAAeH,EAAKI,EAAE;AAC/C,aAAOC,EAAiBJ,CAAO;A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const r = "pointerType" in i ? i.pointerType : void 0;
3
- return r === "" && i.isTrusted ? !0 : t() && r ? i.type === "click" && i.buttons === 1 : i.detail === 0 && !r;
4
- };
1
+ import * as n from "react";
2
+ import { getA11yNameAttributes as C } from "./index78.js";
3
+ function M({
4
+ itemIds: r,
5
+ tabIndex: v = 0,
6
+ defaultFocusedId: u,
7
+ orientation: a = "horizontal",
8
+ cols: i,
9
+ loop: k = !0,
10
+ onFocusChange: f,
11
+ role: h
12
+ }) {
13
+ const [c, b] = n.useState(u || r[0] || ""), g = n.useRef({});
14
+ n.useEffect(() => {
15
+ if (r.length > 0 && !r.includes(c)) {
16
+ const e = u || r[0] || "";
17
+ b(e);
18
+ }
19
+ }, [r, c, u]);
20
+ const x = n.useCallback((e) => {
21
+ b(e), f?.(e);
22
+ }, [f]), y = n.useCallback((e) => {
23
+ const t = g.current[e];
24
+ t ? t.focus() : (b(e), f?.(e));
25
+ }, [f]), p = n.useCallback((e, t = 1) => {
26
+ if (r.length === 0) return;
27
+ const o = r.indexOf(c), l = Math.max(0, o);
28
+ let s = l;
29
+ switch (e) {
30
+ case "first":
31
+ s = 0;
32
+ break;
33
+ case "last":
34
+ s = r.length - 1;
35
+ break;
36
+ case "prev":
37
+ k ? s = (l - t + r.length) % r.length : s = Math.max(0, l - t);
38
+ break;
39
+ case "next":
40
+ k ? s = (l + t) % r.length : s = Math.min(r.length - 1, l + t);
41
+ break;
42
+ }
43
+ const w = r[s];
44
+ w && g.current[w]?.focus();
45
+ }, [r, c, k]), A = n.useCallback((e) => ({
46
+ ref: (t) => {
47
+ g.current[e] = t;
48
+ },
49
+ tabIndex: c === e ? v : -1,
50
+ onFocus: () => x(e)
51
+ }), [c, v, x]), R = n.useCallback((e) => {
52
+ let t = null, o = 1;
53
+ e.key === "Home" ? t = "first" : e.key === "End" ? t = "last" : (a !== "vertical" && (e.key === "ArrowLeft" ? t = "prev" : e.key === "ArrowRight" && (t = "next")), !t && a !== "horizontal" && (e.key === "ArrowUp" ? t = "prev" : e.key === "ArrowDown" && (t = "next"), t && i && (o = i))), t && (e.preventDefault(), e.stopPropagation(), p(t, o));
54
+ }, [a, i, p]), z = n.useCallback((e) => {
55
+ const t = {};
56
+ return h && (t.role = h), a === "horizontal" ? t["aria-orientation"] = "horizontal" : a === "vertical" && (t["aria-orientation"] = "vertical"), e && Object.assign(t, C(e)), t;
57
+ }, [h, a]);
58
+ return {
59
+ setFocusedId: x,
60
+ focusItem: y,
61
+ handleKeyDown: R,
62
+ getRovingItemProps: A,
63
+ getContainerProps: z
64
+ };
65
+ }
5
66
  export {
6
- o as isVirtualClick
67
+ M as useRovingFocus
7
68
  };
8
69
  //# sourceMappingURL=index70.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index70.js","sources":["../src/utils/virtualClick.ts"],"sourcesContent":["/**\n * Input/virtual click detection helpers.\n */\n\nconst isAndroid = () =>\n typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);\n\nexport const isVirtualClick = (event: MouseEvent | PointerEvent): boolean => {\n const pointerType = 'pointerType' in event ? event.pointerType : undefined;\n\n // JAWS/NVDA with Firefox.\n if (pointerType === '' && event.isTrusted) {\n return true;\n }\n\n // Android TalkBack's detail value varies depending on listener type.\n if (isAndroid() && pointerType) {\n return event.type === 'click' && event.buttons === 1;\n }\n\n // Most browsers: virtual click has detail === 0 and no pointerType.\n return event.detail === 0 && !pointerType;\n};\n\n\n"],"names":["isAndroid","navigator","test","userAgent","isVirtualClick","event","pointerType","undefined","isTrusted","type","buttons","detail"],"mappings":"AAIA,MAAMA,IAAYA,MAChB,OAAOC,YAAc,OAAe,WAAWC,KAAKD,UAAUE,SAAS,GAE5DC,IAAiBA,CAACC,MAA8C;AAC3E,QAAMC,IAAc,iBAAiBD,IAAQA,EAAMC,cAAcC;AAG7DD,SAAAA,MAAgB,MAAMD,EAAMG,YACvB,KAILR,OAAeM,IACVD,EAAMI,SAAS,WAAWJ,EAAMK,YAAY,IAI9CL,EAAMM,WAAW,KAAK,CAACL;AAChC;"}
1
+ {"version":3,"file":"index70.js","sources":["../src/utils/a11y/useRovingFocus.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { getA11yNameAttributes, AccessibleNameInput } from './accessibleName';\nexport type { AccessibleNameInput };\n\nexport type RovingDirection = 'prev' | 'next' | 'first' | 'last';\n\nexport interface UseRovingFocusOptions {\n /**\n * Array of item IDs in order\n */\n itemIds: string[];\n\n /**\n * The tabIndex to apply to the currently focused item in the roving group.\n * Defaults to 0 \n */\n tabIndex?: number;\n\n /**\n * Initial focused item ID. Defaults to first item.\n */\n defaultFocusedId?: string;\n\n /**\n * Orientation for arrow key mapping.\n * - horizontal: ArrowLeft/ArrowRight\n * - vertical: ArrowUp/ArrowDown\n * - grid: all four arrow keys (Left/Right move by 1, Up/Down move by `cols`)\n */\n orientation?: 'horizontal' | 'vertical' | 'grid';\n\n /**\n * Number of columns in the grid. Required when orientation is 'grid'.\n * ArrowUp/ArrowDown navigate by this many items in the flat itemIds array.\n */\n cols?: number;\n\n /**\n * Whether navigation wraps around at ends. Defaults to true.\n */\n loop?: boolean;\n\n /**\n * Callback when focus changes\n */\n onFocusChange?: (id: string) => void;\n\n /**\n * ARIA role for the container element (e.g. 'grid', 'menu', 'tablist', 'toolbar').\n * Returned via getContainerProps().\n */\n role?: React.AriaRole;\n}\n\nexport interface RovingItemProps {\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n onFocus: () => void;\n}\n\nexport interface RovingContainerProps {\n role?: React.AriaRole;\n 'aria-orientation'?: 'horizontal' | 'vertical';\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n}\n\nexport interface UseRovingFocusReturn {\n /**\n * Set focused item ID manually\n */\n setFocusedId: (id: string) => void;\n\n /**\n * Imperatively focus a DOM element by id.\n * If the element exists in refs, focus it immediately.\n * If not yet in DOM, update state so it gets focus once rendered.\n */\n focusItem: (id: string) => void;\n\n /**\n * Keyboard handler for arrow/Home/End navigation.\n * Attach to each item's onKeyDown.\n */\n handleKeyDown: (e: React.KeyboardEvent) => void;\n\n /**\n * Get props for an item in the roving focus group (ref + tabIndex)\n */\n getRovingItemProps: (id: string) => RovingItemProps;\n\n /**\n * Props to spread on the container element.\n * Returns role (if provided), aria-orientation (derived from orientation; omitted for grid),\n * and any accessible name/description attributes passed in.\n */\n getContainerProps: (nameInput?: AccessibleNameInput) => RovingContainerProps;\n}\n\n/**\n * Hook for managing roving focus pattern (roving tabindex).\n * Reusable for composite widgets: tabs, toolbars, menus, listboxes, radio groups, grids.\n *\n * @example\n * // 1D (toolbar/tabs):\n * const { getRovingItemProps, handleKeyDown } = useRovingFocus({\n * itemIds: ['tab1', 'tab2', 'tab3'],\n * orientation: 'horizontal'\n * });\n *\n * // 2D (grid — flat itemIds, cols for row-jump math):\n * const { getRovingItemProps, handleKeyDown } = useRovingFocus({\n * itemIds: ['r0c0', 'r0c1', 'r0c2', 'r1c0', 'r1c1', 'r1c2'],\n * orientation: 'grid',\n * cols: 3\n * });\n *\n * // In render:\n * <button {...getRovingItemProps('tab1')} onKeyDown={handleKeyDown}>Tab 1</button>\n */\nexport function useRovingFocus({\n itemIds,\n tabIndex = 0,\n defaultFocusedId,\n orientation = 'horizontal',\n cols,\n loop = true,\n onFocusChange,\n role\n}: UseRovingFocusOptions): UseRovingFocusReturn {\n const [focusedId, setFocusedIdState] = React.useState<string>(\n defaultFocusedId || itemIds[0] || ''\n );\n\n const itemRefs = React.useRef<Record<string, HTMLElement | null>>({});\n\n // Sync focusedId if itemIds change and current focusedId is no longer valid\n React.useEffect(() => {\n if (itemIds.length > 0 && !itemIds.includes(focusedId)) {\n const newFocusedId = defaultFocusedId || itemIds[0] || '';\n setFocusedIdState(newFocusedId);\n }\n }, [itemIds, focusedId, defaultFocusedId]);\n\n const setFocusedId = React.useCallback(\n (id: string) => {\n setFocusedIdState(id);\n onFocusChange?.(id);\n },\n [onFocusChange]\n );\n\n const focusItem = React.useCallback(\n (id: string) => {\n const el = itemRefs.current[id];\n if (el) {\n el.focus();\n } else {\n // element not yet in DOM (e.g. month just changed) — update state so it gets focus once rendered\n setFocusedIdState(id);\n onFocusChange?.(id);\n }\n },\n [onFocusChange]\n );\n\n const moveFocus = React.useCallback(\n (direction: RovingDirection, step: number = 1) => {\n if (itemIds.length === 0) return;\n\n const currentIdx = itemIds.indexOf(focusedId);\n const safeIdx = Math.max(0, currentIdx);\n let nextIdx = safeIdx;\n\n switch (direction) {\n case 'first':\n nextIdx = 0;\n break;\n case 'last':\n nextIdx = itemIds.length - 1;\n break;\n case 'prev':\n if (loop) {\n nextIdx = (safeIdx - step + itemIds.length) % itemIds.length;\n } else {\n nextIdx = Math.max(0, safeIdx - step);\n }\n break;\n case 'next':\n if (loop) {\n nextIdx = (safeIdx + step) % itemIds.length;\n } else {\n nextIdx = Math.min(itemIds.length - 1, safeIdx + step);\n }\n break;\n }\n\n const nextId = itemIds[nextIdx];\n if (!nextId) return;\n\n itemRefs.current[nextId]?.focus();\n },\n [itemIds, focusedId, loop]\n );\n\n const getRovingItemProps = React.useCallback(\n (id: string): RovingItemProps => ({\n ref: (el: HTMLElement | null) => {\n itemRefs.current[id] = el;\n },\n tabIndex: focusedId === id ? tabIndex : -1,\n onFocus: () => setFocusedId(id)\n }),\n [focusedId, tabIndex, setFocusedId]\n );\n\n // Keyboard handler for arrow/Home/End navigation\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n let direction: RovingDirection | null = null;\n let step = 1;\n\n if (e.key === 'Home') {\n direction = 'first';\n } else if (e.key === 'End') {\n direction = 'last';\n } else {\n // Horizontal axis (Left/Right) — active for 'horizontal' and 'grid'\n if (orientation !== 'vertical') {\n if (e.key === 'ArrowLeft') direction = 'prev';\n else if (e.key === 'ArrowRight') direction = 'next';\n }\n // Vertical axis (Up/Down) — active for 'vertical' and 'grid'\n if (!direction && orientation !== 'horizontal') {\n if (e.key === 'ArrowUp') direction = 'prev';\n else if (e.key === 'ArrowDown') direction = 'next';\n if (direction && cols) step = cols;\n }\n }\n\n if (direction) {\n e.preventDefault();\n e.stopPropagation();\n moveFocus(direction, step);\n }\n },\n [orientation, cols, moveFocus]\n );\n\n const getContainerProps = React.useCallback((nameInput?: AccessibleNameInput): RovingContainerProps => {\n const props: RovingContainerProps = {};\n if (role) props.role = role;\n if (orientation === 'horizontal') props['aria-orientation'] = 'horizontal';\n else if (orientation === 'vertical') props['aria-orientation'] = 'vertical';\n // grid: aria-orientation omitted — not applicable for role=\"grid\"\n if (nameInput) Object.assign(props, getA11yNameAttributes(nameInput));\n return props;\n }, [role, orientation]);\n\n return {\n setFocusedId,\n focusItem,\n handleKeyDown,\n getRovingItemProps,\n getContainerProps\n };\n}\n"],"names":["React","getA11yNameAttributes","useRovingFocus","itemIds","tabIndex","defaultFocusedId","orientation","cols","loop","onFocusChange","role","focusedId","setFocusedIdState","useState","itemRefs","useRef","useEffect","length","includes","newFocusedId","setFocusedId","useCallback","id","focusItem","el","current","focus","moveFocus","direction","step","currentIdx","indexOf","safeIdx","Math","max","nextIdx","min","nextId","getRovingItemProps","ref","onFocus","handleKeyDown","e","key","preventDefault","stopPropagation","getContainerProps","nameInput","props","Object","assign"],"mappings":"AA0HO,YAAAA,OAAA;AAAA,SAAA,yBAAAC,SAAA;AAAA,SAASC,EAAe;AAAA,EAC7BC,SAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,kBAAAA;AAAAA,EACAC,aAAAA,IAAc;AAAA,EACdC,MAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACPC,eAAAA;AAAAA,EACAC,MAAAA;AACqB,GAAyB;AAC9C,QAAM,CAACC,GAAWC,CAAiB,IAAIZ,EAAMa,SAC3CR,KAAoBF,EAAQ,CAAC,KAAK,EACpC,GAEMW,IAAWd,EAAMe,OAA2C,EAAE;AAGpEf,EAAAA,EAAMgB,UAAU,MAAM;AACpB,QAAIb,EAAQc,SAAS,KAAK,CAACd,EAAQe,SAASP,CAAS,GAAG;AACtD,YAAMQ,IAAed,KAA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-1,12 +1,30 @@
1
- function f({
2
- ariaLabel: e,
3
- ariaLabelledBy: i,
4
- ariaDescribedBy: r
1
+ const l = ['button:not([disabled]):not([tabindex="-1"])', '[href]:not([tabindex="-1"])', 'input:not([disabled]):not([tabindex="-1"])', 'select:not([disabled]):not([tabindex="-1"])', 'textarea:not([disabled]):not([tabindex="-1"])', '[tabindex]:not([tabindex="-1"]):not([disabled])', '[contenteditable="true"]:not([tabindex="-1"])'].join(", "), u = [l, '[role="menuitem"]', '[role="option"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]'].join(", ");
2
+ function s({
3
+ container: e,
4
+ includeRoles: t = !1,
5
+ additionalSelectors: r = [],
6
+ filterHidden: a = !1
5
7
  }) {
6
- const t = {};
7
- return i ? t["aria-labelledby"] = i : e && (t["aria-label"] = e), r && (t["aria-describedby"] = r), t;
8
+ if (!e) return [];
9
+ const d = [t ? u : l, ...r].filter(Boolean).join(", "), i = Array.from(e.querySelectorAll(d));
10
+ return a ? i.filter((n) => {
11
+ const o = window.getComputedStyle(n);
12
+ return o.display !== "none" && o.visibility !== "hidden" && o.opacity !== "0" && !n.hasAttribute("hidden") && n.offsetWidth > 0 && n.offsetHeight > 0;
13
+ }) : i;
14
+ }
15
+ function b(e) {
16
+ const t = s(e);
17
+ return t.length > 0 ? t[0] : null;
18
+ }
19
+ function c(e) {
20
+ const t = s(e);
21
+ return t.length > 0 ? t[t.length - 1] : null;
8
22
  }
9
23
  export {
10
- f as getA11yNameAttributes
24
+ l as FOCUSABLE_SELECTOR,
25
+ u as FOCUSABLE_WITH_ROLES_SELECTOR,
26
+ b as getFirstFocusableElement,
27
+ s as getFocusableElements,
28
+ c as getLastFocusableElement
11
29
  };
12
30
  //# sourceMappingURL=index71.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index71.js","sources":["../src/utils/a11y/accessibleName.ts"],"sourcesContent":["/**\n * Accessible name/description utilities following WCAG precedence rules.\n * \n * **When to use:**\n * - `ariaLabelledBy`: visible label exists (preferred - keeps SR and visual text in sync)\n * - `ariaLabel`: no visible label (e.g., icon-only buttons)\n * - `ariaDescribedBy`: additional context needed (warnings, hints, constraints)\n * \n * **Precedence:** ariaLabelledBy > ariaLabel > visible text content\n * \n * @example Icon-only button\n * ```tsx\n * <Button iconProps={{ name: 'close' }} ariaLabel=\"Close dialog\" />\n * ```\n * \n * @example Disambiguate generic labels\n * ```tsx\n * <Button label=\"Edit\" ariaLabel=\"Edit name\" />\n * <Button label=\"Edit\" ariaLabel=\"Edit email\" />\n * ```\n */\n\nexport type AccessibleNameInput = {\n /** Accessible name when no visible label exists (icon-only buttons). */\n ariaLabel?: string;\n /** ID(s) of visible element(s) that label this control. Preferred over ariaLabel. */\n ariaLabelledBy?: string;\n /** ID(s) of element(s) providing additional description (additive). */\n ariaDescribedBy?: string;\n};\n\n/**\n * Returns ARIA attributes with correct precedence.\n * Prefer ariaLabelledBy > ariaLabel. ariaDescribedBy is always additive.\n */\nexport function getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy\n}: AccessibleNameInput): Record<string, string> {\n const props: Record<string, string> = {};\n\n if (ariaLabelledBy) props['aria-labelledby'] = ariaLabelledBy;\n else if (ariaLabel) props['aria-label'] = ariaLabel;\n\n if (ariaDescribedBy) props['aria-describedby'] = ariaDescribedBy;\n\n return props;\n}\n"],"names":["getA11yNameAttributes","ariaLabel","ariaLabelledBy","ariaDescribedBy","props"],"mappings":"AAmCO,SAASA,EAAsB;AAAA,EACpCC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,iBAAAA;AACmB,GAA2B;AAC9C,QAAMC,IAAgC,CAAA;AAElCF,SAAAA,IAAsBE,EAAA,iBAAiB,IAAIF,IACtCD,MAAiBG,EAAA,YAAY,IAAIH,IAEtCE,MAAuBC,EAAA,kBAAkB,IAAID,IAE1CC;AACT;"}
1
+ {"version":3,"file":"index71.js","sources":["../src/utils/a11y/focusableElements.ts"],"sourcesContent":["/**\n * Utilities for finding focusable elements within a container.\n * \n * Used for focus management in modals, popovers, and other interactive overlays.\n */\n\n/**\n * Base selector for standard focusable elements.\n * Matches: buttons, links, inputs, selects, textareas, elements with tabindex >= 0, contenteditable.\n */\nexport const FOCUSABLE_SELECTOR = [\n 'button:not([disabled]):not([tabindex=\"-1\"])',\n '[href]:not([tabindex=\"-1\"])',\n 'input:not([disabled]):not([tabindex=\"-1\"])',\n 'select:not([disabled]):not([tabindex=\"-1\"])',\n 'textarea:not([disabled]):not([tabindex=\"-1\"])',\n '[tabindex]:not([tabindex=\"-1\"]):not([disabled])',\n '[contenteditable=\"true\"]:not([tabindex=\"-1\"])'\n].join(', ');\n\n/**\n * Extended selector that includes ARIA role-based focusable elements.\n * Useful for composite widgets like menus, listboxes, etc.\n */\nexport const FOCUSABLE_WITH_ROLES_SELECTOR = [\n FOCUSABLE_SELECTOR,\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]'\n].join(', ');\n\n/**\n * Options for getFocusableElements\n */\nexport interface GetFocusableElementsOptions {\n /**\n * Container element to search within. If null/undefined, returns empty array.\n */\n container: HTMLElement | null;\n /**\n * Whether to include role-based focusable elements (menuitem, option, etc.).\n * Default: false (uses base selector only)\n */\n includeRoles?: boolean;\n /**\n * Additional custom selectors to include.\n */\n additionalSelectors?: string[];\n /**\n * Whether to filter out hidden/invisible elements.\n * Default: false (returns all matching elements regardless of visibility)\n */\n filterHidden?: boolean;\n}\n\n/**\n * Get all focusable elements within a container.\n * \n * @example Basic usage (standard focusable elements)\n * ```ts\n * const focusables = getFocusableElements({ container: dialogRef.current });\n * focusables[0]?.focus(); // Focus first element\n * ```\n * \n * @example With role-based elements (for menus/listboxes)\n * ```ts\n * const focusables = getFocusableElements({ \n * container: menuRef.current,\n * includeRoles: true \n * });\n * ```\n * \n * @example With custom selectors\n * ```ts\n * const focusables = getFocusableElements({ \n * container: customWidgetRef.current,\n * additionalSelectors: ['[data-focusable=\"true\"]']\n * });\n * ```\n */\nexport function getFocusableElements({\n container,\n includeRoles = false,\n additionalSelectors = [],\n filterHidden = false\n}: GetFocusableElementsOptions): HTMLElement[] {\n if (!container) return [];\n\n const selector = [\n includeRoles ? FOCUSABLE_WITH_ROLES_SELECTOR : FOCUSABLE_SELECTOR,\n ...additionalSelectors\n ].filter(Boolean).join(', ');\n\n const elements = Array.from(container.querySelectorAll<HTMLElement>(selector));\n\n if (!filterHidden) return elements;\n\n // Filter out hidden/invisible elements\n return elements.filter((el) => {\n const style = window.getComputedStyle(el);\n return (\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n style.opacity !== '0' &&\n !el.hasAttribute('hidden') &&\n el.offsetWidth > 0 &&\n el.offsetHeight > 0\n );\n });\n}\n\n/**\n * Get the first focusable element in a container.\n * Returns null if none found.\n */\nexport function getFirstFocusableElement(\n options: GetFocusableElementsOptions\n): HTMLElement | null {\n const focusables = getFocusableElements(options);\n return focusables.length > 0 ? focusables[0] : null;\n}\n\n/**\n * Get the last focusable element in a container.\n * Returns null if none found.\n */\nexport function getLastFocusableElement(\n options: GetFocusableElementsOptions\n): HTMLElement | null {\n const focusables = getFocusableElements(options);\n return focusables.length > 0 ? focusables[focusables.length - 1] : null;\n}\n"],"names":["FOCUSABLE_SELECTOR","join","FOCUSABLE_WITH_ROLES_SELECTOR","getFocusableElements","container","includeRoles","additionalSelectors","filterHidden","selector","filter","Boolean","elements","Array","from","querySelectorAll","el","style","window","getComputedStyle","display","visibility","opacity","hasAttribute","offsetWidth","offsetHeight","getFirstFocusableElement","options","focusables","length","getLastFocusableElement"],"mappings":"AAUO,MAAMA,IAAqB,CAChC,+CACA,+BACA,8CACA,+CACA,iDACA,mDACA,+CAA+C,EAC/CC,KAAK,IAAI,GAMEC,IAAgC,CAC3CF,GACA,qBACA,mBACA,6BACA,wBAAwB,EACxBC,KAAK,IAAI;AAmDJ,SAASE,EAAqB;AAAA,EACnCC,WAAAA;AAAAA,EACAC,cAAAA,IAAe;AAAA,EACfC,qBAAAA,IAAsB,CAAA;AAAA,EACtBC,cAAAA,IAAe;AACY,GAAkB;AAC7C,MAAI,CAACH,EAAW,QAAO,CAAA;AAEvB,QAAMI,IAAW,CACfH,IAAeH,IAAgCF,GAC/C,GAAGM,CAAmB,EACtBG,OAAOC,OAAO,EAAET,KAAK,IAAI,GAErBU,IAAWC,MAAMC,KAAKT,EAAUU,iBAA8BN,CAAQ,CAAC;AAE7E,SAAKD,IAGEI,EAASF,OAAQM,CAAAA,MAAO;AAC7B,UAAMC,IAAQC,OAAOC,iBAAiBH,CAAE;AACxC,WACEC,EAAMG,YAAY,UAClBH,EAAMI,eAAe,YACrBJ,EAAMK,YAAY,OAClB,CAACN,EAAGO,aAAa,QAAQ,KACzBP,EAAGQ,cAAc,KACjBR,EAAGS,eAAe;AAAA,EAEtB,CAAC,IAbyBb;AAc5B;AAMO,SAASc,EACdC,GACoB;AACpB,QAAMC,IAAaxB,EAAqBuB,CAAO;AAC/C,SAAOC,EAAWC,SAAS,IAAID,EAAW,CAAC,IAAI;AACjD;AAMO,SAASE,EACdH,GACoB;AACpB,QAAMC,IAAaxB,EAAqBuB,CAAO;AAC/C,SAAOC,EAAWC,SAAS,IAAID,EAAWA,EAAWC,SAAS,CAAC,IAAI;AACrE;"}