@economic/taco 2.53.2 → 2.55.0-EC-64018.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 (412) hide show
  1. package/dist/charts/components/Area/AreaChart.d.ts +1 -1
  2. package/dist/charts/components/Bar/BarChart.d.ts +1 -1
  3. package/dist/charts/components/Donut/ActiveShape.d.ts +2 -2
  4. package/dist/charts/components/Donut/CenteredLabel.d.ts +2 -2
  5. package/dist/charts/components/Donut/DonutChart.d.ts +1 -1
  6. package/dist/charts/components/Donut/Legend.d.ts +1 -1
  7. package/dist/charts/components/Legend.d.ts +2 -2
  8. package/dist/charts/components/Line/LineChart.d.ts +1 -1
  9. package/dist/charts/components/ResponsiveContainer.d.ts +1 -1
  10. package/dist/charts/components/Tooltip.d.ts +2 -2
  11. package/dist/charts/utils/common.d.ts +3 -3
  12. package/dist/components/Accordion/Accordion.d.ts +2 -2
  13. package/dist/components/Alert/Alert.d.ts +1 -1
  14. package/dist/components/AlertDialog/components/Content.d.ts +1 -1
  15. package/dist/components/Calendar/Calendar.d.ts +1 -1
  16. package/dist/components/Checkbox/Checkbox.d.ts +7 -2
  17. package/dist/components/Datepicker/Datepicker.d.ts +1 -1
  18. package/dist/components/Dialog/components/Content.d.ts +1 -1
  19. package/dist/components/Dialog/components/DialogDrawer.d.ts +1 -1
  20. package/dist/components/Drawer/components/Content.d.ts +2 -2
  21. package/dist/components/Header/components/Agreement/Badge.d.ts +1 -1
  22. package/dist/components/Header/components/Agreement/Display.d.ts +2 -2
  23. package/dist/components/Header/components/Agreement/Item.d.ts +2 -2
  24. package/dist/components/Header/components/AgreementSelector.d.ts +2 -2
  25. package/dist/components/Header/components/Button.d.ts +1 -1
  26. package/dist/components/HoverCard/HoverCard.d.ts +1 -1
  27. package/dist/components/Icon/components/AccountPreview.d.ts +1 -1
  28. package/dist/components/Icon/components/Accounting.d.ts +1 -1
  29. package/dist/components/Icon/components/AccountingYear.d.ts +1 -1
  30. package/dist/components/Icon/components/AccountingYearCancel.d.ts +1 -1
  31. package/dist/components/Icon/components/AiChatSolid.d.ts +1 -1
  32. package/dist/components/Icon/components/AiStars.d.ts +1 -1
  33. package/dist/components/Icon/components/ArrowBottom.d.ts +1 -1
  34. package/dist/components/Icon/components/ArrowDown.d.ts +1 -1
  35. package/dist/components/Icon/components/ArrowEnd.d.ts +1 -1
  36. package/dist/components/Icon/components/ArrowLeft.d.ts +1 -1
  37. package/dist/components/Icon/components/ArrowRight.d.ts +1 -1
  38. package/dist/components/Icon/components/ArrowStart.d.ts +1 -1
  39. package/dist/components/Icon/components/ArrowTop.d.ts +1 -1
  40. package/dist/components/Icon/components/ArrowUp.d.ts +1 -1
  41. package/dist/components/Icon/components/Attach.d.ts +1 -1
  42. package/dist/components/Icon/components/AttachAuto.d.ts +1 -1
  43. package/dist/components/Icon/components/AttachCancel.d.ts +1 -1
  44. package/dist/components/Icon/components/AttachWarning.d.ts +1 -1
  45. package/dist/components/Icon/components/Autopay.d.ts +1 -1
  46. package/dist/components/Icon/components/AutopayPaused.d.ts +1 -1
  47. package/dist/components/Icon/components/Autotext.d.ts +1 -1
  48. package/dist/components/Icon/components/AutotextInsert.d.ts +1 -1
  49. package/dist/components/Icon/components/Basic.d.ts +1 -1
  50. package/dist/components/Icon/components/BasicTabs.d.ts +1 -1
  51. package/dist/components/Icon/components/BellSolid.d.ts +1 -1
  52. package/dist/components/Icon/components/Book.d.ts +1 -1
  53. package/dist/components/Icon/components/Booking.d.ts +1 -1
  54. package/dist/components/Icon/components/Budget.d.ts +1 -1
  55. package/dist/components/Icon/components/Calendar.d.ts +1 -1
  56. package/dist/components/Icon/components/CashAccount.d.ts +1 -1
  57. package/dist/components/Icon/components/CashReports.d.ts +1 -1
  58. package/dist/components/Icon/components/ChartArea.d.ts +1 -1
  59. package/dist/components/Icon/components/ChartBar.d.ts +1 -1
  60. package/dist/components/Icon/components/ChartLine.d.ts +1 -1
  61. package/dist/components/Icon/components/ChartPie.d.ts +1 -1
  62. package/dist/components/Icon/components/ChartTable.d.ts +1 -1
  63. package/dist/components/Icon/components/Chat.d.ts +1 -1
  64. package/dist/components/Icon/components/ChatSolid.d.ts +1 -1
  65. package/dist/components/Icon/components/ChevronDown.d.ts +1 -1
  66. package/dist/components/Icon/components/ChevronDownDouble.d.ts +1 -1
  67. package/dist/components/Icon/components/ChevronDownSolid.d.ts +1 -1
  68. package/dist/components/Icon/components/ChevronLeft.d.ts +1 -1
  69. package/dist/components/Icon/components/ChevronLeftDouble.d.ts +1 -1
  70. package/dist/components/Icon/components/ChevronLeftSolid.d.ts +1 -1
  71. package/dist/components/Icon/components/ChevronRight.d.ts +1 -1
  72. package/dist/components/Icon/components/ChevronRightDouble.d.ts +1 -1
  73. package/dist/components/Icon/components/ChevronRightSolid.d.ts +1 -1
  74. package/dist/components/Icon/components/ChevronUp.d.ts +1 -1
  75. package/dist/components/Icon/components/ChevronUpDouble.d.ts +1 -1
  76. package/dist/components/Icon/components/ChevronUpSolid.d.ts +1 -1
  77. package/dist/components/Icon/components/CircleClose.d.ts +1 -1
  78. package/dist/components/Icon/components/CircleInformation.d.ts +1 -1
  79. package/dist/components/Icon/components/CircleMinus.d.ts +1 -1
  80. package/dist/components/Icon/components/CirclePlus.d.ts +1 -1
  81. package/dist/components/Icon/components/CircleQuestionmark.d.ts +1 -1
  82. package/dist/components/Icon/components/CircleTick.d.ts +1 -1
  83. package/dist/components/Icon/components/CircleWarning.d.ts +1 -1
  84. package/dist/components/Icon/components/Clamp.d.ts +1 -1
  85. package/dist/components/Icon/components/ClampOpen.d.ts +1 -1
  86. package/dist/components/Icon/components/Close.d.ts +1 -1
  87. package/dist/components/Icon/components/ColumnFreeze.d.ts +1 -1
  88. package/dist/components/Icon/components/ColumnUnfreeze.d.ts +1 -1
  89. package/dist/components/Icon/components/Columns.d.ts +1 -1
  90. package/dist/components/Icon/components/ConnectionEnable.d.ts +1 -1
  91. package/dist/components/Icon/components/ConnectionRevoke.d.ts +1 -1
  92. package/dist/components/Icon/components/Contacts.d.ts +1 -1
  93. package/dist/components/Icon/components/Copy.d.ts +1 -1
  94. package/dist/components/Icon/components/Courses.d.ts +1 -1
  95. package/dist/components/Icon/components/Credit.d.ts +1 -1
  96. package/dist/components/Icon/components/Delete.d.ts +1 -1
  97. package/dist/components/Icon/components/DeletePermanently.d.ts +1 -1
  98. package/dist/components/Icon/components/Depecriate.d.ts +1 -1
  99. package/dist/components/Icon/components/Developer.d.ts +1 -1
  100. package/dist/components/Icon/components/DistributionTemplate.d.ts +1 -1
  101. package/dist/components/Icon/components/Document.d.ts +1 -1
  102. package/dist/components/Icon/components/DocumentApprove.d.ts +1 -1
  103. package/dist/components/Icon/components/DocumentCreateEntry.d.ts +1 -1
  104. package/dist/components/Icon/components/DocumentCut.d.ts +1 -1
  105. package/dist/components/Icon/components/DocumentError.d.ts +1 -1
  106. package/dist/components/Icon/components/DocumentIsolatePage.d.ts +1 -1
  107. package/dist/components/Icon/components/DocumentMerge.d.ts +1 -1
  108. package/dist/components/Icon/components/DocumentMove.d.ts +1 -1
  109. package/dist/components/Icon/components/DocumentPreview.d.ts +1 -1
  110. package/dist/components/Icon/components/DocumentReceived.d.ts +1 -1
  111. package/dist/components/Icon/components/DocumentRejectedRequest.d.ts +1 -1
  112. package/dist/components/Icon/components/DocumentSigned.d.ts +1 -1
  113. package/dist/components/Icon/components/DocumentSignedSolid.d.ts +1 -1
  114. package/dist/components/Icon/components/DocumentSplit.d.ts +1 -1
  115. package/dist/components/Icon/components/DocumentTime.d.ts +1 -1
  116. package/dist/components/Icon/components/Download.d.ts +1 -1
  117. package/dist/components/Icon/components/Drag.d.ts +1 -1
  118. package/dist/components/Icon/components/ECopedia.d.ts +1 -1
  119. package/dist/components/Icon/components/Edit.d.ts +1 -1
  120. package/dist/components/Icon/components/EditSimple.d.ts +1 -1
  121. package/dist/components/Icon/components/EllipsisHorizontal.d.ts +1 -1
  122. package/dist/components/Icon/components/EllipsisVertical.d.ts +1 -1
  123. package/dist/components/Icon/components/EntriesOnAccount.d.ts +1 -1
  124. package/dist/components/Icon/components/EntriesOpen.d.ts +1 -1
  125. package/dist/components/Icon/components/EntriesWarning.d.ts +1 -1
  126. package/dist/components/Icon/components/EntryTypeCustomerInvoice.d.ts +1 -1
  127. package/dist/components/Icon/components/EntryTypeCustomerPayment.d.ts +1 -1
  128. package/dist/components/Icon/components/EntryTypeJournalEntry.d.ts +1 -1
  129. package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.d.ts +1 -1
  130. package/dist/components/Icon/components/EntryTypeSupplierInvoice.d.ts +1 -1
  131. package/dist/components/Icon/components/EntryTypeSupplierPayment.d.ts +1 -1
  132. package/dist/components/Icon/components/Envelope.d.ts +1 -1
  133. package/dist/components/Icon/components/EnvelopeApproved.d.ts +1 -1
  134. package/dist/components/Icon/components/EnvelopeSolid.d.ts +1 -1
  135. package/dist/components/Icon/components/ExpandView.d.ts +1 -1
  136. package/dist/components/Icon/components/Expenses.d.ts +1 -1
  137. package/dist/components/Icon/components/Experiment.d.ts +1 -1
  138. package/dist/components/Icon/components/Export.d.ts +1 -1
  139. package/dist/components/Icon/components/ExportToExcel.d.ts +1 -1
  140. package/dist/components/Icon/components/ExportToPdf.d.ts +1 -1
  141. package/dist/components/Icon/components/EyeOff.d.ts +1 -1
  142. package/dist/components/Icon/components/EyeOn.d.ts +1 -1
  143. package/dist/components/Icon/components/Filter.d.ts +1 -1
  144. package/dist/components/Icon/components/FilterSolid.d.ts +1 -1
  145. package/dist/components/Icon/components/FontSize.d.ts +1 -1
  146. package/dist/components/Icon/components/GraphSolid.d.ts +1 -1
  147. package/dist/components/Icon/components/Hash.d.ts +1 -1
  148. package/dist/components/Icon/components/HeightExtraTall.d.ts +1 -1
  149. package/dist/components/Icon/components/HeightMedium.d.ts +1 -1
  150. package/dist/components/Icon/components/HeightShort.d.ts +1 -1
  151. package/dist/components/Icon/components/HeightTall.d.ts +1 -1
  152. package/dist/components/Icon/components/House.d.ts +1 -1
  153. package/dist/components/Icon/components/HouseSolid.d.ts +1 -1
  154. package/dist/components/Icon/components/Id.d.ts +1 -1
  155. package/dist/components/Icon/components/Images.d.ts +1 -1
  156. package/dist/components/Icon/components/Import.d.ts +1 -1
  157. package/dist/components/Icon/components/Inbox.d.ts +1 -1
  158. package/dist/components/Icon/components/InboxEinvoicing.d.ts +1 -1
  159. package/dist/components/Icon/components/InboxScanning.d.ts +1 -1
  160. package/dist/components/Icon/components/InboxSmart.d.ts +1 -1
  161. package/dist/components/Icon/components/Info.d.ts +1 -1
  162. package/dist/components/Icon/components/Inventory.d.ts +1 -1
  163. package/dist/components/Icon/components/InventoryMatrix.d.ts +1 -1
  164. package/dist/components/Icon/components/JournalPro.d.ts +1 -1
  165. package/dist/components/Icon/components/Layout.d.ts +1 -1
  166. package/dist/components/Icon/components/LayoutBoth.d.ts +1 -1
  167. package/dist/components/Icon/components/LayoutFirst.d.ts +1 -1
  168. package/dist/components/Icon/components/LayoutLast.d.ts +1 -1
  169. package/dist/components/Icon/components/LayoutNone.d.ts +1 -1
  170. package/dist/components/Icon/components/LedgerCard.d.ts +1 -1
  171. package/dist/components/Icon/components/LedgerCardCustomerReminder.d.ts +1 -1
  172. package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.d.ts +1 -1
  173. package/dist/components/Icon/components/LedgerCardObsoleteStock.d.ts +1 -1
  174. package/dist/components/Icon/components/LedgerCardOpeningEntry.d.ts +1 -1
  175. package/dist/components/Icon/components/LedgerCardReservedEntry.d.ts +1 -1
  176. package/dist/components/Icon/components/LedgerCardShrinkagePilferage.d.ts +1 -1
  177. package/dist/components/Icon/components/LedgerCardStockAdjustment.d.ts +1 -1
  178. package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.d.ts +1 -1
  179. package/dist/components/Icon/components/Lightbulb.d.ts +1 -1
  180. package/dist/components/Icon/components/Line.d.ts +1 -1
  181. package/dist/components/Icon/components/LinkExternal.d.ts +1 -1
  182. package/dist/components/Icon/components/List.d.ts +1 -1
  183. package/dist/components/Icon/components/ListBulleted.d.ts +1 -1
  184. package/dist/components/Icon/components/ListSearch.d.ts +1 -1
  185. package/dist/components/Icon/components/Location.d.ts +1 -1
  186. package/dist/components/Icon/components/Lock.d.ts +1 -1
  187. package/dist/components/Icon/components/LockOpen.d.ts +1 -1
  188. package/dist/components/Icon/components/Log.d.ts +1 -1
  189. package/dist/components/Icon/components/LogOut.d.ts +1 -1
  190. package/dist/components/Icon/components/Market.d.ts +1 -1
  191. package/dist/components/Icon/components/MastercardOs.d.ts +1 -1
  192. package/dist/components/Icon/components/MatchAmount.d.ts +1 -1
  193. package/dist/components/Icon/components/MatchEntries.d.ts +1 -1
  194. package/dist/components/Icon/components/Menu.d.ts +1 -1
  195. package/dist/components/Icon/components/Mileage.d.ts +1 -1
  196. package/dist/components/Icon/components/ModalResize.d.ts +1 -1
  197. package/dist/components/Icon/components/ModalShrink.d.ts +1 -1
  198. package/dist/components/Icon/components/More.d.ts +1 -1
  199. package/dist/components/Icon/components/MoreSolid.d.ts +1 -1
  200. package/dist/components/Icon/components/Move.d.ts +1 -1
  201. package/dist/components/Icon/components/NavigationList.d.ts +1 -1
  202. package/dist/components/Icon/components/Note.d.ts +1 -1
  203. package/dist/components/Icon/components/NoteFollowUp.d.ts +1 -1
  204. package/dist/components/Icon/components/NoteRead.d.ts +1 -1
  205. package/dist/components/Icon/components/NovemberFirst.d.ts +1 -1
  206. package/dist/components/Icon/components/Numbers.d.ts +1 -1
  207. package/dist/components/Icon/components/PartnerApi.d.ts +1 -1
  208. package/dist/components/Icon/components/PaymentPaid.d.ts +1 -1
  209. package/dist/components/Icon/components/PaymentUnpaid.d.ts +1 -1
  210. package/dist/components/Icon/components/Period.d.ts +1 -1
  211. package/dist/components/Icon/components/Person.d.ts +1 -1
  212. package/dist/components/Icon/components/PersonChange.d.ts +1 -1
  213. package/dist/components/Icon/components/PersonMinus.d.ts +1 -1
  214. package/dist/components/Icon/components/PersonPlus.d.ts +1 -1
  215. package/dist/components/Icon/components/PersonSolid.d.ts +1 -1
  216. package/dist/components/Icon/components/PersonTick.d.ts +1 -1
  217. package/dist/components/Icon/components/Phone.d.ts +1 -1
  218. package/dist/components/Icon/components/PhoneSolid.d.ts +1 -1
  219. package/dist/components/Icon/components/Play.d.ts +1 -1
  220. package/dist/components/Icon/components/PlusMinus.d.ts +1 -1
  221. package/dist/components/Icon/components/Print.d.ts +1 -1
  222. package/dist/components/Icon/components/ProcessPayment.d.ts +1 -1
  223. package/dist/components/Icon/components/ProductLedgerCard.d.ts +1 -1
  224. package/dist/components/Icon/components/Profile.d.ts +1 -1
  225. package/dist/components/Icon/components/ProjectCards.d.ts +1 -1
  226. package/dist/components/Icon/components/Projects.d.ts +1 -1
  227. package/dist/components/Icon/components/QuestionMark.d.ts +1 -1
  228. package/dist/components/Icon/components/QuestionMarkBold.d.ts +1 -1
  229. package/dist/components/Icon/components/Quicklinks.d.ts +1 -1
  230. package/dist/components/Icon/components/RatingBankruptcy.d.ts +1 -1
  231. package/dist/components/Icon/components/RatingPaymentProblems.d.ts +1 -1
  232. package/dist/components/Icon/components/Reconciled.d.ts +1 -1
  233. package/dist/components/Icon/components/Refresh.d.ts +1 -1
  234. package/dist/components/Icon/components/Report.d.ts +1 -1
  235. package/dist/components/Icon/components/ReportSolid.d.ts +1 -1
  236. package/dist/components/Icon/components/Restore.d.ts +1 -1
  237. package/dist/components/Icon/components/RotateLeft.d.ts +1 -1
  238. package/dist/components/Icon/components/RotateRight.d.ts +1 -1
  239. package/dist/components/Icon/components/Sales.d.ts +1 -1
  240. package/dist/components/Icon/components/Search.d.ts +1 -1
  241. package/dist/components/Icon/components/SearchBold.d.ts +1 -1
  242. package/dist/components/Icon/components/Secure.d.ts +1 -1
  243. package/dist/components/Icon/components/SecureTick.d.ts +1 -1
  244. package/dist/components/Icon/components/Settings.d.ts +1 -1
  245. package/dist/components/Icon/components/SettingsSolid.d.ts +1 -1
  246. package/dist/components/Icon/components/Shortcuts.d.ts +1 -1
  247. package/dist/components/Icon/components/ShowAll.d.ts +1 -1
  248. package/dist/components/Icon/components/ShowLess.d.ts +1 -1
  249. package/dist/components/Icon/components/ShowMore.d.ts +1 -1
  250. package/dist/components/Icon/components/ShowTemplate.d.ts +1 -1
  251. package/dist/components/Icon/components/Sliders.d.ts +1 -1
  252. package/dist/components/Icon/components/Smartpay.d.ts +1 -1
  253. package/dist/components/Icon/components/SortBy.d.ts +1 -1
  254. package/dist/components/Icon/components/Star.d.ts +1 -1
  255. package/dist/components/Icon/components/StarSolid.d.ts +1 -1
  256. package/dist/components/Icon/components/Subscriptions.d.ts +1 -1
  257. package/dist/components/Icon/components/SystemEntries.d.ts +1 -1
  258. package/dist/components/Icon/components/Tag.d.ts +1 -1
  259. package/dist/components/Icon/components/TemplateOverride.d.ts +1 -1
  260. package/dist/components/Icon/components/Templates.d.ts +1 -1
  261. package/dist/components/Icon/components/ThumbBoth.d.ts +1 -1
  262. package/dist/components/Icon/components/ThumbDown.d.ts +1 -1
  263. package/dist/components/Icon/components/ThumbDownSolid.d.ts +1 -1
  264. package/dist/components/Icon/components/ThumbUp.d.ts +1 -1
  265. package/dist/components/Icon/components/ThumbUpSolid.d.ts +1 -1
  266. package/dist/components/Icon/components/Tick.d.ts +1 -1
  267. package/dist/components/Icon/components/TickBold.d.ts +1 -1
  268. package/dist/components/Icon/components/Time.d.ts +1 -1
  269. package/dist/components/Icon/components/Transfer.d.ts +1 -1
  270. package/dist/components/Icon/components/TransferCancel.d.ts +1 -1
  271. package/dist/components/Icon/components/TransferLocked.d.ts +1 -1
  272. package/dist/components/Icon/components/Undo.d.ts +1 -1
  273. package/dist/components/Icon/components/Undock.d.ts +1 -1
  274. package/dist/components/Icon/components/Unreconciled.d.ts +1 -1
  275. package/dist/components/Icon/components/Wallet.d.ts +1 -1
  276. package/dist/components/Icon/components/Warning.d.ts +1 -1
  277. package/dist/components/Icon/components/Webshop.d.ts +1 -1
  278. package/dist/components/Icon/components/Website.d.ts +1 -1
  279. package/dist/components/Icon/components/Workflow.d.ts +1 -1
  280. package/dist/components/Icon/components/WorkflowTemplateBasic.d.ts +1 -1
  281. package/dist/components/Icon/components/Zoom.d.ts +1 -1
  282. package/dist/components/IconButton/IconButton.d.ts +2 -2
  283. package/dist/components/Input/Input.d.ts +2 -2
  284. package/dist/components/Layout/components/Sidebar.d.ts +14 -2
  285. package/dist/components/Layout/components/Top.d.ts +4 -4
  286. package/dist/components/List/List.d.ts +7 -7
  287. package/dist/components/List/components/Button.d.ts +1 -1
  288. package/dist/components/List/components/Collapsible.d.ts +1 -1
  289. package/dist/components/List/components/Group.d.ts +1 -1
  290. package/dist/components/List/components/Item.d.ts +1 -1
  291. package/dist/components/List/components/Link.d.ts +1 -1
  292. package/dist/components/List/components/Toggle.d.ts +2 -2
  293. package/dist/components/Listbox/Listbox.d.ts +2 -2
  294. package/dist/components/Listbox/ScrollableList.d.ts +1 -1
  295. package/dist/components/Listbox/util.d.ts +2 -2
  296. package/dist/components/Menu/components/Checkbox.d.ts +1 -1
  297. package/dist/components/Menu/components/Content.d.ts +2 -2
  298. package/dist/components/Menu/components/Item.d.ts +2 -2
  299. package/dist/components/Menu/components/Link.d.ts +1 -1
  300. package/dist/components/Menu/components/RadioGroup.d.ts +1 -1
  301. package/dist/components/Menu/components/SubMenu.d.ts +1 -1
  302. package/dist/components/Menu/components/Trigger.d.ts +1 -1
  303. package/dist/components/ModeSwitch/ModeSwitch.d.ts +6 -3
  304. package/dist/components/Navigation2/components/Group.d.ts +1 -1
  305. package/dist/components/Report/Report.d.ts +3 -1
  306. package/dist/components/ScrollArea/ScrollArea.d.ts +2 -2
  307. package/dist/components/SearchInput/SearchInput.d.ts +1 -1
  308. package/dist/components/Select/Select.d.ts +1 -1
  309. package/dist/components/Select2/components/All.d.ts +2 -2
  310. package/dist/components/Select2/components/Collection.d.ts +1 -1
  311. package/dist/components/Select2/components/Create.d.ts +1 -1
  312. package/dist/components/Select2/components/Edit.d.ts +2 -2
  313. package/dist/components/Select2/components/Group.d.ts +1 -1
  314. package/dist/components/Select2/components/Option.d.ts +1 -1
  315. package/dist/components/Select2/components/Search.d.ts +3 -3
  316. package/dist/components/Select2/components/Trigger.d.ts +1 -1
  317. package/dist/components/Select2/hooks/useChildren.d.ts +2 -2
  318. package/dist/components/Shortcut/Shortcut.d.ts +1 -1
  319. package/dist/components/Switch/Switch.d.ts +6 -4
  320. package/dist/components/Table3/Table3.d.ts +3 -4
  321. package/dist/components/Table3/components/Columns/Cell/Cell.d.ts +2 -2
  322. package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.d.ts +1 -1
  323. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.d.ts +2 -2
  324. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
  325. package/dist/components/Table3/components/Editing/Alert.d.ts +1 -1
  326. package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +2 -2
  327. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +1 -1
  328. package/dist/components/Table3/components/Row/Editing/SaveStatus.d.ts +2 -2
  329. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +1 -1
  330. package/dist/components/Table3/components/Row/Row.d.ts +2 -2
  331. package/dist/components/Table3/components/Toolbar/Editing/Editing.d.ts +1 -1
  332. package/dist/components/Tag/Tag.d.ts +2 -2
  333. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  334. package/dist/components/Tour/Tour.d.ts +1 -1
  335. package/dist/components/Truncate/Truncate.d.ts +1 -1
  336. package/dist/esm/index.css +76 -5
  337. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +41 -63
  338. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  339. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +9 -6
  340. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  341. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
  342. package/dist/esm/packages/taco/src/components/Layout/components/Top.js +2 -2
  343. package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -1
  344. package/dist/esm/packages/taco/src/components/List/components/Toggle.js +14 -4
  345. package/dist/esm/packages/taco/src/components/List/components/Toggle.js.map +1 -1
  346. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +6 -3
  347. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
  348. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +34 -12
  349. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  350. package/dist/esm/packages/taco/src/components/Report/Report.js +2 -3
  351. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  352. package/dist/esm/packages/taco/src/components/Switch/Switch.js +37 -35
  353. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  354. package/dist/esm/packages/taco/src/components/Table3/Table3.js +1 -3
  355. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  356. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +4 -2
  357. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  358. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  359. package/dist/esm/packages/taco/src/components/Toast/Toast.js.map +1 -1
  360. package/dist/esm/packages/taco/src/components/Tour/Tour.js +1 -1
  361. package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
  362. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js +2 -0
  363. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js.map +1 -1
  364. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +1 -0
  365. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  366. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
  367. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js +2 -2
  368. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -1
  369. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -3
  370. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
  371. package/dist/esm/packages/taco/src/utils/dom.js +3 -2
  372. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  373. package/dist/index.css +76 -5
  374. package/dist/primitives/BubbleSelect.d.ts +1 -1
  375. package/dist/primitives/Sortable/components/Container.d.ts +2 -2
  376. package/dist/primitives/Sortable/components/Item.d.ts +1 -1
  377. package/dist/primitives/Sortable/components/List.d.ts +1 -1
  378. package/dist/primitives/Table/Core/Table.d.ts +2 -2
  379. package/dist/primitives/Table/Core/components/Body/Body.d.ts +1 -1
  380. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -1
  381. package/dist/primitives/Table/Core/components/Body/util.d.ts +4 -4
  382. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.d.ts +2 -2
  383. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.d.ts +2 -2
  384. package/dist/primitives/Table/Core/components/Columns/Cell/Cell.d.ts +1 -1
  385. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +2 -2
  386. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  387. package/dist/primitives/Table/Core/components/Footer/Summary.d.ts +2 -2
  388. package/dist/primitives/Table/Core/components/Header/Header.d.ts +1 -1
  389. package/dist/primitives/Table/Core/components/Header/components/Goto.d.ts +2 -2
  390. package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -1
  391. package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +2 -2
  392. package/dist/primitives/Table/Core/components/Header/components/SortIndicator.d.ts +1 -1
  393. package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
  394. package/dist/primitives/Table/Core/components/Row/Row.d.ts +1 -1
  395. package/dist/primitives/Table/Core/components/Toolbar/Toolbar.d.ts +1 -1
  396. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.d.ts +2 -2
  397. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.d.ts +2 -2
  398. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
  399. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
  400. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.d.ts +2 -2
  401. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.d.ts +2 -2
  402. package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.d.ts +1 -1
  403. package/dist/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.d.ts +2 -2
  404. package/dist/primitives/Table/Core/components/Toolbar/components/Search/Search.d.ts +1 -1
  405. package/dist/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.d.ts +2 -2
  406. package/dist/primitives/Table/Core/components/Toolbar/components/Settings/Settings.d.ts +2 -2
  407. package/dist/taco.cjs.development.js +162 -143
  408. package/dist/taco.cjs.development.js.map +1 -1
  409. package/dist/taco.cjs.production.min.js +1 -1
  410. package/dist/taco.cjs.production.min.js.map +1 -1
  411. package/dist/utils/dom.d.ts +2 -2
  412. package/package.json +27 -28
@@ -1 +1 @@
1
- {"version":3,"file":"useCombobox.js","sources":["../../../../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\nimport { InputProps } from '../Input/Input';\nimport { isElementInsideTable3OrReport } from '../../utils/dom';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<InputProps, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (listRef.current && event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n // event.target.value is always a string so it is important to cast value to a string before checking the equality\n if (onChange && event.target.value !== String(value)) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (!event.ctrlKey && !event.metaKey) {\n switch (event.key) {\n case 'Backspace': {\n return;\n }\n\n case 'Escape': {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case 'Tab': {\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case 'Enter': {\n event.preventDefault();\n\n if (isElementInsideTable3OrReport(event.currentTarget)) {\n if (inline && !open) {\n setOpen(true);\n } else if (buttonRef.current && !open) {\n buttonRef.current.click();\n }\n }\n\n if (open) {\n setCurrentValue(currentIndex);\n setOpen(false);\n }\n\n return;\n }\n\n case 'ArrowDown':\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current && !isElementInsideTable3OrReport(event.currentTarget)) {\n buttonRef.current.click();\n }\n }\n break;\n\n case 'ArrowUp':\n case 'Home':\n case 'End': {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n !isElementInsideTable3OrReport(event.currentTarget)\n ) {\n event.preventDefault();\n const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ariaLabel","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","id","nativeId","inline","loading","__","onChange","onClick","onKeyDown","onSearch","readOnly","props","ref","inputRef","useMergedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","currentIndex","setCurrentIndex","undefined","getIndexFromValue","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","ctrlKey","metaKey","key","isElementInsideTable3OrReport","currentTarget","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;;AAmBA,MAAMA,SAAS,gBAAGC,QAAQ,CAACC,CAAC,IAAIA,CAAC,EAAE,EAAE,GAAG,CAAC;AAEzC,MAAMC,mBAAmB,GAAIC,KAA0C,IAAKC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;MAUlFE,WAAW,GAAGA,CACvB;EACI,YAAY,EAAEC,SAAS;EACvB,iBAAiB,EAAEC,cAAc;EACjCC,IAAI,EAAEC,cAAc,GAAG,EAAE;EACzBC,YAAY;EACZC,QAAQ;EACRC,EAAE,EAAEC,QAAQ;EACZC,MAAM;EACNC,OAAO,EAAEC,EAAE;EACXC,QAAQ;EACRC,OAAO;EACPC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRlB,KAAK;EACL,GAAGmB;CACyB,EAChCC,GAAgC;EAEhC,MAAMC,QAAQ,GAAGC,YAAY,CAAmBF,GAAG,CAAC;EACpD,MAAMG,SAAS,GAAGC,MAAY,CAAoB,IAAI,CAAC;EACvD,MAAMC,OAAO,GAAGD,MAAY,CAAmB,IAAI,CAAC;EACpD,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGH,QAAc,CAAC,KAAK,CAAC;EAC7C,MAAMI,MAAM,GAAGJ,OAAa,CAAC,MAAMK,EAAI,EAAE,EAAE,EAAE,CAAC;EAC9C,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAc,CAASzB,mBAAmB,CAACC,KAAK,CAAC,CAAC;EACtF,MAAMgC,gBAAgB,GA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AG4C,iBAAiB,GAAGxB,SAAS;IAChEvB,OAAO,EAAE,CAACP,QAAQ,IAAI,CAACU,QAAQ,GAAG6C,gBAAgB,GAAGzB,SAAS;IAC9DtB,SAAS,EAAE,CAACR,QAAQ,IAAI,CAACU,QAAQ,GAAG8C,kBAAkB,GAAG1B,SAAS;IAClEpB,QAAQ;IACRE,GAAG,EAAEC,QAAQ;IACb4D,IAAI,EAAE,MAAM;IACZjF,KAAK,EAAE8B,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI;GACxB;EAED,MAAMoD,IAAI,GAA+B;IACrC,iBAAiB,EAAE9E,cAAc;IACjCC,IAAI;IACJG,QAAQ;IACRC,EAAE,EAAEmB,MAAM;IACVd,QAAQ,EAAE6D,mBAAmB;IAC7B5D,OAAO,EAAE6D,kBAAkB;IAC3BxD,GAAG,EAAEK,OAAO;IACZ0D,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,CAAC,CAAC;IACZpF,KAAK,EAAEoC;GACV;EAED,MAAMiD,MAAM,GAAG;IACXjE,GAAG,EAAEG;GACR;EAED,OAAO;IACHsD,QAAQ;IACRE,KAAK;IACLG,IAAI;IACJG,MAAM;IACNC,OAAO,EAAE;MACL5D,IAAI;MACJ6D,YAAY,EAAE5D;;GAGrB;AACL;;;;"}
1
+ {"version":3,"file":"useCombobox.js","sources":["../../../../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\nimport { InputProps } from '../Input/Input';\nimport { isElementInsideTable3OrReport } from '../../utils/dom';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<InputProps, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined, event?: string): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n const eventType = event ?? 'focusout';\n setInputValueByRef(inputRef.current, option.value, eventType);\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined, event?: string) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index, event);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (listRef.current && event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n // event.target.value is always a string so it is important to cast value to a string before checking the equality\n if (onChange && event.target.value !== String(value)) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (!event.ctrlKey && !event.metaKey) {\n switch (event.key) {\n case 'Backspace': {\n return;\n }\n\n case 'Escape': {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case 'Tab': {\n // default focusout will trigger onBlur and we don't want to trigger it twice\n setCurrentValue(currentIndex, 'change');\n setOpen(false);\n return;\n }\n\n case 'Enter': {\n event.preventDefault();\n\n if (isElementInsideTable3OrReport(event.currentTarget)) {\n if (inline && !open) {\n setOpen(true);\n } else if (buttonRef.current && !open) {\n buttonRef.current.click();\n }\n }\n\n if (open) {\n // we need to focusout to trigger onBlur as we are not actually blurring the input\n setCurrentValue(currentIndex, 'focusout');\n setOpen(false);\n }\n\n return;\n }\n\n case 'ArrowDown':\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current && !isElementInsideTable3OrReport(event.currentTarget)) {\n buttonRef.current.click();\n }\n }\n break;\n\n case 'ArrowUp':\n case 'Home':\n case 'End': {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n !isElementInsideTable3OrReport(event.currentTarget)\n ) {\n event.preventDefault();\n const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ariaLabel","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","id","nativeId","inline","loading","__","onChange","onClick","onKeyDown","onSearch","readOnly","props","ref","inputRef","useMergedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","currentIndex","setCurrentIndex","undefined","getIndexFromValue","setInputValueByIndex","index","event","option","eventType","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","ctrlKey","metaKey","key","isElementInsideTable3OrReport","currentTarget","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;;AAmBA,MAAMA,SAAS,gBAAGC,QAAQ,CAACC,CAAC,IAAIA,CAAC,EAAE,EAAE,GAAG,CAAC;AAEzC,MAAMC,mBAAmB,GAAIC,KAA0C,IAAKC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;MAUlFE,WAAW,GAAGA,CACvB;EACI,YAAY,EAAEC,SAAS;EACvB,iBAAiB,EAAEC,cAAc;EACjCC,IAAI,EAAEC,cAAc,GAAG,EAAE;EACzBC,YAAY;EACZC,QAAQ;EACRC,EAAE,EAAEC,QAAQ;EACZC,MAAM;EACNC,OAAO,EAAEC,EAAE;EACXC,QAAQ;EACRC,OAAO;EACPC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRlB,KAAK;EACL,GAAGmB;CACyB,EAChCC,GAAgC;EAEhC,MAAMC,QAAQ,GAAGC,YAAY,CAAmBF,GAAG,CAAC;EACpD,MAAMG,SAAS,GAAGC,MAAY,CAAoB,IAAI,CAAC;EACvD,MAAMC,OAAO,GAAGD,MAAY,CAAmB,IAAI,CAAC;EACpD,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGH,QAAc,CAAC,KAAK,CAAC;EAC7C,MAAMI,MAAM,GAAGJ,OAAa,CAAC,MAAMK,EAAI,EAAE,EAAE,EAAE,CAAC;EAC9C,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAc,CAASzB,mBAAmB,CAACC,KAAK,CAAC,CAAC;EACtF,MAAMgC,gBAAgB,GAAG,CAACf,QAAQ,KAAK,CAACN,M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,MAAM,EAAE,CAACtD,QAAQ,IAAI,CAACU,QAAQ,GAAGgC,eAAe,GAAGZ,SAAS;IAC5DxB,QAAQ,EAAE,CAACN,QAAQ,IAAI,CAACU,QAAQ,GAAG6C,iBAAiB,GAAGzB,SAAS;IAChEvB,OAAO,EAAE,CAACP,QAAQ,IAAI,CAACU,QAAQ,GAAG8C,gBAAgB,GAAG1B,SAAS;IAC9DtB,SAAS,EAAE,CAACR,QAAQ,IAAI,CAACU,QAAQ,GAAG+C,kBAAkB,GAAG3B,SAAS;IAClEpB,QAAQ;IACRE,GAAG,EAAEC,QAAQ;IACb6D,IAAI,EAAE,MAAM;IACZlF,KAAK,EAAE8B,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI;GACxB;EAED,MAAMqD,IAAI,GAA+B;IACrC,iBAAiB,EAAE/E,cAAc;IACjCC,IAAI;IACJG,QAAQ;IACRC,EAAE,EAAEmB,MAAM;IACVd,QAAQ,EAAE8D,mBAAmB;IAC7B7D,OAAO,EAAE8D,kBAAkB;IAC3BzD,GAAG,EAAEK,OAAO;IACZ2D,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,CAAC,CAAC;IACZrF,KAAK,EAAEoC;GACV;EAED,MAAMkD,MAAM,GAAG;IACXlE,GAAG,EAAEG;GACR;EAED,OAAO;IACHuD,QAAQ;IACRE,KAAK;IACLG,IAAI;IACJG,MAAM;IACNC,OAAO,EAAE;MACL7D,IAAI;MACJ8D,YAAY,EAAE7D;;GAGrB;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { LayoutContext } from './Context';\nimport { useIsLargeScreen } from '../../../hooks/useIsLargeScreen';\nimport { Backdrop, BackdropProps } from '../../Backdrop/Backdrop';\n\nconst SidebarBackdrop = motion<BackdropProps>(Backdrop);\n\nexport type LayoutSidebarProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, LayoutSidebarProps>(function LayoutSidebar(props, ref) {\n const { children, ...attributes } = props;\n const { sidebarOpen, setSidebarOpen } = React.useContext(LayoutContext);\n const isLargeScreen = useIsLargeScreen();\n const isSmallScreen = !isLargeScreen;\n\n // if it's a large screen we override the open state and make it always visible\n const isVisible = isLargeScreen || sidebarOpen;\n\n // ensures the menu is always closed by default when resizing to a smaller window size\n React.useEffect(() => {\n setSidebarOpen(isLargeScreen);\n }, [isLargeScreen]);\n\n React.useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setSidebarOpen(false);\n }\n };\n\n if (isSmallScreen && sidebarOpen) {\n window.addEventListener('keydown', handleEscapeKey);\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isSmallScreen, sidebarOpen]);\n\n const showBackdrop = isSmallScreen && sidebarOpen === true;\n\n const [ready, setReady] = React.useState(isSmallScreen);\n\n const className = cn(\n 'bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0 print:hidden',\n {\n 'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,\n // prevent animation when crossing the boundary from large to small screen,\n // this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)\n invisible: isSmallScreen && !ready,\n 'transition-[transform] duration-300 visible': isSmallScreen && ready,\n 'border-r-2 border-black/[.08] ': !showBackdrop,\n },\n props.className\n );\n\n React.useEffect(() => {\n // ensure state is updated in the next cpu tick so that the animation definitely doesn't run\n setTimeout(() => {\n setReady(isSmallScreen);\n }, 1);\n }, [isSmallScreen]);\n\n const toggleSidebar = () => setSidebarOpen(open => !open);\n const content = typeof children === 'function' ? children({ isLargeScreen, open: sidebarOpen, toggleSidebar }) : children;\n\n if (!content) {\n return null;\n }\n\n return (\n <>\n <nav {...attributes} data-responsive={isSmallScreen} aria-hidden={!isVisible} className={className} ref={ref}>\n {content}\n </nav>\n <AnimatePresence>\n {showBackdrop && (\n <SidebarBackdrop\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"z-[1]\"\n onClick={() => setSidebarOpen(false)}\n />\n )}\n </AnimatePresence>\n </>\n );\n});\n"],"names":["SidebarBackdrop","motion","Backdrop","Sidebar","React","forwardRef","LayoutSidebar","props","ref","children","attributes","sidebarOpen","setSidebarOpen","useContext","LayoutContext","isLargeScreen","useIsLargeScreen","isSmallScreen","isVisible","useEffect","handleEscapeKey","event","key","preventDefault","stopPropagation","window","addEventListener","removeEventListener","showBackdrop","ready","setReady","useState","className","cn","invisible","setTimeout","toggleSidebar","open","content","AnimatePresence","initial","opacity","animate","exit","onClick"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,MAAM,CAAgBC,QAAQ,CAAC;MAI1CC,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EACzG,MAAM;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACzC,MAAM;IAAEI,WAAW;IAAEC;GAAgB,GAAGR,cAAK,CAACS,UAAU,CAACC,aAAa,CAAC;EACvE,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;EACxC,MAAMC,aAAa,GAAG,CAACF,aAAa;;EAGpC,MAAMG,SAAS,GAAGH,aAAa,IAAIJ,WAAW;;EAG9CP,cAAK,CAACe,SAAS,CAAC;IACZP,cAAc,CAACG,aAAa,CAAC;GAChC,EAAE,CAACA,aAAa,CAAC,CAAC;EAEnBX,cAAK,CAACe,SAAS,CAAC;IACZ,MAAMC,eAAe,GAAIC,KAAoB;MACzC,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;QACxBD,KAAK,CAACE,cAAc,EAAE;QACtBF,KAAK,CAACG,eAAe,EAAE;QACvBZ,cAAc,CAAC,KAAK,CAAC;;KAE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6BAACJ,eAAe;IACZwC,OAAO,EAAE;MAAEC,OAAO,EAAE;KAAG;IACvBC,OAAO,EAAE;MAAED,OAAO,EAAE;KAAG;IACvBE,IAAI,EAAE;MAAEF,OAAO,EAAE;KAAG;IACpBT,SAAS,EAAC,OAAO;IACjBY,OAAO,EAAEA,MAAMhC,cAAc,CAAC,KAAK;IACrC,CACL,CACa,CACnB;AAEX,CAAC;;;;"}
1
+ {"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { LayoutContext } from './Context';\nimport { useIsLargeScreen } from '../../../hooks/useIsLargeScreen';\nimport { Backdrop, BackdropProps } from '../../Backdrop/Backdrop';\n\nconst SidebarBackdrop = motion<BackdropProps>(Backdrop);\n\nexport type LayoutSidebarProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n children:\n | React.ReactNode\n | (({\n isLargeScreen,\n open,\n toggleSidebar,\n }: {\n isLargeScreen: boolean;\n open: boolean;\n toggleSidebar: () => void;\n }) => React.ReactNode);\n};\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, LayoutSidebarProps>(function LayoutSidebar(props, ref) {\n const { children, ...attributes } = props;\n const { sidebarOpen, setSidebarOpen } = React.useContext(LayoutContext);\n const isLargeScreen = useIsLargeScreen();\n const isSmallScreen = !isLargeScreen;\n\n // if it's a large screen we override the open state and make it always visible\n const isVisible = isLargeScreen || sidebarOpen;\n\n // ensures the menu is always closed by default when resizing to a smaller window size\n React.useEffect(() => {\n setSidebarOpen(isLargeScreen);\n }, [isLargeScreen]);\n\n React.useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setSidebarOpen(false);\n }\n };\n\n if (isSmallScreen && sidebarOpen) {\n window.addEventListener('keydown', handleEscapeKey);\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isSmallScreen, sidebarOpen]);\n\n const showBackdrop = isSmallScreen && sidebarOpen === true;\n\n const [ready, setReady] = React.useState(isSmallScreen);\n\n const className = cn(\n 'bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0 print:hidden',\n {\n 'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,\n // prevent animation when crossing the boundary from large to small screen,\n // this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)\n invisible: isSmallScreen && !ready,\n 'transition-[transform] duration-300 visible': isSmallScreen && ready,\n 'border-r-2 border-black/[.08] ': !showBackdrop,\n },\n props.className\n );\n\n React.useEffect(() => {\n // ensure state is updated in the next cpu tick so that the animation definitely doesn't run\n setTimeout(() => {\n setReady(isSmallScreen);\n }, 1);\n }, [isSmallScreen]);\n\n const toggleSidebar = () => setSidebarOpen(open => !open);\n const content = typeof children === 'function' ? children({ isLargeScreen, open: sidebarOpen, toggleSidebar }) : children;\n\n if (!content) {\n return null;\n }\n\n return (\n <>\n <nav {...attributes} data-responsive={isSmallScreen} aria-hidden={!isVisible} className={className} ref={ref}>\n {content}\n </nav>\n <AnimatePresence>\n {showBackdrop && (\n <SidebarBackdrop\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"z-[1]\"\n onClick={() => setSidebarOpen(false)}\n />\n )}\n </AnimatePresence>\n </>\n );\n});\n"],"names":["SidebarBackdrop","motion","Backdrop","Sidebar","React","forwardRef","LayoutSidebar","props","ref","children","attributes","sidebarOpen","setSidebarOpen","useContext","LayoutContext","isLargeScreen","useIsLargeScreen","isSmallScreen","isVisible","useEffect","handleEscapeKey","event","key","preventDefault","stopPropagation","window","addEventListener","removeEventListener","showBackdrop","ready","setReady","useState","className","cn","invisible","setTimeout","toggleSidebar","open","content","AnimatePresence","initial","opacity","animate","exit","onClick"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,MAAM,CAAgBC,QAAQ,CAA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AAK;IACrE,gCAAgC,EAAE,CAACD;GACtC,EACDrB,KAAK,CAACyB,SAAS,CAClB;EAED5B,cAAK,CAACe,SAAS,CAAC;;IAEZgB,UAAU,CAAC;MACPL,QAAQ,CAACb,aAAa,CAAC;KAC1B,EAAE,CAAC,CAAC;GACR,EAAE,CAACA,aAAa,CAAC,CAAC;EAEnB,MAAMmB,aAAa,GAAGA,MAAMxB,cAAc,CAACyB,IAAI,IAAI,CAACA,IAAI,CAAC;EACzD,MAAMC,OAAO,GAAG,OAAO7B,QAAQ,KAAK,UAAU,GAAGA,QAAQ,CAAC;IAAEM,aAAa;IAAEsB,IAAI,EAAE1B,WAAW;IAAEyB;GAAe,CAAC,GAAG3B,QAAQ;EAEzH,IAAI,CAAC6B,OAAO,EAAE;IACV,OAAO,IAAI;;EAGf,oBACIlC,yEACIA,sDAASM,UAAU;uBAAmBO,aAAa;mBAAe,CAACC,SAAS;IAAEc,SAAS,EAAEA,SAAS;IAAExB,GAAG,EAAEA;MACpG8B,OAAO,CACN,eACNlC,6BAACmC,eAAe,QACXX,YAAY,kBACTxB,6BAACJ,eAAe;IACZwC,OAAO,EAAE;MAAEC,OAAO,EAAE;KAAG;IACvBC,OAAO,EAAE;MAAED,OAAO,EAAE;KAAG;IACvBE,IAAI,EAAE;MAAEF,OAAO,EAAE;KAAG;IACpBT,SAAS,EAAC,OAAO;IACjBY,OAAO,EAAEA,MAAMhC,cAAc,CAAC,KAAK;IACrC,CACL,CACa,CACnB;AAEX,CAAC;;;;"}
@@ -6,9 +6,9 @@ const Top = props => {
6
6
  setSidebarOpen
7
7
  } = React__default.useContext(LayoutContext);
8
8
  const toggleSidebar = () => setSidebarOpen(open => !open);
9
- return typeof props.children === 'function' ? props.children({
9
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof props.children === 'function' ? props.children({
10
10
  toggleSidebar
11
- }) : props.children;
11
+ }) : props.children);
12
12
  };
13
13
 
14
14
  export { Top };
@@ -1 +1 @@
1
- {"version":3,"file":"Top.js","sources":["../../../../../../../../src/components/Layout/components/Top.tsx"],"sourcesContent":["import React from 'react';\nimport { LayoutContext } from './Context';\n\nexport type LayoutTopProps = {\n children: React.ReactNode | React.ReactNode[] | (({ toggleSidebar }) => React.ReactNode | React.ReactNode[]);\n};\n\nexport const Top = (props: LayoutTopProps) => {\n const { setSidebarOpen } = React.useContext(LayoutContext);\n const toggleSidebar = () => setSidebarOpen(open => !open);\n\n return typeof props.children === 'function' ? props.children({ toggleSidebar }) : props.children;\n};\n"],"names":["Top","props","setSidebarOpen","React","useContext","LayoutContext","toggleSidebar","open","children"],"mappings":";;;MAOaA,GAAG,GAAIC,KAAqB;EACrC,MAAM;IAAEC;GAAgB,GAAGC,cAAK,CAACC,UAAU,CAACC,aAAa,CAAC;EAC1D,MAAMC,aAAa,GAAGA,MAAMJ,cAAc,CAACK,IAAI,IAAI,CAACA,IAAI,CAAC;EAEzD,OAAO,OAAON,KAAK,CAACO,QAAQ,KAAK,UAAU,GAAGP,KAAK,CAACO,QAAQ,CAAC;IAAEF;GAAe,CAAC,GAAGL,KAAK,CAACO,QAAQ;AACpG;;;;"}
1
+ {"version":3,"file":"Top.js","sources":["../../../../../../../../src/components/Layout/components/Top.tsx"],"sourcesContent":["import React from 'react';\nimport { LayoutContext } from './Context';\n\nexport type LayoutTopProps = {\n children: React.ReactNode | (({ toggleSidebar }: { toggleSidebar: () => void }) => React.ReactNode);\n};\n\nexport const Top = (props: LayoutTopProps) => {\n const { setSidebarOpen } = React.useContext(LayoutContext);\n const toggleSidebar = () => setSidebarOpen(open => !open);\n\n return <>{typeof props.children === 'function' ? props.children({ toggleSidebar }) : props.children}</>;\n};\n"],"names":["Top","props","setSidebarOpen","React","useContext","LayoutContext","toggleSidebar","open","children"],"mappings":";;;MAOaA,GAAG,GAAIC,KAAqB;EACrC,MAAM;IAAEC;GAAgB,GAAGC,cAAK,CAACC,UAAU,CAACC,aAAa,CAAC;EAC1D,MAAMC,aAAa,GAAGA,MAAMJ,cAAc,CAACK,IAAI,IAAI,CAACA,IAAI,CAAC;EAEzD,oBAAOJ,4DAAG,OAAOF,KAAK,CAACO,QAAQ,KAAK,UAAU,GAAGP,KAAK,CAACO,QAAQ,CAAC;IAAEF;GAAe,CAAC,GAAGL,KAAK,CAACO,QAAQ,CAAI;AAC3G;;;;"}
@@ -58,13 +58,18 @@ const Switch = /*#__PURE__*/React__default.forwardRef(function Switch(props, ref
58
58
  setChecked(!checked);
59
59
  onChange(!checked);
60
60
  }, [checked, onChange]);
61
+ const controlClassName = cn(
62
+ // When ToggleItem is hovered
63
+ 'group-hover/toggle:bg-grey-700',
64
+ // When ToggleItem is hovered and switch inside it is selected
65
+ 'group-hover/toggle:group-data-[selected]:bg-blue-700');
61
66
  const control = /*#__PURE__*/React__default.createElement(Switch$1, {
62
67
  checked: checked,
63
- className: "group-hover/toggle:[&[aria-checked=false]]:bg-grey-700 group-hover/toggle:[&[aria-checked=true]]:bg-blue-700",
68
+ className: controlClassName,
64
69
  disabled: props.disabled,
65
70
  onChange: toggle,
66
71
  ref: switchRef,
67
- tabIndex: -1
72
+ excludeFromTabOrder: true
68
73
  });
69
74
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
70
75
  control: control,
@@ -85,13 +90,18 @@ const Checkbox = /*#__PURE__*/React__default.forwardRef(function Switch(props, r
85
90
  setChecked(!checked);
86
91
  onChange(!checked);
87
92
  }, [checked, onChange]);
93
+ const controlClassName = cn(
94
+ // When ToggleItem is hovered
95
+ 'group-hover/toggle:border-grey-700',
96
+ // When ToggleItem is hovered and checkbox inside it is selected
97
+ 'group-hover/toggle:group-data-[selected]:border-blue-700 group-hover/toggle:group-data-[selected]:bg-blue-700');
88
98
  const control = /*#__PURE__*/React__default.createElement(Checkbox$1, {
89
99
  checked: checked,
90
- className: "group-hover/toggle:[&[aria-checked=false]]:border-grey-700 group-hover/toggle:[&[aria-checked=true]]:border-blue-700 group-hover/checkbox:[&[aria-checked=true]]:bg-blue-700",
100
+ className: controlClassName,
91
101
  disabled: props.disabled,
92
102
  onChange: toggle,
93
103
  ref: checkboxRef,
94
- tabIndex: -1
104
+ excludeFromTabOrder: true
95
105
  });
96
106
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
97
107
  control: control,
@@ -1 +1 @@
1
- {"version":3,"file":"Toggle.js","sources":["../../../../../../../../src/components/List/components/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { ControlledSwitchProps, Switch as TacoSwitch } from '../../Switch/Switch';\nimport { ControlledCheckboxProps, Checkbox as TacoCheckbox } from '../../Checkbox/Checkbox';\nimport { Item, ComposableListItemProps } from './Item';\n\ntype ToggleProps = ComposableListItemProps<'div'> & {\n control: JSX.Element;\n controlRef: React.RefObject<HTMLButtonElement>;\n onToggle: () => void;\n};\n\nconst ToggleItem = React.forwardRef<HTMLDivElement, ToggleProps>(function Toggle(props, ref) {\n const { controlRef, onToggle, ...attributes } = props;\n\n function handleClick(event: React.MouseEvent<HTMLDivElement>) {\n if (typeof props.onClick === 'function') {\n props.onClick(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n // If event target is not a control and not an element inside the control, then trigger click of the control\n if (event.target !== controlRef.current && !controlRef.current?.contains(event.target as HTMLElement)) {\n onToggle();\n return;\n }\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (typeof props.onKeyDown === 'function') {\n props.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n // If event target is not a control and not an element inside the control, then send appropriate \"activate\" keyboard shortcuts to the control as a click\n if (\n (event.key === 'Enter' || event.key === ' ') &&\n event.target !== controlRef.current &&\n !controlRef.current?.contains(event.target as HTMLElement)\n ) {\n onToggle();\n return;\n }\n }\n\n const className = cn('group/toggle', props.className);\n return <Item {...attributes} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref} />;\n});\n\nexport type ListSwitchProps = ComposableListItemProps<'div'> & Omit<ControlledSwitchProps, 'title'>;\n\nexport const Switch = React.forwardRef<HTMLDivElement, ListSwitchProps>(function Switch(props, ref) {\n const { checked: externalChecked, onChange, ...attributes } = props;\n const [checked, setChecked] = React.useState<boolean>(externalChecked);\n const switchRef = React.useRef<HTMLButtonElement>(null);\n\n const toggle = React.useCallback(() => {\n setChecked(!checked);\n onChange(!checked);\n }, [checked, onChange]);\n\n const control = (\n <TacoSwitch\n checked={checked}\n className=\"group-hover/toggle:[&[aria-checked=false]]:bg-grey-700 group-hover/toggle:[&[aria-checked=true]]:bg-blue-700\"\n disabled={props.disabled}\n onChange={toggle}\n ref={switchRef}\n tabIndex={-1}\n />\n );\n\n return <ToggleItem {...attributes} control={control} controlRef={switchRef} ref={ref} onToggle={toggle} />;\n});\n\nexport type ListCheckboxProps = ComposableListItemProps<'div'> & ControlledCheckboxProps;\n\nexport const Checkbox = React.forwardRef<HTMLDivElement, ListSwitchProps>(function Switch(props, ref) {\n const { checked: externalChecked, onChange, ...attributes } = props;\n const [checked, setChecked] = React.useState<boolean>(externalChecked);\n const checkboxRef = React.useRef<HTMLButtonElement>(null);\n\n const toggle = React.useCallback(() => {\n setChecked(!checked);\n onChange(!checked);\n }, [checked, onChange]);\n\n const control = (\n <TacoCheckbox\n checked={checked}\n className=\"group-hover/toggle:[&[aria-checked=false]]:border-grey-700 group-hover/toggle:[&[aria-checked=true]]:border-blue-700 group-hover/checkbox:[&[aria-checked=true]]:bg-blue-700\"\n disabled={props.disabled}\n onChange={toggle}\n ref={checkboxRef}\n tabIndex={-1}\n />\n );\n\n return <ToggleItem {...attributes} control={control} controlRef={checkboxRef} ref={ref} onToggle={toggle} />;\n});\n"],"names":["ToggleItem","React","forwardRef","Toggle","props","ref","controlRef","onToggle","attributes","handleClick","event","onClick","isDefaultPrevented","target","current","_controlRef$current","contains","handleKeyDown","onKeyDown","key","_controlRef$current2","className","cn","Item","Switch","checked","externalChecked","onChange","setChecked","useState","switchRef","useRef","toggle","useCallback","control","TacoS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MAAM,CAACqB,OAAO,EAAEG,UAAU,CAAC,GAAG3B,cAAK,CAAC4B,QAAQ,CAAUH,eAAe,CAAC;EACtE,MAAMa,WAAW,GAAGtC,cAAK,CAAC8B,MAAM,CAAoB,IAAI,CAAC;EAEzD,MAAMC,MAAM,GAAG/B,cAAK,CAACgC,WAAW,CAAC;IAC7BL,UAAU,CAAC,CAACH,OAAO,CAAC;IACpBE,QAAQ,CAAC,CAACF,OAAO,CAAC;GACrB,EAAE,CAACA,OAAO,EAAEE,QAAQ,CAAC,CAAC;EAEvB,MAAMO,OAAO,gBACTjC,6BAACuC,UAAY;IACTf,OAAO,EAAEA,OAAO;IAChBJ,SAAS,EAAC,8KAA8K;IACxLe,QAAQ,EAAEhC,KAAK,CAACgC,QAAQ;IACxBT,QAAQ,EAAEK,MAAM;IAChB3B,GAAG,EAAEkC,WAAW;IAChBF,QAAQ,EAAE,CAAC;IAElB;EAED,oBAAOpC,6BAACD,UAAU,oBAAKQ,UAAU;IAAE0B,OAAO,EAAEA,OAAO;IAAE5B,UAAU,EAAEiC,WAAW;IAAElC,GAAG,EAAEA,GAAG;IAAEE,QAAQ,EAAEyB;KAAU;AAChH,CAAC;;;;"}
1
+ {"version":3,"file":"Toggle.js","sources":["../../../../../../../../src/components/List/components/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { ControlledSwitchProps, Switch as TacoSwitch } from '../../Switch/Switch';\nimport { ControlledCheckboxProps, Checkbox as TacoCheckbox } from '../../Checkbox/Checkbox';\nimport { Item, ComposableListItemProps } from './Item';\n\ntype ToggleProps = ComposableListItemProps<'div'> & {\n control: JSX.Element;\n controlRef: React.RefObject<HTMLInputElement>;\n onToggle: () => void;\n};\n\nconst ToggleItem = React.forwardRef<HTMLDivElement, ToggleProps>(function Toggle(props, ref) {\n const { controlRef, onToggle, ...attributes } = props;\n\n function handleClick(event: React.MouseEvent<HTMLDivElement>) {\n if (typeof props.onClick === 'function') {\n props.onClick(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n // If event target is not a control and not an element inside the control, then trigger click of the control\n if (event.target !== controlRef.current && !controlRef.current?.contains(event.target as HTMLElement)) {\n onToggle();\n return;\n }\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (typeof props.onKeyDown === 'function') {\n props.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n // If event target is not a control and not an element inside the control, then send appropriate \"activate\" keyboard shortcuts to the control as a click\n if (\n (event.key === 'Enter' || event.key === ' ') &&\n event.target !== controlRef.current &&\n !controlRef.current?.contains(event.target as HTMLElement)\n ) {\n onToggle();\n return;\n }\n }\n\n const className = cn('group/toggle', props.className);\n return <Item {...attributes} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref} />;\n});\n\nexport type ListSwitchProps = ComposableListItemProps<'div'> & Omit<ControlledSwitchProps, 'title'>;\n\nexport const Switch = React.forwardRef<HTMLDivElement, ListSwitchProps>(function Switch(props, ref) {\n const { checked: externalChecked, onChange, ...attributes } = props;\n const [checked, setChecked] = React.useState<boolean>(externalChecked);\n const switchRef = React.useRef<HTMLInputElement>(null);\n\n const toggle = React.useCallback(() => {\n setChecked(!checked);\n onChange(!checked);\n }, [checked, onChange]);\n\n const controlClassName = cn(\n // When ToggleItem is hovered\n 'group-hover/toggle:bg-grey-700',\n // When ToggleItem is hovered and switch inside it is selected\n 'group-hover/toggle:group-data-[selected]:bg-blue-700'\n );\n\n const control = (\n <TacoSwitch\n checked={checked}\n className={controlClassName}\n disabled={props.disabled}\n onChange={toggle}\n ref={switchRef}\n excludeFromTabOrder\n />\n );\n\n return <ToggleItem {...attributes} control={control} controlRef={switchRef} ref={ref} onToggle={toggle} />;\n});\n\nexport type ListCheckboxProps = ComposableListItemProps<'div'> & ControlledCheckboxProps;\n\nexport const Checkbox = React.forwardRef<HTMLDivElement, ListSwitchProps>(function Switch(props, ref) {\n const { checked: externalChecked, onChange, ...attributes } = props;\n const [checked, setChecked] = React.useState<boolean>(externalChecked);\n const checkboxRef = React.useRef<HTMLInputElement>(null);\n\n const toggle = React.useCallback(() => {\n setChecked(!checked);\n onChange(!checked);\n }, [checked, onChange]);\n\n const controlClassName = cn(\n // When ToggleItem is hovered\n 'group-hover/toggle:border-grey-700',\n // When ToggleItem is hovered and checkbox inside it is selected\n 'group-hover/toggle:group-data-[selected]:border-blue-700 group-hover/toggle:group-data-[selected]:bg-blue-700'\n );\n\n const control = (\n <TacoCheckbox\n checked={checked}\n className={controlClassName}\n disabled={props.disabled}\n onChange={toggle}\n ref={checkboxRef}\n excludeFromTabOrder\n />\n );\n\n return <ToggleItem {...attributes} control={control} controlRef={checkboxRef} ref={ref} onToggle={toggle} />;\n});\n"],"names":["ToggleItem","React","forwardRef","Toggle","props","ref","controlRef","onToggle","attributes","handleClick","event","onClick","isDefaultPrevented","target","current","_controlRef$current","contains","handleKeyDown","onKeyDown","key","_controlRef$current2","className","cn","Item","Switch","checked","externalChecked","onChange","setChecked","useState","switchRef","useRef","toggle","useCallback","controlClassName","control","TacoSwitch","disabled","excludeFromTabOrder","Checkbox","checkboxRef","TacoCheckbox"],"mappings":";;;;;;AAYA,MAAMA,UAAU,gBAAGC,cAAK,CAACC,UAAU,CAA8B,SAASC,MAAMA,CAACC,KAAK,EAAEC,GAAG;EACvF,MAAM;IAAEC,UAAU;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAErD,SAASK,WAAWA,CAACC,KAAuC;;IACxD,IAAI,OAAON,KAAK,CAACO,OAAO,KAAK,UAAU,EAAE;MACrCP,KAAK,CAACO,OAAO,CAACD,KAAK,CAAC;;IAGxB,IAAIA,KAAK,CAACE,kBAAkB,EAAE,EAAE;MAC5B;;;IAIJ,IAAIF,KAAK,CAACG,MAAM,KAAKP,UAAU,CAACQ,OAAO,IAAI,GAAAC,mBAAA,GAACT,UAAU,CAACQ,OAAO,cAAAC,mBAAA,eAAlBA,mBAAA,CAAoBC,QAAQ,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EAAEa,gBAAgB;IAC3BG,QAAQ,EAAEjC,KAAK,CAACiC,QAAQ;IACxBV,QAAQ,EAAEK,MAAM;IAChB3B,GAAG,EAAEmC,WAAW;IAChBF,mBAAmB;IAE1B;EAED,oBAAOrC,6BAACD,UAAU,oBAAKQ,UAAU;IAAE2B,OAAO,EAAEA,OAAO;IAAE7B,UAAU,EAAEkC,WAAW;IAAEnC,GAAG,EAAEA,GAAG;IAAEE,QAAQ,EAAEyB;KAAU;AAChH,CAAC;;;;"}
@@ -155,10 +155,13 @@ const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, re
155
155
  // so need to be taken out of screen reader scope.
156
156
  , {
157
157
  "aria-hidden": true,
158
- tabIndex: -1,
158
+ excludeFromTabOrder: true,
159
159
  checked: optionProps['aria-selected'],
160
- onChange: () => null,
161
- className: "pointer-events-none ml-2 self-center p-px"
160
+ onChange: () => {
161
+ var _optionProps$ref, _optionProps$ref$curr;
162
+ (_optionProps$ref = optionProps.ref) === null || _optionProps$ref === void 0 ? void 0 : (_optionProps$ref$curr = _optionProps$ref.current) === null || _optionProps$ref$curr === void 0 ? void 0 : _optionProps$ref$curr.click();
163
+ },
164
+ className: "ml-2 self-center p-px"
162
165
  }))))) : (/*#__PURE__*/createElement("li", {
163
166
  className: "yt-list__empty"
164
167
  }, /*#__PURE__*/createElement("span", null, texts.listbox.empty))));
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollableList.js","sources":["../../../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getNextIndexFromKey } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Localization';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKey(event.key, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n invalid: _,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useMergedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n if (currentIndex && itemRefs[currentIndex]?.current) {\n itemRefs[currentIndex].current?.scrollIntoView({\n block: 'center',\n });\n }\n }, []);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n\n // Stops the keyboard event from propagating so that keyboard event on other components outside the scrollable\n // list are not executed.\n event.stopPropagation();\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue-500 focus:border-blue-500',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: options.length <= 0 || loading ? 'presentation' : 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n // In multiselect variant, this checkbox only acts as visual representation of item being selected,\n // so need to be taken out of screen reader scope.\n aria-hidden\n tabIndex={-1}\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"pointer-events-none ml-2 self-center p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKey","key","length","disabled","ScrollableList","React","props","ref","highlighted","invalid","_","loading","onChange","setCurrentIndex","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useMergedRef","itemRefs","map","texts","useLocalization","scrollTo","useListScrollTo","_itemRefs$currentInde","current","_itemRefs$currentInde2","scrollIntoView","block","handleKeyDown","undefined","preventDefault","persist","stopPropagation","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","options","option","depth","path","split","String","children","text","className","cn","hasChildren","icon","role","style","paddingLeft","list","getInputClasses","tabIndex","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;MA2FaA,KAAK,GAAGA,CAACC,EAAU,EAAEC,KAA8B,KAAa,GAAGD,EAAE,IAAIC,KAAK;AAE3F,MAAMC,kBAAkB,GAAGA,CACvBC,KAAuC,EACvCC,IAA0B,EAC1BC,KAAyB;EAEzB,MAAMC,SAAS,GAAGC,mBAAmB,CAACJ,KAAK,CAACK,GAAG,EAAEJ,IAAI,CAACK,MAAM,EAAEJ,KAAK,CAAC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IACpB4C,SAAS,EAAC;IACZ,CACL,CACA,CACR,CAAC,iBAEFnD;IAAImD,SAAS,EAAC;kBACVnD,4BAAOuB,KAAK,CAACwC,OAAO,CAACI,KAAK,CAAQ,CACjC,CACR,CACA;AAEb,CAAC;;;;"}
1
+ {"version":3,"file":"ScrollableList.js","sources":["../../../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getNextIndexFromKey } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Localization';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKey(event.key, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n invalid: _,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useMergedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n if (currentIndex && itemRefs[currentIndex]?.current) {\n itemRefs[currentIndex].current?.scrollIntoView({\n block: 'center',\n });\n }\n }, []);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n\n // Stops the keyboard event from propagating so that keyboard event on other components outside the scrollable\n // list are not executed.\n event.stopPropagation();\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue-500 focus:border-blue-500',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: options.length <= 0 || loading ? 'presentation' : 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n // In multiselect variant, this checkbox only acts as visual representation of item being selected,\n // so need to be taken out of screen reader scope.\n aria-hidden\n excludeFromTabOrder\n checked={optionProps['aria-selected']}\n onChange={() => {\n optionProps.ref?.current?.click();\n }}\n className=\"ml-2 self-center p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKey","key","length","disabled","ScrollableList","React","props","ref","highlighted","invalid","_","loading","onChange","setCurrentIndex","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useMergedRef","itemRefs","map","texts","useLocalization","scrollTo","useListScrollTo","_itemRefs$currentInde","current","_itemRefs$currentInde2","scrollIntoView","block","handleKeyDown","undefined","preventDefault","persist","stopPropagation","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","options","option","depth","path","split","String","children","text","className","cn","hasChildren","icon","role","style","paddingLeft","list","getInputClasses","tabIndex","Spinner","delay","listbox","optionProps","Checkbox","excludeFromTabOrder","checked","_optionProps$ref","_optionProps$ref$curr","click","empty"],"mappings":";;;;;;;;;;MA2FaA,KAAK,GAAGA,CAACC,EAAU,EAAEC,KAA8B,KAAa,GAAGD,EAAE,IAAIC,KAAK;AAE3F,MAAMC,kBAAkB,GAAGA,CACvBC,KAAuC,EACvCC,IAA0B,EAC1BC,KAAyB;EAEzB,MAAMC,SAAS,GAAGC,mBAAmB,CAACJ,KAAK,CAACK,GAAG,EAAEJ,IAAI,CAACK,MAAM,EAAEJ,KAAK,CAAC;EAEpE,IAAIC,SAAS,EAAE;IACX,IAAIA,SAAS,KAAKD,KAAK,EAAE;MACrB,OAAOA,KAAK;KACf,MAAM,IAAID,IAAI,CAACE,SAAS,CAAC,IAAIF,IAAI,CAACE,SAAS,CAAC,CAACI,QAAQ,EAAE;MACpD,OAAOR,kBAAkB,CAACC,KAAK,EAAEC,IAAI,EAAEE,SAAS,CAAC;;;EAIzD,OAAOA,SAAS;AACpB,CAAC;MAEYK,cAAc,gBAAGC,UAAgB,CAAC,SAASD,cAAcA,CAClEE,KAA0B,EAC1BC,GAAgC;EAEhC,MAAM;IACFV,IAAI;IACJM,QAAQ;IACRK,WAAW;IACXf,EAAE;IACFgB,OAAO,EAAEC,CAAC;IACVC,OAAO;IACPC,QAAQ,EAAEC,eAAe;IACzBC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACRC,aAAa,GAAG,KAAK;IACrBxB,KAAK,EAAEyB,YAAY;IACnBC,WAAW;IACXC,eAAe,GAAG,EAAE;IACpBC,kBAAkB,GA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AAE1C,UAAU,CAAC0C,QAAQ,IAAI;GACpC;EAED,oBACI5D,sCAAQ0D,IAAI;iBAAY;MACnBpD,OAAO,iBACJN;IAAImD,SAAS,EAAC;kBACVnD,yCACIA,cAAC6D,OAAO;IAACC,KAAK,EAAE;IAAK,CAClB,eACP9D,4BAAOuB,KAAK,CAACwC,OAAO,CAACzD,OAAO,CAAQ,CACnC,IACLqC,OAAO,CAAC9C,MAAM,GACd8C,OAAO,CAACrB,GAAG,CAAC,CAAC;IAAE2B,QAAQ;IAAEK,IAAI;IAAE,GAAGU;GAAa,mBAC3ChE,sCAAQgE,WAAW,GACdV,IAAI,eACLtD;IAAMmD,SAAS,EAAC;KAAgCF,QAAQ,CAAQ,EAC/DlC,WAAW,kBACRf,cAACiE;;;;;IAIGC,mBAAmB;IACnBC,OAAO,EAAEH,WAAW,CAAC,eAAe,CAAC;IACrCzD,QAAQ,EAAEA;;MACN,CAAA6D,gBAAA,GAAAJ,WAAW,CAAC9D,GAAG,cAAAkE,gBAAA,wBAAAC,qBAAA,GAAfD,gBAAA,CAAiBxC,OAAO,cAAAyC,qBAAA,uBAAxBA,qBAAA,CAA0BC,KAAK,EAAE;KACpC;IACDnB,SAAS,EAAC;IACZ,CACL,CACA,CACR,CAAC,iBAEFnD;IAAImD,SAAS,EAAC;kBACVnD,4BAAOuB,KAAK,CAACwC,OAAO,CAACQ,KAAK,CAAQ,CACjC,CACR,CACA;AAEb,CAAC;;;;"}
@@ -1,24 +1,46 @@
1
1
  import { forwardRef, createElement } from 'react';
2
2
  import cn from 'clsx';
3
3
  import { Icon } from '../Icon/Icon.js';
4
- import { Root, Thumb } from '@radix-ui/react-switch';
4
+ import { useMergedRef } from '../../hooks/useMergedRef.js';
5
+ import { Switch } from 'react-aria-components';
5
6
 
6
7
  const ModeSwitch = /*#__PURE__*/forwardRef(function ModeSwitch(props, ref) {
7
8
  const {
9
+ checked,
10
+ defaultChecked,
11
+ readOnly,
8
12
  onChange,
13
+ disabled,
14
+ className,
9
15
  ...otherProps
10
16
  } = props;
11
- const className = cn('group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus p-1', {
12
- 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,
13
- 'bg-grey-500 aria-checked:bg-blue-500 cursor-not-allowed opacity-50': props.disabled
14
- }, props.className);
15
- return /*#__PURE__*/createElement(Root, Object.assign({}, otherProps, {
16
- className: className,
17
- "data-taco": "mode",
18
- onCheckedChange: onChange,
19
- ref: ref
20
- }), /*#__PURE__*/createElement(Thumb, {
21
- className: "pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[100%]"
17
+ const inputRef = useMergedRef(ref);
18
+ const switchClassName = cn('group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex p-1 cursor-pointer bg-grey-500', 'data-[focus-visible]:yt-focus', 'hover:bg-grey-700',
19
+ // When modeswitch is selected
20
+ 'data-[selected]:bg-blue-500',
21
+ // When modeswitch is selected and hovered
22
+ 'hover:data-[selected]:bg-blue-700',
23
+ // When modeswitch is disabled
24
+ 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:bg-grey-500 ',
25
+ // When modeswitch is disabled and selected
26
+ 'data-[disabled]:data-[selected]:!bg-blue-500', className);
27
+ const switchThumbClassName = cn('pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform',
28
+ // When modeswitch is disabled
29
+ 'group-data-[disabled]:opacity-50',
30
+ // When modeswitch is selected
31
+ 'group-data-[selected]:translate-x-full');
32
+ return /*#__PURE__*/createElement(Switch, Object.assign({}, otherProps, {
33
+ className: switchClassName,
34
+ defaultSelected: defaultChecked,
35
+ id: otherProps.id,
36
+ inputRef: inputRef,
37
+ isDisabled: disabled,
38
+ isReadOnly: readOnly,
39
+ isSelected: checked,
40
+ onChange: onChange
41
+ }), /*#__PURE__*/createElement("span", {
42
+ className: switchThumbClassName,
43
+ "data-taco": "mode"
22
44
  }, /*#__PURE__*/createElement(Icon, {
23
45
  name: "edit-simple",
24
46
  className: "pointer-events-none !h-5 !w-5"
@@ -1 +1 @@
1
- {"version":3,"file":"ModeSwitch.js","sources":["../../../../../../../src/components/ModeSwitch/ModeSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\n\nimport { Icon } from '../Icon/Icon';\n\ntype ModeSwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledModeSwitchProps extends ModeSwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledModeSwitchProps extends ModeSwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type ModeSwitchProps = UncontrolledModeSwitchProps | ControlledModeSwitchProps;\n\nexport const ModeSwitch = React.forwardRef(function ModeSwitch(props: ModeSwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { onChange, ...otherProps } = props;\n\n const className = cn(\n 'group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus p-1',\n {\n 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,\n 'bg-grey-500 aria-checked:bg-blue-500 cursor-not-allowed opacity-50': props.disabled,\n },\n props.className\n );\n\n return (\n <PrimitiveSwitch.Root {...otherProps} className={className} data-taco=\"mode\" onCheckedChange={onChange} ref={ref}>\n <PrimitiveSwitch.Thumb className=\"pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[100%]\">\n <Icon name=\"edit-simple\" className=\"pointer-events-none !h-5 !w-5\" />\n </PrimitiveSwitch.Thumb>\n </PrimitiveSwitch.Root>\n );\n});\nModeSwitch.displayName = 'ModeSwitch';\n"],"names":["ModeSwitch","React","props","ref","onChange","otherProps","className","cn","disabled","PrimitiveSwitch","onCheckedChange","Icon","name","displayName"],"mappings":";;;;;MA4BaA,UAAU,gBAAGC,UAAgB,CAAC,SAASD,UAAUA,CAACE,KAAsB,EAAEC,GAAiC;EACpH,MAAM;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAEzC,MAAMI,SAAS,GAAGC,EAAE,CAChB,uFAAuF,EACvF;IACI,uFAAuF,EAAE,CAACL,KAAK,CAACM,QAAQ;IACxG,oEAAoE,EAAEN,KAAK,CAACM;GAC/E,EACDN,KAAK,CAACI,SAAS,CAClB;EAED,oBACIL,cAACQ,IAAoB,oBAAKJ,UAAU;IAAEC,SAAS,EAAEA,SAAS;iBAAY,MAAM;IAACI,eAAe,EAAEN,QAAQ;IAAED,GAAG,EAAEA;mBACzGF,cAACQ,KAAqB;IAACH,SAAS,EAAC;kBAC7BL,cAACU,IAAI;IAACC,IAAI,EAAC,aAAa;IAACN,SAAS,EAAC;IAAkC,CACjD,CACL;AAE/B,CAAC;AACDN,UAAU,CAACa,WAAW,GAAG,YAAY;;;;"}
1
+ {"version":3,"file":"ModeSwitch.js","sources":["../../../../../../../src/components/ModeSwitch/ModeSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Switch as SwitchPrimitive, SwitchProps as SwitchPrimitiveProps } from 'react-aria-components';\n\nimport { Icon } from '../Icon/Icon';\nimport { useMergedRef } from '../../hooks/useMergedRef';\n\ntype ModeSwitchBaseProps = Omit<\n SwitchPrimitiveProps,\n 'onChange' | 'label' | 'isDisabled' | 'isReadOnly' | 'isSelected' | 'defaultSelected' | 'isInvalid'\n> & {\n disabled?: boolean;\n readOnly?: boolean;\n onClick?: (event: React.MouseEvent<HTMLSpanElement>) => void;\n};\n\ninterface UncontrolledModeSwitchProps extends ModeSwitchBaseProps {\n checked?: never;\n onChange?: never;\n defaultChecked?: boolean;\n}\n\ninterface ControlledModeSwitchProps extends ModeSwitchBaseProps {\n defaultChecked?: never;\n checked: boolean;\n onChange: (checked: boolean) => void;\n}\n\nexport type ModeSwitchProps = UncontrolledModeSwitchProps | ControlledModeSwitchProps;\n\nexport const ModeSwitch = React.forwardRef(function ModeSwitch(props: ModeSwitchProps, ref: React.Ref<HTMLInputElement>) {\n const { checked, defaultChecked, readOnly, onChange, disabled, className, ...otherProps } = props;\n\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n\n const switchClassName = cn(\n 'group w-14 h-8 flex flex-shrink-0 rounded-full inline-flex p-1 cursor-pointer bg-grey-500',\n 'data-[focus-visible]:yt-focus',\n 'hover:bg-grey-700',\n // When modeswitch is selected\n 'data-[selected]:bg-blue-500',\n // When modeswitch is selected and hovered\n 'hover:data-[selected]:bg-blue-700',\n // When modeswitch is disabled\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:bg-grey-500 ',\n // When modeswitch is disabled and selected\n 'data-[disabled]:data-[selected]:!bg-blue-500',\n className\n );\n\n const switchThumbClassName = cn(\n 'pointer-events-none flex h-6 w-6 items-center justify-center rounded-full bg-white transition-transform will-change-transform',\n // When modeswitch is disabled\n 'group-data-[disabled]:opacity-50',\n // When modeswitch is selected\n 'group-data-[selected]:translate-x-full'\n );\n\n return (\n <SwitchPrimitive\n {...otherProps}\n className={switchClassName}\n defaultSelected={defaultChecked}\n id={otherProps.id}\n inputRef={inputRef}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isSelected={checked}\n onChange={onChange}>\n <span className={switchThumbClassName} data-taco=\"mode\">\n <Icon name=\"edit-simple\" className=\"pointer-events-none !h-5 !w-5\" />\n </span>\n </SwitchPrimitive>\n );\n});\nModeSwitch.displayName = 'ModeSwitch';\n"],"names":["ModeSwitch","React","props","ref","checked","defaultChecked","readOnly","onChange","disabled","className","otherProps","inputRef","useMergedRef","switchClassName","cn","switchThumbClassName","SwitchPrimitive","defaultSelected","id","isDisabled","isReadOnly","isSelected","Icon","name","displayName"],"mappings":";;;;;;MA8BaA,UAAU,gBAAGC,UAAgB,CAAC,SAASD,UAAUA,CAACE,KAAsB,EAAEC,GAAgC;EACnH,MAAM;IAAEC,OAAO;IAAEC,cAAc;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,SAAS;IAAE,GAAGC;GAAY,GAAGR,KAAK;EAEjG,MAAMS,QAAQ,GAAGC,YAAY,CAAmBT,GAAG,CAAC;EAEpD,MAAMU,eAAe,GAAGC,EAAE,CACtB,2FAA2F,EAC3F,+BAA+B,EAC/B,mBAAmB;;EAEnB,6BAA6B;;EAE7B,mCAAmC;;EAEnC,4FAA4F;;EAE5F,8CAA8C,EAC9CL,SAAS,CACZ;EAED,MAAMM,oBAAoB,GAAGD,EAAE,CAC3B,+HAA+H;;EAE/H,kCAAkC;;EAElC,wCAAwC,CAC3C;EAED,oBACIb,cAACe,MAAe,oBACRN,UAAU;IACdD,SAAS,EAAEI,eAAe;IAC1BI,eAAe,EAAEZ,cAAc;IAC/Ba,EAAE,EAAER,UAAU,CAACQ,EAAE;IACjBP,QAAQ,EAAEA,QAAQ;IAClBQ,UAAU,EAAEX,QAAQ;IACpBY,UAAU,EAAEd,QAAQ;IACpBe,UAAU,EAAEjB,OAAO;IACnBG,QAAQ,EAAEA;mBACVN;IAAMQ,SAAS,EAAEM,oBAAoB;iBAAY;kBAC7Cd,cAACqB,IAAI;IAACC,IAAI,EAAC,aAAa;IAACd,SAAS,EAAC;IAAkC,CAClE,CACO;AAE1B,CAAC;AACDT,UAAU,CAACwB,WAAW,GAAG,YAAY;;;;"}
@@ -3,9 +3,8 @@ import { fixedForwardRef } from '../../types.js';
3
3
  import { useReport } from './useReport.js';
4
4
  import { Table } from '../../primitives/Table/Core/Table.js';
5
5
 
6
- function Column(_) {
7
- return null;
8
- }
6
+ const Column = () => null;
7
+ Column.displayName = 'Table3Column';
9
8
  function Group(_) {
10
9
  return null;
11
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Report.js","sources":["../../../../../../../src/components/Report/Report.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useReport } from './useReport';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';\n\nfunction Column<TType = unknown>(_: ReportColumnProps<TType>) {\n return null;\n}\n\nfunction Group(_: ReportGroupProps) {\n return null;\n}\n\nconst BaseReport = fixedForwardRef(function BaseReport<TType = unknown>(props: ReportProps<TType>, ref: React.Ref<ReportRef>) {\n const report = useReport<TType>(props, ref);\n\n return (\n <Table>\n <Table.Toolbar<TType> table={report} />\n <Table.Grid<TType> data-taco=\"table-report\" table={report} />\n </Table>\n );\n});\n\nexport const Report = fixedForwardRef(function Report<TType = unknown>(props: ReportProps<TType>, ref: React.Ref<ReportRef>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <BaseReport<TType> {...props} key={key} ref={ref} />;\n}) as (<TType = unknown>(props: ReportProps<TType> & React.RefAttributes<ReportRef>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nReport.Column = Column;\nReport.Group = Group;\n\nexport type { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';\n"],"names":["Column","_","Group","BaseReport","fixedForwardRef","props","ref","report","useReport","React","Table","Toolbar","table","Grid","Report","stringifiedChildren","String","children","key","useMemo"],"mappings":";;;;;AAMA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AAEA,SAASC,KAAKA,CAACD,CAAmB;EAC9B,OAAO,IAAI;AACf;AAEA,MAAME,UAAU,gBAAGC,eAAe,CAAC,SAASD,UAAUA,CAAkBE,KAAyB,EAAEC,GAAyB;EACxH,MAAMC,MAAM,GAAGC,SAAS,CAAQH,KAAK,EAAEC,GAAG,CAAC;EAE3C,oBACIG,6BAACC,KAAK,qBACFD,6BAACC,KAAK,CAACC,OAAO;IAAQC,KAAK,EAAEL;IAAU,eACvCE,6BAACC,KAAK,CAACG,IAAI;iBAAkB,cAAc;IAACD,KAAK,EAAEL;IAAU,CACzD;AAEhB,CAAC,CAAC;MAEWO,MAAM,gBAAGV,eAAe,CAAC,SAASU,MAAMA,CAAkBT,KAAyB,EAAEC,GAAyB;EACvH,MAAMS,mBAAmB,GAAGC,MAAM,CAACX,KAAK,CAACY,QAAQ,CAAC;;;EAGlD,MAAMC,GAAG,GAAGT,cAAK,CAACU,OAAO,CAAC,MAAMH,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAON,6BAACN,UAAU,oBAAYE,KAAK;IAAEa,GAAG,EAAEA,GAAG;IAAEZ,GAAG,EAAEA;KAAO;AAC/D,CAAC;AAIDQ,MAAM,CAACd,MAAM,GAAGA,MAAM;AACtBc,MAAM,CAACZ,KAAK,GAAGA,KAAK;;;;"}
1
+ {"version":3,"file":"Report.js","sources":["../../../../../../../src/components/Report/Report.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useReport } from './useReport';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';\n\nconst Column: React.FC<ReportColumnProps<unknown>> & {\n <TType = unknown>(_: ReportColumnProps<TType>): null;\n} = () => null;\n\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: ReportGroupProps) {\n return null;\n}\n\nconst BaseReport = fixedForwardRef(function BaseReport<TType = unknown>(props: ReportProps<TType>, ref: React.Ref<ReportRef>) {\n const report = useReport<TType>(props, ref);\n\n return (\n <Table>\n <Table.Toolbar<TType> table={report} />\n <Table.Grid<TType> data-taco=\"table-report\" table={report} />\n </Table>\n );\n});\n\nexport const Report = fixedForwardRef(function Report<TType = unknown>(props: ReportProps<TType>, ref: React.Ref<ReportRef>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <BaseReport<TType> {...props} key={key} ref={ref} />;\n}) as (<TType = unknown>(props: ReportProps<TType> & React.RefAttributes<ReportRef>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nReport.Column = Column;\nReport.Group = Group;\n\nexport type { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';\n"],"names":["Column","displayName","Group","_","BaseReport","fixedForwardRef","props","ref","report","useReport","React","Table","Toolbar","table","Grid","Report","stringifiedChildren","String","children","key","useMemo"],"mappings":";;;;;AAMA,MAAMA,MAAM,GAERA,MAAM,IAAI;AAEdA,MAAM,CAACC,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACC,CAAmB;EAC9B,OAAO,IAAI;AACf;AAEA,MAAMC,UAAU,gBAAGC,eAAe,CAAC,SAASD,UAAUA,CAAkBE,KAAyB,EAAEC,GAAyB;EACxH,MAAMC,MAAM,GAAGC,SAAS,CAAQH,KAAK,EAAEC,GAAG,CAAC;EAE3C,oBACIG,6BAACC,KAAK,qBACFD,6BAACC,KAAK,CAACC,OAAO;IAAQC,KAAK,EAAEL;IAAU,eACvCE,6BAACC,KAAK,CAACG,IAAI;iBAAkB,cAAc;IAACD,KAAK,EAAEL;IAAU,CACzD;AAEhB,CAAC,CAAC;MAEWO,MAAM,gBAAGV,eAAe,CAAC,SAASU,MAAMA,CAAkBT,KAAyB,EAAEC,GAAyB;EACvH,MAAMS,mBAAmB,GAAGC,MAAM,CAACX,KAAK,CAACY,QAAQ,CAAC;;;EAGlD,MAAMC,GAAG,GAAGT,cAAK,CAACU,OAAO,CAAC,MAAMH,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAON,6BAACN,UAAU,oBAAYE,KAAK;IAAEa,GAAG,EAAEA,GAAG;IAAEZ,GAAG,EAAEA;KAAO;AAC/D,CAAC;AAIDQ,MAAM,CAACf,MAAM,GAAGA,MAAM;AACtBe,MAAM,CAACb,KAAK,GAAGA,KAAK;;;;"}
@@ -1,48 +1,50 @@
1
1
  import { forwardRef, createElement } from 'react';
2
2
  import cn from 'clsx';
3
- import { useId } from '../../hooks/useId.js';
4
- import { Root, Thumb } from '@radix-ui/react-switch';
3
+ import { useMergedRef } from '../../hooks/useMergedRef.js';
4
+ import { Switch as Switch$1 } from 'react-aria-components';
5
5
 
6
6
  const Switch = /*#__PURE__*/forwardRef(function Switch(props, ref) {
7
7
  const {
8
+ checked,
9
+ defaultChecked,
10
+ readOnly,
8
11
  label,
9
12
  onChange,
13
+ disabled,
14
+ onClick,
15
+ className,
10
16
  ...otherProps
11
17
  } = props;
12
- const id = useId(props.id);
13
- const className = cn('group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus', {
14
- 'mr-2': !!label,
15
- 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,
16
- 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled
17
- }, props.className);
18
- let labelledByProps = null;
19
- if (label) {
20
- labelledByProps = {
21
- 'aria-labelledby': `${id}-label`,
22
- id
23
- };
24
- }
25
- const element = /*#__PURE__*/createElement(Root, Object.assign({}, otherProps, labelledByProps, {
26
- className: className,
18
+ const inputRef = useMergedRef(ref);
19
+ const switchContainerClassName = cn('group flex self-start', 'data-[disabled]:text-grey-300 data-[disabled]:cursor-not-allowed');
20
+ const switchClassName = cn('h-5 w-9 flex flex-shrink-0 rounded-full inline-flex cursor-pointer bg-grey-500', 'group-data-[focus-visible]:yt-focus', {
21
+ 'mr-2': !!label
22
+ }, 'group-hover:bg-grey-700',
23
+ // When switch is selected
24
+ 'group-data-[selected]:bg-blue-500',
25
+ // When switch is selected and hovered
26
+ 'group-hover:group-data-[selected]:bg-blue-700',
27
+ // When switch is disabled
28
+ 'group-data-[disabled]:!bg-grey-500/50 group-data-[disabled]:cursor-not-allowed',
29
+ // When switch is disabled and selected
30
+ 'group-data-[disabled]:group-data-[selected]:!bg-blue-500/50', className);
31
+ const switchThumbClassName = cn('pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform', 'group-data-[disabled]:opacity-50', 'group-data-[selected]:translate-x-[1.1rem]');
32
+ return /*#__PURE__*/createElement(Switch$1, Object.assign({}, otherProps, {
33
+ className: switchContainerClassName,
34
+ "data-taco": "switch-container",
35
+ inputRef: inputRef,
36
+ isDisabled: disabled,
37
+ isReadOnly: readOnly,
38
+ isSelected: checked,
39
+ defaultSelected: defaultChecked,
40
+ onChange: onChange
41
+ }), /*#__PURE__*/createElement("span", {
42
+ className: switchClassName,
27
43
  "data-taco": "switch",
28
- onCheckedChange: onChange,
29
- ref: ref
30
- }), /*#__PURE__*/createElement(Thumb, {
31
- className: "pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]"
32
- }));
33
- if (label) {
34
- const labelContainerClassName = cn('flex self-start cursor-pointer', {
35
- 'cursor-not-allowed text-grey-300': props.disabled
36
- });
37
- return /*#__PURE__*/createElement("span", {
38
- className: labelContainerClassName,
39
- "data-taco": "switch-container"
40
- }, element, /*#__PURE__*/createElement("label", {
41
- htmlFor: id,
42
- id: `${id}-label`
43
- }, label));
44
- }
45
- return element;
44
+ onClick: onClick
45
+ }, /*#__PURE__*/createElement("span", {
46
+ className: switchThumbClassName
47
+ })), label);
46
48
  });
47
49
  Switch.displayName = 'Switch';
48
50
 
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\nimport { useId } from '../../hooks/useId';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\nexport interface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\nexport interface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n const id = useId(props.id);\n\n const className = cn(\n 'group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus',\n {\n 'mr-2': !!label,\n 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,\n 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled,\n },\n props.className\n );\n\n let labelledByProps: Record<string, string> | null = null;\n\n if (label) {\n labelledByProps = {\n 'aria-labelledby': `${id}-label`,\n id,\n };\n }\n\n const element = (\n <PrimitiveSwitch.Root\n {...otherProps}\n {...labelledByProps}\n className={className}\n data-taco=\"switch\"\n onCheckedChange={onChange}\n ref={ref}>\n <PrimitiveSwitch.Thumb className=\"pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelContainerClassName = cn('flex self-start cursor-pointer', {\n 'cursor-not-allowed text-grey-300': props.disabled,\n });\n\n return (\n <span className={labelContainerClassName} data-taco=\"switch-container\">\n {element}\n <label htmlFor={id} id={`${id}-label`}>\n {label}\n </label>\n </span>\n );\n }\n\n return element;\n});\nSwitch.displayName = 'Switch';\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","id","useId","className","cn","disabled","labelledByProps","element","PrimitiveSwitch","onCheckedChange","labelContainerClassName","htmlFor","displayName"],"mappings":";;;;;MA6BaA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAMA,CAACE,KAAkB,EAAEC,GAAiC;EACxG,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAChD,MAAMK,EAAE,GAAGC,KAAK,CAACN,KAAK,CAACK,EAAE,CAAC;EAE1B,MAAME,SAAS,GAAGC,EAAE,CAChB,kFAAkF,EAClF;IACI,MAAM,EAAE,CAAC,CAACN,KAAK;IACf,uFAAuF,EAAE,CAACF,KAAK,CAACS,QAAQ;IACxG,+DAA+D,EAAET,KAAK,CAACS;GAC1E,EACDT,KAAK,CAACO,SAAS,CAClB;EAED,IAAIG,eAAe,GAAkC,IAAI;EAEzD,IAAIR,KAAK,EAAE;IACPQ,eAAe,GAAG;MACd,iBAAiB,EAAE,GAAGL,EAAE,QAAQ;MAChCA;KACH;;EAGL,MAAMM,OAAO,gBACTZ,cAACa,IAAoB,oBACbR,UAAU,EACVM,eAAe;IACnBH,SAAS,EAAEA,SAAS;iBACV,QAAQ;IAClBM,eAAe,EAAEV,QAAQ;IACzBF,GAAG,EAAEA;mBACLF,cAACa,KAAqB;IAACL,SAAS,EAAC;IAAgM,CAExO;EAED,IAAIL,KAAK,EAAE;IACP,MAAMY,uBAAuB,GAAGN,EAAE,CAAC,gCAAgC,EAAE;MACjE,kCAAkC,EAAER,KAAK,CAACS;KAC7C,CAAC;IAEF,oBACIV;MAAMQ,SAAS,EAAEO,uBAAuB;mBAAY;OAC/CH,OAAO,eACRZ;MAAOgB,OAAO,EAAEV,EAAE;MAAEA,EAAE,EAAE,GAAGA,EAAE;OACxBH,KAAK,CACF,CACL;;EAIf,OAAOS,OAAO;AAClB,CAAC;AACDb,MAAM,CAACkB,WAAW,GAAG,QAAQ;;;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Switch as SwitchPrimitive, SwitchProps as SwitchPrimitiveProps } from 'react-aria-components';\n\nimport { useMergedRef } from '../../hooks/useMergedRef';\n\ntype SwitchBaseProps = Omit<SwitchPrimitiveProps, 'onChange' | 'isDisabled' | 'isReadOnly' | 'isSelected' | 'defaultSelected'> & {\n label?: React.ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n onClick?: (event: React.MouseEvent<HTMLSpanElement>) => void;\n};\n\nexport interface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n defaultChecked?: boolean;\n}\n\nexport interface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n checked: boolean;\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLInputElement>) {\n const { checked, defaultChecked, readOnly, label, onChange, disabled, onClick, className, ...otherProps } = props;\n\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n\n const switchContainerClassName = cn(\n 'group flex self-start',\n 'data-[disabled]:text-grey-300 data-[disabled]:cursor-not-allowed'\n );\n\n const switchClassName = cn(\n 'h-5 w-9 flex flex-shrink-0 rounded-full inline-flex cursor-pointer bg-grey-500',\n 'group-data-[focus-visible]:yt-focus',\n {\n 'mr-2': !!label,\n },\n 'group-hover:bg-grey-700',\n // When switch is selected\n 'group-data-[selected]:bg-blue-500',\n // When switch is selected and hovered\n 'group-hover:group-data-[selected]:bg-blue-700',\n // When switch is disabled\n 'group-data-[disabled]:!bg-grey-500/50 group-data-[disabled]:cursor-not-allowed',\n // When switch is disabled and selected\n 'group-data-[disabled]:group-data-[selected]:!bg-blue-500/50',\n className\n );\n\n const switchThumbClassName = cn(\n 'pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform',\n 'group-data-[disabled]:opacity-50',\n 'group-data-[selected]:translate-x-[1.1rem]'\n );\n\n return (\n <SwitchPrimitive\n {...otherProps}\n className={switchContainerClassName}\n data-taco=\"switch-container\"\n inputRef={inputRef}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isSelected={checked}\n defaultSelected={defaultChecked}\n onChange={onChange}>\n <span className={switchClassName} data-taco=\"switch\" onClick={onClick}>\n <span className={switchThumbClassName} />\n </span>\n {label}\n </SwitchPrimitive>\n );\n});\nSwitch.displayName = 'Switch';\n"],"names":["Switch","React","props","ref","checked","defaultChecked","readOnly","label","onChange","disabled","onClick","className","otherProps","inputRef","useMergedRef","switchContainerClassName","cn","switchClassName","switchThumbClassName","SwitchPrimitive","isDisabled","isReadOnly","isSelected","defaultSelected","displayName"],"mappings":";;;;;MA2BaA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAMA,CAACE,KAAkB,EAAEC,GAAgC;EACvG,MAAM;IAAEC,OAAO;IAAEC,cAAc;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,SAAS;IAAE,GAAGC;GAAY,GAAGV,KAAK;EAEjH,MAAMW,QAAQ,GAAGC,YAAY,CAAmBX,GAAG,CAAC;EAEpD,MAAMY,wBAAwB,GAAGC,EAAE,CAC/B,uBAAuB,EACvB,kEAAkE,CACrE;EAED,MAAMC,eAAe,GAAGD,EAAE,CACtB,gFAAgF,EAChF,qCAAqC,EACrC;IACI,MAAM,EAAE,CAAC,CAACT;GACb,EACD,yBAAyB;;EAEzB,mCAAmC;;EAEnC,+CAA+C;;EAE/C,gFAAgF;;EAEhF,6DAA6D,EAC7DI,SAAS,CACZ;EAED,MAAMO,oBAAoB,GAAGF,EAAE,CAC3B,2HAA2H,EAC3H,kCAAkC,EAClC,4CAA4C,CAC/C;EAED,oBACIf,cAACkB,QAAe,oBACRP,UAAU;IACdD,SAAS,EAAEI,wBAAwB;iBACzB,kBAAkB;IAC5BF,QAAQ,EAAEA,QAAQ;IAClBO,UAAU,EAAEX,QAAQ;IACpBY,UAAU,EAAEf,QAAQ;IACpBgB,UAAU,EAAElB,OAAO;IACnBmB,eAAe,EAAElB,cAAc;IAC/BG,QAAQ,EAAEA;mBACVP;IAAMU,SAAS,EAAEM,eAAe;iBAAY,QAAQ;IAACP,OAAO,EAAEA;kBAC1DT;IAAMU,SAAS,EAAEO;IAAwB,CACtC,EACNX,KAAK,CACQ;AAE1B,CAAC;AACDP,MAAM,CAACwB,WAAW,GAAG,QAAQ;;;;"}