@basic-ui/core 0.0.38 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/build/cjs/index.js +1 -1
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.d.ts +7 -7
  4. package/build/esm/Accordion/Accordion.js +22 -17
  5. package/build/esm/Accordion/Accordion.js.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +5 -5
  7. package/build/esm/Accordion/AccordionBody.js +23 -15
  8. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  9. package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
  10. package/build/esm/Accordion/AccordionHeader.js +45 -31
  11. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  12. package/build/esm/Accordion/AccordionItem.d.ts +7 -7
  13. package/build/esm/Accordion/AccordionItem.js +16 -16
  14. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  15. package/build/esm/Accordion/context.d.ts +4 -4
  16. package/build/esm/Accordion/context.js +12 -10
  17. package/build/esm/Accordion/context.js.map +1 -1
  18. package/build/esm/CheckBox/CheckBox.d.ts +6 -6
  19. package/build/esm/CheckBox/CheckBox.js +19 -12
  20. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  21. package/build/esm/ComboBox/Combobox.d.ts +10 -10
  22. package/build/esm/ComboBox/Combobox.js +52 -46
  23. package/build/esm/ComboBox/Combobox.js.map +1 -1
  24. package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
  25. package/build/esm/ComboBox/ComboboxButton.js +19 -20
  26. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  27. package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
  28. package/build/esm/ComboBox/ComboboxInput.js +52 -50
  29. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  30. package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
  31. package/build/esm/ComboBox/ComboboxLabel.js +11 -12
  32. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
  34. package/build/esm/ComboBox/ComboboxList.js +15 -17
  35. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
  37. package/build/esm/ComboBox/ComboboxOption.js +31 -34
  38. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
  40. package/build/esm/ComboBox/ComboboxPopover.js +15 -17
  41. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  42. package/build/esm/ComboBox/context.d.ts +13 -13
  43. package/build/esm/ComboBox/context.js +6 -5
  44. package/build/esm/ComboBox/context.js.map +1 -1
  45. package/build/esm/ComboBox/hooks.d.ts +4 -4
  46. package/build/esm/ComboBox/hooks.js +82 -115
  47. package/build/esm/ComboBox/hooks.js.map +1 -1
  48. package/build/esm/ComboBox/makeHash.js +3 -3
  49. package/build/esm/ComboBox/makeHash.js.map +1 -1
  50. package/build/esm/FocusLock/FocusLock.d.ts +7 -7
  51. package/build/esm/FocusLock/FocusLock.js +17 -16
  52. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  53. package/build/esm/FocusLock/tabUtils.js +4 -4
  54. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  55. package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
  56. package/build/esm/FocusLock/useFocusLock.js +10 -11
  57. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  58. package/build/esm/List/List.d.ts +6 -6
  59. package/build/esm/List/List.js +5 -6
  60. package/build/esm/List/List.js.map +1 -1
  61. package/build/esm/List/ListItem.d.ts +6 -6
  62. package/build/esm/List/ListItem.js +5 -6
  63. package/build/esm/List/ListItem.js.map +1 -1
  64. package/build/esm/List/context.js +3 -3
  65. package/build/esm/List/context.js.map +1 -1
  66. package/build/esm/Menu/Menu.d.ts +6 -6
  67. package/build/esm/Menu/Menu.js +29 -21
  68. package/build/esm/Menu/Menu.js.map +1 -1
  69. package/build/esm/Menu/MenuButton.d.ts +10 -10
  70. package/build/esm/Menu/MenuButton.js +27 -24
  71. package/build/esm/Menu/MenuButton.js.map +1 -1
  72. package/build/esm/Menu/MenuItem.d.ts +6 -6
  73. package/build/esm/Menu/MenuItem.js +23 -24
  74. package/build/esm/Menu/MenuItem.js.map +1 -1
  75. package/build/esm/Menu/MenuList.d.ts +5 -5
  76. package/build/esm/Menu/MenuList.js +61 -45
  77. package/build/esm/Menu/MenuList.js.map +1 -1
  78. package/build/esm/Menu/MenuPopover.d.ts +6 -6
  79. package/build/esm/Menu/MenuPopover.js +8 -10
  80. package/build/esm/Menu/MenuPopover.js.map +1 -1
  81. package/build/esm/Menu/context.d.ts +2 -2
  82. package/build/esm/Menu/context.js +11 -8
  83. package/build/esm/Menu/context.js.map +1 -1
  84. package/build/esm/Modal/Modal.d.ts +6 -7
  85. package/build/esm/Modal/Modal.js +11 -10
  86. package/build/esm/Modal/Modal.js.map +1 -1
  87. package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
  88. package/build/esm/Modal/ModalBackdrop.js +20 -19
  89. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  90. package/build/esm/Popper/Popper.d.ts +8 -8
  91. package/build/esm/Popper/Popper.js +46 -37
  92. package/build/esm/Popper/Popper.js.map +1 -1
  93. package/build/esm/Popper/PopperArrow.d.ts +5 -5
  94. package/build/esm/Popper/PopperArrow.js +8 -9
  95. package/build/esm/Popper/PopperArrow.js.map +1 -1
  96. package/build/esm/Popper/context.d.ts +1 -1
  97. package/build/esm/Popper/context.js +5 -3
  98. package/build/esm/Popper/context.js.map +1 -1
  99. package/build/esm/Portal/Portal.d.ts +1 -1
  100. package/build/esm/Portal/Portal.js +6 -5
  101. package/build/esm/Portal/Portal.js.map +1 -1
  102. package/build/esm/RadioButton/RadioButton.d.ts +7 -7
  103. package/build/esm/RadioButton/RadioButton.js +12 -13
  104. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  105. package/build/esm/RadioButton/RadioGroup.d.ts +8 -8
  106. package/build/esm/RadioButton/RadioGroup.js +22 -16
  107. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  108. package/build/esm/RadioButton/context.d.ts +2 -2
  109. package/build/esm/RadioButton/context.js +6 -5
  110. package/build/esm/RadioButton/context.js.map +1 -1
  111. package/build/esm/SkipNav/SkipNav.d.ts +6 -6
  112. package/build/esm/SkipNav/SkipNav.js +5 -6
  113. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  114. package/build/esm/Spinner/Spinner.d.ts +7 -7
  115. package/build/esm/Spinner/Spinner.js +41 -31
  116. package/build/esm/Spinner/Spinner.js.map +1 -1
  117. package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
  118. package/build/esm/Spinner/SpinnerButton.js +11 -12
  119. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  120. package/build/esm/Spinner/context.d.ts +2 -2
  121. package/build/esm/Spinner/context.js +6 -5
  122. package/build/esm/Spinner/context.js.map +1 -1
  123. package/build/esm/Tabs/Tab.d.ts +6 -6
  124. package/build/esm/Tabs/Tab.js +29 -29
  125. package/build/esm/Tabs/Tab.js.map +1 -1
  126. package/build/esm/Tabs/TabList.d.ts +6 -6
  127. package/build/esm/Tabs/TabList.js +24 -21
  128. package/build/esm/Tabs/TabList.js.map +1 -1
  129. package/build/esm/Tabs/TabPanel.d.ts +6 -6
  130. package/build/esm/Tabs/TabPanel.js +12 -12
  131. package/build/esm/Tabs/TabPanel.js.map +1 -1
  132. package/build/esm/Tabs/TabPanels.d.ts +5 -5
  133. package/build/esm/Tabs/TabPanels.js +13 -12
  134. package/build/esm/Tabs/TabPanels.js.map +1 -1
  135. package/build/esm/Tabs/Tabs.d.ts +6 -6
  136. package/build/esm/Tabs/Tabs.js +27 -14
  137. package/build/esm/Tabs/Tabs.js.map +1 -1
  138. package/build/esm/Tabs/context.d.ts +3 -3
  139. package/build/esm/Tabs/context.js +12 -10
  140. package/build/esm/Tabs/context.js.map +1 -1
  141. package/build/esm/Tooltip/Tooltip.d.ts +7 -7
  142. package/build/esm/Tooltip/Tooltip.js +18 -16
  143. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  144. package/build/esm/Tooltip/stateMachine.js +56 -80
  145. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  146. package/build/esm/Tooltip/useTooltip.d.ts +7 -7
  147. package/build/esm/Tooltip/useTooltip.js +32 -30
  148. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  149. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  150. package/build/esm/hooks/useAutoFocus.js +1 -1
  151. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  152. package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
  153. package/build/esm/hooks/useChildrenCounter.js +6 -4
  154. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  155. package/build/esm/hooks/useControlledState.d.ts +3 -7
  156. package/build/esm/hooks/useControlledState.js +7 -2
  157. package/build/esm/hooks/useControlledState.js.map +1 -1
  158. package/build/esm/hooks/useFocusReturn.d.ts +1 -1
  159. package/build/esm/hooks/useFocusReturn.js +6 -6
  160. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  161. package/build/esm/hooks/useFocusState.d.ts +3 -3
  162. package/build/esm/hooks/useFocusState.js +13 -9
  163. package/build/esm/hooks/useFocusState.js.map +1 -1
  164. package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
  165. package/build/esm/hooks/useGestureHandlers.js +59 -63
  166. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  167. package/build/esm/hooks/useMeasure.d.ts +2 -2
  168. package/build/esm/hooks/useMeasure.js +13 -7
  169. package/build/esm/hooks/useMeasure.js.map +1 -1
  170. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  171. package/build/esm/hooks/useOnClickOutside.js +5 -4
  172. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  173. package/build/esm/hooks/useOnKeyDown.js +4 -3
  174. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  175. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  176. package/build/esm/hooks/useReducerMachine.js +13 -10
  177. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  178. package/build/esm/hooks/useRemoveBodyScroll.js +4 -4
  179. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  180. package/build/esm/hooks/useScope.d.ts +1 -1
  181. package/build/esm/hooks/useScope.js +10 -12
  182. package/build/esm/hooks/useScope.js.map +1 -1
  183. package/build/esm/hooks/useThrottle.js +10 -5
  184. package/build/esm/hooks/useThrottle.js.map +1 -1
  185. package/build/esm/utils/assignRef.d.ts +1 -1
  186. package/build/esm/utils/assignRef.js +7 -3
  187. package/build/esm/utils/assignRef.js.map +1 -1
  188. package/build/esm/utils/createSubscription.js +7 -5
  189. package/build/esm/utils/createSubscription.js.map +1 -1
  190. package/build/esm/utils/rubberBandClamp.js +5 -2
  191. package/build/esm/utils/rubberBandClamp.js.map +1 -1
  192. package/build/esm/utils/wrapEvent.d.ts +3 -3
  193. package/build/esm/utils/wrapEvent.js +7 -3
  194. package/build/esm/utils/wrapEvent.js.map +1 -1
  195. package/build/tsconfig-build.tsbuildinfo +1 -0
  196. package/build/tsconfig.tsbuildinfo +1 -1
  197. package/package.json +3 -3
  198. package/src/Accordion/Accordion.story.tsx +1 -0
  199. package/src/Accordion/Accordion.tsx +15 -7
  200. package/src/Accordion/AccordionBody.tsx +7 -8
  201. package/src/Accordion/AccordionHeader.tsx +35 -33
  202. package/src/Accordion/AccordionItem.tsx +15 -7
  203. package/src/Accordion/context.ts +5 -3
  204. package/src/CheckBox/CheckBox.tsx +6 -6
  205. package/src/ComboBox/ComboBox.story.tsx +5 -5
  206. package/src/ComboBox/Combobox.tsx +12 -17
  207. package/src/ComboBox/ComboboxButton.tsx +16 -15
  208. package/src/ComboBox/ComboboxInput.tsx +19 -10
  209. package/src/ComboBox/ComboboxLabel.tsx +5 -4
  210. package/src/ComboBox/ComboboxList.tsx +6 -6
  211. package/src/ComboBox/ComboboxOption.tsx +11 -7
  212. package/src/ComboBox/ComboboxPopover.tsx +14 -8
  213. package/src/ComboBox/context.ts +14 -12
  214. package/src/ComboBox/hooks.tsx +9 -11
  215. package/src/FocusLock/FocusLock.tsx +14 -7
  216. package/src/FocusLock/useFocusLock.ts +5 -3
  217. package/src/List/List.tsx +5 -5
  218. package/src/List/ListItem.tsx +5 -5
  219. package/src/Menu/Menu.story.tsx +7 -6
  220. package/src/Menu/Menu.tsx +16 -8
  221. package/src/Menu/MenuButton.tsx +15 -16
  222. package/src/Menu/MenuItem.tsx +15 -10
  223. package/src/Menu/MenuList.tsx +8 -12
  224. package/src/Menu/MenuPopover.tsx +7 -5
  225. package/src/Menu/context.ts +10 -4
  226. package/src/Modal/Modal.story.tsx +1 -0
  227. package/src/Modal/Modal.tsx +12 -6
  228. package/src/Modal/ModalBackdrop.tsx +15 -9
  229. package/src/Modal/NavDrawer.story.tsx +3 -3
  230. package/src/Popper/Popper.story.tsx +3 -4
  231. package/src/Popper/Popper.tsx +13 -12
  232. package/src/Popper/PopperArrow.tsx +5 -4
  233. package/src/Popper/context.ts +2 -1
  234. package/src/Portal/Portal.tsx +1 -1
  235. package/src/RadioButton/RadioButton.story.tsx +1 -0
  236. package/src/RadioButton/RadioButton.tsx +14 -7
  237. package/src/RadioButton/RadioGroup.tsx +14 -10
  238. package/src/RadioButton/context.ts +2 -4
  239. package/src/SkipNav/SkipNav.tsx +5 -5
  240. package/src/Spinner/Spinner.story.tsx +1 -0
  241. package/src/Spinner/Spinner.tsx +14 -9
  242. package/src/Spinner/SpinnerButton.tsx +12 -6
  243. package/src/Spinner/context.ts +2 -3
  244. package/src/Tabs/Tab.story.tsx +1 -0
  245. package/src/Tabs/Tab.tsx +16 -11
  246. package/src/Tabs/TabList.tsx +6 -5
  247. package/src/Tabs/TabPanel.tsx +6 -5
  248. package/src/Tabs/TabPanels.tsx +4 -4
  249. package/src/Tabs/Tabs.tsx +6 -7
  250. package/src/Tabs/context.ts +4 -4
  251. package/src/Tooltip/Tooltip.story.tsx +3 -2
  252. package/src/Tooltip/Tooltip.tsx +11 -9
  253. package/src/Tooltip/stateMachine.ts +1 -1
  254. package/src/Tooltip/useTooltip.ts +19 -10
  255. package/src/hooks/useAutoFocus.ts +3 -1
  256. package/src/hooks/useChildrenCounter.ts +2 -1
  257. package/src/hooks/useControlledState.ts +7 -8
  258. package/src/hooks/useFocusReturn.ts +2 -1
  259. package/src/hooks/useFocusState.ts +4 -2
  260. package/src/hooks/useGestureHandlers.ts +11 -7
  261. package/src/hooks/useMeasure.ts +2 -1
  262. package/src/hooks/useOnClickOutside.ts +2 -2
  263. package/src/hooks/useReducerMachine.ts +2 -1
  264. package/src/hooks/useScope.ts +2 -1
  265. package/src/utils/assignRef.ts +1 -1
  266. package/src/utils/wrapEvent.ts +4 -5
@@ -1,20 +1,19 @@
1
1
  import { useEffect } from 'react';
2
2
  import { focusOnChildNode } from './tabUtils';
3
- const focusLockStack = [];
3
+ var focusLockStack = [];
4
4
  export function useFocusLock(ref, opts) {
5
- const {
6
- enabled = true,
7
- lockStartRef,
8
- lockEndRef
9
- } = opts;
10
- useEffect(() => {
11
- const rootEl = ref.current;
5
+ var _opts$enabled = opts.enabled,
6
+ enabled = _opts$enabled === void 0 ? true : _opts$enabled,
7
+ lockStartRef = opts.lockStartRef,
8
+ lockEndRef = opts.lockEndRef;
9
+ useEffect(function () {
10
+ var rootEl = ref.current;
12
11
 
13
12
  if (enabled && rootEl) {
14
13
  focusLockStack.push(rootEl);
15
14
 
16
- const listener = event => {
17
- const isActiveFocusLock = focusLockStack[focusLockStack.length - 1] === rootEl;
15
+ var listener = function listener(event) {
16
+ var isActiveFocusLock = focusLockStack[focusLockStack.length - 1] === rootEl;
18
17
 
19
18
  if (!isActiveFocusLock) {
20
19
  // Not the currently focused lock. Forget about it.
@@ -32,7 +31,7 @@ export function useFocusLock(ref, opts) {
32
31
  };
33
32
 
34
33
  document.addEventListener('focusin', listener);
35
- return () => {
34
+ return function () {
36
35
  document.removeEventListener('focusin', listener); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
36
 
38
37
  focusLockStack.pop();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/FocusLock/useFocusLock.ts"],"names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,MAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;AACA,QAAM;AAAEC,IAAAA,OAAO,GAAG,IAAZ;AAAkBC,IAAAA,YAAlB;AAAgCC,IAAAA;AAAhC,MAA+CH,IAArD;AAEAL,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;AACA,QAAIJ,OAAO,IAAIG,MAAf,EAAuB;AACrBP,MAAAA,cAAc,CAACS,IAAf,CAAoBF,MAApB;;AAEA,YAAMG,QAAQ,GAAIC,KAAD,IAAuB;AACtC,cAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;AAEA,YAAI,CAACK,iBAAL,EAAwB;AACtB;AACA;AACD;;AAED,YAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;AACvCT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD,SAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;AAChDT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;AACD,SAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;AACAH,UAAAA,KAAK,CAACM,cAAN;AACAlB,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD;AACF,OApBD;;AAsBAQ,MAAAA,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;AACA,aAAO,MAAM;AACXK,QAAAA,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;AACAV,QAAAA,cAAc,CAACoB,GAAf;AACD,OALD;AAMD,KAlCa,CAmCd;;AACD,GApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD","sourcesContent":["import { useEffect } from 'react';\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: React.MutableRefObject<HTMLElement | null>;\n lockEndRef: React.MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: React.MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"file":"useFocusLock.js"}
1
+ {"version":3,"sources":["../../../src/FocusLock/useFocusLock.ts"],"names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,IAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;AAAA,sBACqDA,IADrD,CACQC,OADR;AAAA,MACQA,OADR,8BACkB,IADlB;AAAA,MACwBC,YADxB,GACqDF,IADrD,CACwBE,YADxB;AAAA,MACsCC,UADtC,GACqDH,IADrD,CACsCG,UADtC;AAGAR,EAAAA,SAAS,CAAC,YAAM;AACd,QAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;AACA,QAAIJ,OAAO,IAAIG,MAAf,EAAuB;AACrBP,MAAAA,cAAc,CAACS,IAAf,CAAoBF,MAApB;;AAEA,UAAMG,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAuB;AACtC,YAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;AAEA,YAAI,CAACK,iBAAL,EAAwB;AACtB;AACA;AACD;;AAED,YAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;AACvCT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD,SAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;AAChDT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;AACD,SAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;AACAH,UAAAA,KAAK,CAACM,cAAN;AACAlB,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD;AACF,OApBD;;AAsBAQ,MAAAA,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;AACA,aAAO,YAAM;AACXK,QAAAA,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;AACAV,QAAAA,cAAc,CAACoB,GAAf;AACD,OALD;AAMD,KAlCa,CAmCd;;AACD,GApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD","sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: MutableRefObject<HTMLElement | null>;\n lockEndRef: MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"file":"useFocusLock.js"}
@@ -1,7 +1,7 @@
1
- import type * as React from 'react';
2
- export interface ListProps extends React.HTMLAttributes<HTMLUListElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface ListProps extends HTMLAttributes<HTMLUListElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLUListElement>>;
7
+ export declare const List: import("react").ForwardRefExoticComponent<ListProps & import("react").RefAttributes<HTMLUListElement>>;
@@ -1,12 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
- export const List = /*#__PURE__*/forwardRef(function List(props, forwardedRef) {
6
- const {
7
- as: Comp = 'ul'
8
- } = props,
9
- otherProps = _objectWithoutPropertiesLoose(props, ["as"]);
5
+ export var List = /*#__PURE__*/forwardRef(function List(props, forwardedRef) {
6
+ var _props$as = props.as,
7
+ Comp = _props$as === void 0 ? 'ul' : _props$as,
8
+ otherProps = _objectWithoutProperties(props, ["as"]);
10
9
 
11
10
  return /*#__PURE__*/_jsx(Comp, _extends({
12
11
  ref: forwardedRef
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/List.tsx"],"names":["forwardRef","List","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;;AASA,OAAO,MAAMC,IAAI,gBAAGD,UAAU,CAA8B,SAASC,IAAT,CAC1DC,KAD0D,EAE1DC,YAF0D,EAG1D;AACA,QAAM;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG;AAAb,MAAqCH,KAA3C;AAAA,QAA4BI,UAA5B,iCAA2CJ,KAA3C;;AAEA,sBAAO,KAAC,IAAD;AAAM,IAAA,GAAG,EAAEC;AAAX,KAA6BG,UAA7B,EAAP;AACD,CAP6B,CAAvB","sourcesContent":["import { forwardRef } from 'react';\nimport type * as React from 'react';\n\nexport interface ListProps extends React.HTMLAttributes<HTMLUListElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const List = forwardRef<HTMLUListElement, ListProps>(function List(\n props,\n forwardedRef\n) {\n const { as: Comp = 'ul', ...otherProps } = props;\n\n return <Comp ref={forwardedRef} {...otherProps} />;\n});\n"],"file":"List.js"}
1
+ {"version":3,"sources":["../../../src/List/List.tsx"],"names":["forwardRef","List","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,IAAI,gBAAGD,UAAU,CAA8B,SAASC,IAAT,CAC1DC,KAD0D,EAE1DC,YAF0D,EAG1D;AAAA,kBAC2CD,KAD3C,CACQE,EADR;AAAA,MACYC,IADZ,0BACmB,IADnB;AAAA,MAC4BC,UAD5B,4BAC2CJ,KAD3C;;AAGA,sBAAO,KAAC,IAAD;AAAM,IAAA,GAAG,EAAEC;AAAX,KAA6BG,UAA7B,EAAP;AACD,CAP6B,CAAvB","sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const List = forwardRef<HTMLUListElement, ListProps>(function List(\n props,\n forwardedRef\n) {\n const { as: Comp = 'ul', ...otherProps } = props;\n\n return <Comp ref={forwardedRef} {...otherProps} />;\n});\n"],"file":"List.js"}
@@ -1,7 +1,7 @@
1
- import type * as React from 'react';
2
- export interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const ListItem: React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<HTMLLIElement>>;
7
+ export declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,12 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef } from 'react';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
- export const ListItem = /*#__PURE__*/forwardRef(function ListItem(props, forwardedRef) {
6
- const {
7
- as: Comp = 'li'
8
- } = props,
9
- otherProps = _objectWithoutPropertiesLoose(props, ["as"]);
5
+ export var ListItem = /*#__PURE__*/forwardRef(function ListItem(props, forwardedRef) {
6
+ var _props$as = props.as,
7
+ Comp = _props$as === void 0 ? 'li' : _props$as,
8
+ otherProps = _objectWithoutProperties(props, ["as"]);
10
9
 
11
10
  return /*#__PURE__*/_jsx(Comp, _extends({
12
11
  tabIndex: -1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/ListItem.tsx"],"names":["forwardRef","ListItem","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;;AASA,OAAO,MAAMC,QAAQ,gBAAGD,UAAU,CAChC,SAASC,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AACrC,QAAM;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG;AAAb,MAAqCH,KAA3C;AAAA,QAA4BI,UAA5B,iCAA2CJ,KAA3C;;AAEA,sBACE,KAAC,IAAD;AACE,IAAA,QAAQ,EAAE,CAAC,CADb;AAEE,sBAAe,EAFjB;AAGE,IAAA,GAAG,EAAEC;AAHP,KAIMG,UAJN,EADF;AAQD,CAZ+B,CAA3B","sourcesContent":["import { forwardRef } from 'react';\nimport type * as React from 'react';\n\nexport interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, forwardedRef) {\n const { as: Comp = 'li', ...otherProps } = props;\n\n return (\n <Comp\n tabIndex={-1}\n data-list-item=\"\"\n ref={forwardedRef}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"ListItem.js"}
1
+ {"version":3,"sources":["../../../src/List/ListItem.tsx"],"names":["forwardRef","ListItem","props","forwardedRef","as","Comp","otherProps"],"mappings":";;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,QAAQ,gBAAGD,UAAU,CAChC,SAASC,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AAAA,kBACMD,KADN,CAC7BE,EAD6B;AAAA,MACzBC,IADyB,0BAClB,IADkB;AAAA,MACTC,UADS,4BACMJ,KADN;;AAGrC,sBACE,KAAC,IAAD;AACE,IAAA,QAAQ,EAAE,CAAC,CADb;AAEE,sBAAe,EAFjB;AAGE,IAAA,GAAG,EAAEC;AAHP,KAIMG,UAJN,EADF;AAQD,CAZ+B,CAA3B","sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListItemProps extends HTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, forwardedRef) {\n const { as: Comp = 'li', ...otherProps } = props;\n\n return (\n <Comp\n tabIndex={-1}\n data-list-item=\"\"\n ref={forwardedRef}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"ListItem.js"}
@@ -1,9 +1,9 @@
1
1
  import { createContext, useContext } from 'react'; // List Component
2
2
 
3
- const ListContext = /*#__PURE__*/createContext(null);
3
+ var ListContext = /*#__PURE__*/createContext(null);
4
4
  ListContext.displayName = 'ListContext';
5
- export const useListContext = () => {
6
- const ctx = useContext(ListContext);
5
+ export var useListContext = function useListContext() {
6
+ var ctx = useContext(ListContext);
7
7
 
8
8
  if (!ctx) {
9
9
  throw new Error('useListContext must be used within a ListContext.Provider');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/List/context.ts"],"names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAKA,MAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACAE,WAAW,CAACC,WAAZ,GAA0B,aAA1B;AAEA,OAAO,MAAMC,cAAc,GAAG,MAAwB;AACpD,QAAMC,GAAG,GAAGJ,UAAU,CAACC,WAAD,CAAtB;;AACA,MAAI,CAACG,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CACJ,2DADI,CAAN;AAGD;;AACD,SAAOD,GAAP;AACD,CARM","sourcesContent":["import { createContext, useContext } from 'react';\n\n// List Component\nexport interface ListContextProps {\n id: string | undefined;\n}\n\nconst ListContext = createContext<ListContextProps | null>(null);\nListContext.displayName = 'ListContext';\n\nexport const useListContext = (): ListContextProps => {\n const ctx = useContext(ListContext);\n if (!ctx) {\n throw new Error(\n 'useListContext must be used within a ListContext.Provider'\n );\n }\n return ctx;\n};\n"],"file":"context.js"}
1
+ {"version":3,"sources":["../../../src/List/context.ts"],"names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAKA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACAE,WAAW,CAACC,WAAZ,GAA0B,aAA1B;AAEA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,GAAwB;AACpD,MAAMC,GAAG,GAAGJ,UAAU,CAACC,WAAD,CAAtB;;AACA,MAAI,CAACG,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CACJ,2DADI,CAAN;AAGD;;AACD,SAAOD,GAAP;AACD,CARM","sourcesContent":["import { createContext, useContext } from 'react';\n\n// List Component\nexport interface ListContextProps {\n id: string | undefined;\n}\n\nconst ListContext = createContext<ListContextProps | null>(null);\nListContext.displayName = 'ListContext';\n\nexport const useListContext = (): ListContextProps => {\n const ctx = useContext(ListContext);\n if (!ctx) {\n throw new Error(\n 'useListContext must be used within a ListContext.Provider'\n );\n }\n return ctx;\n};\n"],"file":"context.js"}
@@ -1,10 +1,10 @@
1
- import type * as React from 'react';
1
+ import type { KeyboardEvent, MouseEvent, PointerEvent, ReactNode, ElementType } from 'react';
2
2
  export interface MenuProps {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
6
- onChange?: (e: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement> | React.PointerEvent<HTMLElement>, isOpen: boolean) => void;
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
+ onChange?: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
7
7
  open?: boolean;
8
8
  defaultOpen?: boolean;
9
9
  }
10
- export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,31 +1,39 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import { forwardRef, useRef, Fragment, useId } from 'react';
4
5
  import { MenuProvider } from './context';
5
6
  import { useControlledState } from '../hooks';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export const Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
8
- const {
9
- as: Comp = Fragment,
10
- open: openProp,
11
- defaultOpen = false,
12
- onChange: onChangeProp
13
- } = props,
14
- otherProps = _objectWithoutPropertiesLoose(props, ["as", "open", "defaultOpen", "onChange"]);
8
+ export var Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
9
+ var _props$as = props.as,
10
+ Comp = _props$as === void 0 ? Fragment : _props$as,
11
+ openProp = props.open,
12
+ _props$defaultOpen = props.defaultOpen,
13
+ defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
14
+ onChangeProp = props.onChange,
15
+ otherProps = _objectWithoutProperties(props, ["as", "open", "defaultOpen", "onChange"]);
16
+
17
+ var menuListIdRef = useRef();
18
+ var openWithArrowKeyRef = useRef(null);
19
+ var buttonRef = useRef(null);
20
+
21
+ var _useControlledState = useControlledState(openProp, onChangeProp, defaultOpen, function (setState) {
22
+ return function (e, isOpen) {
23
+ setState(isOpen);
24
+ };
25
+ }),
26
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
27
+ open = _useControlledState2[0],
28
+ onChange = _useControlledState2[1];
15
29
 
16
- const menuListIdRef = useRef();
17
- const openWithArrowKeyRef = useRef(null);
18
- const buttonRef = useRef(null);
19
- const [open, onChange] = useControlledState(openProp, onChangeProp, defaultOpen, setState => (e, isOpen) => {
20
- setState(isOpen);
21
- });
22
30
  menuListIdRef.current = useId();
23
- const value = {
24
- menuListIdRef,
25
- openWithArrowKeyRef,
26
- open,
27
- onChange,
28
- buttonRef
31
+ var value = {
32
+ menuListIdRef: menuListIdRef,
33
+ openWithArrowKeyRef: openWithArrowKeyRef,
34
+ open: open,
35
+ onChange: onChange,
36
+ buttonRef: buttonRef
29
37
  };
30
38
  return /*#__PURE__*/_jsx(MenuProvider, {
31
39
  value: value,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Menu/Menu.tsx"],"names":["forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","open","openProp","defaultOpen","onChange","onChangeProp","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","current","value"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,KAAvC,QAAoD,OAApD;AAEA,SAASC,YAAT,QAA+C,WAA/C;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAiBA,OAAO,MAAMC,IAAI,gBAAGN,UAAU,CAA4B,SAASM,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;AACA,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAGR,QADP;AAEJS,IAAAA,IAAI,EAAEC,QAFF;AAGJC,IAAAA,WAAW,GAAG,KAHV;AAIJC,IAAAA,QAAQ,EAAEC;AAJN,MAMFR,KANJ;AAAA,QAKKS,UALL,iCAMIT,KANJ;;AAOA,QAAMU,aAAa,GAAGhB,MAAM,EAA5B;AACA,QAAMiB,mBAAmB,GAAGjB,MAAM,CAAiC,IAAjC,CAAlC;AACA,QAAMkB,SAAS,GAAGlB,MAAM,CAAoB,IAApB,CAAxB;AACA,QAAM,CAACU,IAAD,EAAOG,QAAP,IAAmBT,kBAAkB,CACzCO,QADyC,EAEzCG,YAFyC,EAGzCF,WAHyC,EAIxCO,QAAD,IAAc,CAACC,CAAD,EAAIC,MAAJ,KAAe;AAC3BF,IAAAA,QAAQ,CAACE,MAAD,CAAR;AACD,GANwC,CAA3C;AASAL,EAAAA,aAAa,CAACM,OAAd,GAAwBpB,KAAK,EAA7B;AAEA,QAAMqB,KAAuB,GAAG;AAC9BP,IAAAA,aAD8B;AAE9BC,IAAAA,mBAF8B;AAG9BP,IAAAA,IAH8B;AAI9BG,IAAAA,QAJ8B;AAK9BK,IAAAA;AAL8B,GAAhC;AAQA,sBACE,KAAC,YAAD;AAAc,IAAA,KAAK,EAAEK,KAArB;AAAA,2BACE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEhB;AAAX,OAA6BQ,UAA7B;AADF,IADF;AAKD,CAtC6B,CAAvB","sourcesContent":["import { forwardRef, useRef, Fragment, useId } from 'react';\nimport type * as React from 'react';\nimport { MenuProvider, MenuContextProps } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface MenuProps {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n onChange?: (\n e:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>\n | React.PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n\n menuListIdRef.current = useId();\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp ref={forwardedRef} {...otherProps} />\n </MenuProvider>\n );\n});\n"],"file":"Menu.js"}
1
+ {"version":3,"sources":["../../../src/Menu/Menu.tsx"],"names":["forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","openProp","open","defaultOpen","onChangeProp","onChange","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","current","value"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,KAAvC,QAAoD,OAApD;AAGA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAiBA,OAAO,IAAMC,IAAI,gBAAGN,UAAU,CAA4B,SAASM,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;AAAA,kBAOID,KAPJ,CAEEE,EAFF;AAAA,MAEMC,IAFN,0BAEaR,QAFb;AAAA,MAGQS,QAHR,GAOIJ,KAPJ,CAGEK,IAHF;AAAA,2BAOIL,KAPJ,CAIEM,WAJF;AAAA,MAIEA,WAJF,mCAIgB,KAJhB;AAAA,MAKYC,YALZ,GAOIP,KAPJ,CAKEQ,QALF;AAAA,MAMKC,UANL,4BAOIT,KAPJ;;AAQA,MAAMU,aAAa,GAAGhB,MAAM,EAA5B;AACA,MAAMiB,mBAAmB,GAAGjB,MAAM,CAAiC,IAAjC,CAAlC;AACA,MAAMkB,SAAS,GAAGlB,MAAM,CAAoB,IAApB,CAAxB;;AAVA,4BAWyBI,kBAAkB,CACzCM,QADyC,EAEzCG,YAFyC,EAGzCD,WAHyC,EAIzC,UAACO,QAAD;AAAA,WAAc,UAACC,CAAD,EAAIC,MAAJ,EAAe;AAC3BF,MAAAA,QAAQ,CAACE,MAAD,CAAR;AACD,KAFD;AAAA,GAJyC,CAX3C;AAAA;AAAA,MAWOV,IAXP;AAAA,MAWaG,QAXb;;AAoBAE,EAAAA,aAAa,CAACM,OAAd,GAAwBpB,KAAK,EAA7B;AAEA,MAAMqB,KAAuB,GAAG;AAC9BP,IAAAA,aAAa,EAAbA,aAD8B;AAE9BC,IAAAA,mBAAmB,EAAnBA,mBAF8B;AAG9BN,IAAAA,IAAI,EAAJA,IAH8B;AAI9BG,IAAAA,QAAQ,EAARA,QAJ8B;AAK9BI,IAAAA,SAAS,EAATA;AAL8B,GAAhC;AAQA,sBACE,KAAC,YAAD;AAAc,IAAA,KAAK,EAAEK,KAArB;AAAA,2BACE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEhB;AAAX,OAA6BQ,UAA7B;AADF,IADF;AAKD,CAtC6B,CAAvB","sourcesContent":["import type {\n KeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ElementType,\n} from 'react';\nimport { forwardRef, useRef, Fragment, useId } from 'react';\n\nimport type { MenuContextProps } from './context';\nimport { MenuProvider } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface MenuProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n\n menuListIdRef.current = useId();\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp ref={forwardedRef} {...otherProps} />\n </MenuProvider>\n );\n});\n"],"file":"Menu.js"}
@@ -1,11 +1,11 @@
1
- import type * as React from 'react';
2
- export declare type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- onClick?: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
1
+ import type { ButtonHTMLAttributes, ElementType, KeyboardEvent, MouseEvent } from 'react';
2
+ export declare type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ onClick?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
6
6
  };
7
- export declare const MenuButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
8
- as?: React.ElementType<any> | undefined;
9
- innerAs?: React.ElementType<any> | undefined;
10
- onClick?: ((e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void) | undefined;
11
- } & React.RefAttributes<HTMLButtonElement>>;
7
+ export declare const MenuButton: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
8
+ as?: ElementType<any> | undefined;
9
+ innerAs?: ElementType<any> | undefined;
10
+ onClick?: ((e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void) | undefined;
11
+ } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,41 +1,44 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef, useId } from 'react';
4
4
  import { useMenuContext } from './context';
5
5
  import { wrapEvent } from '../utils/wrapEvent';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwardedRef) {
8
- const {
9
- as: Comp = 'button',
10
- id: preferredId,
11
- onClick,
12
- onKeyDown,
13
- disabled
14
- } = props,
15
- otherProps = _objectWithoutPropertiesLoose(props, ["as", "id", "onClick", "onKeyDown", "disabled"]);
7
+ export var MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwardedRef) {
8
+ var _props$as = props.as,
9
+ Comp = _props$as === void 0 ? 'button' : _props$as,
10
+ preferredId = props.id,
11
+ onClick = props.onClick,
12
+ onKeyDown = props.onKeyDown,
13
+ disabled = props.disabled,
14
+ otherProps = _objectWithoutProperties(props, ["as", "id", "onClick", "onKeyDown", "disabled"]);
16
15
 
17
- const {
18
- menuListIdRef,
19
- openWithArrowKeyRef,
20
- open,
21
- buttonRef,
22
- onChange
23
- } = useMenuContext();
24
- const buttonIdGenerated = useId();
25
- const buttonId = preferredId || buttonIdGenerated;
16
+ var _useMenuContext = useMenuContext(),
17
+ menuListIdRef = _useMenuContext.menuListIdRef,
18
+ openWithArrowKeyRef = _useMenuContext.openWithArrowKeyRef,
19
+ open = _useMenuContext.open,
20
+ buttonRef = _useMenuContext.buttonRef,
21
+ onChange = _useMenuContext.onChange;
26
22
 
27
- const handleKeyDown = e => {
23
+ var buttonIdGenerated = useId();
24
+ var buttonId = preferredId || buttonIdGenerated;
25
+
26
+ var handleKeyDown = function handleKeyDown(e) {
28
27
  if (disabled) {
29
28
  return;
30
29
  }
31
30
 
32
31
  buttonRef.current = e.currentTarget;
33
32
 
34
- const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);
33
+ var isArrowKey = function isArrowKey() {
34
+ return ['ArrowUp', 'ArrowDown'].includes(e.key);
35
+ };
35
36
 
36
- const isEnterKey = () => [' ', 'Enter'].includes(e.key);
37
+ var isEnterKey = function isEnterKey() {
38
+ return [' ', 'Enter'].includes(e.key);
39
+ };
37
40
 
38
- const openedWithArrow = isArrowKey();
41
+ var openedWithArrow = isArrowKey();
39
42
 
40
43
  if (openedWithArrow || isEnterKey()) {
41
44
  if (openedWithArrow) {
@@ -48,7 +51,7 @@ export const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, for
48
51
  }
49
52
  };
50
53
 
51
- const handleClick = e => {
54
+ var handleClick = function handleClick(e) {
52
55
  if (disabled) {
53
56
  return;
54
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Menu/MenuButton.tsx"],"names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","id","preferredId","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,oBAA1B;;AAYA,OAAO,MAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;AACvC,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAG,QADP;AAEJC,IAAAA,EAAE,EAAEC,WAFA;AAGJC,IAAAA,OAHI;AAIJC,IAAAA,SAJI;AAKJC,IAAAA;AALI,MAOFR,KAPJ;AAAA,QAMKS,UANL,iCAOIT,KAPJ;;AAQA,QAAM;AACJU,IAAAA,aADI;AAEJC,IAAAA,mBAFI;AAGJC,IAAAA,IAHI;AAIJC,IAAAA,SAJI;AAKJC,IAAAA;AALI,MAMFjB,cAAc,EANlB;AAQA,QAAMkB,iBAAiB,GAAGnB,KAAK,EAA/B;AACA,QAAMoB,QAAQ,GAAGX,WAAW,IAAIU,iBAAhC;;AAEA,QAAME,aAAa,GAAIC,CAAD,IAA+C;AACnE,QAAIV,QAAJ,EAAc;AACZ;AACD;;AACDK,IAAAA,SAAS,CAACM,OAAV,GAAoBD,CAAC,CAACE,aAAtB;;AAEA,UAAMC,UAAU,GAAG,MAAM,CAAC,SAAD,EAAY,WAAZ,EAAyBC,QAAzB,CAAkCJ,CAAC,CAACK,GAApC,CAAzB;;AACA,UAAMC,UAAU,GAAG,MAAM,CAAC,GAAD,EAAM,OAAN,EAAeF,QAAf,CAAwBJ,CAAC,CAACK,GAA1B,CAAzB;;AAEA,UAAME,eAAe,GAAGJ,UAAU,EAAlC;;AACA,QAAII,eAAe,IAAID,UAAU,EAAjC,EAAqC;AACnC,UAAIC,eAAJ,EAAqB;AACnB;AACAd,QAAAA,mBAAmB,CAACQ,OAApB,GAA8BD,CAAC,CAACK,GAAhC;AACD;;AACDT,MAAAA,QAAQ,IAAIA,QAAQ,CAACI,CAAD,EAAI,IAAJ,CAApB;AACAA,MAAAA,CAAC,CAACQ,cAAF;AACD;AACF,GAlBD;;AAoBA,QAAMC,WAAW,GAAIT,CAAD,IAA4C;AAC9D,QAAIV,QAAJ,EAAc;AACZ;AACD;;AACDK,IAAAA,SAAS,CAACM,OAAV,GAAoBD,CAAC,CAACE,aAAtB;AAEAN,IAAAA,QAAQ,IAAIA,QAAQ,CAACI,CAAD,EAAI,CAACN,IAAL,CAApB;AACD,GAPD;;AASA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEX,YADP;AAEE,IAAA,EAAE,EAAEe,QAFN;AAGE,IAAA,IAAI,EAAC,QAHP;AAIE,IAAA,IAAI,EAAC,QAJP;AAKE,qBAAe,IALjB;AAME,qBAAeN,aAAa,CAACS,OAN/B;AAOE,qBAAeP,IAAI,GAAG,IAAH,GAAUgB,SAP/B;AAQE,wBAAiB,EARnB;AASE,IAAA,OAAO,EAAE9B,SAAS,CAACQ,OAAD,EAAUqB,WAAV,CATpB;AAUE,IAAA,SAAS,EAAE7B,SAAS,CAACS,SAAD,EAAYU,aAAZ,CAVtB;AAWE,IAAA,QAAQ,EAAET;AAXZ,KAYMC,UAZN,EADF;AAgBD,CAlEiC,CAA7B","sourcesContent":["import { forwardRef, useId } from 'react';\nimport type * as React from 'react';\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrapEvent';\n\nexport type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onClick?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n buttonRef,\n onChange,\n } = useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange && onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n onChange && onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"MenuButton.js"}
1
+ {"version":3,"sources":["../../../src/Menu/MenuButton.tsx"],"names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","preferredId","id","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"mappings":";;AAMA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,oBAA1B;;AAUA,OAAO,IAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;AAAA,kBAQnCD,KARmC,CAErCE,EAFqC;AAAA,MAEjCC,IAFiC,0BAE1B,QAF0B;AAAA,MAGjCC,WAHiC,GAQnCJ,KARmC,CAGrCK,EAHqC;AAAA,MAIrCC,OAJqC,GAQnCN,KARmC,CAIrCM,OAJqC;AAAA,MAKrCC,SALqC,GAQnCP,KARmC,CAKrCO,SALqC;AAAA,MAMrCC,QANqC,GAQnCR,KARmC,CAMrCQ,QANqC;AAAA,MAOlCC,UAPkC,4BAQnCT,KARmC;;AAAA,wBAUrCH,cAAc,EAVuB;AAAA,MAS/Ba,aAT+B,mBAS/BA,aAT+B;AAAA,MAShBC,mBATgB,mBAShBA,mBATgB;AAAA,MASKC,IATL,mBASKA,IATL;AAAA,MASWC,SATX,mBASWA,SATX;AAAA,MASsBC,QATtB,mBASsBA,QATtB;;AAYvC,MAAMC,iBAAiB,GAAGnB,KAAK,EAA/B;AACA,MAAMoB,QAAQ,GAAGZ,WAAW,IAAIW,iBAAhC;;AAEA,MAAME,aAAa,GAAG,SAAhBA,aAAgB,CAACC,CAAD,EAAyC;AAC7D,QAAIV,QAAJ,EAAc;AACZ;AACD;;AACDK,IAAAA,SAAS,CAACM,OAAV,GAAoBD,CAAC,CAACE,aAAtB;;AAEA,QAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,aAAM,CAAC,SAAD,EAAY,WAAZ,EAAyBC,QAAzB,CAAkCJ,CAAC,CAACK,GAApC,CAAN;AAAA,KAAnB;;AACA,QAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,aAAM,CAAC,GAAD,EAAM,OAAN,EAAeF,QAAf,CAAwBJ,CAAC,CAACK,GAA1B,CAAN;AAAA,KAAnB;;AAEA,QAAME,eAAe,GAAGJ,UAAU,EAAlC;;AACA,QAAII,eAAe,IAAID,UAAU,EAAjC,EAAqC;AACnC,UAAIC,eAAJ,EAAqB;AACnB;AACAd,QAAAA,mBAAmB,CAACQ,OAApB,GAA8BD,CAAC,CAACK,GAAhC;AACD;;AACDT,MAAAA,QAAQ,IAAIA,QAAQ,CAACI,CAAD,EAAI,IAAJ,CAApB;AACAA,MAAAA,CAAC,CAACQ,cAAF;AACD;AACF,GAlBD;;AAoBA,MAAMC,WAAW,GAAG,SAAdA,WAAc,CAACT,CAAD,EAAsC;AACxD,QAAIV,QAAJ,EAAc;AACZ;AACD;;AACDK,IAAAA,SAAS,CAACM,OAAV,GAAoBD,CAAC,CAACE,aAAtB;AAEAN,IAAAA,QAAQ,IAAIA,QAAQ,CAACI,CAAD,EAAI,CAACN,IAAL,CAApB;AACD,GAPD;;AASA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEX,YADP;AAEE,IAAA,EAAE,EAAEe,QAFN;AAGE,IAAA,IAAI,EAAC,QAHP;AAIE,IAAA,IAAI,EAAC,QAJP;AAKE,qBAAe,IALjB;AAME,qBAAeN,aAAa,CAACS,OAN/B;AAOE,qBAAeP,IAAI,GAAG,IAAH,GAAUgB,SAP/B;AAQE,wBAAiB,EARnB;AASE,IAAA,OAAO,EAAE9B,SAAS,CAACQ,OAAD,EAAUqB,WAAV,CATpB;AAUE,IAAA,SAAS,EAAE7B,SAAS,CAACS,SAAD,EAAYU,aAAZ,CAVtB;AAWE,IAAA,QAAQ,EAAET;AAXZ,KAYMC,UAZN,EADF;AAgBD,CA7DiC,CAA7B","sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrapEvent';\n\nexport type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const { menuListIdRef, openWithArrowKeyRef, open, buttonRef, onChange } =\n useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange && onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n onChange && onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"MenuButton.js"}
@@ -1,8 +1,8 @@
1
- import type * as React from 'react';
2
- export interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- onSelect?: (e: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
1
+ import type { LiHTMLAttributes, ElementType, MouseEvent, KeyboardEvent } from 'react';
2
+ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ onSelect?: (e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>) => void;
6
6
  disabled?: boolean;
7
7
  }
8
- export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<any>>;
8
+ export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<any>>;
@@ -1,32 +1,31 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import { forwardRef, useRef, useId } from 'react';
4
4
  import { useMenuContext, useMenuListContext } from './context';
5
5
  import { assignMultipleRefs } from '../utils/assignRef';
6
6
  import { wrapEvent } from '../utils';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwardedRef) {
9
- const {
10
- as: Comp = 'li',
11
- disabled,
12
- onSelect,
13
- onClick,
14
- onKeyDown
15
- } = props,
16
- otherProps = _objectWithoutPropertiesLoose(props, ["as", "disabled", "onSelect", "onClick", "onKeyDown"]);
8
+ export var MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwardedRef) {
9
+ var _props$as = props.as,
10
+ Comp = _props$as === void 0 ? 'li' : _props$as,
11
+ disabled = props.disabled,
12
+ onSelect = props.onSelect,
13
+ onClick = props.onClick,
14
+ onKeyDown = props.onKeyDown,
15
+ otherProps = _objectWithoutProperties(props, ["as", "disabled", "onSelect", "onClick", "onKeyDown"]);
17
16
 
18
- const {
19
- onChange,
20
- buttonRef
21
- } = useMenuContext();
22
- const {
23
- navigationItem,
24
- onNavigate
25
- } = useMenuListContext();
26
- const ref = useRef();
27
- const itemId = useId();
28
- const isActive = ref.current && ref.current === navigationItem;
29
- const handleSelect = wrapEvent(onSelect, e => {
17
+ var _useMenuContext = useMenuContext(),
18
+ onChange = _useMenuContext.onChange,
19
+ buttonRef = _useMenuContext.buttonRef;
20
+
21
+ var _useMenuListContext = useMenuListContext(),
22
+ navigationItem = _useMenuListContext.navigationItem,
23
+ onNavigate = _useMenuListContext.onNavigate;
24
+
25
+ var ref = useRef();
26
+ var itemId = useId();
27
+ var isActive = ref.current && ref.current === navigationItem;
28
+ var handleSelect = wrapEvent(onSelect, function (e) {
30
29
  var _buttonRef$current;
31
30
 
32
31
  onChange && onChange(e, false);
@@ -34,7 +33,7 @@ export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forward
34
33
  e.preventDefault();
35
34
  });
36
35
 
37
- const handleClick = e => {
36
+ var handleClick = function handleClick(e) {
38
37
  if (!disabled) {
39
38
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
39
  onNavigate && onNavigate(ref.current);
@@ -42,7 +41,7 @@ export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forward
42
41
  }
43
42
  };
44
43
 
45
- const handleKeyDown = e => {
44
+ var handleKeyDown = function handleKeyDown(e) {
46
45
  switch (e.key) {
47
46
  case 'Enter':
48
47
  case ' ':
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Menu/MenuItem.tsx"],"names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,MAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;AACA,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAG,IADP;AAEJC,IAAAA,QAFI;AAGJC,IAAAA,QAHI;AAIJC,IAAAA,OAJI;AAKJC,IAAAA;AALI,MAOFP,KAPJ;AAAA,QAMKQ,UANL,iCAOIR,KAPJ;;AAQA,QAAM;AAAES,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA0Bf,cAAc,EAA9C;AACA,QAAM;AAAEgB,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAiChB,kBAAkB,EAAzD;AACA,QAAMiB,GAAG,GAAGpB,MAAM,EAAlB;AACA,QAAMqB,MAAM,GAAGpB,KAAK,EAApB;AAEA,QAAMqB,QAAQ,GAAGF,GAAG,CAACG,OAAJ,IAAeH,GAAG,CAACG,OAAJ,KAAgBL,cAAhD;AAEA,QAAMM,YAAY,GAAGnB,SAAS,CAC5BO,QAD4B,EAG1Ba,CADF,IAEK;AAAA;;AACHT,IAAAA,QAAQ,IAAIA,QAAQ,CAACS,CAAD,EAAI,KAAJ,CAApB;AACA,0BAAAR,SAAS,CAACM,OAAV,wCAAmBG,KAAnB;AACAD,IAAAA,CAAC,CAACE,cAAF;AACD,GAR2B,CAA9B;;AAWA,QAAMC,WAAW,GAAIH,CAAD,IAAwC;AAC1D,QAAI,CAACd,QAAL,EAAe;AACb;AACAQ,MAAAA,UAAU,IAAIA,UAAU,CAACC,GAAG,CAACG,OAAL,CAAxB;AACAC,MAAAA,YAAY,CAACC,CAAD,CAAZ;AACD;AACF,GAND;;AAQA,QAAMI,aAAwD,GAAIJ,CAAD,IAAO;AACtE,YAAQA,CAAC,CAACK,GAAV;AACE,WAAK,OAAL;AACA,WAAK,GAAL;AACE,YAAI,CAACnB,QAAL,EAAe;AACba,UAAAA,YAAY,CAACC,CAAD,CAAZ;AACD;;AACD;AANJ;AAQD,GATD;;AAWA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAErB,kBAAkB,CAACgB,GAAD,EAAMZ,YAAN,CADzB;AAEE,IAAA,EAAE,EAAEG,QAAQ,GAAGoB,SAAH,GAAeV,MAF7B;AAGE,sBAAe,EAHjB;AAIE,wBAAkBC,QAAQ,GAAG,EAAH,GAAQS,SAJpC;AAKE,IAAA,IAAI,EAAC,UALP;AAME,IAAA,OAAO,EAAE1B,SAAS,CAACQ,OAAD,EAAUe,WAAV,CANpB;AAOE,IAAA,QAAQ,EAAEjB,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAP5B;AAQE,IAAA,SAAS,EAAEN,SAAS,CAACS,SAAD,EAAYe,aAAZ,CARtB;AASE,qBAAelB,QAAQ,GAAG,EAAH,GAAQoB,SATjC;AAUE,qBAAepB,QAAQ,GAAG,EAAH,GAAQoB,SAVjC;AAWE,IAAA,QAAQ,EAAEpB;AAXZ,KAYMI,UAZN,EADF;AAgBD,CAjEiC,CAA3B","sourcesContent":["import { forwardRef, useRef, useId } from 'react';\nimport type * as React from 'react';\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onSelect?: (\n e: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (\n e: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>\n ) => {\n onChange && onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: React.MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"file":"MenuItem.js"}
1
+ {"version":3,"sources":["../../../src/Menu/MenuItem.tsx"],"names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"mappings":";;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,IAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;AAAA,kBAQID,KARJ,CAEEE,EAFF;AAAA,MAEMC,IAFN,0BAEa,IAFb;AAAA,MAGEC,QAHF,GAQIJ,KARJ,CAGEI,QAHF;AAAA,MAIEC,QAJF,GAQIL,KARJ,CAIEK,QAJF;AAAA,MAKEC,OALF,GAQIN,KARJ,CAKEM,OALF;AAAA,MAMEC,SANF,GAQIP,KARJ,CAMEO,SANF;AAAA,MAOKC,UAPL,4BAQIR,KARJ;;AAAA,wBASgCL,cAAc,EAT9C;AAAA,MASQc,QATR,mBASQA,QATR;AAAA,MASkBC,SATlB,mBASkBA,SATlB;;AAAA,4BAUuCd,kBAAkB,EAVzD;AAAA,MAUQe,cAVR,uBAUQA,cAVR;AAAA,MAUwBC,UAVxB,uBAUwBA,UAVxB;;AAWA,MAAMC,GAAG,GAAGpB,MAAM,EAAlB;AACA,MAAMqB,MAAM,GAAGpB,KAAK,EAApB;AAEA,MAAMqB,QAAQ,GAAGF,GAAG,CAACG,OAAJ,IAAeH,GAAG,CAACG,OAAJ,KAAgBL,cAAhD;AAEA,MAAMM,YAAY,GAAGnB,SAAS,CAC5BO,QAD4B,EAE5B,UAACa,CAAD,EAAiE;AAAA;;AAC/DT,IAAAA,QAAQ,IAAIA,QAAQ,CAACS,CAAD,EAAI,KAAJ,CAApB;AACA,0BAAAR,SAAS,CAACM,OAAV,wCAAmBG,KAAnB;AACAD,IAAAA,CAAC,CAACE,cAAF;AACD,GAN2B,CAA9B;;AASA,MAAMC,WAAW,GAAG,SAAdA,WAAc,CAACH,CAAD,EAAkC;AACpD,QAAI,CAACd,QAAL,EAAe;AACb;AACAQ,MAAAA,UAAU,IAAIA,UAAU,CAACC,GAAG,CAACG,OAAL,CAAxB;AACAC,MAAAA,YAAY,CAACC,CAAD,CAAZ;AACD;AACF,GAND;;AAQA,MAAMI,aAAkD,GAAG,SAArDA,aAAqD,CAACJ,CAAD,EAAO;AAChE,YAAQA,CAAC,CAACK,GAAV;AACE,WAAK,OAAL;AACA,WAAK,GAAL;AACE,YAAI,CAACnB,QAAL,EAAe;AACba,UAAAA,YAAY,CAACC,CAAD,CAAZ;AACD;;AACD;AANJ;AAQD,GATD;;AAWA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAErB,kBAAkB,CAACgB,GAAD,EAAMZ,YAAN,CADzB;AAEE,IAAA,EAAE,EAAEG,QAAQ,GAAGoB,SAAH,GAAeV,MAF7B;AAGE,sBAAe,EAHjB;AAIE,wBAAkBC,QAAQ,GAAG,EAAH,GAAQS,SAJpC;AAKE,IAAA,IAAI,EAAC,UALP;AAME,IAAA,OAAO,EAAE1B,SAAS,CAACQ,OAAD,EAAUe,WAAV,CANpB;AAOE,IAAA,QAAQ,EAAEjB,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAP5B;AAQE,IAAA,SAAS,EAAEN,SAAS,CAACS,SAAD,EAAYe,aAAZ,CARtB;AASE,qBAAelB,QAAQ,GAAG,EAAH,GAAQoB,SATjC;AAUE,qBAAepB,QAAQ,GAAG,EAAH,GAAQoB,SAVjC;AAWE,IAAA,QAAQ,EAAEpB;AAXZ,KAYMI,UAZN,EADF;AAgBD,CA/DiC,CAA3B","sourcesContent":["import type {\n LiHTMLAttributes,\n ElementType,\n MouseEvent,\n KeyboardEvent,\n KeyboardEventHandler,\n} from 'react';\nimport { forwardRef, useRef, useId } from 'react';\n\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onSelect?: (\n e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (e: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => {\n onChange && onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"file":"MenuItem.js"}
@@ -1,7 +1,7 @@
1
- import type * as React from 'react';
2
- export interface MenuListProps extends React.HTMLAttributes<HTMLUListElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
1
+ import type { HTMLAttributes, ElementType } from 'react';
2
+ export interface MenuListProps extends HTMLAttributes<HTMLUListElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  defaultActiveItemValue?: string;
6
6
  }
7
- export declare const MenuList: React.ForwardRefExoticComponent<MenuListProps & React.RefAttributes<HTMLUListElement>>;
7
+ export declare const MenuList: import("react").ForwardRefExoticComponent<MenuListProps & import("react").RefAttributes<HTMLUListElement>>;