@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,50 +1,48 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import { forwardRef, useRef, useMemo, useId } from 'react';
4
5
  import { stateChart, comboboxReducer, isVisible, INIT } from './hooks';
5
6
  import { ComboBoxProvider } from './context';
6
7
  import { useReducerMachine } from '../hooks/useReducerMachine';
7
8
  import { getScope } from '../hooks';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export const Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
10
- let {
11
- // Called whenever the user selects an item from the list
12
- onSelect,
13
- // opens the list when the input receives focused (but only if there are
14
- // items in the list)
15
- openOnFocus = false,
16
- // if set to true, it will select an item after blurring
17
- selectOnBlur = false,
18
- children,
19
- as: Comp = 'div',
20
- innerAs
21
- } = _ref,
22
- rest = _objectWithoutPropertiesLoose(_ref, ["onSelect", "openOnFocus", "selectOnBlur", "children", "as", "innerAs"]);
10
+ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
11
+ var onSelect = _ref.onSelect,
12
+ _ref$openOnFocus = _ref.openOnFocus,
13
+ openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
14
+ _ref$selectOnBlur = _ref.selectOnBlur,
15
+ selectOnBlur = _ref$selectOnBlur === void 0 ? false : _ref$selectOnBlur,
16
+ children = _ref.children,
17
+ _ref$as = _ref.as,
18
+ Comp = _ref$as === void 0 ? 'div' : _ref$as,
19
+ innerAs = _ref.innerAs,
20
+ rest = _objectWithoutProperties(_ref, ["onSelect", "openOnFocus", "selectOnBlur", "children", "as", "innerAs"]);
23
21
 
24
22
  // We store the values of all the ComboboxOptions on this ref. This makes it
25
23
  // possible to perform the keyboard navigation from the input on the list. We
26
24
  // manipulate this array through context so that we don't have to enforce a
27
25
  // parent/child relationship between ComboboxList and ComboboxOption.
28
- const optionsRef = useRef({});
29
- const listScope = useRef(getScope({
26
+ var optionsRef = useRef({});
27
+ var listScope = useRef(getScope({
30
28
  current: null
31
29
  })); // Need this to focus it
32
30
 
33
- const inputRef = useRef(null);
34
- const popoverRef = useRef(null);
35
- const buttonRef = useRef(null); // When <ComboboxInput autocomplete={false} /> we don't want cycle back to
31
+ var inputRef = useRef(null);
32
+ var popoverRef = useRef(null);
33
+ var buttonRef = useRef(null); // When <ComboboxInput autocomplete={false} /> we don't want cycle back to
36
34
  // the user's value while navigating (because it's always the user's value),
37
35
  // but we need to know this in useKeyDown which is far away from the prop
38
36
  // here, so we do something sneaky and write it to this ref on context so we
39
37
  // can use it anywhere else 😛. Another new trick for me and I'm excited
40
38
  // about this one too!
41
39
 
42
- const autocompletePropRef = useRef(false);
43
- const persistSelectionRef = useRef(false);
44
- const clearOnEscapeRef = useRef(false);
45
- const listboxIdRef = useRef();
46
- const labelIdRef = useRef();
47
- const defaultData = {
40
+ var autocompletePropRef = useRef(false);
41
+ var persistSelectionRef = useRef(false);
42
+ var clearOnEscapeRef = useRef(false);
43
+ var listboxIdRef = useRef();
44
+ var labelIdRef = useRef();
45
+ var defaultData = {
48
46
  // initial state
49
47
  state: stateChart.initial,
50
48
  // the value the user has typed, we derived this also when the developer is
@@ -58,28 +56,36 @@ export const Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
58
56
  // the last submitted action
59
57
  lastActionType: INIT
60
58
  };
61
- const [state, data, transition] = useReducerMachine(stateChart, comboboxReducer, defaultData);
59
+
60
+ var _useReducerMachine = useReducerMachine(stateChart, comboboxReducer, defaultData),
61
+ _useReducerMachine2 = _slicedToArray(_useReducerMachine, 3),
62
+ state = _useReducerMachine2[0],
63
+ data = _useReducerMachine2[1],
64
+ transition = _useReducerMachine2[2];
65
+
62
66
  listboxIdRef.current = useId();
63
67
  labelIdRef.current = useId();
64
- const context = useMemo(() => ({
65
- data,
66
- inputRef,
67
- popoverRef,
68
- buttonRef,
69
- onSelect,
70
- optionsRef,
71
- listScope,
72
- state,
73
- transition,
74
- listboxIdRef,
75
- labelIdRef,
76
- autocompletePropRef,
77
- persistSelectionRef,
78
- clearOnEscapeRef,
79
- isVisible: isVisible(state),
80
- openOnFocus,
81
- selectOnBlur
82
- }), [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
68
+ var context = useMemo(function () {
69
+ return {
70
+ data: data,
71
+ inputRef: inputRef,
72
+ popoverRef: popoverRef,
73
+ buttonRef: buttonRef,
74
+ onSelect: onSelect,
75
+ optionsRef: optionsRef,
76
+ listScope: listScope,
77
+ state: state,
78
+ transition: transition,
79
+ listboxIdRef: listboxIdRef,
80
+ labelIdRef: labelIdRef,
81
+ autocompletePropRef: autocompletePropRef,
82
+ persistSelectionRef: persistSelectionRef,
83
+ clearOnEscapeRef: clearOnEscapeRef,
84
+ isVisible: isVisible(state),
85
+ openOnFocus: openOnFocus,
86
+ selectOnBlur: selectOnBlur
87
+ };
88
+ }, [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
83
89
  return /*#__PURE__*/_jsx(ComboBoxProvider, {
84
90
  value: context,
85
91
  children: /*#__PURE__*/_jsx(Comp, _extends({}, rest, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/Combobox.tsx"],"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"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,KAAtC,QAAmD,OAAnD;AAEA,SACEC,UADF,EAEEC,eAFF,EAGEC,SAHF,EAIEC,IAJF,QAMO,SANP;AAOA,SAASC,gBAAT,QAAuD,WAAvD;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AACA,SAAgBC,QAAhB,QAAgC,UAAhC;;AAoBA,OAAO,MAAMC,QAAQ,gBAAGX,UAAU,CAChC,SAASW,QAAT,OAiBEC,GAjBF,EAkBE;AAAA,MAjBA;AACE;AACAC,IAAAA,QAFF;AAIE;AACA;AACAC,IAAAA,WAAW,GAAG,KANhB;AAQE;AACAC,IAAAA,YAAY,GAAG,KATjB;AAWEC,IAAAA,QAXF;AAYEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KAZb;AAaEC,IAAAA;AAbF,GAiBA;AAAA,MAHKC,IAGL;;AACA;AACA;AACA;AACA;AACA,QAAMC,UAAU,GAAGpB,MAAM,CAKtB,EALsB,CAAzB;AAOA,QAAMqB,SAA6B,GAAGrB,MAAM,CAACS,QAAQ,CAAC;AAAEa,IAAAA,OAAO,EAAE;AAAX,GAAD,CAAT,CAA5C,CAZA,CAcA;;AACA,QAAMC,QAAQ,GAAGvB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,IAAAA,mBAZ2B;AAa3BC,IAAAA,mBAb2B;AAc3BC,IAAAA,gBAd2B;AAe3BvB,IAAAA,SAAS,EAAEA,SAAS,CAAC2B,KAAD,CAfO;AAgB3BnB,IAAAA,WAhB2B;AAiB3BC,IAAAA;AAjB2B,GAA7B,CADqB,EAoBrB,CAACwB,IAAD,EAAO1B,QAAP,EAAiBS,SAAjB,EAA4BW,KAA5B,EAAmCO,UAAnC,EAA+C1B,WAA/C,EAA4DC,YAA5D,CApBqB,CAAvB;AAuBA,sBACE,KAAC,gBAAD;AAAkB,IAAA,KAAK,EAAE0B,OAAzB;AAAA,2BACE,KAAC,IAAD,eACMrB,IADN;AAEE,MAAA,EAAE,EAAED,OAFN;AAGE,6BAAoB,EAHtB;AAIE,MAAA,GAAG,EAAEP,GAJP;AAKE,MAAA,IAAI,EAAC,UALP;AAME,uBAAc,SANhB;AAOE,mBAAWkB,YAAY,CAACP,OAP1B;AAQE,uBAAekB,OAAO,CAACnC,SARzB;AAAA,gBAUGU;AAVH;AADF,IADF;AAgBD,CAxH+B,CAA3B","sourcesContent":["import { forwardRef, useRef, useMemo, useId } from 'react';\nimport type * as React from 'react';\nimport {\n stateChart,\n comboboxReducer,\n isVisible,\n INIT,\n ActionTypes,\n} from './hooks';\nimport { ComboBoxProvider, ComboBoxContextProps } from './context';\nimport { useReducerMachine } from '../hooks/useReducerMachine';\nimport { Scope, getScope } from '../hooks';\n\nexport type SelectEventHandler = (\n text: string,\n itemId: string,\n obj: any\n) => void;\n\nexport type ComboboxProps = Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onSelect'\n> & {\n onSelect?: SelectEventHandler;\n openOnFocus?: boolean;\n selectOnBlur?: boolean;\n children?: React.ReactNode;\n as?: React.ElementType<any>;\n innerAs?: React.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"],"file":"Combobox.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/Combobox.tsx"],"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"],"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;AAAA,MAfEC,QAeF,QAfEA,QAeF;AAAA,8BAXEC,WAWF;AAAA,MAXEA,WAWF,iCAXgB,KAWhB;AAAA,+BAREC,YAQF;AAAA,MAREA,YAQF,kCARiB,KAQjB;AAAA,MANEC,QAMF,QANEA,QAMF;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,KAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,IAGL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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"],"file":"Combobox.js"}
@@ -1,9 +1,9 @@
1
- import type * as React from 'react';
2
- export interface ComboboxButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
6
- onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;
7
- children?: React.ReactNode;
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
8
  }
9
- export declare const ComboboxButton: React.ForwardRefExoticComponent<ComboboxButtonProps & React.RefAttributes<HTMLButtonElement>>;
9
+ export declare const ComboboxButton: import("react").ForwardRefExoticComponent<ComboboxButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,32 +1,31 @@
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 { useComboBoxContext } from './context';
5
5
  import { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';
6
6
  import { wrapEvent } from '../utils/wrapEvent';
7
7
  import { assignMultipleRefs } from '../utils/assignRef';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export const ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
10
- let {
11
- as: Comp = 'button',
12
- innerAs,
13
- onClick,
14
- onKeyDown
15
- } = _ref,
16
- props = _objectWithoutPropertiesLoose(_ref, ["as", "innerAs", "onClick", "onKeyDown"]);
9
+ export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
10
+ var _ref$as = _ref.as,
11
+ Comp = _ref$as === void 0 ? 'button' : _ref$as,
12
+ innerAs = _ref.innerAs,
13
+ onClick = _ref.onClick,
14
+ onKeyDown = _ref.onKeyDown,
15
+ props = _objectWithoutProperties(_ref, ["as", "innerAs", "onClick", "onKeyDown"]);
17
16
 
18
- const {
19
- transition,
20
- data,
21
- state,
22
- buttonRef,
23
- listboxIdRef,
24
- isVisible
25
- } = useComboBoxContext();
26
- const handleKeyDown = useKeyDown();
17
+ var _useComboBoxContext = useComboBoxContext(),
18
+ transition = _useComboBoxContext.transition,
19
+ data = _useComboBoxContext.data,
20
+ state = _useComboBoxContext.state,
21
+ buttonRef = _useComboBoxContext.buttonRef,
22
+ listboxIdRef = _useComboBoxContext.listboxIdRef,
23
+ isVisible = _useComboBoxContext.isVisible;
27
24
 
28
- const handleClick = () => {
29
- const payload = {
25
+ var handleKeyDown = useKeyDown();
26
+
27
+ var handleClick = function handleClick() {
28
+ var payload = {
30
29
  item: data.navigationItem
31
30
  };
32
31
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"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"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,oBAAnC;;AAWA,OAAO,MAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;AAAA,MAFA;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,QAAb;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA,OAAhC;AAAyCC,IAAAA;AAAzC,GAEA;AAAA,MAFuDC,KAEvD;;AACA,QAAM;AACJC,IAAAA,UADI;AAEJC,IAAAA,IAFI;AAGJC,IAAAA,KAHI;AAIJC,IAAAA,SAJI;AAKJC,IAAAA,YALI;AAMJC,IAAAA;AANI,MAOFpB,kBAAkB,EAPtB;AASA,QAAMqB,aAAa,GAAGpB,UAAU,EAAhC;;AAEA,QAAMqB,WAAW,GAAG,MAAM;AACxB,UAAMC,OAAO,GAAG;AACdC,MAAAA,IAAI,EAAER,IAAI,CAACS;AADG,KAAhB;;AAIA,QAAIR,KAAK,KAAKf,IAAd,EAAoB;AAClBa,MAAAA,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;AACD,KAFD,MAEO;AACLR,MAAAA,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;AACD;AACF,GAVD;;AAYA,sBACE,KAAC,IAAD;AACE,IAAA,EAAE,EAAEZ,OADN;AAEE,kCAA2B,EAF7B;AAGE,qBAAeQ,YAAY,CAACO,OAH9B;AAIE,qBAAc,SAJhB;AAKE,qBAAeN,SALjB;AAME,IAAA,GAAG,EAAEd,kBAAkB,CAACE,GAAD,EAAMU,SAAN,CANzB;AAOE,IAAA,OAAO,EAAEb,SAAS,CAACO,OAAD,EAAUU,WAAV,CAPpB;AAQE,IAAA,SAAS,EAAEjB,SAAS,CAACQ,SAAD,EAAYQ,aAAZ;AARtB,KASMP,KATN,EADF;AAaD,CA3CuC,CAAjC","sourcesContent":["import { forwardRef } from 'react';\nimport type * as React from 'react';\nimport { useComboBoxContext } from './context';\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport { assignMultipleRefs } from '../utils/assignRef';\n\nexport interface ComboboxButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n children?: React.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 {\n transition,\n data,\n state,\n buttonRef,\n listboxIdRef,\n 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"],"file":"ComboboxButton.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"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"],"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,oBAA1B;AACA,SAASC,kBAAT,QAAmC,oBAAnC;;AAWA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;AAAA,qBAFEC,EAEF;AAAA,MAFMC,IAEN,wBAFa,QAEb;AAAA,MAFuBC,OAEvB,QAFuBA,OAEvB;AAAA,MAFgCC,OAEhC,QAFgCA,OAEhC;AAAA,MAFyCC,SAEzC,QAFyCA,SAEzC;AAAA,MAFuDC,KAEvD;;AAAA,4BAEEd,kBAAkB,EAFpB;AAAA,MACQe,UADR,uBACQA,UADR;AAAA,MACoBC,IADpB,uBACoBA,IADpB;AAAA,MAC0BC,KAD1B,uBAC0BA,KAD1B;AAAA,MACiCC,SADjC,uBACiCA,SADjC;AAAA,MAC4CC,YAD5C,uBAC4CA,YAD5C;AAAA,MAC0DC,SAD1D,uBAC0DA,SAD1D;;AAIA,MAAMC,aAAa,GAAGpB,UAAU,EAAhC;;AAEA,MAAMqB,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxB,QAAMC,OAAO,GAAG;AACdC,MAAAA,IAAI,EAAER,IAAI,CAACS;AADG,KAAhB;;AAIA,QAAIR,KAAK,KAAKf,IAAd,EAAoB;AAClBa,MAAAA,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;AACD,KAFD,MAEO;AACLR,MAAAA,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;AACD;AACF,GAVD;;AAYA,sBACE,KAAC,IAAD;AACE,IAAA,EAAE,EAAEZ,OADN;AAEE,kCAA2B,EAF7B;AAGE,qBAAeQ,YAAY,CAACO,OAH9B;AAIE,qBAAc,SAJhB;AAKE,qBAAeN,SALjB;AAME,IAAA,GAAG,EAAEd,kBAAkB,CAACE,GAAD,EAAMU,SAAN,CANzB;AAOE,IAAA,OAAO,EAAEb,SAAS,CAACO,OAAD,EAAUU,WAAV,CAPpB;AAQE,IAAA,SAAS,EAAEjB,SAAS,CAACQ,SAAD,EAAYQ,aAAZ;AARtB,KASMP,KATN,EADF;AAaD,CArCuC,CAAjC","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/wrapEvent';\nimport { assignMultipleRefs } from '../utils/assignRef';\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"],"file":"ComboboxButton.js"}
@@ -1,17 +1,17 @@
1
- import type * as React from 'react';
2
- export interface ComboboxInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
1
+ import type { ChangeEventHandler, ElementType, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
2
+ export interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  clearOnEscape?: boolean;
4
4
  selectOnClick?: boolean;
5
5
  autocomplete?: boolean;
6
6
  defaultValue?: string;
7
7
  value?: string;
8
- onClick?: React.MouseEventHandler<HTMLInputElement>;
9
- onChange?: React.ChangeEventHandler<HTMLInputElement>;
10
- onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
11
- onBlur?: React.FocusEventHandler<HTMLInputElement>;
12
- onFocus?: React.FocusEventHandler<HTMLInputElement>;
13
- as?: React.ElementType<any>;
14
- innerAs?: React.ElementType<any>;
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
15
  id?: string;
16
16
  }
17
- export declare const ComboboxInput: React.ForwardRefExoticComponent<ComboboxInputProps & React.RefAttributes<HTMLInputElement>>;
17
+ export declare const ComboboxInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,54 +1,54 @@
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, useEffect, useRef } from 'react';
4
4
  import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
5
5
  import { assignMultipleRefs, wrapEvent } from '../utils';
6
6
  import { useComboBoxContext } from './context';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
9
- let {
10
- as: Comp = 'input',
11
- innerAs,
12
- selectOnClick = false,
13
- autocomplete = true,
14
- clearOnEscape = false,
15
- // wrapped events
16
- onClick,
17
- onChange,
18
- onKeyDown,
19
- onBlur,
20
- onFocus,
21
- id: preferredId,
22
- defaultValue = '',
23
- // might be controlled
24
- value: controlledValue
25
- } = _ref,
26
- props = _objectWithoutPropertiesLoose(_ref, ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"]);
8
+ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
9
+ var _ref$as = _ref.as,
10
+ Comp = _ref$as === void 0 ? 'input' : _ref$as,
11
+ innerAs = _ref.innerAs,
12
+ _ref$selectOnClick = _ref.selectOnClick,
13
+ selectOnClick = _ref$selectOnClick === void 0 ? false : _ref$selectOnClick,
14
+ _ref$autocomplete = _ref.autocomplete,
15
+ autocomplete = _ref$autocomplete === void 0 ? true : _ref$autocomplete,
16
+ _ref$clearOnEscape = _ref.clearOnEscape,
17
+ clearOnEscape = _ref$clearOnEscape === void 0 ? false : _ref$clearOnEscape,
18
+ onClick = _ref.onClick,
19
+ onChange = _ref.onChange,
20
+ onKeyDown = _ref.onKeyDown,
21
+ onBlur = _ref.onBlur,
22
+ onFocus = _ref.onFocus,
23
+ preferredId = _ref.id,
24
+ _ref$defaultValue = _ref.defaultValue,
25
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
26
+ controlledValue = _ref.value,
27
+ props = _objectWithoutProperties(_ref, ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"]);
28
+
29
+ var _useComboBoxContext = useComboBoxContext(),
30
+ _useComboBoxContext$d = _useComboBoxContext.data,
31
+ navigationItem = _useComboBoxContext$d.navigationItem,
32
+ text = _useComboBoxContext$d.text,
33
+ lastActionType = _useComboBoxContext$d.lastActionType,
34
+ inputRef = _useComboBoxContext.inputRef,
35
+ state = _useComboBoxContext.state,
36
+ transition = _useComboBoxContext.transition,
37
+ listboxIdRef = _useComboBoxContext.listboxIdRef,
38
+ autocompletePropRef = _useComboBoxContext.autocompletePropRef,
39
+ clearOnEscapeRef = _useComboBoxContext.clearOnEscapeRef,
40
+ openOnFocus = _useComboBoxContext.openOnFocus,
41
+ optionsRef = _useComboBoxContext.optionsRef,
42
+ labelIdRef = _useComboBoxContext.labelIdRef; // Keep focus on the input component
27
43
 
28
- const {
29
- data: {
30
- navigationItem,
31
- text,
32
- lastActionType
33
- },
34
- inputRef,
35
- state,
36
- transition,
37
- listboxIdRef,
38
- autocompletePropRef,
39
- clearOnEscapeRef,
40
- openOnFocus,
41
- optionsRef,
42
- labelIdRef
43
- } = useComboBoxContext(); // Keep focus on the input component
44
44
 
45
45
  useFocusManagement(lastActionType, inputRef); // Keep using the defaultValue until the user started interacting
46
46
 
47
- const hasStartedInteracting = useRef(false); // Because we close the List on blur, we need to track if the blur is
47
+ var hasStartedInteracting = useRef(false); // Because we close the List on blur, we need to track if the blur is
48
48
  // caused by clicking inside the list, and if so, don't close the List.
49
49
 
50
- const selectOnClickRef = useRef(false);
51
- const handleBlur = useBlur(); // Update ref props
50
+ var selectOnClickRef = useRef(false);
51
+ var handleBlur = useBlur(); // Update ref props
52
52
 
53
53
  autocompletePropRef.current = autocomplete;
54
54
  clearOnEscapeRef.current = clearOnEscape;
@@ -56,23 +56,23 @@ export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref
56
56
  // types, instead the developer controls it with the normal input onChange
57
57
  // prop
58
58
 
59
- const handleChange = e => {
59
+ var handleChange = function handleChange(e) {
60
60
  // After the user started typing, lets forget the defaultValue
61
61
  hasStartedInteracting.current = true;
62
- const text = e.target.value;
62
+ var text = e.target.value;
63
63
 
64
64
  if (text.trim() === '') {
65
65
  transition(CLEAR);
66
66
  } else {
67
67
  transition(CHANGE, {
68
- text
68
+ text: text
69
69
  });
70
70
  }
71
71
  };
72
72
 
73
- const handleKeyDown = useKeyDown();
73
+ var handleKeyDown = useKeyDown();
74
74
 
75
- const handleFocus = () => {
75
+ var handleFocus = function handleFocus() {
76
76
  if (selectOnClick) {
77
77
  selectOnClickRef.current = true;
78
78
  } // If we select an option with click, useFocusManagement will focus the
@@ -87,22 +87,24 @@ export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref
87
87
  }
88
88
  };
89
89
 
90
- const handleClick = () => {
90
+ var handleClick = function handleClick() {
91
91
  if (selectOnClickRef.current) {
92
92
  selectOnClickRef.current = false;
93
93
  inputRef.current && inputRef.current.select();
94
94
  }
95
95
  };
96
96
 
97
- const navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
98
- const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
99
- const inputStrings = // When idle, we don't have a navigationText on ArrowUp/Down
97
+ var navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
98
+ var fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
99
+ var inputStrings = // When idle, we don't have a navigationText on ArrowUp/Down
100
100
  autocomplete && state === NAVIGATING ? [navigationText, controlledValue, text, fallbackValue] : [controlledValue, text, fallbackValue];
101
- const inputValue = inputStrings.find(str => str !== undefined); // If they are controlling the value we still need to do our transitions, so
101
+ var inputValue = inputStrings.find(function (str) {
102
+ return str !== undefined;
103
+ }); // If they are controlling the value we still need to do our transitions, so
102
104
  // we have this derived state to emulate onChange of the input as we receive
103
105
  // new `value`s ...[*]
104
106
 
105
- useEffect(() => {
107
+ useEffect(function () {
106
108
  transition(INIT, {
107
109
  text: inputValue,
108
110
  item: ''
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"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","id","preferredId","defaultValue","value","controlledValue","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,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BAAkB,MAbpB;AAcE,6BACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;AAiBE,IAAA,YAAY,EAAC;AAjBf,KADF;AAqBD,CA1IoC,CAAhC","sourcesContent":["import { forwardRef, useEffect, useRef } from 'react';\nimport type * as React from 'react';\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 React.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?: React.MouseEventHandler<HTMLInputElement>;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n as?: React.ElementType<any>;\n innerAs?: React.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: React.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"],"file":"ComboboxInput.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"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"],"mappings":";;AASA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,iBALF,EAMEC,KANF,EAOEC,UAPF,EAQEC,IARF,EASEC,kBATF,QAUO,SAVP;AAWA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,UAA9C;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAwBA,OAAO,IAAMC,aAAa,gBAAGf,UAAU,CACrC,SAASe,aAAT,OAuBEC,YAvBF,EAwBE;AAAA,qBAtBE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tC,SAAS,CAACY,SAAD,EAAY8B,aAAZ,CAVtB;AAWE,uBAAiBT,UAAU,CAACI,OAX9B;AAYE,IAAA,EAAE,EAAET,YAAY,CAACS,OAZnB;AAaE,yBAAkB,MAbpB;AAcE,6BACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;AAiBE,IAAA,YAAY,EAAC;AAjBf,KADF;AAqBD,CA1IoC,CAAhC","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"],"file":"ComboboxInput.js"}
@@ -1,7 +1,7 @@
1
- import type * as React from 'react';
2
- export interface ComboboxLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
1
+ import type { ElementType, LabelHTMLAttributes } from 'react';
2
+ export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  id?: string;
6
6
  }
7
- export declare const ComboboxLabel: React.ForwardRefExoticComponent<ComboboxLabelProps & React.RefAttributes<HTMLLabelElement>>;
7
+ export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
@@ -1,20 +1,19 @@
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 { useComboBoxContext } from './context';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export const ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
7
- let {
8
- as: Comp = 'label',
9
- innerAs,
10
- id: preferredId
11
- } = _ref,
12
- props = _objectWithoutPropertiesLoose(_ref, ["as", "innerAs", "id"]);
6
+ export var ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
7
+ var _ref$as = _ref.as,
8
+ Comp = _ref$as === void 0 ? 'label' : _ref$as,
9
+ innerAs = _ref.innerAs,
10
+ preferredId = _ref.id,
11
+ props = _objectWithoutProperties(_ref, ["as", "innerAs", "id"]);
12
+
13
+ var _useComboBoxContext = useComboBoxContext(),
14
+ listboxIdRef = _useComboBoxContext.listboxIdRef,
15
+ labelIdRef = _useComboBoxContext.labelIdRef;
13
16
 
14
- const {
15
- listboxIdRef,
16
- labelIdRef
17
- } = useComboBoxContext();
18
17
  labelIdRef.current = preferredId || labelIdRef.current;
19
18
  return /*#__PURE__*/_jsx(Comp, _extends({
20
19
  as: innerAs,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"names":["forwardRef","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","id","preferredId","props","listboxIdRef","labelIdRef","current"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;;AASA,OAAO,MAAMC,aAAa,gBAAGF,UAAU,CACrC,SAASG,cAAT,OAEEC,GAFF,EAGE;AAAA,MAFA;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,OAAb;AAAsBC,IAAAA,OAAtB;AAA+BC,IAAAA,EAAE,EAAEC;AAAnC,GAEA;AAAA,MAFmDC,KAEnD;;AACA,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA+BX,kBAAkB,EAAvD;AAEAW,EAAAA,UAAU,CAACC,OAAX,GAAqBJ,WAAW,IAAIG,UAAU,CAACC,OAA/C;AAEA,sBACE,KAAC,IAAD;AACE,IAAA,EAAE,EAAEN,OADN;AAEE,iCAA0B,EAF5B;AAGE,IAAA,OAAO,EAAEI,YAAY,CAACE,OAHxB;AAIE,IAAA,EAAE,EAAED,UAAU,CAACC,OAJjB;AAKE,IAAA,GAAG,EAAET;AALP,KAMMM,KANN,EADF;AAUD,CAnBoC,CAAhC","sourcesContent":["import { forwardRef } from 'react';\nimport type * as React from 'react';\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n as?: React.ElementType<any>;\n innerAs?: React.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"],"file":"ComboboxLabel.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"names":["forwardRef","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","preferredId","id","props","listboxIdRef","labelIdRef","current"],"mappings":";;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;;AASA,OAAO,IAAMC,aAAa,gBAAGF,UAAU,CACrC,SAASG,cAAT,OAEEC,GAFF,EAGE;AAAA,qBAFEC,EAEF;AAAA,MAFMC,IAEN,wBAFa,OAEb;AAAA,MAFsBC,OAEtB,QAFsBA,OAEtB;AAAA,MAFmCC,WAEnC,QAF+BC,EAE/B;AAAA,MAFmDC,KAEnD;;AAAA,4BACqCT,kBAAkB,EADvD;AAAA,MACQU,YADR,uBACQA,YADR;AAAA,MACsBC,UADtB,uBACsBA,UADtB;;AAGAA,EAAAA,UAAU,CAACC,OAAX,GAAqBL,WAAW,IAAII,UAAU,CAACC,OAA/C;AAEA,sBACE,KAAC,IAAD;AACE,IAAA,EAAE,EAAEN,OADN;AAEE,iCAA0B,EAF5B;AAGE,IAAA,OAAO,EAAEI,YAAY,CAACE,OAHxB;AAIE,IAAA,EAAE,EAAED,UAAU,CAACC,OAJjB;AAKE,IAAA,GAAG,EAAET;AALP,KAMMM,KANN,EADF;AAUD,CAnBoC,CAAhC","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"],"file":"ComboboxLabel.js"}
@@ -1,8 +1,8 @@
1
- import type * as React from 'react';
2
- export interface ComboboxListProps extends React.HTMLAttributes<HTMLUListElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
1
+ import type { HTMLAttributes, ElementType, ReactNode } from 'react';
2
+ export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  persistSelection?: boolean;
6
- children?: React.ReactNode;
6
+ children?: ReactNode;
7
7
  }
8
- export declare const ComboboxList: React.ForwardRefExoticComponent<ComboboxListProps & React.RefAttributes<HTMLUListElement>>;
8
+ export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;