@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/Spinner/Spinner.tsx"],"names":["forwardRef","useState","useRef","React","SpinnerProvider","clamp","clampFunc","wrapEvent","assignMultipleRefs","Spinner","props","forwardedRef","as","Comp","minValue","maxValue","stepSize","value","onChange","onKeyDown","onBlur","onFocus","otherProps","spinnerHasFocus","setSpinnerHasFocus","ref","handleKeyDown","e","nextValue","key","current","focus","preventDefault","handleFocus","handleBlur"],"mappings":";;;AAAA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,MAA/B,QAA6C,OAA7C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,eAAT,QAAgC,WAAhC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,gBAAnC;AACA,SAASC,SAAT,EAAoBC,kBAApB,QAA8C,UAA9C;;AAmBA,OAAO,IAAMC,OAAO,gBAAGT,UAAU,CAC/B,SAASS,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AAAA,kBAYhCD,KAZgC,CAElCE,EAFkC;AAAA,MAE9BC,IAF8B,0BAEvB,KAFuB;AAAA,wBAYhCH,KAZgC,CAGlCI,QAHkC;AAAA,MAGlCA,QAHkC,gCAGvB,CAAC,IAHsB;AAAA,wBAYhCJ,KAZgC,CAIlCK,QAJkC;AAAA,MAIlCA,QAJkC,gCAIvB,IAJuB;AAAA,wBAYhCL,KAZgC,CAKlCM,QALkC;AAAA,MAKlCA,QALkC,gCAKvB,EALuB;AAAA,qBAYhCN,KAZgC,CAMlCO,KANkC;AAAA,MAMlCA,KANkC,6BAM1B,CAN0B;AAAA,MAOlCC,QAPkC,GAYhCR,KAZgC,CAOlCQ,QAPkC;AAAA,MAQlCC,SARkC,GAYhCT,KAZgC,CAQlCS,SARkC;AAAA,MASlCC,MATkC,GAYhCV,KAZgC,CASlCU,MATkC;AAAA,MAUlCC,OAVkC,GAYhCX,KAZgC,CAUlCW,OAVkC;AAAA,MAW/BC,UAX+B,4BAYhCZ,KAZgC;;AAAA,kBAaUT,QAAQ,CAA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ACE,KAAC,eAAD;AACE,IAAA,KAAK,EAAE;AACLV,MAAAA,QAAQ,EAARA,QADK;AAELG,MAAAA,KAAK,EAALA,KAFK;AAGLF,MAAAA,QAAQ,EAARA,QAHK;AAILC,MAAAA,QAAQ,EAARA,QAJK;AAKLE,MAAAA,QAAQ,EAARA,QALK;AAMLb,MAAAA,KAAK,EAALA,KANK;AAOLkB,MAAAA,eAAe,EAAfA;AAPK,KADT;AAAA,2BAWE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEf,kBAAkB,CAACG,YAAD,EAAec,GAAf,CADzB;AAEE,2BAAkB,EAFpB;AAGE,MAAA,IAAI,EAAC,YAHP;AAIE,uBAAeR,KAJjB;AAKE,uBAAeH,QALjB;AAME,uBAAeC,QANjB;AAOE,MAAA,QAAQ,EAAE,CAPZ;AAQE,MAAA,SAAS,EAAER,SAAS,CAACY,SAAD,EAAYO,aAAZ,CARtB;AASE,MAAA,OAAO,EAAEnB,SAAS,CAACc,OAAD,EAAUY,WAAV,CATpB;AAUE,MAAA,MAAM,EAAE1B,SAAS,CAACa,MAAD,EAASc,UAAT;AAVnB,OAWMZ,UAXN;AAXF,IADF;AA2BD,CAvF8B,CAA1B","sourcesContent":["import { forwardRef, useState, useRef } from 'react';\nimport * as React from 'react';\n\nimport { SpinnerProvider } from './context';\nimport { clamp as clampFunc } from '../utils/clamp';\nimport { wrapEvent, assignMultipleRefs } from '../utils';\n\nexport interface SpinnerProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n value?: number;\n minValue?: number;\n maxValue?: number;\n stepSize?: number;\n onChange?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n}\n\nexport const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(\n function Spinner(props, forwardedRef) {\n const {\n as: Comp = 'div',\n minValue = -1000,\n maxValue = 1000,\n stepSize = 10,\n value = 0,\n onChange,\n onKeyDown,\n onBlur,\n onFocus,\n ...otherProps\n } = props;\n const [spinnerHasFocus, setSpinnerHasFocus] = useState(false);\n const ref = useRef<HTMLDivElement>();\n\n const clamp = (value: number) => clampFunc(value, minValue, maxValue);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let nextValue = value;\n switch (e.key) {\n case 'ArrowUp':\n nextValue += 1;\n break;\n case 'ArrowDown':\n nextValue -= 1;\n break;\n case 'Home':\n nextValue = minValue;\n break;\n case 'End':\n nextValue = maxValue;\n break;\n case 'PageUp':\n nextValue += stepSize;\n break;\n case 'PageDown':\n nextValue -= stepSize;\n break;\n default:\n return;\n }\n\n ref.current && ref.current.focus();\n nextValue = clamp(nextValue);\n if (nextValue !== value) {\n e.preventDefault(); // prevent scrolling\n onChange && onChange(e, nextValue);\n }\n };\n\n const handleFocus = () => {\n setSpinnerHasFocus(true);\n };\n\n const handleBlur = () => {\n setSpinnerHasFocus(false);\n };\n\n return (\n <SpinnerProvider\n value={{\n minValue,\n value,\n maxValue,\n stepSize,\n onChange,\n clamp,\n spinnerHasFocus,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-spinner-root=\"\"\n role=\"spinbutton\"\n aria-valuenow={value}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n {...otherProps}\n />\n </SpinnerProvider>\n );\n }\n);\n"],"file":"Spinner.js"}
1
+ {"version":3,"sources":["../../../src/Spinner/Spinner.tsx"],"names":["forwardRef","useState","useRef","SpinnerProvider","clamp","clampFunc","wrapEvent","assignMultipleRefs","Spinner","props","forwardedRef","as","Comp","minValue","maxValue","stepSize","value","onChange","onKeyDown","onBlur","onFocus","otherProps","spinnerHasFocus","setSpinnerHasFocus","ref","handleKey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,MAAAA,eAAe,EAAfA;AAPK,KADT;AAAA,2BAWE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEf,kBAAkB,CAACG,YAAD,EAAec,GAAf,CADzB;AAEE,2BAAkB,EAFpB;AAGE,MAAA,IAAI,EAAC,YAHP;AAIE,uBAAeR,KAJjB;AAKE,uBAAeH,QALjB;AAME,uBAAeC,QANjB;AAOE,MAAA,QAAQ,EAAE,CAPZ;AAQE,MAAA,SAAS,EAAER,SAAS,CAACY,SAAD,EAAYO,aAAZ,CARtB;AASE,MAAA,OAAO,EAAEnB,SAAS,CAACc,OAAD,EAAUY,WAAV,CATpB;AAUE,MAAA,MAAM,EAAE1B,SAAS,CAACa,MAAD,EAASc,UAAT;AAVnB,OAWMZ,UAXN;AAXF,IADF;AA2BD,CAvF8B,CAA1B","sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n} from 'react';\nimport { forwardRef, useState, useRef } from 'react';\n\nimport { SpinnerProvider } from './context';\nimport { clamp as clampFunc } from '../utils/clamp';\nimport { wrapEvent, assignMultipleRefs } from '../utils';\n\nexport interface SpinnerProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n value?: number;\n minValue?: number;\n maxValue?: number;\n stepSize?: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n}\n\nexport const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(\n function Spinner(props, forwardedRef) {\n const {\n as: Comp = 'div',\n minValue = -1000,\n maxValue = 1000,\n stepSize = 10,\n value = 0,\n onChange,\n onKeyDown,\n onBlur,\n onFocus,\n ...otherProps\n } = props;\n const [spinnerHasFocus, setSpinnerHasFocus] = useState(false);\n const ref = useRef<HTMLDivElement>();\n\n const clamp = (value: number) => clampFunc(value, minValue, maxValue);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n let nextValue = value;\n switch (e.key) {\n case 'ArrowUp':\n nextValue += 1;\n break;\n case 'ArrowDown':\n nextValue -= 1;\n break;\n case 'Home':\n nextValue = minValue;\n break;\n case 'End':\n nextValue = maxValue;\n break;\n case 'PageUp':\n nextValue += stepSize;\n break;\n case 'PageDown':\n nextValue -= stepSize;\n break;\n default:\n return;\n }\n\n ref.current && ref.current.focus();\n nextValue = clamp(nextValue);\n if (nextValue !== value) {\n e.preventDefault(); // prevent scrolling\n onChange && onChange(e, nextValue);\n }\n };\n\n const handleFocus = () => {\n setSpinnerHasFocus(true);\n };\n\n const handleBlur = () => {\n setSpinnerHasFocus(false);\n };\n\n return (\n <SpinnerProvider\n value={{\n minValue,\n value,\n maxValue,\n stepSize,\n onChange,\n clamp,\n spinnerHasFocus,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-spinner-root=\"\"\n role=\"spinbutton\"\n aria-valuenow={value}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n {...otherProps}\n />\n </SpinnerProvider>\n );\n }\n);\n"],"file":"Spinner.js"}
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
2
- export interface SpinnerButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
2
+ export interface SpinnerButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  type: 'next' | 'previous';
7
7
  }
8
- export declare const SpinnerButton: React.ForwardRefExoticComponent<SpinnerButtonProps & React.RefAttributes<HTMLButtonElement>>;
8
+ export declare const SpinnerButton: import("react").ForwardRefExoticComponent<SpinnerButtonProps & 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 { useSpinnerContext } from './context';
6
5
  import { wrapEvent } from '../utils';
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Spinner/SpinnerButton.tsx"],"names":["forwardRef","React","useSpinnerContext","wrapEvent","SpinnerButton","props","forwardedRef","as","Comp","type","onClick","otherProps","spinnerContext","Error","handleClick","e","delta","onChange","value","disabled","maxValue","minValue","spinnerHasFocus","undefined"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAUA,OAAO,IAAMC,aAAa,gBAAGJ,UAAU,CACrC,SAASI,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;AAAA,kBACoBD,KADpB,CAClCE,EADkC;AAAA,MAC9BC,IAD8B,0BACvB,QADuB;AAAA,MACbC,IADa,GACoBJ,KADpB,CACbI,IADa;AAAA,MACPC,OADO,GACoBL,KADpB,CACPK,OADO;AAAA,MACKC,UADL,4BACoBN,KADpB;;AAE1C,MAAMO,cAAc,GAAGV,iBAAiB,EAAxC;;AAEA,MAAI,CAACU,cAAL,EAAqB;AACnB,UAAM,IAAIC,KAAJ,CAAU,uCAAV,CAAN;AACD;;AAED,MAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,CAAD,EAA4C;AAC9D,QAAMC,KAAK,GAAGP,IAAI,KAAK,MAAT,GAAkB,CAAlB,GAAsB,CAAC,CAArC;AAEAG,IAAAA,cAAc,CAACK,QAAf,IACEL,cAAc,CAACK,QAAf,CAAwBF,CAAxB,EAA2BH,cAAc,CAACM,KAAf,GAAuBF,KAAlD,CADF;AAED,GALD;;AAOA,MAAMG,QAAQ,GACZV,IAAI,KAAK,MAAT,GACIG,cAAc,CAACM,KAAf,GAAuB,CAAvB,GAA2BN,cAAc,CAACQ,QAD9C,GAEIR,cAAc,CAACM,KAAf,GAAuB,CAAvB,GAA2BN,cAAc,CAACS,QAHhD;AAKA,sBACE,KAAC,IAAD,eACMV,UADN;AAEE,IAAA,IAAI,EAAC,QAFP;AAGE,IAAA,GAAG,EAAEL,YAHP;AAIE,IAAA,QAAQ,EAAE,CAAC,CAJb;AAKE,2BAAoB,EALtB;AAME,8BAAwBM,cAAc,CAACU,eAAf,GAAiC,EAAjC,GAAsCC,SANhE;AAOE,IAAA,QAAQ,EAAEJ,QAPZ;AAQE,IAAA,OAAO,EAAEhB,SAAS,CAACO,OAAD,EAAUI,WAAV;AARpB,KADF;AAYD,CAjCoC,CAAhC","sourcesContent":["import { forwardRef } from 'react';\nimport * as React from 'react';\n\nimport { useSpinnerContext } from './context';\nimport { wrapEvent } from '../utils';\n\nexport interface SpinnerButtonProps\n extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n type: 'next' | 'previous';\n}\n\nexport const SpinnerButton = forwardRef<HTMLButtonElement, SpinnerButtonProps>(\n function SpinnerButton(props, forwardedRef) {\n const { as: Comp = 'button', type, onClick, ...otherProps } = props;\n const spinnerContext = useSpinnerContext();\n\n if (!spinnerContext) {\n throw new Error('Missing <Spinner /> in component tree');\n }\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n const delta = type === 'next' ? 1 : -1;\n\n spinnerContext.onChange &&\n spinnerContext.onChange(e, spinnerContext.value + delta);\n };\n\n const disabled =\n type === 'next'\n ? spinnerContext.value + 1 > spinnerContext.maxValue\n : spinnerContext.value - 1 < spinnerContext.minValue;\n\n return (\n <Comp\n {...otherProps}\n type=\"button\"\n ref={forwardedRef}\n tabIndex={-1}\n data-spinner-button=\"\"\n data-spinner-has-focus={spinnerContext.spinnerHasFocus ? '' : undefined}\n disabled={disabled}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n }\n);\n"],"file":"SpinnerButton.js"}
1
+ {"version":3,"sources":["../../../src/Spinner/SpinnerButton.tsx"],"names":["forwardRef","useSpinnerContext","wrapEvent","SpinnerButton","props","forwardedRef","as","Comp","type","onClick","otherProps","spinnerContext","Error","handleClick","e","delta","onChange","value","disabled","maxValue","minValue","spinnerHasFocus","undefined"],"mappings":";;AAMA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAUA,OAAO,IAAMC,aAAa,gBAAGH,UAAU,CACrC,SAASG,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;AAAA,kBACoBD,KADpB,CAClCE,EADkC;AAAA,MAC9BC,IAD8B,0BACvB,QADuB;AAAA,MACbC,IADa,GACoBJ,KADpB,CACbI,IADa;AAAA,MACPC,OADO,GACoBL,KADpB,CACPK,OADO;AAAA,MACKC,UADL,4BACoBN,KADpB;;AAE1C,MAAMO,cAAc,GAAGV,iBAAiB,EAAxC;;AAEA,MAAI,CAACU,cAAL,EAAqB;AACnB,UAAM,IAAIC,KAAJ,CAAU,uCAAV,CAAN;AACD;;AAED,MAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,CAAD,EAAsC;AACxD,QAAMC,KAAK,GAAGP,IAAI,KAAK,MAAT,GAAkB,CAAlB,GAAsB,CAAC,CAArC;AAEAG,IAAAA,cAAc,CAACK,QAAf,IACEL,cAAc,CAACK,QAAf,CAAwBF,CAAxB,EAA2BH,cAAc,CAACM,KAAf,GAAuBF,KAAlD,CADF;AAED,GALD;;AAOA,MAAMG,QAAQ,GACZV,IAAI,KAAK,MAAT,GACIG,cAAc,CAACM,KAAf,GAAuB,CAAvB,GAA2BN,cAAc,CAACQ,QAD9C,GAEIR,cAAc,CAACM,KAAf,GAAuB,CAAvB,GAA2BN,cAAc,CAACS,QAHhD;AAKA,sBACE,KAAC,IAAD,eACMV,UADN;AAEE,IAAA,IAAI,EAAC,QAFP;AAGE,IAAA,GAAG,EAAEL,YAHP;AAIE,IAAA,QAAQ,EAAE,CAAC,CAJb;AAKE,2BAAoB,EALtB;AAME,8BAAwBM,cAAc,CAACU,eAAf,GAAiC,EAAjC,GAAsCC,SANhE;AAOE,IAAA,QAAQ,EAAEJ,QAPZ;AAQE,IAAA,OAAO,EAAEhB,SAAS,CAACO,OAAD,EAAUI,WAAV;AARpB,KADF;AAYD,CAjCoC,CAAhC","sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useSpinnerContext } from './context';\nimport { wrapEvent } from '../utils';\n\nexport interface SpinnerButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n type: 'next' | 'previous';\n}\n\nexport const SpinnerButton = forwardRef<HTMLButtonElement, SpinnerButtonProps>(\n function SpinnerButton(props, forwardedRef) {\n const { as: Comp = 'button', type, onClick, ...otherProps } = props;\n const spinnerContext = useSpinnerContext();\n\n if (!spinnerContext) {\n throw new Error('Missing <Spinner /> in component tree');\n }\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n const delta = type === 'next' ? 1 : -1;\n\n spinnerContext.onChange &&\n spinnerContext.onChange(e, spinnerContext.value + delta);\n };\n\n const disabled =\n type === 'next'\n ? spinnerContext.value + 1 > spinnerContext.maxValue\n : spinnerContext.value - 1 < spinnerContext.minValue;\n\n return (\n <Comp\n {...otherProps}\n type=\"button\"\n ref={forwardedRef}\n tabIndex={-1}\n data-spinner-button=\"\"\n data-spinner-has-focus={spinnerContext.spinnerHasFocus ? '' : undefined}\n disabled={disabled}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n }\n);\n"],"file":"SpinnerButton.js"}
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
1
+ import type { KeyboardEvent, MouseEvent } from 'react';
2
2
  export interface SpinnerContextProps {
3
3
  value: number;
4
4
  minValue: number;
5
5
  maxValue: number;
6
6
  stepSize: number;
7
- onChange?: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLDivElement>, value: number) => void;
7
+ onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>, value: number) => void;
8
8
  clamp: (value: number) => number;
9
9
  spinnerHasFocus: boolean;
10
10
  }
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Spinner/context.ts"],"names":["createContext","useContext","spinbuttonContext","SpinnerProvider","Provider","useSpinnerContext"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAgBA,IAAMC,iBAAiB,gBAAGF,aAAa,CAA6B,IAA7B,CAAvC;IACyBG,e,GAAoBD,iB,CAA9BE,Q;;AACf,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,SAAMJ,UAAU,CAACC,iBAAD,CAAhB;AAAA,CAA1B","sourcesContent":["import { createContext, useContext } from 'react';\n\n// Spinner Component\nexport interface SpinnerContextProps {\n value: number;\n minValue: number;\n maxValue: number;\n stepSize: number;\n onChange?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n clamp: (value: number) => number;\n spinnerHasFocus: boolean;\n}\n\nconst spinbuttonContext = createContext<SpinnerContextProps | null>(null);\nexport const { Provider: SpinnerProvider } = spinbuttonContext;\nexport const useSpinnerContext = () => useContext(spinbuttonContext);\n"],"file":"context.js"}
1
+ {"version":3,"sources":["../../../src/Spinner/context.ts"],"names":["createContext","useContext","spinbuttonContext","SpinnerProvider","Provider","useSpinnerContext"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAcA,IAAMC,iBAAiB,gBAAGF,aAAa,CAA6B,IAA7B,CAAvC;IACyBG,e,GAAoBD,iB,CAA9BE,Q;;AACf,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,SAAMJ,UAAU,CAACC,iBAAD,CAAhB;AAAA,CAA1B","sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { createContext, useContext } from 'react';\n\n// Spinner Component\nexport interface SpinnerContextProps {\n value: number;\n minValue: number;\n maxValue: number;\n stepSize: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n clamp: (value: number) => number;\n spinnerHasFocus: boolean;\n}\n\nconst spinbuttonContext = createContext<SpinnerContextProps | null>(null);\nexport const { Provider: SpinnerProvider } = spinbuttonContext;\nexport const useSpinnerContext = () => useContext(spinbuttonContext);\n"],"file":"context.js"}
File without changes
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
2
- export interface TabProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
1
+ import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
2
+ export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  }
7
- export declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>;
7
+ export declare const Tab: import("react").ForwardRefExoticComponent<TabProps & 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, useRef } from 'react';
4
- import * as React from 'react';
5
4
  import { useTabsContext, useTabListContext } from './context';
6
5
  import { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';
7
6
  import { scopeQuery } from './scopeQuery';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/Tab.tsx"],"names":["forwardRef","useRef","React","useTabsContext","useTabListContext","assignMultipleRefs","getCircularIndex","wrapEvent","scopeQuery","getNextIndex","desiredIndex","delta","allTabs","i","length","nextIndex","disabled","Tab","props","forwardedRef","as","Comp","onKeyDown","onClick","index","tabIndex","otherProps","tabContext","tabListContext","ref","undefined","Error","handleKeyDown","e","right","vertical","left","first","last","navigateIndex","isLast","key","tabsScope","current","queryAllNodes","currentIndex","indexOf","onChange","focus","manualActivation","handleClick","isSelected","tabListId"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,QAAmC,OAAnC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,cAAT,EAAyBC,iBAAzB,QAAkD,WAAlD;AACA,SAASC,kBAAT,EAA6BC,gBAA7B,EAA+CC,SAA/C,QAAgE,UAAhE;AACA,SAASC,UAAT,QAA2B,cAA3B;;;AAEA,SAASC,YAAT,CACEC,YADF,EAEEC,KAFF,EAGEC,OAHF,EAIE;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,OAAO,CAACE,MAA5B,EAAoCD,CAAC,EAArC,EAAyC;AACvC,QAAME,SAAS,GAAGT,gBAAgB,CAChCI,YAAY,GAAGC,KAAK,GAAGE,CADS,EAEhCD,OAAO,CAACE,MAFwB,CAAlC;;AAKA,QAAIC,SAAS,KAAK,IAAd,IAAsB,CAACH,OAAO,CAACG,SAAD,CAAP,CAAmBC,QAA9C,EAAwD;AACtD,aAAOD,SAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD;;AASD,OAAO,IAAME,GAAG,gBAAGjB,UAAU,CAA8B,SAASiB,GAAT,CACzDC,KADyD,EAEzD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,KAAKE,UAAU,CAACkB,YAA3C;AAEA,sBACE,KAAC,IAAD,eACMnB,UADN;AAEE,IAAA,GAAG,EAAErB,kBAAkB,CAACwB,GAAD,EAAMV,YAAN,CAFzB;AAGE,gBAAS,EAHX;AAIE,IAAA,EAAE,EACAQ,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,iBACWE,UAAU,CAACyB,SADtB,cACmC3B,QADnC,IAEIK,SAPR;AASE,qBACEH,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,sBACgBE,UAAU,CAACyB,SAD3B,cACwC3B,QADxC,IAEIK,SAZR;AAcE,IAAA,IAAI,EAAC,KAdP;AAeE,IAAA,QAAQ,EAAEqB,UAAU,GAAG,CAAH,GAAO,CAAC,CAf9B;AAgBE,qBAAeA,UAhBjB;AAiBE,IAAA,QAAQ,EAAEA,UAjBZ;AAkBE,IAAA,SAAS,EAAE5C,SAAS,CAACe,SAAD,EAAYU,aAAZ,CAlBtB;AAmBE,IAAA,OAAO,EAAEzB,SAAS,CAACgB,OAAD,EAAU2B,WAAV;AAnBpB,KADF;AAuBD,CAjG4B,CAAtB","sourcesContent":["import { forwardRef, useRef } from 'react';\nimport * as React from 'react';\n\nimport { useTabsContext, useTabListContext } from './context';\nimport { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';\nimport { scopeQuery } from './scopeQuery';\n\nfunction getNextIndex(\n desiredIndex: number,\n delta: number,\n allTabs: HTMLButtonElement[]\n) {\n for (let i = 0; i < allTabs.length; i++) {\n const nextIndex = getCircularIndex(\n desiredIndex + delta * i,\n allTabs.length\n );\n\n if (nextIndex !== null && !allTabs[nextIndex].disabled) {\n return nextIndex;\n }\n }\n\n return null;\n}\n\nexport interface TabProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n}\n\nexport const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'button',\n onKeyDown,\n onClick,\n index: tabIndex = -1,\n ...otherProps\n } = props as TabProps & { index: number };\n const tabContext = useTabsContext();\n const tabListContext = useTabListContext();\n\n const ref = useRef<HTMLButtonElement | undefined>(undefined);\n\n if (!tabContext || !tabListContext) {\n throw new Error('Missing <Tabs /> or <TabList /> in the component tree');\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n const right = tabListContext.vertical ? 'ArrowDown' : 'ArrowRight';\n const left = tabListContext.vertical ? 'ArrowUp' : 'ArrowLeft';\n const first = 'Home';\n const last = 'End';\n\n const navigateIndex = (desiredIndex: number, isLast: boolean) => {\n const delta = e.key === right || e.key === first ? 1 : -1;\n\n const allTabs =\n tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n const nextIndex = getNextIndex(\n isLast ? desiredIndex : currentIndex + desiredIndex,\n delta,\n allTabs as HTMLButtonElement[]\n );\n\n if (\n nextIndex !== null &&\n nextIndex !== currentIndex &&\n tabContext.onChange\n ) {\n allTabs[nextIndex].focus();\n !tabListContext.manualActivation && tabContext.onChange(e, nextIndex);\n }\n };\n\n switch (e.key) {\n case right:\n case left: {\n navigateIndex(e.key === right ? 1 : -1, false);\n break;\n }\n case first: // Home / End\n case last: {\n navigateIndex(e.key === first ? 0 : -1, true);\n break;\n }\n }\n };\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n const allTabs = tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n if (currentIndex >= 0) {\n tabContext.onChange && tabContext.onChange(e, currentIndex);\n }\n };\n\n const isSelected = tabIndex === tabContext.currentIndex;\n\n return (\n <Comp\n {...otherProps}\n ref={assignMultipleRefs(ref, forwardedRef)}\n data-tab=\"\"\n id={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tab-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n aria-controls={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tabpanel-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n role=\"tab\"\n tabIndex={isSelected ? 0 : -1}\n aria-selected={isSelected}\n selected={isSelected}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n});\n"],"file":"Tab.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/Tab.tsx"],"names":["forwardRef","useRef","useTabsContext","useTabListContext","assignMultipleRefs","getCircularIndex","wrapEvent","scopeQuery","getNextIndex","desiredIndex","delta","allTabs","i","length","nextIndex","disabled","Tab","props","forwardedRef","as","Comp","onKeyDown","onClick","index","tabIndex","otherProps","tabContext","tabListContext","ref","undefined","Error","handleKeyDown","e","right","vertical","left","first","last","navigateIndex","isLast","key","tabsScope","current","queryAllNodes","currentIndex","indexOf","onChange","focus","manualActivation","handleClick","isSelected","tabListId"],"mappings":";;AAOA,SAASA,UAAT,EAAqBC,MAArB,QAAmC,OAAnC;AAEA,SAASC,cAAT,EAAyBC,iBAAzB,QAAkD,WAAlD;AACA,SAASC,kBAAT,EAA6BC,gBAA7B,EAA+CC,SAA/C,QAAgE,UAAhE;AACA,SAASC,UAAT,QAA2B,cAA3B;;;AAEA,SAASC,YAAT,CACEC,YADF,EAEEC,KAFF,EAGEC,OAHF,EAIE;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,OAAO,CAACE,MAA5B,EAAoCD,CAAC,EAArC,EAAyC;AACvC,QAAME,SAAS,GAAGT,gBAAgB,CAChCI,YAAY,GAAGC,KAAK,GAAGE,CADS,EAEhCD,OAAO,CAACE,MAFwB,CAAlC;;AAKA,QAAIC,SAAS,KAAK,IAAd,IAAsB,CAACH,OAAO,CAACG,SAAD,CAAP,CAAmBC,QAA9C,EAAwD;AACtD,aAA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B,QAAX,IAAuBpB,UAAU,CAACoB,QAAX,CAAoBd,CAApB,EAAuBY,YAAvB,CAAvB;AACD;AACF,GAPD;;AASA,MAAMM,UAAU,GAAG1B,QAAQ,KAAKE,UAAU,CAACkB,YAA3C;AAEA,sBACE,KAAC,IAAD,eACMnB,UADN;AAEE,IAAA,GAAG,EAAErB,kBAAkB,CAACwB,GAAD,EAAMV,YAAN,CAFzB;AAGE,gBAAS,EAHX;AAIE,IAAA,EAAE,EACAQ,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,iBACWE,UAAU,CAACyB,SADtB,cACmC3B,QADnC,IAEIK,SAPR;AASE,qBACEH,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,sBACgBE,UAAU,CAACyB,SAD3B,cACwC3B,QADxC,IAEIK,SAZR;AAcE,IAAA,IAAI,EAAC,KAdP;AAeE,IAAA,QAAQ,EAAEqB,UAAU,GAAG,CAAH,GAAO,CAAC,CAf9B;AAgBE,qBAAeA,UAhBjB;AAiBE,IAAA,QAAQ,EAAEA,UAjBZ;AAkBE,IAAA,SAAS,EAAE5C,SAAS,CAACe,SAAD,EAAYU,aAAZ,CAlBtB;AAmBE,IAAA,OAAO,EAAEzB,SAAS,CAACgB,OAAD,EAAU2B,WAAV;AAnBpB,KADF;AAuBD,CAjG4B,CAAtB","sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { forwardRef, useRef } from 'react';\n\nimport { useTabsContext, useTabListContext } from './context';\nimport { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';\nimport { scopeQuery } from './scopeQuery';\n\nfunction getNextIndex(\n desiredIndex: number,\n delta: number,\n allTabs: HTMLButtonElement[]\n) {\n for (let i = 0; i < allTabs.length; i++) {\n const nextIndex = getCircularIndex(\n desiredIndex + delta * i,\n allTabs.length\n );\n\n if (nextIndex !== null && !allTabs[nextIndex].disabled) {\n return nextIndex;\n }\n }\n\n return null;\n}\n\nexport interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'button',\n onKeyDown,\n onClick,\n index: tabIndex = -1,\n ...otherProps\n } = props as TabProps & { index: number };\n const tabContext = useTabsContext();\n const tabListContext = useTabListContext();\n\n const ref = useRef<HTMLButtonElement | undefined>(undefined);\n\n if (!tabContext || !tabListContext) {\n throw new Error('Missing <Tabs /> or <TabList /> in the component tree');\n }\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n const right = tabListContext.vertical ? 'ArrowDown' : 'ArrowRight';\n const left = tabListContext.vertical ? 'ArrowUp' : 'ArrowLeft';\n const first = 'Home';\n const last = 'End';\n\n const navigateIndex = (desiredIndex: number, isLast: boolean) => {\n const delta = e.key === right || e.key === first ? 1 : -1;\n\n const allTabs =\n tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n const nextIndex = getNextIndex(\n isLast ? desiredIndex : currentIndex + desiredIndex,\n delta,\n allTabs as HTMLButtonElement[]\n );\n\n if (\n nextIndex !== null &&\n nextIndex !== currentIndex &&\n tabContext.onChange\n ) {\n allTabs[nextIndex].focus();\n !tabListContext.manualActivation && tabContext.onChange(e, nextIndex);\n }\n };\n\n switch (e.key) {\n case right:\n case left: {\n navigateIndex(e.key === right ? 1 : -1, false);\n break;\n }\n case first: // Home / End\n case last: {\n navigateIndex(e.key === first ? 0 : -1, true);\n break;\n }\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n const allTabs = tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n if (currentIndex >= 0) {\n tabContext.onChange && tabContext.onChange(e, currentIndex);\n }\n };\n\n const isSelected = tabIndex === tabContext.currentIndex;\n\n return (\n <Comp\n {...otherProps}\n ref={assignMultipleRefs(ref, forwardedRef)}\n data-tab=\"\"\n id={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tab-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n aria-controls={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tabpanel-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n role=\"tab\"\n tabIndex={isSelected ? 0 : -1}\n aria-selected={isSelected}\n selected={isSelected}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n});\n"],"file":"Tab.js"}
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- export interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
1
+ import type { HTMLAttributes, ElementType, ReactNode } from 'react';
2
+ export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  manualActivation?: boolean;
6
6
  vertical?: boolean;
7
- children?: React.ReactNode;
7
+ children?: ReactNode;
8
8
  }
9
- export declare const TabList: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & 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, useRef, useEffect, Children, cloneElement, useId } from 'react';
4
- import * as React from 'react';
5
4
  import { TabListProvider, useTabsContext } from './context';
6
5
  import { useScope } from '../hooks';
7
6
  import { assignMultipleRefs } from '../utils';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/TabList.tsx"],"names":["forwardRef","useRef","useEffect","Children","cloneElement","useId","React","TabListProvider","useTabsContext","useScope","assignMultipleRefs","TabList","props","forwardedRef","as","Comp","manualActivation","vertical","childrenProps","children","otherProps","ref","tabsScope","tabsContext","id","Error","undefined","setTabListId","map","node","index"],"mappings":";;AAAA,SACEA,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,YALF,EAMEC,KANF,QAOO,OAPP;AAQA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,WAAhD;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,IAAMC,OAAO,gBAAGX,UAAU,CAC/B,SAASW,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AAAA,kBAOhCD,KAPgC,CAElCE,EAFkC;AAAA,MAE9BC,IAF8B,0BAEvB,KAFuB;AAAA,8BAOhCH,KAPgC,CAGlCI,gBAHkC;AAAA,MAGlCA,gBAHkC,sCAGf,KAHe;AAAA,wBAOhCJ,KAPgC,CAIlCK,QAJkC;AAAA,MAIlCA,QAJkC,gCAIvB,KAJuB;AAAA,MAKxBC,aALwB,GAOhCN,KAPgC,CAKlCO,QALkC;AAAA,MAM/BC,UAN+B,4BAOhCR,KAPgC;;AASpC,MAAMS,GAAG,GAAGpB,MAAM,EAAlB;AACA,MAAMqB,SAAS,GAAGb,QAAQ,CAACY,GAAD,CAA1B;AACA,MAAME,WAAW,GAAGf,cAAc,EAAlC;AACA,MAAMgB,EAAE,GAAGnB,KAAK,EAAhB;;AAEA,MAAI,CAACkB,WAAL,EAAkB;AAChB,UAAM,IAAIE,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAEDvB,EAAAA,SAAS,CAAC,YAAM;AACd,QAAIsB,EAAE,KAAKE,SAAX,EAAsB;AACpBH,MAAAA,WAAW,CAACI,YAAZ,CAAyBH,EAAzB;AAEA,aAAO,YAAM;AACXD,QAAAA,WAAW,CAACI,YAAZ,CAAyB,IAAzB;AACD,OAFD;AAGD;;AAED;AACD,GAVQ,EAUN,CAACH,EAAD,EAAKD,WAAL,EAAkBA,WAAW,CAACI,YAA9B,CAVM,CAAT;AAYA,MAAMR,QAAQ,GAAGhB,QAAQ,CAACyB,GAAT,CAAaV,aAAb,EAA4B,UAACW,IAAD,EAAOC,KAAP;AAAA,wBAC3C1B,YAAY,CAACyB,IAAD,EAAc;AAAEC,MAAAA,KAAK,EAALA;AAAF,KAAd,CAD+B;AAAA,GAA5B,CAAjB;AAIA,sBACE,KAAC,eAAD;AAAiB,IAAA,KAAK,EAAE;AAAER,MAAAA,SAAS,EAATA,SAAF;AAAaN,MAAAA,gBAAgB,EAAhBA,gBAAb;AAA+BC,MAAAA,QAAQ,EAARA;AAA/B,KAAxB;AAAA,2BACE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEP,kBAAkB,CAACG,YAAD,EAAeQ,GAAf,CADzB;AAEE,uBAAc,EAFhB;AAGE,MAAA,IAAI,EAAC;AAHP,OAIMD,UAJN;AAAA,gBAMGD;AANH;AADF,IADF;AAYD,CA/C8B,CAA1B","sourcesContent":["import {\n forwardRef,\n useRef,\n useEffect,\n Children,\n cloneElement,\n useId,\n} from 'react';\nimport * as React from 'react';\n\nimport { TabListProvider, useTabsContext } from './context';\nimport { useScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n manualActivation?: boolean;\n vertical?: boolean;\n children?: React.ReactNode;\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(\n function TabList(props, forwardedRef) {\n const {\n as: Comp = 'div',\n manualActivation = false,\n vertical = false,\n children: childrenProps,\n ...otherProps\n } = props;\n\n const ref = useRef();\n const tabsScope = useScope(ref);\n const tabsContext = useTabsContext();\n const id = useId();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree');\n }\n\n useEffect(() => {\n if (id !== undefined) {\n tabsContext.setTabListId(id);\n\n return () => {\n tabsContext.setTabListId(null);\n };\n }\n\n return;\n }, [id, tabsContext, tabsContext.setTabListId]);\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index })\n );\n\n return (\n <TabListProvider value={{ tabsScope, manualActivation, vertical }}>\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-tab-list=\"\"\n role=\"tablist\"\n {...otherProps}\n >\n {children}\n </Comp>\n </TabListProvider>\n );\n }\n);\n"],"file":"TabList.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/TabList.tsx"],"names":["forwardRef","useRef","useEffect","Children","cloneElement","useId","TabListProvider","useTabsContext","useScope","assignMultipleRefs","TabList","props","forwardedRef","as","Comp","manualActivation","vertical","childrenProps","children","otherProps","ref","tabsScope","tabsContext","id","Error","undefined","setTabListId","map","node","index"],"mappings":";;AACA,SACEA,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,YALF,EAMEC,KANF,QAOO,OAPP;AASA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,WAAhD;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,IAAMC,OAAO,gBAAGV,UAAU,CAC/B,SAASU,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AAAA,kBAOhCD,KAPgC,CAElCE,EAFkC;AAAA,MAE9BC,IAF8B,0BAEvB,KAFuB;AAAA,8BAOhCH,KAPgC,CAGlCI,gBAHkC;AAAA,MAGlCA,gBAHkC,sCAGf,KAHe;AAAA,wBAOhCJ,KAPgC,CAIlCK,QAJkC;AAAA,MAIlCA,QAJkC,gCAIvB,KAJuB;AAAA,MAKxBC,aALwB,GAOhCN,KAPgC,CAKlCO,QALkC;AAAA,MAM/BC,UAN+B,4BAOhCR,KAPgC;;AASpC,MAAMS,GAAG,GAAGnB,MAAM,EAAlB;AACA,MAAMoB,SAAS,GAAGb,QAAQ,CAACY,GAAD,CAA1B;AACA,MAAME,WAAW,GAAGf,cAAc,EAAlC;AACA,MAAMgB,EAAE,GAAGlB,KAAK,EAAhB;;AAEA,MAAI,CAACiB,WAAL,EAAkB;AAChB,UAAM,IAAIE,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAEDtB,EAAAA,SAAS,CAAC,YAAM;AACd,QAAIqB,EAAE,KAAKE,SAAX,EAAsB;AACpBH,MAAAA,WAAW,CAACI,YAAZ,CAAyBH,EAAzB;AAEA,aAAO,YAAM;AACXD,QAAAA,WAAW,CAACI,YAAZ,CAAyB,IAAzB;AACD,OAFD;AAGD;;AAED;AACD,GAVQ,EAUN,CAACH,EAAD,EAAKD,WAAL,EAAkBA,WAAW,CAACI,YAA9B,CAVM,CAAT;AAYA,MAAMR,QAAQ,GAAGf,QAAQ,CAACwB,GAAT,CAAaV,aAAb,EAA4B,UAACW,IAAD,EAAOC,KAAP;AAAA,wBAC3CzB,YAAY,CAACwB,IAAD,EAAc;AAAEC,MAAAA,KAAK,EAALA;AAAF,KAAd,CAD+B;AAAA,GAA5B,CAAjB;AAIA,sBACE,KAAC,eAAD;AAAiB,IAAA,KAAK,EAAE;AAAER,MAAAA,SAAS,EAATA,SAAF;AAAaN,MAAAA,gBAAgB,EAAhBA,gBAAb;AAA+BC,MAAAA,QAAQ,EAARA;AAA/B,KAAxB;AAAA,2BACE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEP,kBAAkB,CAACG,YAAD,EAAeQ,GAAf,CADzB;AAEE,uBAAc,EAFhB;AAGE,MAAA,IAAI,EAAC;AAHP,OAIMD,UAJN;AAAA,gBAMGD;AANH;AADF,IADF;AAYD,CA/C8B,CAA1B","sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\nimport {\n forwardRef,\n useRef,\n useEffect,\n Children,\n cloneElement,\n useId,\n} from 'react';\n\nimport { TabListProvider, useTabsContext } from './context';\nimport { useScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface TabListProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n manualActivation?: boolean;\n vertical?: boolean;\n children?: ReactNode;\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(\n function TabList(props, forwardedRef) {\n const {\n as: Comp = 'div',\n manualActivation = false,\n vertical = false,\n children: childrenProps,\n ...otherProps\n } = props;\n\n const ref = useRef();\n const tabsScope = useScope(ref);\n const tabsContext = useTabsContext();\n const id = useId();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree');\n }\n\n useEffect(() => {\n if (id !== undefined) {\n tabsContext.setTabListId(id);\n\n return () => {\n tabsContext.setTabListId(null);\n };\n }\n\n return;\n }, [id, tabsContext, tabsContext.setTabListId]);\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index })\n );\n\n return (\n <TabListProvider value={{ tabsScope, manualActivation, vertical }}>\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-tab-list=\"\"\n role=\"tablist\"\n {...otherProps}\n >\n {children}\n </Comp>\n </TabListProvider>\n );\n }\n);\n"],"file":"TabList.js"}
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
2
- export interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement> {
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 TabPanelProps extends HTMLAttributes<HTMLDivElement> {
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
6
  lazy?: boolean;
7
7
  }
8
- export declare const TabPanel: React.ForwardRefExoticComponent<TabPanelProps & React.RefAttributes<HTMLDivElement>>;
8
+ export declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & 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 { useTabsContext } from './context';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  export var TabPanel = /*#__PURE__*/forwardRef(function TabPanel(props, forwardedRef) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/TabPanel.tsx"],"names":["forwardRef","React","useTabsContext","TabPanel","props","forwardedRef","as","Comp","index","lazy","children","otherProps","tabsContext","Error","isSelected","currentIndex","tabListId","undefined"],"mappings":";;AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,cAAT,QAA+B,WAA/B;;AASA,OAAO,IAAMC,QAAQ,gBAAGH,UAAU,CAChC,SAASG,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AAAA,aAOjCD,KAPiC;AAAA,qBAEnCE,EAFmC;AAAA,MAE/BC,IAF+B,wBAExB,KAFwB;AAAA,MAGnCC,KAHmC,QAGnCA,KAHmC;AAAA,uBAInCC,IAJmC;AAAA,MAInCA,IAJmC,0BAI5B,KAJ4B;AAAA,MAKnCC,QALmC,QAKnCA,QALmC;AAAA,MAMhCC,UANgC;;AAQrC,MAAMC,WAAW,GAAGV,cAAc,EAAlC;;AAEA,MAAI,CAACU,WAAL,EAAkB;AAChB,UAAM,IAAIC,KAAJ,CAAU,yCAAV,CAAN;AACD;;AAED,MAAMC,UAAU,GAAGF,WAAW,CAACG,YAAZ,KAA6BP,KAAhD;AAEA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEH,YADP;AAEE,sBAAe,EAFjB;AAGE,IAAA,IAAI,EAAC,UAHP;AAIE,IAAA,EAAE,EACAO,WAAW,CAACI,SAAZ,KAA0B,IAA1B,sBACgBJ,WAAW,CAACI,SAD5B,cACyCR,KADzC,IAEIS,SAPR;AASE,uBACEL,WAAW,CAACI,SAAZ,KAA0B,IAA1B,iBACWJ,WAAW,CAACI,SADvB,cACoCR,KADpC,IAEIS,SAZR;AAcE,IAAA,MAAM,EAAEH,UAAU,GAAGG,SAAH,GAAe,QAdnC;AAeE,IAAA,QAAQ,EAAE;AAfZ,KAgBMN,UAhBN;AAAA,cAkBG,CAACG,UAAU,IAAI,CAACL,IAAhB,KAAyBC;AAlB5B,KADF;AAsBD,CAvC+B,CAA3B","sourcesContent":["import { forwardRef } from 'react';\nimport * as React from 'react';\n\nimport { useTabsContext } from './context';\n\nexport interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n lazy?: boolean;\n}\n\nexport const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(\n function TabPanel(props, forwardedRef) {\n const {\n as: Comp = 'div',\n index,\n lazy = false,\n children,\n ...otherProps\n } = props as TabPanelProps & { index: number };\n const tabsContext = useTabsContext();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree.');\n }\n\n const isSelected = tabsContext.currentIndex === index;\n\n return (\n <Comp\n ref={forwardedRef}\n data-tab-panel=\"\"\n role=\"tabpanel\"\n id={\n tabsContext.tabListId !== null\n ? `tabpanel-${tabsContext.tabListId}-${index}`\n : undefined\n }\n aria-labelledby={\n tabsContext.tabListId !== null\n ? `tab-${tabsContext.tabListId}-${index}`\n : undefined\n }\n hidden={isSelected ? undefined : 'hidden'}\n tabIndex={0}\n {...otherProps}\n >\n {(isSelected || !lazy) && children}\n </Comp>\n );\n }\n);\n"],"file":"TabPanel.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/TabPanel.tsx"],"names":["forwardRef","useTabsContext","TabPanel","props","forwardedRef","as","Comp","index","lazy","children","otherProps","tabsContext","Error","isSelected","currentIndex","tabListId","undefined"],"mappings":";;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,cAAT,QAA+B,WAA/B;;AASA,OAAO,IAAMC,QAAQ,gBAAGF,UAAU,CAChC,SAASE,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;AAAA,aAOjCD,KAPiC;AAAA,qBAEnCE,EAFmC;AAAA,MAE/BC,IAF+B,wBAExB,KAFwB;AAAA,MAGnCC,KAHmC,QAGnCA,KAHmC;AAAA,uBAInCC,IAJmC;AAAA,MAInCA,IAJmC,0BAI5B,KAJ4B;AAAA,MAKnCC,QALmC,QAKnCA,QALmC;AAAA,MAMhCC,UANgC;;AAQrC,MAAMC,WAAW,GAAGV,cAAc,EAAlC;;AAEA,MAAI,CAACU,WAAL,EAAkB;AAChB,UAAM,IAAIC,KAAJ,CAAU,yCAAV,CAAN;AACD;;AAED,MAAMC,UAAU,GAAGF,WAAW,CAACG,YAAZ,KAA6BP,KAAhD;AAEA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEH,YADP;AAEE,sBAAe,EAFjB;AAGE,IAAA,IAAI,EAAC,UAHP;AAIE,IAAA,EAAE,EACAO,WAAW,CAACI,SAAZ,KAA0B,IAA1B,sBACgBJ,WAAW,CAACI,SAD5B,cACyCR,KADzC,IAEIS,SAPR;AASE,uBACEL,WAAW,CAACI,SAAZ,KAA0B,IAA1B,iBACWJ,WAAW,CAACI,SADvB,cACoCR,KADpC,IAEIS,SAZR;AAcE,IAAA,MAAM,EAAEH,UAAU,GAAGG,SAAH,GAAe,QAdnC;AAeE,IAAA,QAAQ,EAAE;AAfZ,KAgBMN,UAhBN;AAAA,cAkBG,CAACG,UAAU,IAAI,CAACL,IAAhB,KAAyBC;AAlB5B,KADF;AAsBD,CAvC+B,CAA3B","sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useTabsContext } from './context';\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n lazy?: boolean;\n}\n\nexport const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(\n function TabPanel(props, forwardedRef) {\n const {\n as: Comp = 'div',\n index,\n lazy = false,\n children,\n ...otherProps\n } = props as TabPanelProps & { index: number };\n const tabsContext = useTabsContext();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree.');\n }\n\n const isSelected = tabsContext.currentIndex === index;\n\n return (\n <Comp\n ref={forwardedRef}\n data-tab-panel=\"\"\n role=\"tabpanel\"\n id={\n tabsContext.tabListId !== null\n ? `tabpanel-${tabsContext.tabListId}-${index}`\n : undefined\n }\n aria-labelledby={\n tabsContext.tabListId !== null\n ? `tab-${tabsContext.tabListId}-${index}`\n : undefined\n }\n hidden={isSelected ? undefined : 'hidden'}\n tabIndex={0}\n {...otherProps}\n >\n {(isSelected || !lazy) && children}\n </Comp>\n );\n }\n);\n"],"file":"TabPanel.js"}
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
1
+ import type { ElementType, ReactNode } from 'react';
2
2
  export interface TabPanelsProps {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
5
  lazy?: boolean;
6
- children?: React.ReactNode;
6
+ children?: ReactNode;
7
7
  }
8
- export declare const TabPanels: React.ForwardRefExoticComponent<TabPanelsProps & React.RefAttributes<HTMLDivElement>>;
8
+ export declare const TabPanels: import("react").ForwardRefExoticComponent<TabPanelsProps & 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, Fragment, Children, cloneElement } from 'react';
4
- import * as React from 'react';
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  export var TabPanels = /*#__PURE__*/forwardRef(function TabPanels(props, forwardedRef) {
7
6
  var _props$as = props.as,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/TabPanels.tsx"],"names":["forwardRef","Fragment","Children","cloneElement","React","TabPanels","props","forwardedRef","as","Comp","childrenProps","children","lazy","otherProps","map","node","index"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,EAAyCC,YAAzC,QAA6D,OAA7D;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;;AASA,OAAO,IAAMC,SAAS,gBAAGL,UAAU,CACjC,SAASK,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;AAAA,kBAMlCD,KANkC,CAEpCE,EAFoC;AAAA,MAEhCC,IAFgC,0BAEzBR,QAFyB;AAAA,MAG1BS,aAH0B,GAMlCJ,KANkC,CAGpCK,QAHoC;AAAA,MAIpCC,IAJoC,GAMlCN,KANkC,CAIpCM,IAJoC;AAAA,MAKjCC,UALiC,4BAMlCP,KANkC;;AAQtC,MAAMK,QAAQ,GAAGT,QAAQ,CAACY,GAAT,CAAaJ,aAAb,EAA4B,UAACK,IAAD,EAAOC,KAAP;AAAA,wBAC3Cb,YAAY,CAACY,IAAD,EAAc;AAAEC,MAAAA,KAAK,EAALA,KAAF;AAASJ,MAAAA,IAAI,EAAJA;AAAT,KAAd,CAD+B;AAAA,GAA5B,CAAjB;AAIA,sBACE,KAAC,IAAD;AAAM,IAAA,GAAG,EAAEL;AAAX,KAA6BM,UAA7B;AAAA,cACGF;AADH,KADF;AAKD,CAlBgC,CAA5B","sourcesContent":["import { forwardRef, Fragment, Children, cloneElement } from 'react';\nimport * as React from 'react';\n\nexport interface TabPanelsProps {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n lazy?: boolean;\n children?: React.ReactNode;\n}\n\nexport const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(\n function TabPanels(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n children: childrenProps,\n lazy,\n ...otherProps\n } = props;\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index, lazy })\n );\n\n return (\n <Comp ref={forwardedRef} {...otherProps}>\n {children}\n </Comp>\n );\n }\n);\n"],"file":"TabPanels.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/TabPanels.tsx"],"names":["forwardRef","Fragment","Children","cloneElement","TabPanels","props","forwardedRef","as","Comp","childrenProps","children","lazy","otherProps","map","node","index"],"mappings":";;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,EAAyCC,YAAzC,QAA6D,OAA7D;;AASA,OAAO,IAAMC,SAAS,gBAAGJ,UAAU,CACjC,SAASI,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;AAAA,kBAMlCD,KANkC,CAEpCE,EAFoC;AAAA,MAEhCC,IAFgC,0BAEzBP,QAFyB;AAAA,MAG1BQ,aAH0B,GAMlCJ,KANkC,CAGpCK,QAHoC;AAAA,MAIpCC,IAJoC,GAMlCN,KANkC,CAIpCM,IAJoC;AAAA,MAKjCC,UALiC,4BAMlCP,KANkC;;AAQtC,MAAMK,QAAQ,GAAGR,QAAQ,CAACW,GAAT,CAAaJ,aAAb,EAA4B,UAACK,IAAD,EAAOC,KAAP;AAAA,wBAC3CZ,YAAY,CAACW,IAAD,EAAc;AAAEC,MAAAA,KAAK,EAALA,KAAF;AAASJ,MAAAA,IAAI,EAAJA;AAAT,KAAd,CAD+B;AAAA,GAA5B,CAAjB;AAIA,sBACE,KAAC,IAAD;AAAM,IAAA,GAAG,EAAEL;AAAX,KAA6BM,UAA7B;AAAA,cACGF;AADH,KADF;AAKD,CAlBgC,CAA5B","sourcesContent":["import type { ElementType, ReactNode } from 'react';\nimport { forwardRef, Fragment, Children, cloneElement } from 'react';\n\nexport interface TabPanelsProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n lazy?: boolean;\n children?: ReactNode;\n}\n\nexport const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(\n function TabPanels(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n children: childrenProps,\n lazy,\n ...otherProps\n } = props;\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index, lazy })\n );\n\n return (\n <Comp ref={forwardedRef} {...otherProps}>\n {children}\n </Comp>\n );\n }\n);\n"],"file":"TabPanels.js"}
@@ -1,10 +1,10 @@
1
- import * as React from 'react';
1
+ import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
2
2
  export interface TabsProps {
3
- as?: React.ElementType<any>;
4
- innerAs?: React.ElementType<any>;
5
- children?: React.ReactNode;
6
- onChange?: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>, value: number) => void;
3
+ as?: ElementType<any>;
4
+ innerAs?: ElementType<any>;
5
+ children?: ReactNode;
6
+ onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
7
7
  index?: number;
8
8
  defaultIndex?: number;
9
9
  }
10
- export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & 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, Fragment, useState } from 'react';
5
- import * as React from 'react';
6
5
  import { TabsProvider } from './context';
7
6
  import { useControlledState } from '../hooks';
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/Tabs.tsx"],"names":["forwardRef","Fragment","useState","React","TabsProvider","useControlledState","Tabs","props","forwardedRef","as","Comp","indexProp","index","onChangeProp","onChange","defaultIndex","otherProps","setState","e","idx","tabListId","setTabListId","currentIndex"],"mappings":";;;AAAA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,QAA+C,OAA/C;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAgBA,OAAO,IAAMC,IAAI,gBAAGN,UAAU,CAA4B,SAASM,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;AAAA,kBAOID,KAPJ,CAEEE,EAFF;AAAA,MAEMC,IAFN,0BAEaT,QAFb;AAAA,MAGSU,SAHT,GAOIJ,KAPJ,CAGEK,KAHF;AAAA,MAIYC,YAJZ,GAOIN,KAPJ,CAIEO,QAJF;AAAA,4BAOIP,KAPJ,CAKEQ,YALF;AAAA,MAKEA,YALF,oCAKiB,CALjB;AAAA,MAMKC,UANL,4BAOIT,KAPJ;;AAAA,4BAQ0BF,kBAAkB,CAC1CM,SAD0C,EAE1CE,YAF0C,EAG1CE,YAH0C,EAI1C,UAACE,QAAD;AAAA,WAAc,UAACC,CAAD,EAAIC,GAAJ;AAAA,aAAYF,QAAQ,CAACE,GAAD,CAApB;AAAA,KAAd;AAAA,GAJ0C,CAR5C;AAAA;AAAA,MAQOP,KARP;AAAA,MAQcE,QARd;;AAAA,kBAekCZ,QAAQ,CAAgB,IAAhB,CAf1C;AAAA;AAAA,MAeOkB,SAfP;AAAA,MAekBC,YAflB;;AAiBA,sBACE,KAAC,YAAD;AACE,IAAA,KAAK,EAAE;AAAEC,MAAAA,YAAY,EAAEV,KAAK,IAAI,CAAzB;AAA4BE,MAAAA,QAAQ,EAARA,QAA5B;AAAsCM,MAAAA,SAAS,EAATA,SAAtC;AAAiDC,MAAAA,YAAY,EAAZA;AAAjD,KADT;AAAA,2BAGE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEb;AAAX,OAA6BQ,UAA7B;AAHF,IADF;AAOD,CA3B6B,CAAvB","sourcesContent":["import { forwardRef, Fragment, useState } from 'react';\nimport * as React from 'react';\n\nimport { TabsProvider } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface TabsProps {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n onChange?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n index?: number;\n defaultIndex?: number;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(function Tabs(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n index: indexProp,\n onChange: onChangeProp,\n defaultIndex = 0,\n ...otherProps\n } = props;\n const [index, onChange] = useControlledState(\n indexProp,\n onChangeProp,\n defaultIndex,\n (setState) => (e, idx) => setState(idx)\n );\n\n const [tabListId, setTabListId] = useState<string | null>(null);\n\n return (\n <TabsProvider\n value={{ currentIndex: index || 0, onChange, tabListId, setTabListId }}\n >\n <Comp ref={forwardedRef} {...otherProps} />\n </TabsProvider>\n );\n});\n"],"file":"Tabs.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/Tabs.tsx"],"names":["forwardRef","Fragment","useState","TabsProvider","useControlledState","Tabs","props","forwardedRef","as","Comp","indexProp","index","onChangeProp","onChange","defaultIndex","otherProps","setState","e","idx","tabListId","setTabListId","currentIndex"],"mappings":";;;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,QAA+C,OAA/C;AAEA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAcA,OAAO,IAAMC,IAAI,gBAAGL,UAAU,CAA4B,SAASK,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;AAAA,kBAOID,KAPJ,CAEEE,EAFF;AAAA,MAEMC,IAFN,0BAEaR,QAFb;AAAA,MAGSS,SAHT,GAOIJ,KAPJ,CAGEK,KAHF;AAAA,MAIYC,YAJZ,GAOIN,KAPJ,CAIEO,QAJF;AAAA,4BAOIP,KAPJ,CAKEQ,YALF;AAAA,MAKEA,YALF,oCAKiB,CALjB;AAAA,MAMKC,UANL,4BAOIT,KAPJ;;AAAA,4BAQ0BF,kBAAkB,CAC1CM,SAD0C,EAE1CE,YAF0C,EAG1CE,YAH0C,EAI1C,UAACE,QAAD;AAAA,WAAc,UAACC,CAAD,EAAIC,GAAJ;AAAA,aAAYF,QAAQ,CAACE,GAAD,CAApB;AAAA,KAAd;AAAA,GAJ0C,CAR5C;AAAA;AAAA,MAQOP,KARP;AAAA,MAQcE,QARd;;AAAA,kBAekCX,QAAQ,CAAgB,IAAhB,CAf1C;AAAA;AAAA,MAeOiB,SAfP;AAAA,MAekBC,YAflB;;AAiBA,sBACE,KAAC,YAAD;AACE,IAAA,KAAK,EAAE;AAAEC,MAAAA,YAAY,EAAEV,KAAK,IAAI,CAAzB;AAA4BE,MAAAA,QAAQ,EAARA,QAA5B;AAAsCM,MAAAA,SAAS,EAATA,SAAtC;AAAiDC,MAAAA,YAAY,EAAZA;AAAjD,KADT;AAAA,2BAGE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEb;AAAX,OAA6BQ,UAA7B;AAHF,IADF;AAOD,CA3B6B,CAAvB","sourcesContent":["import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';\nimport { forwardRef, Fragment, useState } from 'react';\n\nimport { TabsProvider } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface TabsProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n index?: number;\n defaultIndex?: number;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(function Tabs(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n index: indexProp,\n onChange: onChangeProp,\n defaultIndex = 0,\n ...otherProps\n } = props;\n const [index, onChange] = useControlledState(\n indexProp,\n onChangeProp,\n defaultIndex,\n (setState) => (e, idx) => setState(idx)\n );\n\n const [tabListId, setTabListId] = useState<string | null>(null);\n\n return (\n <TabsProvider\n value={{ currentIndex: index || 0, onChange, tabListId, setTabListId }}\n >\n <Comp ref={forwardedRef} {...otherProps} />\n </TabsProvider>\n );\n});\n"],"file":"Tabs.js"}
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import type { KeyboardEvent, MouseEvent } from 'react';
2
2
  import type { Scope } from '../hooks/useScope';
3
3
  export interface TabsContextProps {
4
4
  currentIndex: number;
5
- onChange?: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>, value: number) => void;
5
+ onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
6
6
  tabListId: string | null;
7
7
  setTabListId: (v: string | null) => void;
8
8
  }
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tabs/context.ts"],"names":["createContext","useContext","tabsContext","TabsProvider","Provider","useTabsContext","tablistContext","TabListProvider","useTabListContext"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAiBA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;IACyBG,Y,GAAiBD,W,CAA3BE,Q;;AACf,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAAMJ,UAAU,CAACC,WAAD,CAAhB;AAAA,CAAvB,C,CAEP;;AAOA,IAAMI,cAAc,gBAAGN,aAAa,CAA6B,IAA7B,CAApC;IACyBO,e,GAAoBD,c,CAA9BF,Q;;AACf,OAAO,IAAMI,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,SAAMP,UAAU,CAACK,cAAD,CAAhB;AAAA,CAA1B","sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// Tabs Component\nexport interface TabsContextProps {\n currentIndex: number;\n onChange?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n tabListId: string | null;\n setTabListId: (v: string | null) => void;\n}\n\nconst tabsContext = createContext<TabsContextProps | null>(null);\nexport const { Provider: TabsProvider } = tabsContext;\nexport const useTabsContext = () => useContext(tabsContext);\n\n// TabList Component\nexport interface TabListContextProps {\n tabsScope: Scope<HTMLElement>;\n manualActivation: boolean;\n vertical: boolean;\n}\n\nconst tablistContext = createContext<TabListContextProps | null>(null);\nexport const { Provider: TabListProvider } = tablistContext;\nexport const useTabListContext = () => useContext(tablistContext);\n"],"file":"context.js"}
1
+ {"version":3,"sources":["../../../src/Tabs/context.ts"],"names":["createContext","useContext","tabsContext","TabsProvider","Provider","useTabsContext","tablistContext","TabListProvider","useTabListContext"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAeA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;IACyBG,Y,GAAiBD,W,CAA3BE,Q;;AACf,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAAMJ,UAAU,CAACC,WAAD,CAAhB;AAAA,CAAvB,C,CAEP;;AAOA,IAAMI,cAAc,gBAAGN,aAAa,CAA6B,IAA7B,CAApC;IACyBO,e,GAAoBD,c,CAA9BF,Q;;AACf,OAAO,IAAMI,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,SAAMP,UAAU,CAACK,cAAD,CAAhB;AAAA,CAA1B","sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { createContext, useContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// Tabs Component\nexport interface TabsContextProps {\n currentIndex: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n tabListId: string | null;\n setTabListId: (v: string | null) => void;\n}\n\nconst tabsContext = createContext<TabsContextProps | null>(null);\nexport const { Provider: TabsProvider } = tabsContext;\nexport const useTabsContext = () => useContext(tabsContext);\n\n// TabList Component\nexport interface TabListContextProps {\n tabsScope: Scope<HTMLElement>;\n manualActivation: boolean;\n vertical: boolean;\n}\n\nconst tablistContext = createContext<TabListContextProps | null>(null);\nexport const { Provider: TabListProvider } = tablistContext;\nexport const useTabListContext = () => useContext(tablistContext);\n"],"file":"context.js"}
File without changes
File without changes
@@ -1,11 +1,10 @@
1
- import type { RefAttributes } from 'react';
2
- import React from 'react';
1
+ import type { ElementType, HTMLAttributes, ReactNode, RefAttributes } from 'react';
3
2
  export type { InjectedTooltipProps } from './useTooltip';
4
- export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
5
- as?: React.ElementType<any>;
6
- innerAs?: React.ElementType<any>;
7
- children?: React.ReactNode;
8
- label: React.ReactNode;
3
+ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
4
+ as?: ElementType<any>;
5
+ innerAs?: ElementType<any>;
6
+ children?: ReactNode;
7
+ label: ReactNode;
9
8
  disabled?: boolean;
10
9
  }
11
- export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
10
+ export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  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
- import React, { forwardRef, cloneElement, Children } from 'react';
4
+ import { forwardRef, cloneElement, Children } from 'react';
5
5
  import { useTooltip } from './useTooltip';
6
6
  import { Fragment as _Fragment } from "react/jsx-runtime";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tooltip/Tooltip.tsx"],"names":["React","forwardRef","cloneElement","Children","useTooltip","Tooltip","props","forwardedRef","as","Comp","innerAs","children","disabled","otherProps","child","only","ref","childProps","visible","tooltipProps"],"mappings":";;;AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,YAA5B,EAA0CC,QAA1C,QAA0D,OAA1D;AAEA,SAASC,UAAT,QAA2B,cAA3B;;;;AAWA,OAAO,IAAMC,OAAO,gBAAGJ,UAAU,CAC/B,SAASI,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AAAA,kBAOhCD,KAPgC,CAElCE,EAFkC;AAAA,MAE9BC,IAF8B,0BAEvB,KAFuB;AAAA,MAGlCC,OAHkC,GAOhCJ,KAPgC,CAGlCI,OAHkC;AAAA,MAIlCC,QAJkC,GAOhCL,KAPgC,CAIlCK,QAJkC;AAAA,wBAOhCL,KAPgC,CAKlCM,QALkC;AAAA,MAKlCA,QALkC,gCAKvB,KALuB;AAAA,MAM/BC,UAN+B,4BAOhCP,KAPgC;;AAQpC,MAAMQ,KAAwC,GAAGX,QAAQ,CAACY,IAAT,CAC/CJ,QAD+C,CAAjD;;AARoC,oBAWeP,UAAU,CAC3DU,KAAK,CAACR,KADqD,EAE3DQ,KAAK,CAACE,GAFqD,EAG3DH,UAH2D,CAXzB;AAAA;AAAA,MAW7BI,UAX6B;AAAA;AAAA,MAWfC,OAXe,iBAWfA,OAXe;AAAA,MAWHC,YAXG;;AAiBpC,MAAIP,QAAJ,EAAc;AACZ,wBAAO;AAAA,gBAAGE;AAAH,MAAP;AACD;;AAED,sBACE;AAAA,4BACGZ,YAAY,CAACY,KAAD,EAAQG,UAAR,CADf,EAEGC,OAAO,iBAAI,KAAC,IAAD;AAAM,MAAA,EAAE,EAAER,OAAV;AAAmB,MAAA,GAAG,EAAEH;AAAxB,OAA0CY,YAA1C,EAFd;AAAA,IADF;AAMD,CA5B8B,CAA1B","sourcesContent":["import type { ReactElement, RefAttributes } from 'react';\nimport React, { forwardRef, cloneElement, Children } from 'react';\n\nimport { useTooltip } from './useTooltip';\nexport type { InjectedTooltipProps } from './useTooltip';\n\nexport interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n label: React.ReactNode;\n disabled?: boolean;\n}\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n function Tooltip(props, forwardedRef) {\n const {\n as: Comp = 'div',\n innerAs,\n children,\n disabled = false,\n ...otherProps\n } = props;\n const child: ReactElement & RefAttributes<any> = Children.only(\n children\n ) as any;\n const [childProps, { visible, ...tooltipProps }] = useTooltip(\n child.props,\n child.ref,\n otherProps\n );\n\n if (disabled) {\n return <>{child}</>;\n }\n\n return (\n <>\n {cloneElement(child, childProps)}\n {visible && <Comp as={innerAs} ref={forwardedRef} {...tooltipProps} />}\n </>\n );\n }\n);\n"],"file":"Tooltip.js"}
1
+ {"version":3,"sources":["../../../src/Tooltip/Tooltip.tsx"],"names":["forwardRef","cloneElement","Children","useTooltip","Tooltip","props","forwardedRef","as","Comp","innerAs","children","disabled","otherProps","child","only","ref","childProps","visible","tooltipProps"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,YAArB,EAAmCC,QAAnC,QAAmD,OAAnD;AAEA,SAASC,UAAT,QAA2B,cAA3B;;;;AAWA,OAAO,IAAMC,OAAO,gBAAGJ,UAAU,CAC/B,SAASI,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AAAA,kBAOhCD,KAPgC,CAElCE,EAFkC;AAAA,MAE9BC,IAF8B,0BAEvB,KAFuB;AAAA,MAGlCC,OAHkC,GAOhCJ,KAPgC,CAGlCI,OAHkC;AAAA,MAIlCC,QAJkC,GAOhCL,KAPgC,CAIlCK,QAJkC;AAAA,wBAOhCL,KAPgC,CAKlCM,QALkC;AAAA,MAKlCA,QALkC,gCAKvB,KALuB;AAAA,MAM/BC,UAN+B,4BAOhCP,KAPgC;;AAQpC,MAAMQ,KAAwC,GAAGX,QAAQ,CAACY,IAAT,CAC/CJ,QAD+C,CAAjD;;AARoC,oBAWeP,UAAU,CAC3DU,KAAK,CAACR,KADqD,EAE3DQ,KAAK,CAACE,GAFqD,EAG3DH,UAH2D,CAXzB;AAAA;AAAA,MAW7BI,UAX6B;AAAA;AAAA,MAWfC,OAXe,iBAWfA,OAXe;AAAA,MAWHC,YAXG;;AAiBpC,MAAIP,QAAJ,EAAc;AACZ,wBAAO;AAAA,gBAAGE;AAAH,MAAP;AACD;;AAED,sBACE;AAAA,4BACGZ,YAAY,CAACY,KAAD,EAAQG,UAAR,CADf,EAEGC,OAAO,iBAAI,KAAC,IAAD;AAAM,MAAA,EAAE,EAAER,OAAV;AAAmB,MAAA,GAAG,EAAEH;AAAxB,OAA0CY,YAA1C,EAFd;AAAA,IADF;AAMD,CA5B8B,CAA1B","sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n RefAttributes,\n} from 'react';\nimport { forwardRef, cloneElement, Children } from 'react';\n\nimport { useTooltip } from './useTooltip';\nexport type { InjectedTooltipProps } from './useTooltip';\n\nexport interface TooltipProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n label: ReactNode;\n disabled?: boolean;\n}\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n function Tooltip(props, forwardedRef) {\n const {\n as: Comp = 'div',\n innerAs,\n children,\n disabled = false,\n ...otherProps\n } = props;\n const child: ReactElement & RefAttributes<any> = Children.only(\n children\n ) as any;\n const [childProps, { visible, ...tooltipProps }] = useTooltip(\n child.props,\n child.ref,\n otherProps\n );\n\n if (disabled) {\n return <>{child}</>;\n }\n\n return (\n <>\n {cloneElement(child, childProps)}\n {visible && <Comp as={innerAs} ref={forwardedRef} {...tooltipProps} />}\n </>\n );\n }\n);\n"],"file":"Tooltip.js"}
File without changes
File without changes
@@ -1,10 +1,10 @@
1
- import type { RefAttributes } from 'react';
2
- export declare type ChildProps = React.HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>;
3
- export interface InjectedTooltipProps extends React.HTMLAttributes<HTMLElement> {
4
- anchorEl: React.RefObject<HTMLElement>;
1
+ import type { HTMLAttributes, ReactNode, Ref, RefAttributes, RefObject } from 'react';
2
+ export declare type ChildProps = HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>;
3
+ export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
4
+ anchorEl: RefObject<HTMLElement>;
5
5
  visible: boolean;
6
- children?: React.ReactNode;
6
+ children?: ReactNode;
7
7
  }
8
- export declare function useTooltip(childProps: ChildProps, childRef: React.Ref<HTMLElement> | undefined, tooltipProps: React.HTMLAttributes<HTMLElement> & {
9
- label?: React.ReactNode;
8
+ export declare function useTooltip(childProps: ChildProps, childRef: Ref<HTMLElement> | undefined, tooltipProps: HTMLAttributes<HTMLElement> & {
9
+ label?: ReactNode;
10
10
  }): [ChildProps, InjectedTooltipProps];
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Tooltip/useTooltip.ts"],"names":["useRef","useEffect","useState","useId","assignMultipleRefs","wrapEvent","send","state","subscription","Blur","Focus","LeavingVisible","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","Visible","useTooltip","childProps","childRef","tooltipProps","onMouseEnter","onMouseLeave","onMouseMove","onMouseDown","onKeyDown","onFocus","onBlur","anchorEl","visible","setVisible","id","subscribe","current","handleMouseEnter","handleMouseMove","handleMouseLeave","handleMouseDown","handleFocus","handleBlur","undefined","handleKeyDown","event","key","children","label","tooltipOnMouseEnter","tooltipOnMouseLeave","tooltipOnMouseMove","otherTooltipProps","tooltipId","ref","role"],"mappings":";;;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,EAAsCC,KAAtC,QAAmD,OAAnD;AAEA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SACEC,IADF,EAEEC,KAFF,EAGEC,YAHF,EAIEC,IAJF,EAKEC,KALF,EAMEC,cANF,EAOEC,SAPF,EAQEC,UARF,EASEC,UATF,EAUEC,SAVF,EAWEC,kBAXF,EAYEC,OAZF,QAaO,gBAbP;AAyBA,OAAO,SAASC,UAAT,CACLC,UADK,EAELC,QAFK,EAGLC,YAHK,EAI+B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Aec,gBAAf,CAPpB;AAQHb,IAAAA,WAAW,EAAEnB,SAAS,CAACmB,WAAD,EAAcY,eAAd,CARnB;AASHX,IAAAA,WAAW,EAAEpB,SAAS,CAACoB,WAAD,EAAca,eAAd,CATnB;AAUHX,IAAAA,OAAO,EAAEtB,SAAS,CAACsB,OAAD,EAAUY,WAAV,CAVf;AAWHX,IAAAA,MAAM,EAAEvB,SAAS,CAACuB,MAAD,EAASY,UAAT,CAXd;AAYHd,IAAAA,SAAS,EAAErB,SAAS,CAACqB,SAAD,EAAYgB,aAAZ;AAZjB;AAeHV,IAAAA,EAAE,EAAEmB,SAfD;AAgBHtB,IAAAA,QAAQ,EAARA,QAhBG;AAiBHC,IAAAA,OAAO,EAAPA,OAjBG;AAkBHe,IAAAA,QAAQ,EAARA,QAlBG;AAmBHvB,IAAAA,YAAY,EAAEjB,SAAS,CAAC0C,mBAAD,EAAsBZ,gBAAtB,CAnBpB;AAoBHZ,IAAAA,YAAY,EAAElB,SAAS,CAAC2C,mBAAD,EAAsBX,gBAAtB,CApBpB;AAqBHb,IAAAA,WAAW,EAAEnB,SAAS,CAAC4C,kBAAD,EAAqBb,eAArB,CArBnB;AAsBHiB,IAAAA,IAAI,EAAE;AAtBH,KAuBAH,iBAvBA,EAAP;AA0BD","sourcesContent":["import type { RefAttributes } from 'react';\nimport { useRef, useEffect, useState, useId } from 'react';\n\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport {\n send,\n state,\n subscription,\n Blur,\n Focus,\n LeavingVisible,\n MouseDown,\n MouseEnter,\n MouseLeave,\n MouseMove,\n SelectWithKeyboard,\n Visible,\n} from './stateMachine';\n\nexport type ChildProps = React.HTMLAttributes<HTMLElement> &\n RefAttributes<HTMLElement>;\n\nexport interface InjectedTooltipProps\n extends React.HTMLAttributes<HTMLElement> {\n anchorEl: React.RefObject<HTMLElement>;\n visible: boolean;\n children?: React.ReactNode;\n}\n\nexport function useTooltip(\n childProps: ChildProps,\n childRef: React.Ref<HTMLElement> | undefined,\n tooltipProps: React.HTMLAttributes<HTMLElement> & { label?: React.ReactNode }\n): [ChildProps, InjectedTooltipProps] {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseMove,\n onMouseDown,\n onKeyDown,\n onFocus,\n onBlur,\n } = childProps;\n const anchorEl = useRef<HTMLElement>(null);\n const [visible, setVisible] = useState(false);\n const id = useId();\n\n useEffect(() => {\n subscription.subscribe(() => {\n setVisible(\n (state.current.state === Visible ||\n state.current.state === LeavingVisible) &&\n state.current.id === id\n );\n });\n }, [id]);\n\n function handleMouseEnter() {\n send(MouseEnter, { id });\n }\n\n function handleMouseMove() {\n send(MouseMove, { id });\n }\n\n function handleMouseLeave() {\n send(MouseLeave);\n }\n\n function handleMouseDown() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(MouseDown);\n }\n }\n\n function handleFocus() {\n send(Focus, { id });\n }\n\n function handleBlur() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(Blur, undefined);\n }\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n if (event.key === 'Enter' || event.key === ' ') {\n send(SelectWithKeyboard);\n }\n }\n\n const {\n label: children,\n onMouseEnter: tooltipOnMouseEnter,\n onMouseLeave: tooltipOnMouseLeave,\n onMouseMove: tooltipOnMouseMove,\n ...otherTooltipProps\n } = tooltipProps;\n\n const tooltipId = `tooltip-${id}`;\n return [\n {\n ...childProps,\n ref: assignMultipleRefs(childRef, anchorEl),\n ...(visible &&\n !childProps['aria-label'] && { 'aria-describedby': tooltipId }),\n onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(onMouseMove, handleMouseMove),\n onMouseDown: wrapEvent(onMouseDown, handleMouseDown),\n onFocus: wrapEvent(onFocus, handleFocus),\n onBlur: wrapEvent(onBlur, handleBlur),\n onKeyDown: wrapEvent(onKeyDown, handleKeyDown),\n },\n {\n id: tooltipId,\n anchorEl,\n visible,\n children,\n onMouseEnter: wrapEvent(tooltipOnMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(tooltipOnMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(tooltipOnMouseMove, handleMouseMove),\n role: 'tooltip',\n ...otherTooltipProps,\n },\n ];\n}\n"],"file":"useTooltip.js"}
1
+ {"version":3,"sources":["../../../src/Tooltip/useTooltip.ts"],"names":["useRef","useEffect","useState","useId","assignMultipleRefs","wrapEvent","send","state","subscription","Blur","Focus","LeavingVisible","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","Visible","useTooltip","childProps","childRef","tooltipProps","onMouseEnter","onMouseLeave","onMouseMove","onMouseDown","onKeyDown","onFocus","onBlur","anchorEl","visible","setVisible","id","subscribe","current","handleMouseEnter","handleMouseMove","handleMouseLeave","handleMouseDown","handleFocus","handleBlur","undefined","handleKeyDown","event","key","children","label","tooltipOnMouseEnter","tooltipOnMouseLeave","tooltipOnMouseMove","otherTooltipProps","tooltipId","ref","role"],"mappings":";;;AAQA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,EAAsCC,KAAtC,QAAmD,OAAnD;AAEA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SACEC,IADF,EAEEC,KAFF,EAGEC,YAHF,EAIEC,IAJF,EAKEC,KALF,EAMEC,cANF,EAOEC,SAPF,EAQEC,UARF,EASEC,UATF,EAUEC,SAVF,EAWEC,kBAXF,EAYEC,OAZF,QAaO,gBAbP;AAwBA,OAAO,SAASC,UAAT,CACLC,UADK,EAELC,QAFK,EAGLC,YAHK,EAI+B;AAAA,MAElCC,YAFkC,GAShCH,UATgC,CAElCG,YAFkC;AAAA,MAGlCC,YAHkC,GAShCJ,UATgC,CAGlCI,YAHkC;AAAA,MAIlCC,WAJkC,GAShCL,UATgC,CAIlCK,WAJkC;AAAA,MAKlCC,WALk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EAAEtB,SAAS,CAACsB,OAAD,EAAUY,WAAV,CAVf;AAWHX,IAAAA,MAAM,EAAEvB,SAAS,CAACuB,MAAD,EAASY,UAAT,CAXd;AAYHd,IAAAA,SAAS,EAAErB,SAAS,CAACqB,SAAD,EAAYgB,aAAZ;AAZjB;AAeHV,IAAAA,EAAE,EAAEmB,SAfD;AAgBHtB,IAAAA,QAAQ,EAARA,QAhBG;AAiBHC,IAAAA,OAAO,EAAPA,OAjBG;AAkBHe,IAAAA,QAAQ,EAARA,QAlBG;AAmBHvB,IAAAA,YAAY,EAAEjB,SAAS,CAAC0C,mBAAD,EAAsBZ,gBAAtB,CAnBpB;AAoBHZ,IAAAA,YAAY,EAAElB,SAAS,CAAC2C,mBAAD,EAAsBX,gBAAtB,CApBpB;AAqBHb,IAAAA,WAAW,EAAEnB,SAAS,CAAC4C,kBAAD,EAAqBb,eAArB,CArBnB;AAsBHiB,IAAAA,IAAI,EAAE;AAtBH,KAuBAH,iBAvBA,EAAP;AA0BD","sourcesContent":["import type {\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n Ref,\n RefAttributes,\n RefObject,\n} from 'react';\nimport { useRef, useEffect, useState, useId } from 'react';\n\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport {\n send,\n state,\n subscription,\n Blur,\n Focus,\n LeavingVisible,\n MouseDown,\n MouseEnter,\n MouseLeave,\n MouseMove,\n SelectWithKeyboard,\n Visible,\n} from './stateMachine';\n\nexport type ChildProps = HTMLAttributes<HTMLElement> &\n RefAttributes<HTMLElement>;\n\nexport interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {\n anchorEl: RefObject<HTMLElement>;\n visible: boolean;\n children?: ReactNode;\n}\n\nexport function useTooltip(\n childProps: ChildProps,\n childRef: Ref<HTMLElement> | undefined,\n tooltipProps: HTMLAttributes<HTMLElement> & { label?: ReactNode }\n): [ChildProps, InjectedTooltipProps] {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseMove,\n onMouseDown,\n onKeyDown,\n onFocus,\n onBlur,\n } = childProps;\n const anchorEl = useRef<HTMLElement>(null);\n const [visible, setVisible] = useState(false);\n const id = useId();\n\n useEffect(() => {\n subscription.subscribe(() => {\n setVisible(\n (state.current.state === Visible ||\n state.current.state === LeavingVisible) &&\n state.current.id === id\n );\n });\n }, [id]);\n\n function handleMouseEnter() {\n send(MouseEnter, { id });\n }\n\n function handleMouseMove() {\n send(MouseMove, { id });\n }\n\n function handleMouseLeave() {\n send(MouseLeave);\n }\n\n function handleMouseDown() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(MouseDown);\n }\n }\n\n function handleFocus() {\n send(Focus, { id });\n }\n\n function handleBlur() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(Blur, undefined);\n }\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLElement>) {\n if (event.key === 'Enter' || event.key === ' ') {\n send(SelectWithKeyboard);\n }\n }\n\n const {\n label: children,\n onMouseEnter: tooltipOnMouseEnter,\n onMouseLeave: tooltipOnMouseLeave,\n onMouseMove: tooltipOnMouseMove,\n ...otherTooltipProps\n } = tooltipProps;\n\n const tooltipId = `tooltip-${id}`;\n return [\n {\n ...childProps,\n ref: assignMultipleRefs(childRef, anchorEl),\n ...(visible &&\n !childProps['aria-label'] && { 'aria-describedby': tooltipId }),\n onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(onMouseMove, handleMouseMove),\n onMouseDown: wrapEvent(onMouseDown, handleMouseDown),\n onFocus: wrapEvent(onFocus, handleFocus),\n onBlur: wrapEvent(onBlur, handleBlur),\n onKeyDown: wrapEvent(onKeyDown, handleKeyDown),\n },\n {\n id: tooltipId,\n anchorEl,\n visible,\n children,\n onMouseEnter: wrapEvent(tooltipOnMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(tooltipOnMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(tooltipOnMouseMove, handleMouseMove),\n role: 'tooltip',\n ...otherTooltipProps,\n },\n ];\n}\n"],"file":"useTooltip.js"}
File without changes
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare function useAutoFocus(open: boolean, elementRef: React.MutableRefObject<HTMLElement | null>): void;
1
+ import type { MutableRefObject } from 'react';
2
+ export declare function useAutoFocus(open: boolean, elementRef: MutableRefObject<HTMLElement | null>): void;
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/useAutoFocus.ts"],"names":["useEffect","focusOnChildNode","useAutoFocus","open","elementRef","current","contains","document","activeElement"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA,OAAO,SAASC,YAAT,CACLC,IADK,EAELC,UAFK,EAGL;AACAJ,EAAAA,SAAS,CAAC,YAAM;AACd,QAAIG,IAAJ,EAAU;AACR;AACA,UACEC,UAAU,CAACC,OAAX,IACA,CAACD,UAAU,CAACC,OAAX,CAAmBC,QAAnB,CAA4BC,QAAQ,CAACC,aAArC,CAFH,EAGE;AACAP,QAAAA,gBAAgB,CAACG,UAAU,CAACC,OAAZ,EAAqB,CAArB,CAAhB;AACD;AACF,KATa,CAUd;;AACD,GAXQ,EAWN,CAACF,IAAD,CAXM,CAAT;AAYD","sourcesContent":["import { useEffect } from 'react';\n\nimport { focusOnChildNode } from '../FocusLock/tabUtils';\n\nexport function useAutoFocus(\n open: boolean,\n elementRef: React.MutableRefObject<HTMLElement | null>\n) {\n useEffect(() => {\n if (open) {\n // We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal\n if (\n elementRef.current &&\n !elementRef.current.contains(document.activeElement)\n ) {\n focusOnChildNode(elementRef.current, 0);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n}\n"],"file":"useAutoFocus.js"}
1
+ {"version":3,"sources":["../../../src/hooks/useAutoFocus.ts"],"names":["useEffect","focusOnChildNode","useAutoFocus","open","elementRef","current","contains","document","activeElement"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA,OAAO,SAASC,YAAT,CACLC,IADK,EAELC,UAFK,EAGL;AACAJ,EAAAA,SAAS,CAAC,YAAM;AACd,QAAIG,IAAJ,EAAU;AACR;AACA,UACEC,UAAU,CAACC,OAAX,IACA,CAACD,UAAU,CAACC,OAAX,CAAmBC,QAAnB,CAA4BC,QAAQ,CAACC,aAArC,CAFH,EAGE;AACAP,QAAAA,gBAAgB,CAACG,UAAU,CAACC,OAAZ,EAAqB,CAArB,CAAhB;AACD;AACF,KATa,CAUd;;AACD,GAXQ,EAWN,CAACF,IAAD,CAXM,CAAT;AAYD","sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport { focusOnChildNode } from '../FocusLock/tabUtils';\n\nexport function useAutoFocus(\n open: boolean,\n elementRef: MutableRefObject<HTMLElement | null>\n) {\n useEffect(() => {\n if (open) {\n // We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal\n if (\n elementRef.current &&\n !elementRef.current.contains(document.activeElement)\n ) {\n focusOnChildNode(elementRef.current, 0);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n}\n"],"file":"useAutoFocus.js"}
File without changes
@@ -1,7 +1,3 @@
1
- /// <reference types="react" />
1
+ import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
2
2
  import type { CustomEventHandler } from '../utils';
3
- export declare function useControlledState<V, E extends React.SyntheticEvent<any>, H extends unknown[]>(valueProp: V | undefined, onChangeProp: CustomEventHandler<E, H> | undefined, defaultValue: V, defaultOnChange: (setValue: React.Dispatch<React.SetStateAction<V>>) => CustomEventHandler<E, H>): [
4
- V,
5
- CustomEventHandler<E, H> | undefined,
6
- React.Dispatch<React.SetStateAction<V>>
7
- ];
3
+ export declare function useControlledState<V, E extends SyntheticEvent<any>, H extends unknown[]>(valueProp: V | undefined, onChangeProp: CustomEventHandler<E, H> | undefined, defaultValue: V, defaultOnChange: (setValue: Dispatch<SetStateAction<V>>) => CustomEventHandler<E, H>): [V, CustomEventHandler<E, H> | undefined, Dispatch<SetStateAction<V>>];
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/useControlledState.ts"],"names":["useRef","useState","wrapEvent","useControlledState","valueProp","onChangeProp","defaultValue","defaultOnChange","isControlled","undefined","valueState","setValueState","current","console","warn"],"mappings":";AAAA,SAASA,MAAT,EAAiBC,QAAjB,QAAiC,OAAjC;AAGA,SAASC,SAAT,QAA0B,UAA1B;AAEA,OAAO,SAASC,kBAAT,CAKLC,SALK,EAMLC,YANK,EAOLC,YAPK,EAQLC,eARK,EAeL;AACA,MAAMC,YAAY,GAAGR,MAAM,CAACI,SAAS,KAAKK,SAAf,CAA3B;;AADA,kBAEoCR,QAAQ,CAAIK,YAAJ,CAF5C;AAAA;AAAA,MAEOI,UAFP;AAAA,MAEmBC,aAFnB;;AAIA,MAAIH,YAAY,CAACI,OAAjB,EAA0B;AACxB,QAAIR,SAAS,KAAKK,SAAlB,EAA6B;AAC3BI,MAAAA,OAAO,CAACC,IAAR,CAAa,mDAAb;AACD,KAHuB,CAIxB;;;AACA,WAAO,CAACV,SAAD,EAAaC,YAAb,EAA2BM,aAA3B,CAAP;AACD;;AAED,SAAO,CACL;AACAD,EAAAA,UAFK,EAGLR,SAAS,CAACG,YAAD,EAAeE,eAAe,CAACI,aAAD,CAA9B,CAHJ,EAILA,aAJK,CAAP;AAMD","sourcesContent":["import { useRef, useState } from 'react';\n\nimport type { CustomEventHandler } from '../utils';\nimport { wrapEvent } from '../utils';\n\nexport function useControlledState<\n V,\n E extends React.SyntheticEvent<any>,\n H extends unknown[]\n>(\n valueProp: V | undefined,\n onChangeProp: CustomEventHandler<E, H> | undefined,\n defaultValue: V,\n defaultOnChange: (\n setValue: React.Dispatch<React.SetStateAction<V>>\n ) => CustomEventHandler<E, H>\n): [\n V,\n CustomEventHandler<E, H> | undefined,\n React.Dispatch<React.SetStateAction<V>>\n] {\n const isControlled = useRef(valueProp !== undefined);\n const [valueState, setValueState] = useState<V>(defaultValue);\n\n if (isControlled.current) {\n if (valueProp === undefined) {\n console.warn('Trying to change from controlled to uncontrolled.');\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return [valueProp!, onChangeProp, setValueState];\n }\n\n return [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n valueState!,\n wrapEvent(onChangeProp, defaultOnChange(setValueState)),\n setValueState,\n ];\n}\n"],"file":"useControlledState.js"}
1
+ {"version":3,"sources":["../../../src/hooks/useControlledState.ts"],"names":["useRef","useState","wrapEvent","useControlledState","valueProp","onChangeProp","defaultValue","defaultOnChange","isControlled","undefined","valueState","setValueState","current","console","warn"],"mappings":";AACA,SAASA,MAAT,EAAiBC,QAAjB,QAAiC,OAAjC;AAGA,SAASC,SAAT,QAA0B,UAA1B;AAEA,OAAO,SAASC,kBAAT,CAKLC,SALK,EAMLC,YANK,EAOLC,YAPK,EAQLC,eARK,EAWmE;AACxE,MAAMC,YAAY,GAAGR,MAAM,CAACI,SAAS,KAAKK,SAAf,CAA3B;;AADwE,kBAEpCR,QAAQ,CAAIK,YAAJ,CAF4B;AAAA;AAAA,MAEjEI,UAFiE;AAAA,MAErDC,aAFqD;;AAIxE,MAAIH,YAAY,CAACI,OAAjB,EAA0B;AACxB,QAAIR,SAAS,KAAKK,SAAlB,EAA6B;AAC3BI,MAAAA,OAAO,CAACC,IAAR,CAAa,mDAAb;AACD,KAHuB,CAIxB;;;AACA,WAAO,CAACV,SAAD,EAAaC,YAAb,EAA2BM,aAA3B,CAAP;AACD;;AAED,SAAO,CACL;AACAD,EAAAA,UAFK,EAGLR,SAAS,CAACG,YAAD,EAAeE,eAAe,CAACI,aAAD,CAA9B,CAHJ,EAILA,aAJK,CAAP;AAMD","sourcesContent":["import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';\nimport { useRef, useState } from 'react';\n\nimport type { CustomEventHandler } from '../utils';\nimport { wrapEvent } from '../utils';\n\nexport function useControlledState<\n V,\n E extends SyntheticEvent<any>,\n H extends unknown[]\n>(\n valueProp: V | undefined,\n onChangeProp: CustomEventHandler<E, H> | undefined,\n defaultValue: V,\n defaultOnChange: (\n setValue: Dispatch<SetStateAction<V>>\n ) => CustomEventHandler<E, H>\n): [V, CustomEventHandler<E, H> | undefined, Dispatch<SetStateAction<V>>] {\n const isControlled = useRef(valueProp !== undefined);\n const [valueState, setValueState] = useState<V>(defaultValue);\n\n if (isControlled.current) {\n if (valueProp === undefined) {\n console.warn('Trying to change from controlled to uncontrolled.');\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return [valueProp!, onChangeProp, setValueState];\n }\n\n return [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n valueState!,\n wrapEvent(onChangeProp, defaultOnChange(setValueState)),\n setValueState,\n ];\n}\n"],"file":"useControlledState.js"}
File without changes
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import type { FocusEventHandler } from 'react';
2
2
  export declare function useFocusState<T>(props?: {
3
- onFocus?: React.FocusEventHandler<T>;
4
- onBlur?: React.FocusEventHandler<T>;
3
+ onFocus?: FocusEventHandler<T>;
4
+ onBlur?: FocusEventHandler<T>;
5
5
  }): {
6
6
  bind: {
7
7
  onFocus: import("../utils/wrapEvent").CustomEventHandler<import("react").FocusEvent<T, Element>, []>;
File without changes