@economic/taco 2.53.0-settings.6 → 2.53.0-settings.8

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 (442) 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/Datepicker/Datepicker.d.ts +1 -1
  17. package/dist/components/Dialog/components/Content.d.ts +1 -1
  18. package/dist/components/Dialog/components/DialogDrawer.d.ts +2 -2
  19. package/dist/components/Drawer/components/Content.d.ts +2 -2
  20. package/dist/components/Header/components/Agreement/Badge.d.ts +1 -1
  21. package/dist/components/Header/components/Agreement/Display.d.ts +2 -2
  22. package/dist/components/Header/components/Agreement/Item.d.ts +2 -2
  23. package/dist/components/Header/components/AgreementSelector.d.ts +2 -2
  24. package/dist/components/Header/components/Button.d.ts +1 -1
  25. package/dist/components/HoverCard/HoverCard.d.ts +1 -1
  26. package/dist/components/Icon/components/AccountPreview.d.ts +1 -1
  27. package/dist/components/Icon/components/Accounting.d.ts +1 -1
  28. package/dist/components/Icon/components/AccountingYear.d.ts +1 -1
  29. package/dist/components/Icon/components/AccountingYearCancel.d.ts +1 -1
  30. package/dist/components/Icon/components/AiChatSolid.d.ts +1 -1
  31. package/dist/components/Icon/components/AiStars.d.ts +1 -1
  32. package/dist/components/Icon/components/ArrowBottom.d.ts +1 -1
  33. package/dist/components/Icon/components/ArrowDown.d.ts +1 -1
  34. package/dist/components/Icon/components/ArrowEnd.d.ts +1 -1
  35. package/dist/components/Icon/components/ArrowLeft.d.ts +1 -1
  36. package/dist/components/Icon/components/ArrowRight.d.ts +1 -1
  37. package/dist/components/Icon/components/ArrowStart.d.ts +1 -1
  38. package/dist/components/Icon/components/ArrowTop.d.ts +1 -1
  39. package/dist/components/Icon/components/ArrowUp.d.ts +1 -1
  40. package/dist/components/Icon/components/Attach.d.ts +1 -1
  41. package/dist/components/Icon/components/AttachAuto.d.ts +1 -1
  42. package/dist/components/Icon/components/AttachCancel.d.ts +1 -1
  43. package/dist/components/Icon/components/AttachWarning.d.ts +1 -1
  44. package/dist/components/Icon/components/Autopay.d.ts +1 -1
  45. package/dist/components/Icon/components/AutopayPaused.d.ts +1 -1
  46. package/dist/components/Icon/components/Autotext.d.ts +1 -1
  47. package/dist/components/Icon/components/AutotextInsert.d.ts +1 -1
  48. package/dist/components/Icon/components/Basic.d.ts +1 -1
  49. package/dist/components/Icon/components/BasicTabs.d.ts +1 -1
  50. package/dist/components/Icon/components/BellSolid.d.ts +1 -1
  51. package/dist/components/Icon/components/Book.d.ts +1 -1
  52. package/dist/components/Icon/components/Booking.d.ts +1 -1
  53. package/dist/components/Icon/components/Budget.d.ts +1 -1
  54. package/dist/components/Icon/components/Calendar.d.ts +1 -1
  55. package/dist/components/Icon/components/CashAccount.d.ts +1 -1
  56. package/dist/components/Icon/components/CashReports.d.ts +1 -1
  57. package/dist/components/Icon/components/ChartArea.d.ts +1 -1
  58. package/dist/components/Icon/components/ChartBar.d.ts +1 -1
  59. package/dist/components/Icon/components/ChartLine.d.ts +1 -1
  60. package/dist/components/Icon/components/ChartPie.d.ts +1 -1
  61. package/dist/components/Icon/components/ChartTable.d.ts +1 -1
  62. package/dist/components/Icon/components/Chat.d.ts +1 -1
  63. package/dist/components/Icon/components/ChatSolid.d.ts +1 -1
  64. package/dist/components/Icon/components/ChevronDown.d.ts +1 -1
  65. package/dist/components/Icon/components/ChevronDownDouble.d.ts +1 -1
  66. package/dist/components/Icon/components/ChevronDownSolid.d.ts +1 -1
  67. package/dist/components/Icon/components/ChevronLeft.d.ts +1 -1
  68. package/dist/components/Icon/components/ChevronLeftDouble.d.ts +1 -1
  69. package/dist/components/Icon/components/ChevronLeftSolid.d.ts +1 -1
  70. package/dist/components/Icon/components/ChevronRight.d.ts +1 -1
  71. package/dist/components/Icon/components/ChevronRightDouble.d.ts +1 -1
  72. package/dist/components/Icon/components/ChevronRightSolid.d.ts +1 -1
  73. package/dist/components/Icon/components/ChevronUp.d.ts +1 -1
  74. package/dist/components/Icon/components/ChevronUpDouble.d.ts +1 -1
  75. package/dist/components/Icon/components/ChevronUpSolid.d.ts +1 -1
  76. package/dist/components/Icon/components/CircleClose.d.ts +1 -1
  77. package/dist/components/Icon/components/CircleInformation.d.ts +1 -1
  78. package/dist/components/Icon/components/CircleMinus.d.ts +1 -1
  79. package/dist/components/Icon/components/CirclePlus.d.ts +1 -1
  80. package/dist/components/Icon/components/CircleQuestionmark.d.ts +1 -1
  81. package/dist/components/Icon/components/CircleTick.d.ts +1 -1
  82. package/dist/components/Icon/components/CircleWarning.d.ts +1 -1
  83. package/dist/components/Icon/components/Clamp.d.ts +1 -1
  84. package/dist/components/Icon/components/ClampOpen.d.ts +1 -1
  85. package/dist/components/Icon/components/Close.d.ts +1 -1
  86. package/dist/components/Icon/components/ColumnFreeze.d.ts +1 -1
  87. package/dist/components/Icon/components/ColumnUnfreeze.d.ts +1 -1
  88. package/dist/components/Icon/components/Columns.d.ts +1 -1
  89. package/dist/components/Icon/components/ConnectionEnable.d.ts +1 -1
  90. package/dist/components/Icon/components/ConnectionRevoke.d.ts +1 -1
  91. package/dist/components/Icon/components/Contacts.d.ts +1 -1
  92. package/dist/components/Icon/components/Copy.d.ts +1 -1
  93. package/dist/components/Icon/components/Courses.d.ts +1 -1
  94. package/dist/components/Icon/components/Credit.d.ts +1 -1
  95. package/dist/components/Icon/components/Delete.d.ts +1 -1
  96. package/dist/components/Icon/components/DeletePermanently.d.ts +1 -1
  97. package/dist/components/Icon/components/Depecriate.d.ts +1 -1
  98. package/dist/components/Icon/components/Developer.d.ts +1 -1
  99. package/dist/components/Icon/components/DistributionTemplate.d.ts +1 -1
  100. package/dist/components/Icon/components/Document.d.ts +1 -1
  101. package/dist/components/Icon/components/DocumentApprove.d.ts +1 -1
  102. package/dist/components/Icon/components/DocumentCreateEntry.d.ts +1 -1
  103. package/dist/components/Icon/components/DocumentCut.d.ts +1 -1
  104. package/dist/components/Icon/components/DocumentError.d.ts +1 -1
  105. package/dist/components/Icon/components/DocumentIsolatePage.d.ts +1 -1
  106. package/dist/components/Icon/components/DocumentMerge.d.ts +1 -1
  107. package/dist/components/Icon/components/DocumentMove.d.ts +1 -1
  108. package/dist/components/Icon/components/DocumentPreview.d.ts +1 -1
  109. package/dist/components/Icon/components/DocumentReceived.d.ts +1 -1
  110. package/dist/components/Icon/components/DocumentRejectedRequest.d.ts +1 -1
  111. package/dist/components/Icon/components/DocumentSigned.d.ts +1 -1
  112. package/dist/components/Icon/components/DocumentSignedSolid.d.ts +1 -1
  113. package/dist/components/Icon/components/DocumentSplit.d.ts +1 -1
  114. package/dist/components/Icon/components/DocumentTime.d.ts +1 -1
  115. package/dist/components/Icon/components/Download.d.ts +1 -1
  116. package/dist/components/Icon/components/Drag.d.ts +1 -1
  117. package/dist/components/Icon/components/ECopedia.d.ts +1 -1
  118. package/dist/components/Icon/components/Edit.d.ts +1 -1
  119. package/dist/components/Icon/components/EditSimple.d.ts +1 -1
  120. package/dist/components/Icon/components/EllipsisHorizontal.d.ts +1 -1
  121. package/dist/components/Icon/components/EllipsisVertical.d.ts +1 -1
  122. package/dist/components/Icon/components/EntriesOnAccount.d.ts +1 -1
  123. package/dist/components/Icon/components/EntriesOpen.d.ts +1 -1
  124. package/dist/components/Icon/components/EntriesWarning.d.ts +1 -1
  125. package/dist/components/Icon/components/EntryTypeCustomerInvoice.d.ts +1 -1
  126. package/dist/components/Icon/components/EntryTypeCustomerPayment.d.ts +1 -1
  127. package/dist/components/Icon/components/EntryTypeJournalEntry.d.ts +1 -1
  128. package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.d.ts +1 -1
  129. package/dist/components/Icon/components/EntryTypeSupplierInvoice.d.ts +1 -1
  130. package/dist/components/Icon/components/EntryTypeSupplierPayment.d.ts +1 -1
  131. package/dist/components/Icon/components/Envelope.d.ts +1 -1
  132. package/dist/components/Icon/components/EnvelopeApproved.d.ts +1 -1
  133. package/dist/components/Icon/components/EnvelopeSolid.d.ts +1 -1
  134. package/dist/components/Icon/components/ExpandView.d.ts +1 -1
  135. package/dist/components/Icon/components/Expenses.d.ts +1 -1
  136. package/dist/components/Icon/components/Experiment.d.ts +1 -1
  137. package/dist/components/Icon/components/Export.d.ts +1 -1
  138. package/dist/components/Icon/components/ExportToExcel.d.ts +1 -1
  139. package/dist/components/Icon/components/ExportToPdf.d.ts +1 -1
  140. package/dist/components/Icon/components/EyeOff.d.ts +1 -1
  141. package/dist/components/Icon/components/EyeOn.d.ts +1 -1
  142. package/dist/components/Icon/components/Filter.d.ts +1 -1
  143. package/dist/components/Icon/components/FilterSolid.d.ts +1 -1
  144. package/dist/components/Icon/components/FontSize.d.ts +1 -1
  145. package/dist/components/Icon/components/GraphSolid.d.ts +1 -1
  146. package/dist/components/Icon/components/Hash.d.ts +1 -1
  147. package/dist/components/Icon/components/HeightExtraTall.d.ts +1 -1
  148. package/dist/components/Icon/components/HeightMedium.d.ts +1 -1
  149. package/dist/components/Icon/components/HeightShort.d.ts +1 -1
  150. package/dist/components/Icon/components/HeightTall.d.ts +1 -1
  151. package/dist/components/Icon/components/House.d.ts +1 -1
  152. package/dist/components/Icon/components/HouseSolid.d.ts +1 -1
  153. package/dist/components/Icon/components/Id.d.ts +1 -1
  154. package/dist/components/Icon/components/Images.d.ts +1 -1
  155. package/dist/components/Icon/components/Import.d.ts +1 -1
  156. package/dist/components/Icon/components/Inbox.d.ts +1 -1
  157. package/dist/components/Icon/components/InboxEinvoicing.d.ts +1 -1
  158. package/dist/components/Icon/components/InboxScanning.d.ts +1 -1
  159. package/dist/components/Icon/components/InboxSmart.d.ts +1 -1
  160. package/dist/components/Icon/components/Info.d.ts +1 -1
  161. package/dist/components/Icon/components/Inventory.d.ts +1 -1
  162. package/dist/components/Icon/components/InventoryMatrix.d.ts +1 -1
  163. package/dist/components/Icon/components/JournalPro.d.ts +1 -1
  164. package/dist/components/Icon/components/Layout.d.ts +1 -1
  165. package/dist/components/Icon/components/LayoutBoth.d.ts +1 -1
  166. package/dist/components/Icon/components/LayoutFirst.d.ts +1 -1
  167. package/dist/components/Icon/components/LayoutLast.d.ts +1 -1
  168. package/dist/components/Icon/components/LayoutNone.d.ts +1 -1
  169. package/dist/components/Icon/components/LedgerCard.d.ts +1 -1
  170. package/dist/components/Icon/components/LedgerCardCustomerReminder.d.ts +1 -1
  171. package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.d.ts +1 -1
  172. package/dist/components/Icon/components/LedgerCardObsoleteStock.d.ts +1 -1
  173. package/dist/components/Icon/components/LedgerCardOpeningEntry.d.ts +1 -1
  174. package/dist/components/Icon/components/LedgerCardReservedEntry.d.ts +1 -1
  175. package/dist/components/Icon/components/LedgerCardShrinkagePilferage.d.ts +1 -1
  176. package/dist/components/Icon/components/LedgerCardStockAdjustment.d.ts +1 -1
  177. package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.d.ts +1 -1
  178. package/dist/components/Icon/components/Lightbulb.d.ts +1 -1
  179. package/dist/components/Icon/components/Line.d.ts +1 -1
  180. package/dist/components/Icon/components/LinkExternal.d.ts +1 -1
  181. package/dist/components/Icon/components/List.d.ts +1 -1
  182. package/dist/components/Icon/components/ListBulleted.d.ts +1 -1
  183. package/dist/components/Icon/components/ListSearch.d.ts +1 -1
  184. package/dist/components/Icon/components/Location.d.ts +1 -1
  185. package/dist/components/Icon/components/Lock.d.ts +1 -1
  186. package/dist/components/Icon/components/LockOpen.d.ts +1 -1
  187. package/dist/components/Icon/components/Log.d.ts +1 -1
  188. package/dist/components/Icon/components/LogOut.d.ts +1 -1
  189. package/dist/components/Icon/components/Market.d.ts +1 -1
  190. package/dist/components/Icon/components/MastercardOs.d.ts +1 -1
  191. package/dist/components/Icon/components/MatchAmount.d.ts +1 -1
  192. package/dist/components/Icon/components/MatchEntries.d.ts +1 -1
  193. package/dist/components/Icon/components/Menu.d.ts +1 -1
  194. package/dist/components/Icon/components/Mileage.d.ts +1 -1
  195. package/dist/components/Icon/components/ModalResize.d.ts +1 -1
  196. package/dist/components/Icon/components/ModalShrink.d.ts +1 -1
  197. package/dist/components/Icon/components/More.d.ts +1 -1
  198. package/dist/components/Icon/components/MoreSolid.d.ts +1 -1
  199. package/dist/components/Icon/components/Move.d.ts +1 -1
  200. package/dist/components/Icon/components/NavigationList.d.ts +1 -1
  201. package/dist/components/Icon/components/Note.d.ts +1 -1
  202. package/dist/components/Icon/components/NoteFollowUp.d.ts +1 -1
  203. package/dist/components/Icon/components/NoteRead.d.ts +1 -1
  204. package/dist/components/Icon/components/NovemberFirst.d.ts +1 -1
  205. package/dist/components/Icon/components/Numbers.d.ts +1 -1
  206. package/dist/components/Icon/components/PartnerApi.d.ts +1 -1
  207. package/dist/components/Icon/components/PaymentPaid.d.ts +1 -1
  208. package/dist/components/Icon/components/PaymentUnpaid.d.ts +1 -1
  209. package/dist/components/Icon/components/Period.d.ts +1 -1
  210. package/dist/components/Icon/components/Person.d.ts +1 -1
  211. package/dist/components/Icon/components/PersonChange.d.ts +1 -1
  212. package/dist/components/Icon/components/PersonMinus.d.ts +1 -1
  213. package/dist/components/Icon/components/PersonPlus.d.ts +1 -1
  214. package/dist/components/Icon/components/PersonSolid.d.ts +1 -1
  215. package/dist/components/Icon/components/PersonTick.d.ts +1 -1
  216. package/dist/components/Icon/components/Phone.d.ts +1 -1
  217. package/dist/components/Icon/components/PhoneSolid.d.ts +1 -1
  218. package/dist/components/Icon/components/Play.d.ts +1 -1
  219. package/dist/components/Icon/components/PlusMinus.d.ts +1 -1
  220. package/dist/components/Icon/components/Print.d.ts +1 -1
  221. package/dist/components/Icon/components/ProcessPayment.d.ts +1 -1
  222. package/dist/components/Icon/components/ProductLedgerCard.d.ts +1 -1
  223. package/dist/components/Icon/components/Profile.d.ts +1 -1
  224. package/dist/components/Icon/components/ProjectCards.d.ts +1 -1
  225. package/dist/components/Icon/components/Projects.d.ts +1 -1
  226. package/dist/components/Icon/components/QuestionMark.d.ts +1 -1
  227. package/dist/components/Icon/components/QuestionMarkBold.d.ts +1 -1
  228. package/dist/components/Icon/components/Quicklinks.d.ts +1 -1
  229. package/dist/components/Icon/components/RatingBankruptcy.d.ts +1 -1
  230. package/dist/components/Icon/components/RatingPaymentProblems.d.ts +1 -1
  231. package/dist/components/Icon/components/Reconciled.d.ts +1 -1
  232. package/dist/components/Icon/components/Refresh.d.ts +1 -1
  233. package/dist/components/Icon/components/Report.d.ts +1 -1
  234. package/dist/components/Icon/components/ReportSolid.d.ts +1 -1
  235. package/dist/components/Icon/components/Restore.d.ts +1 -1
  236. package/dist/components/Icon/components/RotateLeft.d.ts +1 -1
  237. package/dist/components/Icon/components/RotateRight.d.ts +1 -1
  238. package/dist/components/Icon/components/Sales.d.ts +1 -1
  239. package/dist/components/Icon/components/Search.d.ts +1 -1
  240. package/dist/components/Icon/components/SearchBold.d.ts +1 -1
  241. package/dist/components/Icon/components/Secure.d.ts +1 -1
  242. package/dist/components/Icon/components/SecureTick.d.ts +1 -1
  243. package/dist/components/Icon/components/Settings.d.ts +1 -1
  244. package/dist/components/Icon/components/SettingsSolid.d.ts +1 -1
  245. package/dist/components/Icon/components/Shortcuts.d.ts +1 -1
  246. package/dist/components/Icon/components/ShowAll.d.ts +1 -1
  247. package/dist/components/Icon/components/ShowLess.d.ts +1 -1
  248. package/dist/components/Icon/components/ShowMore.d.ts +1 -1
  249. package/dist/components/Icon/components/ShowTemplate.d.ts +1 -1
  250. package/dist/components/Icon/components/Sliders.d.ts +1 -1
  251. package/dist/components/Icon/components/Smartpay.d.ts +1 -1
  252. package/dist/components/Icon/components/SortBy.d.ts +1 -1
  253. package/dist/components/Icon/components/Star.d.ts +1 -1
  254. package/dist/components/Icon/components/StarSolid.d.ts +1 -1
  255. package/dist/components/Icon/components/Subscriptions.d.ts +1 -1
  256. package/dist/components/Icon/components/SystemEntries.d.ts +1 -1
  257. package/dist/components/Icon/components/Tag.d.ts +1 -1
  258. package/dist/components/Icon/components/TemplateOverride.d.ts +1 -1
  259. package/dist/components/Icon/components/Templates.d.ts +1 -1
  260. package/dist/components/Icon/components/ThumbBoth.d.ts +1 -1
  261. package/dist/components/Icon/components/ThumbDown.d.ts +1 -1
  262. package/dist/components/Icon/components/ThumbDownSolid.d.ts +1 -1
  263. package/dist/components/Icon/components/ThumbUp.d.ts +1 -1
  264. package/dist/components/Icon/components/ThumbUpSolid.d.ts +1 -1
  265. package/dist/components/Icon/components/Tick.d.ts +1 -1
  266. package/dist/components/Icon/components/TickBold.d.ts +1 -1
  267. package/dist/components/Icon/components/Time.d.ts +1 -1
  268. package/dist/components/Icon/components/Transfer.d.ts +1 -1
  269. package/dist/components/Icon/components/TransferCancel.d.ts +1 -1
  270. package/dist/components/Icon/components/TransferLocked.d.ts +1 -1
  271. package/dist/components/Icon/components/Undo.d.ts +1 -1
  272. package/dist/components/Icon/components/Undock.d.ts +1 -1
  273. package/dist/components/Icon/components/Unreconciled.d.ts +1 -1
  274. package/dist/components/Icon/components/Wallet.d.ts +1 -1
  275. package/dist/components/Icon/components/Warning.d.ts +1 -1
  276. package/dist/components/Icon/components/Webshop.d.ts +1 -1
  277. package/dist/components/Icon/components/Website.d.ts +1 -1
  278. package/dist/components/Icon/components/Workflow.d.ts +1 -1
  279. package/dist/components/Icon/components/WorkflowTemplateBasic.d.ts +1 -1
  280. package/dist/components/Icon/components/Zoom.d.ts +1 -1
  281. package/dist/components/IconButton/IconButton.d.ts +2 -2
  282. package/dist/components/Input/Input.d.ts +2 -2
  283. package/dist/components/Input/util.d.ts +7 -1
  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 +3 -3
  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 +8 -8
  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/Navigation2/components/Group.d.ts +1 -1
  304. package/dist/components/Popover/Popover.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/Table3/Table3.d.ts +3 -4
  320. package/dist/components/Table3/components/Columns/Cell/Cell.d.ts +2 -2
  321. package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.d.ts +1 -1
  322. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.d.ts +2 -2
  323. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
  324. package/dist/components/Table3/components/Editing/Alert.d.ts +1 -1
  325. package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +2 -2
  326. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +1 -1
  327. package/dist/components/Table3/components/Row/Editing/SaveStatus.d.ts +2 -2
  328. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +1 -1
  329. package/dist/components/Table3/components/Row/Row.d.ts +2 -2
  330. package/dist/components/Table3/components/Toolbar/Editing/Editing.d.ts +1 -1
  331. package/dist/components/Tag/Tag.d.ts +2 -2
  332. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  333. package/dist/components/Tour/Tour.d.ts +1 -1
  334. package/dist/components/Truncate/Truncate.d.ts +1 -1
  335. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -1
  336. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -1
  337. package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -1
  338. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +9 -6
  339. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  340. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  341. package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
  342. package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -1
  343. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +1 -1
  344. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  345. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  346. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
  347. package/dist/esm/packages/taco/src/components/Layout/components/Top.js +2 -2
  348. package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -1
  349. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  350. package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
  351. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
  352. package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
  353. package/dist/esm/packages/taco/src/components/Report/Report.js +2 -3
  354. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  355. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +4 -4
  356. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
  357. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  358. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  359. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +0 -2
  360. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  361. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  362. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  363. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  364. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
  365. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  366. package/dist/esm/packages/taco/src/components/Table3/Table3.js +1 -3
  367. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  368. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  369. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +4 -2
  370. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  371. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +4 -1
  372. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  373. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  374. package/dist/esm/packages/taco/src/components/Toast/Toast.js.map +1 -1
  375. package/dist/esm/packages/taco/src/components/Tour/Tour.js +1 -1
  376. package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
  377. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
  378. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js +2 -0
  379. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js.map +1 -1
  380. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js +4 -4
  381. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js.map +1 -1
  382. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -2
  383. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  384. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Resizer.js.map +1 -1
  385. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/SortIndicator.js.map +1 -1
  386. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +6 -14
  387. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  388. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
  389. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  390. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  391. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
  392. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
  393. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +12 -45
  394. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  395. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  396. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -1
  397. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -3
  398. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
  399. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.js.map +1 -1
  400. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  401. package/dist/esm/packages/taco/src/utils/dom.js +3 -2
  402. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  403. package/dist/primitives/BubbleSelect.d.ts +1 -1
  404. package/dist/primitives/Sortable/components/Container.d.ts +2 -2
  405. package/dist/primitives/Sortable/components/Item.d.ts +2 -1
  406. package/dist/primitives/Sortable/components/List.d.ts +1 -1
  407. package/dist/primitives/Table/Core/Table.d.ts +2 -2
  408. package/dist/primitives/Table/Core/components/Body/Body.d.ts +1 -1
  409. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -1
  410. package/dist/primitives/Table/Core/components/Body/util.d.ts +4 -4
  411. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.d.ts +2 -2
  412. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.d.ts +2 -2
  413. package/dist/primitives/Table/Core/components/Columns/Cell/Cell.d.ts +1 -1
  414. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +2 -2
  415. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  416. package/dist/primitives/Table/Core/components/Footer/Summary.d.ts +2 -2
  417. package/dist/primitives/Table/Core/components/Header/Header.d.ts +1 -1
  418. package/dist/primitives/Table/Core/components/Header/components/Goto.d.ts +2 -2
  419. package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -1
  420. package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +2 -2
  421. package/dist/primitives/Table/Core/components/Header/components/SortIndicator.d.ts +3 -3
  422. package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
  423. package/dist/primitives/Table/Core/components/Row/Row.d.ts +1 -1
  424. package/dist/primitives/Table/Core/components/Toolbar/Toolbar.d.ts +1 -1
  425. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.d.ts +2 -2
  426. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.d.ts +2 -2
  427. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
  428. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
  429. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.d.ts +2 -2
  430. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.d.ts +2 -2
  431. package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.d.ts +1 -1
  432. package/dist/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.d.ts +2 -2
  433. package/dist/primitives/Table/Core/components/Toolbar/components/Search/Search.d.ts +1 -1
  434. package/dist/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.d.ts +2 -2
  435. package/dist/primitives/Table/Core/components/Toolbar/components/Settings/Settings.d.ts +2 -2
  436. package/dist/primitives/Table/Core/types.d.ts +1 -1
  437. package/dist/taco.cjs.development.js +60 -95
  438. package/dist/taco.cjs.development.js.map +1 -1
  439. package/dist/taco.cjs.production.min.js +1 -1
  440. package/dist/taco.cjs.production.min.js.map +1 -1
  441. package/dist/utils/dom.d.ts +2 -2
  442. package/package.json +26 -27
@@ -1 +1 @@
1
- {"version":3,"file":"Settings.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Menu } from '../../../../../../../components/Menu/Menu';\nimport { HideOrOrderPopover } from './HideOrOrderPopover';\nimport { getSettings } from '../../../../../useTableManager/util/settings';\nimport { FontSizes } from '../../../../../../../types';\nimport { IconName } from '../../../../../../../components/Icon/Icon';\nimport { TableCustomSettingsRenderer } from '../../../../../types';\n\nexport type SettingsProps<TType = unknown> = {\n customSettings?: TableCustomSettingsRenderer;\n table: ReactTable<TType>;\n};\n\nexport function Settings<TType = unknown>(props: SettingsProps<TType>) {\n const { customSettings, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const canHideOrOrder = table.options.enableHiding || tableMeta.columnOrdering.isEnabled;\n const canChangeFontSize = tableMeta.fontSize.isEnabled;\n const canChangeRowHeight = tableMeta.rowHeight.isEnabled;\n\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'columnSettings': {\n if (canHideOrOrder) {\n popoverElement = popoverProps => (\n <HideOrOrderPopover {...popoverProps} open onChange={handleClosePopover} table={table} />\n );\n }\n }\n }\n }\n\n return (\n <IconButton\n aria-label={texts.table.otherOptions.tooltip}\n icon=\"sliders\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <Menu {...menuProps}>\n <Menu.Content align=\"end\">\n {canHideOrOrder ? (\n <Menu.Item icon=\"columns\" onClick={() => setPopover('columnSettings')}>\n {texts.table.columnSettings.button}\n </Menu.Item>\n ) : null}\n {canHideOrOrder && (canChangeRowHeight || canChangeFontSize || customSettings) ? (\n <Menu.Separator />\n ) : null}\n {canChangeRowHeight ? (\n <Menu.Item\n icon={`height-${tableMeta.rowHeight.height}` as IconName}\n subMenu={() => <RowHeightMenuItem tableMeta={tableMeta} />}>\n {texts.table.rowHeight.tooltip}\n </Menu.Item>\n ) : null}\n {canChangeFontSize ? (\n <Menu.Item icon=\"font-size\" subMenu={() => <FontSizeMenuItem tableMeta={tableMeta} />}>\n {texts.table.fontSize.tooltip}\n </Menu.Item>\n ) : null}\n\n {customSettings ? (\n <>\n {canChangeRowHeight || canChangeFontSize ? <Menu.Separator /> : null}\n {customSettings(getSettings(table)).map((item, index) => (\n <React.Fragment key={index}>{item}</React.Fragment>\n ))}\n </>\n ) : null}\n </Menu.Content>\n </Menu>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n tooltip={texts.table.otherOptions.tooltip}\n />\n );\n}\n\nfunction FontSizeMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.fontSize.setSize as any} value={tableMeta.fontSize.size}>\n <Menu.RadioGroup.Item value={FontSizes.small}>{texts.table.fontSize.sizes.small}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value={FontSizes.medium}>{texts.table.fontSize.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item disabled={tableMeta.rowHeight.height === 'short'} value={FontSizes.large}>\n {texts.table.fontSize.sizes.large}\n </Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n\nfunction RowHeightMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.rowHeight.setHeight as any} value={tableMeta.rowHeight.height}>\n <Menu.RadioGroup.Item value=\"short\">{texts.table.rowHeight.sizes.short}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"medium\">{texts.table.rowHeight.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"tall\">{texts.table.rowHeight.sizes.tall}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"extra-tall\">{texts.table.rowHeight.sizes.extraTall}</Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n"],"names":["Settings","props","customSettings","table","texts","useLocalization","tableMeta","options","meta","canHideOrOrder","enableHiding","columnOrdering","isEnabled","canChangeFontSize","fontSize","canChangeRowHeight","rowHeight","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","popoverProps","HideOrOrderPopover","open","onChange","IconButton","otherOptions","tooltip","icon","menu","menuProps","Menu","Content","align","Item","onClick","columnSettings","button","Separator","height","subMenu","RowHeightMenuItem","FontSizeMenuItem","getSettings","map","item","index","Fragment","key","onClickCapture","event","preventDefault","SubMenu","RadioGroup","setSize","value","size","FontSizes","small","sizes","medium","disabled","large","setHeight","short","tall","extraTall"],"mappings":";;;;;;;;SAgBgBA,QAAQA,CAAkBC,KAA2B;EACjE,MAAM;IAAEC,cAAc;IAAEC;GAAO,GAAGF,KAAK;EACvC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAE7D,MAAMC,cAAc,GAAGN,KAAK,CAACI,OAAO,CAACG,YAAY,IAAIJ,SAAS,CAACK,cAAc,CAACC,SAAS;EACvF,MAAMC,iBAAiB,GAAGP,SAAS,CAACQ,QAAQ,CAACF,SAAS;EACtD,MAAMG,kBAAk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;KAAS3D,KAAK,CAACD,KAAK,CAACW,QAAQ,CAACgD,KAAK,CAACC,MAAM,CAAwB,eACzG5C,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAAC2B,QAAQ,EAAE1D,SAAS,CAACU,SAAS,CAAC0B,MAAM,KAAK,OAAO;IAAEgB,KAAK,EAAEE,SAAS,CAACK;KACpF7D,KAAK,CAACD,KAAK,CAACW,QAAQ,CAACgD,KAAK,CAACG,KAAK,CACd,CACT,CACP;AAEvB;AAEA,SAASrB,iBAAiBA,CAAkB;EAAEtC;CAAiD;EAC3F,MAAM;IAAEF;GAAO,GAAGC,eAAe,EAAE;EAEnC,oBACIc,6BAACe,IAAI,CAACqB,OAAO,qBACTpC,6BAACe,IAAI,CAACsB,UAAU;IAAC7B,QAAQ,EAAErB,SAAS,CAACU,SAAS,CAACkD,SAAgB;IAAER,KAAK,EAAEpD,SAAS,CAACU,SAAS,CAAC0B;kBACxFvB,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAStD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACK,KAAK,CAAwB,eAC9FhD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAUtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACC,MAAM,CAAwB,eAChG5C,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAQtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACM,IAAI,CAAwB,eAC5FjD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAActD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACO,SAAS,CAAwB,CACzF,CACP;AAEvB;;;;"}
1
+ {"version":3,"file":"Settings.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Menu } from '../../../../../../../components/Menu/Menu';\nimport { HideOrOrderPopover } from './HideOrOrderPopover';\nimport { getSettings } from '../../../../../useTableManager/util/settings';\nimport { FontSizes } from '../../../../../../../types';\nimport { IconName } from '../../../../../../../components/Icon/Icon';\nimport { TableCustomSettingsRenderer } from '../../../../../types';\nimport { PopoverProps } from '../../../../../../../components/Popover/Popover';\n\nexport type SettingsProps<TType = unknown> = {\n customSettings?: TableCustomSettingsRenderer;\n table: ReactTable<TType>;\n};\n\nexport function Settings<TType = unknown>(props: SettingsProps<TType>) {\n const { customSettings, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const canHideOrOrder = table.options.enableHiding || tableMeta.columnOrdering.isEnabled;\n const canChangeFontSize = tableMeta.fontSize.isEnabled;\n const canChangeRowHeight = tableMeta.rowHeight.isEnabled;\n\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'columnSettings': {\n if (canHideOrOrder) {\n popoverElement = (popoverProps: PopoverProps) => (\n <HideOrOrderPopover {...popoverProps} open onChange={handleClosePopover} table={table} />\n );\n }\n }\n }\n }\n\n return (\n <IconButton\n aria-label={texts.table.otherOptions.tooltip}\n icon=\"sliders\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <Menu {...menuProps}>\n <Menu.Content align=\"end\">\n {canHideOrOrder ? (\n <Menu.Item icon=\"columns\" onClick={() => setPopover('columnSettings')}>\n {texts.table.columnSettings.button}\n </Menu.Item>\n ) : null}\n {canHideOrOrder && (canChangeRowHeight || canChangeFontSize || customSettings) ? (\n <Menu.Separator />\n ) : null}\n {canChangeRowHeight ? (\n <Menu.Item\n icon={`height-${tableMeta.rowHeight.height}` as IconName}\n subMenu={() => <RowHeightMenuItem tableMeta={tableMeta} />}>\n {texts.table.rowHeight.tooltip}\n </Menu.Item>\n ) : null}\n {canChangeFontSize ? (\n <Menu.Item icon=\"font-size\" subMenu={() => <FontSizeMenuItem tableMeta={tableMeta} />}>\n {texts.table.fontSize.tooltip}\n </Menu.Item>\n ) : null}\n\n {customSettings ? (\n <>\n {canChangeRowHeight || canChangeFontSize ? <Menu.Separator /> : null}\n {customSettings(getSettings(table)).map((item, index) => (\n <React.Fragment key={index}>{item}</React.Fragment>\n ))}\n </>\n ) : null}\n </Menu.Content>\n </Menu>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n tooltip={texts.table.otherOptions.tooltip}\n />\n );\n}\n\nfunction FontSizeMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.fontSize.setSize as any} value={tableMeta.fontSize.size}>\n <Menu.RadioGroup.Item value={FontSizes.small}>{texts.table.fontSize.sizes.small}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value={FontSizes.medium}>{texts.table.fontSize.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item disabled={tableMeta.rowHeight.height === 'short'} value={FontSizes.large}>\n {texts.table.fontSize.sizes.large}\n </Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n\nfunction RowHeightMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.rowHeight.setHeight as any} value={tableMeta.rowHeight.height}>\n <Menu.RadioGroup.Item value=\"short\">{texts.table.rowHeight.sizes.short}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"medium\">{texts.table.rowHeight.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"tall\">{texts.table.rowHeight.sizes.tall}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"extra-tall\">{texts.table.rowHeight.sizes.extraTall}</Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n"],"names":["Settings","props","customSettings","table","texts","useLocalization","tableMeta","options","meta","canHideOrOrder","enableHiding","columnOrdering","isEnabled","canChangeFontSize","fontSize","canChangeRowHeight","rowHeight","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","popoverProps","HideOrOrderPopover","open","onChange","IconButton","otherOptions","tooltip","icon","menu","menuProps","Menu","Content","align","Item","onClick","columnSettings","button","Separator","height","subMenu","RowHeightMenuItem","FontSizeMenuItem","getSettings","map","item","index","Fragment","key","onClickCapture","event","preventDefault","SubMenu","RadioGroup","setSize","value","size","FontSizes","small","sizes","medium","disabled","large","setHeight","short","tall","extraTall"],"mappings":";;;;;;;;SAiBgBA,QAAQA,CAAkBC,KAA2B;EACjE,MAAM;IAAEC,cAAc;IAAEC;GAAO,GAAGF,KAAK;EACvC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAE7D,MAAMC,cAAc,GAAGN,KAAK,CAACI,OAAO,CAACG,YAAY,IAAIJ,SAAS,CAACK,cAAc,CAACC,SAAS;EACvF,MAAMC,iBAAiB,GAAGP,SAAS,CAACQ,QAAQ,CAACF,SAAS;EACtD,MAAMG,kBAAkB,GAAGT,SAAS,CAACU,SAAS,CAACJ,SAAS;EAExD,MAAM,CAACK,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBC,SAAS,CAAC;EAE3E,IAAIC,cAAc;EAElB,IAAIL,OAAO,EAAE;IACT,MAAMM,kBAAkB,GAAGA,MAAML,UAAU,CAACG,SAAS,CAAC;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AAK,CAACD,KAAK,CAACW,QAAQ,CAACgD,KAAK,CAACG,KAAK,CACd,CACT,CACP;AAEvB;AAEA,SAASrB,iBAAiBA,CAAkB;EAAEtC;CAAiD;EAC3F,MAAM;IAAEF;GAAO,GAAGC,eAAe,EAAE;EAEnC,oBACIc,6BAACe,IAAI,CAACqB,OAAO,qBACTpC,6BAACe,IAAI,CAACsB,UAAU;IAAC7B,QAAQ,EAAErB,SAAS,CAACU,SAAS,CAACkD,SAAgB;IAAER,KAAK,EAAEpD,SAAS,CAACU,SAAS,CAAC0B;kBACxFvB,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAStD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACK,KAAK,CAAwB,eAC9FhD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAUtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACC,MAAM,CAAwB,eAChG5C,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAQtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACM,IAAI,CAAwB,eAC5FjD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAActD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACO,SAAS,CAAwB,CACzF,CACP;AAEvB;;;;"}
@@ -29,16 +29,13 @@ function getPaddingEndOffset(table, options) {
29
29
  const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
30
30
  return ROW_HEIGHT_ESTIMATES.medium * ((_options$virtualiserP = options === null || options === void 0 ? void 0 : options.virtualiserPaddingEndOffset) !== null && _options$virtualiserP !== void 0 ? _options$virtualiserP : 1) * bottomRows.length;
31
31
  }
32
+ // A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well
33
+ const OVERSCAN_ROW_COUNT = 8;
32
34
  function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
33
35
  var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _virtualItems$end, _virtualItems;
34
36
  const tableMeta = table.options.meta;
35
37
  const isTableRowGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
36
38
  const rows = (_table$getCenterRows = table.getCenterRows()) !== null && _table$getCenterRows !== void 0 ? _table$getCenterRows : [];
37
- // expanded rows
38
- const {
39
- createRowMeasurer,
40
- estimateSize
41
- } = useRowHeightVirtualisation(table);
42
39
  // row groups
43
40
  const rangeExtractor = useRowGroupVirtualisation(table);
44
41
  // account for thead and tfoot in the scroll area - both are always medium row height
@@ -46,15 +43,20 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
46
43
  const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;
47
44
  const virtualiser = useVirtualizer({
48
45
  count,
49
- estimateSize,
46
+ estimateSize: () => {
47
+ return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;
48
+ },
50
49
  getScrollElement: () => tableRef.current,
51
- overscan: tableMeta.printing.isPrinting ? count : undefined,
50
+ overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,
52
51
  rangeExtractor,
53
52
  // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
54
53
  scrollPaddingStart,
55
54
  scrollPaddingEnd: getScrollPaddingEndOffset(table),
56
55
  paddingEnd: getPaddingEndOffset(table, options)
57
56
  });
57
+ React__default.useEffect(() => {
58
+ virtualiser.measure();
59
+ }, [table.getState().expanded]);
58
60
  const totalSize = virtualiser.getTotalSize();
59
61
  const virtualItems = virtualiser.getVirtualItems();
60
62
  const scrollToIndex = React__default.useCallback((index, options = {
@@ -136,7 +138,9 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
136
138
  table: table
137
139
  });
138
140
  }
139
- const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);
141
+ const measureRow = rowHeight => {
142
+ virtualiser.resizeItem(virtualRow, rowHeight);
143
+ };
140
144
  return /*#__PURE__*/React__default.createElement(Row, {
141
145
  key: row.id,
142
146
  row: row,
@@ -155,43 +159,6 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
155
159
  scrollToIndex
156
160
  };
157
161
  }
158
- // support varying row heights - variable row heights, row expansion
159
- function useRowHeightVirtualisation(table) {
160
- const tableMeta = table.options.meta;
161
- const rows = table.getRowModel().rows;
162
- const expandedState = table.getState().expanded;
163
- const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React__default.useState({});
164
- // look at all registered expanded row heights and use them to form a more accurate average size
165
- // it might be worth considering if taking the max, or an upper bound, would be better
166
- const averageExpandedRowHeight = React__default.useMemo(() => {
167
- const values = Object.values(expandedRowHeightsCache);
168
- return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;
169
- }, [expandedRowHeightsCache]);
170
- // row heights
171
- const estimateSize = React__default.useCallback(index => {
172
- var _rows$index, _rows$index$getIsExpa;
173
- const rowHeight = tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;
174
- if (expandedState === true || (_rows$index = rows[index]) !== null && _rows$index !== void 0 && (_rows$index$getIsExpa = _rows$index.getIsExpanded) !== null && _rows$index$getIsExpa !== void 0 && _rows$index$getIsExpa.call(_rows$index)) {
175
- return rowHeight + averageExpandedRowHeight;
176
- }
177
- return rowHeight;
178
- }, [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]);
179
- const createRowMeasurer = React__default.useCallback((resizeItem, virtualRow) => (rowHeight, expansionHeight) => {
180
- // register the expansion height so that it can be used to determine an average
181
- if (expansionHeight) {
182
- setExpandedRowHeightsCache(cache => ({
183
- ...cache,
184
- [virtualRow.index]: expansionHeight
185
- }));
186
- }
187
- // update the whole row's size to include the expanded height
188
- resizeItem(virtualRow, rowHeight + (expansionHeight !== null && expansionHeight !== void 0 ? expansionHeight : 0));
189
- }, []);
190
- return {
191
- estimateSize,
192
- createRowMeasurer
193
- };
194
- }
195
162
  // support virtualised row groups (where the row group headers are sticky)
196
163
  function useRowGroupVirtualisation(table) {
197
164
  const rows = table.getRowModel().rows;
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef, TableDefaultRowActiveIndex } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\nimport { getSettings } from '../../useTableManager/util/settings';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: TableDefaultRowActiveIndex | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex !== undefined) {\n const index =\n typeof defaultRowActiveIndex === 'function' ? defaultRowActiveIndex(getSettings(table)) : defaultRowActiveIndex;\n\n if (index !== undefined) {\n scrollToIndex(index, { align: 'center', behavior: 'auto' });\n }\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n return (\n <SkeletonRow\n key={virtualRow.index}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n />\n );\n }\n\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n range => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","count","server","_experimentalDataLoader2","virtualiser","useVirtualizer","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_virtualItems$end","_virtualItems","end","useEffect","getSettings","style","content","isNaN","map","virtualRow","row","_tableMeta$server$pag","_tableMeta$server$pag2","currentPageIndex","floor","pageSize","pagePosition","pages","indexOf","fakeIndex","_row","original","_virtualiser$scrollDi","SkeletonRow","key","scrollDirection","measureRow","resizeItem","Row","id","_virtualiser$scrollDi2","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;;;AAeA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT,SAAS,CAACa,SAAS,CAACL,MAAM,CAAC,GAAG,GAAG,GAAGG,UAAU,CAACJ,MAAM;;EAGxF,OAAOC,MAAM;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features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef, TableDefaultRowActiveIndex } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\nimport { getSettings } from '../../useTableManager/util/settings';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\n// A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well\nconst OVERSCAN_ROW_COUNT = 8;\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: TableDefaultRowActiveIndex | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize: () => {\n return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;\n },\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n React.useEffect(() => {\n virtualiser.measure();\n }, [table.getState().expanded]);\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex !== undefined) {\n const index =\n typeof defaultRowActiveIndex === 'function' ? defaultRowActiveIndex(getSettings(table)) : defaultRowActiveIndex;\n\n if (index !== undefined) {\n scrollToIndex(index, { align: 'center', behavior: 'auto' });\n }\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n return (\n <SkeletonRow\n key={virtualRow.index}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n />\n );\n }\n\n const measureRow = (rowHeight: number) => {\n virtualiser.resizeItem(virtualRow, rowHeight);\n };\n\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","OVERSCAN_ROW_COUNT","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","count","server","_experimentalDataLoader2","virtualiser","useVirtualizer","estimateSize","getScrollElement","current","overscan","printing","isPrinting","scrollPaddingEnd","paddingEnd","React","useEffect","measure","expanded","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_virtualItems$end","_virtualItems","end","undefined","getSettings","style","content","isNaN","map","virtualRow","row","_tableMeta$server$pag","_tableMeta$server$pag2","currentPageIndex","floor","pageSize","pagePosition","pages","indexOf","fakeIndex","_row","original","_virtualiser$scrollDi","SkeletonRow","key","scrollDirection","measureRow","resizeItem","Row","id","_virtualiser$scrollDi2","renderer","cellRenderer","cell","getRowModel","isTableGrouped","rowGroupIndexes","useMemo","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort","a","b"],"mappings":";;;;;;;AAeA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT,SAAS,CAACa,SAAS,CAACL,MAAM,CAAC,GAAG,GAAG,GAAGG,UAAU,CAACJ,MAAM;;EAGxF,OAAOC,MAAM;AACjB;AAEA;AACA,SAASM,mBAAmBA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B,MAAM;EAEzD,MAAMuG,eAAe,GAAGhE,cAAK,CAACiE,OAAO,CAAC;IAClC,MAAMC,OAAO,GAAa,EAAE;IAE5B,IAAIH,cAAc,EAAE;MAChBlF,IAAI,CAACsF,OAAO,CAAC,CAAC7B,GAAG,EAAE5B,KAAK;QACpB,IAAI4B,GAAG,CAAC8B,YAAY,EAAE,EAAE;UACpBF,OAAO,CAACG,IAAI,CAAC3D,KAAK,CAAC;;OAE1B,CAAC;;IAGN,OAAOwD,OAAO;GACjB,EAAE,CAACrF,IAAI,CAAC,CAAC;;EAGV,MAAMG,cAAc,GAAGgB,cAAK,CAACS,WAAW,CACnC6D,KAAY;;IACT,MAAMC,mBAAmB,IAAAC,aAAA,GACrB,CAAC,GAAGR,eAAe,CAAC,CAACS,OAAO,EAAE,CAACC,IAAI,CAAChE,KAAK,IAAI4D,KAAK,CAACK,UAAU,IAAIjE,KAAK,CAAC,cAAA8D,aAAA,cAAAA,aAAA,GAAIR,eAAe,CAAC,CAAC,CAAC;IAEjG,MAAMY,IAAI,GAAG,IAAIC,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACjB,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAG/E,cAAc,GAAG+C,SAAS;AACtD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n ) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(\n _lastUsedPageIndex.current ?? 0,\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current\n );\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedHiddenColumns","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","hiddenColumns","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","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IAAA2B,sBAAA;;QAEH,OAAOjC,QAAQ,EAAAiC,sBAAA,GAACnC,kBAAkB,CAACQ,OAAO,cAAA2B,sBAAA,cAAAA,sBAAA,GAAI,CAAC,EAAEvC,gBAAgB,CAACY,OAAO,EAAEH,OAAO,EAAEN,sBAAsB,CAACS,OAAO,CAAC;;KAE1H,QAAAkB,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDvC,eAAe,CAACU,OAAO,GAAG6B,MAAM,IAAI9C,SAAS;;;MAE7C,OAAAoB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIlC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACoB,OAAO;IACtBoB,OAAO;IACP1B,QAAQ;IACRoC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB7C;GACH,EACD2C,UAAU,CACb;AACL;;;;"}
1
+ {"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n ) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(\n _lastUsedPageIndex.current ?? 0,\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current\n );\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedHiddenColumns","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","hiddenColumns","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","_lastUsedPageIndex$cu2","handleFilter","_lastUsedPageIndex$cu3","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA6BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5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AA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDvC,eAAe,CAACU,OAAO,GAAG6B,MAAM,IAAI9C,SAAS;;;MAE7C,OAAAoB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIlC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACoB,OAAO;IACtBoB,OAAO;IACP1B,QAAQ;IACRoC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB7C;GACH,EACD2C,UAAU,CACb;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !reset) {\n return;\n }\n\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","_pendingPageRequests","current","Promise","resolve","hasChangedData","JSON","stringify","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2","currentPages","middle","floor","lastUsedPageIndex","includes"],"mappings":";;;;;AAaA,MAAMA,uBAAuB,GAAG,EAAE;SAuClBC,mBAAmBA,CAC/BC,SAA0C,EAC1CC,QAAwC,EACxCC,UAAqC;EA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AACpB;AAEA,SAAST,QAAQA,CAAChC,SAAiB,EAAE+E,iBAAqC,EAAEH,YAAsB,EAAEhD,SAAoB;EACpH,IAAIgD,YAAY,CAACnD,MAAM,KAAKzB,SAAS,KAAK+E,iBAAiB,IAAIH,YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
1
+ {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !reset) {\n return;\n }\n\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","_pendingPageRequests","current","Promise","resolve","hasChangedData","JSON","stringify","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2","currentPages","middle","floor","lastUsedPageIndex","includes"],"mappings":";;;;;AAaA,MAAMA,uBAAuB,GAAG,EAAE;SAuClBC,mBAAmBA,CAC/BC,SAA0C,EAC1CC,QAAwC,EACxCC,UAAqC;EAAEC,QAAQ,EAAEC;CAAmB;QAmBrDC,QAAQ,aACnBC,SAAiB,EACjBC,OAA0B,EAC1BC,OAA4B,EAC5BC,aAAuB,EACvBC,MAA0B,EAC1BC,KAAK,GAAG,KAAK;IAAA;;MAGb,IAAIC,oBAAoB,CAACC,OAAO,CAACP,SAAS,CAAC,IAAI,CAACK,KAAK,EAAE;QACnD,OAAAG,OAAA,CAAAC,OAAA;;MAGJ,MAAMC,cAAc,GAChBC,IAAI,CAACC,SAAS,CAACX,OAAO,CAAC,KAAKU,IAAI,CAACC,SAAS,CAACC,gBAAgB,CAACN,OAAO,CAAC,IACpEI,IAAI,CAACC,SAAS,CAACV,OAAO,CAAC,KAAKS,IAAI,CAACC,SAAS,CAACE,gBAAgB,CAACP,OAAO,CAAC,IACpEH,MAAM,KAAKW,eAAe,CAACR,OAAO;;MAGtC,IAAIS,IAAI,CAACC,KAAK,CAACjB,SAAS,CAAC,IAAIgB,IAAI,CAACC,KAAK,CAACjB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAACU,cAAc,IAAI,CAACL,KAAK,EAAE;QAChF,OAAAG,OAAA,CAAAC,OAAA;;;MAIJ,MAAMS,SAAS,GAAGC,EAAI,EAAE;;MAGxBb,oBAAoB,CAACC,OAAO,CAACP,SAAS,CAAC,GAAG,IAAI;MAAC,MAAAoB,MAAA,GAAAC,MAAA,aAE3C;QACAC,cAAc,CAACf,OAAO,GAAGW,SAAS;QAAC,OAAAV,OAAA,CAAAC,OAAA,CAC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AAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE;MACzD,OAAO,SAAS;KACnB,MAAM,IACHzB,SAAS,KAAK4E,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAChCA,YAAY,CAACnD,MAAM,KAAK,CAAC,IAAImD,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI5E,SAAS,KAAK4E,YAAY,CAAC,CAAC,CAAE,EACvF;MACE,OAAO,UAAU;;;EAIzB,OAAOnC,SAAS;AACpB;AAEA,SAAST,QAAQA,CAAChC,SAAiB,EAAE+E,iBAAqC,EAAEH,YAAsB,EAAEhD,SAAoB;EACpH,IAAIgD,YAAY,CAACnD,MAAM,KAAKzB,SAAS,KAAK+E,iBAAiB,IAAIH,YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
@@ -12,10 +12,10 @@ function useTableSearch(isEnabled = false, onChangeSearch, defaultEnableGlobalFi
12
12
  // react-table doesn't re-render when options.enableGlobalFilter changes, so for now we force it
13
13
  const currentFilter = instance.getState().globalFilter;
14
14
  if (currentFilter) {
15
- setTimeout(() => {
16
- instance.setGlobalFilter('');
15
+ instance.resetGlobalFilter(true);
16
+ window.requestAnimationFrame(() => {
17
17
  instance.setGlobalFilter(currentFilter);
18
- }, 1);
18
+ });
19
19
  }
20
20
  }
21
21
  // highlighting
@@ -1 +1 @@
1
- {"version":3,"file":"useTableSearch.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableSearchHandler } from '../../types';\n\n/*\n Search has two behaviours:\n - Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)\n - Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off\n*/\nexport function useTableSearch<TType = unknown>(\n isEnabled = false,\n onChangeSearch: TableSearchHandler | undefined,\n defaultEnableGlobalFilter = false\n) {\n const [enableGlobalFilter, _setEnableGlobalFilter] = React.useState<boolean>(defaultEnableGlobalFilter);\n\n function setEnableGlobalFilter<T extends TType>(enabled: boolean, instance: ReactTable<T>) {\n _setEnableGlobalFilter(enabled);\n\n // react-table doesn't re-render when options.enableGlobalFilter changes, so for now we force it\n const currentFilter = instance.getState().globalFilter;\n\n if (currentFilter) {\n setTimeout(() => {\n instance.setGlobalFilter('');\n instance.setGlobalFilter(currentFilter);\n }, 1);\n }\n }\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n // filtering - built-in\n enableGlobalFilter,\n setEnableGlobalFilter,\n // highlighting - custom\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n handleSearch: isEnabled && typeof onChangeSearch === 'function' ? onChangeSearch : undefined,\n };\n}\n"],"names":["useTableSearch","isEnabled","onChangeSearch","defaultEnableGlobalFilter","enableGlobalFilter","_setEnableGlobalFilter","React","useState","setEnableGlobalFilter","enabled","instance","currentFilter","getState","globalFilter","setTimeout","setGlobalFilter","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined","handleSearch"],"mappings":";;AAIA;;;;;SAKgBA,cAAcA,CAC1BC,SAAS,GAAG,KAAK,EACjBC,cAA8C,EAC9CC,yBAAyB,GAAG,KAAK;EAEjC,MAAM,CAACC,kBAAkB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,yBAAyB,CAAC;EAEvG,SAASK,qBAAqBA,CAAkBC,OAAgB,EAAEC,QAAuB;IACrFL,sBAAsB,CAACI,OAAO,CAAC;;IAG/B,MAAME,aAAa,GAAGD,QAAQ,CAACE,QAAQ,EAAE,CAACC,YAAY;IAEtD,IAAIF,aAAa,EAAE;MACfG,UAAU,CAAC;QACPJ,QAAQ,CAACK,eAAe,CAAC,EAAE,CAAC;QAC5BL,QAAQ,CAACK,eAAe,CAACJ,aAAa,CAAC;OAC1C,EAAE,CAAC,CAAC;;;;EAKb,MAAM,CAACK,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGX,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACW,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGb,cAAK,CAACC,QAAQ,CAAqBa,SAAS,CAAC;EAEnH,OAAO;IACHnB,SAAS;;IAETG,kBAAkB;IAClBI,qBAAqB;;IAErBQ,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC,8BAA8B;IAC9BE,YAAY,EAAEpB,SAAS,IAAI,OAAOC,cAAc,KAAK,UAAU,GAAGA,cAAc,GAAGkB;GACtF;AACL;;;;"}
1
+ {"version":3,"file":"useTableSearch.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableSearchHandler } from '../../types';\n\n/*\n Search has two behaviours:\n - Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)\n - Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off\n*/\nexport function useTableSearch<TType = unknown>(\n isEnabled = false,\n onChangeSearch: TableSearchHandler | undefined,\n defaultEnableGlobalFilter = false\n) {\n const [enableGlobalFilter, _setEnableGlobalFilter] = React.useState<boolean>(defaultEnableGlobalFilter);\n\n function setEnableGlobalFilter<T extends TType>(enabled: boolean, instance: ReactTable<T>) {\n _setEnableGlobalFilter(enabled);\n\n // react-table doesn't re-render when options.enableGlobalFilter changes, so for now we force it\n const currentFilter = instance.getState().globalFilter;\n\n if (currentFilter) {\n instance.resetGlobalFilter(true);\n\n window.requestAnimationFrame(() => {\n instance.setGlobalFilter(currentFilter);\n });\n }\n }\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n // filtering - built-in\n enableGlobalFilter,\n setEnableGlobalFilter,\n // highlighting - custom\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n handleSearch: isEnabled && typeof onChangeSearch === 'function' ? onChangeSearch : undefined,\n };\n}\n"],"names":["useTableSearch","isEnabled","onChangeSearch","defaultEnableGlobalFilter","enableGlobalFilter","_setEnableGlobalFilter","React","useState","setEnableGlobalFilter","enabled","instance","currentFilter","getState","globalFilter","resetGlobalFilter","window","requestAnimationFrame","setGlobalFilter","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined","handleSearch"],"mappings":";;AAIA;;;;;SAKgBA,cAAcA,CAC1BC,SAAS,GAAG,KAAK,EACjBC,cAA8C,EAC9CC,yBAAyB,GAAG,KAAK;EAEjC,MAAM,CAACC,kBAAkB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,yBAAyB,CAAC;EAEvG,SAASK,qBAAqBA,CAAkBC,OAAgB,EAAEC,QAAuB;IACrFL,sBAAsB,CAACI,OAAO,CAAC;;IAG/B,MAAME,aAAa,GAAGD,QAAQ,CAACE,QAAQ,EAAE,CAACC,YAAY;IAEtD,IAAIF,aAAa,EAAE;MACfD,QAAQ,CAACI,iBAAiB,CAAC,IAAI,CAAC;MAEhCC,MAAM,CAACC,qBAAqB,CAAC;QACzBN,QAAQ,CAACO,eAAe,CAACN,aAAa,CAAC;OAC1C,CAAC;;;;EAKV,MAAM,CAACO,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGb,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACa,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGf,cAAK,CAACC,QAAQ,CAAqBe,SAAS,CAAC;EAEnH,OAAO;IACHrB,SAAS;;IAETG,kBAAkB;IAClBI,qBAAqB;;IAErBU,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC,8BAA8B;IAC9BE,YAAY,EAAEtB,SAAS,IAAI,OAAOC,cAAc,KAAK,UAAU,GAAGA,cAAc,GAAGoB;GACtF;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as TableShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(rowActive?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);\n}\n"],"names":["useTableShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","rowActive","rowActiveIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,KAAwB,EACxBC,SAA4C;EAE5C,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IACjD,MAAMU,cAAc,GAA0C,EAAE;;IAGhE,IAAIV,SAAS,IAAIO,YAAY,CAACI,MAAM,IAAIV,IAAI,CAACW,SAAS,CAACC,cAAc,KAAKC,SAAS,EAAE;MACjF,MAAMF,SAAS,GAAGT,IAAI,CAACF,IAAI,CAACW,SAAS,CAACC,cAAc,CAAC;MAErDN,YAAY,CAACQ,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGjB,SAAS,CAACgB,GAAG,CAAC;QAE9B,IAAIE,cAAc;QAClB,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA4C;UAClEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHf,IAAI,EAAEmB,aAAa,CAACnB,IAAI;YACxBoB,KAAK,EAAED,aAAa,CAACC;WACxB;;QAGLX,cAAc,CAACY,IAAI,CACfC,4BAA4B,CAACJ,qBAAqB,EAAEK,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBP,cAAc,CAACN,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEc,QAAQ,CAAC;SACtC,CAAC,CACL;OACJ,CAAC;;IAGNhB,cAAc,CAACK,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHP,cAAc,CAACK,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAACjB,SAAS,EAAEC,IAAI,CAACW,SAAS,CAACC,cAAc,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AAC/D;;;;"}
1
+ {"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerFn, TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler: TableShortcutHandlerFn<TType>;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as TableShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(rowActive?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);\n}\n"],"names":["useTableShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","rowActive","rowActiveIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original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