@basic-ui/core 0.0.40 → 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 (251) hide show
  1. package/build/cjs/index.js.map +1 -1
  2. package/build/esm/Accordion/Accordion.d.ts +7 -7
  3. package/build/esm/Accordion/Accordion.js +0 -1
  4. package/build/esm/Accordion/Accordion.js.map +1 -1
  5. package/build/esm/Accordion/AccordionBody.d.ts +5 -5
  6. package/build/esm/Accordion/AccordionBody.js +0 -1
  7. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  8. package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
  9. package/build/esm/Accordion/AccordionHeader.js +0 -1
  10. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  11. package/build/esm/Accordion/AccordionItem.d.ts +7 -7
  12. package/build/esm/Accordion/AccordionItem.js +0 -1
  13. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  14. package/build/esm/Accordion/context.d.ts +3 -3
  15. package/build/esm/Accordion/context.js +0 -0
  16. package/build/esm/Accordion/context.js.map +1 -1
  17. package/build/esm/Accordion/index.js +0 -0
  18. package/build/esm/Accordion/scopeQuery.js +0 -0
  19. package/build/esm/CheckBox/CheckBox.d.ts +6 -6
  20. package/build/esm/CheckBox/CheckBox.js +0 -1
  21. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  22. package/build/esm/CheckBox/index.js +0 -0
  23. package/build/esm/ComboBox/Combobox.d.ts +10 -10
  24. package/build/esm/ComboBox/Combobox.js +0 -1
  25. package/build/esm/ComboBox/Combobox.js.map +1 -1
  26. package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
  27. package/build/esm/ComboBox/ComboboxButton.js +0 -1
  28. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  29. package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
  30. package/build/esm/ComboBox/ComboboxInput.js +0 -1
  31. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  32. package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
  33. package/build/esm/ComboBox/ComboboxLabel.js +0 -1
  34. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  35. package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
  36. package/build/esm/ComboBox/ComboboxList.js +0 -1
  37. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  38. package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
  39. package/build/esm/ComboBox/ComboboxOption.js +0 -1
  40. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  41. package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
  42. package/build/esm/ComboBox/ComboboxPopover.js +0 -1
  43. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  44. package/build/esm/ComboBox/cities.js +0 -0
  45. package/build/esm/ComboBox/context.d.ts +10 -10
  46. package/build/esm/ComboBox/context.js +0 -0
  47. package/build/esm/ComboBox/context.js.map +1 -1
  48. package/build/esm/ComboBox/hooks.d.ts +3 -3
  49. package/build/esm/ComboBox/hooks.js +0 -0
  50. package/build/esm/ComboBox/hooks.js.map +1 -1
  51. package/build/esm/ComboBox/index.js +0 -0
  52. package/build/esm/ComboBox/makeHash.js +0 -0
  53. package/build/esm/ComboBox/scopeQuery.js +0 -0
  54. package/build/esm/FocusLock/FocusLock.d.ts +7 -7
  55. package/build/esm/FocusLock/FocusLock.js +0 -1
  56. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  57. package/build/esm/FocusLock/index.js +0 -0
  58. package/build/esm/FocusLock/tabUtils.js +0 -0
  59. package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
  60. package/build/esm/FocusLock/useFocusLock.js +0 -0
  61. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  62. package/build/esm/List/List.d.ts +6 -6
  63. package/build/esm/List/List.js +0 -1
  64. package/build/esm/List/List.js.map +1 -1
  65. package/build/esm/List/ListItem.d.ts +6 -6
  66. package/build/esm/List/ListItem.js +0 -1
  67. package/build/esm/List/ListItem.js.map +1 -1
  68. package/build/esm/List/context.js +0 -0
  69. package/build/esm/List/index.js +0 -0
  70. package/build/esm/Menu/Menu.d.ts +6 -6
  71. package/build/esm/Menu/Menu.js +0 -1
  72. package/build/esm/Menu/Menu.js.map +1 -1
  73. package/build/esm/Menu/MenuButton.d.ts +10 -10
  74. package/build/esm/Menu/MenuButton.js +0 -1
  75. package/build/esm/Menu/MenuButton.js.map +1 -1
  76. package/build/esm/Menu/MenuItem.d.ts +6 -6
  77. package/build/esm/Menu/MenuItem.js +0 -1
  78. package/build/esm/Menu/MenuItem.js.map +1 -1
  79. package/build/esm/Menu/MenuList.d.ts +5 -5
  80. package/build/esm/Menu/MenuList.js +0 -1
  81. package/build/esm/Menu/MenuList.js.map +1 -1
  82. package/build/esm/Menu/MenuPopover.d.ts +5 -5
  83. package/build/esm/Menu/MenuPopover.js +0 -1
  84. package/build/esm/Menu/MenuPopover.js.map +1 -1
  85. package/build/esm/Menu/context.d.ts +2 -2
  86. package/build/esm/Menu/context.js +0 -0
  87. package/build/esm/Menu/context.js.map +1 -1
  88. package/build/esm/Menu/index.js +0 -0
  89. package/build/esm/Menu/scope.js +0 -0
  90. package/build/esm/Modal/Modal.d.ts +6 -7
  91. package/build/esm/Modal/Modal.js +0 -1
  92. package/build/esm/Modal/Modal.js.map +1 -1
  93. package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
  94. package/build/esm/Modal/ModalBackdrop.js +0 -1
  95. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  96. package/build/esm/Modal/index.js +0 -0
  97. package/build/esm/Popper/Popper.d.ts +7 -7
  98. package/build/esm/Popper/Popper.js +0 -1
  99. package/build/esm/Popper/Popper.js.map +1 -1
  100. package/build/esm/Popper/PopperArrow.d.ts +5 -5
  101. package/build/esm/Popper/PopperArrow.js +0 -1
  102. package/build/esm/Popper/PopperArrow.js.map +1 -1
  103. package/build/esm/Popper/context.js +0 -0
  104. package/build/esm/Popper/index.js +0 -0
  105. package/build/esm/Portal/Portal.js +0 -0
  106. package/build/esm/Portal/index.js +0 -0
  107. package/build/esm/RadioButton/RadioButton.d.ts +6 -6
  108. package/build/esm/RadioButton/RadioButton.js +0 -1
  109. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  110. package/build/esm/RadioButton/RadioGroup.d.ts +7 -7
  111. package/build/esm/RadioButton/RadioGroup.js +0 -1
  112. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  113. package/build/esm/RadioButton/context.d.ts +2 -2
  114. package/build/esm/RadioButton/context.js +0 -0
  115. package/build/esm/RadioButton/context.js.map +1 -1
  116. package/build/esm/RadioButton/index.js +0 -0
  117. package/build/esm/SkipNav/SkipNav.d.ts +6 -6
  118. package/build/esm/SkipNav/SkipNav.js +0 -1
  119. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  120. package/build/esm/SkipNav/index.js +0 -0
  121. package/build/esm/Spinner/Spinner.d.ts +7 -7
  122. package/build/esm/Spinner/Spinner.js +0 -1
  123. package/build/esm/Spinner/Spinner.js.map +1 -1
  124. package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
  125. package/build/esm/Spinner/SpinnerButton.js +0 -1
  126. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  127. package/build/esm/Spinner/context.d.ts +2 -2
  128. package/build/esm/Spinner/context.js +0 -0
  129. package/build/esm/Spinner/context.js.map +1 -1
  130. package/build/esm/Spinner/index.js +0 -0
  131. package/build/esm/Tabs/Tab.d.ts +6 -6
  132. package/build/esm/Tabs/Tab.js +0 -1
  133. package/build/esm/Tabs/Tab.js.map +1 -1
  134. package/build/esm/Tabs/TabList.d.ts +6 -6
  135. package/build/esm/Tabs/TabList.js +0 -1
  136. package/build/esm/Tabs/TabList.js.map +1 -1
  137. package/build/esm/Tabs/TabPanel.d.ts +6 -6
  138. package/build/esm/Tabs/TabPanel.js +0 -1
  139. package/build/esm/Tabs/TabPanel.js.map +1 -1
  140. package/build/esm/Tabs/TabPanels.d.ts +5 -5
  141. package/build/esm/Tabs/TabPanels.js +0 -1
  142. package/build/esm/Tabs/TabPanels.js.map +1 -1
  143. package/build/esm/Tabs/Tabs.d.ts +6 -6
  144. package/build/esm/Tabs/Tabs.js +0 -1
  145. package/build/esm/Tabs/Tabs.js.map +1 -1
  146. package/build/esm/Tabs/context.d.ts +2 -2
  147. package/build/esm/Tabs/context.js +0 -0
  148. package/build/esm/Tabs/context.js.map +1 -1
  149. package/build/esm/Tabs/index.js +0 -0
  150. package/build/esm/Tabs/scopeQuery.js +0 -0
  151. package/build/esm/Tooltip/Tooltip.d.ts +7 -8
  152. package/build/esm/Tooltip/Tooltip.js +1 -1
  153. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  154. package/build/esm/Tooltip/index.js +0 -0
  155. package/build/esm/Tooltip/stateMachine.js +0 -0
  156. package/build/esm/Tooltip/useTooltip.d.ts +7 -7
  157. package/build/esm/Tooltip/useTooltip.js +0 -0
  158. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  159. package/build/esm/hooks/index.js +0 -0
  160. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  161. package/build/esm/hooks/useAutoFocus.js +0 -0
  162. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  163. package/build/esm/hooks/useChildrenCounter.js +0 -0
  164. package/build/esm/hooks/useControlledState.d.ts +2 -6
  165. package/build/esm/hooks/useControlledState.js +0 -0
  166. package/build/esm/hooks/useControlledState.js.map +1 -1
  167. package/build/esm/hooks/useFocusReturn.js +0 -0
  168. package/build/esm/hooks/useFocusState.d.ts +3 -3
  169. package/build/esm/hooks/useFocusState.js +0 -0
  170. package/build/esm/hooks/useFocusState.js.map +1 -1
  171. package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
  172. package/build/esm/hooks/useGestureHandlers.js +0 -0
  173. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  174. package/build/esm/hooks/useMeasure.d.ts +2 -2
  175. package/build/esm/hooks/useMeasure.js +0 -0
  176. package/build/esm/hooks/useMeasure.js.map +1 -1
  177. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  178. package/build/esm/hooks/useOnClickOutside.js +0 -0
  179. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  180. package/build/esm/hooks/useOnKeyDown.js +0 -0
  181. package/build/esm/hooks/useReducerMachine.js +0 -0
  182. package/build/esm/hooks/useRemoveBodyScroll.js +0 -0
  183. package/build/esm/hooks/useScope.js +0 -0
  184. package/build/esm/hooks/useThrottle.js +0 -0
  185. package/build/esm/index.js +0 -0
  186. package/build/esm/utils/assignRef.js +0 -0
  187. package/build/esm/utils/clamp.js +0 -0
  188. package/build/esm/utils/createSubscription.js +0 -0
  189. package/build/esm/utils/getCircularIndex.js +0 -0
  190. package/build/esm/utils/index.js +0 -0
  191. package/build/esm/utils/rubberBandClamp.js +0 -0
  192. package/build/esm/utils/wrapEvent.d.ts +3 -3
  193. package/build/esm/utils/wrapEvent.js +0 -0
  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.tsx +12 -6
  199. package/src/Accordion/AccordionBody.tsx +4 -5
  200. package/src/Accordion/AccordionHeader.tsx +30 -27
  201. package/src/Accordion/AccordionItem.tsx +12 -6
  202. package/src/Accordion/context.ts +3 -2
  203. package/src/CheckBox/CheckBox.tsx +5 -6
  204. package/src/ComboBox/ComboBox.story.tsx +3 -3
  205. package/src/ComboBox/Combobox.tsx +5 -8
  206. package/src/ComboBox/ComboboxButton.tsx +13 -7
  207. package/src/ComboBox/ComboboxInput.tsx +18 -10
  208. package/src/ComboBox/ComboboxLabel.tsx +4 -4
  209. package/src/ComboBox/ComboboxList.tsx +5 -6
  210. package/src/ComboBox/ComboboxOption.tsx +11 -7
  211. package/src/ComboBox/ComboboxPopover.tsx +13 -8
  212. package/src/ComboBox/context.ts +10 -9
  213. package/src/ComboBox/hooks.tsx +3 -2
  214. package/src/FocusLock/FocusLock.tsx +13 -7
  215. package/src/FocusLock/useFocusLock.ts +4 -3
  216. package/src/List/List.tsx +5 -5
  217. package/src/List/ListItem.tsx +5 -5
  218. package/src/Menu/Menu.story.tsx +2 -2
  219. package/src/Menu/Menu.tsx +13 -7
  220. package/src/Menu/MenuButton.tsx +12 -9
  221. package/src/Menu/MenuItem.tsx +14 -10
  222. package/src/Menu/MenuList.tsx +5 -5
  223. package/src/Menu/MenuPopover.tsx +4 -4
  224. package/src/Menu/context.ts +9 -4
  225. package/src/Modal/Modal.tsx +10 -6
  226. package/src/Modal/ModalBackdrop.tsx +14 -9
  227. package/src/Popper/Popper.tsx +6 -6
  228. package/src/Popper/PopperArrow.tsx +4 -4
  229. package/src/RadioButton/RadioButton.tsx +11 -6
  230. package/src/RadioButton/RadioGroup.tsx +11 -9
  231. package/src/RadioButton/context.ts +2 -4
  232. package/src/SkipNav/SkipNav.tsx +5 -5
  233. package/src/Spinner/Spinner.tsx +13 -9
  234. package/src/Spinner/SpinnerButton.tsx +11 -6
  235. package/src/Spinner/context.ts +2 -3
  236. package/src/Tabs/Tab.tsx +13 -8
  237. package/src/Tabs/TabList.tsx +5 -5
  238. package/src/Tabs/TabPanel.tsx +5 -5
  239. package/src/Tabs/TabPanels.tsx +4 -4
  240. package/src/Tabs/Tabs.tsx +5 -7
  241. package/src/Tabs/context.ts +2 -3
  242. package/src/Tooltip/Tooltip.story.tsx +1 -1
  243. package/src/Tooltip/Tooltip.tsx +13 -7
  244. package/src/Tooltip/useTooltip.ts +15 -9
  245. package/src/hooks/useAutoFocus.ts +2 -1
  246. package/src/hooks/useControlledState.ts +4 -7
  247. package/src/hooks/useFocusState.ts +3 -2
  248. package/src/hooks/useGestureHandlers.ts +11 -7
  249. package/src/hooks/useMeasure.ts +2 -1
  250. package/src/hooks/useOnClickOutside.ts +2 -2
  251. package/src/utils/wrapEvent.ts +4 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Accordion/AccordionHeader.tsx"],"names":["forwardRef","useRef","useState","useEffect","React","wrapEvent","assignMultipleRefs","getCircularIndex","useAccordionContext","useAccordionItemContext","headerScopeQuery","scopeQuery","AccordionHeader","props","forwardedRef","as","Comp","onKeyDown","onClickProp","onClick","onFocus","onBlur","otherProps","accordionContext","accordionItemContext","ref","index","setIndex","Error","allHeaders","scope","current","queryAllNodes","findIndex","e","expanded","expandedIndex","onChange","handleKeyDown","key","preventDefault","length","nextIndex","focus","handleFocus","childrenHeaderHasFocus","setChildrenHeaderHasFocus","handleBlur","newFocusIsHeader","header","relatedTarget","Boolean","headerId","bodyId","String"],"mappings":";;;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,SAAvC,QAAwD,OAAxD;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,SAAT,EAAoBC,kBAApB,EAAwCC,gBAAxC,QAAgE,UAAhE;AACA,SAASC,mBAAT,EAA8BC,uBAA9B,QAA6D,WAA7D;AACA,SAASC,gBAAgB,IAAIC,UAA7B,QAA+C,cAA/C;;AASA,OAAO,IAAMC,eAAe,gBAAGZ,UAAU,CACvC,SAASY,eAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8C;AAAA,kBAQxCD,KARwC,CAE1CE,EAF0C;AAAA,MAEtCC,IAFsC,0BAE/B,KAF+B;AAAA,MAG1CC,SAH0C,GAQxCJ,KARwC,CAG1CI,SAH0C;AAAA,MAIjCC,WAJiC,GAQxCL,KARwC,CAI1CM,OAJ0C;AAAA,MAK1CC,OAL0C,GAQxCP,KARwC,CAK1CO,OAL0C;AAAA,MAM1CC,MAN0C,GAQxCR,KARwC,CAM1CQ,MAN0C;AAAA,MAOvCC,UAPuC,4BAQxCT,KARwC;;AAS5C,MAAMU,gBAAgB,GAAGf,mBAAmB,EAA5C;AACA,MAAMgB,oBAAoB,GAAGf,uBAAuB,EAApD;AACA,MAAMgB,GAAG,GAAGxB,MAAM,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,IAAA,OAAO,EAAEjC,SAAS,CAACe,OAAD,EAAUwB,WAAV,CATpB;AAUE,IAAA,MAAM,EAAEvC,SAAS,CAACgB,MAAD,EAAS0B,UAAT,CAVnB;AAWE,IAAA,OAAO,EAAE5B,OAXX;AAYE,qBAAemC,MAAM,CAACnB,QAAD;AAZvB,KADF;AAgBD,CApJsC,CAAlC","sourcesContent":["import { forwardRef, useRef, useState, useEffect } from 'react';\nimport * as React from 'react';\n\nimport { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';\nimport { useAccordionContext, useAccordionItemContext } from './context';\nimport { headerScopeQuery as scopeQuery } from './scopeQuery';\n\nexport interface AccordionHeaderProps\n extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLDivElement, AccordionHeaderProps>(\n function AccordionHeader(props, forwardedRef) {\n const {\n as: Comp = 'div',\n onKeyDown,\n onClick: onClickProp,\n onFocus,\n onBlur,\n ...otherProps\n } = props;\n const accordionContext = useAccordionContext();\n const accordionItemContext = useAccordionItemContext();\n const ref = useRef<HTMLDivElement>();\n const [index, setIndex] = useState<number | undefined>();\n\n if (!accordionItemContext) {\n throw new Error('Missing parent <Accordion /> component');\n }\n\n useEffect(() => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n const index = allHeaders.findIndex((e) => e === ref.current);\n setIndex(index);\n }\n }, [accordionContext]);\n\n const onClick = wrapEvent(\n onClickProp,\n (e: React.MouseEvent<HTMLDivElement>) => {\n let index = 0;\n if (accordionItemContext.expanded) {\n index = -1;\n } else if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n index = allHeaders.findIndex((e) => e === ref.current);\n if (index === accordionContext.expandedIndex) {\n index = -1;\n }\n accordionContext.onChange && accordionContext.onChange(e, index);\n }\n\n accordionItemContext.onChange &&\n accordionItemContext.onChange(e, index >= 0);\n }\n );\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n onClick(e as unknown as React.MouseEvent<HTMLDivElement>);\n e.preventDefault();\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n case 'Home':\n case 'End': {\n if (!accordionContext) {\n return;\n }\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n\n e.preventDefault();\n\n if (allHeaders.length === 0) {\n return;\n }\n\n let nextIndex = allHeaders.findIndex((e) => e === ref.current);\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += +1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n\n // We're sure it will not be null, because we already checked for allHeaders.length > 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allHeaders.length)!;\n allHeaders[nextIndex] && allHeaders[nextIndex].focus();\n break;\n }\n default:\n return;\n }\n };\n\n const handleFocus = () => {\n if (accordionContext) {\n if (!accordionContext.childrenHeaderHasFocus) {\n // this is needed to avoid rerendering the parent and\n // messing up with the internal count for children/parent count\n accordionContext.setChildrenHeaderHasFocus(true);\n }\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLDivElement>) => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n const newFocusIsHeader =\n allHeaders.findIndex((header) => header === e.relatedTarget) >= 0;\n\n // only remove focus flag if the focus went to some element\n // that is not an accordion header\n if (!newFocusIsHeader) {\n accordionContext.setChildrenHeaderHasFocus(false);\n }\n }\n };\n\n const expanded = Boolean(\n accordionItemContext.expanded ||\n (accordionContext && accordionContext.expandedIndex === index)\n );\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n {...otherProps}\n id={accordionItemContext.headerId}\n aria-controls={accordionItemContext.bodyId}\n role=\"button\"\n data-accordion-header=\"\"\n tabIndex=\"0\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onClick={onClick}\n aria-expanded={String(expanded)}\n />\n );\n }\n);\n"],"file":"AccordionHeader.js"}
1
+ {"version":3,"sources":["../../../src/Accordion/AccordionHeader.tsx"],"names":["forwardRef","useRef","useState","useEffect","wrapEvent","assignMultipleRefs","getCircularIndex","useAccordionContext","useAccordionItemContext","headerScopeQuery","scopeQuery","AccordionHeader","props","forwardedRef","as","Comp","onKeyDown","onClickProp","onClick","onFocus","onBlur","otherProps","accordionContext","accordionItemContext","ref","index","setIndex","Error","allHeaders","scope","current","queryAllNodes","findIndex","e","expanded","expandedIndex","onChange","handleKeyDown","key","preventDefault","length","nextIndex","focus","handleFocus","childrenHeaderHasFocus","setChildrenHeaderHasFocus","handleBlur","newFocusIsHeader","header","relatedTarget","Boolean","headerId","bodyId","String"],"mappings":";;;AAQA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,SAAvC,QAAwD,OAAxD;AAEA,SAASC,SAAT,EAAoBC,kBAApB,EAAwCC,gBAAxC,QAAgE,UAAhE;AACA,SAASC,mBAAT,EAA8BC,uBAA9B,QAA6D,WAA7D;AACA,SAASC,gBAAgB,IAAIC,UAA7B,QAA+C,cAA/C;;AAQA,OAAO,IAAMC,eAAe,gBAAGX,UAAU,CACvC,SAASW,eAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8C;AAAA,kBAQxCD,KARwC,CAE1CE,EAF0C;AAAA,MAEtCC,IAFsC,0BAE/B,KAF+B;AAAA,MAG1CC,SAH0C,GAQxCJ,KARwC,CAG1CI,SAH0C;AAAA,MAIjCC,WAJiC,GAQxCL,KARwC,CAI1CM,OAJ0C;AAAA,MAK1CC,OAL0C,GAQxCP,KARwC,CAK1CO,OAL0C;AAAA,MAM1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4B,QAH3B;AAIE,qBAAe5B,oBAAoB,CAAC6B,MAJtC;AAKE,IAAA,IAAI,EAAC,QALP;AAME,6BAAsB,EANxB;AAOE,IAAA,QAAQ,EAAC,GAPX;AAQE,IAAA,SAAS,EAAEhD,SAAS,CAACY,SAAD,EAAYqB,aAAZ,CARtB;AASE,IAAA,OAAO,EAAEjC,SAAS,CAACe,OAAD,EAAUwB,WAAV,CATpB;AAUE,IAAA,MAAM,EAAEvC,SAAS,CAACgB,MAAD,EAAS0B,UAAT,CAVnB;AAWE,IAAA,OAAO,EAAE5B,OAXX;AAYE,qBAAemC,MAAM,CAACnB,QAAD;AAZvB,KADF;AAgBD,CAjJsC,CAAlC","sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { forwardRef, useRef, useState, useEffect } from 'react';\n\nimport { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';\nimport { useAccordionContext, useAccordionItemContext } from './context';\nimport { headerScopeQuery as scopeQuery } from './scopeQuery';\n\nexport interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLDivElement, AccordionHeaderProps>(\n function AccordionHeader(props, forwardedRef) {\n const {\n as: Comp = 'div',\n onKeyDown,\n onClick: onClickProp,\n onFocus,\n onBlur,\n ...otherProps\n } = props;\n const accordionContext = useAccordionContext();\n const accordionItemContext = useAccordionItemContext();\n const ref = useRef<HTMLDivElement>();\n const [index, setIndex] = useState<number | undefined>();\n\n if (!accordionItemContext) {\n throw new Error('Missing parent <Accordion /> component');\n }\n\n useEffect(() => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n const index = allHeaders.findIndex((e) => e === ref.current);\n setIndex(index);\n }\n }, [accordionContext]);\n\n const onClick = wrapEvent(onClickProp, (e: MouseEvent<HTMLDivElement>) => {\n let index = 0;\n if (accordionItemContext.expanded) {\n index = -1;\n } else if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n index = allHeaders.findIndex((e) => e === ref.current);\n if (index === accordionContext.expandedIndex) {\n index = -1;\n }\n accordionContext.onChange && accordionContext.onChange(e, index);\n }\n\n accordionItemContext.onChange &&\n accordionItemContext.onChange(e, index >= 0);\n });\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n onClick(e as unknown as MouseEvent<HTMLDivElement>);\n e.preventDefault();\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n case 'Home':\n case 'End': {\n if (!accordionContext) {\n return;\n }\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n\n e.preventDefault();\n\n if (allHeaders.length === 0) {\n return;\n }\n\n let nextIndex = allHeaders.findIndex((e) => e === ref.current);\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += +1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n\n // We're sure it will not be null, because we already checked for allHeaders.length > 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allHeaders.length)!;\n allHeaders[nextIndex] && allHeaders[nextIndex].focus();\n break;\n }\n default:\n return;\n }\n };\n\n const handleFocus = () => {\n if (accordionContext) {\n if (!accordionContext.childrenHeaderHasFocus) {\n // this is needed to avoid rerendering the parent and\n // messing up with the internal count for children/parent count\n accordionContext.setChildrenHeaderHasFocus(true);\n }\n }\n };\n\n const handleBlur = (e: FocusEvent<HTMLDivElement>) => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n const newFocusIsHeader =\n allHeaders.findIndex((header) => header === e.relatedTarget) >= 0;\n\n // only remove focus flag if the focus went to some element\n // that is not an accordion header\n if (!newFocusIsHeader) {\n accordionContext.setChildrenHeaderHasFocus(false);\n }\n }\n };\n\n const expanded = Boolean(\n accordionItemContext.expanded ||\n (accordionContext && accordionContext.expandedIndex === index)\n );\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n {...otherProps}\n id={accordionItemContext.headerId}\n aria-controls={accordionItemContext.bodyId}\n role=\"button\"\n data-accordion-header=\"\"\n tabIndex=\"0\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onClick={onClick}\n aria-expanded={String(expanded)}\n />\n );\n }\n);\n"],"file":"AccordionHeader.js"}
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- export interface AccordionItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { HTMLAttributes, ElementType, ReactNode, KeyboardEvent, MouseEvent } from 'react';
2
+ export interface AccordionItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  expanded?: boolean;
7
- onChange?: (e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>, value: boolean) => void;
7
+ onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
8
8
  }
9
- export declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const AccordionItem: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { Fragment, forwardRef, useId } from 'react';
4
- import * as React from 'react';
5
4
  import { AccordionItemProvider } from './context';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  export var AccordionItem = /*#__PURE__*/forwardRef(function AccordionItem(props, forwardedRef) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Accordion/AccordionItem.tsx"],"names":["Fragment","forwardRef","useId","React","AccordionItemProvider","AccordionItem","props","forwardedRef","as","Comp","expanded","onChange","otherProps","id","headerId","undefined","bodyId","contextValue"],"mappings":";;AAAA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,KAA/B,QAA4C,OAA5C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAGA,SAASC,qBAAT,QAAsC,WAAtC;;AAcA,OAAO,IAAMC,aAAa,gBAAGJ,UAAU,CACrC,SAASI,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;AAAA,kBAMtCD,KANsC,CAExCE,EAFwC;AAAA,MAEpCC,IAFoC,0BAE7BT,QAF6B;AAAA,wBAMtCM,KANsC,CAGxCI,QAHwC;AAAA,MAGxCA,QAHwC,gCAG7B,KAH6B;AAAA,MAIxCC,QAJwC,GAMtCL,KANsC,CAIxCK,QAJwC;AAAA,MAKrCC,UALqC,4BAMtCN,KANsC;;AAO1C,MAAMO,EAAE,GAAGX,KAAK,EAAhB;AAEA,MAAMY,QAAQ,GAAGD,EAAE,8BAAuBA,EAAvB,IAA8BE,SAAjD;AACA,MAAMC,MAAM,GAAGH,EAAE,4BAAqBA,EAArB,IAA4BE,SAA7C;AACA,MAAME,YAAuC,GAAG;AAC9CH,IAAAA,QAAQ,EAARA,QAD8C;AAE9CE,IAAAA,MAAM,EAANA,MAF8C;AAG9CN,IAAAA,QAAQ,EAARA,QAH8C;AAI9CC,IAAAA,QAAQ,EAARA;AAJ8C,GAAhD;AAOA,sBACE,KAAC,qBAAD;AAAuB,IAAA,KAAK,EAAEM,YAA9B;AAAA,2BACE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEV;AAAX,OAA6BK,UAA7B;AADF,IADF;AAKD,CAxBoC,CAAhC","sourcesContent":["import { Fragment, forwardRef, useId } from 'react';\nimport * as React from 'react';\n\nimport type { AccordionItemContextProps } from './context';\nimport { AccordionItemProvider } from './context';\n\nexport interface AccordionItemProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n expanded?: boolean;\n onChange?: (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\n function AccordionItem(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n expanded = false,\n onChange,\n ...otherProps\n } = props;\n const id = useId();\n\n const headerId = id ? `accordion-header-${id}` : undefined;\n const bodyId = id ? `accordion-body-${id}` : undefined;\n const contextValue: AccordionItemContextProps = {\n headerId,\n bodyId,\n expanded,\n onChange,\n };\n\n return (\n <AccordionItemProvider value={contextValue}>\n <Comp ref={forwardedRef} {...otherProps} />\n </AccordionItemProvider>\n );\n }\n);\n"],"file":"AccordionItem.js"}
1
+ {"version":3,"sources":["../../../src/Accordion/AccordionItem.tsx"],"names":["Fragment","forwardRef","useId","AccordionItemProvider","AccordionItem","props","forwardedRef","as","Comp","expanded","onChange","otherProps","id","headerId","undefined","bodyId","contextValue"],"mappings":";;AAOA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,KAA/B,QAA4C,OAA5C;AAGA,SAASC,qBAAT,QAAsC,WAAtC;;AAcA,OAAO,IAAMC,aAAa,gBAAGH,UAAU,CACrC,SAASG,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;AAAA,kBAMtCD,KANsC,CAExCE,EAFwC;AAAA,MAEpCC,IAFoC,0BAE7BR,QAF6B;AAAA,wBAMtCK,KANsC,CAGxCI,QAHwC;AAAA,MAGxCA,QAHwC,gCAG7B,KAH6B;AAAA,MAIxCC,QAJwC,GAMtCL,KANsC,CAIxCK,QAJwC;AAAA,MAKrCC,UALqC,4BAMtCN,KANsC;;AAO1C,MAAMO,EAAE,GAAGV,KAAK,EAAhB;AAEA,MAAMW,QAAQ,GAAGD,EAAE,8BAAuBA,EAAvB,IAA8BE,SAAjD;AACA,MAAMC,MAAM,GAAGH,EAAE,4BAAqBA,EAArB,IAA4BE,SAA7C;AACA,MAAME,YAAuC,GAAG;AAC9CH,IAAAA,QAAQ,EAARA,QAD8C;AAE9CE,IAAAA,MAAM,EAANA,MAF8C;AAG9CN,IAAAA,QAAQ,EAARA,QAH8C;AAI9CC,IAAAA,QAAQ,EAARA;AAJ8C,GAAhD;AAOA,sBACE,KAAC,qBAAD;AAAuB,IAAA,KAAK,EAAEM,YAA9B;AAAA,2BACE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEV;AAAX,OAA6BK,UAA7B;AADF,IADF;AAKD,CAxBoC,CAAhC","sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { Fragment, forwardRef, useId } from 'react';\n\nimport type { AccordionItemContextProps } from './context';\nimport { AccordionItemProvider } from './context';\n\nexport interface AccordionItemProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n expanded?: boolean;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\n function AccordionItem(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n expanded = false,\n onChange,\n ...otherProps\n } = props;\n const id = useId();\n\n const headerId = id ? `accordion-header-${id}` : undefined;\n const bodyId = id ? `accordion-body-${id}` : undefined;\n const contextValue: AccordionItemContextProps = {\n headerId,\n bodyId,\n expanded,\n onChange,\n };\n\n return (\n <AccordionItemProvider value={contextValue}>\n <Comp ref={forwardedRef} {...otherProps} />\n </AccordionItemProvider>\n );\n }\n);\n"],"file":"AccordionItem.js"}
@@ -1,11 +1,11 @@
1
- /// <reference types="react" />
1
+ import type { KeyboardEvent, MouseEvent } from 'react';
2
2
  import type { Scope } from '../hooks/useScope';
3
3
  export interface AccordionContextProps {
4
4
  childrenHeaderHasFocus: boolean;
5
5
  setChildrenHeaderHasFocus: (value: boolean) => void;
6
6
  scope: Scope<HTMLElement>;
7
7
  expandedIndex: number;
8
- onChange?: (e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>, index: number) => void;
8
+ onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, index: number) => void;
9
9
  }
10
10
  export declare const AccordionProvider: import("react").Provider<AccordionContextProps | null>;
11
11
  export declare const useAccordionContext: () => AccordionContextProps | null;
@@ -13,7 +13,7 @@ export interface AccordionItemContextProps {
13
13
  headerId: string | undefined;
14
14
  bodyId: string | undefined;
15
15
  expanded: boolean;
16
- onChange?: (e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>, value: boolean) => void;
16
+ onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
17
17
  }
18
18
  export declare const AccordionItemProvider: import("react").Provider<AccordionItemContextProps | null>;
19
19
  export declare const useAccordionItemContext: () => AccordionItemContextProps | null;
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Accordion/context.ts"],"names":["useContext","createContext","accordionContext","AccordionProvider","Provider","useAccordionContext","accordionItemContext","AccordionItemProvider","useAccordionItemContext"],"mappings":"AAAA,SAASA,UAAT,EAAqBC,aAArB,QAA0C,OAA1C;AAgBA,IAAMC,gBAAgB,gBAAGD,aAAa,CAA+B,IAA/B,CAAtC;IACyBE,iB,GAAsBD,gB,CAAhCE,Q;;AACf,OAAO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB;AAAA,SAAML,UAAU,CAACE,gBAAD,CAAhB;AAAA,CAA5B,C,CAEP;;AAWA,IAAMI,oBAAoB,gBAAGL,aAAa,CACxC,IADwC,CAA1C;IAGyBM,qB,GAA0BD,oB,CAApCF,Q;;AACf,OAAO,IAAMI,uBAAuB,GAAG,SAA1BA,uBAA0B;AAAA,SAAMR,UAAU,CAACM,oBAAD,CAAhB;AAAA,CAAhC","sourcesContent":["import { useContext, createContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// AccordionGroup Component\nexport interface AccordionContextProps {\n childrenHeaderHasFocus: boolean;\n setChildrenHeaderHasFocus: (value: boolean) => void;\n scope: Scope<HTMLElement>;\n expandedIndex: number;\n onChange?: (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n index: number\n ) => void;\n}\n\nconst accordionContext = createContext<AccordionContextProps | null>(null);\nexport const { Provider: AccordionProvider } = accordionContext;\nexport const useAccordionContext = () => useContext(accordionContext);\n\n// Accordion Component\nexport interface AccordionItemContextProps {\n headerId: string | undefined;\n bodyId: string | undefined;\n expanded: boolean;\n onChange?: (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nconst accordionItemContext = createContext<AccordionItemContextProps | null>(\n null\n);\nexport const { Provider: AccordionItemProvider } = accordionItemContext;\nexport const useAccordionItemContext = () => useContext(accordionItemContext);\n"],"file":"context.js"}
1
+ {"version":3,"sources":["../../../src/Accordion/context.ts"],"names":["useContext","createContext","accordionContext","AccordionProvider","Provider","useAccordionContext","accordionItemContext","AccordionItemProvider","useAccordionItemContext"],"mappings":"AACA,SAASA,UAAT,EAAqBC,aAArB,QAA0C,OAA1C;AAgBA,IAAMC,gBAAgB,gBAAGD,aAAa,CAA+B,IAA/B,CAAtC;IACyBE,iB,GAAsBD,gB,CAAhCE,Q;;AACf,OAAO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB;AAAA,SAAML,UAAU,CAACE,gBAAD,CAAhB;AAAA,CAA5B,C,CAEP;;AAWA,IAAMI,oBAAoB,gBAAGL,aAAa,CACxC,IADwC,CAA1C;IAGyBM,qB,GAA0BD,oB,CAApCF,Q;;AACf,OAAO,IAAMI,uBAAuB,GAAG,SAA1BA,uBAA0B;AAAA,SAAMR,UAAU,CAACM,oBAAD,CAAhB;AAAA,CAAhC","sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { useContext, createContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// AccordionGroup Component\nexport interface AccordionContextProps {\n childrenHeaderHasFocus: boolean;\n setChildrenHeaderHasFocus: (value: boolean) => void;\n scope: Scope<HTMLElement>;\n expandedIndex: number;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n index: number\n ) => void;\n}\n\nconst accordionContext = createContext<AccordionContextProps | null>(null);\nexport const { Provider: AccordionProvider } = accordionContext;\nexport const useAccordionContext = () => useContext(accordionContext);\n\n// Accordion Component\nexport interface AccordionItemContextProps {\n headerId: string | undefined;\n bodyId: string | undefined;\n expanded: boolean;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nconst accordionItemContext = createContext<AccordionItemContextProps | null>(\n null\n);\nexport const { Provider: AccordionItemProvider } = accordionItemContext;\nexport const useAccordionItemContext = () => useContext(accordionItemContext);\n"],"file":"context.js"}
File without changes
File without changes
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
2
- export interface CheckBoxProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';
2
+ export interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const CheckBox: React.ForwardRefExoticComponent<CheckBoxProps & React.RefAttributes<HTMLInputElement>>;
7
+ export declare const CheckBox: import("react").ForwardRefExoticComponent<CheckBoxProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import { forwardRef } from 'react';
5
- import * as React from 'react';
6
5
  import { useControlledState } from '../hooks';
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
8
7
  export var CheckBox = /*#__PURE__*/forwardRef(function CheckBox(props, forwardedRef) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/CheckBox/CheckBox.tsx"],"names":["forwardRef","React","useControlledState","CheckBox","props","forwardedRef","as","Comp","checkedProp","checked","defaultChecked","onChangeProp","onChange","otherProps","setValue","e","target"],"mappings":";;;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,kBAAT,QAAmC,UAAnC;;AASA,OAAO,IAAMC,QAAQ,gBAAGH,UAAU,CAChC,SAASG,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AAAA,kBAOjCD,KAPiC,CAEnCE,EAFmC;AAAA,MAE/BC,IAF+B,0BAExB,OAFwB;AAAA,MAG1BC,WAH0B,GAOjCJ,KAPiC,CAGnCK,OAHmC;AAAA,8BAOjCL,KAPiC,CAInCM,cAJmC;AAAA,MAInCA,cAJmC,sCAIlB,KAJkB;AAAA,MAKzBC,YALyB,GAOjCP,KAPiC,CAKnCQ,QALmC;AAAA,MAMhCC,UANgC,4BAOjCT,KAPiC;;AAAA,4BAQTF,kBAAkB,CAC5CM,WAD4C,EAE5CG,YAF4C,EAG5CD,cAH4C,EAI5C,UAACI,QAAD;AAAA,WAAc,UAACC,CAAD,EAAO;AACnBD,MAAAA,QAAQ,CAACC,CAAC,CAACC,MAAF,CAASP,OAAV,CAAR;AACD,KAFD;AAAA,GAJ4C,CART;AAAA;AAAA,MAQ9BA,OAR8B;AAAA,MAQrBG,QARqB;;AAiBrC,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEP,YADP;AAEE,IAAA,IAAI,EAAC,UAFP;AAGE,IAAA,OAAO,EAAEI,OAHX;AAIE,oBAAcA,OAJhB;AAKE,IAAA,QAAQ,EAAEG;AALZ,KAMMC,UANN,EADF;AAUD,CA5B+B,CAA3B","sourcesContent":["import { forwardRef } from 'react';\nimport * as React from 'react';\n\nimport { useControlledState } from '../hooks';\n\nexport interface CheckBoxProps\n extends React.InputHTMLAttributes<HTMLInputElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.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"],"file":"CheckBox.js"}
1
+ {"version":3,"sources":["../../../src/CheckBox/CheckBox.tsx"],"names":["forwardRef","useControlledState","CheckBox","props","forwardedRef","as","Comp","checkedProp","checked","defaultChecked","onChangeProp","onChange","otherProps","setValue","e","target"],"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;AAAA,kBAOjCD,KAPiC,CAEnCE,EAFmC;AAAA,MAE/BC,IAF+B,0BAExB,OAFwB;AAAA,MAG1BC,WAH0B,GAOjCJ,KAPiC,CAGnCK,OAHmC;AAAA,8BAOjCL,KAPiC,CAInCM,cAJmC;AAAA,MAInCA,cAJmC,sCAIlB,KAJkB;AAAA,MAKzBC,YALyB,GAOjCP,KAPiC,CAKnCQ,QALmC;AAAA,MAMhCC,UANgC,4BAOjCT,KAPiC;;AAAA,4BAQTF,kBAAkB,CAC5CM,WAD4C,EAE5CG,YAF4C,EAG5CD,cAH4C,EAI5C,UAACI,QAAD;AAAA,WAAc,UAACC,CAAD,EAAO;AACnBD,MAAAA,QAAQ,CAACC,CAAC,CAACC,MAAF,CAASP,OAAV,CAAR;AACD,KAFD;AAAA,GAJ4C,CART;AAAA;AAAA,MAQ9BA,OAR8B;AAAA,MAQrBG,QARqB;;AAiBrC,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEP,YADP;AAEE,IAAA,IAAI,EAAC,UAFP;AAGE,IAAA,OAAO,EAAEI,OAHX;AAIE,oBAAcA,OAJhB;AAKE,IAAA,QAAQ,EAAEG;AALZ,KAMMC,UANN,EADF;AAUD,CA5B+B,CAA3B","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"],"file":"CheckBox.js"}
File without changes
@@ -1,18 +1,18 @@
1
- import * as React from 'react';
1
+ import type { HTMLAttributes, ReactNode, ElementType } from 'react';
2
2
  export declare type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
3
- export declare type ComboboxProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
3
+ export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
4
4
  onSelect?: SelectEventHandler;
5
5
  openOnFocus?: boolean;
6
6
  selectOnBlur?: boolean;
7
- children?: React.ReactNode;
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
7
+ children?: ReactNode;
8
+ as?: ElementType<any>;
9
+ innerAs?: ElementType<any>;
10
10
  };
11
- export declare const Combobox: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> & {
11
+ export declare const Combobox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
12
12
  onSelect?: SelectEventHandler | undefined;
13
13
  openOnFocus?: boolean | undefined;
14
14
  selectOnBlur?: boolean | undefined;
15
- children?: React.ReactNode;
16
- as?: React.ElementType<any> | undefined;
17
- innerAs?: React.ElementType<any> | undefined;
18
- } & React.RefAttributes<HTMLDivElement>>;
15
+ children?: ReactNode;
16
+ as?: ElementType<any> | undefined;
17
+ innerAs?: ElementType<any> | undefined;
18
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import { forwardRef, useRef, useMemo, useId } from 'react';
5
- import * as React from 'react';
6
5
  import { stateChart, comboboxReducer, isVisible, INIT } from './hooks';
7
6
  import { ComboBoxProvider } from './context';
8
7
  import { useReducerMachine } from '../hooks/useReducerMachine';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/Combobox.tsx"],"names":["forwardRef","useRef","useMemo","useId","React","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;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;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;;AAoBA,OAAO,IAAMC,QAAQ,gBAAGZ,UAAU,CAChC,SAASY,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;;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAGrB,MAAM,CAKtB,EALsB,CAAzB;AAOA,MAAMsB,SAA6B,GAAGtB,MAAM,CAACU,QAAQ,CAAC;AAAEa,IAAAA,OAAO,EAAE;AAAX,GAAD,CAAT,CAA5C,CAZA,CAcA;;AACA,MAAMC,QAAQ,GAAGxB,MAAM,CAAmB,IAAnB,CAAvB;AA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W,MAAAA,KAAK,EAALA,KAR2B;AAS3BO,MAAAA,UAAU,EAAVA,UAT2B;AAU3BV,MAAAA,YAAY,EAAZA,YAV2B;AAW3BC,MAAAA,UAAU,EAAVA,UAX2B;AAY3BJ,MAAAA,mBAAmB,EAAnBA,mBAZ2B;AAa3BC,MAAAA,mBAAmB,EAAnBA,mBAb2B;AAc3BC,MAAAA,gBAAgB,EAAhBA,gBAd2B;AAe3BvB,MAAAA,SAAS,EAAEA,SAAS,CAAC2B,KAAD,CAfO;AAgB3BnB,MAAAA,WAAW,EAAXA,WAhB2B;AAiB3BC,MAAAA,YAAY,EAAZA;AAjB2B,KAA7B;AAAA,GADqB,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 * as React 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<\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,Q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P;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 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"],"file":"Combobox.js"}
@@ -1,9 +1,9 @@
1
- import * 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,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
- import * as React from 'react';
5
4
  import { useComboBoxContext } from './context';
6
5
  import { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';
7
6
  import { wrapEvent } from '../utils/wrapEvent';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"names":["forwardRef","React","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;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,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CAACQ,SAAD,EAAYQ,aAAZ;AARtB,KASMP,KATN,EADF;AAaD,CArCuC,CAAjC","sourcesContent":["import { forwardRef } from 'react';\nimport * as React 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 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 { 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
+ {"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","isVis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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 * 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,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef, useEffect, useRef } from 'react';
4
- import * as React from 'react';
5
4
  import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
6
5
  import { assignMultipleRefs, wrapEvent } from '../utils';
7
6
  import { useComboBoxContext } from './context';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"names":["forwardRef","useEffect","useRef","React","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":";;AAAA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;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,gBAAGhB,UAAU,CACrC,SAASgB,aAAT,OAuBEC,YAvBF,EAwBE;AAAA,qBAtBEC,EAsBF;AAAA,MAtBMC,IAsBN,wBAtBa,OAsBb;AAAA,MArBEC,OAqBF,QArBEA,OAqBF;AAAA,gCApBEC,aAoBF;AAAA,MApBEA,aAoBF,mCApBkB,KAoBlB;AAAA,+BAnBEC,YAmBF;AAAA,MAnBEA,YAmBF,kCAnBiB,IAmBjB;AAAA,gCAlBEC,aAkBF;AAAA,MAlBEA,aAk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KADF;AAqBD,CA1IoC,CAAhC","sourcesContent":["import { forwardRef, useEffect, useRef } from 'react';\nimport * as React 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 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,qBAtBEC,EAsBF;AAAA,MAtBMC,IAsBN,wBAtBa,OAsBb;AAAA,MArBEC,OAqBF,QArBEA,OAqBF;AAAA,gCApBEC,aAoBF;AAAA,M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AACS,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 * 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,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
- import * as React from 'react';
5
4
  import { useComboBoxContext } from './context';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  export var ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"names":["forwardRef","React","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","preferredId","id","props","listboxIdRef","labelIdRef","current"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,kBAAT,QAAmC,WAAnC;;AASA,OAAO,IAAMC,aAAa,gBAAGH,UAAU,CACrC,SAASI,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 { forwardRef } from 'react';\nimport * as React from 'react';\n\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 * 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>>;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef, useRef, useEffect } from 'react';
4
- import * as React from 'react';
5
4
  import { useComboBoxContext } from './context';
6
5
  import { getScope } from '../hooks';
7
6
  import { assignMultipleRefs } from '../utils';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxList.tsx"],"names":["forwardRef","useRef","useEffect","React","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,IAAMC,YAAY,gBAAGP,UAAU,CACpC,SAASO,YAAT,OASEC,GATF,EAUE;AAAA,mCANEC,gBAMF;AAAA,MANEA,gBAMF,sCANqB,KAMrB;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,IAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,KAGL;;AAAA,4BACuDT,kBAAkB,EADzE;AAAA,MACQU,mBADR,uBACQA,mBADR;AAAA,MAC6BC,UAD7B,uBAC6BA,UAD7B;AAAA,MACyCC,SADzC,uBACyCA,SADzC;;AAGA,MAAMC,OAAO,GAAGhB,MAAM,EAAtB;AACAC,EAAAA,SAAS,CAAC,YAAM;AACdc,IAAAA,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;AACD,GAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;AAIAF,EAAAA,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;AAEA,sBACE,KAAC,IAAD,eACMI,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,IAAA,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;AAIE,gCAAyB,EAJ3B;AAKE,IAAA,IAAI,EAAC,SALP;AAME,uBAAiBF,UAAU,CAACG;AAN9B,KADF;AAUD,CA/BmC,CAA/B","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport * as React from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { getScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ComboboxListProps\n extends React.HTMLAttributes<HTMLUListElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n persistSelection?: boolean;\n children?: React.ReactNode;\n}\n\nexport const ComboboxList = forwardRef<HTMLUListElement, ComboboxListProps>(\n function ComboboxList(\n {\n // when true, and the list opens again, the option with a matching value will be\n // automatically highleted.\n persistSelection = false,\n as: Comp = 'ul',\n innerAs,\n ...props\n },\n ref\n ) {\n const { persistSelectionRef, labelIdRef, listScope } = useComboBoxContext();\n\n const listRef = useRef<HTMLUListElement>();\n useEffect(() => {\n listScope.current = getScope(listRef);\n }, [listScope]);\n\n persistSelectionRef.current = persistSelection;\n\n return (\n <Comp\n {...props}\n as={innerAs}\n ref={assignMultipleRefs(ref, listRef)}\n data-reach-combobox-list=\"\"\n role=\"listbox\"\n aria-labelledby={labelIdRef.current}\n />\n );\n }\n);\n"],"file":"ComboboxList.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxList.tsx"],"names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"mappings":";;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,SAA7B,QAA8C,OAA9C;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AASA,OAAO,IAAMC,YAAY,gBAAGN,UAAU,CACpC,SAASM,YAAT,OASEC,GATF,EAUE;AAAA,mCANEC,gBAMF;AAAA,MANEA,gBAMF,sCANqB,KAMrB;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,IAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,KAGL;;AAAA,4BACuDT,kBAAkB,EADzE;AAAA,MACQU,mBADR,uBACQA,mBADR;AAAA,MAC6BC,UAD7B,uBAC6BA,UAD7B;AAAA,MACyCC,SADzC,uBACyCA,SADzC;;AAGA,MAAMC,OAAO,GAAGf,MAAM,EAAtB;AACAC,EAAAA,SAAS,CAAC,YAAM;AACda,IAAAA,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;AACD,GAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;AAIAF,EAAAA,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;AAEA,sBACE,KAAC,IAAD,eACMI,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,IAAA,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;AAIE,gCAAyB,EAJ3B;AAKE,IAAA,IAAI,EAAC,SALP;AAME,uBAAiBF,UAAU,CAACG;AAN9B,KADF;AAUD,CA/BmC,CAA/B","sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\nimport { forwardRef, useRef, useEffect } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { getScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n persistSelection?: boolean;\n children?: ReactNode;\n}\n\nexport const ComboboxList = forwardRef<HTMLUListElement, ComboboxListProps>(\n function ComboboxList(\n {\n // when true, and the list opens again, the option with a matching value will be\n // automatically highleted.\n persistSelection = false,\n as: Comp = 'ul',\n innerAs,\n ...props\n },\n ref\n ) {\n const { persistSelectionRef, labelIdRef, listScope } = useComboBoxContext();\n\n const listRef = useRef<HTMLUListElement>();\n useEffect(() => {\n listScope.current = getScope(listRef);\n }, [listScope]);\n\n persistSelectionRef.current = persistSelection;\n\n return (\n <Comp\n {...props}\n as={innerAs}\n ref={assignMultipleRefs(ref, listRef)}\n data-reach-combobox-list=\"\"\n role=\"listbox\"\n aria-labelledby={labelIdRef.current}\n />\n );\n }\n);\n"],"file":"ComboboxList.js"}
@@ -1,11 +1,11 @@
1
- import * as React from 'react';
2
- export interface ComboboxOptionProps extends React.LiHTMLAttributes<HTMLLIElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
1
+ import type { ElementType, LiHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
2
+ export interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  id: string;
6
6
  value: any;
7
7
  text?: string;
8
- onClick?: React.MouseEventHandler<HTMLLIElement>;
9
- children?: React.ReactNode;
8
+ onClick?: MouseEventHandler<HTMLLIElement>;
9
+ children?: ReactNode;
10
10
  }
11
- export declare const ComboboxOption: React.ForwardRefExoticComponent<ComboboxOptionProps & React.RefAttributes<HTMLLIElement>>;
11
+ export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
@@ -3,7 +3,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
 
4
4
  /* eslint-disable @typescript-eslint/no-use-before-define */
5
5
  import { forwardRef, useEffect, useRef } from 'react';
6
- import * as React from 'react';
7
6
  import { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';
8
7
  import { wrapEvent } from '../utils/wrapEvent';
9
8
  import { useComboBoxContext } from './context';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"names":["forwardRef","useEffect","useRef","React","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","ComboboxOption","ref","children","idProp","id","valueProp","value","textProp","text","onClick","as","Comp","innerAs","props","onSelect","navigationItem","data","transition","optionsRef","transitionCleanupRef","isActiveRef","length","Error","String","opts","current","handleClick","item","undefined"],"mappings":";;;AAAA;AACA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,iBAAT,EAA4BC,eAA5B,QAAmD,SAAnD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,YAAzB;;AAaA,OAAO,IAAMC,cAAc,gBAAGT,UAAU,CACtC,SAASS,cAAT,OAWEC,GAXF,EAYE;AAAA,MAVEC,QAUF,QAVEA,QAUF;AAA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IAAjB,EAAuBF,KAAvB,CAPM,CAAT,CAvBA,CAgCA;AACA;AACA;;AACAa,EAAAA,oBAAoB,CAACM,OAArB,GAA+BR,UAA/B;AACAG,EAAAA,WAAW,CAACK,OAAZ,GAAsBV,cAAc,KAAKX,EAAzC;AAEAZ,EAAAA,SAAS,CAAC,YAAM;AACd,WAAO,YAAM;AACX,UAAI4B,WAAW,CAACK,OAAZ,KAAwB,IAA5B,EAAkC;AAChC;AACA;AACAN,QAAAA,oBAAoB,CAACM,OAArB,CAA6B7B,eAA7B;AACD;AACF,KAND;AAOD,GARQ,EAQN,EARM,CAAT;;AAUA,MAAM8B,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxBZ,IAAAA,QAAQ,IAAIA,QAAQ,CAACN,IAAD,EAAOJ,EAAP,EAAWE,KAAX,CAApB;AACAW,IAAAA,UAAU,CAACtB,iBAAD,EAAoB;AAAEa,MAAAA,IAAI,EAAJA,IAAF;AAAQmB,MAAAA,IAAI,EAAEvB;AAAd,KAApB,CAAV;AACD,GAHD;;AAKA,sBACE,KAAC,IAAD,eACMS,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,kCAA2B,EAH7B;AAIE,IAAA,GAAG,EAAEX,GAJP;AAKE,IAAA,EAAE,EAAEG,EALN;AAME,IAAA,IAAI,EAAC,QANP;AAOE,qBAAegB,WAAW,CAACK,OAP7B;AAQE,wBAAkBL,WAAW,CAACK,OAAZ,GAAsB,EAAtB,GAA2BG,SAR/C,CASE;AACA;AACA;AAXF;AAYE,IAAA,QAAQ,EAAC,IAZX;AAaE,IAAA,OAAO,EAAE/B,SAAS,CAACY,OAAD,EAAUiB,WAAV,CAbpB;AAAA,cAeGxB,QAAQ,IAAIM;AAff,KADF;AAmBD,CArFqC,CAAjC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { forwardRef, useEffect, useRef } from 'react';\nimport * as React from 'react';\n\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport { useComboBoxContext } from './context';\nimport { makeHash } from './makeHash';\n\nexport interface ComboboxOptionProps\n extends React.LiHTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n id: string;\n value: any;\n text?: string;\n onClick?: React.MouseEventHandler<HTMLLIElement>;\n children?: React.ReactNode;\n}\n\nexport const ComboboxOption = forwardRef<HTMLLIElement, ComboboxOptionProps>(\n function ComboboxOption(\n {\n children,\n id: idProp,\n value: valueProp,\n text: textProp,\n onClick,\n as: Comp = 'li',\n innerAs,\n ...props\n },\n ref\n ) {\n const {\n onSelect,\n data: { navigationItem },\n transition,\n optionsRef,\n } = useComboBoxContext();\n const transitionCleanupRef = useRef(transition);\n const isActiveRef = useRef(false);\n\n const value: any = valueProp;\n let text: string = textProp ? textProp : '';\n\n if (text.length === 0) {\n if (typeof valueProp === 'string' && valueProp.length > 0) {\n text = valueProp;\n } else {\n throw new Error('Missing text for <ComboboxOption />');\n }\n }\n\n const id = String(makeHash(idProp));\n\n useEffect(() => {\n const opts = optionsRef.current;\n opts[id] = { value, text };\n\n return () => {\n delete opts[id];\n };\n }, [optionsRef, id, text, value]);\n\n // Keep updating this ref with the current\n // function pointer for transition, so it can\n // be used by the unmount effect below.\n transitionCleanupRef.current = transition;\n isActiveRef.current = navigationItem === id;\n\n useEffect(() => {\n return () => {\n if (isActiveRef.current === true) {\n // clean up selections if this option is getting\n // unmounted and it was the currently selected item\n transitionCleanupRef.current(CLEAR_SELECTION);\n }\n };\n }, []);\n\n const handleClick = () => {\n onSelect && onSelect(text, id, value);\n transition(SELECT_WITH_CLICK, { text, item: id });\n };\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-option=\"\"\n ref={ref}\n id={id}\n role=\"option\"\n aria-selected={isActiveRef.current}\n data-highlighted={isActiveRef.current ? '' : undefined}\n // without this the menu will close from `onBlur`, but with it the\n // element can be `document.activeElement` and then our focus checks in\n // onBlur will work as intended\n tabIndex=\"-1\"\n onClick={wrapEvent(onClick, handleClick)}\n >\n {children || text}\n </Comp>\n );\n }\n);\n"],"file":"ComboboxOption.js"}
1
+ {"version":3,"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","ComboboxOption","ref","children","idProp","id","valueProp","value","textProp","text","onClick","as","Comp","innerAs","props","onSelect","navigationItem","data","transition","optionsRef","transitionCleanupRef","isActiveRef","length","Error","String","opts","current","handleClick","item","undefined"],"mappings":";;;AAAA;AAOA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SAASC,iBAAT,EAA4BC,eAA5B,QAAmD,SAAnD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,YAAzB;;AAYA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CACtC,SAASQ,cAAT,OAWEC,GAXF,EAYE;AAAA,MAVEC,QAUF,QAVEA,QAUF;AAAA,MATMC,MASN,QATEC,EASF;AAAA,MARSC,SAQT,QAREC,KAQF;AAAA,MAPQC,QAOR,QAPEC,IAOF;AAAA,MANEC,OAMF,QANEA,OAMF;AAAA,qBALEC,EAKF;AAAA,MALMC,IAKN,wBALa,IAKb;AAAA,MAJEC,OAIF,QAJEA,OAIF;AAAA,MAHKC,KAGL;;AAAA,4BAMIf,kBAAkB,EANtB;AAAA,MAEEgB,QAFF,uBAEEA,QAFF;AAAA,MAGUC,cAHV,uBAGEC,IAHF,CAGUD,cAHV;AAAA,MAIEE,UAJF,uBAIEA,UAJF;AAAA,MAKEC,UALF,uBAKEA,UALF;;AAOA,MAAMC,oBAAoB,GAAGzB,MAAM,CAACuB,UAAD,CAAnC;AACA,MAAMG,WAAW,GAAG1B,MAAM,CAAC,KAAD,CAA1B;AAEA,MAAMY,KAAU,GA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U,CAACtB,iBAAD,EAAoB;AAAEa,MAAAA,IAAI,EAAJA,IAAF;AAAQmB,MAAAA,IAAI,EAAEvB;AAAd,KAApB,CAAV;AACD,GAHD;;AAKA,sBACE,KAAC,IAAD,eACMS,KADN;AAEE,IAAA,EAAE,EAAED,OAFN;AAGE,kCAA2B,EAH7B;AAIE,IAAA,GAAG,EAAEX,GAJP;AAKE,IAAA,EAAE,EAAEG,EALN;AAME,IAAA,IAAI,EAAC,QANP;AAOE,qBAAegB,WAAW,CAACK,OAP7B;AAQE,wBAAkBL,WAAW,CAACK,OAAZ,GAAsB,EAAtB,GAA2BG,SAR/C,CASE;AACA;AACA;AAXF;AAYE,IAAA,QAAQ,EAAC,IAZX;AAaE,IAAA,OAAO,EAAE/B,SAAS,CAACY,OAAD,EAAUiB,WAAV,CAbpB;AAAA,cAeGxB,QAAQ,IAAIM;AAff,KADF;AAmBD,CArFqC,CAAjC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type {\n ElementType,\n LiHTMLAttributes,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport { useComboBoxContext } from './context';\nimport { makeHash } from './makeHash';\n\nexport interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id: string;\n value: any;\n text?: string;\n onClick?: MouseEventHandler<HTMLLIElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxOption = forwardRef<HTMLLIElement, ComboboxOptionProps>(\n function ComboboxOption(\n {\n children,\n id: idProp,\n value: valueProp,\n text: textProp,\n onClick,\n as: Comp = 'li',\n innerAs,\n ...props\n },\n ref\n ) {\n const {\n onSelect,\n data: { navigationItem },\n transition,\n optionsRef,\n } = useComboBoxContext();\n const transitionCleanupRef = useRef(transition);\n const isActiveRef = useRef(false);\n\n const value: any = valueProp;\n let text: string = textProp ? textProp : '';\n\n if (text.length === 0) {\n if (typeof valueProp === 'string' && valueProp.length > 0) {\n text = valueProp;\n } else {\n throw new Error('Missing text for <ComboboxOption />');\n }\n }\n\n const id = String(makeHash(idProp));\n\n useEffect(() => {\n const opts = optionsRef.current;\n opts[id] = { value, text };\n\n return () => {\n delete opts[id];\n };\n }, [optionsRef, id, text, value]);\n\n // Keep updating this ref with the current\n // function pointer for transition, so it can\n // be used by the unmount effect below.\n transitionCleanupRef.current = transition;\n isActiveRef.current = navigationItem === id;\n\n useEffect(() => {\n return () => {\n if (isActiveRef.current === true) {\n // clean up selections if this option is getting\n // unmounted and it was the currently selected item\n transitionCleanupRef.current(CLEAR_SELECTION);\n }\n };\n }, []);\n\n const handleClick = () => {\n onSelect && onSelect(text, id, value);\n transition(SELECT_WITH_CLICK, { text, item: id });\n };\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-option=\"\"\n ref={ref}\n id={id}\n role=\"option\"\n aria-selected={isActiveRef.current}\n data-highlighted={isActiveRef.current ? '' : undefined}\n // without this the menu will close from `onBlur`, but with it the\n // element can be `document.activeElement` and then our focus checks in\n // onBlur will work as intended\n tabIndex=\"-1\"\n onClick={wrapEvent(onClick, handleClick)}\n >\n {children || text}\n </Comp>\n );\n }\n);\n"],"file":"ComboboxOption.js"}
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- export interface ComboboxPopoverProps extends React.HTMLAttributes<HTMLDivElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- onBlur?: React.FocusEventHandler<HTMLDivElement>;
6
- onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
7
- children?: React.ReactNode;
1
+ import type { ElementType, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, ReactNode } from 'react';
2
+ export interface ComboboxPopoverProps extends HTMLAttributes<HTMLDivElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ onBlur?: FocusEventHandler<HTMLDivElement>;
6
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
7
+ children?: ReactNode;
8
8
  }
9
- export declare const ComboboxPopover: React.ForwardRefExoticComponent<ComboboxPopoverProps & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const ComboboxPopover: import("react").ForwardRefExoticComponent<ComboboxPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
- import * as React from 'react';
5
4
  import { useKeyDown, useBlur } from './hooks';
6
5
  import { wrapEvent } from '../utils/wrapEvent';
7
6
  import { assignMultipleRefs } from '../utils/assignRef';