@depup/react-aria-components 1.19.0-depup.27 → 1.21.0-depup.0

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 (333) hide show
  1. package/NavigationTree/package.json +5 -0
  2. package/PreviewTrigger/package.json +5 -0
  3. package/README.md +2 -2
  4. package/TokenField/package.json +5 -0
  5. package/changes.json +1 -1
  6. package/dist/exports/GridList.cjs.map +1 -1
  7. package/dist/exports/GridList.js.map +1 -1
  8. package/dist/exports/GridList.mjs.map +1 -1
  9. package/dist/exports/Menu.cjs +1 -0
  10. package/dist/exports/Menu.cjs.map +1 -1
  11. package/dist/exports/Menu.js +2 -2
  12. package/dist/exports/Menu.js.map +1 -1
  13. package/dist/exports/Menu.mjs +2 -2
  14. package/dist/exports/Menu.mjs.map +1 -1
  15. package/dist/exports/NavigationTree.cjs +37 -0
  16. package/dist/exports/NavigationTree.cjs.map +1 -0
  17. package/dist/exports/NavigationTree.js +25 -0
  18. package/dist/exports/NavigationTree.js.map +1 -0
  19. package/dist/exports/NavigationTree.mjs +25 -0
  20. package/dist/exports/NavigationTree.mjs.map +1 -0
  21. package/dist/exports/PreviewTrigger.cjs +26 -0
  22. package/dist/exports/PreviewTrigger.cjs.map +1 -0
  23. package/dist/exports/PreviewTrigger.js +21 -0
  24. package/dist/exports/PreviewTrigger.js.map +1 -0
  25. package/dist/exports/PreviewTrigger.mjs +21 -0
  26. package/dist/exports/PreviewTrigger.mjs.map +1 -0
  27. package/dist/exports/TokenField.cjs +31 -0
  28. package/dist/exports/TokenField.cjs.map +1 -0
  29. package/dist/exports/TokenField.js +21 -0
  30. package/dist/exports/TokenField.js.map +1 -0
  31. package/dist/exports/TokenField.mjs +21 -0
  32. package/dist/exports/TokenField.mjs.map +1 -0
  33. package/dist/exports/Tree.cjs.map +1 -1
  34. package/dist/exports/Tree.js.map +1 -1
  35. package/dist/exports/Tree.mjs.map +1 -1
  36. package/dist/exports/index.cjs +25 -0
  37. package/dist/exports/index.cjs.map +1 -1
  38. package/dist/exports/index.js +12 -2
  39. package/dist/exports/index.js.map +1 -1
  40. package/dist/exports/index.mjs +12 -2
  41. package/dist/exports/index.mjs.map +1 -1
  42. package/dist/private/Checkbox.cjs.map +1 -1
  43. package/dist/private/Checkbox.js.map +1 -1
  44. package/dist/private/Checkbox.mjs.map +1 -1
  45. package/dist/private/ComboBox.cjs +21 -2
  46. package/dist/private/ComboBox.cjs.map +1 -1
  47. package/dist/private/ComboBox.js +21 -2
  48. package/dist/private/ComboBox.js.map +1 -1
  49. package/dist/private/ComboBox.mjs +21 -2
  50. package/dist/private/ComboBox.mjs.map +1 -1
  51. package/dist/private/Dialog.cjs +21 -1
  52. package/dist/private/Dialog.cjs.map +1 -1
  53. package/dist/private/Dialog.js +21 -1
  54. package/dist/private/Dialog.js.map +1 -1
  55. package/dist/private/Dialog.mjs +21 -1
  56. package/dist/private/Dialog.mjs.map +1 -1
  57. package/dist/private/DragAndDrop.cjs +1 -0
  58. package/dist/private/DragAndDrop.cjs.map +1 -1
  59. package/dist/private/DragAndDrop.js +1 -0
  60. package/dist/private/DragAndDrop.js.map +1 -1
  61. package/dist/private/DragAndDrop.mjs +1 -0
  62. package/dist/private/DragAndDrop.mjs.map +1 -1
  63. package/dist/private/DropZone.cjs +5 -2
  64. package/dist/private/DropZone.cjs.map +1 -1
  65. package/dist/private/DropZone.js +5 -3
  66. package/dist/private/DropZone.js.map +1 -1
  67. package/dist/private/DropZone.mjs +5 -2
  68. package/dist/private/DropZone.mjs.map +1 -1
  69. package/dist/private/FileTrigger.cjs +1 -0
  70. package/dist/private/FileTrigger.cjs.map +1 -1
  71. package/dist/private/FileTrigger.js +1 -0
  72. package/dist/private/FileTrigger.js.map +1 -1
  73. package/dist/private/FileTrigger.mjs +1 -0
  74. package/dist/private/FileTrigger.mjs.map +1 -1
  75. package/dist/private/GridLayout.cjs +3 -1
  76. package/dist/private/GridLayout.cjs.map +1 -1
  77. package/dist/private/GridLayout.js +3 -1
  78. package/dist/private/GridLayout.js.map +1 -1
  79. package/dist/private/GridLayout.mjs +3 -1
  80. package/dist/private/GridLayout.mjs.map +1 -1
  81. package/dist/private/GridList.cjs +12 -1
  82. package/dist/private/GridList.cjs.map +1 -1
  83. package/dist/private/GridList.js +12 -1
  84. package/dist/private/GridList.js.map +1 -1
  85. package/dist/private/GridList.mjs +12 -1
  86. package/dist/private/GridList.mjs.map +1 -1
  87. package/dist/private/ListBox.cjs +9 -1
  88. package/dist/private/ListBox.cjs.map +1 -1
  89. package/dist/private/ListBox.js +9 -1
  90. package/dist/private/ListBox.js.map +1 -1
  91. package/dist/private/ListBox.mjs +9 -1
  92. package/dist/private/ListBox.mjs.map +1 -1
  93. package/dist/private/Menu.cjs +59 -2
  94. package/dist/private/Menu.cjs.map +1 -1
  95. package/dist/private/Menu.js +60 -4
  96. package/dist/private/Menu.js.map +1 -1
  97. package/dist/private/Menu.mjs +60 -4
  98. package/dist/private/Menu.mjs.map +1 -1
  99. package/dist/private/Meter.cjs +2 -1
  100. package/dist/private/Meter.cjs.map +1 -1
  101. package/dist/private/Meter.js +2 -1
  102. package/dist/private/Meter.js.map +1 -1
  103. package/dist/private/Meter.mjs +2 -1
  104. package/dist/private/Meter.mjs.map +1 -1
  105. package/dist/private/Modal.cjs +2 -0
  106. package/dist/private/Modal.cjs.map +1 -1
  107. package/dist/private/Modal.js +2 -0
  108. package/dist/private/Modal.js.map +1 -1
  109. package/dist/private/Modal.mjs +2 -0
  110. package/dist/private/Modal.mjs.map +1 -1
  111. package/dist/private/NavigationTree.cjs +272 -0
  112. package/dist/private/NavigationTree.cjs.map +1 -0
  113. package/dist/private/NavigationTree.js +258 -0
  114. package/dist/private/NavigationTree.js.map +1 -0
  115. package/dist/private/NavigationTree.mjs +257 -0
  116. package/dist/private/NavigationTree.mjs.map +1 -0
  117. package/dist/private/Popover.cjs +34 -9
  118. package/dist/private/Popover.cjs.map +1 -1
  119. package/dist/private/Popover.js +34 -9
  120. package/dist/private/Popover.js.map +1 -1
  121. package/dist/private/Popover.mjs +34 -9
  122. package/dist/private/Popover.mjs.map +1 -1
  123. package/dist/private/PreviewTrigger.cjs +88 -0
  124. package/dist/private/PreviewTrigger.cjs.map +1 -0
  125. package/dist/private/PreviewTrigger.js +80 -0
  126. package/dist/private/PreviewTrigger.js.map +1 -0
  127. package/dist/private/PreviewTrigger.mjs +79 -0
  128. package/dist/private/PreviewTrigger.mjs.map +1 -0
  129. package/dist/private/ProgressBar.cjs +6 -1
  130. package/dist/private/ProgressBar.cjs.map +1 -1
  131. package/dist/private/ProgressBar.js +6 -1
  132. package/dist/private/ProgressBar.js.map +1 -1
  133. package/dist/private/ProgressBar.mjs +6 -1
  134. package/dist/private/ProgressBar.mjs.map +1 -1
  135. package/dist/private/RadioGroup.cjs.map +1 -1
  136. package/dist/private/RadioGroup.js.map +1 -1
  137. package/dist/private/RadioGroup.mjs.map +1 -1
  138. package/dist/private/Select.cjs.map +1 -1
  139. package/dist/private/Select.js.map +1 -1
  140. package/dist/private/Select.mjs.map +1 -1
  141. package/dist/private/Switch.cjs +8 -2
  142. package/dist/private/Switch.cjs.map +1 -1
  143. package/dist/private/Switch.js +9 -3
  144. package/dist/private/Switch.js.map +1 -1
  145. package/dist/private/Switch.mjs +9 -3
  146. package/dist/private/Switch.mjs.map +1 -1
  147. package/dist/private/Table.cjs +26 -14
  148. package/dist/private/Table.cjs.map +1 -1
  149. package/dist/private/Table.js +26 -14
  150. package/dist/private/Table.js.map +1 -1
  151. package/dist/private/Table.mjs +26 -14
  152. package/dist/private/Table.mjs.map +1 -1
  153. package/dist/private/TableLayout.cjs +3 -1
  154. package/dist/private/TableLayout.cjs.map +1 -1
  155. package/dist/private/TableLayout.js +3 -1
  156. package/dist/private/TableLayout.js.map +1 -1
  157. package/dist/private/TableLayout.mjs +3 -1
  158. package/dist/private/TableLayout.mjs.map +1 -1
  159. package/dist/private/TagGroup.cjs +1 -0
  160. package/dist/private/TagGroup.cjs.map +1 -1
  161. package/dist/private/TagGroup.js +1 -0
  162. package/dist/private/TagGroup.js.map +1 -1
  163. package/dist/private/TagGroup.mjs +1 -0
  164. package/dist/private/TagGroup.mjs.map +1 -1
  165. package/dist/private/Text.cjs +3 -1
  166. package/dist/private/Text.cjs.map +1 -1
  167. package/dist/private/Text.js +4 -2
  168. package/dist/private/Text.js.map +1 -1
  169. package/dist/private/Text.mjs +4 -2
  170. package/dist/private/Text.mjs.map +1 -1
  171. package/dist/private/ToggleButton.cjs.map +1 -1
  172. package/dist/private/ToggleButton.js.map +1 -1
  173. package/dist/private/ToggleButton.mjs.map +1 -1
  174. package/dist/private/TokenField.cjs +235 -0
  175. package/dist/private/TokenField.cjs.map +1 -0
  176. package/dist/private/TokenField.js +225 -0
  177. package/dist/private/TokenField.js.map +1 -0
  178. package/dist/private/TokenField.mjs +223 -0
  179. package/dist/private/TokenField.mjs.map +1 -0
  180. package/dist/private/Tooltip.cjs +10 -2
  181. package/dist/private/Tooltip.cjs.map +1 -1
  182. package/dist/private/Tooltip.js +10 -2
  183. package/dist/private/Tooltip.js.map +1 -1
  184. package/dist/private/Tooltip.mjs +10 -2
  185. package/dist/private/Tooltip.mjs.map +1 -1
  186. package/dist/private/Tree.cjs +11 -1
  187. package/dist/private/Tree.cjs.map +1 -1
  188. package/dist/private/Tree.js +11 -1
  189. package/dist/private/Tree.js.map +1 -1
  190. package/dist/private/Tree.mjs +11 -1
  191. package/dist/private/Tree.mjs.map +1 -1
  192. package/dist/private/TreeDropTargetDelegate.cjs +11 -6
  193. package/dist/private/TreeDropTargetDelegate.cjs.map +1 -1
  194. package/dist/private/TreeDropTargetDelegate.js +11 -6
  195. package/dist/private/TreeDropTargetDelegate.js.map +1 -1
  196. package/dist/private/TreeDropTargetDelegate.mjs +11 -6
  197. package/dist/private/TreeDropTargetDelegate.mjs.map +1 -1
  198. package/dist/private/Virtualizer.cjs +18 -16
  199. package/dist/private/Virtualizer.cjs.map +1 -1
  200. package/dist/private/Virtualizer.js +18 -16
  201. package/dist/private/Virtualizer.js.map +1 -1
  202. package/dist/private/Virtualizer.mjs +18 -16
  203. package/dist/private/Virtualizer.mjs.map +1 -1
  204. package/dist/private/useDragAndDrop.cjs +7 -0
  205. package/dist/private/useDragAndDrop.cjs.map +1 -1
  206. package/dist/private/useDragAndDrop.js +7 -0
  207. package/dist/private/useDragAndDrop.js.map +1 -1
  208. package/dist/private/useDragAndDrop.mjs +7 -0
  209. package/dist/private/useDragAndDrop.mjs.map +1 -1
  210. package/dist/private/utils.cjs.map +1 -1
  211. package/dist/private/utils.js.map +1 -1
  212. package/dist/private/utils.mjs.map +1 -1
  213. package/dist/types/exports/GridList.d.ts +1 -1
  214. package/dist/types/exports/Menu.d.ts +2 -2
  215. package/dist/types/exports/NavigationTree.d.ts +8 -0
  216. package/dist/types/exports/PreviewTrigger.d.ts +3 -0
  217. package/dist/types/exports/TokenField.d.ts +5 -0
  218. package/dist/types/exports/Tree.d.ts +1 -1
  219. package/dist/types/exports/index.d.ts +14 -5
  220. package/dist/types/src/Breadcrumbs.d.ts +2 -2
  221. package/dist/types/src/Button.d.ts +1 -1
  222. package/dist/types/src/Calendar.d.ts +6 -6
  223. package/dist/types/src/Checkbox.d.ts +8 -8
  224. package/dist/types/src/Collection.d.ts +1 -1
  225. package/dist/types/src/ComboBox.d.ts +6 -3
  226. package/dist/types/src/DateField.d.ts +4 -4
  227. package/dist/types/src/DatePicker.d.ts +2 -2
  228. package/dist/types/src/Dialog.d.ts +2 -2
  229. package/dist/types/src/Disclosure.d.ts +2 -2
  230. package/dist/types/src/GridList.d.ts +18 -7
  231. package/dist/types/src/Group.d.ts +1 -1
  232. package/dist/types/src/Header.d.ts +1 -1
  233. package/dist/types/src/Input.d.ts +1 -1
  234. package/dist/types/src/Label.d.ts +1 -1
  235. package/dist/types/src/Link.d.ts +1 -1
  236. package/dist/types/src/ListBox.d.ts +6 -6
  237. package/dist/types/src/Menu.d.ts +25 -6
  238. package/dist/types/src/Meter.d.ts +1 -1
  239. package/dist/types/src/Modal.d.ts +2 -2
  240. package/dist/types/src/NavigationTree.d.ts +80 -0
  241. package/dist/types/src/NumberField.d.ts +1 -1
  242. package/dist/types/src/OverlayArrow.d.ts +1 -1
  243. package/dist/types/src/Popover.d.ts +8 -1
  244. package/dist/types/src/PreviewTrigger.d.ts +23 -0
  245. package/dist/types/src/RadioGroup.d.ts +8 -8
  246. package/dist/types/src/SearchField.d.ts +1 -1
  247. package/dist/types/src/Select.d.ts +3 -3
  248. package/dist/types/src/Separator.d.ts +1 -1
  249. package/dist/types/src/Slider.d.ts +5 -5
  250. package/dist/types/src/Switch.d.ts +7 -7
  251. package/dist/types/src/Table.d.ts +32 -8
  252. package/dist/types/src/Tabs.d.ts +5 -5
  253. package/dist/types/src/TagGroup.d.ts +3 -3
  254. package/dist/types/src/Text.d.ts +1 -1
  255. package/dist/types/src/TextField.d.ts +1 -1
  256. package/dist/types/src/Toast.d.ts +3 -3
  257. package/dist/types/src/ToggleButton.d.ts +1 -1
  258. package/dist/types/src/ToggleButtonGroup.d.ts +1 -1
  259. package/dist/types/src/TokenField.d.ts +111 -0
  260. package/dist/types/src/Toolbar.d.ts +1 -1
  261. package/dist/types/src/Tooltip.d.ts +1 -1
  262. package/dist/types/src/Tree.d.ts +12 -10
  263. package/dist/types/src/Virtualizer.d.ts +4 -0
  264. package/dist/types/src/utils.d.ts +19 -5
  265. package/i18n/ar-AE.js +1 -1
  266. package/i18n/ar-AE.mjs +1 -1
  267. package/i18n/bg-BG.js +1 -1
  268. package/i18n/bg-BG.mjs +1 -1
  269. package/i18n/cs-CZ.js +1 -1
  270. package/i18n/cs-CZ.mjs +1 -1
  271. package/i18n/da-DK.js +1 -1
  272. package/i18n/da-DK.mjs +1 -1
  273. package/i18n/de-DE.js +1 -1
  274. package/i18n/de-DE.mjs +1 -1
  275. package/i18n/el-GR.js +1 -1
  276. package/i18n/el-GR.mjs +1 -1
  277. package/i18n/en-US.js +1 -1
  278. package/i18n/en-US.mjs +1 -1
  279. package/i18n/es-ES.js +1 -1
  280. package/i18n/es-ES.mjs +1 -1
  281. package/i18n/et-EE.js +1 -1
  282. package/i18n/et-EE.mjs +1 -1
  283. package/i18n/fi-FI.js +1 -1
  284. package/i18n/fi-FI.mjs +1 -1
  285. package/i18n/fr-FR.js +1 -1
  286. package/i18n/fr-FR.mjs +1 -1
  287. package/i18n/he-IL.js +1 -1
  288. package/i18n/he-IL.mjs +1 -1
  289. package/i18n/hr-HR.js +1 -1
  290. package/i18n/hr-HR.mjs +1 -1
  291. package/i18n/hu-HU.js +1 -1
  292. package/i18n/hu-HU.mjs +1 -1
  293. package/i18n/it-IT.js +1 -1
  294. package/i18n/it-IT.mjs +1 -1
  295. package/i18n/ja-JP.js +1 -1
  296. package/i18n/ja-JP.mjs +1 -1
  297. package/i18n/ko-KR.js +1 -1
  298. package/i18n/ko-KR.mjs +1 -1
  299. package/i18n/lt-LT.js +1 -1
  300. package/i18n/lt-LT.mjs +1 -1
  301. package/i18n/lv-LV.js +1 -1
  302. package/i18n/lv-LV.mjs +1 -1
  303. package/i18n/nb-NO.js +1 -1
  304. package/i18n/nb-NO.mjs +1 -1
  305. package/i18n/nl-NL.js +1 -1
  306. package/i18n/nl-NL.mjs +1 -1
  307. package/i18n/pl-PL.js +1 -1
  308. package/i18n/pl-PL.mjs +1 -1
  309. package/i18n/pt-BR.js +1 -1
  310. package/i18n/pt-BR.mjs +1 -1
  311. package/i18n/pt-PT.js +1 -1
  312. package/i18n/pt-PT.mjs +1 -1
  313. package/i18n/ro-RO.js +1 -1
  314. package/i18n/ro-RO.mjs +1 -1
  315. package/i18n/ru-RU.js +1 -1
  316. package/i18n/ru-RU.mjs +1 -1
  317. package/i18n/sk-SK.js +1 -1
  318. package/i18n/sk-SK.mjs +1 -1
  319. package/i18n/sl-SI.js +1 -1
  320. package/i18n/sl-SI.mjs +1 -1
  321. package/i18n/sr-SP.js +1 -1
  322. package/i18n/sr-SP.mjs +1 -1
  323. package/i18n/sv-SE.js +1 -1
  324. package/i18n/sv-SE.mjs +1 -1
  325. package/i18n/tr-TR.js +1 -1
  326. package/i18n/tr-TR.mjs +1 -1
  327. package/i18n/uk-UA.js +1 -1
  328. package/i18n/uk-UA.mjs +1 -1
  329. package/i18n/zh-CN.js +1 -1
  330. package/i18n/zh-CN.mjs +1 -1
  331. package/i18n/zh-TW.js +1 -1
  332. package/i18n/zh-TW.mjs +1 -1
  333. package/package.json +33 -31
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwMM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAA+C;AACjF,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AACzD,MAAM,yDAAqB,CAAA,GAAA,0BAAY,EAAsB;AAO7D,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,OAC1E,KAAkB,EAClB,GAAmC;IAEnC,IAAI,EAAC,UAAU,uBAAuB,IAAI,EAAE,GAAG,YAAW,GAAG;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,YAAY,KAAK;IAChD,IAAI,WAAW,CAAA,GAAA,yCAAW,EACxB,CAAA,GAAA,mCAAQ,EAAE,sBAAsB,MAAM,QAAQ,KAAK,YAAY,MAAM,QAAQ,GAAG;IAElF,IAAI,QAAQ,CAAA,GAAA,gDAAa,EAAE;IAC3B,IAAI,OAAO,CAAA,GAAA,mCAAQ,EACjB;QACE,GAAG,CAAA,GAAA,8CAAmB,EAAE,MAAM;QAC9B,kDAAkD;QAClD,UAAU,OAAO,MAAM,QAAQ,KAAK,aAAa,OAAO,MAAM,QAAQ;IACxE,GACA,OACA;IAGF,qBACE,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC;gBAAoB;aAAM;YAC3B;gBACE;gBACA;oBACE,GAAG,IAAI;8BACP;oBACA,kBAAkB;gBACpB;aACD;SACF;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AAQ;wBACN;uBACA;uBACA;uBACA;4BACA;wBACA;wBACA;uBACA;YACA,YAAY,cAAc;mBAC1B;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,0DAAC,CAAA,GAAA,6CAAa;QAAE,aAAY;qBAC1B,0DAAC;QAAO,GAAG,CAAA,GAAA,qCAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwMM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAA+C;AACjF,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AACzD,MAAM,yDAAqB,CAAA,GAAA,0BAAY,EAAsB;AAO7D,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,OAC1E,KAAkB,EAClB,GAAmC;IAEnC,IAAI,EAAC,UAAU,uBAAuB,IAAI,EAAE,GAAG,YAAW,GAAG;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,YAAY,KAAK;IAChD,IAAI,WAAW,CAAA,GAAA,yCAAW,EACxB,CAAA,GAAA,oBAAM,EACJ,IAAM,CAAA,GAAA,mCAAQ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QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, Ref, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.cjs.map"}
@@ -6,7 +6,7 @@ import {useSwitch as $aLaER$useSwitch} from "react-aria/useSwitch";
6
6
  import {filterDOMProps as $aLaER$filterDOMProps} from "react-aria/filterDOMProps";
7
7
  import {mergeProps as $aLaER$mergeProps} from "react-aria/mergeProps";
8
8
  import {mergeRefs as $aLaER$mergeRefs} from "react-aria/mergeRefs";
9
- import $aLaER$react, {createContext as $aLaER$createContext, forwardRef as $aLaER$forwardRef, useContext as $aLaER$useContext} from "react";
9
+ import $aLaER$react, {createContext as $aLaER$createContext, forwardRef as $aLaER$forwardRef, useMemo as $aLaER$useMemo, useContext as $aLaER$useContext} from "react";
10
10
  import {useToggleState as $aLaER$useToggleState} from "react-stately/useToggleState";
11
11
  import {useFocusRing as $aLaER$useFocusRing} from "react-aria/useFocusRing";
12
12
  import {useHover as $aLaER$useHover} from "react-aria/useHover";
@@ -43,7 +43,10 @@ const $7a050e53d1672c98$export$5cc1518e1ec171c = /*#__PURE__*/ (0, $aLaER$create
43
43
  const $7a050e53d1672c98$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $aLaER$forwardRef)(function Switch(props, ref) {
44
44
  let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
45
45
  [props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(otherProps, ref, $7a050e53d1672c98$export$8699e3b644d5a28a);
46
- let inputRef = (0, $aLaER$useObjectRef)((0, $aLaER$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
46
+ let inputRef = (0, $aLaER$useObjectRef)((0, $aLaER$useMemo)(()=>(0, $aLaER$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), [
47
+ userProvidedInputRef,
48
+ props.inputRef
49
+ ]));
47
50
  let state = (0, $aLaER$useToggleState)(props);
48
51
  let aria = (0, $aLaER$useSwitch)({
49
52
  ...(0, $b7b7a92703138c9b$export$ef03459518577ad4)(props),
@@ -77,7 +80,10 @@ const $7a050e53d1672c98$export$208c2e617baf9fc3 = /*#__PURE__*/ (0, $aLaER$forwa
77
80
  let { validationBehavior: formValidationBehavior } = (0, $b7b7a92703138c9b$export$fabf2dc03a41866e)((0, $c7332d4a2d191cd2$export$c24727297075ec6a)) || {};
78
81
  var _props_validationBehavior, _ref;
79
82
  let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : 'native';
80
- let inputRef = (0, $aLaER$useObjectRef)((0, $aLaER$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
83
+ let inputRef = (0, $aLaER$useObjectRef)((0, $aLaER$useMemo)(()=>(0, $aLaER$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), [
84
+ userProvidedInputRef,
85
+ props.inputRef
86
+ ]));
81
87
  let state = (0, $aLaER$useToggleState)(props);
82
88
  let aria = (0, $aLaER$useSwitch)({
83
89
  ...(0, $b7b7a92703138c9b$export$ef03459518577ad4)(props),
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwMM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAA+C;AACjF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AACzD,MAAM,yDAAqB,CAAA,GAAA,oBAAY,EAAsB;AAO7D,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAC1E,KAAkB,EAClB,GAAmC;IAEnC,IAAI,EAAC,UAAU,uBAAuB,IAAI,EAAE,GAAG,YAAW,GAAG;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,YAAY,KAAK;IAChD,IAAI,WAAW,CAAA,GAAA,mBAAW,EACxB,CAAA,G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components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;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AA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, Ref, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.js.map"}
@@ -6,7 +6,7 @@ import {useSwitch as $kf3DM$useSwitch} from "react-aria/useSwitch";
6
6
  import {filterDOMProps as $kf3DM$filterDOMProps} from "react-aria/filterDOMProps";
7
7
  import {mergeProps as $kf3DM$mergeProps} from "react-aria/mergeProps";
8
8
  import {mergeRefs as $kf3DM$mergeRefs} from "react-aria/mergeRefs";
9
- import $kf3DM$react, {createContext as $kf3DM$createContext, forwardRef as $kf3DM$forwardRef, useContext as $kf3DM$useContext} from "react";
9
+ import $kf3DM$react, {createContext as $kf3DM$createContext, forwardRef as $kf3DM$forwardRef, useMemo as $kf3DM$useMemo, useContext as $kf3DM$useContext} from "react";
10
10
  import {useToggleState as $kf3DM$useToggleState} from "react-stately/useToggleState";
11
11
  import {useFocusRing as $kf3DM$useFocusRing} from "react-aria/useFocusRing";
12
12
  import {useHover as $kf3DM$useHover} from "react-aria/useHover";
@@ -43,7 +43,10 @@ const $24585aa46d6ffdff$export$5cc1518e1ec171c = /*#__PURE__*/ (0, $kf3DM$create
43
43
  const $24585aa46d6ffdff$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $kf3DM$forwardRef)(function Switch(props, ref) {
44
44
  let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
45
45
  [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(otherProps, ref, $24585aa46d6ffdff$export$8699e3b644d5a28a);
46
- let inputRef = (0, $kf3DM$useObjectRef)((0, $kf3DM$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
46
+ let inputRef = (0, $kf3DM$useObjectRef)((0, $kf3DM$useMemo)(()=>(0, $kf3DM$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), [
47
+ userProvidedInputRef,
48
+ props.inputRef
49
+ ]));
47
50
  let state = (0, $kf3DM$useToggleState)(props);
48
51
  let aria = (0, $kf3DM$useSwitch)({
49
52
  ...(0, $7230ffa83bc0c2cf$export$ef03459518577ad4)(props),
@@ -76,7 +79,10 @@ const $24585aa46d6ffdff$export$208c2e617baf9fc3 = /*#__PURE__*/ (0, $kf3DM$forwa
76
79
  [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(otherProps, ref, $24585aa46d6ffdff$export$3e1405298f0cafda);
77
80
  let { validationBehavior: formValidationBehavior } = (0, $7230ffa83bc0c2cf$export$fabf2dc03a41866e)((0, $cdaed739b1139372$export$c24727297075ec6a)) || {};
78
81
  let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';
79
- let inputRef = (0, $kf3DM$useObjectRef)((0, $kf3DM$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
82
+ let inputRef = (0, $kf3DM$useObjectRef)((0, $kf3DM$useMemo)(()=>(0, $kf3DM$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), [
83
+ userProvidedInputRef,
84
+ props.inputRef
85
+ ]));
80
86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AO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwMM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAA+C;AACjF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AACzD,MAAM,yDAAqB,CAAA,GAAA,oBAAY,EAAsB;AAO7D,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAC1E,KAAkB,EAClB,GAAmC;IAEnC,IAAI,EAAC,UAAU,uBAAuB,IAAI,EAAE,GAAG,YAAW,GAAG;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,YAAY,KAAK;IAChD,IAAI,WAAW,CAAA,GAAA,mBAAW,EACxB,CAAA,GAAA,cAAM,EACJ,IAAM,CAAA,GAAA,gBAAQ,EAAE,sBAAsB,MAAM,QAAQ,KAAK,YAAY,MAAM,QAAQ,GAAG,OACtF;QAAC;QAAsB,MAAM,QAAQ;KAAC;IAG1C,IAAI,QAAQ,CAAA,GAAA,qBAAa,EAAE;IAC3B,IAAI,OAAO,CAAA,GAAA,gBAAQ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GAAG,CAAA,GAAA,iBAAS,EAAE;IACf,IAAI,aAAC,SAAS,kBAAE,cAAc,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,mBAAW;IACzD,IAAI,wBAAwB,cAAc;IAC1C,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE;IAEvB,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACrC,GAAG,KAAK;QACR,YAAY;IACd;IAEA,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;0BACR;QACA,QAAQ;wBACN;uBACA;uBACA;uBACA;4BACA;wBACA;wBACA;uBACA;YACA,YAAY,cAAc;mBAC1B;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, Ref, useContext, useMemo} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: Ref<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n useMemo(\n () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null),\n [userProvidedInputRef, props.inputRef]\n )\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.mjs.map"}
@@ -308,7 +308,8 @@ const $af9b3e5459f1bf61$export$7063e69b8a954175 = /*#__PURE__*/ (0, $ke19Y$react
308
308
  tableRef: tableRef,
309
309
  scrollRef: scrollRef,
310
310
  tableWidth: width,
311
- useTableColumnResizeState: $ke19Y$reactstatelyuseTableState.useTableColumnResizeState,
311
+ useTableColumnResizeState: // oxlint-disable-next-line react/react-compiler
312
+ $ke19Y$reactstatelyuseTableState.useTableColumnResizeState,
312
313
  onResizeStart: props.onResizeStart,
313
314
  onResize: props.onResize,
314
315
  onResizeEnd: props.onResizeEnd
@@ -336,6 +337,7 @@ const $af9b3e5459f1bf61$export$93e4b0b2cc49b648 = /*#__PURE__*/ (0, $ke19Y$react
336
337
  const $af9b3e5459f1bf61$export$38de1cb0526c21fb = /*#__PURE__*/ (0, $ke19Y$react.createContext)(null);
337
338
  const $af9b3e5459f1bf61$export$a2680a798823803c = /*#__PURE__*/ (0, $ke19Y$react.createContext)(null);
338
339
  const $af9b3e5459f1bf61$export$54ec01a60f47d33d = /*#__PURE__*/ (0, $ke19Y$react.forwardRef)(function Table(props, ref) {
340
+ // oxlint-disable-next-line react/react-compiler
339
341
  [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $af9b3e5459f1bf61$export$93e4b0b2cc49b648);
340
342
  // Separate selection state so we have access to it from collection components via useTableOptions.
341
343
  let selectionState = (0, $ke19Y$reactstatelyuseMultipleSelectionState.useMultipleSelectionState)(props);
@@ -387,6 +389,7 @@ const $af9b3e5459f1bf61$var$EXPANSION_KEYS = {
387
389
  }
388
390
  };
389
391
  function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, selectionState: selectionState, collection: collection }) {
392
+ // oxlint-disable-next-line react/react-compiler
390
393
  [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, (0, $433949643203e332$exports.SelectableCollectionContext));
391
394
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
392
395
  let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, filter: filter, ...DOMCollectionProps } = props;
@@ -396,6 +399,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
396
399
  tableContainerContext?.tableRef
397
400
  ]));
398
401
  let [expandedKeys, setExpandedKeys] = (0, $ke19Y$reactstatelyuseControlledState.useControlledState)(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
402
+ // oxlint-disable-next-line react/react-compiler
399
403
  collection = (0, $ke19Y$react.useMemo)(()=>collection.withExpandedKeys(expandedKeys), [
400
404
  collection,
401
405
  expandedKeys
@@ -408,6 +412,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
408
412
  expandedKeys: expandedKeys,
409
413
  onExpandedChange: setExpandedKeys
410
414
  });
415
+ // oxlint-disable-next-line react/react-compiler
411
416
  let filteredState = (0, $ke19Y$reactstatelyuseTableState.UNSTABLE_useFilteredTableState)(tableState, filter);
412
417
  let { isVirtualized: isVirtualized, layoutDelegate: layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate, CollectionRoot: CollectionRoot } = (0, $ke19Y$react.useContext)((0, $f7b82bedbb70abac$exports.CollectionRendererContext));
413
418
  let { dragAndDropHooks: dragAndDropHooks } = props;
@@ -438,11 +443,13 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
438
443
  let { direction: direction } = (0, $ke19Y$reactariaI18nProvider.useLocale)();
439
444
  let [treeDropTargetDelegate] = (0, $ke19Y$react.useState)(()=>new (0, $56f56e0916461149$exports.TreeDropTargetDelegate)());
440
445
  if (hasDragHooks && dragAndDropHooks) {
446
+ // oxlint-disable-next-line react/react-compiler
441
447
  dragState = dragAndDropHooks.useDraggableCollectionState({
442
448
  collection: filteredState.collection,
443
449
  selectionManager: selectionManager,
444
450
  preview: dragAndDropHooks.renderDragPreview ? preview : undefined
445
451
  });
452
+ // oxlint-disable-next-line react/react-compiler
446
453
  dragAndDropHooks.useDraggableCollection({}, dragState, ref);
447
454
  let DragPreview = dragAndDropHooks.DragPreview;
448
455
  dragPreview = dragAndDropHooks.renderDragPreview ? /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement(DragPreview, {
@@ -450,6 +457,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
450
457
  }, dragAndDropHooks.renderDragPreview) : null;
451
458
  }
452
459
  if (hasDropHooks && dragAndDropHooks) {
460
+ // oxlint-disable-next-line react/react-compiler
453
461
  dropState = dragAndDropHooks.useDroppableCollectionState({
454
462
  collection: filteredState.collection,
455
463
  selectionManager: selectionManager
@@ -463,6 +471,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
463
471
  });
464
472
  let dropTargetDelegate = dragAndDropHooks.dropTargetDelegate || ctxDropTargetDelegate || new dragAndDropHooks.ListDropTargetDelegate(collection.rows, ref);
465
473
  treeDropTargetDelegate.setup(dropTargetDelegate, tableState, direction);
474
+ // oxlint-disable-next-line react/react-compiler
466
475
  droppableCollection = dragAndDropHooks.useDroppableCollection({
467
476
  keyboardDelegate: keyboardDelegate,
468
477
  dropTargetDelegate: treeDropTargetDelegate,
@@ -504,6 +513,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
504
513
  let style = renderProps.style;
505
514
  let layoutState = null;
506
515
  if (tableContainerContext) {
516
+ // oxlint-disable-next-line react/react-compiler
507
517
  layoutState = tableContainerContext.useTableColumnResizeState({
508
518
  tableWidth: tableContainerContext.tableWidth
509
519
  }, filteredState);
@@ -697,7 +707,9 @@ const $af9b3e5459f1bf61$export$816b5d811295e6bc = /*#__PURE__*/ (0, $ke19Y$react
697
707
  let { isVirtualized: isVirtualized } = (0, $ke19Y$react.useContext)((0, $f7b82bedbb70abac$exports.CollectionRendererContext));
698
708
  let { columnHeaderProps: columnHeaderProps, isPressed: isPressed } = (0, $ke19Y$reactariauseTable.useTableColumnHeader)({
699
709
  node: column,
700
- isVirtualized: isVirtualized
710
+ isVirtualized: isVirtualized,
711
+ focusMode: props.focusMode,
712
+ allowsArrowNavigation: props.allowsArrowNavigation
701
713
  }, state, ref);
702
714
  let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $ke19Y$reactariauseFocusRing.useFocusRing)();
703
715
  let layoutState = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$export$a2680a798823803c);
@@ -783,7 +795,7 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
783
795
  let { onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd } = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$var$ResizableTableContainerContext);
784
796
  let { column: column, triggerRef: triggerRef } = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$var$ColumnResizerContext);
785
797
  let inputRef = (0, $ke19Y$react.useRef)(null);
786
- let { resizerProps: resizerProps, inputProps: inputProps, isResizing: isResizing } = (0, $ke19Y$reactariauseTable.useTableColumnResize)({
798
+ let { resizerProps: resizerProps, inputProps: inputProps, isResizing: isResizing, isMouseResizing: isMouseResizing } = (0, $ke19Y$reactariauseTable.useTableColumnResize)({
787
799
  column: column,
788
800
  'aria-label': props['aria-label'] || stringFormatter.format('tableResizer'),
789
801
  onResizeStart: onResizeStart,
@@ -821,20 +833,15 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
821
833
  resizableDirection: resizableDirection
822
834
  }
823
835
  });
824
- let [isMouseDown, setMouseDown] = (0, $ke19Y$react.useState)(false);
825
- let onPointerDown = (e)=>{
826
- if (e.pointerType === 'mouse') setMouseDown(true);
827
- };
828
- if (!isResizing && isMouseDown) setMouseDown(false);
829
836
  let DOMProps = (0, $ke19Y$reactariafilterDOMProps.filterDOMProps)(props, {
830
837
  global: true
831
838
  });
839
+ // Cursor overlay is used to style the cursor against the entire screen.
840
+ // Do not turn off pointer events or the cursor will no longer be styled.
832
841
  return /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
833
842
  ref: objectRef,
834
843
  role: "presentation",
835
- ...(0, $ke19Y$reactariamergeProps.mergeProps)(DOMProps, renderProps, resizerProps, {
836
- onPointerDown: onPointerDown
837
- }, hoverProps),
844
+ ...(0, $ke19Y$reactariamergeProps.mergeProps)(DOMProps, renderProps, resizerProps, hoverProps),
838
845
  "data-hovered": isHovered || undefined,
839
846
  "data-focused": isFocused || undefined,
840
847
  "data-focus-visible": isFocusVisible || undefined,
@@ -843,7 +850,7 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
843
850
  }, renderProps.children, /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("input", {
844
851
  ref: inputRef,
845
852
  ...(0, $ke19Y$reactariamergeProps.mergeProps)(inputProps, focusProps)
846
- }), isResizing && isMouseDown && /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$reactdom))).createPortal(/*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("div", {
853
+ }), isResizing && isMouseResizing && /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$reactdom))).createPortal(/*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("div", {
847
854
  style: {
848
855
  position: 'fixed',
849
856
  top: 0,
@@ -851,7 +858,8 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
851
858
  bottom: 0,
852
859
  right: 0,
853
860
  cursor: cursor
854
- }
861
+ },
862
+ "data-testid": "cursor-overlay"
855
863
  }), document.body));
856
864
  });
857
865
  class $af9b3e5459f1bf61$var$TableBodyNode extends (0, $ke19Y$reactariaprivatecollectionsBaseCollection.FilterableNode) {
@@ -1200,7 +1208,9 @@ const $af9b3e5459f1bf61$export$f6f0c3fe4ec306ea = /*#__PURE__*/ (0, $ke19Y$react
1200
1208
  let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $ke19Y$reactariauseTable.useTableCell)({
1201
1209
  node: cell,
1202
1210
  shouldSelectOnPressUp: !!dragState,
1203
- isVirtualized: isVirtualized
1211
+ isVirtualized: isVirtualized,
1212
+ focusMode: props.focusMode,
1213
+ allowsArrowNavigation: props.allowsArrowNavigation
1204
1214
  }, state, ref);
1205
1215
  let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $ke19Y$reactariauseFocusRing.useFocusRing)();
1206
1216
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $ke19Y$reactariauseHover.useHover)({});
@@ -1258,6 +1268,7 @@ function $af9b3e5459f1bf61$var$TableDropIndicatorWrapper(props, ref) {
1258
1268
  ref = (0, $ke19Y$reactariauseObjectRef.useObjectRef)(ref);
1259
1269
  let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $ke19Y$react.useContext)((0, $d3d8871226fc64f2$exports.DragAndDropContext));
1260
1270
  let buttonRef = (0, $ke19Y$react.useRef)(null);
1271
+ // oxlint-disable-next-line react/react-compiler
1261
1272
  let { dropIndicatorProps: dropIndicatorProps, isHidden: isHidden, isDropTarget: isDropTarget } = dragAndDropHooks.useDropIndicator(props, dropState, buttonRef);
1262
1273
  if (isHidden) return null;
1263
1274
  let level = dropState && props.target.type === 'item' ? (dropState.collection.getItem(props.target.key)?.level || 0) + 1 : 1;
@@ -1334,6 +1345,7 @@ function $af9b3e5459f1bf61$var$RootDropIndicator() {
1334
1345
  let state = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$export$38de1cb0526c21fb);
1335
1346
  let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $ke19Y$react.useContext)((0, $d3d8871226fc64f2$exports.DragAndDropContext));
1336
1347
  let ref = (0, $ke19Y$react.useRef)(null);
1348
+ // oxlint-disable-next-line react/react-compiler
1337
1349
  let { dropIndicatorProps: dropIndicatorProps } = dragAndDropHooks.useDropIndicator({
1338
1350
  target: {
1339
1351
  type: 'root'