@basic-ui/core 0.0.53 → 0.0.56

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 (302) hide show
  1. package/build/cjs/index.js +278 -505
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.js +20 -29
  4. package/build/esm/Accordion/Accordion.js.map +1 -1
  5. package/build/esm/Accordion/AccordionBody.js +18 -32
  6. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  7. package/build/esm/Accordion/AccordionHeader.js +37 -74
  8. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  9. package/build/esm/Accordion/AccordionItem.js +19 -22
  10. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  11. package/build/esm/Accordion/context.js +16 -13
  12. package/build/esm/Accordion/context.js.map +1 -1
  13. package/build/esm/Accordion/index.js.map +1 -1
  14. package/build/esm/Accordion/scopeQuery.js.map +1 -1
  15. package/build/esm/CheckBox/CheckBox.js +15 -25
  16. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  17. package/build/esm/CheckBox/index.js.map +1 -1
  18. package/build/esm/ComboBox/Combobox.d.ts +7 -7
  19. package/build/esm/ComboBox/Combobox.js +52 -59
  20. package/build/esm/ComboBox/Combobox.js.map +1 -1
  21. package/build/esm/ComboBox/ComboboxButton.js +23 -28
  22. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  23. package/build/esm/ComboBox/ComboboxInput.js +67 -70
  24. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  25. package/build/esm/ComboBox/ComboboxLabel.js +15 -17
  26. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  27. package/build/esm/ComboBox/ComboboxList.js +19 -20
  28. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  29. package/build/esm/ComboBox/ComboboxOption.js +41 -45
  30. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  31. package/build/esm/ComboBox/ComboboxPopover.js +22 -21
  32. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  33. package/build/esm/ComboBox/cities.js.map +1 -1
  34. package/build/esm/ComboBox/context.js +5 -6
  35. package/build/esm/ComboBox/context.js.map +1 -1
  36. package/build/esm/ComboBox/hooks.d.ts +2 -2
  37. package/build/esm/ComboBox/hooks.js +175 -148
  38. package/build/esm/ComboBox/hooks.js.map +1 -1
  39. package/build/esm/ComboBox/index.js.map +1 -1
  40. package/build/esm/ComboBox/makeHash.js +3 -6
  41. package/build/esm/ComboBox/makeHash.js.map +1 -1
  42. package/build/esm/ComboBox/scopeQuery.js.map +1 -1
  43. package/build/esm/FocusLock/FocusLock.js +26 -32
  44. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  45. package/build/esm/FocusLock/index.js.map +1 -1
  46. package/build/esm/FocusLock/tabUtils.js +5 -7
  47. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  48. package/build/esm/FocusLock/useFocusLock.js +14 -19
  49. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  50. package/build/esm/List/List.js +9 -11
  51. package/build/esm/List/List.js.map +1 -1
  52. package/build/esm/List/ListItem.js +9 -11
  53. package/build/esm/List/ListItem.js.map +1 -1
  54. package/build/esm/List/context.js +6 -6
  55. package/build/esm/List/context.js.map +1 -1
  56. package/build/esm/List/index.js.map +1 -1
  57. package/build/esm/Menu/ContextMenuTrigger.d.ts +4 -4
  58. package/build/esm/Menu/ContextMenuTrigger.js +32 -37
  59. package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
  60. package/build/esm/Menu/Menu.js +33 -49
  61. package/build/esm/Menu/Menu.js.map +1 -1
  62. package/build/esm/Menu/MenuButton.d.ts +4 -4
  63. package/build/esm/Menu/MenuButton.js +28 -44
  64. package/build/esm/Menu/MenuButton.js.map +1 -1
  65. package/build/esm/Menu/MenuItem.js +29 -38
  66. package/build/esm/Menu/MenuItem.js.map +1 -1
  67. package/build/esm/Menu/MenuList.js +61 -116
  68. package/build/esm/Menu/MenuList.js.map +1 -1
  69. package/build/esm/Menu/MenuPopover.js +16 -19
  70. package/build/esm/Menu/MenuPopover.js.map +1 -1
  71. package/build/esm/Menu/context.d.ts +1 -1
  72. package/build/esm/Menu/context.js +14 -12
  73. package/build/esm/Menu/context.js.map +1 -1
  74. package/build/esm/Menu/fixtures/countryList.js +1 -1
  75. package/build/esm/Menu/fixtures/countryList.js.map +1 -1
  76. package/build/esm/Menu/index.js.map +1 -1
  77. package/build/esm/Menu/scope.js.map +1 -1
  78. package/build/esm/Modal/Modal.js +13 -18
  79. package/build/esm/Modal/Modal.js.map +1 -1
  80. package/build/esm/Modal/ModalBackdrop.js +24 -33
  81. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  82. package/build/esm/Modal/index.js.map +1 -1
  83. package/build/esm/Popper/Popper.d.ts +3 -3
  84. package/build/esm/Popper/Popper.js +44 -61
  85. package/build/esm/Popper/Popper.js.map +1 -1
  86. package/build/esm/Popper/PopperArrow.js +11 -16
  87. package/build/esm/Popper/PopperArrow.js.map +1 -1
  88. package/build/esm/Popper/context.js +3 -5
  89. package/build/esm/Popper/context.js.map +1 -1
  90. package/build/esm/Popper/index.js.map +1 -1
  91. package/build/esm/Portal/Portal.js +9 -11
  92. package/build/esm/Portal/Portal.js.map +1 -1
  93. package/build/esm/Portal/PortalSelectorProvider.d.ts +3 -3
  94. package/build/esm/Portal/PortalSelectorProvider.js +6 -4
  95. package/build/esm/Portal/PortalSelectorProvider.js.map +1 -1
  96. package/build/esm/Portal/index.js.map +1 -1
  97. package/build/esm/RadioButton/RadioButton.js +17 -23
  98. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  99. package/build/esm/RadioButton/RadioGroup.js +19 -28
  100. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  101. package/build/esm/RadioButton/context.d.ts +1 -1
  102. package/build/esm/RadioButton/context.js +8 -6
  103. package/build/esm/RadioButton/context.js.map +1 -1
  104. package/build/esm/RadioButton/index.js.map +1 -1
  105. package/build/esm/SkipNav/SkipNav.js +9 -11
  106. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  107. package/build/esm/SkipNav/index.js.map +1 -1
  108. package/build/esm/Slider/Slider.d.ts +7 -7
  109. package/build/esm/Slider/Slider.js +340 -407
  110. package/build/esm/Slider/Slider.js.map +1 -1
  111. package/build/esm/Slider/index.js.map +1 -1
  112. package/build/esm/Spinner/Spinner.js +31 -59
  113. package/build/esm/Spinner/Spinner.js.map +1 -1
  114. package/build/esm/Spinner/SpinnerButton.js +14 -19
  115. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  116. package/build/esm/Spinner/context.js +8 -7
  117. package/build/esm/Spinner/context.js.map +1 -1
  118. package/build/esm/Spinner/index.js.map +1 -1
  119. package/build/esm/Tabs/Tab.js +32 -50
  120. package/build/esm/Tabs/Tab.js.map +1 -1
  121. package/build/esm/Tabs/TabList.js +24 -34
  122. package/build/esm/Tabs/TabList.js.map +1 -1
  123. package/build/esm/Tabs/TabPanel.js +16 -23
  124. package/build/esm/Tabs/TabPanel.js.map +1 -1
  125. package/build/esm/Tabs/TabPanels.js +15 -20
  126. package/build/esm/Tabs/TabPanels.js.map +1 -1
  127. package/build/esm/Tabs/Tabs.js +17 -33
  128. package/build/esm/Tabs/Tabs.js.map +1 -1
  129. package/build/esm/Tabs/context.js +16 -13
  130. package/build/esm/Tabs/context.js.map +1 -1
  131. package/build/esm/Tabs/index.js.map +1 -1
  132. package/build/esm/Tabs/scopeQuery.js.map +1 -1
  133. package/build/esm/Tooltip/Tooltip.d.ts +2 -2
  134. package/build/esm/Tooltip/Tooltip.js +20 -30
  135. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  136. package/build/esm/Tooltip/index.js.map +1 -1
  137. package/build/esm/Tooltip/stateMachine.d.ts +2 -2
  138. package/build/esm/Tooltip/stateMachine.js +95 -81
  139. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  140. package/build/esm/Tooltip/useTooltip.d.ts +2 -2
  141. package/build/esm/Tooltip/useTooltip.js +38 -50
  142. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  143. package/build/esm/hooks/index.js.map +1 -1
  144. package/build/esm/hooks/useAutoFocus.js +3 -3
  145. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  146. package/build/esm/hooks/useChildrenCounter.js +6 -8
  147. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  148. package/build/esm/hooks/useControlledState.js +6 -16
  149. package/build/esm/hooks/useControlledState.js.map +1 -1
  150. package/build/esm/hooks/useFocusReturn.js +8 -12
  151. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  152. package/build/esm/hooks/useFocusState.d.ts +2 -2
  153. package/build/esm/hooks/useFocusState.js +9 -15
  154. package/build/esm/hooks/useFocusState.js.map +1 -1
  155. package/build/esm/hooks/useGestureHandlers.d.ts +1 -1
  156. package/build/esm/hooks/useGestureHandlers.js +80 -100
  157. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  158. package/build/esm/hooks/useMeasure.js +7 -15
  159. package/build/esm/hooks/useMeasure.js.map +1 -1
  160. package/build/esm/hooks/useOnClickOutside.js +4 -6
  161. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  162. package/build/esm/hooks/useOnKeyDown.js +3 -4
  163. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  164. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  165. package/build/esm/hooks/useReducerMachine.js +15 -26
  166. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  167. package/build/esm/hooks/useRemoveBodyScroll.js +9 -14
  168. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  169. package/build/esm/hooks/useScope.d.ts +2 -2
  170. package/build/esm/hooks/useScope.js +12 -14
  171. package/build/esm/hooks/useScope.js.map +1 -1
  172. package/build/esm/hooks/useThrottle.js +5 -10
  173. package/build/esm/hooks/useThrottle.js.map +1 -1
  174. package/build/esm/index.js +4 -2
  175. package/build/esm/index.js.map +1 -1
  176. package/build/esm/styles.d.js +2 -0
  177. package/build/esm/styles.d.js.map +1 -0
  178. package/build/esm/utils/assign-ref.js +3 -5
  179. package/build/esm/utils/assign-ref.js.map +1 -1
  180. package/build/esm/utils/can-use-dom.js.map +1 -1
  181. package/build/esm/utils/clamp.js.map +1 -1
  182. package/build/esm/utils/context.d.ts +1 -1
  183. package/build/esm/utils/context.js +13 -20
  184. package/build/esm/utils/context.js.map +1 -1
  185. package/build/esm/utils/create-subscription.js +5 -10
  186. package/build/esm/utils/create-subscription.js.map +1 -1
  187. package/build/esm/utils/get-circular-index.js +0 -1
  188. package/build/esm/utils/get-circular-index.js.map +1 -1
  189. package/build/esm/utils/index.js.map +1 -1
  190. package/build/esm/utils/is-right-click.js.map +1 -1
  191. package/build/esm/utils/owner-document.js +1 -1
  192. package/build/esm/utils/owner-document.js.map +1 -1
  193. package/build/esm/utils/polymorphic.d.ts +10 -10
  194. package/build/esm/utils/polymorphic.js.map +1 -1
  195. package/build/esm/utils/rubber-band-clamp.js +2 -5
  196. package/build/esm/utils/rubber-band-clamp.js.map +1 -1
  197. package/build/esm/utils/use-stable-callback.js +8 -10
  198. package/build/esm/utils/use-stable-callback.js.map +1 -1
  199. package/build/esm/utils/wrap-event.d.ts +1 -1
  200. package/build/esm/utils/wrap-event.js +2 -5
  201. package/build/esm/utils/wrap-event.js.map +1 -1
  202. package/build/tsconfig-build.tsbuildinfo +1 -1
  203. package/package.json +6 -6
  204. package/src/Accordion/Accordion.tsx +1 -1
  205. package/src/Accordion/AccordionBody.tsx +1 -1
  206. package/src/Accordion/AccordionHeader.tsx +1 -2
  207. package/src/ComboBox/Combobox.tsx +2 -2
  208. package/src/ComboBox/ComboboxList.tsx +1 -1
  209. package/src/ComboBox/ComboboxOption.tsx +0 -1
  210. package/src/ComboBox/hooks.tsx +0 -3
  211. package/src/FocusLock/useFocusLock.ts +0 -1
  212. package/src/Menu/Menu.tsx +2 -3
  213. package/src/Menu/MenuItem.tsx +1 -2
  214. package/src/Menu/MenuList.tsx +4 -4
  215. package/src/Modal/Modal.story.tsx +11 -7
  216. package/src/Modal/ModalBackdrop.tsx +1 -1
  217. package/src/Modal/NavDrawer.story.tsx +9 -6
  218. package/src/Popper/Popper.story.tsx +23 -7
  219. package/src/Popper/Popper.tsx +2 -2
  220. package/src/RadioButton/RadioButton.story.tsx +2 -1
  221. package/src/Slider/Slider.tsx +6 -11
  222. package/src/Spinner/Spinner.tsx +1 -1
  223. package/src/Tabs/TabList.tsx +1 -1
  224. package/src/Tooltip/Tooltip.tsx +8 -5
  225. package/src/Tooltip/useTooltip.ts +1 -1
  226. package/src/hooks/useControlledState.ts +1 -6
  227. package/src/hooks/useGestureHandlers.ts +0 -4
  228. package/src/hooks/useRemoveBodyScroll.ts +0 -1
  229. package/src/hooks/useScope.ts +1 -1
  230. package/src/styles.d.ts +1 -0
  231. package/src/utils/polymorphic.ts +14 -10
  232. package/src/utils/use-stable-callback.ts +0 -1
  233. package/build/esm/Carousel/Carousel.d.ts +0 -9
  234. package/build/esm/Carousel/Carousel.js +0 -38
  235. package/build/esm/Carousel/Carousel.js.map +0 -1
  236. package/build/esm/Carousel/Fader.d.ts +0 -14
  237. package/build/esm/Carousel/Fader.js +0 -76
  238. package/build/esm/Carousel/Fader.js.map +0 -1
  239. package/build/esm/Carousel/FaderItem.d.ts +0 -5
  240. package/build/esm/Carousel/FaderItem.js +0 -16
  241. package/build/esm/Carousel/FaderItem.js.map +0 -1
  242. package/build/esm/Carousel/Preloader.d.ts +0 -7
  243. package/build/esm/Carousel/Preloader.js +0 -70
  244. package/build/esm/Carousel/Preloader.js.map +0 -1
  245. package/build/esm/Carousel/Slider.d.ts +0 -14
  246. package/build/esm/Carousel/Slider.js +0 -212
  247. package/build/esm/Carousel/Slider.js.map +0 -1
  248. package/build/esm/Carousel/SliderItem.d.ts +0 -12
  249. package/build/esm/Carousel/SliderItem.js +0 -41
  250. package/build/esm/Carousel/SliderItem.js.map +0 -1
  251. package/build/esm/Carousel/context.d.ts +0 -10
  252. package/build/esm/Carousel/context.js +0 -8
  253. package/build/esm/Carousel/context.js.map +0 -1
  254. package/build/esm/Carousel/getSliderParams.d.ts +0 -9
  255. package/build/esm/Carousel/getSliderParams.js +0 -85
  256. package/build/esm/Carousel/getSliderParams.js.map +0 -1
  257. package/build/esm/Carousel/index.d.ts +0 -7
  258. package/build/esm/Carousel/index.js +0 -8
  259. package/build/esm/Carousel/index.js.map +0 -1
  260. package/build/esm/Carousel/useCarouselGestures.d.ts +0 -30
  261. package/build/esm/Carousel/useCarouselGestures.js +0 -33
  262. package/build/esm/Carousel/useCarouselGestures.js.map +0 -1
  263. package/build/esm/DatePicker/DatePicker.d.ts +0 -24
  264. package/build/esm/DatePicker/DatePicker.js +0 -101
  265. package/build/esm/DatePicker/DatePicker.js.map +0 -1
  266. package/build/esm/DatePicker/DatePickerSelect.d.ts +0 -8
  267. package/build/esm/DatePicker/DatePickerSelect.js +0 -201
  268. package/build/esm/DatePicker/DatePickerSelect.js.map +0 -1
  269. package/build/esm/DatePicker/RangeDatePicker.d.ts +0 -28
  270. package/build/esm/DatePicker/RangeDatePicker.js +0 -94
  271. package/build/esm/DatePicker/RangeDatePicker.js.map +0 -1
  272. package/build/esm/DatePicker/adjustDates.d.ts +0 -4
  273. package/build/esm/DatePicker/adjustDates.js +0 -18
  274. package/build/esm/DatePicker/adjustDates.js.map +0 -1
  275. package/build/esm/DatePicker/contexts.d.ts +0 -31
  276. package/build/esm/DatePicker/contexts.js +0 -15
  277. package/build/esm/DatePicker/contexts.js.map +0 -1
  278. package/build/esm/DatePicker/dateTypes.d.ts +0 -2
  279. package/build/esm/DatePicker/dateTypes.js +0 -2
  280. package/build/esm/DatePicker/dateTypes.js.map +0 -1
  281. package/build/esm/DatePicker/hooks.d.ts +0 -36
  282. package/build/esm/DatePicker/hooks.js +0 -98
  283. package/build/esm/DatePicker/hooks.js.map +0 -1
  284. package/build/esm/DatePicker/index.d.ts +0 -5
  285. package/build/esm/DatePicker/index.js +0 -6
  286. package/build/esm/DatePicker/index.js.map +0 -1
  287. package/build/esm/hooks/useId.d.ts +0 -1
  288. package/build/esm/hooks/useId.js +0 -25
  289. package/build/esm/hooks/useId.js.map +0 -1
  290. package/build/esm/utils/assignRef.d.ts +0 -3
  291. package/build/esm/utils/assignRef.js +0 -25
  292. package/build/esm/utils/assignRef.js.map +0 -1
  293. package/build/esm/utils/getCircularIndex.d.ts +0 -1
  294. package/build/esm/utils/getCircularIndex.js +0 -8
  295. package/build/esm/utils/getCircularIndex.js.map +0 -1
  296. package/build/esm/utils/rubberBandClamp.d.ts +0 -2
  297. package/build/esm/utils/rubberBandClamp.js +0 -20
  298. package/build/esm/utils/rubberBandClamp.js.map +0 -1
  299. package/build/esm/utils/wrapEvent.d.ts +0 -3
  300. package/build/esm/utils/wrapEvent.js +0 -16
  301. package/build/esm/utils/wrapEvent.js.map +0 -1
  302. package/build/tsconfig.tsbuildinfo +0 -7270
@@ -1,34 +1,24 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["as", "checked", "defaultChecked", "onChange"];
5
1
  import { forwardRef } from 'react';
6
2
  import { useControlledState } from '../hooks';
7
3
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export var CheckBox = /*#__PURE__*/forwardRef(function CheckBox(props, forwardedRef) {
9
- var _props$as = props.as,
10
- Comp = _props$as === void 0 ? 'input' : _props$as,
11
- checkedProp = props.checked,
12
- _props$defaultChecked = props.defaultChecked,
13
- defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
14
- onChangeProp = props.onChange,
15
- otherProps = _objectWithoutProperties(props, _excluded);
16
-
17
- var _useControlledState = useControlledState(checkedProp, onChangeProp, defaultChecked, function (setValue) {
18
- return function (e) {
19
- setValue(e.target.checked);
20
- };
21
- }),
22
- _useControlledState2 = _slicedToArray(_useControlledState, 2),
23
- checked = _useControlledState2[0],
24
- onChange = _useControlledState2[1];
25
-
26
- return /*#__PURE__*/_jsx(Comp, _extends({
4
+ export const CheckBox = /*#__PURE__*/forwardRef(function CheckBox(props, forwardedRef) {
5
+ const {
6
+ as: Comp = 'input',
7
+ checked: checkedProp,
8
+ defaultChecked = false,
9
+ onChange: onChangeProp,
10
+ ...otherProps
11
+ } = props;
12
+ const [checked, onChange] = useControlledState(checkedProp, onChangeProp, defaultChecked, setValue => e => {
13
+ setValue(e.target.checked);
14
+ });
15
+ return /*#__PURE__*/_jsx(Comp, {
27
16
  ref: forwardedRef,
28
17
  type: "checkbox",
29
18
  checked: checked,
30
19
  "aria-checked": checked,
31
- onChange: onChange
32
- }, otherProps));
20
+ onChange: onChange,
21
+ ...otherProps
22
+ });
33
23
  });
34
24
  //# sourceMappingURL=CheckBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBox.js","names":["forwardRef","useControlledState","CheckBox","props","forwardedRef","as","Comp","checkedProp","checked","defaultChecked","onChangeProp","onChange","otherProps","setValue","e","target"],"sources":["../../../src/CheckBox/CheckBox.tsx"],"sourcesContent":["import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useControlledState } from '../hooks';\n\nexport interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const CheckBox = forwardRef<HTMLInputElement, CheckBoxProps>(\n function CheckBox(props, forwardedRef) {\n const {\n as: Comp = 'input',\n checked: checkedProp,\n defaultChecked = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const [checked, onChange] = useControlledState(\n checkedProp,\n onChangeProp,\n defaultChecked,\n (setValue) => (e) => {\n setValue(e.target.checked);\n }\n );\n\n return (\n <Comp\n ref={forwardedRef}\n type=\"checkbox\"\n checked={checked}\n aria-checked={checked}\n onChange={onChange}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,UAAnC;;AAQA,OAAO,IAAMC,QAAQ,gBAAGF,UAAU,CAChC,SAASE,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;EACrC,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,OADb;EAAA,IAEWC,WAFX,GAMIJ,KANJ,CAEEK,OAFF;EAAA,4BAMIL,KANJ,CAGEM,cAHF;EAAA,IAGEA,cAHF,sCAGmB,KAHnB;EAAA,IAIYC,YAJZ,GAMIP,KANJ,CAIEQ,QAJF;EAAA,IAKKC,UALL,4BAMIT,KANJ;;EAOA,0BAA4BF,kBAAkB,CAC5CM,WAD4C,EAE5CG,YAF4C,EAG5CD,cAH4C,EAI5C,UAACI,QAAD;IAAA,OAAc,UAACC,CAAD,EAAO;MACnBD,QAAQ,CAACC,CAAC,CAACC,MAAF,CAASP,OAAV,CAAR;IACD,CAFD;EAAA,CAJ4C,CAA9C;EAAA;EAAA,IAAOA,OAAP;EAAA,IAAgBG,QAAhB;;EASA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEP,YADP;IAEE,IAAI,EAAC,UAFP;IAGE,OAAO,EAAEI,OAHX;IAIE,gBAAcA,OAJhB;IAKE,QAAQ,EAAEG;EALZ,GAMMC,UANN,EADF;AAUD,CA5B+B,CAA3B"}
1
+ {"version":3,"file":"CheckBox.js","names":["forwardRef","useControlledState","jsx","_jsx","CheckBox","props","forwardedRef","as","Comp","checked","checkedProp","defaultChecked","onChange","onChangeProp","otherProps","setValue","e","target","ref","type"],"sources":["../../../src/CheckBox/CheckBox.tsx"],"sourcesContent":["import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useControlledState } from '../hooks';\n\nexport interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const CheckBox = forwardRef<HTMLInputElement, CheckBoxProps>(\n function CheckBox(props, forwardedRef) {\n const {\n as: Comp = 'input',\n checked: checkedProp,\n defaultChecked = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const [checked, onChange] = useControlledState(\n checkedProp,\n onChangeProp,\n defaultChecked,\n (setValue) => (e) => {\n setValue(e.target.checked);\n }\n );\n\n return (\n <Comp\n ref={forwardedRef}\n type=\"checkbox\"\n checked={checked}\n aria-checked={checked}\n onChange={onChange}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ9C,OAAO,MAAMC,QAAQ,gBAAGJ,UAAU,CAChC,SAASI,QAAQA,CAACC,KAAK,EAAEC,YAAY,EAAE;EACrC,MAAM;IACJC,EAAE,EAAEC,IAAI,GAAG,OAAO;IAClBC,OAAO,EAAEC,WAAW;IACpBC,cAAc,GAAG,KAAK;IACtBC,QAAQ,EAAEC,YAAY;IACtB,GAAGC;EACL,CAAC,GAAGT,KAAK;EACT,MAAM,CAACI,OAAO,EAAEG,QAAQ,CAAC,GAAGX,kBAAkB,CAC5CS,WAAW,EACXG,YAAY,EACZF,cAAc,EACbI,QAAQ,IAAMC,CAAC,IAAK;IACnBD,QAAQ,CAACC,CAAC,CAACC,MAAM,CAACR,OAAO,CAAC;EAC5B,CACF,CAAC;EAED,oBACEN,IAAA,CAACK,IAAI;IACHU,GAAG,EAAEZ,YAAa;IAClBa,IAAI,EAAC,UAAU;IACfV,OAAO,EAAEA,OAAQ;IACjB,gBAAcA,OAAQ;IACtBG,QAAQ,EAAEA,QAAS;IAAA,GACfE;EAAU,CACf,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,YAAd"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,YAAY","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { HTMLAttributes, ReactNode, ElementType } from 'react';
2
- export declare type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
3
- export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
2
+ export type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
3
+ export type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
4
4
  onSelect?: SelectEventHandler;
5
5
  openOnFocus?: boolean;
6
6
  selectOnBlur?: boolean;
@@ -9,10 +9,10 @@ export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSele
9
9
  innerAs?: ElementType<any>;
10
10
  };
11
11
  export declare const Combobox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
12
- onSelect?: SelectEventHandler | undefined;
13
- openOnFocus?: boolean | undefined;
14
- selectOnBlur?: boolean | undefined;
12
+ onSelect?: SelectEventHandler;
13
+ openOnFocus?: boolean;
14
+ selectOnBlur?: boolean;
15
15
  children?: ReactNode;
16
- as?: ElementType<any> | undefined;
17
- innerAs?: ElementType<any> | undefined;
16
+ as?: ElementType<any>;
17
+ innerAs?: ElementType<any>;
18
18
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,49 +1,49 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["onSelect", "openOnFocus", "selectOnBlur", "children", "as", "innerAs"];
5
1
  import { forwardRef, useRef, useMemo, useId } from 'react';
6
2
  import { stateChart, comboboxReducer, isVisible, INIT } from './hooks';
7
3
  import { ComboBoxProvider } from './context';
8
4
  import { useReducerMachine } from '../hooks/useReducerMachine';
9
5
  import { getScope } from '../hooks';
10
6
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
12
- var onSelect = _ref.onSelect,
13
- _ref$openOnFocus = _ref.openOnFocus,
14
- openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
15
- _ref$selectOnBlur = _ref.selectOnBlur,
16
- selectOnBlur = _ref$selectOnBlur === void 0 ? false : _ref$selectOnBlur,
17
- children = _ref.children,
18
- _ref$as = _ref.as,
19
- Comp = _ref$as === void 0 ? 'div' : _ref$as,
20
- innerAs = _ref.innerAs,
21
- rest = _objectWithoutProperties(_ref, _excluded);
22
-
7
+ export const Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
8
+ let {
9
+ // Called whenever the user selects an item from the list
10
+ onSelect,
11
+ // opens the list when the input receives focused (but only if there are
12
+ // items in the list)
13
+ openOnFocus = false,
14
+ // if set to true, it will select an item after blurring
15
+ selectOnBlur = false,
16
+ children,
17
+ as: Comp = 'div',
18
+ innerAs,
19
+ ...rest
20
+ } = _ref;
23
21
  // We store the values of all the ComboboxOptions on this ref. This makes it
24
22
  // possible to perform the keyboard navigation from the input on the list. We
25
23
  // manipulate this array through context so that we don't have to enforce a
26
24
  // parent/child relationship between ComboboxList and ComboboxOption.
27
- var optionsRef = useRef({});
28
- var listScope = useRef(getScope({
25
+ const optionsRef = useRef({});
26
+ const listScope = useRef(getScope({
29
27
  current: null
30
- })); // Need this to focus it
28
+ }));
29
+
30
+ // Need this to focus it
31
+ const inputRef = useRef(null);
32
+ const popoverRef = useRef(null);
33
+ const buttonRef = useRef(null);
31
34
 
32
- var inputRef = useRef(null);
33
- var popoverRef = useRef(null);
34
- var buttonRef = useRef(null); // When <ComboboxInput autocomplete={false} /> we don't want cycle back to
35
+ // When <ComboboxInput autocomplete={false} /> we don't want cycle back to
35
36
  // the user's value while navigating (because it's always the user's value),
36
37
  // but we need to know this in useKeyDown which is far away from the prop
37
38
  // here, so we do something sneaky and write it to this ref on context so we
38
39
  // can use it anywhere else 😛. Another new trick for me and I'm excited
39
40
  // about this one too!
40
-
41
- var autocompletePropRef = useRef(false);
42
- var persistSelectionRef = useRef(false);
43
- var clearOnEscapeRef = useRef(false);
44
- var listboxIdRef = useRef();
45
- var labelIdRef = useRef();
46
- var defaultData = {
41
+ const autocompletePropRef = useRef(false);
42
+ const persistSelectionRef = useRef(false);
43
+ const clearOnEscapeRef = useRef(false);
44
+ const listboxIdRef = useRef(undefined);
45
+ const labelIdRef = useRef(undefined);
46
+ const defaultData = {
47
47
  // initial state
48
48
  state: stateChart.initial,
49
49
  // the value the user has typed, we derived this also when the developer is
@@ -57,39 +57,32 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
57
57
  // the last submitted action
58
58
  lastActionType: INIT
59
59
  };
60
-
61
- var _useReducerMachine = useReducerMachine(stateChart, comboboxReducer, defaultData),
62
- _useReducerMachine2 = _slicedToArray(_useReducerMachine, 3),
63
- state = _useReducerMachine2[0],
64
- data = _useReducerMachine2[1],
65
- transition = _useReducerMachine2[2];
66
-
60
+ const [state, data, transition] = useReducerMachine(stateChart, comboboxReducer, defaultData);
67
61
  listboxIdRef.current = useId();
68
62
  labelIdRef.current = useId();
69
- var context = useMemo(function () {
70
- return {
71
- data: data,
72
- inputRef: inputRef,
73
- popoverRef: popoverRef,
74
- buttonRef: buttonRef,
75
- onSelect: onSelect,
76
- optionsRef: optionsRef,
77
- listScope: listScope,
78
- state: state,
79
- transition: transition,
80
- listboxIdRef: listboxIdRef,
81
- labelIdRef: labelIdRef,
82
- autocompletePropRef: autocompletePropRef,
83
- persistSelectionRef: persistSelectionRef,
84
- clearOnEscapeRef: clearOnEscapeRef,
85
- isVisible: isVisible(state),
86
- openOnFocus: openOnFocus,
87
- selectOnBlur: selectOnBlur
88
- };
89
- }, [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
63
+ const context = useMemo(() => ({
64
+ data,
65
+ inputRef,
66
+ popoverRef,
67
+ buttonRef,
68
+ onSelect,
69
+ optionsRef,
70
+ listScope,
71
+ state,
72
+ transition,
73
+ listboxIdRef,
74
+ labelIdRef,
75
+ autocompletePropRef,
76
+ persistSelectionRef,
77
+ clearOnEscapeRef,
78
+ isVisible: isVisible(state),
79
+ openOnFocus,
80
+ selectOnBlur
81
+ }), [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
90
82
  return /*#__PURE__*/_jsx(ComboBoxProvider, {
91
83
  value: context,
92
- children: /*#__PURE__*/_jsx(Comp, _extends(_extends({}, rest), {}, {
84
+ children: /*#__PURE__*/_jsx(Comp, {
85
+ ...rest,
93
86
  as: innerAs,
94
87
  "data-reach-combobox": "",
95
88
  ref: ref,
@@ -98,7 +91,7 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
98
91
  "aria-owns": listboxIdRef.current,
99
92
  "aria-expanded": context.isVisible,
100
93
  children: children
101
- }))
94
+ })
102
95
  });
103
96
  });
104
97
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","Combobox","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context"],"sources":["../../../src/ComboBox/Combobox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode, ElementType } from 'react';\nimport { forwardRef, useRef, useMemo, useId } from 'react';\n\nimport type { ActionTypes } from './hooks';\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\nimport type { ComboBoxContextProps } from './context';\nimport { ComboBoxProvider } from './context';\nimport { useReducerMachine } from '../hooks/useReducerMachine';\nimport type { Scope } from '../hooks';\nimport { getScope } from '../hooks';\n\nexport type SelectEventHandler = (\n text: string,\n itemId: string,\n obj: any\n) => void;\n\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n onSelect?: SelectEventHandler;\n openOnFocus?: boolean;\n selectOnBlur?: boolean;\n children?: ReactNode;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n};\n\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\n function Combobox(\n {\n // Called whenever the user selects an item from the list\n onSelect,\n\n // opens the list when the input receives focused (but only if there are\n // items in the list)\n openOnFocus = false,\n\n // if set to true, it will select an item after blurring\n selectOnBlur = false,\n\n children,\n as: Comp = 'div',\n innerAs,\n ...rest\n }: ComboboxProps,\n ref\n ) {\n // We store the values of all the ComboboxOptions on this ref. This makes it\n // possible to perform the keyboard navigation from the input on the list. We\n // manipulate this array through context so that we don't have to enforce a\n // parent/child relationship between ComboboxList and ComboboxOption.\n const optionsRef = useRef<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>({});\n\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\n\n // Need this to focus it\n const inputRef = useRef<HTMLInputElement>(null);\n\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\n // the user's value while navigating (because it's always the user's value),\n // but we need to know this in useKeyDown which is far away from the prop\n // here, so we do something sneaky and write it to this ref on context so we\n // can use it anywhere else 😛. Another new trick for me and I'm excited\n // about this one too!\n const autocompletePropRef = useRef<boolean>(false);\n\n const persistSelectionRef = useRef<boolean>(false);\n\n const clearOnEscapeRef = useRef<boolean>(false);\n\n const listboxIdRef = useRef<string | undefined>();\n\n const labelIdRef = useRef<string | undefined>();\n\n const defaultData = {\n // initial state\n state: stateChart.initial,\n // the value the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n text: '',\n // the index the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n item: '',\n // the hash of the currently navigated item\n navigationItem: '',\n // the last submitted action\n lastActionType: INIT as ActionTypes,\n };\n\n const [state, data, transition] = useReducerMachine(\n stateChart,\n comboboxReducer,\n defaultData\n );\n\n listboxIdRef.current = useId();\n\n labelIdRef.current = useId();\n\n const context = useMemo(\n (): ComboBoxContextProps => ({\n data,\n inputRef,\n popoverRef,\n buttonRef,\n onSelect,\n optionsRef,\n listScope,\n state,\n transition,\n listboxIdRef,\n labelIdRef,\n autocompletePropRef,\n persistSelectionRef,\n clearOnEscapeRef,\n isVisible: isVisible(state),\n openOnFocus,\n selectOnBlur,\n }),\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\n );\n\n return (\n <ComboBoxProvider value={context}>\n <Comp\n {...rest}\n as={innerAs}\n data-reach-combobox=\"\"\n ref={ref}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-owns={listboxIdRef.current}\n aria-expanded={context.isVisible}\n >\n {children}\n </Comp>\n </ComboBoxProvider>\n );\n }\n);\n"],"mappings":"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"}
1
+ {"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","jsx","_jsx","Combobox","_ref","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","undefined","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context","value","role"],"sources":["../../../src/ComboBox/Combobox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode, ElementType } from 'react';\nimport { forwardRef, useRef, useMemo, useId } from 'react';\n\nimport type { ActionTypes } from './hooks';\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\nimport type { ComboBoxContextProps } from './context';\nimport { ComboBoxProvider } from './context';\nimport { useReducerMachine } from '../hooks/useReducerMachine';\nimport type { Scope } from '../hooks';\nimport { getScope } from '../hooks';\n\nexport type SelectEventHandler = (\n text: string,\n itemId: string,\n obj: any\n) => void;\n\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n onSelect?: SelectEventHandler;\n openOnFocus?: boolean;\n selectOnBlur?: boolean;\n children?: ReactNode;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n};\n\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\n function Combobox(\n {\n // Called whenever the user selects an item from the list\n onSelect,\n\n // opens the list when the input receives focused (but only if there are\n // items in the list)\n openOnFocus = false,\n\n // if set to true, it will select an item after blurring\n selectOnBlur = false,\n\n children,\n as: Comp = 'div',\n innerAs,\n ...rest\n }: ComboboxProps,\n ref\n ) {\n // We store the values of all the ComboboxOptions on this ref. This makes it\n // possible to perform the keyboard navigation from the input on the list. We\n // manipulate this array through context so that we don't have to enforce a\n // parent/child relationship between ComboboxList and ComboboxOption.\n const optionsRef = useRef<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>({});\n\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\n\n // Need this to focus it\n const inputRef = useRef<HTMLInputElement>(null);\n\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\n // the user's value while navigating (because it's always the user's value),\n // but we need to know this in useKeyDown which is far away from the prop\n // here, so we do something sneaky and write it to this ref on context so we\n // can use it anywhere else 😛. Another new trick for me and I'm excited\n // about this one too!\n const autocompletePropRef = useRef<boolean>(false);\n\n const persistSelectionRef = useRef<boolean>(false);\n\n const clearOnEscapeRef = useRef<boolean>(false);\n\n const listboxIdRef = useRef<string | undefined>(undefined);\n\n const labelIdRef = useRef<string | undefined>(undefined);\n\n const defaultData = {\n // initial state\n state: stateChart.initial,\n // the value the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n text: '',\n // the index the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n item: '',\n // the hash of the currently navigated item\n navigationItem: '',\n // the last submitted action\n lastActionType: INIT as ActionTypes,\n };\n\n const [state, data, transition] = useReducerMachine(\n stateChart,\n comboboxReducer,\n defaultData\n );\n\n listboxIdRef.current = useId();\n\n labelIdRef.current = useId();\n\n const context = useMemo(\n (): ComboBoxContextProps => ({\n data,\n inputRef,\n popoverRef,\n buttonRef,\n onSelect,\n optionsRef,\n listScope,\n state,\n transition,\n listboxIdRef,\n labelIdRef,\n autocompletePropRef,\n persistSelectionRef,\n clearOnEscapeRef,\n isVisible: isVisible(state),\n openOnFocus,\n selectOnBlur,\n }),\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\n );\n\n return (\n <ComboBoxProvider value={context}>\n <Comp\n {...rest}\n as={innerAs}\n data-reach-combobox=\"\"\n ref={ref}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-owns={listboxIdRef.current}\n aria-expanded={context.isVisible}\n >\n {children}\n </Comp>\n </ComboBoxProvider>\n );\n }\n);\n"],"mappings":"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","ignoreList":[]}
@@ -1,43 +1,37 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "innerAs", "onClick", "onKeyDown"];
4
1
  import { forwardRef } from 'react';
5
2
  import { useComboBoxContext } from './context';
6
3
  import { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';
7
4
  import { wrapEvent } from '../utils/wrap-event';
8
5
  import { assignMultipleRefs } from '../utils/assign-ref';
9
6
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
11
- var _ref$as = _ref.as,
12
- Comp = _ref$as === void 0 ? 'button' : _ref$as,
13
- innerAs = _ref.innerAs,
14
- onClick = _ref.onClick,
15
- onKeyDown = _ref.onKeyDown,
16
- props = _objectWithoutProperties(_ref, _excluded);
17
-
18
- var _useComboBoxContext = useComboBoxContext(),
19
- transition = _useComboBoxContext.transition,
20
- data = _useComboBoxContext.data,
21
- state = _useComboBoxContext.state,
22
- buttonRef = _useComboBoxContext.buttonRef,
23
- listboxIdRef = _useComboBoxContext.listboxIdRef,
24
- isVisible = _useComboBoxContext.isVisible;
25
-
26
- var handleKeyDown = useKeyDown();
27
-
28
- var handleClick = function handleClick() {
29
- var payload = {
7
+ export const ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
8
+ let {
9
+ as: Comp = 'button',
10
+ innerAs,
11
+ onClick,
12
+ onKeyDown,
13
+ ...props
14
+ } = _ref;
15
+ const {
16
+ transition,
17
+ data,
18
+ state,
19
+ buttonRef,
20
+ listboxIdRef,
21
+ isVisible
22
+ } = useComboBoxContext();
23
+ const handleKeyDown = useKeyDown();
24
+ const handleClick = () => {
25
+ const payload = {
30
26
  item: data.navigationItem
31
27
  };
32
-
33
28
  if (state === IDLE) {
34
29
  transition(OPEN_WITH_BUTTON, payload);
35
30
  } else {
36
31
  transition(CLOSE_WITH_BUTTON, payload);
37
32
  }
38
33
  };
39
-
40
- return /*#__PURE__*/_jsx(Comp, _extends({
34
+ return /*#__PURE__*/_jsx(Comp, {
41
35
  as: innerAs,
42
36
  "data-reach-combobox-button": "",
43
37
  "aria-controls": listboxIdRef.current,
@@ -45,7 +39,8 @@ export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref
45
39
  "aria-expanded": isVisible,
46
40
  ref: assignMultipleRefs(ref, buttonRef),
47
41
  onClick: wrapEvent(onClick, handleClick),
48
- onKeyDown: wrapEvent(onKeyDown, handleKeyDown)
49
- }, props));
42
+ onKeyDown: wrapEvent(onKeyDown, handleKeyDown),
43
+ ...props
44
+ });
50
45
  });
51
46
  //# sourceMappingURL=ComboboxButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","ComboboxButton","ref","as","Comp","innerAs","onClick","onKeyDown","props","transition","data","state","buttonRef","listboxIdRef","isVisible","handleKeyDown","handleClick","payload","item","navigationItem","current"],"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { assignMultipleRefs } from '../utils/assign-ref';\n\nexport interface ComboboxButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxButton = forwardRef<\n HTMLButtonElement,\n ComboboxButtonProps\n>(function ComboboxButton(\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\n ref\n) {\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\n useComboBoxContext();\n\n const handleKeyDown = useKeyDown();\n\n const handleClick = () => {\n const payload = {\n item: data.navigationItem,\n };\n\n if (state === IDLE) {\n transition(OPEN_WITH_BUTTON, payload);\n } else {\n transition(CLOSE_WITH_BUTTON, payload);\n }\n };\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-button=\"\"\n aria-controls={listboxIdRef.current}\n aria-haspopup=\"listbox\"\n aria-expanded={isVisible}\n ref={assignMultipleRefs(ref, buttonRef)}\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n {...props}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;;AAWA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,QAEb;EAAA,IAFuBC,OAEvB,QAFuBA,OAEvB;EAAA,IAFgCC,OAEhC,QAFgCA,OAEhC;EAAA,IAFyCC,SAEzC,QAFyCA,SAEzC;EAAA,IAFuDC,KAEvD;;EACA,0BACEd,kBAAkB,EADpB;EAAA,IAAQe,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,IAApB,uBAAoBA,IAApB;EAAA,IAA0BC,KAA1B,uBAA0BA,KAA1B;EAAA,IAAiCC,SAAjC,uBAAiCA,SAAjC;EAAA,IAA4CC,YAA5C,uBAA4CA,YAA5C;EAAA,IAA0DC,SAA1D,uBAA0DA,SAA1D;;EAGA,IAAMC,aAAa,GAAGpB,UAAU,EAAhC;;EAEA,IAAMqB,WAAW,GAAG,SAAdA,WAAc,GAAM;IACxB,IAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IADG,CAAhB;;IAIA,IAAIR,KAAK,KAAKf,IAAd,EAAoB;MAClBa,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;IACD,CAFD,MAEO;MACLR,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;IACD;EACF,CAVD;;EAYA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEZ,OADN;IAEE,8BAA2B,EAF7B;IAGE,iBAAeQ,YAAY,CAACO,OAH9B;IAIE,iBAAc,SAJhB;IAKE,iBAAeN,SALjB;IAME,GAAG,EAAEd,kBAAkB,CAACE,GAAD,EAAMU,SAAN,CANzB;IAOE,OAAO,EAAEb,SAAS,CAACO,OAAD,EAAUU,WAAV,CAPpB;IAQE,SAAS,EAAEjB,SAAS,CAACQ,SAAD,EAAYQ,aAAZ;EARtB,GASMP,KATN,EADF;AAaD,CArCuC,CAAjC"}
1
+ {"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","jsx","_jsx","ComboboxButton","_ref","ref","as","Comp","innerAs","onClick","onKeyDown","props","transition","data","state","buttonRef","listboxIdRef","isVisible","handleKeyDown","handleClick","payload","item","navigationItem","current"],"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { assignMultipleRefs } from '../utils/assign-ref';\n\nexport interface ComboboxButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxButton = forwardRef<\n HTMLButtonElement,\n ComboboxButtonProps\n>(function ComboboxButton(\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\n ref\n) {\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\n useComboBoxContext();\n\n const handleKeyDown = useKeyDown();\n\n const handleClick = () => {\n const payload = {\n item: data.navigationItem,\n };\n\n if (state === IDLE) {\n transition(OPEN_WITH_BUTTON, payload);\n } else {\n transition(CLOSE_WITH_BUTTON, payload);\n }\n };\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-button=\"\"\n aria-controls={listboxIdRef.current}\n aria-haspopup=\"listbox\"\n aria-expanded={isVisible}\n ref={assignMultipleRefs(ref, buttonRef)}\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n {...props}\n />\n );\n});\n"],"mappings":"AAOA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,UAAU,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,SAAS;AAC/E,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,kBAAkB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAWzD,OAAO,MAAMC,cAAc,gBAAGV,UAAU,CAGtC,SAASU,cAAcA,CAAAC,IAAA,EAEvBC,GAAG,EACH;EAAA,IAFA;IAAEC,EAAE,EAAEC,IAAI,GAAG,QAAQ;IAAEC,OAAO;IAAEC,OAAO;IAAEC,SAAS;IAAE,GAAGC;EAAM,CAAC,GAAAP,IAAA;EAG9D,MAAM;IAAEQ,UAAU;IAAEC,IAAI;IAAEC,KAAK;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAU,CAAC,GACnEvB,kBAAkB,CAAC,CAAC;EAEtB,MAAMwB,aAAa,GAAGvB,UAAU,CAAC,CAAC;EAElC,MAAMwB,WAAW,GAAGA,CAAA,KAAM;IACxB,MAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IACb,CAAC;IAED,IAAIR,KAAK,KAAKlB,IAAI,EAAE;MAClBgB,UAAU,CAACf,gBAAgB,EAAEuB,OAAO,CAAC;IACvC,CAAC,MAAM;MACLR,UAAU,CAACd,iBAAiB,EAAEsB,OAAO,CAAC;IACxC;EACF,CAAC;EAED,oBACElB,IAAA,CAACK,IAAI;IACHD,EAAE,EAAEE,OAAQ;IACZ,8BAA2B,EAAE;IAC7B,iBAAeQ,YAAY,CAACO,OAAQ;IACpC,iBAAc,SAAS;IACvB,iBAAeN,SAAU;IACzBZ,GAAG,EAAEL,kBAAkB,CAACK,GAAG,EAAEU,SAAS,CAAE;IACxCN,OAAO,EAAEV,SAAS,CAACU,OAAO,EAAEU,WAAW,CAAE;IACzCT,SAAS,EAAEX,SAAS,CAACW,SAAS,EAAEQ,aAAa,CAAE;IAAA,GAC3CP;EAAK,CACV,CAAC;AAEN,CAAC,CAAC","ignoreList":[]}
@@ -1,117 +1,114 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"];
4
1
  import { forwardRef, useEffect, useRef } from 'react';
5
2
  import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
6
3
  import { assignMultipleRefs, wrapEvent } from '../utils';
7
4
  import { useComboBoxContext } from './context';
8
5
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
10
- var _ref$as = _ref.as,
11
- Comp = _ref$as === void 0 ? 'input' : _ref$as,
12
- innerAs = _ref.innerAs,
13
- _ref$selectOnClick = _ref.selectOnClick,
14
- selectOnClick = _ref$selectOnClick === void 0 ? false : _ref$selectOnClick,
15
- _ref$autocomplete = _ref.autocomplete,
16
- autocomplete = _ref$autocomplete === void 0 ? true : _ref$autocomplete,
17
- _ref$clearOnEscape = _ref.clearOnEscape,
18
- clearOnEscape = _ref$clearOnEscape === void 0 ? false : _ref$clearOnEscape,
19
- onClick = _ref.onClick,
20
- onChange = _ref.onChange,
21
- onKeyDown = _ref.onKeyDown,
22
- onBlur = _ref.onBlur,
23
- onFocus = _ref.onFocus,
24
- preferredId = _ref.id,
25
- _ref$defaultValue = _ref.defaultValue,
26
- defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
27
- controlledValue = _ref.value,
28
- props = _objectWithoutProperties(_ref, _excluded);
6
+ export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
7
+ let {
8
+ as: Comp = 'input',
9
+ innerAs,
10
+ selectOnClick = false,
11
+ autocomplete = true,
12
+ clearOnEscape = false,
13
+ // wrapped events
14
+ onClick,
15
+ onChange,
16
+ onKeyDown,
17
+ onBlur,
18
+ onFocus,
19
+ id: preferredId,
20
+ defaultValue = '',
21
+ // might be controlled
22
+ value: controlledValue,
23
+ ...props
24
+ } = _ref;
25
+ const {
26
+ data: {
27
+ navigationItem,
28
+ text,
29
+ lastActionType
30
+ },
31
+ inputRef,
32
+ state,
33
+ transition,
34
+ listboxIdRef,
35
+ autocompletePropRef,
36
+ clearOnEscapeRef,
37
+ openOnFocus,
38
+ optionsRef,
39
+ labelIdRef
40
+ } = useComboBoxContext();
29
41
 
30
- var _useComboBoxContext = useComboBoxContext(),
31
- _useComboBoxContext$d = _useComboBoxContext.data,
32
- navigationItem = _useComboBoxContext$d.navigationItem,
33
- text = _useComboBoxContext$d.text,
34
- lastActionType = _useComboBoxContext$d.lastActionType,
35
- inputRef = _useComboBoxContext.inputRef,
36
- state = _useComboBoxContext.state,
37
- transition = _useComboBoxContext.transition,
38
- listboxIdRef = _useComboBoxContext.listboxIdRef,
39
- autocompletePropRef = _useComboBoxContext.autocompletePropRef,
40
- clearOnEscapeRef = _useComboBoxContext.clearOnEscapeRef,
41
- openOnFocus = _useComboBoxContext.openOnFocus,
42
- optionsRef = _useComboBoxContext.optionsRef,
43
- labelIdRef = _useComboBoxContext.labelIdRef; // Keep focus on the input component
42
+ // Keep focus on the input component
43
+ useFocusManagement(lastActionType, inputRef);
44
44
 
45
+ // Keep using the defaultValue until the user started interacting
46
+ const hasStartedInteracting = useRef(false);
45
47
 
46
- useFocusManagement(lastActionType, inputRef); // Keep using the defaultValue until the user started interacting
47
-
48
- var hasStartedInteracting = useRef(false); // Because we close the List on blur, we need to track if the blur is
48
+ // Because we close the List on blur, we need to track if the blur is
49
49
  // caused by clicking inside the list, and if so, don't close the List.
50
+ const selectOnClickRef = useRef(false);
51
+ const handleBlur = useBlur();
50
52
 
51
- var selectOnClickRef = useRef(false);
52
- var handleBlur = useBlur(); // Update ref props
53
-
53
+ // Update ref props
54
54
  autocompletePropRef.current = autocomplete;
55
55
  clearOnEscapeRef.current = clearOnEscape;
56
- listboxIdRef.current = preferredId || listboxIdRef.current; // [*]... and when controlled, we don't trigger handleValueChange as the user
56
+ listboxIdRef.current = preferredId || listboxIdRef.current;
57
+
58
+ // [*]... and when controlled, we don't trigger handleValueChange as the user
57
59
  // types, instead the developer controls it with the normal input onChange
58
60
  // prop
59
-
60
- var handleChange = function handleChange(e) {
61
+ const handleChange = e => {
61
62
  // After the user started typing, lets forget the defaultValue
62
63
  hasStartedInteracting.current = true;
63
- var text = e.target.value;
64
-
64
+ const text = e.target.value;
65
65
  if (text.trim() === '') {
66
66
  transition(CLEAR);
67
67
  } else {
68
68
  transition(CHANGE, {
69
- text: text
69
+ text
70
70
  });
71
71
  }
72
72
  };
73
-
74
- var handleKeyDown = useKeyDown();
75
-
76
- var handleFocus = function handleFocus() {
73
+ const handleKeyDown = useKeyDown();
74
+ const handleFocus = () => {
77
75
  if (selectOnClick) {
78
76
  selectOnClickRef.current = true;
79
- } // If we select an option with click, useFocusManagement will focus the
77
+ }
78
+ // If we select an option with click, useFocusManagement will focus the
80
79
  // input, in those cases we don't want to cause the menu to open back up,
81
80
  // so we guard behind these states
82
-
83
-
84
81
  if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {
85
82
  transition(FOCUS, {
86
83
  item: navigationItem
87
84
  });
88
85
  }
89
86
  };
90
-
91
- var handleClick = function handleClick() {
87
+ const handleClick = () => {
92
88
  if (selectOnClickRef.current) {
93
89
  selectOnClickRef.current = false;
94
90
  inputRef.current && inputRef.current.select();
95
91
  }
96
92
  };
97
-
98
- var navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
99
- var fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
100
- var inputStrings = // When idle, we don't have a navigationText on ArrowUp/Down
93
+ const navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
94
+ const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
95
+ const inputStrings =
96
+ // When idle, we don't have a navigationText on ArrowUp/Down
101
97
  autocomplete && state === NAVIGATING ? [navigationText, controlledValue, text, fallbackValue] : [controlledValue, text, fallbackValue];
102
- var inputValue = inputStrings.find(function (str) {
103
- return str !== undefined;
104
- }); // If they are controlling the value we still need to do our transitions, so
98
+ const inputValue = inputStrings.find(str => str !== undefined);
99
+
100
+ // If they are controlling the value we still need to do our transitions, so
105
101
  // we have this derived state to emulate onChange of the input as we receive
106
102
  // new `value`s ...[*]
107
-
108
- useEffect(function () {
103
+ useEffect(() => {
109
104
  transition(INIT, {
110
105
  text: inputValue,
111
106
  item: ''
112
- }); // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ });
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
113
109
  }, []);
114
- return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
110
+ return /*#__PURE__*/_jsx(Comp, {
111
+ ...props,
115
112
  as: innerAs,
116
113
  "data-reach-combobox-input": "",
117
114
  ref: assignMultipleRefs(inputRef, forwardedRef),
@@ -126,6 +123,6 @@ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref,
126
123
  "aria-autocomplete": "both",
127
124
  "aria-activedescendant": navigationItem !== '' ? navigationItem : undefined,
128
125
  autoComplete: "off"
129
- }));
126
+ });
130
127
  });
131
128
  //# sourceMappingURL=ComboboxInput.js.map