@basic-ui/core 0.0.52 → 0.0.53

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 (408) hide show
  1. package/README.md +3 -3
  2. package/build/cjs/index.js +105 -89
  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.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +6 -6
  7. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  8. package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
  9. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  10. package/build/esm/Accordion/AccordionItem.d.ts +9 -9
  11. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  12. package/build/esm/Accordion/context.d.ts +19 -19
  13. package/build/esm/Accordion/context.js.map +1 -1
  14. package/build/esm/Accordion/index.d.ts +4 -4
  15. package/build/esm/Accordion/index.js.map +1 -1
  16. package/build/esm/Accordion/scopeQuery.d.ts +2 -2
  17. package/build/esm/Accordion/scopeQuery.js.map +1 -1
  18. package/build/esm/Carousel/Carousel.d.ts +9 -0
  19. package/build/esm/Carousel/Carousel.js +38 -0
  20. package/build/esm/Carousel/Carousel.js.map +1 -0
  21. package/build/esm/Carousel/Fader.d.ts +14 -0
  22. package/build/esm/Carousel/Fader.js +76 -0
  23. package/build/esm/Carousel/Fader.js.map +1 -0
  24. package/build/esm/Carousel/FaderItem.d.ts +5 -0
  25. package/build/esm/Carousel/FaderItem.js +16 -0
  26. package/build/esm/Carousel/FaderItem.js.map +1 -0
  27. package/build/esm/Carousel/Preloader.d.ts +7 -0
  28. package/build/esm/Carousel/Preloader.js +70 -0
  29. package/build/esm/Carousel/Preloader.js.map +1 -0
  30. package/build/esm/Carousel/Slider.d.ts +14 -0
  31. package/build/esm/Carousel/Slider.js +212 -0
  32. package/build/esm/Carousel/Slider.js.map +1 -0
  33. package/build/esm/Carousel/SliderItem.d.ts +12 -0
  34. package/build/esm/Carousel/SliderItem.js +41 -0
  35. package/build/esm/Carousel/SliderItem.js.map +1 -0
  36. package/build/esm/Carousel/context.d.ts +10 -0
  37. package/build/esm/Carousel/context.js +8 -0
  38. package/build/esm/Carousel/context.js.map +1 -0
  39. package/build/esm/Carousel/getSliderParams.d.ts +9 -0
  40. package/build/esm/Carousel/getSliderParams.js +85 -0
  41. package/build/esm/Carousel/getSliderParams.js.map +1 -0
  42. package/build/esm/Carousel/index.d.ts +7 -0
  43. package/build/esm/Carousel/index.js +8 -0
  44. package/build/esm/Carousel/index.js.map +1 -0
  45. package/build/esm/Carousel/useCarouselGestures.d.ts +30 -0
  46. package/build/esm/Carousel/useCarouselGestures.js +33 -0
  47. package/build/esm/Carousel/useCarouselGestures.js.map +1 -0
  48. package/build/esm/CheckBox/CheckBox.d.ts +7 -7
  49. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  50. package/build/esm/CheckBox/index.d.ts +1 -1
  51. package/build/esm/CheckBox/index.js.map +1 -1
  52. package/build/esm/ComboBox/Combobox.d.ts +18 -18
  53. package/build/esm/ComboBox/Combobox.js.map +1 -1
  54. package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
  55. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  56. package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
  57. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  58. package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
  59. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  60. package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
  61. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  62. package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
  63. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  64. package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
  65. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  66. package/build/esm/ComboBox/cities.d.ts +5 -5
  67. package/build/esm/ComboBox/cities.js.map +1 -1
  68. package/build/esm/ComboBox/context.d.ts +30 -30
  69. package/build/esm/ComboBox/context.js.map +1 -1
  70. package/build/esm/ComboBox/hooks.d.ts +37 -37
  71. package/build/esm/ComboBox/hooks.js.map +1 -1
  72. package/build/esm/ComboBox/index.d.ts +8 -8
  73. package/build/esm/ComboBox/index.js.map +1 -1
  74. package/build/esm/ComboBox/makeHash.d.ts +1 -1
  75. package/build/esm/ComboBox/makeHash.js.map +1 -1
  76. package/build/esm/ComboBox/scopeQuery.d.ts +1 -1
  77. package/build/esm/ComboBox/scopeQuery.js.map +1 -1
  78. package/build/esm/DatePicker/DatePicker.d.ts +24 -0
  79. package/build/esm/DatePicker/DatePicker.js +101 -0
  80. package/build/esm/DatePicker/DatePicker.js.map +1 -0
  81. package/build/esm/DatePicker/DatePickerSelect.d.ts +8 -0
  82. package/build/esm/DatePicker/DatePickerSelect.js +201 -0
  83. package/build/esm/DatePicker/DatePickerSelect.js.map +1 -0
  84. package/build/esm/DatePicker/RangeDatePicker.d.ts +28 -0
  85. package/build/esm/DatePicker/RangeDatePicker.js +94 -0
  86. package/build/esm/DatePicker/RangeDatePicker.js.map +1 -0
  87. package/build/esm/DatePicker/adjustDates.d.ts +4 -0
  88. package/build/esm/DatePicker/adjustDates.js +18 -0
  89. package/build/esm/DatePicker/adjustDates.js.map +1 -0
  90. package/build/esm/DatePicker/contexts.d.ts +31 -0
  91. package/build/esm/DatePicker/contexts.js +15 -0
  92. package/build/esm/DatePicker/contexts.js.map +1 -0
  93. package/build/esm/DatePicker/dateTypes.d.ts +2 -0
  94. package/build/esm/DatePicker/dateTypes.js +2 -0
  95. package/build/esm/DatePicker/dateTypes.js.map +1 -0
  96. package/build/esm/DatePicker/hooks.d.ts +36 -0
  97. package/build/esm/DatePicker/hooks.js +98 -0
  98. package/build/esm/DatePicker/hooks.js.map +1 -0
  99. package/build/esm/DatePicker/index.d.ts +5 -0
  100. package/build/esm/DatePicker/index.js +6 -0
  101. package/build/esm/DatePicker/index.js.map +1 -0
  102. package/build/esm/FocusLock/FocusLock.d.ts +9 -9
  103. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  104. package/build/esm/FocusLock/index.d.ts +1 -1
  105. package/build/esm/FocusLock/index.js.map +1 -1
  106. package/build/esm/FocusLock/tabUtils.d.ts +3 -3
  107. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  108. package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
  109. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  110. package/build/esm/List/List.d.ts +7 -7
  111. package/build/esm/List/List.js.map +1 -1
  112. package/build/esm/List/ListItem.d.ts +7 -7
  113. package/build/esm/List/ListItem.js.map +1 -1
  114. package/build/esm/List/context.d.ts +4 -4
  115. package/build/esm/List/context.js.map +1 -1
  116. package/build/esm/List/index.d.ts +2 -2
  117. package/build/esm/List/index.js.map +1 -1
  118. package/build/esm/Menu/ContextMenuTrigger.d.ts +11 -11
  119. package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
  120. package/build/esm/Menu/Menu.d.ts +10 -10
  121. package/build/esm/Menu/Menu.js.map +1 -1
  122. package/build/esm/Menu/MenuButton.d.ts +11 -11
  123. package/build/esm/Menu/MenuButton.js.map +1 -1
  124. package/build/esm/Menu/MenuItem.d.ts +8 -8
  125. package/build/esm/Menu/MenuItem.js.map +1 -1
  126. package/build/esm/Menu/MenuList.d.ts +7 -7
  127. package/build/esm/Menu/MenuList.js.map +1 -1
  128. package/build/esm/Menu/MenuPopover.d.ts +8 -8
  129. package/build/esm/Menu/MenuPopover.js.map +1 -1
  130. package/build/esm/Menu/context.d.ts +25 -25
  131. package/build/esm/Menu/context.js.map +1 -1
  132. package/build/esm/Menu/fixtures/countryList.d.ts +1 -1
  133. package/build/esm/Menu/fixtures/countryList.js.map +1 -1
  134. package/build/esm/Menu/index.d.ts +6 -6
  135. package/build/esm/Menu/index.js.map +1 -1
  136. package/build/esm/Menu/scope.d.ts +1 -1
  137. package/build/esm/Menu/scope.js.map +1 -1
  138. package/build/esm/Modal/Modal.d.ts +9 -9
  139. package/build/esm/Modal/Modal.js.map +1 -1
  140. package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
  141. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  142. package/build/esm/Modal/index.d.ts +2 -2
  143. package/build/esm/Modal/index.js.map +1 -1
  144. package/build/esm/Popper/Popper.d.ts +35 -35
  145. package/build/esm/Popper/Popper.js.map +1 -1
  146. package/build/esm/Popper/PopperArrow.d.ts +6 -6
  147. package/build/esm/Popper/PopperArrow.js.map +1 -1
  148. package/build/esm/Popper/context.d.ts +6 -6
  149. package/build/esm/Popper/context.js.map +1 -1
  150. package/build/esm/Popper/index.d.ts +3 -3
  151. package/build/esm/Popper/index.js.map +1 -1
  152. package/build/esm/Portal/Portal.d.ts +7 -6
  153. package/build/esm/Portal/Portal.js +6 -3
  154. package/build/esm/Portal/Portal.js.map +1 -1
  155. package/build/esm/Portal/PortalSelectorProvider.d.ts +8 -0
  156. package/build/esm/Portal/PortalSelectorProvider.js +13 -0
  157. package/build/esm/Portal/PortalSelectorProvider.js.map +1 -0
  158. package/build/esm/Portal/index.d.ts +2 -1
  159. package/build/esm/Portal/index.js +1 -0
  160. package/build/esm/Portal/index.js.map +1 -1
  161. package/build/esm/RadioButton/RadioButton.d.ts +10 -10
  162. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  163. package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
  164. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  165. package/build/esm/RadioButton/context.d.ts +9 -9
  166. package/build/esm/RadioButton/context.js.map +1 -1
  167. package/build/esm/RadioButton/index.d.ts +2 -2
  168. package/build/esm/RadioButton/index.js.map +1 -1
  169. package/build/esm/SkipNav/SkipNav.d.ts +7 -7
  170. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  171. package/build/esm/SkipNav/index.d.ts +1 -1
  172. package/build/esm/SkipNav/index.js.map +1 -1
  173. package/build/esm/Slider/Slider.d.ts +197 -197
  174. package/build/esm/Slider/Slider.js +82 -82
  175. package/build/esm/Slider/Slider.js.map +1 -1
  176. package/build/esm/Slider/index.d.ts +1 -1
  177. package/build/esm/Slider/index.js.map +1 -1
  178. package/build/esm/Spinner/Spinner.d.ts +12 -12
  179. package/build/esm/Spinner/Spinner.js.map +1 -1
  180. package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
  181. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  182. package/build/esm/Spinner/context.d.ts +12 -12
  183. package/build/esm/Spinner/context.js.map +1 -1
  184. package/build/esm/Spinner/index.d.ts +2 -2
  185. package/build/esm/Spinner/index.js.map +1 -1
  186. package/build/esm/Tabs/Tab.d.ts +7 -7
  187. package/build/esm/Tabs/Tab.js.map +1 -1
  188. package/build/esm/Tabs/TabList.d.ts +9 -9
  189. package/build/esm/Tabs/TabList.js.map +1 -1
  190. package/build/esm/Tabs/TabPanel.d.ts +8 -8
  191. package/build/esm/Tabs/TabPanel.js.map +1 -1
  192. package/build/esm/Tabs/TabPanels.d.ts +8 -8
  193. package/build/esm/Tabs/TabPanels.js.map +1 -1
  194. package/build/esm/Tabs/Tabs.d.ts +10 -10
  195. package/build/esm/Tabs/Tabs.js.map +1 -1
  196. package/build/esm/Tabs/context.d.ts +17 -17
  197. package/build/esm/Tabs/context.js.map +1 -1
  198. package/build/esm/Tabs/index.d.ts +5 -5
  199. package/build/esm/Tabs/index.js.map +1 -1
  200. package/build/esm/Tabs/scopeQuery.d.ts +1 -1
  201. package/build/esm/Tabs/scopeQuery.js.map +1 -1
  202. package/build/esm/Tooltip/Tooltip.d.ts +10 -10
  203. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  204. package/build/esm/Tooltip/index.d.ts +1 -1
  205. package/build/esm/Tooltip/index.js.map +1 -1
  206. package/build/esm/Tooltip/stateMachine.d.ts +28 -28
  207. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  208. package/build/esm/Tooltip/useTooltip.d.ts +10 -10
  209. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  210. package/build/esm/hooks/index.d.ts +13 -13
  211. package/build/esm/hooks/index.js.map +1 -1
  212. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  213. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  214. package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
  215. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  216. package/build/esm/hooks/useControlledState.d.ts +3 -3
  217. package/build/esm/hooks/useFocusReturn.d.ts +2 -2
  218. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  219. package/build/esm/hooks/useFocusState.d.ts +11 -11
  220. package/build/esm/hooks/useFocusState.js.map +1 -1
  221. package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
  222. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  223. package/build/esm/hooks/useId.d.ts +1 -0
  224. package/build/esm/hooks/useId.js +25 -0
  225. package/build/esm/hooks/useId.js.map +1 -0
  226. package/build/esm/hooks/useMeasure.d.ts +7 -7
  227. package/build/esm/hooks/useMeasure.js.map +1 -1
  228. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  229. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  230. package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
  231. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  232. package/build/esm/hooks/useReducerMachine.d.ts +24 -24
  233. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  234. package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
  235. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  236. package/build/esm/hooks/useScope.d.ts +11 -11
  237. package/build/esm/hooks/useScope.js.map +1 -1
  238. package/build/esm/hooks/useThrottle.d.ts +1 -1
  239. package/build/esm/hooks/useThrottle.js.map +1 -1
  240. package/build/esm/index.d.ts +15 -15
  241. package/build/esm/index.js.map +1 -1
  242. package/build/esm/utils/assign-ref.d.ts +3 -3
  243. package/build/esm/utils/assign-ref.js.map +1 -1
  244. package/build/esm/utils/assignRef.d.ts +3 -0
  245. package/build/esm/utils/assignRef.js +25 -0
  246. package/build/esm/utils/assignRef.js.map +1 -0
  247. package/build/esm/utils/can-use-dom.d.ts +1 -1
  248. package/build/esm/utils/can-use-dom.js.map +1 -1
  249. package/build/esm/utils/clamp.d.ts +1 -1
  250. package/build/esm/utils/clamp.js.map +1 -1
  251. package/build/esm/utils/context.d.ts +7 -7
  252. package/build/esm/utils/context.js.map +1 -1
  253. package/build/esm/utils/create-subscription.d.ts +4 -4
  254. package/build/esm/utils/create-subscription.js.map +1 -1
  255. package/build/esm/utils/get-circular-index.d.ts +1 -1
  256. package/build/esm/utils/get-circular-index.js.map +1 -1
  257. package/build/esm/utils/getCircularIndex.d.ts +1 -0
  258. package/build/esm/utils/getCircularIndex.js +8 -0
  259. package/build/esm/utils/getCircularIndex.js.map +1 -0
  260. package/build/esm/utils/index.d.ts +10 -10
  261. package/build/esm/utils/index.js.map +1 -1
  262. package/build/esm/utils/is-right-click.d.ts +6 -6
  263. package/build/esm/utils/is-right-click.js +4 -4
  264. package/build/esm/utils/is-right-click.js.map +1 -1
  265. package/build/esm/utils/owner-document.d.ts +7 -7
  266. package/build/esm/utils/owner-document.js +5 -5
  267. package/build/esm/utils/owner-document.js.map +1 -1
  268. package/build/esm/utils/polymorphic.d.ts +39 -39
  269. package/build/esm/utils/polymorphic.js.map +1 -1
  270. package/build/esm/utils/rubber-band-clamp.d.ts +2 -2
  271. package/build/esm/utils/rubber-band-clamp.js.map +1 -1
  272. package/build/esm/utils/rubberBandClamp.d.ts +2 -0
  273. package/build/esm/utils/rubberBandClamp.js +20 -0
  274. package/build/esm/utils/rubberBandClamp.js.map +1 -0
  275. package/build/esm/utils/use-stable-callback.d.ts +16 -16
  276. package/build/esm/utils/use-stable-callback.js +16 -16
  277. package/build/esm/utils/use-stable-callback.js.map +1 -1
  278. package/build/esm/utils/wrap-event.d.ts +3 -3
  279. package/build/esm/utils/wrap-event.js.map +1 -1
  280. package/build/esm/utils/wrapEvent.d.ts +3 -0
  281. package/build/esm/utils/wrapEvent.js +16 -0
  282. package/build/esm/utils/wrapEvent.js.map +1 -0
  283. package/build/tsconfig-build.tsbuildinfo +1 -1
  284. package/build/tsconfig.tsbuildinfo +7270 -0
  285. package/package.json +2 -2
  286. package/src/Accordion/Accordion.story.tsx +74 -74
  287. package/src/Accordion/Accordion.tsx +59 -59
  288. package/src/Accordion/AccordionBody.tsx +52 -52
  289. package/src/Accordion/AccordionHeader.tsx +167 -167
  290. package/src/Accordion/AccordionItem.tsx +50 -50
  291. package/src/Accordion/context.ts +37 -37
  292. package/src/Accordion/index.ts +4 -4
  293. package/src/Accordion/scopeQuery.ts +7 -7
  294. package/src/Accordion/styles.css +21 -21
  295. package/src/CheckBox/CheckBox.tsx +41 -41
  296. package/src/CheckBox/index.ts +1 -1
  297. package/src/ComboBox/ComboBox.story.tsx +120 -120
  298. package/src/ComboBox/Combobox.tsx +148 -148
  299. package/src/ComboBox/ComboboxButton.tsx +61 -61
  300. package/src/ComboBox/ComboboxInput.tsx +187 -187
  301. package/src/ComboBox/ComboboxLabel.tsx +33 -33
  302. package/src/ComboBox/ComboboxList.tsx +47 -47
  303. package/src/ComboBox/ComboboxOption.tsx +111 -111
  304. package/src/ComboBox/ComboboxPopover.tsx +64 -64
  305. package/src/ComboBox/cities.ts +23194 -23194
  306. package/src/ComboBox/context.ts +35 -35
  307. package/src/ComboBox/hooks.tsx +451 -451
  308. package/src/ComboBox/index.ts +8 -8
  309. package/src/ComboBox/makeHash.ts +19 -19
  310. package/src/ComboBox/scopeQuery.ts +6 -6
  311. package/src/ComboBox/styles.css +32 -32
  312. package/src/FocusLock/FocusLock.tsx +66 -66
  313. package/src/FocusLock/index.ts +1 -1
  314. package/src/FocusLock/tabUtils.ts +40 -40
  315. package/src/FocusLock/useFocusLock.ts +56 -56
  316. package/src/List/List.story.tsx +18 -18
  317. package/src/List/List.tsx +17 -17
  318. package/src/List/ListItem.tsx +23 -23
  319. package/src/List/context.ts +19 -19
  320. package/src/List/index.ts +2 -2
  321. package/src/Menu/ContextMenu.story.tsx +73 -73
  322. package/src/Menu/ContextMenuTrigger.tsx +76 -76
  323. package/src/Menu/Menu.story.tsx +160 -160
  324. package/src/Menu/Menu.tsx +83 -83
  325. package/src/Menu/MenuButton.tsx +83 -83
  326. package/src/Menu/MenuComplex.story.tsx +58 -58
  327. package/src/Menu/MenuItem.tsx +88 -88
  328. package/src/Menu/MenuList.tsx +254 -254
  329. package/src/Menu/MenuPopover.tsx +35 -35
  330. package/src/Menu/context.ts +44 -44
  331. package/src/Menu/fixtures/countryList.ts +198 -198
  332. package/src/Menu/index.ts +6 -6
  333. package/src/Menu/scope.ts +7 -7
  334. package/src/Menu/styles.css +42 -42
  335. package/src/Modal/Modal.story.tsx +258 -258
  336. package/src/Modal/Modal.tsx +48 -48
  337. package/src/Modal/ModalBackdrop.tsx +78 -78
  338. package/src/Modal/NavDrawer.story.tsx +158 -158
  339. package/src/Modal/index.ts +2 -2
  340. package/src/Modal/styles.css +46 -46
  341. package/src/Popper/Popper.story.tsx +263 -263
  342. package/src/Popper/Popper.tsx +154 -154
  343. package/src/Popper/PopperArrow.tsx +35 -35
  344. package/src/Popper/context.ts +10 -10
  345. package/src/Popper/index.ts +3 -3
  346. package/src/Popper/styles.css +60 -60
  347. package/src/Portal/Portal.tsx +31 -20
  348. package/src/Portal/PortalSelectorProvider.tsx +24 -0
  349. package/src/Portal/index.ts +6 -1
  350. package/src/RadioButton/RadioButton.story.tsx +77 -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 +1120 -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 +50 -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/useFocusReturn.ts +43 -43
  386. package/src/hooks/useFocusState.ts +30 -30
  387. package/src/hooks/useGestureHandlers.ts +286 -286
  388. package/src/hooks/useMeasure.ts +33 -33
  389. package/src/hooks/useOnClickOutside.ts +32 -32
  390. package/src/hooks/useOnKeyDown.ts +19 -19
  391. package/src/hooks/useReducerMachine.ts +60 -60
  392. package/src/hooks/useRemoveBodyScroll.ts +39 -39
  393. package/src/hooks/useScope.ts +52 -52
  394. package/src/hooks/useThrottle.ts +19 -19
  395. package/src/index.ts +20 -20
  396. package/src/utils/assign-ref.ts +27 -27
  397. package/src/utils/can-use-dom.ts +7 -7
  398. package/src/utils/clamp.ts +3 -3
  399. package/src/utils/context.tsx +48 -48
  400. package/src/utils/create-subscription.ts +16 -16
  401. package/src/utils/get-circular-index.ts +7 -7
  402. package/src/utils/index.ts +10 -10
  403. package/src/utils/is-right-click.ts +14 -14
  404. package/src/utils/owner-document.ts +13 -13
  405. package/src/utils/polymorphic.ts +78 -78
  406. package/src/utils/rubber-band-clamp.ts +25 -25
  407. package/src/utils/use-stable-callback.ts +58 -58
  408. package/src/utils/wrap-event.ts +22 -22
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","Combobox","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context"],"sources":["../../../src/ComboBox/Combobox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode, ElementType } from 'react';\r\nimport { forwardRef, useRef, useMemo, useId } from 'react';\r\n\r\nimport type { ActionTypes } from './hooks';\r\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\r\nimport type { ComboBoxContextProps } from './context';\r\nimport { ComboBoxProvider } from './context';\r\nimport { useReducerMachine } from '../hooks/useReducerMachine';\r\nimport type { Scope } from '../hooks';\r\nimport { getScope } from '../hooks';\r\n\r\nexport type SelectEventHandler = (\r\n text: string,\r\n itemId: string,\r\n obj: any\r\n) => void;\r\n\r\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\r\n onSelect?: SelectEventHandler;\r\n openOnFocus?: boolean;\r\n selectOnBlur?: boolean;\r\n children?: ReactNode;\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n};\r\n\r\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\r\n function Combobox(\r\n {\r\n // Called whenever the user selects an item from the list\r\n onSelect,\r\n\r\n // opens the list when the input receives focused (but only if there are\r\n // items in the list)\r\n openOnFocus = false,\r\n\r\n // if set to true, it will select an item after blurring\r\n selectOnBlur = false,\r\n\r\n children,\r\n as: Comp = 'div',\r\n innerAs,\r\n ...rest\r\n }: ComboboxProps,\r\n ref\r\n ) {\r\n // We store the values of all the ComboboxOptions on this ref. This makes it\r\n // possible to perform the keyboard navigation from the input on the list. We\r\n // manipulate this array through context so that we don't have to enforce a\r\n // parent/child relationship between ComboboxList and ComboboxOption.\r\n const optionsRef = useRef<{\r\n [itemId: string]: {\r\n value: string | unknown;\r\n text: string;\r\n };\r\n }>({});\r\n\r\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\r\n\r\n // Need this to focus it\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n\r\n const popoverRef = useRef<HTMLDivElement>(null);\r\n\r\n const buttonRef = useRef<HTMLButtonElement>(null);\r\n\r\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\r\n // the user's value while navigating (because it's always the user's value),\r\n // but we need to know this in useKeyDown which is far away from the prop\r\n // here, so we do something sneaky and write it to this ref on context so we\r\n // can use it anywhere else 😛. Another new trick for me and I'm excited\r\n // about this one too!\r\n const autocompletePropRef = useRef<boolean>(false);\r\n\r\n const persistSelectionRef = useRef<boolean>(false);\r\n\r\n const clearOnEscapeRef = useRef<boolean>(false);\r\n\r\n const listboxIdRef = useRef<string | undefined>();\r\n\r\n const labelIdRef = useRef<string | undefined>();\r\n\r\n const defaultData = {\r\n // initial state\r\n state: stateChart.initial,\r\n // the value the user has typed, we derived this also when the developer is\r\n // controlling the value of ComboboxInput\r\n text: '',\r\n // the index the user has typed, we derived this also when the developer is\r\n // controlling the value of ComboboxInput\r\n item: '',\r\n // the hash of the currently navigated item\r\n navigationItem: '',\r\n // the last submitted action\r\n lastActionType: INIT as ActionTypes,\r\n };\r\n\r\n const [state, data, transition] = useReducerMachine(\r\n stateChart,\r\n comboboxReducer,\r\n defaultData\r\n );\r\n\r\n listboxIdRef.current = useId();\r\n\r\n labelIdRef.current = useId();\r\n\r\n const context = useMemo(\r\n (): ComboBoxContextProps => ({\r\n data,\r\n inputRef,\r\n popoverRef,\r\n buttonRef,\r\n onSelect,\r\n optionsRef,\r\n listScope,\r\n state,\r\n transition,\r\n listboxIdRef,\r\n labelIdRef,\r\n autocompletePropRef,\r\n persistSelectionRef,\r\n clearOnEscapeRef,\r\n isVisible: isVisible(state),\r\n openOnFocus,\r\n selectOnBlur,\r\n }),\r\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\r\n );\r\n\r\n return (\r\n <ComboBoxProvider value={context}>\r\n <Comp\r\n {...rest}\r\n as={innerAs}\r\n data-reach-combobox=\"\"\r\n ref={ref}\r\n role=\"combobox\"\r\n aria-haspopup=\"listbox\"\r\n aria-owns={listboxIdRef.current}\r\n aria-expanded={context.isVisible}\r\n >\r\n {children}\r\n </Comp>\r\n </ComboBoxProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,KAAtC,QAAmD,OAAnD;AAGA,SAASC,UAAT,EAAqBC,eAArB,EAAsCC,SAAtC,EAAiDC,IAAjD,QAA6D,SAA7D;AAEA,SAASC,gBAAT,QAAiC,WAAjC;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AAEA,SAASC,QAAT,QAAyB,UAAzB;;AAiBA,OAAO,IAAMC,QAAQ,gBAAGX,UAAU,CAChC,SAASW,QAAT,OAiBEC,GAjBF,EAkBE;EAAA,IAfEC,QAeF,QAfEA,QAeF;EAAA,4BAXEC,WAWF;EAAA,IAXEA,WAWF,iCAXgB,KAWhB;EAAA,6BAREC,YAQF;EAAA,IAREA,YAQF,kCARiB,KAQjB;EAAA,IANEC,QAMF,QANEA,QAMF;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,KAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,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AU,EAAVA,UAH2B;MAI3BC,SAAS,EAATA,SAJ2B;MAK3Bb,QAAQ,EAARA,QAL2B;MAM3BQ,UAAU,EAAVA,UAN2B;MAO3BC,SAAS,EAATA,SAP2B;MAQ3BW,KAAK,EAALA,KAR2B;MAS3BO,UAAU,EAAVA,UAT2B;MAU3BV,YAAY,EAAZA,YAV2B;MAW3BC,UAAU,EAAVA,UAX2B;MAY3BJ,mBAAmB,EAAnBA,mBAZ2B;MAa3BC,mBAAmB,EAAnBA,mBAb2B;MAc3BC,gBAAgB,EAAhBA,gBAd2B;MAe3BvB,SAAS,EAAEA,SAAS,CAAC2B,KAAD,CAfO;MAgB3BnB,WAAW,EAAXA,WAhB2B;MAiB3BC,YAAY,EAAZA;IAjB2B,CAA7B;EAAA,CADqB,EAoBrB,CAACwB,IAAD,EAAO1B,QAAP,EAAiBS,SAAjB,EAA4BW,KAA5B,EAAmCO,UAAnC,EAA+C1B,WAA/C,EAA4DC,YAA5D,CApBqB,CAAvB;EAuBA,oBACE,KAAC,gBAAD;IAAkB,KAAK,EAAE0B,OAAzB;IAAA,uBACE,KAAC,IAAD,wBACMrB,IADN;MAEE,EAAE,EAAED,OAFN;MAGE,uBAAoB,EAHtB;MAIE,GAAG,EAAEP,GAJP;MAKE,IAAI,EAAC,UALP;MAME,iBAAc,SANhB;MAOE,aAAWkB,YAAY,CAACP,OAP1B;MAQE,iBAAekB,OAAO,CAACnC,SARzB;MAAA,UAUGU;IAVH;EADF,EADF;AAgBD,CAxH+B,CAA3B"}
1
+ {"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","Combobox","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context"],"sources":["../../../src/ComboBox/Combobox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode, ElementType } from 'react';\nimport { forwardRef, useRef, useMemo, useId } from 'react';\n\nimport type { ActionTypes } from './hooks';\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\nimport type { ComboBoxContextProps } from './context';\nimport { ComboBoxProvider } from './context';\nimport { useReducerMachine } from '../hooks/useReducerMachine';\nimport type { Scope } from '../hooks';\nimport { getScope } from '../hooks';\n\nexport type SelectEventHandler = (\n text: string,\n itemId: string,\n obj: any\n) => void;\n\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n onSelect?: SelectEventHandler;\n openOnFocus?: boolean;\n selectOnBlur?: boolean;\n children?: ReactNode;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n};\n\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\n function Combobox(\n {\n // Called whenever the user selects an item from the list\n onSelect,\n\n // opens the list when the input receives focused (but only if there are\n // items in the list)\n openOnFocus = false,\n\n // if set to true, it will select an item after blurring\n selectOnBlur = false,\n\n children,\n as: Comp = 'div',\n innerAs,\n ...rest\n }: ComboboxProps,\n ref\n ) {\n // We store the values of all the ComboboxOptions on this ref. This makes it\n // possible to perform the keyboard navigation from the input on the list. We\n // manipulate this array through context so that we don't have to enforce a\n // parent/child relationship between ComboboxList and ComboboxOption.\n const optionsRef = useRef<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>({});\n\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\n\n // Need this to focus it\n const inputRef = useRef<HTMLInputElement>(null);\n\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\n // the user's value while navigating (because it's always the user's value),\n // but we need to know this in useKeyDown which is far away from the prop\n // here, so we do something sneaky and write it to this ref on context so we\n // can use it anywhere else 😛. Another new trick for me and I'm excited\n // about this one too!\n const autocompletePropRef = useRef<boolean>(false);\n\n const persistSelectionRef = useRef<boolean>(false);\n\n const clearOnEscapeRef = useRef<boolean>(false);\n\n const listboxIdRef = useRef<string | undefined>();\n\n const labelIdRef = useRef<string | undefined>();\n\n const defaultData = {\n // initial state\n state: stateChart.initial,\n // the value the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n text: '',\n // the index the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n item: '',\n // the hash of the currently navigated item\n navigationItem: '',\n // the last submitted action\n lastActionType: INIT as ActionTypes,\n };\n\n const [state, data, transition] = useReducerMachine(\n stateChart,\n comboboxReducer,\n defaultData\n );\n\n listboxIdRef.current = useId();\n\n labelIdRef.current = useId();\n\n const context = useMemo(\n (): ComboBoxContextProps => ({\n data,\n inputRef,\n popoverRef,\n buttonRef,\n onSelect,\n optionsRef,\n listScope,\n state,\n transition,\n listboxIdRef,\n labelIdRef,\n autocompletePropRef,\n persistSelectionRef,\n clearOnEscapeRef,\n isVisible: isVisible(state),\n openOnFocus,\n selectOnBlur,\n }),\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\n );\n\n return (\n <ComboBoxProvider value={context}>\n <Comp\n {...rest}\n as={innerAs}\n data-reach-combobox=\"\"\n ref={ref}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-owns={listboxIdRef.current}\n aria-expanded={context.isVisible}\n >\n {children}\n </Comp>\n </ComboBoxProvider>\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,KAAtC,QAAmD,OAAnD;AAGA,SAASC,UAAT,EAAqBC,eAArB,EAAsCC,SAAtC,EAAiDC,IAAjD,QAA6D,SAA7D;AAEA,SAASC,gBAAT,QAAiC,WAAjC;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AAEA,SAASC,QAAT,QAAyB,UAAzB;;AAiBA,OAAO,IAAMC,QAAQ,gBAAGX,UAAU,CACh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B,CAA3B"}
@@ -1,9 +1,9 @@
1
- import type { ButtonHTMLAttributes, ElementType, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
2
- export interface ComboboxButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
- as?: ElementType<any>;
4
- innerAs?: ElementType<any>;
5
- onClick?: MouseEventHandler<HTMLButtonElement>;
6
- onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
7
- children?: ReactNode;
8
- }
9
- export declare const ComboboxButton: import("react").ForwardRefExoticComponent<ComboboxButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
1
+ import type { ButtonHTMLAttributes, ElementType, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
2
+ export interface ComboboxButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ onClick?: MouseEventHandler<HTMLButtonElement>;
6
+ onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
7
+ children?: ReactNode;
8
+ }
9
+ export declare const ComboboxButton: import("react").ForwardRefExoticComponent<ComboboxButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","ComboboxButton","ref","as","Comp","innerAs","onClick","onKeyDown","props","transition","data","state","buttonRef","listboxIdRef","isVisible","handleKeyDown","handleClick","payload","item","navigationItem","current"],"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"sourcesContent":["import type {\r\n ButtonHTMLAttributes,\r\n ElementType,\r\n KeyboardEventHandler,\r\n MouseEventHandler,\r\n ReactNode,\r\n} from 'react';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useComboBoxContext } from './context';\r\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\r\nimport { wrapEvent } from '../utils/wrap-event';\r\nimport { assignMultipleRefs } from '../utils/assign-ref';\r\n\r\nexport interface ComboboxButtonProps\r\n extends ButtonHTMLAttributes<HTMLButtonElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n onClick?: MouseEventHandler<HTMLButtonElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const ComboboxButton = forwardRef<\r\n HTMLButtonElement,\r\n ComboboxButtonProps\r\n>(function ComboboxButton(\r\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\r\n ref\r\n) {\r\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\r\n useComboBoxContext();\r\n\r\n const handleKeyDown = useKeyDown();\r\n\r\n const handleClick = () => {\r\n const payload = {\r\n item: data.navigationItem,\r\n };\r\n\r\n if (state === IDLE) {\r\n transition(OPEN_WITH_BUTTON, payload);\r\n } else {\r\n transition(CLOSE_WITH_BUTTON, payload);\r\n }\r\n };\r\n\r\n return (\r\n <Comp\r\n as={innerAs}\r\n data-reach-combobox-button=\"\"\r\n aria-controls={listboxIdRef.current}\r\n aria-haspopup=\"listbox\"\r\n aria-expanded={isVisible}\r\n ref={assignMultipleRefs(ref, buttonRef)}\r\n onClick={wrapEvent(onClick, handleClick)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n {...props}\r\n />\r\n );\r\n});\r\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;;AAWA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,QAEb;EAAA,IAFuBC,OAEvB,QAFuBA,OAEvB;EAAA,IAFgCC,OAEhC,QAFgCA,OAEhC;EAAA,IAFyCC,SAEzC,QAFyCA,SAEzC;EAAA,IAFuDC,KAEvD;;EACA,0BACEd,kBAAkB,EADpB;EAAA,IAAQe,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,IAApB,uBAAoBA,IAApB;EAAA,IAA0BC,KAA1B,uBAA0BA,KAA1B;EAAA,IAAiCC,SAAjC,uBAAiCA,SAAjC;EAAA,IAA4CC,YAA5C,uBAA4CA,YAA5C;EAAA,IAA0DC,SAA1D,uBAA0DA,SAA1D;;EAGA,IAAMC,aAAa,GAAGpB,UAAU,EAAhC;;EAEA,IAAMqB,WAAW,GAAG,SAAdA,WAAc,GAAM;IACxB,IAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IADG,CAAhB;;IAIA,IAAIR,KAAK,KAAKf,IAAd,EAAoB;MAClBa,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;IACD,CAFD,MAEO;MACLR,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;IACD;EACF,CAVD;;EAYA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEZ,OADN;IAEE,8BAA2B,EAF7B;IAGE,iBAAeQ,YAAY,CAACO,OAH9B;IAIE,iBAAc,SAJhB;IAKE,iBAAeN,SALjB;IAME,GAAG,EAAEd,kBAAkB,CAACE,GAAD,EAAMU,SAAN,CANzB;IAOE,OAAO,EAAEb,SAAS,CAACO,OAAD,EAAUU,WAAV,CAPpB;IAQE,SAAS,EAAEjB,SAAS,CAACQ,SAAD,EAAYQ,aAAZ;EARtB,GASMP,KATN,EADF;AAaD,CArCuC,CAAjC"}
1
+ {"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","ComboboxButton","ref","as","Comp","innerAs","onClick","onKeyDown","props","transition","data","state","buttonRef","listboxIdRef","isVisible","handleKeyDown","handleClick","payload","item","navigationItem","current"],"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { assignMultipleRefs } from '../utils/assign-ref';\n\nexport interface ComboboxButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxButton = forwardRef<\n HTMLButtonElement,\n ComboboxButtonProps\n>(function ComboboxButton(\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\n ref\n) {\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\n useComboBoxContext();\n\n const handleKeyDown = useKeyDown();\n\n const handleClick = () => {\n const payload = {\n item: data.navigationItem,\n };\n\n if (state === IDLE) {\n transition(OPEN_WITH_BUTTON, payload);\n } else {\n transition(CLOSE_WITH_BUTTON, payload);\n }\n };\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-button=\"\"\n aria-controls={listboxIdRef.current}\n aria-haspopup=\"listbox\"\n aria-expanded={isVisible}\n ref={assignMultipleRefs(ref, buttonRef)}\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n {...props}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6C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,SAAD,EAAYQ,aAAZ;EARtB,GASMP,KATN,EADF;AAaD,CArCuC,CAAjC"}
@@ -1,17 +1,17 @@
1
- import type { ChangeEventHandler, ElementType, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
2
- export interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
- clearOnEscape?: boolean;
4
- selectOnClick?: boolean;
5
- autocomplete?: boolean;
6
- defaultValue?: string;
7
- value?: string;
8
- onClick?: MouseEventHandler<HTMLInputElement>;
9
- onChange?: ChangeEventHandler<HTMLInputElement>;
10
- onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
11
- onBlur?: FocusEventHandler<HTMLInputElement>;
12
- onFocus?: FocusEventHandler<HTMLInputElement>;
13
- as?: ElementType<any>;
14
- innerAs?: ElementType<any>;
15
- id?: string;
16
- }
17
- export declare const ComboboxInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
1
+ import type { ChangeEventHandler, ElementType, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
2
+ export interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ clearOnEscape?: boolean;
4
+ selectOnClick?: boolean;
5
+ autocomplete?: boolean;
6
+ defaultValue?: string;
7
+ value?: string;
8
+ onClick?: MouseEventHandler<HTMLInputElement>;
9
+ onChange?: ChangeEventHandler<HTMLInputElement>;
10
+ onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
11
+ onBlur?: FocusEventHandler<HTMLInputElement>;
12
+ onFocus?: FocusEventHandler<HTMLInputElement>;
13
+ as?: ElementType<any>;
14
+ innerAs?: ElementType<any>;
15
+ id?: string;
16
+ }
17
+ export declare const ComboboxInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -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,QA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;IAQE,OAAO,EAAEpC,SAAS,CAACc,OAAD,EAAU6B,WAAV,CARpB;IASE,QAAQ,EAAE3C,SAAS,CAACW,QAAD,EAAW2B,YAAX,CATrB;IAUE,SAAS,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","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 {\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,UAAT,EAAqBC,SAArB,EAAgCC,M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T,CAPnB;IAQE,OAAO,EAAEpC,SAAS,CAACc,OAAD,EAAU6B,WAAV,CARpB;IASE,QAAQ,EAAE3C,SAAS,CAACW,QAAD,EAAW2B,YAAX,CATrB;IAUE,SAAS,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,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 +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","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","preferredId","id","props","listboxIdRef","labelIdRef","current"],"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,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,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 +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","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';\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>();\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,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,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 +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,E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AAC,YAAM;IACd,OAAO,YAAM;MACX,IAAI2B,WAAW,CAACK,OAAZ,KAAwB,IAA5B,EAAkC;QAChC;QACA;QACAN,oBAAoB,CAACM,OAArB,CAA6B7B,eAA7B;MACD;IACF,CAND;EAOD,CARQ,EAQN,EARM,CAAT;;EAUA,IAAM8B,WAAW,GAAG,SAAdA,WAAc,GAAM;IACxBZ,QAAQ,IAAIA,QAAQ,CAACN,IAAD,EAAOJ,EAAP,EAAWE,KAAX,CAApB;IACAW,UAAU,CAACtB,iBAAD,EAAoB;MAAEa,IAAI,EAAJA,IAAF;MAAQmB,IAAI,EAAEvB;IAAd,CAApB,CAAV;EACD,CAHD;;EAKA,oBACE,KAAC,IAAD,wBACMS,KADN;IAEE,EAAE,EAAED,OAFN;IAGE,8BAA2B,EAH7B;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","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 */\nimport 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":";;;;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,KAAgB,CAApB,EAAuB;IACrB,IAAI,OAAOhB,SAAP,KAAqB,QAArB,IAAiCA,SAAS,CAACgB,MAAV,GAAmB,CAAxD,EAA2D;MACzDb,IAAI,GAAGH,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AACK,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,9 +1,9 @@
1
- import type { ElementType, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, ReactNode } from 'react';
2
- export interface ComboboxPopoverProps extends HTMLAttributes<HTMLDivElement> {
3
- as?: ElementType<any>;
4
- innerAs?: ElementType<any>;
5
- onBlur?: FocusEventHandler<HTMLDivElement>;
6
- onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
7
- children?: ReactNode;
8
- }
9
- export declare const ComboboxPopover: import("react").ForwardRefExoticComponent<ComboboxPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
1
+ import type { ElementType, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, ReactNode } from 'react';
2
+ export interface ComboboxPopoverProps extends HTMLAttributes<HTMLDivElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ onBlur?: FocusEventHandler<HTMLDivElement>;
6
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
7
+ children?: ReactNode;
8
+ }
9
+ export declare const ComboboxPopover: import("react").ForwardRefExoticComponent<ComboboxPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxPopover.js","names":["forwardRef","useKeyDown","useBlur","wrapEvent","assignMultipleRefs","useComboBoxContext","ComboboxPopover","forwardedRef","onKeyDown","onBlur","as","Comp","innerAs","props","popoverRef","isVisible","handleKeyDown","handleBlur","hidden"],"sources":["../../../src/ComboBox/ComboboxPopover.tsx"],"sourcesContent":["import type {\r\n ElementType,\r\n FocusEventHandler,\r\n HTMLAttributes,\r\n KeyboardEventHandler,\r\n ReactNode,\r\n} from 'react';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useKeyDown, useBlur } from './hooks';\r\nimport { wrapEvent } from '../utils/wrap-event';\r\nimport { assignMultipleRefs } from '../utils/assign-ref';\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxPopoverProps extends HTMLAttributes<HTMLDivElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n onBlur?: FocusEventHandler<HTMLDivElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const ComboboxPopover = forwardRef<HTMLDivElement, ComboboxPopoverProps>(\r\n function ComboboxPopover(\r\n {\r\n // wrapped events\r\n onKeyDown,\r\n onBlur,\r\n\r\n as: Comp = 'div',\r\n innerAs,\r\n ...props\r\n },\r\n forwardedRef\r\n ) {\r\n const { popoverRef, isVisible } = useComboBoxContext();\r\n const handleKeyDown = useKeyDown();\r\n const handleBlur = useBlur();\r\n\r\n // Instead of conditionally rendering the popover we use the `hidden` prop\r\n // because we don't want to unmount on close (from escape or onSelect). If\r\n // we unmounted, then we'd lose the optionsRef and the user wouldn't be able\r\n // to use the arrow keys to pop the list back open. However, the developer\r\n // can conditionally render the ComboboxPopover if they do want to cause\r\n // mount/unmount based on the app's own data (like results.length or\r\n // whatever).\r\n const hidden = !isVisible;\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n data-reach-combobox-popover=\"\"\r\n ref={assignMultipleRefs(popoverRef, forwardedRef)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n hidden={hidden}\r\n // Allow the user to click empty space inside the popover without causing\r\n // to close from useBlur\r\n tabIndex=\"-1\"\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,SAApC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAUA,OAAO,IAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAUEC,YAVF,EAWE;EAAA,IAREC,SAQF,QAREA,SAQF;EAAA,IAPEC,MAOF,QAPEA,MAOF;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,KAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,KAGL;;EACA,0BAAkCR,kBAAkB,EAApD;EAAA,IAAQS,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,SAApB,uBAAoBA,SAApB;;EACA,IAAMC,aAAa,GAAGf,UAAU,EAAhC;EACA,IAAMgB,UAAU,GAAGf,OAAO,EAA1B,CAHA,CAKA;EACA;EACA;EACA;EACA;EACA;EACA;;EACA,IAAMgB,MAAM,GAAG,CAACH,SAAhB;EAEA,oBACE,KAAC,IAAD,wBACMF,KADN;IAEE,EAAE,EAAED,OAFN;IAGE,+BAA4B,EAH9B;IAIE,GAAG,EAAER,kBAAkB,CAACU,UAAD,EAAaP,YAAb,CAJzB;IAKE,SAAS,EAAEJ,SAAS,CAACK,SAAD,EAAYQ,aAAZ,CALtB;IAME,MAAM,EAAEb,SAAS,CAACM,MAAD,EAASQ,UAAT,CANnB;IAOE,MAAM,EAAEC,MAPV,CAQE;IACA;IATF;IAUE,QAAQ,EAAC;EAVX,GADF;AAcD,CAxCsC,CAAlC"}
1
+ {"version":3,"file":"ComboboxPopover.js","names":["forwardRef","useKeyDown","useBlur","wrapEvent","assignMultipleRefs","useComboBoxContext","ComboboxPopover","forwardedRef","onKeyDown","onBlur","as","Comp","innerAs","props","popoverRef","isVisible","handleKeyDown","handleBlur","hidden"],"sources":["../../../src/ComboBox/ComboboxPopover.tsx"],"sourcesContent":["import type {\n ElementType,\n FocusEventHandler,\n HTMLAttributes,\n KeyboardEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useKeyDown, useBlur } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxPopoverProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onBlur?: FocusEventHandler<HTMLDivElement>;\n onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxPopover = forwardRef<HTMLDivElement, ComboboxPopoverProps>(\n function ComboboxPopover(\n {\n // wrapped events\n onKeyDown,\n onBlur,\n\n as: Comp = 'div',\n innerAs,\n ...props\n },\n forwardedRef\n ) {\n const { popoverRef, isVisible } = useComboBoxContext();\n const handleKeyDown = useKeyDown();\n const handleBlur = useBlur();\n\n // Instead of conditionally rendering the popover we use the `hidden` prop\n // because we don't want to unmount on close (from escape or onSelect). If\n // we unmounted, then we'd lose the optionsRef and the user wouldn't be able\n // to use the arrow keys to pop the list back open. However, the developer\n // can conditionally render the ComboboxPopover if they do want to cause\n // mount/unmount based on the app's own data (like results.length or\n // whatever).\n const hidden = !isVisible;\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-popover=\"\"\n ref={assignMultipleRefs(popoverRef, forwardedRef)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n hidden={hidden}\n // Allow the user to click empty space inside the popover without causing\n // to close from useBlur\n tabIndex=\"-1\"\n />\n );\n }\n);\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,SAApC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAUA,OAAO,IAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAUEC,YAVF,EAWE;EAAA,IAREC,SAQF,QAREA,SAQF;EAAA,IAPEC,MAOF,QAPEA,MAOF;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,KAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,KAGL;;EACA,0BAAkCR,kBAAkB,EAApD;EAAA,IAAQS,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,SAApB,uBAAoBA,SAApB;;EACA,IAAMC,aAAa,GAAGf,UAAU,EAAhC;EACA,IAAMgB,UAAU,GAAGf,OAAO,EAA1B,CAHA,CAKA;EACA;EACA;EACA;EACA;EACA;EACA;;EACA,IAAMgB,MAAM,GAAG,CAACH,SAAhB;EAEA,oBACE,KAAC,IAAD,wBACMF,KADN;IAEE,EAAE,EAAED,OAFN;IAGE,+BAA4B,EAH9B;IAIE,GAAG,EAAER,kBAAkB,CAACU,UAAD,EAAaP,YAAb,CAJzB;IAKE,SAAS,EAAEJ,SAAS,CAACK,SAAD,EAAYQ,aAAZ,CALtB;IAME,MAAM,EAAEb,SAAS,CAACM,MAAD,EAASQ,UAAT,CANnB;IAOE,MAAM,EAAEC,MAPV,CAQE;IACA;IATF;IAUE,QAAQ,EAAC;EAVX,GADF;AAcD,CAxCsC,CAAlC"}
@@ -1,5 +1,5 @@
1
- declare const _default: {
2
- city: string;
3
- state: string;
4
- }[];
5
- export default _default;
1
+ declare const _default: {
2
+ city: string;
3
+ state: string;
4
+ }[];
5
+ export default _default;