@basic-ui/core 0.0.38 → 0.0.41

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 (266) hide show
  1. package/build/cjs/index.js +1 -1
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.d.ts +7 -7
  4. package/build/esm/Accordion/Accordion.js +22 -17
  5. package/build/esm/Accordion/Accordion.js.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +5 -5
  7. package/build/esm/Accordion/AccordionBody.js +23 -15
  8. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  9. package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
  10. package/build/esm/Accordion/AccordionHeader.js +45 -31
  11. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  12. package/build/esm/Accordion/AccordionItem.d.ts +7 -7
  13. package/build/esm/Accordion/AccordionItem.js +16 -16
  14. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  15. package/build/esm/Accordion/context.d.ts +4 -4
  16. package/build/esm/Accordion/context.js +12 -10
  17. package/build/esm/Accordion/context.js.map +1 -1
  18. package/build/esm/CheckBox/CheckBox.d.ts +6 -6
  19. package/build/esm/CheckBox/CheckBox.js +19 -12
  20. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  21. package/build/esm/ComboBox/Combobox.d.ts +10 -10
  22. package/build/esm/ComboBox/Combobox.js +52 -46
  23. package/build/esm/ComboBox/Combobox.js.map +1 -1
  24. package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
  25. package/build/esm/ComboBox/ComboboxButton.js +19 -20
  26. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  27. package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
  28. package/build/esm/ComboBox/ComboboxInput.js +52 -50
  29. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  30. package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
  31. package/build/esm/ComboBox/ComboboxLabel.js +11 -12
  32. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
  34. package/build/esm/ComboBox/ComboboxList.js +15 -17
  35. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
  37. package/build/esm/ComboBox/ComboboxOption.js +31 -34
  38. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
  40. package/build/esm/ComboBox/ComboboxPopover.js +15 -17
  41. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  42. package/build/esm/ComboBox/context.d.ts +13 -13
  43. package/build/esm/ComboBox/context.js +6 -5
  44. package/build/esm/ComboBox/context.js.map +1 -1
  45. package/build/esm/ComboBox/hooks.d.ts +4 -4
  46. package/build/esm/ComboBox/hooks.js +82 -115
  47. package/build/esm/ComboBox/hooks.js.map +1 -1
  48. package/build/esm/ComboBox/makeHash.js +3 -3
  49. package/build/esm/ComboBox/makeHash.js.map +1 -1
  50. package/build/esm/FocusLock/FocusLock.d.ts +7 -7
  51. package/build/esm/FocusLock/FocusLock.js +17 -16
  52. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  53. package/build/esm/FocusLock/tabUtils.js +4 -4
  54. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  55. package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
  56. package/build/esm/FocusLock/useFocusLock.js +10 -11
  57. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  58. package/build/esm/List/List.d.ts +6 -6
  59. package/build/esm/List/List.js +5 -6
  60. package/build/esm/List/List.js.map +1 -1
  61. package/build/esm/List/ListItem.d.ts +6 -6
  62. package/build/esm/List/ListItem.js +5 -6
  63. package/build/esm/List/ListItem.js.map +1 -1
  64. package/build/esm/List/context.js +3 -3
  65. package/build/esm/List/context.js.map +1 -1
  66. package/build/esm/Menu/Menu.d.ts +6 -6
  67. package/build/esm/Menu/Menu.js +29 -21
  68. package/build/esm/Menu/Menu.js.map +1 -1
  69. package/build/esm/Menu/MenuButton.d.ts +10 -10
  70. package/build/esm/Menu/MenuButton.js +27 -24
  71. package/build/esm/Menu/MenuButton.js.map +1 -1
  72. package/build/esm/Menu/MenuItem.d.ts +6 -6
  73. package/build/esm/Menu/MenuItem.js +23 -24
  74. package/build/esm/Menu/MenuItem.js.map +1 -1
  75. package/build/esm/Menu/MenuList.d.ts +5 -5
  76. package/build/esm/Menu/MenuList.js +61 -45
  77. package/build/esm/Menu/MenuList.js.map +1 -1
  78. package/build/esm/Menu/MenuPopover.d.ts +6 -6
  79. package/build/esm/Menu/MenuPopover.js +8 -10
  80. package/build/esm/Menu/MenuPopover.js.map +1 -1
  81. package/build/esm/Menu/context.d.ts +2 -2
  82. package/build/esm/Menu/context.js +11 -8
  83. package/build/esm/Menu/context.js.map +1 -1
  84. package/build/esm/Modal/Modal.d.ts +6 -7
  85. package/build/esm/Modal/Modal.js +11 -10
  86. package/build/esm/Modal/Modal.js.map +1 -1
  87. package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
  88. package/build/esm/Modal/ModalBackdrop.js +20 -19
  89. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  90. package/build/esm/Popper/Popper.d.ts +8 -8
  91. package/build/esm/Popper/Popper.js +46 -37
  92. package/build/esm/Popper/Popper.js.map +1 -1
  93. package/build/esm/Popper/PopperArrow.d.ts +5 -5
  94. package/build/esm/Popper/PopperArrow.js +8 -9
  95. package/build/esm/Popper/PopperArrow.js.map +1 -1
  96. package/build/esm/Popper/context.d.ts +1 -1
  97. package/build/esm/Popper/context.js +5 -3
  98. package/build/esm/Popper/context.js.map +1 -1
  99. package/build/esm/Portal/Portal.d.ts +1 -1
  100. package/build/esm/Portal/Portal.js +6 -5
  101. package/build/esm/Portal/Portal.js.map +1 -1
  102. package/build/esm/RadioButton/RadioButton.d.ts +7 -7
  103. package/build/esm/RadioButton/RadioButton.js +12 -13
  104. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  105. package/build/esm/RadioButton/RadioGroup.d.ts +8 -8
  106. package/build/esm/RadioButton/RadioGroup.js +22 -16
  107. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  108. package/build/esm/RadioButton/context.d.ts +2 -2
  109. package/build/esm/RadioButton/context.js +6 -5
  110. package/build/esm/RadioButton/context.js.map +1 -1
  111. package/build/esm/SkipNav/SkipNav.d.ts +6 -6
  112. package/build/esm/SkipNav/SkipNav.js +5 -6
  113. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  114. package/build/esm/Spinner/Spinner.d.ts +7 -7
  115. package/build/esm/Spinner/Spinner.js +41 -31
  116. package/build/esm/Spinner/Spinner.js.map +1 -1
  117. package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
  118. package/build/esm/Spinner/SpinnerButton.js +11 -12
  119. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  120. package/build/esm/Spinner/context.d.ts +2 -2
  121. package/build/esm/Spinner/context.js +6 -5
  122. package/build/esm/Spinner/context.js.map +1 -1
  123. package/build/esm/Tabs/Tab.d.ts +6 -6
  124. package/build/esm/Tabs/Tab.js +29 -29
  125. package/build/esm/Tabs/Tab.js.map +1 -1
  126. package/build/esm/Tabs/TabList.d.ts +6 -6
  127. package/build/esm/Tabs/TabList.js +24 -21
  128. package/build/esm/Tabs/TabList.js.map +1 -1
  129. package/build/esm/Tabs/TabPanel.d.ts +6 -6
  130. package/build/esm/Tabs/TabPanel.js +12 -12
  131. package/build/esm/Tabs/TabPanel.js.map +1 -1
  132. package/build/esm/Tabs/TabPanels.d.ts +5 -5
  133. package/build/esm/Tabs/TabPanels.js +13 -12
  134. package/build/esm/Tabs/TabPanels.js.map +1 -1
  135. package/build/esm/Tabs/Tabs.d.ts +6 -6
  136. package/build/esm/Tabs/Tabs.js +27 -14
  137. package/build/esm/Tabs/Tabs.js.map +1 -1
  138. package/build/esm/Tabs/context.d.ts +3 -3
  139. package/build/esm/Tabs/context.js +12 -10
  140. package/build/esm/Tabs/context.js.map +1 -1
  141. package/build/esm/Tooltip/Tooltip.d.ts +7 -7
  142. package/build/esm/Tooltip/Tooltip.js +18 -16
  143. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  144. package/build/esm/Tooltip/stateMachine.js +56 -80
  145. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  146. package/build/esm/Tooltip/useTooltip.d.ts +7 -7
  147. package/build/esm/Tooltip/useTooltip.js +32 -30
  148. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  149. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  150. package/build/esm/hooks/useAutoFocus.js +1 -1
  151. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  152. package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
  153. package/build/esm/hooks/useChildrenCounter.js +6 -4
  154. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  155. package/build/esm/hooks/useControlledState.d.ts +3 -7
  156. package/build/esm/hooks/useControlledState.js +7 -2
  157. package/build/esm/hooks/useControlledState.js.map +1 -1
  158. package/build/esm/hooks/useFocusReturn.d.ts +1 -1
  159. package/build/esm/hooks/useFocusReturn.js +6 -6
  160. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  161. package/build/esm/hooks/useFocusState.d.ts +3 -3
  162. package/build/esm/hooks/useFocusState.js +13 -9
  163. package/build/esm/hooks/useFocusState.js.map +1 -1
  164. package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
  165. package/build/esm/hooks/useGestureHandlers.js +59 -63
  166. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  167. package/build/esm/hooks/useMeasure.d.ts +2 -2
  168. package/build/esm/hooks/useMeasure.js +13 -7
  169. package/build/esm/hooks/useMeasure.js.map +1 -1
  170. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  171. package/build/esm/hooks/useOnClickOutside.js +5 -4
  172. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  173. package/build/esm/hooks/useOnKeyDown.js +4 -3
  174. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  175. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  176. package/build/esm/hooks/useReducerMachine.js +13 -10
  177. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  178. package/build/esm/hooks/useRemoveBodyScroll.js +4 -4
  179. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  180. package/build/esm/hooks/useScope.d.ts +1 -1
  181. package/build/esm/hooks/useScope.js +10 -12
  182. package/build/esm/hooks/useScope.js.map +1 -1
  183. package/build/esm/hooks/useThrottle.js +10 -5
  184. package/build/esm/hooks/useThrottle.js.map +1 -1
  185. package/build/esm/utils/assignRef.d.ts +1 -1
  186. package/build/esm/utils/assignRef.js +7 -3
  187. package/build/esm/utils/assignRef.js.map +1 -1
  188. package/build/esm/utils/createSubscription.js +7 -5
  189. package/build/esm/utils/createSubscription.js.map +1 -1
  190. package/build/esm/utils/rubberBandClamp.js +5 -2
  191. package/build/esm/utils/rubberBandClamp.js.map +1 -1
  192. package/build/esm/utils/wrapEvent.d.ts +3 -3
  193. package/build/esm/utils/wrapEvent.js +7 -3
  194. package/build/esm/utils/wrapEvent.js.map +1 -1
  195. package/build/tsconfig-build.tsbuildinfo +1 -0
  196. package/build/tsconfig.tsbuildinfo +1 -1
  197. package/package.json +3 -3
  198. package/src/Accordion/Accordion.story.tsx +1 -0
  199. package/src/Accordion/Accordion.tsx +15 -7
  200. package/src/Accordion/AccordionBody.tsx +7 -8
  201. package/src/Accordion/AccordionHeader.tsx +35 -33
  202. package/src/Accordion/AccordionItem.tsx +15 -7
  203. package/src/Accordion/context.ts +5 -3
  204. package/src/CheckBox/CheckBox.tsx +6 -6
  205. package/src/ComboBox/ComboBox.story.tsx +5 -5
  206. package/src/ComboBox/Combobox.tsx +12 -17
  207. package/src/ComboBox/ComboboxButton.tsx +16 -15
  208. package/src/ComboBox/ComboboxInput.tsx +19 -10
  209. package/src/ComboBox/ComboboxLabel.tsx +5 -4
  210. package/src/ComboBox/ComboboxList.tsx +6 -6
  211. package/src/ComboBox/ComboboxOption.tsx +11 -7
  212. package/src/ComboBox/ComboboxPopover.tsx +14 -8
  213. package/src/ComboBox/context.ts +14 -12
  214. package/src/ComboBox/hooks.tsx +9 -11
  215. package/src/FocusLock/FocusLock.tsx +14 -7
  216. package/src/FocusLock/useFocusLock.ts +5 -3
  217. package/src/List/List.tsx +5 -5
  218. package/src/List/ListItem.tsx +5 -5
  219. package/src/Menu/Menu.story.tsx +7 -6
  220. package/src/Menu/Menu.tsx +16 -8
  221. package/src/Menu/MenuButton.tsx +15 -16
  222. package/src/Menu/MenuItem.tsx +15 -10
  223. package/src/Menu/MenuList.tsx +8 -12
  224. package/src/Menu/MenuPopover.tsx +7 -5
  225. package/src/Menu/context.ts +10 -4
  226. package/src/Modal/Modal.story.tsx +1 -0
  227. package/src/Modal/Modal.tsx +12 -6
  228. package/src/Modal/ModalBackdrop.tsx +15 -9
  229. package/src/Modal/NavDrawer.story.tsx +3 -3
  230. package/src/Popper/Popper.story.tsx +3 -4
  231. package/src/Popper/Popper.tsx +13 -12
  232. package/src/Popper/PopperArrow.tsx +5 -4
  233. package/src/Popper/context.ts +2 -1
  234. package/src/Portal/Portal.tsx +1 -1
  235. package/src/RadioButton/RadioButton.story.tsx +1 -0
  236. package/src/RadioButton/RadioButton.tsx +14 -7
  237. package/src/RadioButton/RadioGroup.tsx +14 -10
  238. package/src/RadioButton/context.ts +2 -4
  239. package/src/SkipNav/SkipNav.tsx +5 -5
  240. package/src/Spinner/Spinner.story.tsx +1 -0
  241. package/src/Spinner/Spinner.tsx +14 -9
  242. package/src/Spinner/SpinnerButton.tsx +12 -6
  243. package/src/Spinner/context.ts +2 -3
  244. package/src/Tabs/Tab.story.tsx +1 -0
  245. package/src/Tabs/Tab.tsx +16 -11
  246. package/src/Tabs/TabList.tsx +6 -5
  247. package/src/Tabs/TabPanel.tsx +6 -5
  248. package/src/Tabs/TabPanels.tsx +4 -4
  249. package/src/Tabs/Tabs.tsx +6 -7
  250. package/src/Tabs/context.ts +4 -4
  251. package/src/Tooltip/Tooltip.story.tsx +3 -2
  252. package/src/Tooltip/Tooltip.tsx +11 -9
  253. package/src/Tooltip/stateMachine.ts +1 -1
  254. package/src/Tooltip/useTooltip.ts +19 -10
  255. package/src/hooks/useAutoFocus.ts +3 -1
  256. package/src/hooks/useChildrenCounter.ts +2 -1
  257. package/src/hooks/useControlledState.ts +7 -8
  258. package/src/hooks/useFocusReturn.ts +2 -1
  259. package/src/hooks/useFocusState.ts +4 -2
  260. package/src/hooks/useGestureHandlers.ts +11 -7
  261. package/src/hooks/useMeasure.ts +2 -1
  262. package/src/hooks/useOnClickOutside.ts +2 -2
  263. package/src/hooks/useReducerMachine.ts +2 -1
  264. package/src/hooks/useScope.ts +2 -1
  265. package/src/utils/assignRef.ts +1 -1
  266. package/src/utils/wrapEvent.ts +4 -5
@@ -1,27 +1,25 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef, useRef, useEffect } from 'react';
4
4
  import { useComboBoxContext } from './context';
5
5
  import { getScope } from '../hooks';
6
6
  import { assignMultipleRefs } from '../utils';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export const ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, ref) {
9
- let {
10
- // when true, and the list opens again, the option with a matching value will be
11
- // automatically highleted.
12
- persistSelection = false,
13
- as: Comp = 'ul',
14
- innerAs
15
- } = _ref,
16
- props = _objectWithoutPropertiesLoose(_ref, ["persistSelection", "as", "innerAs"]);
8
+ export var ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, ref) {
9
+ var _ref$persistSelection = _ref.persistSelection,
10
+ persistSelection = _ref$persistSelection === void 0 ? false : _ref$persistSelection,
11
+ _ref$as = _ref.as,
12
+ Comp = _ref$as === void 0 ? 'ul' : _ref$as,
13
+ innerAs = _ref.innerAs,
14
+ props = _objectWithoutProperties(_ref, ["persistSelection", "as", "innerAs"]);
17
15
 
18
- const {
19
- persistSelectionRef,
20
- labelIdRef,
21
- listScope
22
- } = useComboBoxContext();
23
- const listRef = useRef();
24
- useEffect(() => {
16
+ var _useComboBoxContext = useComboBoxContext(),
17
+ persistSelectionRef = _useComboBoxContext.persistSelectionRef,
18
+ labelIdRef = _useComboBoxContext.labelIdRef,
19
+ listScope = _useComboBoxContext.listScope;
20
+
21
+ var listRef = useRef();
22
+ useEffect(function () {
25
23
  listScope.current = getScope(listRef);
26
24
  }, [listScope]);
27
25
  persistSelectionRef.current = persistSelection;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxList.tsx"],"names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,SAA7B,QAA8C,OAA9C;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,MAAMC,YAAY,gBAAGN,UAAU,CACpC,SAASM,YAAT,OASEC,GATF,EAUE;AAAA,MATA;AACE;AACA;AACAC,IAAAA,gBAAgB,GAAG,KAHrB;AAIEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,IAJb;AAKEC,IAAAA;AALF,GASA;AAAA,MAHKC,KAGL;;AACA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,UAAvB;AAAmCC,IAAAA;AAAnC,MAAiDZ,kBAAkB,EAAzE;AAEA,QAAMa,OAAO,GAAGf,MAAM,EAAtB;AACAC,EAAAA,SAAS,CAAC,MAAM;AACda,IAAAA,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;AACD,GAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;AAIAF,EAAAA,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;AAEA,sBACE,KAAC,IAAD,eACMI,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,IAAA,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;AAIE,gCAAyB,EAJ3B;AAKE,IAAA,IAAI,EAAC,SALP;AAME,uBAAiBF,UAAU,CAACG;AAN9B,KADF;AAUD,CA/BmC,CAA/B","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport type * as React from 'react';\nimport { useComboBoxContext } from './context';\nimport { getScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ComboboxListProps\n extends React.HTMLAttributes<HTMLUListElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n persistSelection?: boolean;\n children?: React.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"],"file":"ComboboxList.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxList.tsx"],"names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"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;AAAA,mCANEC,gBAMF;AAAA,MANEA,gBAMF,sCANqB,KAMrB;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,IAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,KAGL;;AAAA,4BACuDT,kBAAkB,EADzE;AAAA,MACQU,mBADR,uBACQA,mBADR;AAAA,MAC6BC,UAD7B,uBAC6BA,UAD7B;AAAA,MACyCC,SADzC,uBACyCA,SADzC;;AAGA,MAAMC,OAAO,GAAGf,MAAM,EAAtB;AACAC,EAAAA,SAAS,CAAC,YAAM;AACda,IAAAA,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;AACD,GAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;AAIAF,EAAAA,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;AAEA,sBACE,KAAC,IAAD,eACMI,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,IAAA,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;AAIE,gCAAyB,EAJ3B;AAKE,IAAA,IAAI,EAAC,SALP;AAME,uBAAiBF,UAAU,CAACG;AAN9B,KADF;AAUD,CA/BmC,CAA/B","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"],"file":"ComboboxList.js"}
@@ -1,11 +1,11 @@
1
- import type * as React from 'react';
2
- export interface ComboboxOptionProps extends React.LiHTMLAttributes<HTMLLIElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
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
5
  id: string;
6
6
  value: any;
7
7
  text?: string;
8
- onClick?: React.MouseEventHandler<HTMLLIElement>;
9
- children?: React.ReactNode;
8
+ onClick?: MouseEventHandler<HTMLLIElement>;
9
+ children?: ReactNode;
10
10
  }
11
- export declare const ComboboxOption: React.ForwardRefExoticComponent<ComboboxOptionProps & React.RefAttributes<HTMLLIElement>>;
11
+ export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
 
4
4
  /* eslint-disable @typescript-eslint/no-use-before-define */
5
5
  import { forwardRef, useEffect, useRef } from 'react';
@@ -8,30 +8,27 @@ import { wrapEvent } from '../utils/wrapEvent';
8
8
  import { useComboBoxContext } from './context';
9
9
  import { makeHash } from './makeHash';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref, ref) {
12
- let {
13
- children,
14
- id: idProp,
15
- value: valueProp,
16
- text: textProp,
17
- onClick,
18
- as: Comp = 'li',
19
- innerAs
20
- } = _ref,
21
- props = _objectWithoutPropertiesLoose(_ref, ["children", "id", "value", "text", "onClick", "as", "innerAs"]);
11
+ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref, ref) {
12
+ var children = _ref.children,
13
+ idProp = _ref.id,
14
+ valueProp = _ref.value,
15
+ textProp = _ref.text,
16
+ onClick = _ref.onClick,
17
+ _ref$as = _ref.as,
18
+ Comp = _ref$as === void 0 ? 'li' : _ref$as,
19
+ innerAs = _ref.innerAs,
20
+ props = _objectWithoutProperties(_ref, ["children", "id", "value", "text", "onClick", "as", "innerAs"]);
22
21
 
23
- const {
24
- onSelect,
25
- data: {
26
- navigationItem
27
- },
28
- transition,
29
- optionsRef
30
- } = useComboBoxContext();
31
- const transitionCleanupRef = useRef(transition);
32
- const isActiveRef = useRef(false);
33
- const value = valueProp;
34
- let text = textProp ? textProp : '';
22
+ var _useComboBoxContext = useComboBoxContext(),
23
+ onSelect = _useComboBoxContext.onSelect,
24
+ navigationItem = _useComboBoxContext.data.navigationItem,
25
+ transition = _useComboBoxContext.transition,
26
+ optionsRef = _useComboBoxContext.optionsRef;
27
+
28
+ var transitionCleanupRef = useRef(transition);
29
+ var isActiveRef = useRef(false);
30
+ var value = valueProp;
31
+ var text = textProp ? textProp : '';
35
32
 
36
33
  if (text.length === 0) {
37
34
  if (typeof valueProp === 'string' && valueProp.length > 0) {
@@ -41,14 +38,14 @@ export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_r
41
38
  }
42
39
  }
43
40
 
44
- const id = String(makeHash(idProp));
45
- useEffect(() => {
46
- const opts = optionsRef.current;
41
+ var id = String(makeHash(idProp));
42
+ useEffect(function () {
43
+ var opts = optionsRef.current;
47
44
  opts[id] = {
48
- value,
49
- text
45
+ value: value,
46
+ text: text
50
47
  };
51
- return () => {
48
+ return function () {
52
49
  delete opts[id];
53
50
  };
54
51
  }, [optionsRef, id, text, value]); // Keep updating this ref with the current
@@ -57,8 +54,8 @@ export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_r
57
54
 
58
55
  transitionCleanupRef.current = transition;
59
56
  isActiveRef.current = navigationItem === id;
60
- useEffect(() => {
61
- return () => {
57
+ useEffect(function () {
58
+ return function () {
62
59
  if (isActiveRef.current === true) {
63
60
  // clean up selections if this option is getting
64
61
  // unmounted and it was the currently selected item
@@ -67,10 +64,10 @@ export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_r
67
64
  };
68
65
  }, []);
69
66
 
70
- const handleClick = () => {
67
+ var handleClick = function handleClick() {
71
68
  onSelect && onSelect(text, id, value);
72
69
  transition(SELECT_WITH_CLICK, {
73
- text,
70
+ text: text,
74
71
  item: id
75
72
  });
76
73
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","ComboboxOption","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","undefined"],"mappings":";;;AAAA;AACA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAGA,SAASC,iBAAT,EAA4BC,eAA5B,QAAmD,SAAnD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,YAAzB;;AAaA,OAAO,MAAMC,cAAc,gBAAGR,UAAU,CACtC,SAASQ,cAAT,OAWEC,GAXF,EAYE;AAAA,MAXA;AACEC,IAAAA,QADF;AAEEC,IAAAA,EAAE,EAAEC,MAFN;AAGEC,IAAAA,KAAK,EAAEC,SAHT;AAIEC,IAAAA,IAAI,EAAEC,QAJR;AAKEC,IAAAA,OALF;AAMEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,IANb;AAOEC,IAAAA;AAPF,GAWA;AAAA,MAHKC,KAGL;;AACA,QAAM;AACJC,IAAAA,QADI;AAEJC,IAAAA,IAAI,EAAE;AAAEC,MAAAA;AAAF,KAFF;AAGJC,IAAAA,UAHI;AAIJC,IAAAA;AAJI,MAKFpB,kBAAkB,EALtB;AAMA,QAAMqB,oBAAoB,GAAGzB,MAAM,CAACuB,UAAD,CAAnC;AACA,QAAMG,WAAW,GAAG1B,MAAM,CAAC,KAAD,CAA1B;AAEA,QAAMW,KAAU,GAAGC,SAAnB;AACA,MAAIC,IAAY,GAAGC,QAAQ,GAAGA,QAAH,GAAc,EAAzC;;AAEA,MAAID,IAAI,CAACc,MAAL,KAAgB,CAApB,EAAuB;AACrB,QAAI,OAAOf,SAAP,KAAqB,QAArB,IAAiCA,SAAS,CAACe,MAAV,GAAmB,CAAxD,EAA2D;AACzDd,MAAAA,IAAI,GAAGD,SAAP;AACD,KAFD,MAEO;AACL,YAAM,IAAIgB,KAAJ,CAAU,qCAAV,CAAN;AACD;AACF;;AAED,QAAMnB,EAAE,GAAGoB,MAAM,CAACxB,QAAQ,CAACK,MAAD,CAAT,CAAjB;AAEAX,EAAAA,SAAS,CAAC,MAAM;AACd,UAAM+B,IAAI,GAAGN,UAAU,CAACO,OAAxB;AACAD,IAAAA,IAAI,CAACrB,EAAD,CAAJ,GAAW;AAAEE,MAAAA,KAAF;AAASE,MAAAA;AAAT,KAAX;AAEA,WAAO,MAAM;AACX,aAAOiB,IAAI,CAACrB,EAAD,CAAX;AACD,KAFD;AAGD,GAPQ,EAON,CAACe,UAAD,EAAaf,EAAb,EAAiBI,IAAjB,EAAuBF,KAAvB,CAPM,CAAT,CAvBA,CAgCA;AACA;AACA;;AACAc,EAAAA,oBAAoB,CAACM,OAArB,GAA+BR,UAA/B;AACAG,EAAAA,WAAW,CAACK,OAAZ,GAAsBT,cAAc,KAAKb,EAAzC;AAEAV,EAAAA,SAAS,CAAC,MAAM;AACd,WAAO,MAAM;AACX,UAAI2B,WAAW,CAACK,OAAZ,KAAwB,IAA5B,EAAkC;AAChC;AACA;AACAN,QAAAA,oBAAoB,CAACM,OAArB,CAA6B7B,eAA7B;AACD;AACF,KAND;AAOD,GARQ,EAQN,EARM,CAAT;;AAUA,QAAM8B,WAAW,GAAG,MAAM;AACxBZ,IAAAA,QAAQ,IAAIA,QAAQ,CAACP,IAAD,EAAOJ,EAAP,EAAWE,KAAX,CAApB;AACAY,IAAAA,UAAU,CAACtB,iBAAD,EAAoB;AAAEY,MAAAA,IAAF;AAAQoB,MAAAA,IAAI,EAAExB;AAAd,KAApB,CAAV;AACD,GAHD;;AAKA,sBACE,KAAC,IAAD,eACMU,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,kCAA2B,EAH7B;AAIE,IAAA,GAAG,EAAEX,GAJP;AAKE,IAAA,EAAE,EAAEE,EALN;AAME,IAAA,IAAI,EAAC,QANP;AAOE,qBAAeiB,WAAW,CAACK,OAP7B;AAQE,wBAAkBL,WAAW,CAACK,OAAZ,GAAsB,EAAtB,GAA2BG,SAR/C,CASE;AACA;AACA;AAXF;AAYE,IAAA,QAAQ,EAAC,IAZX;AAaE,IAAA,OAAO,EAAE/B,SAAS,CAACY,OAAD,EAAUiB,WAAV,CAbpB;AAAA,cAeGxB,QAAQ,IAAIK;AAff,KADF;AAmBD,CArFqC,CAAjC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport type * as React from 'react';\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport { useComboBoxContext } from './context';\nimport { makeHash } from './makeHash';\n\nexport interface ComboboxOptionProps\n extends React.LiHTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n id: string;\n value: any;\n text?: string;\n onClick?: React.MouseEventHandler<HTMLLIElement>;\n children?: React.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"],"file":"ComboboxOption.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"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"],"mappings":"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","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/wrapEvent';\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"],"file":"ComboboxOption.js"}
@@ -1,9 +1,9 @@
1
- import type * as React from 'react';
2
- export interface ComboboxPopoverProps extends React.HTMLAttributes<HTMLDivElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- onBlur?: React.FocusEventHandler<HTMLDivElement>;
6
- onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
7
- children?: React.ReactNode;
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
8
  }
9
- export declare const ComboboxPopover: React.ForwardRefExoticComponent<ComboboxPopoverProps & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const ComboboxPopover: import("react").ForwardRefExoticComponent<ComboboxPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,27 +1,25 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
4
  import { useKeyDown, useBlur } from './hooks';
5
5
  import { wrapEvent } from '../utils/wrapEvent';
6
6
  import { assignMultipleRefs } from '../utils/assignRef';
7
7
  import { useComboBoxContext } from './context';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export const ComboboxPopover = /*#__PURE__*/forwardRef(function ComboboxPopover(_ref, forwardedRef) {
10
- let {
11
- // wrapped events
12
- onKeyDown,
13
- onBlur,
14
- as: Comp = 'div',
15
- innerAs
16
- } = _ref,
17
- props = _objectWithoutPropertiesLoose(_ref, ["onKeyDown", "onBlur", "as", "innerAs"]);
9
+ export var ComboboxPopover = /*#__PURE__*/forwardRef(function ComboboxPopover(_ref, forwardedRef) {
10
+ var onKeyDown = _ref.onKeyDown,
11
+ onBlur = _ref.onBlur,
12
+ _ref$as = _ref.as,
13
+ Comp = _ref$as === void 0 ? 'div' : _ref$as,
14
+ innerAs = _ref.innerAs,
15
+ props = _objectWithoutProperties(_ref, ["onKeyDown", "onBlur", "as", "innerAs"]);
18
16
 
19
- const {
20
- popoverRef,
21
- isVisible
22
- } = useComboBoxContext();
23
- const handleKeyDown = useKeyDown();
24
- const handleBlur = useBlur(); // Instead of conditionally rendering the popover we use the `hidden` prop
17
+ var _useComboBoxContext = useComboBoxContext(),
18
+ popoverRef = _useComboBoxContext.popoverRef,
19
+ isVisible = _useComboBoxContext.isVisible;
20
+
21
+ var handleKeyDown = useKeyDown();
22
+ var handleBlur = useBlur(); // Instead of conditionally rendering the popover we use the `hidden` prop
25
23
  // because we don't want to unmount on close (from escape or onSelect). If
26
24
  // we unmounted, then we'd lose the optionsRef and the user wouldn't be able
27
25
  // to use the arrow keys to pop the list back open. However, the developer
@@ -29,7 +27,7 @@ export const ComboboxPopover = /*#__PURE__*/forwardRef(function ComboboxPopover(
29
27
  // mount/unmount based on the app's own data (like results.length or
30
28
  // whatever).
31
29
 
32
- const hidden = !isVisible;
30
+ var hidden = !isVisible;
33
31
  return /*#__PURE__*/_jsx(Comp, _extends({}, props, {
34
32
  as: innerAs,
35
33
  "data-reach-combobox-popover": "",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxPopover.tsx"],"names":["forwardRef","useKeyDown","useBlur","wrapEvent","assignMultipleRefs","useComboBoxContext","ComboboxPopover","forwardedRef","onKeyDown","onBlur","as","Comp","innerAs","props","popoverRef","isVisible","handleKeyDown","handleBlur","hidden"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,SAApC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAWA,OAAO,MAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAUEC,YAVF,EAWE;AAAA,MAVA;AACE;AACAC,IAAAA,SAFF;AAGEC,IAAAA,MAHF;AAKEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KALb;AAMEC,IAAAA;AANF,GAUA;AAAA,MAHKC,KAGL;;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BV,kBAAkB,EAApD;AACA,QAAMW,aAAa,GAAGf,UAAU,EAAhC;AACA,QAAMgB,UAAU,GAAGf,OAAO,EAA1B,CAHA,CAKA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMgB,MAAM,GAAG,CAACH,SAAhB;AAEA,sBACE,KAAC,IAAD,eACMF,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,mCAA4B,EAH9B;AAIE,IAAA,GAAG,EAAER,kBAAkB,CAACU,UAAD,EAAaP,YAAb,CAJzB;AAKE,IAAA,SAAS,EAAEJ,SAAS,CAACK,SAAD,EAAYQ,aAAZ,CALtB;AAME,IAAA,MAAM,EAAEb,SAAS,CAACM,MAAD,EAASQ,UAAT,CANnB;AAOE,IAAA,MAAM,EAAEC,MAPV,CAQE;AACA;AATF;AAUE,IAAA,QAAQ,EAAC;AAVX,KADF;AAcD,CAxCsC,CAAlC","sourcesContent":["import { forwardRef } from 'react';\nimport type * as React from 'react';\nimport { useKeyDown, useBlur } from './hooks';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxPopoverProps\n extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onBlur?: React.FocusEventHandler<HTMLDivElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n children?: React.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"],"file":"ComboboxPopover.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxPopover.tsx"],"names":["forwardRef","useKeyDown","useBlur","wrapEvent","assignMultipleRefs","useComboBoxContext","ComboboxPopover","forwardedRef","onKeyDown","onBlur","as","Comp","innerAs","props","popoverRef","isVisible","handleKeyDown","handleBlur","hidden"],"mappings":";;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,SAApC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAUA,OAAO,IAAMC,eAAe,gBAAGN,UAAU,CACvC,SAASM,eAAT,OAUEC,YAVF,EAWE;AAAA,MAREC,SAQF,QAREA,SAQF;AAAA,MAPEC,MAOF,QAPEA,MAOF;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,KAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,KAGL;;AAAA,4BACkCR,kBAAkB,EADpD;AAAA,MACQS,UADR,uBACQA,UADR;AAAA,MACoBC,SADpB,uBACoBA,SADpB;;AAEA,MAAMC,aAAa,GAAGf,UAAU,EAAhC;AACA,MAAMgB,UAAU,GAAGf,OAAO,EAA1B,CAHA,CAKA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMgB,MAAM,GAAG,CAACH,SAAhB;AAEA,sBACE,KAAC,IAAD,eACMF,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,mCAA4B,EAH9B;AAIE,IAAA,GAAG,EAAER,kBAAkB,CAACU,UAAD,EAAaP,YAAb,CAJzB;AAKE,IAAA,SAAS,EAAEJ,SAAS,CAACK,SAAD,EAAYQ,aAAZ,CALtB;AAME,IAAA,MAAM,EAAEb,SAAS,CAACM,MAAD,EAASQ,UAAT,CANnB;AAOE,IAAA,MAAM,EAAEC,MAPV,CAQE;AACA;AATF;AAUE,IAAA,QAAQ,EAAC;AAVX,KADF;AAcD,CAxCsC,CAAlC","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/wrapEvent';\nimport { assignMultipleRefs } from '../utils/assignRef';\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"],"file":"ComboboxPopover.js"}
@@ -1,14 +1,14 @@
1
- /// <reference types="react" />
2
- import { ActionTypes, StateTypes, ReducerState } from './hooks';
3
- import { SelectEventHandler } from './Combobox';
4
- import { Scope } from '../hooks';
1
+ import type { MutableRefObject } from 'react';
2
+ import type { ActionTypes, StateTypes, ReducerState } from './hooks';
3
+ import type { SelectEventHandler } from './Combobox';
4
+ import type { Scope } from '../hooks';
5
5
  export interface ComboBoxContextProps {
6
6
  data: Omit<ReducerState, 'state'>;
7
- inputRef: React.MutableRefObject<HTMLInputElement | null>;
8
- popoverRef: React.MutableRefObject<HTMLDivElement | null>;
9
- buttonRef: React.MutableRefObject<HTMLButtonElement | null>;
7
+ inputRef: MutableRefObject<HTMLInputElement | null>;
8
+ popoverRef: MutableRefObject<HTMLDivElement | null>;
9
+ buttonRef: MutableRefObject<HTMLButtonElement | null>;
10
10
  onSelect?: SelectEventHandler;
11
- optionsRef: React.MutableRefObject<{
11
+ optionsRef: MutableRefObject<{
12
12
  [itemId: string]: {
13
13
  value: string | unknown;
14
14
  text: string;
@@ -17,11 +17,11 @@ export interface ComboBoxContextProps {
17
17
  listScope: Scope<HTMLElement>;
18
18
  state: StateTypes;
19
19
  transition: (action: ActionTypes, payload?: any) => void;
20
- listboxIdRef: React.MutableRefObject<string | undefined>;
21
- labelIdRef: React.MutableRefObject<string | undefined>;
22
- autocompletePropRef: React.MutableRefObject<boolean>;
23
- persistSelectionRef: React.MutableRefObject<boolean>;
24
- clearOnEscapeRef: React.MutableRefObject<boolean>;
20
+ listboxIdRef: MutableRefObject<string | undefined>;
21
+ labelIdRef: MutableRefObject<string | undefined>;
22
+ autocompletePropRef: MutableRefObject<boolean>;
23
+ persistSelectionRef: MutableRefObject<boolean>;
24
+ clearOnEscapeRef: MutableRefObject<boolean>;
25
25
  isVisible: boolean;
26
26
  openOnFocus: boolean;
27
27
  selectOnBlur: boolean;
@@ -1,7 +1,8 @@
1
1
  import { createContext, useContext } from 'react';
2
- const comboboxContext = /*#__PURE__*/createContext(null);
3
- export const {
4
- Provider: ComboBoxProvider
5
- } = comboboxContext;
6
- export const useComboBoxContext = () => useContext(comboboxContext);
2
+ var comboboxContext = /*#__PURE__*/createContext(null);
3
+ var ComboBoxProvider = comboboxContext.Provider;
4
+ export { ComboBoxProvider };
5
+ export var useComboBoxContext = function useComboBoxContext() {
6
+ return useContext(comboboxContext);
7
+ };
7
8
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/context.ts"],"names":["createContext","useContext","comboboxContext","Provider","ComboBoxProvider","useComboBoxContext"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AA8BA,MAAMC,eAAe,gBAAGF,aAAa,CAAuB,IAAvB,CAArC;AACA,OAAO,MAAM;AAAEG,EAAAA,QAAQ,EAAEC;AAAZ,IAAiCF,eAAvC;AACP,OAAO,MAAMG,kBAAkB,GAAG,MAAMJ,UAAU,CAACC,eAAD,CAA3C","sourcesContent":["import { createContext, useContext } from 'react';\nimport { ActionTypes, StateTypes, ReducerState } from './hooks';\nimport { SelectEventHandler } from './Combobox';\nimport { Scope } from '../hooks';\n\nexport interface ComboBoxContextProps {\n data: Omit<ReducerState, 'state'>;\n inputRef: React.MutableRefObject<HTMLInputElement | null>;\n popoverRef: React.MutableRefObject<HTMLDivElement | null>;\n buttonRef: React.MutableRefObject<HTMLButtonElement | null>;\n onSelect?: SelectEventHandler;\n optionsRef: React.MutableRefObject<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>;\n listScope: Scope<HTMLElement>;\n state: StateTypes;\n transition: (action: ActionTypes, payload?: any) => void;\n listboxIdRef: React.MutableRefObject<string | undefined>;\n labelIdRef: React.MutableRefObject<string | undefined>;\n autocompletePropRef: React.MutableRefObject<boolean>;\n persistSelectionRef: React.MutableRefObject<boolean>;\n clearOnEscapeRef: React.MutableRefObject<boolean>;\n isVisible: boolean;\n openOnFocus: boolean;\n selectOnBlur: boolean;\n}\n\nconst comboboxContext = createContext<ComboBoxContextProps>(null as any);\nexport const { Provider: ComboBoxProvider } = comboboxContext;\nexport const useComboBoxContext = () => useContext(comboboxContext);\n"],"file":"context.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/context.ts"],"names":["createContext","useContext","comboboxContext","ComboBoxProvider","Provider","useComboBoxContext"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AA+BA,IAAMC,eAAe,gBAAGF,aAAa,CAAuB,IAAvB,CAArC;IACyBG,gB,GAAqBD,e,CAA/BE,Q;;AACf,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,SAAMJ,UAAU,CAACC,eAAD,CAAhB;AAAA,CAA3B","sourcesContent":["import type { MutableRefObject } from 'react';\nimport { createContext, useContext } from 'react';\n\nimport type { ActionTypes, StateTypes, ReducerState } from './hooks';\nimport type { SelectEventHandler } from './Combobox';\nimport type { Scope } from '../hooks';\n\nexport interface ComboBoxContextProps {\n data: Omit<ReducerState, 'state'>;\n inputRef: MutableRefObject<HTMLInputElement | null>;\n popoverRef: MutableRefObject<HTMLDivElement | null>;\n buttonRef: MutableRefObject<HTMLButtonElement | null>;\n onSelect?: SelectEventHandler;\n optionsRef: MutableRefObject<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>;\n listScope: Scope<HTMLElement>;\n state: StateTypes;\n transition: (action: ActionTypes, payload?: any) => void;\n listboxIdRef: MutableRefObject<string | undefined>;\n labelIdRef: MutableRefObject<string | undefined>;\n autocompletePropRef: MutableRefObject<boolean>;\n persistSelectionRef: MutableRefObject<boolean>;\n clearOnEscapeRef: MutableRefObject<boolean>;\n isVisible: boolean;\n openOnFocus: boolean;\n selectOnBlur: boolean;\n}\n\nconst comboboxContext = createContext<ComboBoxContextProps>(null as any);\nexport const { Provider: ComboBoxProvider } = comboboxContext;\nexport const useComboBoxContext = () => useContext(comboboxContext);\n"],"file":"context.js"}
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- import { StateChart as GenericStateChart, StateMachineState } from '../hooks/useReducerMachine';
1
+ import type { KeyboardEvent, MutableRefObject } from 'react';
2
+ import type { StateChart as GenericStateChart, StateMachineState } from '../hooks/useReducerMachine';
3
3
  export declare const IDLE = "IDLE";
4
4
  declare const SUGGESTING = "SUGGESTING";
5
5
  export declare const NAVIGATING = "NAVIGATING";
@@ -31,7 +31,7 @@ interface ActionObject {
31
31
  }
32
32
  export declare function comboboxReducer(data: Readonly<ReducerState>, action: ActionObject): ReducerState;
33
33
  export declare const isVisible: (state: any) => boolean;
34
- export declare function useFocusManagement(lastActionType: ActionTypes, inputRef: React.MutableRefObject<HTMLInputElement | null>): void;
35
- export declare function useKeyDown(): (event: React.KeyboardEvent<any>) => void;
34
+ export declare function useFocusManagement(lastActionType: ActionTypes, inputRef: MutableRefObject<HTMLInputElement | null>): void;
35
+ export declare function useKeyDown(): (event: KeyboardEvent<any>) => void;
36
36
  export declare function useBlur(): () => void;
37
37
  export {};