@basic-ui/core 0.0.39 → 0.0.42

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 (383) hide show
  1. package/build/cjs/index.js +1312 -464
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.d.ts +7 -7
  4. package/build/esm/Accordion/Accordion.js +4 -4
  5. package/build/esm/Accordion/Accordion.js.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +5 -5
  7. package/build/esm/Accordion/AccordionBody.js +4 -4
  8. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  9. package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
  10. package/build/esm/Accordion/AccordionHeader.js +4 -4
  11. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  12. package/build/esm/Accordion/AccordionItem.d.ts +7 -7
  13. package/build/esm/Accordion/AccordionItem.js +2 -2
  14. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  15. package/build/esm/Accordion/context.d.ts +3 -3
  16. package/build/esm/Accordion/context.js +0 -0
  17. package/build/esm/Accordion/context.js.map +1 -1
  18. package/build/esm/Accordion/index.d.ts +0 -0
  19. package/build/esm/Accordion/index.js +0 -0
  20. package/build/esm/Accordion/index.js.map +1 -1
  21. package/build/esm/Accordion/scopeQuery.d.ts +0 -0
  22. package/build/esm/Accordion/scopeQuery.js +0 -0
  23. package/build/esm/Accordion/scopeQuery.js.map +1 -1
  24. package/build/esm/CheckBox/CheckBox.d.ts +6 -6
  25. package/build/esm/CheckBox/CheckBox.js +2 -2
  26. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  27. package/build/esm/CheckBox/index.d.ts +0 -0
  28. package/build/esm/CheckBox/index.js +0 -0
  29. package/build/esm/CheckBox/index.js.map +1 -1
  30. package/build/esm/ComboBox/Combobox.d.ts +10 -10
  31. package/build/esm/ComboBox/Combobox.js +3 -3
  32. package/build/esm/ComboBox/Combobox.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
  34. package/build/esm/ComboBox/ComboboxButton.js +4 -4
  35. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
  37. package/build/esm/ComboBox/ComboboxInput.js +3 -3
  38. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
  40. package/build/esm/ComboBox/ComboboxLabel.js +2 -2
  41. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  42. package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
  43. package/build/esm/ComboBox/ComboboxList.js +3 -3
  44. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  45. package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
  46. package/build/esm/ComboBox/ComboboxOption.js +4 -4
  47. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  48. package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
  49. package/build/esm/ComboBox/ComboboxPopover.js +5 -5
  50. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  51. package/build/esm/ComboBox/cities.d.ts +0 -0
  52. package/build/esm/ComboBox/cities.js +0 -0
  53. package/build/esm/ComboBox/cities.js.map +1 -1
  54. package/build/esm/ComboBox/context.d.ts +10 -10
  55. package/build/esm/ComboBox/context.js +0 -0
  56. package/build/esm/ComboBox/context.js.map +1 -1
  57. package/build/esm/ComboBox/hooks.d.ts +3 -3
  58. package/build/esm/ComboBox/hooks.js +11 -11
  59. package/build/esm/ComboBox/hooks.js.map +1 -1
  60. package/build/esm/ComboBox/index.d.ts +0 -0
  61. package/build/esm/ComboBox/index.js +0 -0
  62. package/build/esm/ComboBox/index.js.map +1 -1
  63. package/build/esm/ComboBox/makeHash.d.ts +0 -0
  64. package/build/esm/ComboBox/makeHash.js +0 -0
  65. package/build/esm/ComboBox/makeHash.js.map +1 -1
  66. package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
  67. package/build/esm/ComboBox/scopeQuery.js +0 -0
  68. package/build/esm/ComboBox/scopeQuery.js.map +1 -1
  69. package/build/esm/FocusLock/FocusLock.d.ts +7 -7
  70. package/build/esm/FocusLock/FocusLock.js +2 -2
  71. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  72. package/build/esm/FocusLock/index.d.ts +0 -0
  73. package/build/esm/FocusLock/index.js +0 -0
  74. package/build/esm/FocusLock/index.js.map +1 -1
  75. package/build/esm/FocusLock/tabUtils.d.ts +0 -0
  76. package/build/esm/FocusLock/tabUtils.js +0 -0
  77. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  78. package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
  79. package/build/esm/FocusLock/useFocusLock.js +0 -0
  80. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  81. package/build/esm/List/List.d.ts +6 -6
  82. package/build/esm/List/List.js +2 -2
  83. package/build/esm/List/List.js.map +1 -1
  84. package/build/esm/List/ListItem.d.ts +6 -6
  85. package/build/esm/List/ListItem.js +2 -2
  86. package/build/esm/List/ListItem.js.map +1 -1
  87. package/build/esm/List/context.d.ts +0 -0
  88. package/build/esm/List/context.js +0 -0
  89. package/build/esm/List/context.js.map +1 -1
  90. package/build/esm/List/index.d.ts +0 -0
  91. package/build/esm/List/index.js +0 -0
  92. package/build/esm/List/index.js.map +1 -1
  93. package/build/esm/Menu/Menu.d.ts +6 -6
  94. package/build/esm/Menu/Menu.js +2 -2
  95. package/build/esm/Menu/Menu.js.map +1 -1
  96. package/build/esm/Menu/MenuButton.d.ts +10 -10
  97. package/build/esm/Menu/MenuButton.js +3 -3
  98. package/build/esm/Menu/MenuButton.js.map +1 -1
  99. package/build/esm/Menu/MenuItem.d.ts +6 -6
  100. package/build/esm/Menu/MenuItem.js +4 -4
  101. package/build/esm/Menu/MenuItem.js.map +1 -1
  102. package/build/esm/Menu/MenuList.d.ts +5 -5
  103. package/build/esm/Menu/MenuList.js +6 -6
  104. package/build/esm/Menu/MenuList.js.map +1 -1
  105. package/build/esm/Menu/MenuPopover.d.ts +5 -5
  106. package/build/esm/Menu/MenuPopover.js +2 -2
  107. package/build/esm/Menu/MenuPopover.js.map +1 -1
  108. package/build/esm/Menu/context.d.ts +2 -2
  109. package/build/esm/Menu/context.js +0 -0
  110. package/build/esm/Menu/context.js.map +1 -1
  111. package/build/esm/Menu/index.d.ts +0 -0
  112. package/build/esm/Menu/index.js +0 -0
  113. package/build/esm/Menu/index.js.map +1 -1
  114. package/build/esm/Menu/scope.d.ts +0 -0
  115. package/build/esm/Menu/scope.js +0 -0
  116. package/build/esm/Menu/scope.js.map +1 -1
  117. package/build/esm/Modal/Modal.d.ts +6 -7
  118. package/build/esm/Modal/Modal.js +5 -5
  119. package/build/esm/Modal/Modal.js.map +1 -1
  120. package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
  121. package/build/esm/Modal/ModalBackdrop.js +6 -6
  122. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  123. package/build/esm/Modal/index.d.ts +0 -0
  124. package/build/esm/Modal/index.js +0 -0
  125. package/build/esm/Modal/index.js.map +1 -1
  126. package/build/esm/Popper/Popper.d.ts +7 -7
  127. package/build/esm/Popper/Popper.js +6 -6
  128. package/build/esm/Popper/Popper.js.map +1 -1
  129. package/build/esm/Popper/PopperArrow.d.ts +5 -5
  130. package/build/esm/Popper/PopperArrow.js +5 -6
  131. package/build/esm/Popper/PopperArrow.js.map +1 -1
  132. package/build/esm/Popper/context.d.ts +0 -0
  133. package/build/esm/Popper/context.js +0 -0
  134. package/build/esm/Popper/context.js.map +1 -1
  135. package/build/esm/Popper/index.d.ts +0 -0
  136. package/build/esm/Popper/index.js +0 -0
  137. package/build/esm/Popper/index.js.map +1 -1
  138. package/build/esm/Portal/Portal.d.ts +0 -0
  139. package/build/esm/Portal/Portal.js +0 -0
  140. package/build/esm/Portal/Portal.js.map +1 -1
  141. package/build/esm/Portal/index.d.ts +0 -0
  142. package/build/esm/Portal/index.js +0 -0
  143. package/build/esm/Portal/index.js.map +1 -1
  144. package/build/esm/RadioButton/RadioButton.d.ts +6 -6
  145. package/build/esm/RadioButton/RadioButton.js +5 -3
  146. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  147. package/build/esm/RadioButton/RadioGroup.d.ts +7 -7
  148. package/build/esm/RadioButton/RadioGroup.js +2 -2
  149. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  150. package/build/esm/RadioButton/context.d.ts +2 -2
  151. package/build/esm/RadioButton/context.js +0 -0
  152. package/build/esm/RadioButton/context.js.map +1 -1
  153. package/build/esm/RadioButton/index.d.ts +0 -0
  154. package/build/esm/RadioButton/index.js +0 -0
  155. package/build/esm/RadioButton/index.js.map +1 -1
  156. package/build/esm/SkipNav/SkipNav.d.ts +6 -6
  157. package/build/esm/SkipNav/SkipNav.js +2 -2
  158. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  159. package/build/esm/SkipNav/index.d.ts +0 -0
  160. package/build/esm/SkipNav/index.js +0 -0
  161. package/build/esm/SkipNav/index.js.map +1 -1
  162. package/build/esm/Slider/Slider.d.ts +218 -0
  163. package/build/esm/Slider/Slider.js +842 -0
  164. package/build/esm/Slider/Slider.js.map +1 -0
  165. package/build/esm/Slider/index.d.ts +1 -0
  166. package/build/esm/Slider/index.js +2 -0
  167. package/build/esm/Slider/index.js.map +1 -0
  168. package/build/esm/Spinner/Spinner.d.ts +7 -7
  169. package/build/esm/Spinner/Spinner.js +2 -2
  170. package/build/esm/Spinner/Spinner.js.map +1 -1
  171. package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
  172. package/build/esm/Spinner/SpinnerButton.js +3 -3
  173. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  174. package/build/esm/Spinner/context.d.ts +2 -2
  175. package/build/esm/Spinner/context.js +0 -0
  176. package/build/esm/Spinner/context.js.map +1 -1
  177. package/build/esm/Spinner/index.d.ts +0 -0
  178. package/build/esm/Spinner/index.js +0 -0
  179. package/build/esm/Spinner/index.js.map +1 -1
  180. package/build/esm/Tabs/Tab.d.ts +6 -6
  181. package/build/esm/Tabs/Tab.js +3 -3
  182. package/build/esm/Tabs/Tab.js.map +1 -1
  183. package/build/esm/Tabs/TabList.d.ts +6 -6
  184. package/build/esm/Tabs/TabList.js +4 -4
  185. package/build/esm/Tabs/TabList.js.map +1 -1
  186. package/build/esm/Tabs/TabPanel.d.ts +6 -6
  187. package/build/esm/Tabs/TabPanel.js +4 -4
  188. package/build/esm/Tabs/TabPanel.js.map +1 -1
  189. package/build/esm/Tabs/TabPanels.d.ts +5 -5
  190. package/build/esm/Tabs/TabPanels.js +4 -4
  191. package/build/esm/Tabs/TabPanels.js.map +1 -1
  192. package/build/esm/Tabs/Tabs.d.ts +6 -6
  193. package/build/esm/Tabs/Tabs.js +2 -2
  194. package/build/esm/Tabs/Tabs.js.map +1 -1
  195. package/build/esm/Tabs/context.d.ts +2 -2
  196. package/build/esm/Tabs/context.js +0 -0
  197. package/build/esm/Tabs/context.js.map +1 -1
  198. package/build/esm/Tabs/index.d.ts +0 -0
  199. package/build/esm/Tabs/index.js +0 -0
  200. package/build/esm/Tabs/index.js.map +1 -1
  201. package/build/esm/Tabs/scopeQuery.d.ts +0 -0
  202. package/build/esm/Tabs/scopeQuery.js +0 -0
  203. package/build/esm/Tabs/scopeQuery.js.map +1 -1
  204. package/build/esm/Tooltip/Tooltip.d.ts +7 -8
  205. package/build/esm/Tooltip/Tooltip.js +5 -3
  206. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  207. package/build/esm/Tooltip/index.d.ts +0 -0
  208. package/build/esm/Tooltip/index.js +0 -0
  209. package/build/esm/Tooltip/index.js.map +1 -1
  210. package/build/esm/Tooltip/stateMachine.d.ts +0 -0
  211. package/build/esm/Tooltip/stateMachine.js +9 -9
  212. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  213. package/build/esm/Tooltip/useTooltip.d.ts +7 -7
  214. package/build/esm/Tooltip/useTooltip.js +7 -6
  215. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  216. package/build/esm/hooks/index.d.ts +0 -0
  217. package/build/esm/hooks/index.js +0 -0
  218. package/build/esm/hooks/index.js.map +1 -1
  219. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  220. package/build/esm/hooks/useAutoFocus.js +0 -0
  221. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  222. package/build/esm/hooks/useChildrenCounter.d.ts +0 -0
  223. package/build/esm/hooks/useChildrenCounter.js +0 -0
  224. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  225. package/build/esm/hooks/useControlledState.d.ts +2 -6
  226. package/build/esm/hooks/useControlledState.js +8 -7
  227. package/build/esm/hooks/useControlledState.js.map +1 -1
  228. package/build/esm/hooks/useFocusReturn.d.ts +0 -0
  229. package/build/esm/hooks/useFocusReturn.js +2 -2
  230. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  231. package/build/esm/hooks/useFocusState.d.ts +5 -5
  232. package/build/esm/hooks/useFocusState.js +1 -1
  233. package/build/esm/hooks/useFocusState.js.map +1 -1
  234. package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
  235. package/build/esm/hooks/useGestureHandlers.js +23 -15
  236. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  237. package/build/esm/hooks/useMeasure.d.ts +2 -2
  238. package/build/esm/hooks/useMeasure.js +0 -1
  239. package/build/esm/hooks/useMeasure.js.map +1 -1
  240. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  241. package/build/esm/hooks/useOnClickOutside.js +0 -0
  242. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  243. package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
  244. package/build/esm/hooks/useOnKeyDown.js +5 -5
  245. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  246. package/build/esm/hooks/useReducerMachine.d.ts +0 -0
  247. package/build/esm/hooks/useReducerMachine.js +2 -1
  248. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  249. package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -1
  250. package/build/esm/hooks/useRemoveBodyScroll.js +12 -8
  251. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  252. package/build/esm/hooks/useScope.d.ts +0 -0
  253. package/build/esm/hooks/useScope.js +0 -0
  254. package/build/esm/hooks/useScope.js.map +1 -1
  255. package/build/esm/hooks/useThrottle.d.ts +0 -0
  256. package/build/esm/hooks/useThrottle.js +0 -0
  257. package/build/esm/hooks/useThrottle.js.map +1 -1
  258. package/build/esm/index.d.ts +1 -0
  259. package/build/esm/index.js +1 -0
  260. package/build/esm/index.js.map +1 -1
  261. package/build/esm/utils/assign-ref.d.ts +3 -0
  262. package/build/esm/utils/{assignRef.js → assign-ref.js} +1 -1
  263. package/build/esm/utils/assign-ref.js.map +1 -0
  264. package/build/esm/utils/can-use-dom.d.ts +1 -0
  265. package/build/esm/utils/can-use-dom.js +4 -0
  266. package/build/esm/utils/can-use-dom.js.map +1 -0
  267. package/build/esm/utils/clamp.d.ts +0 -0
  268. package/build/esm/utils/clamp.js +0 -0
  269. package/build/esm/utils/clamp.js.map +1 -1
  270. package/build/esm/utils/context.d.ts +7 -0
  271. package/build/esm/utils/context.js +41 -0
  272. package/build/esm/utils/context.js.map +1 -0
  273. package/build/esm/utils/{createSubscription.d.ts → create-subscription.d.ts} +0 -0
  274. package/build/esm/utils/{createSubscription.js → create-subscription.js} +1 -1
  275. package/build/esm/utils/create-subscription.js.map +1 -0
  276. package/build/esm/utils/{getCircularIndex.d.ts → get-circular-index.d.ts} +0 -0
  277. package/build/esm/utils/{getCircularIndex.js → get-circular-index.js} +1 -1
  278. package/build/esm/utils/get-circular-index.js.map +1 -0
  279. package/build/esm/utils/index.d.ts +10 -4
  280. package/build/esm/utils/index.js +10 -4
  281. package/build/esm/utils/index.js.map +1 -1
  282. package/build/esm/utils/is-right-click.d.ts +6 -0
  283. package/build/esm/utils/is-right-click.js +9 -0
  284. package/build/esm/utils/is-right-click.js.map +1 -0
  285. package/build/esm/utils/owner-document.d.ts +7 -0
  286. package/build/esm/utils/owner-document.js +12 -0
  287. package/build/esm/utils/owner-document.js.map +1 -0
  288. package/build/esm/utils/polymorphic.d.ts +32 -0
  289. package/build/esm/utils/polymorphic.js +2 -0
  290. package/build/esm/utils/polymorphic.js.map +1 -0
  291. package/build/esm/utils/{rubberBandClamp.d.ts → rubber-band-clamp.d.ts} +0 -0
  292. package/build/esm/utils/{rubberBandClamp.js → rubber-band-clamp.js} +1 -1
  293. package/build/esm/utils/rubber-band-clamp.js.map +1 -0
  294. package/build/esm/utils/use-stable-callback.d.ts +16 -0
  295. package/build/esm/utils/use-stable-callback.js +43 -0
  296. package/build/esm/utils/use-stable-callback.js.map +1 -0
  297. package/build/esm/utils/wrap-event.d.ts +3 -0
  298. package/build/esm/utils/{wrapEvent.js → wrap-event.js} +1 -1
  299. package/build/esm/utils/wrap-event.js.map +1 -0
  300. package/build/tsconfig-build.tsbuildinfo +1 -0
  301. package/package.json +4 -5
  302. package/src/Accordion/Accordion.tsx +12 -6
  303. package/src/Accordion/AccordionBody.tsx +4 -5
  304. package/src/Accordion/AccordionHeader.tsx +30 -27
  305. package/src/Accordion/AccordionItem.tsx +12 -6
  306. package/src/Accordion/context.ts +3 -2
  307. package/src/CheckBox/CheckBox.tsx +5 -6
  308. package/src/ComboBox/ComboBox.story.tsx +3 -3
  309. package/src/ComboBox/Combobox.tsx +5 -8
  310. package/src/ComboBox/ComboboxButton.tsx +15 -9
  311. package/src/ComboBox/ComboboxInput.tsx +18 -10
  312. package/src/ComboBox/ComboboxLabel.tsx +4 -4
  313. package/src/ComboBox/ComboboxList.tsx +5 -6
  314. package/src/ComboBox/ComboboxOption.tsx +12 -8
  315. package/src/ComboBox/ComboboxPopover.tsx +15 -10
  316. package/src/ComboBox/context.ts +10 -9
  317. package/src/ComboBox/hooks.tsx +4 -3
  318. package/src/FocusLock/FocusLock.tsx +13 -7
  319. package/src/FocusLock/useFocusLock.ts +4 -3
  320. package/src/List/List.tsx +5 -5
  321. package/src/List/ListItem.tsx +5 -5
  322. package/src/Menu/Menu.story.tsx +2 -2
  323. package/src/Menu/Menu.tsx +13 -7
  324. package/src/Menu/MenuButton.tsx +13 -10
  325. package/src/Menu/MenuItem.tsx +15 -11
  326. package/src/Menu/MenuList.tsx +6 -6
  327. package/src/Menu/MenuPopover.tsx +4 -4
  328. package/src/Menu/context.ts +9 -4
  329. package/src/Modal/Modal.tsx +11 -7
  330. package/src/Modal/ModalBackdrop.tsx +16 -11
  331. package/src/Popper/Popper.tsx +7 -7
  332. package/src/Popper/PopperArrow.tsx +6 -8
  333. package/src/RadioButton/RadioButton.tsx +11 -6
  334. package/src/RadioButton/RadioGroup.tsx +11 -9
  335. package/src/RadioButton/context.ts +2 -4
  336. package/src/SkipNav/SkipNav.tsx +5 -5
  337. package/src/Slider/Slider.story.tsx +45 -0
  338. package/src/Slider/Slider.tsx +1106 -0
  339. package/src/Slider/index.ts +1 -0
  340. package/src/Slider/styles.css +131 -0
  341. package/src/Spinner/Spinner.tsx +13 -9
  342. package/src/Spinner/SpinnerButton.tsx +11 -6
  343. package/src/Spinner/context.ts +2 -3
  344. package/src/Tabs/Tab.tsx +13 -8
  345. package/src/Tabs/TabList.tsx +5 -5
  346. package/src/Tabs/TabPanel.tsx +5 -5
  347. package/src/Tabs/TabPanels.tsx +4 -4
  348. package/src/Tabs/Tabs.tsx +5 -7
  349. package/src/Tabs/context.ts +2 -3
  350. package/src/Tooltip/Tooltip.story.tsx +3 -3
  351. package/src/Tooltip/Tooltip.tsx +13 -7
  352. package/src/Tooltip/stateMachine.ts +9 -13
  353. package/src/Tooltip/useTooltip.ts +19 -12
  354. package/src/hooks/useAutoFocus.ts +2 -1
  355. package/src/hooks/useControlledState.ts +14 -14
  356. package/src/hooks/useFocusState.ts +4 -3
  357. package/src/hooks/useGestureHandlers.ts +33 -19
  358. package/src/hooks/useMeasure.ts +2 -2
  359. package/src/hooks/useOnClickOutside.ts +2 -2
  360. package/src/hooks/useOnKeyDown.ts +4 -3
  361. package/src/hooks/useRemoveBodyScroll.ts +18 -8
  362. package/src/index.ts +1 -0
  363. package/src/utils/{assignRef.ts → assign-ref.ts} +4 -4
  364. package/src/utils/can-use-dom.ts +7 -0
  365. package/src/utils/context.tsx +48 -0
  366. package/src/utils/{createSubscription.ts → create-subscription.ts} +0 -0
  367. package/src/utils/{getCircularIndex.ts → get-circular-index.ts} +0 -0
  368. package/src/utils/index.ts +10 -4
  369. package/src/utils/is-right-click.ts +14 -0
  370. package/src/utils/owner-document.ts +13 -0
  371. package/src/utils/polymorphic.ts +72 -0
  372. package/src/utils/{rubberBandClamp.ts → rubber-band-clamp.ts} +0 -0
  373. package/src/utils/use-stable-callback.ts +58 -0
  374. package/src/utils/wrap-event.ts +22 -0
  375. package/build/esm/utils/assignRef.d.ts +0 -3
  376. package/build/esm/utils/assignRef.js.map +0 -1
  377. package/build/esm/utils/createSubscription.js.map +0 -1
  378. package/build/esm/utils/getCircularIndex.js.map +0 -1
  379. package/build/esm/utils/rubberBandClamp.js.map +0 -1
  380. package/build/esm/utils/wrapEvent.d.ts +0 -3
  381. package/build/esm/utils/wrapEvent.js.map +0 -1
  382. package/build/tsconfig.tsbuildinfo +0 -1
  383. package/src/utils/wrapEvent.ts +0 -20
@@ -1,14 +1,14 @@
1
- /// <reference types="react" />
1
+ import type { MutableRefObject } from 'react';
2
2
  import type { ActionTypes, StateTypes, ReducerState } from './hooks';
3
3
  import type { SelectEventHandler } from './Combobox';
4
4
  import type { Scope } from '../hooks';
5
5
  export interface ComboBoxContextProps {
6
6
  data: Omit<ReducerState, 'state'>;
7
- inputRef: React.MutableRefObject<HTMLInputElement | null>;
8
- popoverRef: React.MutableRefObject<HTMLDivElement | null>;
9
- buttonRef: React.MutableRefObject<HTMLButtonElement | null>;
7
+ inputRef: MutableRefObject<HTMLInputElement | null>;
8
+ popoverRef: MutableRefObject<HTMLDivElement | null>;
9
+ buttonRef: MutableRefObject<HTMLButtonElement | null>;
10
10
  onSelect?: SelectEventHandler;
11
- optionsRef: React.MutableRefObject<{
11
+ optionsRef: MutableRefObject<{
12
12
  [itemId: string]: {
13
13
  value: string | unknown;
14
14
  text: string;
@@ -17,11 +17,11 @@ export interface ComboBoxContextProps {
17
17
  listScope: Scope<HTMLElement>;
18
18
  state: StateTypes;
19
19
  transition: (action: ActionTypes, payload?: any) => void;
20
- listboxIdRef: React.MutableRefObject<string | undefined>;
21
- labelIdRef: React.MutableRefObject<string | undefined>;
22
- autocompletePropRef: React.MutableRefObject<boolean>;
23
- persistSelectionRef: React.MutableRefObject<boolean>;
24
- clearOnEscapeRef: React.MutableRefObject<boolean>;
20
+ listboxIdRef: MutableRefObject<string | undefined>;
21
+ labelIdRef: MutableRefObject<string | undefined>;
22
+ autocompletePropRef: MutableRefObject<boolean>;
23
+ persistSelectionRef: MutableRefObject<boolean>;
24
+ clearOnEscapeRef: MutableRefObject<boolean>;
25
25
  isVisible: boolean;
26
26
  openOnFocus: boolean;
27
27
  selectOnBlur: boolean;
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/context.ts"],"names":["createContext","useContext","comboboxContext","ComboBoxProvider","Provider","useComboBoxContext"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AA+BA,IAAMC,eAAe,gBAAGF,aAAa,CAAuB,IAAvB,CAArC;IACyBG,gB,GAAqBD,e,CAA/BE,Q;;AACf,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,SAAMJ,UAAU,CAACC,eAAD,CAAhB;AAAA,CAA3B","sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { ActionTypes, StateTypes, ReducerState } from './hooks';\nimport type { SelectEventHandler } from './Combobox';\nimport type { Scope } from '../hooks';\n\nexport interface ComboBoxContextProps {\n data: Omit<ReducerState, 'state'>;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n popoverRef: React.MutableRefObject<HTMLDivElement | null>;\n buttonRef: React.MutableRefObject<HTMLButtonElement | null>;\n onSelect?: SelectEventHandler;\n optionsRef: React.MutableRefObject<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>;\n listScope: Scope<HTMLElement>;\n state: StateTypes;\n transition: (action: ActionTypes, payload?: any) => void;\n listboxIdRef: React.MutableRefObject<string | undefined>;\n labelIdRef: React.MutableRefObject<string | undefined>;\n autocompletePropRef: React.MutableRefObject<boolean>;\n persistSelectionRef: React.MutableRefObject<boolean>;\n clearOnEscapeRef: React.MutableRefObject<boolean>;\n isVisible: boolean;\n openOnFocus: boolean;\n selectOnBlur: boolean;\n}\n\nconst comboboxContext = createContext<ComboBoxContextProps>(null as any);\nexport const { Provider: ComboBoxProvider } = comboboxContext;\nexport const useComboBoxContext = () => useContext(comboboxContext);\n"],"file":"context.js"}
1
+ {"version":3,"file":"context.js","names":["createContext","useContext","comboboxContext","ComboBoxProvider","Provider","useComboBoxContext"],"sources":["../../../src/ComboBox/context.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { createContext, useContext } from 'react';\n\nimport type { ActionTypes, StateTypes, ReducerState } from './hooks';\nimport type { SelectEventHandler } from './Combobox';\nimport type { Scope } from '../hooks';\n\nexport interface ComboBoxContextProps {\n data: Omit<ReducerState, 'state'>;\n inputRef: MutableRefObject<HTMLInputElement | null>;\n popoverRef: MutableRefObject<HTMLDivElement | null>;\n buttonRef: MutableRefObject<HTMLButtonElement | null>;\n onSelect?: SelectEventHandler;\n optionsRef: MutableRefObject<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>;\n listScope: Scope<HTMLElement>;\n state: StateTypes;\n transition: (action: ActionTypes, payload?: any) => void;\n listboxIdRef: MutableRefObject<string | undefined>;\n labelIdRef: MutableRefObject<string | undefined>;\n autocompletePropRef: MutableRefObject<boolean>;\n persistSelectionRef: MutableRefObject<boolean>;\n clearOnEscapeRef: MutableRefObject<boolean>;\n isVisible: boolean;\n openOnFocus: boolean;\n selectOnBlur: boolean;\n}\n\nconst comboboxContext = createContext<ComboBoxContextProps>(null as any);\nexport const { Provider: ComboBoxProvider } = comboboxContext;\nexport const useComboBoxContext = () => useContext(comboboxContext);\n"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AA+BA,IAAMC,eAAe,gBAAGF,aAAa,CAAuB,IAAvB,CAArC;AACO,IAAkBG,gBAAlB,GAAuCD,eAAvC,CAAQE,QAAR;;AACP,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB;EAAA,OAAMJ,UAAU,CAACC,eAAD,CAAhB;AAAA,CAA3B"}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import type { KeyboardEvent, MutableRefObject } from 'react';
2
2
  import type { StateChart as GenericStateChart, StateMachineState } from '../hooks/useReducerMachine';
3
3
  export declare const IDLE = "IDLE";
4
4
  declare const SUGGESTING = "SUGGESTING";
@@ -31,7 +31,7 @@ interface ActionObject {
31
31
  }
32
32
  export declare function comboboxReducer(data: Readonly<ReducerState>, action: ActionObject): ReducerState;
33
33
  export declare const isVisible: (state: any) => boolean;
34
- export declare function useFocusManagement(lastActionType: ActionTypes, inputRef: React.MutableRefObject<HTMLInputElement | null>): void;
35
- export declare function useKeyDown(): (event: React.KeyboardEvent<any>) => void;
34
+ export declare function useFocusManagement(lastActionType: ActionTypes, inputRef: MutableRefObject<HTMLInputElement | null>): void;
35
+ export declare function useKeyDown(): (event: KeyboardEvent<any>) => void;
36
36
  export declare function useBlur(): () => void;
37
37
  export {};
@@ -7,7 +7,7 @@ var _on, _on2, _on3, _states;
7
7
 
8
8
  /* eslint-disable default-case */
9
9
  import { useEffect } from 'react';
10
- import { getCircularIndex } from '../utils/getCircularIndex';
10
+ import { getCircularIndex } from '../utils/get-circular-index';
11
11
  import { useComboBoxContext } from './context';
12
12
  import { scopeQuery } from './scopeQuery'; ////////////////////////////////////////////////////////////////////////////////
13
13
  // States
@@ -52,7 +52,7 @@ export var stateChart = {
52
52
  }), _states)
53
53
  };
54
54
  export function comboboxReducer(data, action) {
55
- var nextState = _extends({}, data, {
55
+ var nextState = _extends(_extends({}, data), {}, {
56
56
  state: action.nextState,
57
57
  lastActionType: action.type
58
58
  });
@@ -60,7 +60,7 @@ export function comboboxReducer(data, action) {
60
60
  switch (action.type) {
61
61
  case INIT:
62
62
  case CHANGE:
63
- return _extends({}, nextState, {
63
+ return _extends(_extends({}, nextState), {}, {
64
64
  text: action.text,
65
65
  navigationItem: '',
66
66
  item: ''
@@ -69,29 +69,29 @@ export function comboboxReducer(data, action) {
69
69
  case NAVIGATE:
70
70
  case OPEN_WITH_BUTTON:
71
71
  if (action.persistSelection) {
72
- return _extends({}, nextState, {
72
+ return _extends(_extends({}, nextState), {}, {
73
73
  navigationItem: data.item
74
74
  });
75
75
  }
76
76
 
77
- return _extends({}, nextState, {
77
+ return _extends(_extends({}, nextState), {}, {
78
78
  navigationItem: action.item
79
79
  });
80
80
 
81
81
  case CLEAR_SELECTION:
82
- return _extends({}, nextState, {
82
+ return _extends(_extends({}, nextState), {}, {
83
83
  navigationItem: ''
84
84
  });
85
85
 
86
86
  case CLEAR:
87
- return _extends({}, nextState, {
87
+ return _extends(_extends({}, nextState), {}, {
88
88
  text: '',
89
89
  navigationItem: '',
90
90
  item: ''
91
91
  });
92
92
 
93
93
  case BLUR:
94
- return _extends({}, nextState, {
94
+ return _extends(_extends({}, nextState), {}, {
95
95
  text: action.text,
96
96
  navigationItem: '',
97
97
  item: action.item
@@ -99,21 +99,21 @@ export function comboboxReducer(data, action) {
99
99
 
100
100
  case CLOSE_WITH_BUTTON:
101
101
  case ESCAPE:
102
- return _extends({}, nextState, {
102
+ return _extends(_extends({}, nextState), {}, {
103
103
  navigationItem: '',
104
104
  item: ''
105
105
  });
106
106
 
107
107
  case SELECT_WITH_CLICK:
108
108
  case SELECT_WITH_KEYBOARD:
109
- return _extends({}, nextState, {
109
+ return _extends(_extends({}, nextState), {}, {
110
110
  text: action.text,
111
111
  item: action.item,
112
112
  navigationItem: ''
113
113
  });
114
114
 
115
115
  case FOCUS:
116
- return _extends({}, nextState, {
116
+ return _extends(_extends({}, nextState), {}, {
117
117
  navigationItem: action.item
118
118
  });
119
119
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/hooks.tsx"],"names":["useEffect","getCircularIndex","useComboBoxContext","scopeQuery","IDLE","SUGGESTING","NAVIGATING","INIT","CLEAR","CLEAR_SELECTION","CHANGE","NAVIGATE","SELECT_WITH_KEYBOARD","SELECT_WITH_CLICK","ESCAPE","BLUR","FOCUS","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","stateChart","initial","states","on","comboboxReducer","data","action","nextState","state","lastActionType","type","text","navigationItem","item","persistSelection","Error","visibleStates","isVisible","indexOf","useFocusManagement","inputRef","current","focus","getNextItem","currentItem","incr","optionsItems","autocomplete","index","findIndex","n","String","id","optionsLen","length","nextIndex","useKeyDown","onSelect","optionsRef","transition","autocompletePropRef","clearOnEscapeRef","persistSelectionRef","listScope","handleKeyDown","event","optionNodes","queryAllNodes","key","preventDefault","nextItem","value","lastValue","tracker","_valueTracker","setValue","Event","bubbles","dispatchEvent","navigationValue","navigationText","useBlur","stateText","popoverRef","buttonRef","selectOnBlur","handleBlur","requestAnimationFrame","document","activeElement","contains"],"mappings":";;;;;AAAA;;AACA;AACA,SAASA,SAAT,QAA0B,OAA1B;AAMA,SAASC,gBAAT,QAAiC,2BAAjC;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,QAA2B,cAA3B,C,CAEA;AACA;AAEA;;AACA,OAAO,IAAMC,IAAI,GAAG,MAAb,C,CAEP;;AACA,IAAMC,UAAU,GAAG,YAAnB,C,CAEA;;AACA,OAAO,IAAMC,UAAU,GAAG,YAAnB;AAIP;AACA;AAEA;AACA,OAAO,IAAMC,IAAI,GAAG,MAAb,C,CAEP;;AACA,OAAO,IAAMC,KAAK,GAAG,OAAd,C,CAEP;;AACA,OAAO,IAAMC,eAAe,GAAG,iBAAxB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disable default-case */\nimport { useEffect } from 'react';\n\nimport type {\n StateChart as GenericStateChart,\n StateMachineState,\n} from '../hooks/useReducerMachine';\nimport { getCircularIndex } from '../utils/getCircularIndex';\nimport { useComboBoxContext } from './context';\nimport { scopeQuery } from './scopeQuery';\n\n////////////////////////////////////////////////////////////////////////////////\n// States\n\n// Nothing going on, waiting for the user to type or use the arrow keys\nexport const IDLE = 'IDLE';\n\n// The component is suggesting options as the user types\nconst SUGGESTING = 'SUGGESTING';\n\n// The user is using the keyboard to navigate the list, not typing\nexport const NAVIGATING = 'NAVIGATING';\n\nexport type StateTypes = typeof IDLE | typeof SUGGESTING | typeof NAVIGATING;\n\n////////////////////////////////////////////////////////////////////////////////\n// Actions:\n\n// Used to sync the state with controlled state, right after mounting\nexport const INIT = 'INIT';\n\n// User cleared the value w/ backspace, but input still has focus\nexport const CLEAR = 'CLEAR';\n\n// User cleared the value w/ backspace, but input still has focus\nexport const CLEAR_SELECTION = 'CLEAR_SELECTION';\n\n// User is typing\nexport const CHANGE = 'CHANGE';\n\n// User is navigating w/ the keyboard\nexport const NAVIGATE = 'NAVIGATE';\n\n// User can be navigating with keyboard and then click instead, we want the\n// value from the click, not the current nav item\nconst SELECT_WITH_KEYBOARD = 'SELECT_WITH_KEYBOARD';\nexport const SELECT_WITH_CLICK = 'SELECT_WITH_CLICK';\n\n// Pretty self-explanatory, user can hit escape or blur to close the popover\nconst ESCAPE = 'ESCAPE';\nconst BLUR = 'BLUR';\n\nexport const FOCUS = 'FOCUS';\n\nexport const OPEN_WITH_BUTTON = 'OPEN_WITH_BUTTON';\n\nexport const CLOSE_WITH_BUTTON = 'CLOSE_WITH_BUTTON';\n\nexport type ActionTypes =\n | typeof CLEAR\n | typeof CLEAR_SELECTION\n | typeof CHANGE\n | typeof INIT\n | typeof NAVIGATE\n | typeof SELECT_WITH_KEYBOARD\n | typeof SELECT_WITH_CLICK\n | typeof ESCAPE\n | typeof BLUR\n | typeof FOCUS\n | typeof OPEN_WITH_BUTTON\n | typeof CLOSE_WITH_BUTTON;\n\n////////////////////////////////////////////////////////////////////////////////\nexport const stateChart: GenericStateChart<StateTypes, ActionTypes> = {\n initial: IDLE,\n states: {\n [IDLE]: {\n on: {\n [BLUR]: IDLE,\n [CLEAR]: IDLE,\n [INIT]: IDLE,\n [CLEAR_SELECTION]: IDLE,\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [NAVIGATE]: NAVIGATING,\n [OPEN_WITH_BUTTON]: SUGGESTING,\n },\n },\n [SUGGESTING]: {\n on: {\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [INIT]: SUGGESTING,\n [NAVIGATE]: NAVIGATING,\n [CLEAR]: IDLE,\n [CLEAR_SELECTION]: SUGGESTING,\n [ESCAPE]: IDLE,\n [BLUR]: IDLE,\n [SELECT_WITH_CLICK]: IDLE,\n [CLOSE_WITH_BUTTON]: IDLE,\n },\n },\n [NAVIGATING]: {\n on: {\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [INIT]: NAVIGATING,\n [CLEAR]: IDLE,\n [CLEAR_SELECTION]: NAVIGATING,\n [BLUR]: IDLE,\n [ESCAPE]: IDLE,\n [NAVIGATE]: NAVIGATING,\n [SELECT_WITH_KEYBOARD]: IDLE,\n [SELECT_WITH_CLICK]: IDLE,\n [CLOSE_WITH_BUTTON]: IDLE,\n },\n },\n },\n};\n\nexport interface ReducerState\n extends StateMachineState<StateTypes, ActionTypes> {\n item: string;\n navigationItem: string;\n text: string;\n}\n\ninterface ActionObject {\n type: ActionTypes;\n state: StateTypes;\n nextState: StateTypes;\n [rest: string]: any;\n}\n\nexport function comboboxReducer(\n data: Readonly<ReducerState>,\n action: ActionObject\n): ReducerState {\n const nextState = {\n ...data,\n state: action.nextState,\n lastActionType: action.type,\n };\n\n switch (action.type) {\n case INIT:\n case CHANGE:\n return {\n ...nextState,\n text: action.text,\n navigationItem: '',\n item: '',\n };\n case NAVIGATE:\n case OPEN_WITH_BUTTON:\n if (action.persistSelection) {\n return {\n ...nextState,\n navigationItem: data.item,\n };\n }\n\n return {\n ...nextState,\n navigationItem: action.item,\n };\n case CLEAR_SELECTION:\n return {\n ...nextState,\n navigationItem: '',\n };\n case CLEAR:\n return {\n ...nextState,\n text: '',\n navigationItem: '',\n item: '',\n };\n case BLUR:\n return {\n ...nextState,\n text: action.text,\n navigationItem: '',\n item: action.item,\n };\n case CLOSE_WITH_BUTTON:\n case ESCAPE:\n return {\n ...nextState,\n navigationItem: '',\n item: '',\n };\n case SELECT_WITH_CLICK:\n case SELECT_WITH_KEYBOARD:\n return {\n ...nextState,\n text: action.text,\n item: action.item,\n navigationItem: '',\n };\n case FOCUS:\n return {\n ...nextState,\n navigationItem: action.item,\n };\n\n default:\n throw new Error(`Unknown action ${action.type}`);\n }\n}\n\nconst visibleStates = [SUGGESTING, NAVIGATING];\nexport const isVisible = (state: any) => visibleStates.indexOf(state) >= 0;\n\n////////////////////////////////////////////////////////////////////////////////\n// The rest is all implementation details\n\n// Move focus back to the input if we start navigating w/ the\n// keyboard after focus has moved to any focusable content in\n// the popup.\nexport function useFocusManagement(\n lastActionType: ActionTypes,\n inputRef: React.MutableRefObject<HTMLInputElement | null>\n) {\n // useEffect so that the cursor goes to the end of the input instead\n // of awkwardly at the beginning, unclear to me why ...\n useEffect(() => {\n if (\n lastActionType === NAVIGATE ||\n lastActionType === ESCAPE ||\n lastActionType === SELECT_WITH_CLICK ||\n lastActionType === OPEN_WITH_BUTTON\n ) {\n inputRef.current && inputRef.current.focus();\n }\n });\n}\n\nfunction getNextItem(\n currentItem: string,\n incr: number,\n optionsItems: HTMLElement[],\n autocomplete: boolean\n): string {\n const index =\n currentItem === ''\n ? -1\n : optionsItems.findIndex((n) => String(n.id) === currentItem);\n\n const optionsLen = optionsItems.length;\n\n // Nothing selected, either go to start, or end\n if (index < 0) {\n if (incr > 0) {\n // Go to start\n return optionsItems[0].id;\n } else {\n // Go to end\n return optionsItems[optionsLen - 1].id;\n }\n } else if (autocomplete) {\n const nextIndex = index + incr;\n\n if (nextIndex < 0 || nextIndex >= optionsLen) {\n // Next is outside the bounds of list, return nothing selected\n return '';\n }\n }\n\n // I'm sure it won't be null, we already check optionsLen above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return optionsItems[getCircularIndex(index + incr, optionsLen)!].id;\n}\n\n// We want the same events when the input or the popup have focus (HOW COOL ARE\n// HOOKS BTW?) This is probably the hairiest piece but it's not bad.\nexport function useKeyDown() {\n const {\n data: { text, navigationItem },\n onSelect,\n optionsRef,\n inputRef,\n state,\n transition,\n autocompletePropRef,\n clearOnEscapeRef,\n persistSelectionRef,\n listScope,\n } = useComboBoxContext();\n\n return function handleKeyDown(event: React.KeyboardEvent<any>) {\n const optionNodes = listScope.current.queryAllNodes(scopeQuery);\n\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown': {\n // Don't scroll the page\n event.preventDefault();\n\n const optionsLen = optionNodes.length;\n\n // If the developer didn't render any options, there's no point in\n // trying to navigate--but seriously what the heck? Give us some\n // options fam.\n if (optionsLen === 0) {\n return;\n }\n\n if (state === IDLE) {\n // Opening a closed list\n transition(NAVIGATE, {\n persistSelection: persistSelectionRef.current,\n });\n } else {\n // ArrowUp decreases index, ArrowDown increases\n const incr = event.key === 'ArrowUp' ? -1 : 1;\n\n // When autocompletting, we'll not cycle through the list directly\n const autocomplete = autocompletePropRef.current;\n\n // Get next selected item\n const nextItem = getNextItem(\n navigationItem,\n incr,\n optionNodes,\n autocomplete\n );\n\n const value =\n nextItem !== '' ? optionsRef.current[nextItem].text : null;\n\n transition(NAVIGATE, { value, item: nextItem });\n }\n break;\n }\n case 'Escape': {\n if (state !== IDLE) {\n transition(ESCAPE);\n } else if (state === IDLE && text !== '') {\n if (!inputRef.current || !clearOnEscapeRef.current) {\n break;\n }\n\n // emulate a inputRef change event, might not work in future versions of React\n const lastValue = inputRef.current.value;\n inputRef.current.value = '';\n\n const tracker = (inputRef.current as any)._valueTracker;\n if (tracker) {\n tracker.setValue(lastValue);\n }\n\n const event = new Event('change', { bubbles: true });\n inputRef.current.dispatchEvent(event);\n }\n break;\n }\n case 'Enter': {\n if (state === NAVIGATING && navigationItem !== '') {\n const { value: navigationValue, text: navigationText } =\n optionsRef.current[navigationItem];\n\n // don't want to submit forms\n event.preventDefault();\n onSelect && onSelect(navigationText, navigationItem, navigationValue);\n transition(SELECT_WITH_KEYBOARD, {\n text: navigationText,\n item: navigationItem,\n });\n }\n break;\n }\n }\n };\n}\n\nexport function useBlur() {\n const {\n data: { navigationItem, text: stateText },\n transition,\n optionsRef,\n popoverRef,\n inputRef,\n buttonRef,\n onSelect,\n selectOnBlur, // not implemented yet\n } = useComboBoxContext();\n\n return function handleBlur() {\n requestAnimationFrame(() => {\n // we on want to close only if focus rests outside the combobox\n if (\n document.activeElement !== inputRef.current &&\n document.activeElement !== buttonRef.current &&\n popoverRef.current\n ) {\n if (popoverRef.current.contains(document.activeElement)) {\n // focus landed inside the combobox, keep it open\n // in the future, we can make it not close, select, or anything\n // this way we can have like... checkboxes available in the\n // menu item, etc.\n } else {\n // focus landed outside the combobox, close it.\n if (!selectOnBlur || navigationItem === '') {\n // we don't wanna select on blur, or navigationIndex is invalid\n transition(BLUR, { text: stateText, item: '' });\n } else {\n // select the currently selected item\n const { value: navigationValue, text: navigationText } =\n optionsRef.current[navigationItem];\n\n onSelect &&\n onSelect(navigationText, navigationItem, navigationValue);\n\n transition(BLUR, {\n text: navigationText,\n item: navigationItem,\n });\n }\n }\n }\n });\n };\n}\n"],"file":"hooks.js"}
1
+ {"version":3,"file":"hooks.js","names":["useEffect","getCircularIndex","useComboBoxContext","scopeQuery","IDLE","SUGGESTING","NAVIGATING","INIT","CLEAR","CLEAR_SELECTION","CHANGE","NAVIGATE","SELECT_WITH_KEYBOARD","SELECT_WITH_CLICK","ESCAPE","BLUR","FOCUS","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","stateChart","initial","states","on","comboboxReducer","data","action","nextState","state","lastActionType","type","text","navigationItem","item","persistSelection","Error","visibleStates","isVisible","indexOf","useFocusManagement","inputRef","current","focus","getNextItem","currentItem","incr","optionsItems","autocomplete","index","findIndex","n","String","id","optionsLen","length","nextIndex","useKeyDown","onSelect","optionsRef","transition","autocompletePropRef","clearOnEscapeRef","persistSelectionRef","listScope","handleKeyDown","event","optionNodes","queryAllNodes","key","preventDefault","nextItem","value","lastValue","tracker","_valueTracker","setValue","Event","bubbles","dispatchEvent","navigationValue","navigationText","useBlur","stateText","popoverRef","buttonRef","selectOnBlur","handleBlur","requestAnimationFrame","document","activeElement","contains"],"sources":["../../../src/ComboBox/hooks.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable default-case */\nimport type { KeyboardEvent, MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport type {\n StateChart as GenericStateChart,\n StateMachineState,\n} from '../hooks/useReducerMachine';\nimport { getCircularIndex } from '../utils/get-circular-index';\nimport { useComboBoxContext } from './context';\nimport { scopeQuery } from './scopeQuery';\n\n////////////////////////////////////////////////////////////////////////////////\n// States\n\n// Nothing going on, waiting for the user to type or use the arrow keys\nexport const IDLE = 'IDLE';\n\n// The component is suggesting options as the user types\nconst SUGGESTING = 'SUGGESTING';\n\n// The user is using the keyboard to navigate the list, not typing\nexport const NAVIGATING = 'NAVIGATING';\n\nexport type StateTypes = typeof IDLE | typeof SUGGESTING | typeof NAVIGATING;\n\n////////////////////////////////////////////////////////////////////////////////\n// Actions:\n\n// Used to sync the state with controlled state, right after mounting\nexport const INIT = 'INIT';\n\n// User cleared the value w/ backspace, but input still has focus\nexport const CLEAR = 'CLEAR';\n\n// User cleared the value w/ backspace, but input still has focus\nexport const CLEAR_SELECTION = 'CLEAR_SELECTION';\n\n// User is typing\nexport const CHANGE = 'CHANGE';\n\n// User is navigating w/ the keyboard\nexport const NAVIGATE = 'NAVIGATE';\n\n// User can be navigating with keyboard and then click instead, we want the\n// value from the click, not the current nav item\nconst SELECT_WITH_KEYBOARD = 'SELECT_WITH_KEYBOARD';\nexport const SELECT_WITH_CLICK = 'SELECT_WITH_CLICK';\n\n// Pretty self-explanatory, user can hit escape or blur to close the popover\nconst ESCAPE = 'ESCAPE';\nconst BLUR = 'BLUR';\n\nexport const FOCUS = 'FOCUS';\n\nexport const OPEN_WITH_BUTTON = 'OPEN_WITH_BUTTON';\n\nexport const CLOSE_WITH_BUTTON = 'CLOSE_WITH_BUTTON';\n\nexport type ActionTypes =\n | typeof CLEAR\n | typeof CLEAR_SELECTION\n | typeof CHANGE\n | typeof INIT\n | typeof NAVIGATE\n | typeof SELECT_WITH_KEYBOARD\n | typeof SELECT_WITH_CLICK\n | typeof ESCAPE\n | typeof BLUR\n | typeof FOCUS\n | typeof OPEN_WITH_BUTTON\n | typeof CLOSE_WITH_BUTTON;\n\n////////////////////////////////////////////////////////////////////////////////\nexport const stateChart: GenericStateChart<StateTypes, ActionTypes> = {\n initial: IDLE,\n states: {\n [IDLE]: {\n on: {\n [BLUR]: IDLE,\n [CLEAR]: IDLE,\n [INIT]: IDLE,\n [CLEAR_SELECTION]: IDLE,\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [NAVIGATE]: NAVIGATING,\n [OPEN_WITH_BUTTON]: SUGGESTING,\n },\n },\n [SUGGESTING]: {\n on: {\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [INIT]: SUGGESTING,\n [NAVIGATE]: NAVIGATING,\n [CLEAR]: IDLE,\n [CLEAR_SELECTION]: SUGGESTING,\n [ESCAPE]: IDLE,\n [BLUR]: IDLE,\n [SELECT_WITH_CLICK]: IDLE,\n [CLOSE_WITH_BUTTON]: IDLE,\n },\n },\n [NAVIGATING]: {\n on: {\n [CHANGE]: SUGGESTING,\n [FOCUS]: SUGGESTING,\n [INIT]: NAVIGATING,\n [CLEAR]: IDLE,\n [CLEAR_SELECTION]: NAVIGATING,\n [BLUR]: IDLE,\n [ESCAPE]: IDLE,\n [NAVIGATE]: NAVIGATING,\n [SELECT_WITH_KEYBOARD]: IDLE,\n [SELECT_WITH_CLICK]: IDLE,\n [CLOSE_WITH_BUTTON]: IDLE,\n },\n },\n },\n};\n\nexport interface ReducerState\n extends StateMachineState<StateTypes, ActionTypes> {\n item: string;\n navigationItem: string;\n text: string;\n}\n\ninterface ActionObject {\n type: ActionTypes;\n state: StateTypes;\n nextState: StateTypes;\n [rest: string]: any;\n}\n\nexport function comboboxReducer(\n data: Readonly<ReducerState>,\n action: ActionObject\n): ReducerState {\n const nextState = {\n ...data,\n state: action.nextState,\n lastActionType: action.type,\n };\n\n switch (action.type) {\n case INIT:\n case CHANGE:\n return {\n ...nextState,\n text: action.text,\n navigationItem: '',\n item: '',\n };\n case NAVIGATE:\n case OPEN_WITH_BUTTON:\n if (action.persistSelection) {\n return {\n ...nextState,\n navigationItem: data.item,\n };\n }\n\n return {\n ...nextState,\n navigationItem: action.item,\n };\n case CLEAR_SELECTION:\n return {\n ...nextState,\n navigationItem: '',\n };\n case CLEAR:\n return {\n ...nextState,\n text: '',\n navigationItem: '',\n item: '',\n };\n case BLUR:\n return {\n ...nextState,\n text: action.text,\n navigationItem: '',\n item: action.item,\n };\n case CLOSE_WITH_BUTTON:\n case ESCAPE:\n return {\n ...nextState,\n navigationItem: '',\n item: '',\n };\n case SELECT_WITH_CLICK:\n case SELECT_WITH_KEYBOARD:\n return {\n ...nextState,\n text: action.text,\n item: action.item,\n navigationItem: '',\n };\n case FOCUS:\n return {\n ...nextState,\n navigationItem: action.item,\n };\n\n default:\n throw new Error(`Unknown action ${action.type}`);\n }\n}\n\nconst visibleStates = [SUGGESTING, NAVIGATING];\nexport const isVisible = (state: any) => visibleStates.indexOf(state) >= 0;\n\n////////////////////////////////////////////////////////////////////////////////\n// The rest is all implementation details\n\n// Move focus back to the input if we start navigating w/ the\n// keyboard after focus has moved to any focusable content in\n// the popup.\nexport function useFocusManagement(\n lastActionType: ActionTypes,\n inputRef: MutableRefObject<HTMLInputElement | null>\n) {\n // useEffect so that the cursor goes to the end of the input instead\n // of awkwardly at the beginning, unclear to me why ...\n useEffect(() => {\n if (\n lastActionType === NAVIGATE ||\n lastActionType === ESCAPE ||\n lastActionType === SELECT_WITH_CLICK ||\n lastActionType === OPEN_WITH_BUTTON\n ) {\n inputRef.current && inputRef.current.focus();\n }\n });\n}\n\nfunction getNextItem(\n currentItem: string,\n incr: number,\n optionsItems: HTMLElement[],\n autocomplete: boolean\n): string {\n const index =\n currentItem === ''\n ? -1\n : optionsItems.findIndex((n) => String(n.id) === currentItem);\n\n const optionsLen = optionsItems.length;\n\n // Nothing selected, either go to start, or end\n if (index < 0) {\n if (incr > 0) {\n // Go to start\n return optionsItems[0].id;\n } else {\n // Go to end\n return optionsItems[optionsLen - 1].id;\n }\n } else if (autocomplete) {\n const nextIndex = index + incr;\n\n if (nextIndex < 0 || nextIndex >= optionsLen) {\n // Next is outside the bounds of list, return nothing selected\n return '';\n }\n }\n\n // I'm sure it won't be null, we already check optionsLen above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return optionsItems[getCircularIndex(index + incr, optionsLen)!].id;\n}\n\n// We want the same events when the input or the popup have focus (HOW COOL ARE\n// HOOKS BTW?) This is probably the hairiest piece but it's not bad.\nexport function useKeyDown() {\n const {\n data: { text, navigationItem },\n onSelect,\n optionsRef,\n inputRef,\n state,\n transition,\n autocompletePropRef,\n clearOnEscapeRef,\n persistSelectionRef,\n listScope,\n } = useComboBoxContext();\n\n return function handleKeyDown(event: KeyboardEvent<any>) {\n const optionNodes = listScope.current.queryAllNodes(scopeQuery);\n\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown': {\n // Don't scroll the page\n event.preventDefault();\n\n const optionsLen = optionNodes.length;\n\n // If the developer didn't render any options, there's no point in\n // trying to navigate--but seriously what the heck? Give us some\n // options fam.\n if (optionsLen === 0) {\n return;\n }\n\n if (state === IDLE) {\n // Opening a closed list\n transition(NAVIGATE, {\n persistSelection: persistSelectionRef.current,\n });\n } else {\n // ArrowUp decreases index, ArrowDown increases\n const incr = event.key === 'ArrowUp' ? -1 : 1;\n\n // When autocompletting, we'll not cycle through the list directly\n const autocomplete = autocompletePropRef.current;\n\n // Get next selected item\n const nextItem = getNextItem(\n navigationItem,\n incr,\n optionNodes,\n autocomplete\n );\n\n const value =\n nextItem !== '' ? optionsRef.current[nextItem].text : null;\n\n transition(NAVIGATE, { value, item: nextItem });\n }\n break;\n }\n case 'Escape': {\n if (state !== IDLE) {\n transition(ESCAPE);\n } else if (state === IDLE && text !== '') {\n if (!inputRef.current || !clearOnEscapeRef.current) {\n break;\n }\n\n // emulate a inputRef change event, might not work in future versions of React\n const lastValue = inputRef.current.value;\n inputRef.current.value = '';\n\n const tracker = (inputRef.current as any)._valueTracker;\n if (tracker) {\n tracker.setValue(lastValue);\n }\n\n const event = new Event('change', { bubbles: true });\n inputRef.current.dispatchEvent(event);\n }\n break;\n }\n case 'Enter': {\n if (state === NAVIGATING && navigationItem !== '') {\n const { value: navigationValue, text: navigationText } =\n optionsRef.current[navigationItem];\n\n // don't want to submit forms\n event.preventDefault();\n onSelect && onSelect(navigationText, navigationItem, navigationValue);\n transition(SELECT_WITH_KEYBOARD, {\n text: navigationText,\n item: navigationItem,\n });\n }\n break;\n }\n }\n };\n}\n\nexport function useBlur() {\n const {\n data: { navigationItem, text: stateText },\n transition,\n optionsRef,\n popoverRef,\n inputRef,\n buttonRef,\n onSelect,\n selectOnBlur, // not implemented yet\n } = useComboBoxContext();\n\n return function handleBlur() {\n requestAnimationFrame(() => {\n // we on want to close only if focus rests outside the combobox\n if (\n document.activeElement !== inputRef.current &&\n document.activeElement !== buttonRef.current &&\n popoverRef.current\n ) {\n if (popoverRef.current.contains(document.activeElement)) {\n // focus landed inside the combobox, keep it open\n // in the future, we can make it not close, select, or anything\n // this way we can have like... checkboxes available in the\n // menu item, etc.\n } else {\n // focus landed outside the combobox, close it.\n if (!selectOnBlur || navigationItem === '') {\n // we don't wanna select on blur, or navigationIndex is invalid\n transition(BLUR, { text: stateText, item: '' });\n } else {\n // select the currently selected item\n const { value: navigationValue, text: navigationText } =\n optionsRef.current[navigationItem];\n\n onSelect &&\n onSelect(navigationText, navigationItem, navigationValue);\n\n transition(BLUR, {\n text: navigationText,\n item: navigationItem,\n });\n }\n }\n }\n });\n };\n}\n"],"mappings":";;;;;AAAA;;AACA;AAEA,SAASA,SAAT,QAA0B,OAA1B;AAMA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,QAA2B,cAA3B,C,CAEA;AACA;AAEA;;AACA,OAAO,IAAMC,IAAI,GAAG,MAAb,C,CAEP;;AACA,IAAMC,UAAU,GAAG,YAAnB,C,CAEA;;AACA,OAAO,IAAMC,UAAU,GAAG,YAAnB;AAIP;AACA;AAEA;AACA,OAAO,IAAMC,IAAI,GAAG,MAAb,C,CAEP;;AACA,OAAO,IAAMC,KAAK,GAAG,OAAd,C,CAEP;;AACA,OAAO,IAAMC,eAAe,GAAG,iBAAxB,C,CAEP;;AACA,OAAO,IAAMC,MAAM,GAAG,QAAf,C,CAEP;;AACA,OAAO,IAAMC,QAAQ,GAAG,UAAjB,C,CAEP;AACA;;AACA,IAAMC,oBAAoB,GAAG,sBAA7B;AACA,OAAO,IAAMC,iBAAiB,GAAG,mBAA1B,C,CAEP;;AACA,IAAMC,MAAM,GAAG,QAAf;AACA,IAAMC,IAAI,GAAG,MAAb;AAEA,OAAO,IAAMC,KAAK,GAAG,OAAd;AAEP,OAAO,IAAMC,gBAAgB,GAAG,kBAAzB;AAEP,OAAO,IAAMC,iBAAiB,GAAG,mBAA1B;AAgBP;AACA,OAAO,IAAMC,UAAsD,GAAG;EACpEC,OAAO,EAAEhB,IAD2D;EAEpEiB,MAAM,0CACHjB,IADG,EACI;IACNkB,EAAE,kCACCP,IADD,EACQX,IADR,wBAECI,KAFD,EAESJ,IAFT,wBAGCG,IAHD,EAGQH,IAHR,wBAICK,eAJD,EAImBL,IA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e,IAAI,EAAEiD,cADS;cAEf/C,IAAI,EAAED;YAFS,CAAP,CAAV;UAID;QACF;MACF;IACF,CAhCoB,CAArB;EAiCD,CAlCD;AAmCD"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AACA,cAAc,iBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,WAAd","sourcesContent":["export * from './Combobox';\nexport * from './ComboboxButton';\nexport * from './ComboboxInput';\nexport * from './ComboboxLabel';\nexport * from './ComboboxList';\nexport * from './ComboboxOption';\nexport * from './ComboboxPopover';\nexport * from './context';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/ComboBox/index.ts"],"sourcesContent":["export * from './Combobox';\nexport * from './ComboboxButton';\nexport * from './ComboboxInput';\nexport * from './ComboboxLabel';\nexport * from './ComboboxList';\nexport * from './ComboboxOption';\nexport * from './ComboboxPopover';\nexport * from './context';\n"],"mappings":"AAAA,cAAc,YAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AACA,cAAc,iBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,WAAd"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/makeHash.ts"],"names":["makeHash","str","hash","length","i","char","charCodeAt"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,QAAT,CAAkBC,GAAlB,EAA+B;AACpC,MAAIC,IAAI,GAAG,CAAX;;AACA,MAAID,GAAG,CAACE,MAAJ,KAAe,CAAnB,EAAsB;AACpB,WAAOD,IAAP;AACD;;AACD,OAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,GAAG,CAACE,MAAxB,EAAgCC,CAAC,EAAjC,EAAqC;AACnC,QAAMC,IAAI,GAAGJ,GAAG,CAACK,UAAJ,CAAeF,CAAf,CAAb;AACAF,IAAAA,IAAI,GAAG,CAACA,IAAI,IAAI,CAAT,IAAcA,IAAd,GAAqBG,IAA5B;AACAH,IAAAA,IAAI,GAAGA,IAAI,GAAGA,IAAd;AACD;;AACD,SAAOA,IAAP;AACD","sourcesContent":["// We don't want to track the active descendant with indexes because nothing is\n// more annoying in a combobox than having it change values RIGHT AS YOU HIT\n// ENTER. That only happens if you use the index as your data, rather than\n// *your data as your data*. We use this to generate a unique ID based on the\n// value of each item. This function is short, sweet, and good enough™ (I also\n// don't know how it works, tbqh)\n// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript\nexport function makeHash(str: string) {\n let hash = 0;\n if (str.length === 0) {\n return hash;\n }\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash;\n}\n"],"file":"makeHash.js"}
1
+ {"version":3,"file":"makeHash.js","names":["makeHash","str","hash","length","i","char","charCodeAt"],"sources":["../../../src/ComboBox/makeHash.ts"],"sourcesContent":["// We don't want to track the active descendant with indexes because nothing is\n// more annoying in a combobox than having it change values RIGHT AS YOU HIT\n// ENTER. That only happens if you use the index as your data, rather than\n// *your data as your data*. We use this to generate a unique ID based on the\n// value of each item. This function is short, sweet, and good enough™ (I also\n// don't know how it works, tbqh)\n// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript\nexport function makeHash(str: string) {\n let hash = 0;\n if (str.length === 0) {\n return hash;\n }\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,QAAT,CAAkBC,GAAlB,EAA+B;EACpC,IAAIC,IAAI,GAAG,CAAX;;EACA,IAAID,GAAG,CAACE,MAAJ,KAAe,CAAnB,EAAsB;IACpB,OAAOD,IAAP;EACD;;EACD,KAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,GAAG,CAACE,MAAxB,EAAgCC,CAAC,EAAjC,EAAqC;IACnC,IAAMC,IAAI,GAAGJ,GAAG,CAACK,UAAJ,CAAeF,CAAf,CAAb;IACAF,IAAI,GAAG,CAACA,IAAI,IAAI,CAAT,IAAcA,IAAd,GAAqBG,IAA5B;IACAH,IAAI,GAAGA,IAAI,GAAGA,IAAd;EACD;;EACD,OAAOA,IAAP;AACD"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/scopeQuery.ts"],"names":["scopeQuery","nodeType","props"],"mappings":"AAAA,OAAO,SAASA,UAAT,CACLC,QADK,EAELC,KAFK,EAGI;AACT,SAAOA,KAAK,CAAC,4BAAD,CAAL,KAAwC,EAA/C;AACD","sourcesContent":["export function scopeQuery(\n nodeType: string,\n props: Record<string, unknown>\n): boolean {\n return props['data-reach-combobox-option'] === '';\n}\n"],"file":"scopeQuery.js"}
1
+ {"version":3,"file":"scopeQuery.js","names":["scopeQuery","nodeType","props"],"sources":["../../../src/ComboBox/scopeQuery.ts"],"sourcesContent":["export function scopeQuery(\n nodeType: string,\n props: Record<string, unknown>\n): boolean {\n return props['data-reach-combobox-option'] === '';\n}\n"],"mappings":"AAAA,OAAO,SAASA,UAAT,CACLC,QADK,EAELC,KAFK,EAGI;EACT,OAAOA,KAAK,CAAC,4BAAD,CAAL,KAAwC,EAA/C;AACD"}
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- export interface FocusLockProps extends React.HTMLAttributes<HTMLDivElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
6
- childRef: React.MutableRefObject<HTMLElement | null>;
1
+ import type { ElementType, FC, HTMLAttributes, MutableRefObject, ReactNode } from 'react';
2
+ export interface FocusLockProps extends HTMLAttributes<HTMLDivElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
+ childRef: MutableRefObject<HTMLElement | null>;
7
7
  enabled?: boolean;
8
8
  }
9
- export declare const FocusLock: React.FC<FocusLockProps>;
9
+ export declare const FocusLock: FC<FocusLockProps>;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["as", "childRef", "enabled", "style", "children"];
3
4
  import { useRef } from 'react';
4
- import * as React from 'react';
5
5
  import { useFocusLock } from './useFocusLock';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -15,7 +15,7 @@ export var FocusLock = function FocusLock(props) {
15
15
  _props$style = props.style,
16
16
  style = _props$style === void 0 ? {} : _props$style,
17
17
  children = props.children,
18
- otherProps = _objectWithoutProperties(props, ["as", "childRef", "enabled", "style", "children"]);
18
+ otherProps = _objectWithoutProperties(props, _excluded);
19
19
 
20
20
  var lockStartRef = useRef(null);
21
21
  var lockEndRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/FocusLock/FocusLock.tsx"],"names":["useRef","React","useFocusLock","FocusLock","props","as","Comp","childRef","enabled","style","children","otherProps","lockStartRef","lockEndRef","lockStyle","width","height","padding","overflow","position","top","left"],"mappings":";;AAAA,SAASA,MAAT,QAAuB,OAAvB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,YAAT,QAA6B,gBAA7B;;;;AAUA,OAAO,IAAMC,SAAmC,GAAG,SAASA,SAAT,CAAmBC,KAAnB,EAA0B;AAAA,kBAQvEA,KARuE,CAEzEC,EAFyE;AAAA,MAErEC,IAFqE,0BAE9D,KAF8D;AAAA,MAGzEC,QAHyE,GAQvEH,KARuE,CAGzEG,QAHyE;AAAA,uBAQvEH,KARuE,CAIzEI,OAJyE;AAAA,MAIzEA,OAJyE,+BAI/D,KAJ+D;AAAA,qBAQvEJ,KARuE,CAKzEK,KALyE;AAAA,MAKzEA,KALyE,6BAKjE,EALiE;AAAA,MAMzEC,QANyE,GAQvEN,KARuE,CAMzEM,QANyE;AAAA,MAOtEC,UAPsE,4BAQvEP,KARuE;;AAS3E,MAAMQ,YAAY,GAAGZ,MAAM,CAAc,IAAd,CAA3B;AACA,MAAMa,UAAU,GAAGb,MAAM,CAAc,IAAd,CAAzB;AAEAE,EAAAA,YAAY,CAACK,QAAD,EAAW;AAAEC,IAAAA,OAAO,EAAPA,OAAF;AAAWI,IAAAA,YAAY,EAAZA,YAAX;AAAyBC,IAAAA,UAAU,EAAVA;AAAzB,GAAX,CAAZ;;AAEA,MAAMC,SAAS;AACbC,IAAAA,KAAK,EAAE,CADM;AAEbC,IAAAA,MAAM,EAAE,CAFK;AAGbC,IAAAA,OAAO,EAAE,CAHI;AAIbC,IAAAA,QAAQ,EAAE,QAJG;AAKbC,IAAAA,QAAQ,EAAE,OALG;AAMbC,IAAAA,GAAG,EAAE,CANQ;AAObC,IAAAA,IAAI,EAAE;AAPO,KAQVZ,KARU,CAAf;;AAWA,sBACE;AAAA,4BACE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEG,YADP;AAEE,+BAAsB,EAFxB;AAGE,qBAAa,IAHf;AAIE,MAAA,QAAQ,EAAE,CAJZ;AAKE,MAAA,KAAK,EAAEE;AALT,OAMMH,UANN,EADF,EASGD,QATH,eAUE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEG,UADP;AAEE,6BAAoB,EAFtB;AAGE,qBAAa,IAHf;AAIE,MAAA,QAAQ,EAAE,CAJZ;AAKE,MAAA,KAAK,EAAEC;AALT,OAMMH,UANN,EAVF;AAAA,IADF;AAqBD,CA9CM","sourcesContent":["import { useRef } from 'react';\nimport * as React from 'react';\n\nimport { useFocusLock } from './useFocusLock';\n\nexport interface FocusLockProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n childRef: React.MutableRefObject<HTMLElement | null>;\n enabled?: boolean;\n}\n\nexport const FocusLock: React.FC<FocusLockProps> = function FocusLock(props) {\n const {\n as: Comp = 'div',\n childRef,\n enabled = false,\n style = {},\n children,\n ...otherProps\n } = props;\n const lockStartRef = useRef<HTMLElement>(null);\n const lockEndRef = useRef<HTMLElement>(null);\n\n useFocusLock(childRef, { enabled, lockStartRef, lockEndRef });\n\n const lockStyle = {\n width: 1,\n height: 0,\n padding: 0,\n overflow: 'hidden',\n position: 'fixed',\n top: 1,\n left: 1,\n ...style,\n };\n\n return (\n <>\n <Comp\n ref={lockStartRef}\n data-focus-lock-start=\"\"\n aria-hidden={true}\n tabIndex={0}\n style={lockStyle}\n {...otherProps}\n />\n {children}\n <Comp\n ref={lockEndRef}\n data-focus-lock-end=\"\"\n aria-hidden={true}\n tabIndex={0}\n style={lockStyle}\n {...otherProps}\n />\n </>\n );\n};\n"],"file":"FocusLock.js"}
1
+ {"version":3,"file":"FocusLock.js","names":["useRef","useFocusLock","FocusLock","props","as","Comp","childRef","enabled","style","children","otherProps","lockStartRef","lockEndRef","lockStyle","width","height","padding","overflow","position","top","left"],"sources":["../../../src/FocusLock/FocusLock.tsx"],"sourcesContent":["import type {\n ElementType,\n FC,\n HTMLAttributes,\n MutableRefObject,\n ReactNode,\n} from 'react';\nimport { useRef } from 'react';\n\nimport { useFocusLock } from './useFocusLock';\n\nexport interface FocusLockProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n childRef: MutableRefObject<HTMLElement | null>;\n enabled?: boolean;\n}\n\nexport const FocusLock: FC<FocusLockProps> = function FocusLock(props) {\n const {\n as: Comp = 'div',\n childRef,\n enabled = false,\n style = {},\n children,\n ...otherProps\n } = props;\n const lockStartRef = useRef<HTMLElement>(null);\n const lockEndRef = useRef<HTMLElement>(null);\n\n useFocusLock(childRef, { enabled, lockStartRef, lockEndRef });\n\n const lockStyle = {\n width: 1,\n height: 0,\n padding: 0,\n overflow: 'hidden',\n position: 'fixed',\n top: 1,\n left: 1,\n ...style,\n };\n\n return (\n <>\n <Comp\n ref={lockStartRef}\n data-focus-lock-start=\"\"\n aria-hidden={true}\n tabIndex={0}\n style={lockStyle}\n {...otherProps}\n />\n {children}\n <Comp\n ref={lockEndRef}\n data-focus-lock-end=\"\"\n aria-hidden={true}\n tabIndex={0}\n style={lockStyle}\n {...otherProps}\n />\n </>\n );\n};\n"],"mappings":";;;AAOA,SAASA,MAAT,QAAuB,OAAvB;AAEA,SAASC,YAAT,QAA6B,gBAA7B;;;;AAUA,OAAO,IAAMC,SAA6B,GAAG,SAASA,SAAT,CAAmBC,KAAnB,EAA0B;EACrE,gBAOIA,KAPJ,CACEC,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,IAEEC,QAFF,GAOIH,KAPJ,CAEEG,QAFF;EAAA,qBAOIH,KAPJ,CAGEI,OAHF;EAAA,IAGEA,OAHF,+BAGY,KAHZ;EAAA,mBAOIJ,KAPJ,CAIEK,KAJF;EAAA,IAIEA,KAJF,6BAIU,EAJV;EAAA,IAKEC,QALF,GAOIN,KAPJ,CAKEM,QALF;EAAA,IAMKC,UANL,4BAOIP,KAPJ;;EAQA,IAAMQ,YAAY,GAAGX,MAAM,CAAc,IAAd,CAA3B;EACA,IAAMY,UAAU,GAAGZ,MAAM,CAAc,IAAd,CAAzB;EAEAC,YAAY,CAACK,QAAD,EAAW;IAAEC,OAAO,EAAPA,OAAF;IAAWI,YAAY,EAAZA,YAAX;IAAyBC,UAAU,EAAVA;EAAzB,CAAX,CAAZ;;EAEA,IAAMC,SAAS;IACbC,KAAK,EAAE,CADM;IAEbC,MAAM,EAAE,CAFK;IAGbC,OAAO,EAAE,CAHI;IAIbC,QAAQ,EAAE,QAJG;IAKbC,QAAQ,EAAE,OALG;IAMbC,GAAG,EAAE,CANQ;IAObC,IAAI,EAAE;EAPO,GAQVZ,KARU,CAAf;;EAWA,oBACE;IAAA,wBACE,KAAC,IAAD;MACE,GAAG,EAAEG,YADP;MAEE,yBAAsB,EAFxB;MAGE,eAAa,IAHf;MAIE,QAAQ,EAAE,CAJZ;MAKE,KAAK,EAAEE;IALT,GAMMH,UANN,EADF,EASGD,QATH,eAUE,KAAC,IAAD;MACE,GAAG,EAAEG,UADP;MAEE,uBAAoB,EAFtB;MAGE,eAAa,IAHf;MAIE,QAAQ,EAAE,CAJZ;MAKE,KAAK,EAAEC;IALT,GAMMH,UANN,EAVF;EAAA,EADF;AAqBD,CA9CM"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/FocusLock/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAd","sourcesContent":["export * from './FocusLock';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/FocusLock/index.ts"],"sourcesContent":["export * from './FocusLock';\n"],"mappings":"AAAA,cAAc,aAAd"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/FocusLock/tabUtils.ts"],"names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll","focusOnChildNode","itemIndex","elements","length","focus","currentTabIndex","tabIndex"],"mappings":"AAAA,OAAO,IAAMA,SAAS,GAAG,CACvB,gCADuB,EAEvB,gCAFuB,EAGvB,kCAHuB,EAIvB,+BAJuB,EAMvB,SANuB,EAOvB,YAPuB,EASvB,QATuB,EAUvB,QAVuB,EAWvB,OAXuB,EAavB,YAbuB,EAcvB,mBAduB,EAevB,aAfuB,EAgBvBC,IAhBuB,CAgBlB,GAhBkB,CAAlB;AAkBP;;AACA,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAC/BC,UAD+B,EAEb;AAClB,MAAI,CAACA,UAAL,EAAiB;AACf,WAAO,EAAP;AACD;;AAED,SAAOC,KAAK,CAACC,IAAN,CAAWF,UAAU,CAACG,gBAAX,CAA4BN,SAA5B,CAAX,CAAP;AACD,CARM;AAUP,OAAO,SAASO,gBAAT,CAA0BJ,UAA1B,EAAmDK,SAAnD,EAAsE;AAC3E,MAAMC,QAAQ,GAAGP,iBAAiB,CAACC,UAAD,CAAlC;;AACA,MAAIM,QAAQ,CAACC,MAAT,GAAkB,CAAtB,EAAyB;AACvBD,IAAAA,QAAQ,CAACD,SAAS,KAAK,CAAC,CAAf,GAAmBC,QAAQ,CAACC,MAAT,GAAkB,CAArC,GAAyC,CAA1C,CAAR,CAAqDC,KAArD;AACD,GAFD,MAEO;AACL,QAAMC,eAAe,GAAGT,UAAU,CAACU,QAAnC;AACAV,IAAAA,UAAU,CAACU,QAAX,GAAsB,CAAtB;AACAV,IAAAA,UAAU,CAACQ,KAAX;AACAR,IAAAA,UAAU,CAACU,QAAX,GAAsBD,eAAtB;AACD;AACF","sourcesContent":["export const tabblable = [\n 'button:enabled:not([readonly])',\n 'select:enabled:not([readonly])',\n 'textarea:enabled:not([readonly])',\n 'input:enabled:not([readonly])',\n\n 'a[href]',\n 'area[href]',\n\n 'iframe',\n 'object',\n 'embed',\n\n '[tabindex]',\n '[contenteditable]',\n '[autofocus]',\n].join(',');\n\n/* This is naive and will not consider tabIndex */\nexport const getTabblableNodes = (\n parentNode: HTMLElement | null\n): HTMLElement[] => {\n if (!parentNode) {\n return [];\n }\n\n return Array.from(parentNode.querySelectorAll(tabblable));\n};\n\nexport function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1) {\n const elements = getTabblableNodes(parentNode);\n if (elements.length > 0) {\n elements[itemIndex === -1 ? elements.length - 1 : 0].focus();\n } else {\n const currentTabIndex = parentNode.tabIndex;\n parentNode.tabIndex = 0;\n parentNode.focus();\n parentNode.tabIndex = currentTabIndex;\n }\n}\n"],"file":"tabUtils.js"}
1
+ {"version":3,"file":"tabUtils.js","names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll","focusOnChildNode","itemIndex","elements","length","focus","currentTabIndex","tabIndex"],"sources":["../../../src/FocusLock/tabUtils.ts"],"sourcesContent":["export const tabblable = [\n 'button:enabled:not([readonly])',\n 'select:enabled:not([readonly])',\n 'textarea:enabled:not([readonly])',\n 'input:enabled:not([readonly])',\n\n 'a[href]',\n 'area[href]',\n\n 'iframe',\n 'object',\n 'embed',\n\n '[tabindex]',\n '[contenteditable]',\n '[autofocus]',\n].join(',');\n\n/* This is naive and will not consider tabIndex */\nexport const getTabblableNodes = (\n parentNode: HTMLElement | null\n): HTMLElement[] => {\n if (!parentNode) {\n return [];\n }\n\n return Array.from(parentNode.querySelectorAll(tabblable));\n};\n\nexport function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1) {\n const elements = getTabblableNodes(parentNode);\n if (elements.length > 0) {\n elements[itemIndex === -1 ? elements.length - 1 : 0].focus();\n } else {\n const currentTabIndex = parentNode.tabIndex;\n parentNode.tabIndex = 0;\n parentNode.focus();\n parentNode.tabIndex = currentTabIndex;\n }\n}\n"],"mappings":"AAAA,OAAO,IAAMA,SAAS,GAAG,CACvB,gCADuB,EAEvB,gCAFuB,EAGvB,kCAHuB,EAIvB,+BAJuB,EAMvB,SANuB,EAOvB,YAPuB,EASvB,QATuB,EAUvB,QAVuB,EAWvB,OAXuB,EAavB,YAbuB,EAcvB,mBAduB,EAevB,aAfuB,EAgBvBC,IAhBuB,CAgBlB,GAhBkB,CAAlB;AAkBP;;AACA,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAC/BC,UAD+B,EAEb;EAClB,IAAI,CAACA,UAAL,EAAiB;IACf,OAAO,EAAP;EACD;;EAED,OAAOC,KAAK,CAACC,IAAN,CAAWF,UAAU,CAACG,gBAAX,CAA4BN,SAA5B,CAAX,CAAP;AACD,CARM;AAUP,OAAO,SAASO,gBAAT,CAA0BJ,UAA1B,EAAmDK,SAAnD,EAAsE;EAC3E,IAAMC,QAAQ,GAAGP,iBAAiB,CAACC,UAAD,CAAlC;;EACA,IAAIM,QAAQ,CAACC,MAAT,GAAkB,CAAtB,EAAyB;IACvBD,QAAQ,CAACD,SAAS,KAAK,CAAC,CAAf,GAAmBC,QAAQ,CAACC,MAAT,GAAkB,CAArC,GAAyC,CAA1C,CAAR,CAAqDC,KAArD;EACD,CAFD,MAEO;IACL,IAAMC,eAAe,GAAGT,UAAU,CAACU,QAAnC;IACAV,UAAU,CAACU,QAAX,GAAsB,CAAtB;IACAV,UAAU,CAACQ,KAAX;IACAR,UAAU,CAACU,QAAX,GAAsBD,eAAtB;EACD;AACF"}
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import type { MutableRefObject } from 'react';
2
2
  export interface FocusLockOptions {
3
3
  enabled: boolean;
4
- lockStartRef: React.MutableRefObject<HTMLElement | null>;
5
- lockEndRef: React.MutableRefObject<HTMLElement | null>;
4
+ lockStartRef: MutableRefObject<HTMLElement | null>;
5
+ lockEndRef: MutableRefObject<HTMLElement | null>;
6
6
  }
7
- export declare function useFocusLock(ref: React.MutableRefObject<HTMLElement | null>, opts: FocusLockOptions): void;
7
+ export declare function useFocusLock(ref: MutableRefObject<HTMLElement | null>, opts: FocusLockOptions): void;
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/FocusLock/useFocusLock.ts"],"names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,IAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;AAAA,sBACqDA,IADrD,CACQC,OADR;AAAA,MACQA,OADR,8BACkB,IADlB;AAAA,MACwBC,YADxB,GACqDF,IADrD,CACwBE,YADxB;AAAA,MACsCC,UADtC,GACqDH,IADrD,CACsCG,UADtC;AAGAR,EAAAA,SAAS,CAAC,YAAM;AACd,QAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;AACA,QAAIJ,OAAO,IAAIG,MAAf,EAAuB;AACrBP,MAAAA,cAAc,CAACS,IAAf,CAAoBF,MAApB;;AAEA,UAAMG,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAuB;AACtC,YAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;AAEA,YAAI,CAACK,iBAAL,EAAwB;AACtB;AACA;AACD;;AAED,YAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;AACvCT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD,SAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;AAChDT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;AACD,SAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;AACAH,UAAAA,KAAK,CAACM,cAAN;AACAlB,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD;AACF,OApBD;;AAsBAQ,MAAAA,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;AACA,aAAO,YAAM;AACXK,QAAAA,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;AACAV,QAAAA,cAAc,CAACoB,GAAf;AACD,OALD;AAMD,KAlCa,CAmCd;;AACD,GApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD","sourcesContent":["import { useEffect } from 'react';\n\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: React.MutableRefObject<HTMLElement | null>;\n lockEndRef: React.MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: React.MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"file":"useFocusLock.js"}
1
+ {"version":3,"file":"useFocusLock.js","names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"sources":["../../../src/FocusLock/useFocusLock.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: MutableRefObject<HTMLElement | null>;\n lockEndRef: MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,IAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;EACA,oBAAqDA,IAArD,CAAQC,OAAR;EAAA,IAAQA,OAAR,8BAAkB,IAAlB;EAAA,IAAwBC,YAAxB,GAAqDF,IAArD,CAAwBE,YAAxB;EAAA,IAAsCC,UAAtC,GAAqDH,IAArD,CAAsCG,UAAtC;EAEAR,SAAS,CAAC,YAAM;IACd,IAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;IACA,IAAIJ,OAAO,IAAIG,MAAf,EAAuB;MACrBP,cAAc,CAACS,IAAf,CAAoBF,MAApB;;MAEA,IAAMG,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAuB;QACtC,IAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;QAEA,IAAI,CAACK,iBAAL,EAAwB;UACtB;UACA;QACD;;QAED,IAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;UACvCT,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;QACD,CAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;UAChDT,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;QACD,CAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;UACAH,KAAK,CAACM,cAAN;UACAlB,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;QACD;MACF,CApBD;;MAsBAQ,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;MACA,OAAO,YAAM;QACXK,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;QACAV,cAAc,CAACoB,GAAf;MACD,CALD;IAMD,CAlCa,CAmCd;;EACD,CApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD"}
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
2
- export interface ListProps extends React.HTMLAttributes<HTMLUListElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface ListProps extends HTMLAttributes<HTMLUListElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLUListElement>>;
7
+ export declare const List: import("react").ForwardRefExoticComponent<ListProps & import("react").RefAttributes<HTMLUListElement>>;
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["as"];
3
4
  import { forwardRef } from 'react';
4
- import * as React from 'react';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  export var List = /*#__PURE__*/forwardRef(function List(props, forwardedRef) {
7
7
  var _props$as = props.as,
8
8
  Comp = _props$as === void 0 ? 'ul' : _props$as,
9
- otherProps = _objectWithoutProperties(props, ["as"]);
9
+ otherProps = _objectWithoutProperties(props, _excluded);
10
10
 
11
11
  return /*#__PURE__*/_jsx(Comp, _extends({
12
12
  ref: forwardedRef
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/List.tsx"],"names":["forwardRef","React","List","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;;AAQA,OAAO,IAAMC,IAAI,gBAAGF,UAAU,CAA8B,SAASE,IAAT,CAC1DC,KAD0D,EAE1DC,YAF0D,EAG1D;AAAA,kBAC2CD,KAD3C,CACQE,EADR;AAAA,MACYC,IADZ,0BACmB,IADnB;AAAA,MAC4BC,UAD5B,4BAC2CJ,KAD3C;;AAGA,sBAAO,KAAC,IAAD;AAAM,IAAA,GAAG,EAAEC;AAAX,KAA6BG,UAA7B,EAAP;AACD,CAP6B,CAAvB","sourcesContent":["import { forwardRef } from 'react';\nimport * as React from 'react';\n\nexport interface ListProps extends React.HTMLAttributes<HTMLUListElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const List = forwardRef<HTMLUListElement, ListProps>(function List(\n props,\n forwardedRef\n) {\n const { as: Comp = 'ul', ...otherProps } = props;\n\n return <Comp ref={forwardedRef} {...otherProps} />;\n});\n"],"file":"List.js"}
1
+ {"version":3,"file":"List.js","names":["forwardRef","List","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/List.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const List = forwardRef<HTMLUListElement, ListProps>(function List(\n props,\n forwardedRef\n) {\n const { as: Comp = 'ul', ...otherProps } = props;\n\n return <Comp ref={forwardedRef} {...otherProps} />;\n});\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,IAAI,gBAAGD,UAAU,CAA8B,SAASC,IAAT,CAC1DC,KAD0D,EAE1DC,YAF0D,EAG1D;EACA,gBAA2CD,KAA3C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,IAAnB;EAAA,IAA4BC,UAA5B,4BAA2CJ,KAA3C;;EAEA,oBAAO,KAAC,IAAD;IAAM,GAAG,EAAEC;EAAX,GAA6BG,UAA7B,EAAP;AACD,CAP6B,CAAvB"}
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
2
- export interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const ListItem: React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<HTMLLIElement>>;
7
+ export declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["as"];
3
4
  import { forwardRef } from 'react';
4
- import * as React from 'react';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  export var ListItem = /*#__PURE__*/forwardRef(function ListItem(props, forwardedRef) {
7
7
  var _props$as = props.as,
8
8
  Comp = _props$as === void 0 ? 'li' : _props$as,
9
- otherProps = _objectWithoutProperties(props, ["as"]);
9
+ otherProps = _objectWithoutProperties(props, _excluded);
10
10
 
11
11
  return /*#__PURE__*/_jsx(Comp, _extends({
12
12
  tabIndex: -1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/ListItem.tsx"],"names":["forwardRef","React","ListItem","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;;AAQA,OAAO,IAAMC,QAAQ,gBAAGF,UAAU,CAChC,SAASE,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AAAA,kBACMD,KADN,CAC7BE,EAD6B;AAAA,MACzBC,IADyB,0BAClB,IADkB;AAAA,MACTC,UADS,4BACMJ,KADN;;AAGrC,sBACE,KAAC,IAAD;AACE,IAAA,QAAQ,EAAE,CAAC,CADb;AAEE,sBAAe,EAFjB;AAGE,IAAA,GAAG,EAAEC;AAHP,KAIMG,UAJN,EADF;AAQD,CAZ+B,CAA3B","sourcesContent":["import { forwardRef } from 'react';\nimport * as React from 'react';\n\nexport interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, forwardedRef) {\n const { as: Comp = 'li', ...otherProps } = props;\n\n return (\n <Comp\n tabIndex={-1}\n data-list-item=\"\"\n ref={forwardedRef}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"ListItem.js"}
1
+ {"version":3,"file":"ListItem.js","names":["forwardRef","ListItem","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/ListItem.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListItemProps extends HTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, forwardedRef) {\n const { as: Comp = 'li', ...otherProps } = props;\n\n return (\n <Comp\n tabIndex={-1}\n data-list-item=\"\"\n ref={forwardedRef}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,QAAQ,gBAAGD,UAAU,CAChC,SAASC,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;EACrC,gBAA2CD,KAA3C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,IAAnB;EAAA,IAA4BC,UAA5B,4BAA2CJ,KAA3C;;EAEA,oBACE,KAAC,IAAD;IACE,QAAQ,EAAE,CAAC,CADb;IAEE,kBAAe,EAFjB;IAGE,GAAG,EAAEC;EAHP,GAIMG,UAJN,EADF;AAQD,CAZ+B,CAA3B"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/context.ts"],"names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAKA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACAE,WAAW,CAACC,WAAZ,GAA0B,aAA1B;AAEA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,GAAwB;AACpD,MAAMC,GAAG,GAAGJ,UAAU,CAACC,WAAD,CAAtB;;AACA,MAAI,CAACG,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CACJ,2DADI,CAAN;AAGD;;AACD,SAAOD,GAAP;AACD,CARM","sourcesContent":["import { createContext, useContext } from 'react';\n\n// List Component\nexport interface ListContextProps {\n id: string | undefined;\n}\n\nconst ListContext = createContext<ListContextProps | null>(null);\nListContext.displayName = 'ListContext';\n\nexport const useListContext = (): ListContextProps => {\n const ctx = useContext(ListContext);\n if (!ctx) {\n throw new Error(\n 'useListContext must be used within a ListContext.Provider'\n );\n }\n return ctx;\n};\n"],"file":"context.js"}
1
+ {"version":3,"file":"context.js","names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"sources":["../../../src/List/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n// List Component\nexport interface ListContextProps {\n id: string | undefined;\n}\n\nconst ListContext = createContext<ListContextProps | null>(null);\nListContext.displayName = 'ListContext';\n\nexport const useListContext = (): ListContextProps => {\n const ctx = useContext(ListContext);\n if (!ctx) {\n throw new Error(\n 'useListContext must be used within a ListContext.Provider'\n );\n }\n return ctx;\n};\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAKA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACAE,WAAW,CAACC,WAAZ,GAA0B,aAA1B;AAEA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,GAAwB;EACpD,IAAMC,GAAG,GAAGJ,UAAU,CAACC,WAAD,CAAtB;;EACA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CACJ,2DADI,CAAN;EAGD;;EACD,OAAOD,GAAP;AACD,CARM"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,YAAd","sourcesContent":["export * from './List';\nexport * from './ListItem';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/List/index.ts"],"sourcesContent":["export * from './List';\nexport * from './ListItem';\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,YAAd"}
@@ -1,10 +1,10 @@
1
- import * as React from 'react';
1
+ import type { KeyboardEvent, MouseEvent, PointerEvent, ReactNode, ElementType } from 'react';
2
2
  export interface MenuProps {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
6
- onChange?: (e: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement> | React.PointerEvent<HTMLElement>, isOpen: boolean) => void;
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
+ onChange?: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
7
7
  open?: boolean;
8
8
  defaultOpen?: boolean;
9
9
  }
10
- export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["as", "open", "defaultOpen", "onChange"];
4
5
  import { forwardRef, useRef, Fragment, useId } from 'react';
5
- import * as React from 'react';
6
6
  import { MenuProvider } from './context';
7
7
  import { useControlledState } from '../hooks';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -13,7 +13,7 @@ export var Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
13
13
  _props$defaultOpen = props.defaultOpen,
14
14
  defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
15
15
  onChangeProp = props.onChange,
16
- otherProps = _objectWithoutProperties(props, ["as", "open", "defaultOpen", "onChange"]);
16
+ otherProps = _objectWithoutProperties(props, _excluded);
17
17
 
18
18
  var menuListIdRef = useRef();
19
19
  var openWithArrowKeyRef = useRef(null);