@basic-ui/core 0.0.54 → 0.0.57

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 (410) hide show
  1. package/README.md +3 -3
  2. package/build/cjs/index.js +364 -591
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/esm/Accordion/Accordion.d.ts +9 -9
  5. package/build/esm/Accordion/Accordion.js +20 -29
  6. package/build/esm/Accordion/Accordion.js.map +1 -1
  7. package/build/esm/Accordion/AccordionBody.d.ts +6 -6
  8. package/build/esm/Accordion/AccordionBody.js +18 -32
  9. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  10. package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
  11. package/build/esm/Accordion/AccordionHeader.js +37 -74
  12. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  13. package/build/esm/Accordion/AccordionItem.d.ts +9 -9
  14. package/build/esm/Accordion/AccordionItem.js +19 -22
  15. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  16. package/build/esm/Accordion/context.d.ts +19 -19
  17. package/build/esm/Accordion/context.js +16 -13
  18. package/build/esm/Accordion/context.js.map +1 -1
  19. package/build/esm/Accordion/index.d.ts +4 -4
  20. package/build/esm/Accordion/index.js.map +1 -1
  21. package/build/esm/Accordion/scopeQuery.d.ts +2 -2
  22. package/build/esm/Accordion/scopeQuery.js.map +1 -1
  23. package/build/esm/CheckBox/CheckBox.d.ts +7 -7
  24. package/build/esm/CheckBox/CheckBox.js +15 -25
  25. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  26. package/build/esm/CheckBox/index.d.ts +1 -1
  27. package/build/esm/CheckBox/index.js.map +1 -1
  28. package/build/esm/ComboBox/Combobox.d.ts +18 -18
  29. package/build/esm/ComboBox/Combobox.js +52 -59
  30. package/build/esm/ComboBox/Combobox.js.map +1 -1
  31. package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
  32. package/build/esm/ComboBox/ComboboxButton.js +23 -28
  33. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  34. package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
  35. package/build/esm/ComboBox/ComboboxInput.js +67 -70
  36. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  37. package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
  38. package/build/esm/ComboBox/ComboboxLabel.js +15 -17
  39. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  40. package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
  41. package/build/esm/ComboBox/ComboboxList.js +19 -20
  42. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  43. package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
  44. package/build/esm/ComboBox/ComboboxOption.js +41 -45
  45. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  46. package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
  47. package/build/esm/ComboBox/ComboboxPopover.js +22 -21
  48. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  49. package/build/esm/ComboBox/cities.d.ts +5 -5
  50. package/build/esm/ComboBox/cities.js.map +1 -1
  51. package/build/esm/ComboBox/context.d.ts +30 -30
  52. package/build/esm/ComboBox/context.js +5 -6
  53. package/build/esm/ComboBox/context.js.map +1 -1
  54. package/build/esm/ComboBox/hooks.d.ts +37 -37
  55. package/build/esm/ComboBox/hooks.js +175 -148
  56. package/build/esm/ComboBox/hooks.js.map +1 -1
  57. package/build/esm/ComboBox/index.d.ts +8 -8
  58. package/build/esm/ComboBox/index.js.map +1 -1
  59. package/build/esm/ComboBox/makeHash.d.ts +1 -1
  60. package/build/esm/ComboBox/makeHash.js +3 -6
  61. package/build/esm/ComboBox/makeHash.js.map +1 -1
  62. package/build/esm/ComboBox/scopeQuery.d.ts +1 -1
  63. package/build/esm/ComboBox/scopeQuery.js.map +1 -1
  64. package/build/esm/FocusLock/FocusLock.d.ts +9 -9
  65. package/build/esm/FocusLock/FocusLock.js +26 -32
  66. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  67. package/build/esm/FocusLock/index.d.ts +1 -1
  68. package/build/esm/FocusLock/index.js.map +1 -1
  69. package/build/esm/FocusLock/tabUtils.d.ts +3 -3
  70. package/build/esm/FocusLock/tabUtils.js +5 -7
  71. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  72. package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
  73. package/build/esm/FocusLock/useFocusLock.js +14 -19
  74. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  75. package/build/esm/List/List.d.ts +7 -7
  76. package/build/esm/List/List.js +9 -11
  77. package/build/esm/List/List.js.map +1 -1
  78. package/build/esm/List/ListItem.d.ts +7 -7
  79. package/build/esm/List/ListItem.js +9 -11
  80. package/build/esm/List/ListItem.js.map +1 -1
  81. package/build/esm/List/context.d.ts +4 -4
  82. package/build/esm/List/context.js +6 -6
  83. package/build/esm/List/context.js.map +1 -1
  84. package/build/esm/List/index.d.ts +2 -2
  85. package/build/esm/List/index.js.map +1 -1
  86. package/build/esm/Menu/ContextMenuTrigger.d.ts +11 -11
  87. package/build/esm/Menu/ContextMenuTrigger.js +32 -37
  88. package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
  89. package/build/esm/Menu/Menu.d.ts +10 -10
  90. package/build/esm/Menu/Menu.js +33 -49
  91. package/build/esm/Menu/Menu.js.map +1 -1
  92. package/build/esm/Menu/MenuButton.d.ts +11 -11
  93. package/build/esm/Menu/MenuButton.js +28 -44
  94. package/build/esm/Menu/MenuButton.js.map +1 -1
  95. package/build/esm/Menu/MenuItem.d.ts +8 -8
  96. package/build/esm/Menu/MenuItem.js +29 -38
  97. package/build/esm/Menu/MenuItem.js.map +1 -1
  98. package/build/esm/Menu/MenuList.d.ts +7 -7
  99. package/build/esm/Menu/MenuList.js +61 -116
  100. package/build/esm/Menu/MenuList.js.map +1 -1
  101. package/build/esm/Menu/MenuPopover.d.ts +8 -8
  102. package/build/esm/Menu/MenuPopover.js +16 -19
  103. package/build/esm/Menu/MenuPopover.js.map +1 -1
  104. package/build/esm/Menu/context.d.ts +25 -25
  105. package/build/esm/Menu/context.js +14 -12
  106. package/build/esm/Menu/context.js.map +1 -1
  107. package/build/esm/Menu/fixtures/countryList.d.ts +1 -1
  108. package/build/esm/Menu/fixtures/countryList.js +1 -1
  109. package/build/esm/Menu/fixtures/countryList.js.map +1 -1
  110. package/build/esm/Menu/index.d.ts +6 -6
  111. package/build/esm/Menu/index.js.map +1 -1
  112. package/build/esm/Menu/scope.d.ts +1 -1
  113. package/build/esm/Menu/scope.js.map +1 -1
  114. package/build/esm/Modal/Modal.d.ts +9 -9
  115. package/build/esm/Modal/Modal.js +13 -18
  116. package/build/esm/Modal/Modal.js.map +1 -1
  117. package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
  118. package/build/esm/Modal/ModalBackdrop.js +24 -33
  119. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  120. package/build/esm/Modal/index.d.ts +2 -2
  121. package/build/esm/Modal/index.js.map +1 -1
  122. package/build/esm/Popper/Popper.d.ts +35 -35
  123. package/build/esm/Popper/Popper.js +44 -60
  124. package/build/esm/Popper/Popper.js.map +1 -1
  125. package/build/esm/Popper/PopperArrow.d.ts +6 -6
  126. package/build/esm/Popper/PopperArrow.js +11 -16
  127. package/build/esm/Popper/PopperArrow.js.map +1 -1
  128. package/build/esm/Popper/context.d.ts +6 -6
  129. package/build/esm/Popper/context.js +3 -5
  130. package/build/esm/Popper/context.js.map +1 -1
  131. package/build/esm/Popper/index.d.ts +3 -3
  132. package/build/esm/Popper/index.js.map +1 -1
  133. package/build/esm/Portal/Portal.d.ts +7 -7
  134. package/build/esm/Portal/Portal.js +9 -11
  135. package/build/esm/Portal/Portal.js.map +1 -1
  136. package/build/esm/Portal/PortalSelectorProvider.d.ts +8 -8
  137. package/build/esm/Portal/PortalSelectorProvider.js +6 -4
  138. package/build/esm/Portal/PortalSelectorProvider.js.map +1 -1
  139. package/build/esm/Portal/index.d.ts +2 -2
  140. package/build/esm/Portal/index.js.map +1 -1
  141. package/build/esm/RadioButton/RadioButton.d.ts +10 -10
  142. package/build/esm/RadioButton/RadioButton.js +17 -23
  143. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  144. package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
  145. package/build/esm/RadioButton/RadioGroup.js +19 -28
  146. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  147. package/build/esm/RadioButton/context.d.ts +9 -9
  148. package/build/esm/RadioButton/context.js +8 -6
  149. package/build/esm/RadioButton/context.js.map +1 -1
  150. package/build/esm/RadioButton/index.d.ts +2 -2
  151. package/build/esm/RadioButton/index.js.map +1 -1
  152. package/build/esm/SkipNav/SkipNav.d.ts +7 -7
  153. package/build/esm/SkipNav/SkipNav.js +9 -11
  154. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  155. package/build/esm/SkipNav/index.d.ts +1 -1
  156. package/build/esm/SkipNav/index.js.map +1 -1
  157. package/build/esm/Slider/Slider.d.ts +197 -197
  158. package/build/esm/Slider/Slider.js +422 -489
  159. package/build/esm/Slider/Slider.js.map +1 -1
  160. package/build/esm/Slider/index.d.ts +1 -1
  161. package/build/esm/Slider/index.js.map +1 -1
  162. package/build/esm/Spinner/Spinner.d.ts +12 -12
  163. package/build/esm/Spinner/Spinner.js +31 -59
  164. package/build/esm/Spinner/Spinner.js.map +1 -1
  165. package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
  166. package/build/esm/Spinner/SpinnerButton.js +14 -19
  167. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  168. package/build/esm/Spinner/context.d.ts +12 -12
  169. package/build/esm/Spinner/context.js +8 -7
  170. package/build/esm/Spinner/context.js.map +1 -1
  171. package/build/esm/Spinner/index.d.ts +2 -2
  172. package/build/esm/Spinner/index.js.map +1 -1
  173. package/build/esm/Tabs/Tab.d.ts +7 -7
  174. package/build/esm/Tabs/Tab.js +32 -50
  175. package/build/esm/Tabs/Tab.js.map +1 -1
  176. package/build/esm/Tabs/TabList.d.ts +9 -9
  177. package/build/esm/Tabs/TabList.js +24 -34
  178. package/build/esm/Tabs/TabList.js.map +1 -1
  179. package/build/esm/Tabs/TabPanel.d.ts +8 -8
  180. package/build/esm/Tabs/TabPanel.js +16 -23
  181. package/build/esm/Tabs/TabPanel.js.map +1 -1
  182. package/build/esm/Tabs/TabPanels.d.ts +8 -8
  183. package/build/esm/Tabs/TabPanels.js +15 -20
  184. package/build/esm/Tabs/TabPanels.js.map +1 -1
  185. package/build/esm/Tabs/Tabs.d.ts +10 -10
  186. package/build/esm/Tabs/Tabs.js +17 -33
  187. package/build/esm/Tabs/Tabs.js.map +1 -1
  188. package/build/esm/Tabs/context.d.ts +17 -17
  189. package/build/esm/Tabs/context.js +16 -13
  190. package/build/esm/Tabs/context.js.map +1 -1
  191. package/build/esm/Tabs/index.d.ts +5 -5
  192. package/build/esm/Tabs/index.js.map +1 -1
  193. package/build/esm/Tabs/scopeQuery.d.ts +1 -1
  194. package/build/esm/Tabs/scopeQuery.js.map +1 -1
  195. package/build/esm/Tooltip/Tooltip.d.ts +10 -10
  196. package/build/esm/Tooltip/Tooltip.js +20 -30
  197. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  198. package/build/esm/Tooltip/index.d.ts +1 -1
  199. package/build/esm/Tooltip/index.js.map +1 -1
  200. package/build/esm/Tooltip/stateMachine.d.ts +28 -28
  201. package/build/esm/Tooltip/stateMachine.js +95 -81
  202. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  203. package/build/esm/Tooltip/useTooltip.d.ts +10 -10
  204. package/build/esm/Tooltip/useTooltip.js +38 -50
  205. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  206. package/build/esm/hooks/index.d.ts +13 -13
  207. package/build/esm/hooks/index.js.map +1 -1
  208. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  209. package/build/esm/hooks/useAutoFocus.js +3 -3
  210. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  211. package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
  212. package/build/esm/hooks/useChildrenCounter.js +6 -8
  213. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  214. package/build/esm/hooks/useControlledState.d.ts +3 -3
  215. package/build/esm/hooks/useControlledState.js +6 -16
  216. package/build/esm/hooks/useControlledState.js.map +1 -1
  217. package/build/esm/hooks/useFocusReturn.d.ts +2 -2
  218. package/build/esm/hooks/useFocusReturn.js +8 -12
  219. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  220. package/build/esm/hooks/useFocusState.d.ts +11 -11
  221. package/build/esm/hooks/useFocusState.js +9 -15
  222. package/build/esm/hooks/useFocusState.js.map +1 -1
  223. package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
  224. package/build/esm/hooks/useGestureHandlers.js +80 -100
  225. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  226. package/build/esm/hooks/useMeasure.d.ts +7 -7
  227. package/build/esm/hooks/useMeasure.js +7 -15
  228. package/build/esm/hooks/useMeasure.js.map +1 -1
  229. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  230. package/build/esm/hooks/useOnClickOutside.js +4 -6
  231. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  232. package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
  233. package/build/esm/hooks/useOnKeyDown.js +3 -4
  234. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  235. package/build/esm/hooks/useReducerMachine.d.ts +24 -24
  236. package/build/esm/hooks/useReducerMachine.js +15 -26
  237. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  238. package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
  239. package/build/esm/hooks/useRemoveBodyScroll.js +9 -14
  240. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  241. package/build/esm/hooks/useScope.d.ts +11 -11
  242. package/build/esm/hooks/useScope.js +12 -14
  243. package/build/esm/hooks/useScope.js.map +1 -1
  244. package/build/esm/hooks/useThrottle.d.ts +1 -1
  245. package/build/esm/hooks/useThrottle.js +5 -10
  246. package/build/esm/hooks/useThrottle.js.map +1 -1
  247. package/build/esm/index.d.ts +15 -15
  248. package/build/esm/index.js +4 -2
  249. package/build/esm/index.js.map +1 -1
  250. package/build/esm/styles.d.js +2 -0
  251. package/build/esm/styles.d.js.map +1 -0
  252. package/build/esm/utils/assign-ref.d.ts +3 -3
  253. package/build/esm/utils/assign-ref.js +3 -5
  254. package/build/esm/utils/assign-ref.js.map +1 -1
  255. package/build/esm/utils/can-use-dom.d.ts +1 -1
  256. package/build/esm/utils/can-use-dom.js.map +1 -1
  257. package/build/esm/utils/clamp.d.ts +1 -1
  258. package/build/esm/utils/clamp.js.map +1 -1
  259. package/build/esm/utils/context.d.ts +7 -7
  260. package/build/esm/utils/context.js +13 -20
  261. package/build/esm/utils/context.js.map +1 -1
  262. package/build/esm/utils/create-subscription.d.ts +4 -4
  263. package/build/esm/utils/create-subscription.js +5 -10
  264. package/build/esm/utils/create-subscription.js.map +1 -1
  265. package/build/esm/utils/get-circular-index.d.ts +1 -1
  266. package/build/esm/utils/get-circular-index.js +0 -1
  267. package/build/esm/utils/get-circular-index.js.map +1 -1
  268. package/build/esm/utils/index.d.ts +10 -10
  269. package/build/esm/utils/index.js.map +1 -1
  270. package/build/esm/utils/is-right-click.d.ts +6 -6
  271. package/build/esm/utils/is-right-click.js +4 -4
  272. package/build/esm/utils/is-right-click.js.map +1 -1
  273. package/build/esm/utils/owner-document.d.ts +7 -7
  274. package/build/esm/utils/owner-document.js +6 -6
  275. package/build/esm/utils/owner-document.js.map +1 -1
  276. package/build/esm/utils/polymorphic.d.ts +39 -39
  277. package/build/esm/utils/polymorphic.js.map +1 -1
  278. package/build/esm/utils/rubber-band-clamp.d.ts +2 -2
  279. package/build/esm/utils/rubber-band-clamp.js +2 -5
  280. package/build/esm/utils/rubber-band-clamp.js.map +1 -1
  281. package/build/esm/utils/use-stable-callback.d.ts +16 -16
  282. package/build/esm/utils/use-stable-callback.js +24 -26
  283. package/build/esm/utils/use-stable-callback.js.map +1 -1
  284. package/build/esm/utils/wrap-event.d.ts +3 -3
  285. package/build/esm/utils/wrap-event.js +2 -5
  286. package/build/esm/utils/wrap-event.js.map +1 -1
  287. package/build/tsconfig-build.tsbuildinfo +1 -1
  288. package/package.json +7 -11
  289. package/src/Accordion/Accordion.story.tsx +74 -74
  290. package/src/Accordion/Accordion.tsx +59 -59
  291. package/src/Accordion/AccordionBody.tsx +52 -52
  292. package/src/Accordion/AccordionHeader.tsx +166 -167
  293. package/src/Accordion/AccordionItem.tsx +50 -50
  294. package/src/Accordion/context.ts +37 -37
  295. package/src/Accordion/index.ts +4 -4
  296. package/src/Accordion/scopeQuery.ts +7 -7
  297. package/src/Accordion/styles.css +21 -21
  298. package/src/CheckBox/CheckBox.tsx +41 -41
  299. package/src/CheckBox/index.ts +1 -1
  300. package/src/ComboBox/ComboBox.story.tsx +120 -120
  301. package/src/ComboBox/Combobox.tsx +148 -148
  302. package/src/ComboBox/ComboboxButton.tsx +61 -61
  303. package/src/ComboBox/ComboboxInput.tsx +187 -187
  304. package/src/ComboBox/ComboboxLabel.tsx +33 -33
  305. package/src/ComboBox/ComboboxList.tsx +47 -47
  306. package/src/ComboBox/ComboboxOption.tsx +110 -111
  307. package/src/ComboBox/ComboboxPopover.tsx +64 -64
  308. package/src/ComboBox/cities.ts +23194 -23194
  309. package/src/ComboBox/context.ts +35 -35
  310. package/src/ComboBox/hooks.tsx +448 -451
  311. package/src/ComboBox/index.ts +8 -8
  312. package/src/ComboBox/makeHash.ts +19 -19
  313. package/src/ComboBox/scopeQuery.ts +6 -6
  314. package/src/ComboBox/styles.css +32 -32
  315. package/src/FocusLock/FocusLock.tsx +66 -66
  316. package/src/FocusLock/index.ts +1 -1
  317. package/src/FocusLock/tabUtils.ts +40 -40
  318. package/src/FocusLock/useFocusLock.ts +55 -56
  319. package/src/List/List.story.tsx +18 -18
  320. package/src/List/List.tsx +17 -17
  321. package/src/List/ListItem.tsx +23 -23
  322. package/src/List/context.ts +19 -19
  323. package/src/List/index.ts +2 -2
  324. package/src/Menu/ContextMenu.story.tsx +73 -73
  325. package/src/Menu/ContextMenuTrigger.tsx +76 -76
  326. package/src/Menu/Menu.story.tsx +160 -160
  327. package/src/Menu/Menu.tsx +82 -83
  328. package/src/Menu/MenuButton.tsx +83 -83
  329. package/src/Menu/MenuComplex.story.tsx +58 -58
  330. package/src/Menu/MenuItem.tsx +87 -88
  331. package/src/Menu/MenuList.tsx +254 -254
  332. package/src/Menu/MenuPopover.tsx +35 -35
  333. package/src/Menu/context.ts +44 -44
  334. package/src/Menu/fixtures/countryList.ts +198 -198
  335. package/src/Menu/index.ts +6 -6
  336. package/src/Menu/scope.ts +7 -7
  337. package/src/Menu/styles.css +42 -42
  338. package/src/Modal/Modal.story.tsx +262 -258
  339. package/src/Modal/Modal.tsx +48 -48
  340. package/src/Modal/ModalBackdrop.tsx +78 -78
  341. package/src/Modal/NavDrawer.story.tsx +161 -158
  342. package/src/Modal/index.ts +2 -2
  343. package/src/Modal/styles.css +46 -46
  344. package/src/Popper/Popper.story.tsx +279 -263
  345. package/src/Popper/Popper.tsx +1 -1
  346. package/src/Popper/PopperArrow.tsx +35 -35
  347. package/src/Popper/context.ts +10 -10
  348. package/src/Popper/index.ts +3 -3
  349. package/src/Popper/styles.css +60 -60
  350. package/src/RadioButton/RadioButton.story.tsx +78 -77
  351. package/src/RadioButton/RadioButton.tsx +55 -55
  352. package/src/RadioButton/RadioGroup.tsx +60 -60
  353. package/src/RadioButton/context.ts +17 -17
  354. package/src/RadioButton/index.ts +2 -2
  355. package/src/SkipNav/SkipNav.tsx +16 -16
  356. package/src/SkipNav/index.tsx +1 -1
  357. package/src/Slider/Slider.story.tsx +45 -45
  358. package/src/Slider/Slider.tsx +1115 -1120
  359. package/src/Slider/index.ts +1 -1
  360. package/src/Slider/styles.css +131 -131
  361. package/src/Spinner/Spinner.story.tsx +31 -31
  362. package/src/Spinner/Spinner.tsx +117 -117
  363. package/src/Spinner/SpinnerButton.tsx +54 -54
  364. package/src/Spinner/context.ts +20 -20
  365. package/src/Spinner/index.ts +2 -2
  366. package/src/Spinner/styles.css +23 -23
  367. package/src/Tabs/Tab.story.tsx +80 -80
  368. package/src/Tabs/Tab.tsx +136 -136
  369. package/src/Tabs/TabList.tsx +71 -71
  370. package/src/Tabs/TabPanel.tsx +53 -53
  371. package/src/Tabs/TabPanels.tsx +30 -30
  372. package/src/Tabs/Tabs.tsx +46 -46
  373. package/src/Tabs/context.ts +30 -30
  374. package/src/Tabs/index.tsx +5 -5
  375. package/src/Tabs/scopeQuery.ts +6 -6
  376. package/src/Tooltip/Tooltip.story.tsx +61 -61
  377. package/src/Tooltip/Tooltip.tsx +53 -50
  378. package/src/Tooltip/index.ts +1 -1
  379. package/src/Tooltip/stateMachine.ts +192 -192
  380. package/src/Tooltip/styles.css +17 -17
  381. package/src/Tooltip/useTooltip.ts +136 -136
  382. package/src/hooks/index.ts +13 -13
  383. package/src/hooks/useAutoFocus.ts +22 -22
  384. package/src/hooks/useChildrenCounter.ts +51 -51
  385. package/src/hooks/useControlledState.ts +1 -6
  386. package/src/hooks/useFocusReturn.ts +43 -43
  387. package/src/hooks/useFocusState.ts +30 -30
  388. package/src/hooks/useGestureHandlers.ts +282 -286
  389. package/src/hooks/useMeasure.ts +33 -33
  390. package/src/hooks/useOnClickOutside.ts +32 -32
  391. package/src/hooks/useOnKeyDown.ts +19 -19
  392. package/src/hooks/useReducerMachine.ts +60 -60
  393. package/src/hooks/useRemoveBodyScroll.ts +38 -39
  394. package/src/hooks/useScope.ts +52 -52
  395. package/src/hooks/useThrottle.ts +19 -19
  396. package/src/index.ts +20 -20
  397. package/src/styles.d.ts +1 -0
  398. package/src/utils/assign-ref.ts +27 -27
  399. package/src/utils/can-use-dom.ts +7 -7
  400. package/src/utils/clamp.ts +3 -3
  401. package/src/utils/context.tsx +48 -48
  402. package/src/utils/create-subscription.ts +16 -16
  403. package/src/utils/get-circular-index.ts +7 -7
  404. package/src/utils/index.ts +10 -10
  405. package/src/utils/is-right-click.ts +14 -14
  406. package/src/utils/owner-document.ts +13 -13
  407. package/src/utils/polymorphic.ts +82 -78
  408. package/src/utils/rubber-band-clamp.ts +25 -25
  409. package/src/utils/use-stable-callback.ts +57 -58
  410. package/src/utils/wrap-event.ts +22 -22
@@ -1,117 +1,114 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"];
4
1
  import { forwardRef, useEffect, useRef } from 'react';
5
2
  import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
6
3
  import { assignMultipleRefs, wrapEvent } from '../utils';
7
4
  import { useComboBoxContext } from './context';
8
5
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
10
- var _ref$as = _ref.as,
11
- Comp = _ref$as === void 0 ? 'input' : _ref$as,
12
- innerAs = _ref.innerAs,
13
- _ref$selectOnClick = _ref.selectOnClick,
14
- selectOnClick = _ref$selectOnClick === void 0 ? false : _ref$selectOnClick,
15
- _ref$autocomplete = _ref.autocomplete,
16
- autocomplete = _ref$autocomplete === void 0 ? true : _ref$autocomplete,
17
- _ref$clearOnEscape = _ref.clearOnEscape,
18
- clearOnEscape = _ref$clearOnEscape === void 0 ? false : _ref$clearOnEscape,
19
- onClick = _ref.onClick,
20
- onChange = _ref.onChange,
21
- onKeyDown = _ref.onKeyDown,
22
- onBlur = _ref.onBlur,
23
- onFocus = _ref.onFocus,
24
- preferredId = _ref.id,
25
- _ref$defaultValue = _ref.defaultValue,
26
- defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
27
- controlledValue = _ref.value,
28
- props = _objectWithoutProperties(_ref, _excluded);
6
+ export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
7
+ let {
8
+ as: Comp = 'input',
9
+ innerAs,
10
+ selectOnClick = false,
11
+ autocomplete = true,
12
+ clearOnEscape = false,
13
+ // wrapped events
14
+ onClick,
15
+ onChange,
16
+ onKeyDown,
17
+ onBlur,
18
+ onFocus,
19
+ id: preferredId,
20
+ defaultValue = '',
21
+ // might be controlled
22
+ value: controlledValue,
23
+ ...props
24
+ } = _ref;
25
+ const {
26
+ data: {
27
+ navigationItem,
28
+ text,
29
+ lastActionType
30
+ },
31
+ inputRef,
32
+ state,
33
+ transition,
34
+ listboxIdRef,
35
+ autocompletePropRef,
36
+ clearOnEscapeRef,
37
+ openOnFocus,
38
+ optionsRef,
39
+ labelIdRef
40
+ } = useComboBoxContext();
29
41
 
30
- var _useComboBoxContext = useComboBoxContext(),
31
- _useComboBoxContext$d = _useComboBoxContext.data,
32
- navigationItem = _useComboBoxContext$d.navigationItem,
33
- text = _useComboBoxContext$d.text,
34
- lastActionType = _useComboBoxContext$d.lastActionType,
35
- inputRef = _useComboBoxContext.inputRef,
36
- state = _useComboBoxContext.state,
37
- transition = _useComboBoxContext.transition,
38
- listboxIdRef = _useComboBoxContext.listboxIdRef,
39
- autocompletePropRef = _useComboBoxContext.autocompletePropRef,
40
- clearOnEscapeRef = _useComboBoxContext.clearOnEscapeRef,
41
- openOnFocus = _useComboBoxContext.openOnFocus,
42
- optionsRef = _useComboBoxContext.optionsRef,
43
- labelIdRef = _useComboBoxContext.labelIdRef; // Keep focus on the input component
42
+ // Keep focus on the input component
43
+ useFocusManagement(lastActionType, inputRef);
44
44
 
45
+ // Keep using the defaultValue until the user started interacting
46
+ const hasStartedInteracting = useRef(false);
45
47
 
46
- useFocusManagement(lastActionType, inputRef); // Keep using the defaultValue until the user started interacting
47
-
48
- var hasStartedInteracting = useRef(false); // Because we close the List on blur, we need to track if the blur is
48
+ // Because we close the List on blur, we need to track if the blur is
49
49
  // caused by clicking inside the list, and if so, don't close the List.
50
+ const selectOnClickRef = useRef(false);
51
+ const handleBlur = useBlur();
50
52
 
51
- var selectOnClickRef = useRef(false);
52
- var handleBlur = useBlur(); // Update ref props
53
-
53
+ // Update ref props
54
54
  autocompletePropRef.current = autocomplete;
55
55
  clearOnEscapeRef.current = clearOnEscape;
56
- listboxIdRef.current = preferredId || listboxIdRef.current; // [*]... and when controlled, we don't trigger handleValueChange as the user
56
+ listboxIdRef.current = preferredId || listboxIdRef.current;
57
+
58
+ // [*]... and when controlled, we don't trigger handleValueChange as the user
57
59
  // types, instead the developer controls it with the normal input onChange
58
60
  // prop
59
-
60
- var handleChange = function handleChange(e) {
61
+ const handleChange = e => {
61
62
  // After the user started typing, lets forget the defaultValue
62
63
  hasStartedInteracting.current = true;
63
- var text = e.target.value;
64
-
64
+ const text = e.target.value;
65
65
  if (text.trim() === '') {
66
66
  transition(CLEAR);
67
67
  } else {
68
68
  transition(CHANGE, {
69
- text: text
69
+ text
70
70
  });
71
71
  }
72
72
  };
73
-
74
- var handleKeyDown = useKeyDown();
75
-
76
- var handleFocus = function handleFocus() {
73
+ const handleKeyDown = useKeyDown();
74
+ const handleFocus = () => {
77
75
  if (selectOnClick) {
78
76
  selectOnClickRef.current = true;
79
- } // If we select an option with click, useFocusManagement will focus the
77
+ }
78
+ // If we select an option with click, useFocusManagement will focus the
80
79
  // input, in those cases we don't want to cause the menu to open back up,
81
80
  // so we guard behind these states
82
-
83
-
84
81
  if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {
85
82
  transition(FOCUS, {
86
83
  item: navigationItem
87
84
  });
88
85
  }
89
86
  };
90
-
91
- var handleClick = function handleClick() {
87
+ const handleClick = () => {
92
88
  if (selectOnClickRef.current) {
93
89
  selectOnClickRef.current = false;
94
90
  inputRef.current && inputRef.current.select();
95
91
  }
96
92
  };
97
-
98
- var navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
99
- var fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
100
- var inputStrings = // When idle, we don't have a navigationText on ArrowUp/Down
93
+ const navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
94
+ const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
95
+ const inputStrings =
96
+ // When idle, we don't have a navigationText on ArrowUp/Down
101
97
  autocomplete && state === NAVIGATING ? [navigationText, controlledValue, text, fallbackValue] : [controlledValue, text, fallbackValue];
102
- var inputValue = inputStrings.find(function (str) {
103
- return str !== undefined;
104
- }); // If they are controlling the value we still need to do our transitions, so
98
+ const inputValue = inputStrings.find(str => str !== undefined);
99
+
100
+ // If they are controlling the value we still need to do our transitions, so
105
101
  // we have this derived state to emulate onChange of the input as we receive
106
102
  // new `value`s ...[*]
107
-
108
- useEffect(function () {
103
+ useEffect(() => {
109
104
  transition(INIT, {
110
105
  text: inputValue,
111
106
  item: ''
112
- }); // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ });
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
113
109
  }, []);
114
- return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
110
+ return /*#__PURE__*/_jsx(Comp, {
111
+ ...props,
115
112
  as: innerAs,
116
113
  "data-reach-combobox-input": "",
117
114
  ref: assignMultipleRefs(inputRef, forwardedRef),
@@ -126,6 +123,6 @@ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref,
126
123
  "aria-autocomplete": "both",
127
124
  "aria-activedescendant": navigationItem !== '' ? navigationItem : undefined,
128
125
  autoComplete: "off"
129
- }));
126
+ });
130
127
  });
131
128
  //# sourceMappingURL=ComboboxInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","ComboboxInput","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","preferredId","id","defaultValue","controlledValue","value","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\r\n ChangeEvent,\r\n ChangeEventHandler,\r\n ElementType,\r\n FocusEventHandler,\r\n InputHTMLAttributes,\r\n KeyboardEventHandler,\r\n MouseEventHandler,\r\n} from 'react';\r\nimport { forwardRef, useEffect, useRef } from 'react';\r\n\r\nimport {\r\n useBlur,\r\n CLEAR,\r\n CHANGE,\r\n useKeyDown,\r\n SELECT_WITH_CLICK,\r\n FOCUS,\r\n NAVIGATING,\r\n INIT,\r\n useFocusManagement,\r\n} from './hooks';\r\nimport { assignMultipleRefs, wrapEvent } from '../utils';\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxInputProps\r\n extends InputHTMLAttributes<HTMLInputElement> {\r\n // clear on ESC\r\n clearOnEscape?: boolean;\r\n // highlights all the text in the box on click when true\r\n selectOnClick?: boolean;\r\n // updates the value in the input when navigating w/ the keyboard\r\n autocomplete?: boolean;\r\n // initial value for uncontrolled mode\r\n defaultValue?: string;\r\n // value for controlled mode\r\n value?: string;\r\n onClick?: MouseEventHandler<HTMLInputElement>;\r\n onChange?: ChangeEventHandler<HTMLInputElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\r\n onBlur?: FocusEventHandler<HTMLInputElement>;\r\n onFocus?: FocusEventHandler<HTMLInputElement>;\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id?: string;\r\n}\r\n\r\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(\r\n function ComboboxInput(\r\n {\r\n as: Comp = 'input',\r\n innerAs,\r\n selectOnClick = false,\r\n autocomplete = true,\r\n clearOnEscape = false,\r\n\r\n // wrapped events\r\n onClick,\r\n onChange,\r\n onKeyDown,\r\n onBlur,\r\n onFocus,\r\n\r\n id: preferredId,\r\n\r\n defaultValue = '',\r\n\r\n // might be controlled\r\n value: controlledValue,\r\n ...props\r\n },\r\n forwardedRef\r\n ) {\r\n const {\r\n data: { navigationItem, text, lastActionType },\r\n inputRef,\r\n state,\r\n transition,\r\n listboxIdRef,\r\n autocompletePropRef,\r\n clearOnEscapeRef,\r\n openOnFocus,\r\n optionsRef,\r\n labelIdRef,\r\n } = useComboBoxContext();\r\n\r\n // Keep focus on the input component\r\n useFocusManagement(lastActionType, inputRef);\r\n\r\n // Keep using the defaultValue until the user started interacting\r\n const hasStartedInteracting = useRef(false);\r\n\r\n // Because we close the List on blur, we need to track if the blur is\r\n // caused by clicking inside the list, and if so, don't close the List.\r\n const selectOnClickRef = useRef(false);\r\n\r\n const handleBlur = useBlur();\r\n\r\n // Update ref props\r\n autocompletePropRef.current = autocomplete;\r\n clearOnEscapeRef.current = clearOnEscape;\r\n listboxIdRef.current = preferredId || listboxIdRef.current;\r\n\r\n // [*]... and when controlled, we don't trigger handleValueChange as the user\r\n // types, instead the developer controls it with the normal input onChange\r\n // prop\r\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\r\n // After the user started typing, lets forget the defaultValue\r\n hasStartedInteracting.current = true;\r\n\r\n const text = e.target.value;\r\n if (text.trim() === '') {\r\n transition(CLEAR);\r\n } else {\r\n transition(CHANGE, { text });\r\n }\r\n };\r\n\r\n const handleKeyDown = useKeyDown();\r\n\r\n const handleFocus = () => {\r\n if (selectOnClick) {\r\n selectOnClickRef.current = true;\r\n }\r\n // If we select an option with click, useFocusManagement will focus the\r\n // input, in those cases we don't want to cause the menu to open back up,\r\n // so we guard behind these states\r\n if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {\r\n transition(FOCUS, {\r\n item: navigationItem,\r\n });\r\n }\r\n };\r\n\r\n const handleClick = () => {\r\n if (selectOnClickRef.current) {\r\n selectOnClickRef.current = false;\r\n inputRef.current && inputRef.current.select();\r\n }\r\n };\r\n\r\n const navigationText =\r\n navigationItem !== ''\r\n ? optionsRef.current[navigationItem].text\r\n : undefined;\r\n\r\n const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;\r\n\r\n const inputStrings =\r\n // When idle, we don't have a navigationText on ArrowUp/Down\r\n autocomplete && state === NAVIGATING\r\n ? [navigationText, controlledValue, text, fallbackValue]\r\n : [controlledValue, text, fallbackValue];\r\n\r\n const inputValue = inputStrings.find((str) => str !== undefined);\r\n\r\n // If they are controlling the value we still need to do our transitions, so\r\n // we have this derived state to emulate onChange of the input as we receive\r\n // new `value`s ...[*]\r\n useEffect(() => {\r\n transition(INIT, { text: inputValue, item: '' });\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n data-reach-combobox-input=\"\"\r\n ref={assignMultipleRefs(inputRef, forwardedRef)}\r\n value={inputValue}\r\n onClick={wrapEvent(onClick, handleClick)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n onFocus={wrapEvent(onFocus, handleFocus)}\r\n onChange={wrapEvent(onChange, handleChange)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n aria-labelledby={labelIdRef.current}\r\n id={listboxIdRef.current}\r\n aria-autocomplete=\"both\"\r\n aria-activedescendant={\r\n navigationItem !== '' ? navigationItem : undefined\r\n }\r\n autoComplete=\"off\"\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AASA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,iBALF,EAMEC,KANF,EAOEC,UAPF,EAQEC,IARF,EASEC,k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AAS,EAAEtC,SAAS,CAACY,SAAD,EAAY8B,aAAZ,CAVtB;IAWE,mBAAiBT,UAAU,CAACI,OAX9B;IAYE,EAAE,EAAET,YAAY,CAACS,OAZnB;IAaE,qBAAkB,MAbpB;IAcE,yBACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;IAiBE,YAAY,EAAC;EAjBf,GADF;AAqBD,CA1IoC,CAAhC"}
1
+ {"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","jsx","_jsx","ComboboxInput","_ref","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","id","preferredId","defaultValue","value","controlledValue","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str","ref","autoComplete"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\n ChangeEvent,\n ChangeEventHandler,\n ElementType,\n FocusEventHandler,\n InputHTMLAttributes,\n KeyboardEventHandler,\n MouseEventHandler,\n} from 'react';\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport {\n useBlur,\n CLEAR,\n CHANGE,\n useKeyDown,\n SELECT_WITH_CLICK,\n FOCUS,\n NAVIGATING,\n INIT,\n useFocusManagement,\n} from './hooks';\nimport { assignMultipleRefs, wrapEvent } from '../utils';\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxInputProps\n extends InputHTMLAttributes<HTMLInputElement> {\n // clear on ESC\n clearOnEscape?: boolean;\n // highlights all the text in the box on click when true\n selectOnClick?: boolean;\n // updates the value in the input when navigating w/ the keyboard\n autocomplete?: boolean;\n // initial value for uncontrolled mode\n defaultValue?: string;\n // value for controlled mode\n value?: string;\n onClick?: MouseEventHandler<HTMLInputElement>;\n onChange?: ChangeEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id?: string;\n}\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(\n function ComboboxInput(\n {\n as: Comp = 'input',\n innerAs,\n selectOnClick = false,\n autocomplete = true,\n clearOnEscape = false,\n\n // wrapped events\n onClick,\n onChange,\n onKeyDown,\n onBlur,\n onFocus,\n\n id: preferredId,\n\n defaultValue = '',\n\n // might be controlled\n value: controlledValue,\n ...props\n },\n forwardedRef\n ) {\n const {\n data: { navigationItem, text, lastActionType },\n inputRef,\n state,\n transition,\n listboxIdRef,\n autocompletePropRef,\n clearOnEscapeRef,\n openOnFocus,\n optionsRef,\n labelIdRef,\n } = useComboBoxContext();\n\n // Keep focus on the input component\n useFocusManagement(lastActionType, inputRef);\n\n // Keep using the defaultValue until the user started interacting\n const hasStartedInteracting = useRef(false);\n\n // Because we close the List on blur, we need to track if the blur is\n // caused by clicking inside the list, and if so, don't close the List.\n const selectOnClickRef = useRef(false);\n\n const handleBlur = useBlur();\n\n // Update ref props\n autocompletePropRef.current = autocomplete;\n clearOnEscapeRef.current = clearOnEscape;\n listboxIdRef.current = preferredId || listboxIdRef.current;\n\n // [*]... and when controlled, we don't trigger handleValueChange as the user\n // types, instead the developer controls it with the normal input onChange\n // prop\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n // After the user started typing, lets forget the defaultValue\n hasStartedInteracting.current = true;\n\n const text = e.target.value;\n if (text.trim() === '') {\n transition(CLEAR);\n } else {\n transition(CHANGE, { text });\n }\n };\n\n const handleKeyDown = useKeyDown();\n\n const handleFocus = () => {\n if (selectOnClick) {\n selectOnClickRef.current = true;\n }\n // If we select an option with click, useFocusManagement will focus the\n // input, in those cases we don't want to cause the menu to open back up,\n // so we guard behind these states\n if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {\n transition(FOCUS, {\n item: navigationItem,\n });\n }\n };\n\n const handleClick = () => {\n if (selectOnClickRef.current) {\n selectOnClickRef.current = false;\n inputRef.current && inputRef.current.select();\n }\n };\n\n const navigationText =\n navigationItem !== ''\n ? optionsRef.current[navigationItem].text\n : undefined;\n\n const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;\n\n const inputStrings =\n // When idle, we don't have a navigationText on ArrowUp/Down\n autocomplete && state === NAVIGATING\n ? [navigationText, controlledValue, text, fallbackValue]\n : [controlledValue, text, fallbackValue];\n\n const inputValue = inputStrings.find((str) => str !== undefined);\n\n // If they are controlling the value we still need to do our transitions, so\n // we have this derived state to emulate onChange of the input as we receive\n // new `value`s ...[*]\n useEffect(() => {\n transition(INIT, { text: inputValue, item: '' });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-input=\"\"\n ref={assignMultipleRefs(inputRef, forwardedRef)}\n value={inputValue}\n onClick={wrapEvent(onClick, handleClick)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onChange={wrapEvent(onChange, handleChange)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n aria-labelledby={labelIdRef.current}\n id={listboxIdRef.current}\n aria-autocomplete=\"both\"\n aria-activedescendant={\n navigationItem !== '' ? navigationItem : undefined\n }\n autoComplete=\"off\"\n />\n );\n }\n);\n"],"mappings":"AASA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAErD,SACEC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,iBAAiB,EACjBC,KAAK,EACLC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aAAa,CAAC;EAE5C,MAAME,UAAU,GAAGD,YAAY,CAACE,IAAI,CAAEC,GAAG,IAAKA,GAAG,KAAKL,SAAS,CAAC;;EAEhE;EACA;EACA;EACA/D,SAAS,CAAC,MAAM;IACd0C,UAAU,CAACjC,IAAI,EAAE;MAAE6B,IAAI,EAAE4B,UAAU;MAAEP,IAAI,EAAE;IAAG,CAAC,CAAC;IAChD;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,oBACE5C,IAAA,CAACK,IAAI;IAAA,GACCe,KAAK;IACThB,EAAE,EAAEE,OAAQ;IACZ,6BAA0B,EAAE;IAC5BgD,GAAG,EAAE1D,kBAAkB,CAAC6B,QAAQ,EAAEtB,YAAY,CAAE;IAChDe,KAAK,EAAEiC,UAAW;IAClBzC,OAAO,EAAEb,SAAS,CAACa,OAAO,EAAEmC,WAAW,CAAE;IACzChC,MAAM,EAAEhB,SAAS,CAACgB,MAAM,EAAEuB,UAAU,CAAE;IACtCtB,OAAO,EAAEjB,SAAS,CAACiB,OAAO,EAAE6B,WAAW,CAAE;IACzChC,QAAQ,EAAEd,SAAS,CAACc,QAAQ,EAAE2B,YAAY,CAAE;IAC5C1B,SAAS,EAAEf,SAAS,CAACe,SAAS,EAAE8B,aAAa,CAAE;IAC/C,mBAAiBT,UAAU,CAACI,OAAQ;IACpCtB,EAAE,EAAEa,YAAY,CAACS,OAAQ;IACzB,qBAAkB,MAAM;IACxB,yBACEf,cAAc,KAAK,EAAE,GAAGA,cAAc,GAAG0B,SAC1C;IACDO,YAAY,EAAC;EAAK,CACnB,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import type { ElementType, LabelHTMLAttributes } from 'react';
2
- export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
3
- as?: ElementType<any>;
4
- innerAs?: ElementType<any>;
5
- id?: string;
6
- }
7
- export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
1
+ import type { ElementType, LabelHTMLAttributes } from 'react';
2
+ export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ id?: string;
6
+ }
7
+ export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
@@ -1,27 +1,25 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "innerAs", "id"];
4
1
  import { forwardRef } from 'react';
5
2
  import { useComboBoxContext } from './context';
6
3
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export var ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
8
- var _ref$as = _ref.as,
9
- Comp = _ref$as === void 0 ? 'label' : _ref$as,
10
- innerAs = _ref.innerAs,
11
- preferredId = _ref.id,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
-
14
- var _useComboBoxContext = useComboBoxContext(),
15
- listboxIdRef = _useComboBoxContext.listboxIdRef,
16
- labelIdRef = _useComboBoxContext.labelIdRef;
17
-
4
+ export const ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
5
+ let {
6
+ as: Comp = 'label',
7
+ innerAs,
8
+ id: preferredId,
9
+ ...props
10
+ } = _ref;
11
+ const {
12
+ listboxIdRef,
13
+ labelIdRef
14
+ } = useComboBoxContext();
18
15
  labelIdRef.current = preferredId || labelIdRef.current;
19
- return /*#__PURE__*/_jsx(Comp, _extends({
16
+ return /*#__PURE__*/_jsx(Comp, {
20
17
  as: innerAs,
21
18
  "data-reach-combobox-label": "",
22
19
  htmlFor: listboxIdRef.current,
23
20
  id: labelIdRef.current,
24
- ref: ref
25
- }, props));
21
+ ref: ref,
22
+ ...props
23
+ });
26
24
  });
27
25
  //# sourceMappingURL=ComboboxLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxLabel.js","names":["forwardRef","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","preferredId","id","props","listboxIdRef","labelIdRef","current"],"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"sourcesContent":["import type { ElementType, LabelHTMLAttributes } from 'react';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxLabelProps\r\n extends LabelHTMLAttributes<HTMLLabelElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id?: string;\r\n}\r\n\r\nexport const ComboboxLabel = forwardRef<HTMLLabelElement, ComboboxLabelProps>(\r\n function ComboboxButton(\r\n { as: Comp = 'label', innerAs, id: preferredId, ...props },\r\n ref\r\n ) {\r\n const { listboxIdRef, labelIdRef } = useComboBoxContext();\r\n\r\n labelIdRef.current = preferredId || labelIdRef.current;\r\n\r\n return (\r\n <Comp\r\n as={innerAs}\r\n data-reach-combobox-label=\"\"\r\n htmlFor={listboxIdRef.current}\r\n id={labelIdRef.current}\r\n ref={ref}\r\n {...props}\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;;AASA,OAAO,IAAMC,aAAa,gBAAGF,UAAU,CACrC,SAASG,cAAT,OAEEC,GAFF,EAGE;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,OAEb;EAAA,IAFsBC,OAEtB,QAFsBA,OAEtB;EAAA,IAFmCC,WAEnC,QAF+BC,EAE/B;EAAA,IAFmDC,KAEnD;;EACA,0BAAqCT,kBAAkB,EAAvD;EAAA,IAAQU,YAAR,uBAAQA,YAAR;EAAA,IAAsBC,UAAtB,uBAAsBA,UAAtB;;EAEAA,UAAU,CAACC,OAAX,GAAqBL,WAAW,IAAII,UAAU,CAACC,OAA/C;EAEA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEN,OADN;IAEE,6BAA0B,EAF5B;IAGE,OAAO,EAAEI,YAAY,CAACE,OAHxB;IAIE,EAAE,EAAED,UAAU,CAACC,OAJjB;IAKE,GAAG,EAAET;EALP,GAMMM,KANN,EADF;AAUD,CAnBoC,CAAhC"}
1
+ {"version":3,"file":"ComboboxLabel.js","names":["forwardRef","useComboBoxContext","jsx","_jsx","ComboboxLabel","ComboboxButton","_ref","ref","as","Comp","innerAs","id","preferredId","props","listboxIdRef","labelIdRef","current","htmlFor"],"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"sourcesContent":["import type { ElementType, LabelHTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxLabelProps\n extends LabelHTMLAttributes<HTMLLabelElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id?: string;\n}\n\nexport const ComboboxLabel = forwardRef<HTMLLabelElement, ComboboxLabelProps>(\n function ComboboxButton(\n { as: Comp = 'label', innerAs, id: preferredId, ...props },\n ref\n ) {\n const { listboxIdRef, labelIdRef } = useComboBoxContext();\n\n labelIdRef.current = preferredId || labelIdRef.current;\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-label=\"\"\n htmlFor={listboxIdRef.current}\n id={labelIdRef.current}\n ref={ref}\n {...props}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/C,OAAO,MAAMC,aAAa,gBAAGJ,UAAU,CACrC,SAASK,cAAcA,CAAAC,IAAA,EAErBC,GAAG,EACH;EAAA,IAFA;IAAEC,EAAE,EAAEC,IAAI,GAAG,OAAO;IAAEC,OAAO;IAAEC,EAAE,EAAEC,WAAW;IAAE,GAAGC;EAAM,CAAC,GAAAP,IAAA;EAG1D,MAAM;IAAEQ,YAAY;IAAEC;EAAW,CAAC,GAAGd,kBAAkB,CAAC,CAAC;EAEzDc,UAAU,CAACC,OAAO,GAAGJ,WAAW,IAAIG,UAAU,CAACC,OAAO;EAEtD,oBACEb,IAAA,CAACM,IAAI;IACHD,EAAE,EAAEE,OAAQ;IACZ,6BAA0B,EAAE;IAC5BO,OAAO,EAAEH,YAAY,CAACE,OAAQ;IAC9BL,EAAE,EAAEI,UAAU,CAACC,OAAQ;IACvBT,GAAG,EAAEA,GAAI;IAAA,GACLM;EAAK,CACV,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import type { HTMLAttributes, ElementType, ReactNode } from 'react';
2
- export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
3
- as?: ElementType<any>;
4
- innerAs?: ElementType<any>;
5
- persistSelection?: boolean;
6
- children?: ReactNode;
7
- }
8
- export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
1
+ import type { HTMLAttributes, ElementType, ReactNode } from 'react';
2
+ export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ persistSelection?: boolean;
6
+ children?: ReactNode;
7
+ }
8
+ export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
@@ -1,35 +1,34 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["persistSelection", "as", "innerAs"];
4
1
  import { forwardRef, useRef, useEffect } from 'react';
5
2
  import { useComboBoxContext } from './context';
6
3
  import { getScope } from '../hooks';
7
4
  import { assignMultipleRefs } from '../utils';
8
5
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export var ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, ref) {
10
- var _ref$persistSelection = _ref.persistSelection,
11
- persistSelection = _ref$persistSelection === void 0 ? false : _ref$persistSelection,
12
- _ref$as = _ref.as,
13
- Comp = _ref$as === void 0 ? 'ul' : _ref$as,
14
- innerAs = _ref.innerAs,
15
- props = _objectWithoutProperties(_ref, _excluded);
16
-
17
- var _useComboBoxContext = useComboBoxContext(),
18
- persistSelectionRef = _useComboBoxContext.persistSelectionRef,
19
- labelIdRef = _useComboBoxContext.labelIdRef,
20
- listScope = _useComboBoxContext.listScope;
21
-
22
- var listRef = useRef();
23
- useEffect(function () {
6
+ export const ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, ref) {
7
+ let {
8
+ // when true, and the list opens again, the option with a matching value will be
9
+ // automatically highleted.
10
+ persistSelection = false,
11
+ as: Comp = 'ul',
12
+ innerAs,
13
+ ...props
14
+ } = _ref;
15
+ const {
16
+ persistSelectionRef,
17
+ labelIdRef,
18
+ listScope
19
+ } = useComboBoxContext();
20
+ const listRef = useRef(null);
21
+ useEffect(() => {
24
22
  listScope.current = getScope(listRef);
25
23
  }, [listScope]);
26
24
  persistSelectionRef.current = persistSelection;
27
- return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
25
+ return /*#__PURE__*/_jsx(Comp, {
26
+ ...props,
28
27
  as: innerAs,
29
28
  ref: assignMultipleRefs(ref, listRef),
30
29
  "data-reach-combobox-list": "",
31
30
  role: "listbox",
32
31
  "aria-labelledby": labelIdRef.current
33
- }));
32
+ });
34
33
  });
35
34
  //# sourceMappingURL=ComboboxList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxList.js","names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"sources":["../../../src/ComboBox/ComboboxList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\r\nimport { forwardRef, useRef, useEffect } from 'react';\r\n\r\nimport { useComboBoxContext } from './context';\r\nimport { getScope } from '../hooks';\r\nimport { assignMultipleRefs } from '../utils';\r\n\r\nexport interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n persistSelection?: boolean;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const ComboboxList = forwardRef<HTMLUListElement, ComboboxListProps>(\r\n function ComboboxList(\r\n {\r\n // when true, and the list opens again, the option with a matching value will be\r\n // automatically highleted.\r\n persistSelection = false,\r\n as: Comp = 'ul',\r\n innerAs,\r\n ...props\r\n },\r\n ref\r\n ) {\r\n const { persistSelectionRef, labelIdRef, listScope } = useComboBoxContext();\r\n\r\n const listRef = useRef<HTMLUListElement>();\r\n useEffect(() => {\r\n listScope.current = getScope(listRef);\r\n }, [listScope]);\r\n\r\n persistSelectionRef.current = persistSelection;\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n ref={assignMultipleRefs(ref, listRef)}\r\n data-reach-combobox-list=\"\"\r\n role=\"listbox\"\r\n aria-labelledby={labelIdRef.current}\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,SAA7B,QAA8C,OAA9C;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AASA,OAAO,IAAMC,YAAY,gBAAGN,UAAU,CACpC,SAASM,YAAT,OASEC,GATF,EAUE;EAAA,iCANEC,gBAMF;EAAA,IANEA,gBAMF,sCANqB,KAMrB;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,IAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,KAGL;;EACA,0BAAuDT,kBAAkB,EAAzE;EAAA,IAAQU,mBAAR,uBAAQA,mBAAR;EAAA,IAA6BC,UAA7B,uBAA6BA,UAA7B;EAAA,IAAyCC,SAAzC,uBAAyCA,SAAzC;;EAEA,IAAMC,OAAO,GAAGf,MAAM,EAAtB;EACAC,SAAS,CAAC,YAAM;IACda,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;EACD,CAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;EAIAF,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;EAEA,oBACE,KAAC,IAAD,wBACMI,KADN;IAEE,EAAE,EAAED,OAFN;IAGE,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;IAIE,4BAAyB,EAJ3B;IAKE,IAAI,EAAC,SALP;IAME,mBAAiBF,UAAU,CAACG;EAN9B,GADF;AAUD,CA/BmC,CAA/B"}
1
+ {"version":3,"file":"ComboboxList.js","names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","jsx","_jsx","ComboboxList","_ref","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current","role"],"sources":["../../../src/ComboBox/ComboboxList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\nimport { forwardRef, useRef, useEffect } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { getScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n persistSelection?: boolean;\n children?: ReactNode;\n}\n\nexport const ComboboxList = forwardRef<HTMLUListElement, ComboboxListProps>(\n function ComboboxList(\n {\n // when true, and the list opens again, the option with a matching value will be\n // automatically highleted.\n persistSelection = false,\n as: Comp = 'ul',\n innerAs,\n ...props\n },\n ref\n ) {\n const { persistSelectionRef, labelIdRef, listScope } = useComboBoxContext();\n\n const listRef = useRef<HTMLUListElement | null>(null);\n useEffect(() => {\n listScope.current = getScope(listRef);\n }, [listScope]);\n\n persistSelectionRef.current = persistSelection;\n\n return (\n <Comp\n {...props}\n as={innerAs}\n ref={assignMultipleRefs(ref, listRef)}\n data-reach-combobox-list=\"\"\n role=\"listbox\"\n aria-labelledby={labelIdRef.current}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAErD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,QAAQ,QAAQ,UAAU;AACnC,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS9C,OAAO,MAAMC,YAAY,gBAAGR,UAAU,CACpC,SAASQ,YAAYA,CAAAC,IAAA,EASnBC,GAAG,EACH;EAAA,IATA;IACE;IACA;IACAC,gBAAgB,GAAG,KAAK;IACxBC,EAAE,EAAEC,IAAI,GAAG,IAAI;IACfC,OAAO;IACP,GAAGC;EACL,CAAC,GAAAN,IAAA;EAGD,MAAM;IAAEO,mBAAmB;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGf,kBAAkB,CAAC,CAAC;EAE3E,MAAMgB,OAAO,GAAGlB,MAAM,CAA0B,IAAI,CAAC;EACrDC,SAAS,CAAC,MAAM;IACdgB,SAAS,CAACE,OAAO,GAAGhB,QAAQ,CAACe,OAAO,CAAC;EACvC,CAAC,EAAE,CAACD,SAAS,CAAC,CAAC;EAEfF,mBAAmB,CAACI,OAAO,GAAGT,gBAAgB;EAE9C,oBACEJ,IAAA,CAACM,IAAI;IAAA,GACCE,KAAK;IACTH,EAAE,EAAEE,OAAQ;IACZJ,GAAG,EAAEL,kBAAkB,CAACK,GAAG,EAAES,OAAO,CAAE;IACtC,4BAAyB,EAAE;IAC3BE,IAAI,EAAC,SAAS;IACd,mBAAiBJ,UAAU,CAACG;EAAQ,CACrC,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
- import type { ElementType, LiHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
2
- export interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {
3
- as?: ElementType<any>;
4
- innerAs?: ElementType<any>;
5
- id: string;
6
- value: any;
7
- text?: string;
8
- onClick?: MouseEventHandler<HTMLLIElement>;
9
- children?: ReactNode;
10
- }
11
- export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
1
+ import type { ElementType, LiHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
2
+ export interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ id: string;
6
+ value: any;
7
+ text?: string;
8
+ onClick?: MouseEventHandler<HTMLLIElement>;
9
+ children?: ReactNode;
10
+ }
11
+ export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,36 +1,32 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "id", "value", "text", "onClick", "as", "innerAs"];
4
-
5
- /* eslint-disable @typescript-eslint/no-use-before-define */
6
1
  import { forwardRef, useEffect, useRef } from 'react';
7
2
  import { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';
8
3
  import { wrapEvent } from '../utils/wrap-event';
9
4
  import { useComboBoxContext } from './context';
10
5
  import { makeHash } from './makeHash';
11
6
  import { jsx as _jsx } from "react/jsx-runtime";
12
- export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref, ref) {
13
- var children = _ref.children,
14
- idProp = _ref.id,
15
- valueProp = _ref.value,
16
- textProp = _ref.text,
17
- onClick = _ref.onClick,
18
- _ref$as = _ref.as,
19
- Comp = _ref$as === void 0 ? 'li' : _ref$as,
20
- innerAs = _ref.innerAs,
21
- props = _objectWithoutProperties(_ref, _excluded);
22
-
23
- var _useComboBoxContext = useComboBoxContext(),
24
- onSelect = _useComboBoxContext.onSelect,
25
- navigationItem = _useComboBoxContext.data.navigationItem,
26
- transition = _useComboBoxContext.transition,
27
- optionsRef = _useComboBoxContext.optionsRef;
28
-
29
- var transitionCleanupRef = useRef(transition);
30
- var isActiveRef = useRef(false);
31
- var value = valueProp;
32
- var text = textProp ? textProp : '';
33
-
7
+ export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref, ref) {
8
+ let {
9
+ children,
10
+ id: idProp,
11
+ value: valueProp,
12
+ text: textProp,
13
+ onClick,
14
+ as: Comp = 'li',
15
+ innerAs,
16
+ ...props
17
+ } = _ref;
18
+ const {
19
+ onSelect,
20
+ data: {
21
+ navigationItem
22
+ },
23
+ transition,
24
+ optionsRef
25
+ } = useComboBoxContext();
26
+ const transitionCleanupRef = useRef(transition);
27
+ const isActiveRef = useRef(false);
28
+ const value = valueProp;
29
+ let text = textProp ? textProp : '';
34
30
  if (text.length === 0) {
35
31
  if (typeof valueProp === 'string' && valueProp.length > 0) {
36
32
  text = valueProp;
@@ -38,25 +34,25 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
38
34
  throw new Error('Missing text for <ComboboxOption />');
39
35
  }
40
36
  }
41
-
42
- var id = String(makeHash(idProp));
43
- useEffect(function () {
44
- var opts = optionsRef.current;
37
+ const id = String(makeHash(idProp));
38
+ useEffect(() => {
39
+ const opts = optionsRef.current;
45
40
  opts[id] = {
46
- value: value,
47
- text: text
41
+ value,
42
+ text
48
43
  };
49
- return function () {
44
+ return () => {
50
45
  delete opts[id];
51
46
  };
52
- }, [optionsRef, id, text, value]); // Keep updating this ref with the current
47
+ }, [optionsRef, id, text, value]);
48
+
49
+ // Keep updating this ref with the current
53
50
  // function pointer for transition, so it can
54
51
  // be used by the unmount effect below.
55
-
56
52
  transitionCleanupRef.current = transition;
57
53
  isActiveRef.current = navigationItem === id;
58
- useEffect(function () {
59
- return function () {
54
+ useEffect(() => {
55
+ return () => {
60
56
  if (isActiveRef.current === true) {
61
57
  // clean up selections if this option is getting
62
58
  // unmounted and it was the currently selected item
@@ -64,29 +60,29 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
64
60
  }
65
61
  };
66
62
  }, []);
67
-
68
- var handleClick = function handleClick() {
63
+ const handleClick = () => {
69
64
  onSelect && onSelect(text, id, value);
70
65
  transition(SELECT_WITH_CLICK, {
71
- text: text,
66
+ text,
72
67
  item: id
73
68
  });
74
69
  };
75
-
76
- return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
70
+ return /*#__PURE__*/_jsx(Comp, {
71
+ ...props,
77
72
  as: innerAs,
78
73
  "data-reach-combobox-option": "",
79
74
  ref: ref,
80
75
  id: id,
81
76
  role: "option",
82
77
  "aria-selected": isActiveRef.current,
83
- "data-highlighted": isActiveRef.current ? '' : undefined // without this the menu will close from `onBlur`, but with it the
78
+ "data-highlighted": isActiveRef.current ? '' : undefined
79
+ // without this the menu will close from `onBlur`, but with it the
84
80
  // element can be `document.activeElement` and then our focus checks in
85
81
  // onBlur will work as intended
86
82
  ,
87
83
  tabIndex: "-1",
88
84
  onClick: wrapEvent(onClick, handleClick),
89
85
  children: children || text
90
- }));
86
+ });
91
87
  });
92
88
  //# sourceMappingURL=ComboboxOption.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxOption.js","names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","ComboboxOption","ref","children","idProp","id","valueProp","value","textProp","text","onClick","as","Comp","innerAs","props","onSelect","navigationItem","data","transition","optionsRef","transitionCleanupRef","isActiveRef","length","Error","String","opts","current","handleClick","item","undefined"],"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport type {\r\n ElementType,\r\n LiHTMLAttributes,\r\n MouseEventHandler,\r\n ReactNode,\r\n} from 'react';\r\nimport { forwardRef, useEffect, useRef } from 'react';\r\n\r\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\r\nimport { wrapEvent } from '../utils/wrap-event';\r\nimport { useComboBoxContext } from './context';\r\nimport { makeHash } from './makeHash';\r\n\r\nexport interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id: string;\r\n value: any;\r\n text?: string;\r\n onClick?: MouseEventHandler<HTMLLIElement>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const ComboboxOption = forwardRef<HTMLLIElement, ComboboxOptionProps>(\r\n function ComboboxOption(\r\n {\r\n children,\r\n id: idProp,\r\n value: valueProp,\r\n text: textProp,\r\n onClick,\r\n as: Comp = 'li',\r\n innerAs,\r\n ...props\r\n },\r\n ref\r\n ) {\r\n const {\r\n onSelect,\r\n data: { navigationItem },\r\n transition,\r\n optionsRef,\r\n } = useComboBoxContext();\r\n const transitionCleanupRef = useRef(transition);\r\n const isActiveRef = useRef(false);\r\n\r\n const value: any = valueProp;\r\n let text: string = textProp ? textProp : '';\r\n\r\n if (text.length === 0) {\r\n if (typeof valueProp === 'string' && valueProp.length > 0) {\r\n text = valueProp;\r\n } else {\r\n throw new Error('Missing text for <ComboboxOption />');\r\n }\r\n }\r\n\r\n const id = String(makeHash(idProp));\r\n\r\n useEffect(() => {\r\n const opts = optionsRef.current;\r\n opts[id] = { value, text };\r\n\r\n return () => {\r\n delete opts[id];\r\n };\r\n }, [optionsRef, id, text, value]);\r\n\r\n // Keep updating this ref with the current\r\n // function pointer for transition, so it can\r\n // be used by the unmount effect below.\r\n transitionCleanupRef.current = transition;\r\n isActiveRef.current = navigationItem === id;\r\n\r\n useEffect(() => {\r\n return () => {\r\n if (isActiveRef.current === true) {\r\n // clean up selections if this option is getting\r\n // unmounted and it was the currently selected item\r\n transitionCleanupRef.current(CLEAR_SELECTION);\r\n }\r\n };\r\n }, []);\r\n\r\n const handleClick = () => {\r\n onSelect && onSelect(text, id, value);\r\n transition(SELECT_WITH_CLICK, { text, item: id });\r\n };\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n data-reach-combobox-option=\"\"\r\n ref={ref}\r\n id={id}\r\n role=\"option\"\r\n aria-selected={isActiveRef.current}\r\n data-highlighted={isActiveRef.current ? '' : undefined}\r\n // without this the menu will close from `onBlur`, but with it the\r\n // element can be `document.activeElement` and then our focus checks in\r\n // onBlur will work as intended\r\n tabIndex=\"-1\"\r\n onClick={wrapEvent(onClick, handleClick)}\r\n >\r\n {children || text}\r\n </Comp>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AAAA;AAOA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SAASC,iBAAT,EAA4BC,eAA5B,QAAmD,SAAnD;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,YAAzB;;AAYA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CACtC,SAASQ,cAAT,OAWEC,GAXF,EAYE;EAAA,IAVEC,QAUF,QAVEA,QAUF;EAAA,IATMC,MASN,QATEC,EASF;EAAA,IARSC,SAQT,QAREC,KAQF;EAAA,IAPQC,QAOR,QAPEC,IAOF;EAAA,IANEC,OAMF,QANEA,OAMF;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,IAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,KAGL;;EACA,0BAKIf,kBAAkB,EALtB;EAAA,IACEgB,QADF,uBACEA,QADF;EAAA,IAEUC,cAFV,uBAEEC,IAFF,CAEUD,cAFV;EAAA,IAGEE,UAHF,uBAGEA,UAHF;EAAA,IAIEC,UAJF,uBAIEA,UAJF;;EAMA,IAAMC,oBAAoB,GAAGzB,MAAM,CAACuB,UAAD,CAAnC;EACA,IAAMG,WAAW,GAAG1B,MAAM,CAAC,KAAD,CAA1B;EAEA,IAAMY,KAAU,GAAGD,SAAnB;EACA,IAAIG,IAAY,GAAGD,QAAQ,GAAGA,QAAH,GAAc,EAAzC;;EAEA,IAAIC,IAAI,CAACa,MAAL,K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;IAIE,GAAG,EAAEX,GAJP;IAKE,EAAE,EAAEG,EALN;IAME,IAAI,EAAC,QANP;IAOE,iBAAegB,WAAW,CAACK,OAP7B;IAQE,oBAAkBL,WAAW,CAACK,OAAZ,GAAsB,EAAtB,GAA2BG,SAR/C,CASE;IACA;IACA;IAXF;IAYE,QAAQ,EAAC,IAZX;IAaE,OAAO,EAAE/B,SAAS,CAACY,OAAD,EAAUiB,WAAV,CAbpB;IAAA,UAeGxB,QAAQ,IAAIM;EAff,GADF;AAmBD,CArFqC,CAAjC"}
1
+ {"version":3,"file":"ComboboxOption.js","names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","jsx","_jsx","ComboboxOption","_ref","ref","children","id","idProp","value","valueProp","text","textProp","onClick","as","Comp","innerAs","props","onSelect","data","navigationItem","transition","optionsRef","transitionCleanupRef","isActiveRef","length","Error","String","opts","current","handleClick","item","role","undefined","tabIndex"],"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"sourcesContent":["import type {\n ElementType,\n LiHTMLAttributes,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { useComboBoxContext } from './context';\nimport { makeHash } from './makeHash';\n\nexport interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id: string;\n value: any;\n text?: string;\n onClick?: MouseEventHandler<HTMLLIElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxOption = forwardRef<HTMLLIElement, ComboboxOptionProps>(\n function ComboboxOption(\n {\n children,\n id: idProp,\n value: valueProp,\n text: textProp,\n onClick,\n as: Comp = 'li',\n innerAs,\n ...props\n },\n ref\n ) {\n const {\n onSelect,\n data: { navigationItem },\n transition,\n optionsRef,\n } = useComboBoxContext();\n const transitionCleanupRef = useRef(transition);\n const isActiveRef = useRef(false);\n\n const value: any = valueProp;\n let text: string = textProp ? textProp : '';\n\n if (text.length === 0) {\n if (typeof valueProp === 'string' && valueProp.length > 0) {\n text = valueProp;\n } else {\n throw new Error('Missing text for <ComboboxOption />');\n }\n }\n\n const id = String(makeHash(idProp));\n\n useEffect(() => {\n const opts = optionsRef.current;\n opts[id] = { value, text };\n\n return () => {\n delete opts[id];\n };\n }, [optionsRef, id, text, value]);\n\n // Keep updating this ref with the current\n // function pointer for transition, so it can\n // be used by the unmount effect below.\n transitionCleanupRef.current = transition;\n isActiveRef.current = navigationItem === id;\n\n useEffect(() => {\n return () => {\n if (isActiveRef.current === true) {\n // clean up selections if this option is getting\n // unmounted and it was the currently selected item\n transitionCleanupRef.current(CLEAR_SELECTION);\n }\n };\n }, []);\n\n const handleClick = () => {\n onSelect && onSelect(text, id, value);\n transition(SELECT_WITH_CLICK, { text, item: id });\n };\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-option=\"\"\n ref={ref}\n id={id}\n role=\"option\"\n aria-selected={isActiveRef.current}\n data-highlighted={isActiveRef.current ? '' : undefined}\n // without this the menu will close from `onBlur`, but with it the\n // element can be `document.activeElement` and then our focus checks in\n // onBlur will work as intended\n tabIndex=\"-1\"\n onClick={wrapEvent(onClick, handleClick)}\n >\n {children || text}\n </Comp>\n );\n }\n);\n"],"mappings":"AAMA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAErD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,SAAS;AAC5D,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,QAAQ,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAYtC,OAAO,MAAMC,cAAc,gBAAGV,UAAU,CACtC,SAASU,cAAcA,CAAAC,IAAA,EAWrBC,GAAG,EACH;EAAA,IAXA;IACEC,QAAQ;IAC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