@economic/taco 11.0.0 → 11.0.1-react-v19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (774) hide show
  1. package/dist/charts/components/Area/AreaChart.cjs.map +1 -1
  2. package/dist/charts/components/Area/AreaChart.d.ts +1 -1
  3. package/dist/charts/components/Area/AreaChart.js.map +1 -1
  4. package/dist/charts/components/Bar/BarChart.cjs.map +1 -1
  5. package/dist/charts/components/Bar/BarChart.d.ts +1 -1
  6. package/dist/charts/components/Bar/BarChart.js.map +1 -1
  7. package/dist/charts/components/Composed/BarLineChart.cjs.map +1 -1
  8. package/dist/charts/components/Composed/BarLineChart.d.ts +2 -2
  9. package/dist/charts/components/Composed/BarLineChart.js.map +1 -1
  10. package/dist/charts/components/Donut/DonutChart.cjs.map +1 -1
  11. package/dist/charts/components/Donut/DonutChart.d.ts +1 -1
  12. package/dist/charts/components/Donut/DonutChart.js.map +1 -1
  13. package/dist/charts/components/Line/LineChart.cjs.map +1 -1
  14. package/dist/charts/components/Line/LineChart.d.ts +1 -1
  15. package/dist/charts/components/Line/LineChart.js.map +1 -1
  16. package/dist/charts/components/Pie/PieChart.cjs.map +1 -1
  17. package/dist/charts/components/Pie/PieChart.d.ts +1 -1
  18. package/dist/charts/components/Pie/PieChart.js.map +1 -1
  19. package/dist/charts/components/Tooltip.cjs.map +1 -1
  20. package/dist/charts/components/Tooltip.d.ts +1 -1
  21. package/dist/charts/components/Tooltip.js.map +1 -1
  22. package/dist/charts/components/types.d.ts +2 -2
  23. package/dist/components/AlertDialog/AlertDialog.cjs.map +1 -1
  24. package/dist/components/AlertDialog/AlertDialog.d.ts +1 -1
  25. package/dist/components/AlertDialog/AlertDialog.js.map +1 -1
  26. package/dist/components/Banner/util.cjs.map +1 -1
  27. package/dist/components/Banner/util.d.ts +2 -1
  28. package/dist/components/Banner/util.js.map +1 -1
  29. package/dist/components/Card/Card.cjs.map +1 -1
  30. package/dist/components/Card/Card.d.ts +1 -1
  31. package/dist/components/Card/Card.js.map +1 -1
  32. package/dist/components/Combobox/Combobox.cjs.map +1 -1
  33. package/dist/components/Combobox/Combobox.d.ts +1 -1
  34. package/dist/components/Combobox/Combobox.js.map +1 -1
  35. package/dist/components/Combobox/useCombobox.cjs.map +1 -1
  36. package/dist/components/Combobox/useCombobox.d.ts +1 -1
  37. package/dist/components/Combobox/useCombobox.js.map +1 -1
  38. package/dist/components/Dialog/Dialog.cjs.map +1 -1
  39. package/dist/components/Dialog/Dialog.d.ts +1 -1
  40. package/dist/components/Dialog/Dialog.js.map +1 -1
  41. package/dist/components/Dialog/components/Content.cjs.map +1 -1
  42. package/dist/components/Dialog/components/Content.d.ts +2 -2
  43. package/dist/components/Dialog/components/Content.js.map +1 -1
  44. package/dist/components/Drawer/Drawer.cjs.map +1 -1
  45. package/dist/components/Drawer/Drawer.d.ts +1 -1
  46. package/dist/components/Drawer/Drawer.js.map +1 -1
  47. package/dist/components/Drawer/useDrawerStack.cjs +1 -1
  48. package/dist/components/Drawer/useDrawerStack.cjs.map +1 -1
  49. package/dist/components/Drawer/useDrawerStack.js +1 -1
  50. package/dist/components/Drawer/useDrawerStack.js.map +1 -1
  51. package/dist/components/Hanger/Hanger.cjs.map +1 -1
  52. package/dist/components/Hanger/Hanger.d.ts +1 -1
  53. package/dist/components/Hanger/Hanger.js.map +1 -1
  54. package/dist/components/Header/components/Agreement/Display.cjs.map +1 -1
  55. package/dist/components/Header/components/Agreement/Display.d.ts +1 -1
  56. package/dist/components/Header/components/Agreement/Display.js.map +1 -1
  57. package/dist/components/Header/components/Agreement/Item.cjs.map +1 -1
  58. package/dist/components/Header/components/Agreement/Item.d.ts +1 -1
  59. package/dist/components/Header/components/Agreement/Item.js.map +1 -1
  60. package/dist/components/Header/components/Link.cjs.map +1 -1
  61. package/dist/components/Header/components/Link.d.ts +1 -1
  62. package/dist/components/Header/components/Link.js.map +1 -1
  63. package/dist/components/Icon/components/AccountPreview.cjs.map +1 -1
  64. package/dist/components/Icon/components/AccountPreview.js.map +1 -1
  65. package/dist/components/Icon/components/Accounting.cjs.map +1 -1
  66. package/dist/components/Icon/components/Accounting.js.map +1 -1
  67. package/dist/components/Icon/components/AccountingYear.cjs.map +1 -1
  68. package/dist/components/Icon/components/AccountingYear.js.map +1 -1
  69. package/dist/components/Icon/components/AccountingYearCancel.cjs.map +1 -1
  70. package/dist/components/Icon/components/AccountingYearCancel.js.map +1 -1
  71. package/dist/components/Icon/components/AiChatSolid.cjs.map +1 -1
  72. package/dist/components/Icon/components/AiChatSolid.js.map +1 -1
  73. package/dist/components/Icon/components/AiStars.cjs.map +1 -1
  74. package/dist/components/Icon/components/AiStars.js.map +1 -1
  75. package/dist/components/Icon/components/ArrowBottom.cjs.map +1 -1
  76. package/dist/components/Icon/components/ArrowBottom.js.map +1 -1
  77. package/dist/components/Icon/components/ArrowDown.cjs.map +1 -1
  78. package/dist/components/Icon/components/ArrowDown.js.map +1 -1
  79. package/dist/components/Icon/components/ArrowEnd.cjs.map +1 -1
  80. package/dist/components/Icon/components/ArrowEnd.js.map +1 -1
  81. package/dist/components/Icon/components/ArrowLeft.cjs.map +1 -1
  82. package/dist/components/Icon/components/ArrowLeft.js.map +1 -1
  83. package/dist/components/Icon/components/ArrowRight.cjs.map +1 -1
  84. package/dist/components/Icon/components/ArrowRight.js.map +1 -1
  85. package/dist/components/Icon/components/ArrowStart.cjs.map +1 -1
  86. package/dist/components/Icon/components/ArrowStart.js.map +1 -1
  87. package/dist/components/Icon/components/ArrowTop.cjs.map +1 -1
  88. package/dist/components/Icon/components/ArrowTop.js.map +1 -1
  89. package/dist/components/Icon/components/ArrowUp.cjs.map +1 -1
  90. package/dist/components/Icon/components/ArrowUp.js.map +1 -1
  91. package/dist/components/Icon/components/Attach.cjs.map +1 -1
  92. package/dist/components/Icon/components/Attach.js.map +1 -1
  93. package/dist/components/Icon/components/AttachAuto.cjs.map +1 -1
  94. package/dist/components/Icon/components/AttachAuto.js.map +1 -1
  95. package/dist/components/Icon/components/AttachCancel.cjs.map +1 -1
  96. package/dist/components/Icon/components/AttachCancel.js.map +1 -1
  97. package/dist/components/Icon/components/AttachWarning.cjs.map +1 -1
  98. package/dist/components/Icon/components/AttachWarning.js.map +1 -1
  99. package/dist/components/Icon/components/Autopay.cjs.map +1 -1
  100. package/dist/components/Icon/components/Autopay.js.map +1 -1
  101. package/dist/components/Icon/components/AutopayPaused.cjs.map +1 -1
  102. package/dist/components/Icon/components/AutopayPaused.js.map +1 -1
  103. package/dist/components/Icon/components/Autotext.cjs.map +1 -1
  104. package/dist/components/Icon/components/Autotext.js.map +1 -1
  105. package/dist/components/Icon/components/AutotextInsert.cjs.map +1 -1
  106. package/dist/components/Icon/components/AutotextInsert.js.map +1 -1
  107. package/dist/components/Icon/components/Basic.cjs.map +1 -1
  108. package/dist/components/Icon/components/Basic.js.map +1 -1
  109. package/dist/components/Icon/components/BasicTabs.cjs.map +1 -1
  110. package/dist/components/Icon/components/BasicTabs.js.map +1 -1
  111. package/dist/components/Icon/components/BellSolid.cjs.map +1 -1
  112. package/dist/components/Icon/components/BellSolid.js.map +1 -1
  113. package/dist/components/Icon/components/Book.cjs.map +1 -1
  114. package/dist/components/Icon/components/Book.js.map +1 -1
  115. package/dist/components/Icon/components/Booking.cjs.map +1 -1
  116. package/dist/components/Icon/components/Booking.js.map +1 -1
  117. package/dist/components/Icon/components/Budget.cjs.map +1 -1
  118. package/dist/components/Icon/components/Budget.js.map +1 -1
  119. package/dist/components/Icon/components/Calendar.cjs.map +1 -1
  120. package/dist/components/Icon/components/Calendar.js.map +1 -1
  121. package/dist/components/Icon/components/CashAccount.cjs.map +1 -1
  122. package/dist/components/Icon/components/CashAccount.js.map +1 -1
  123. package/dist/components/Icon/components/CashReports.cjs.map +1 -1
  124. package/dist/components/Icon/components/CashReports.js.map +1 -1
  125. package/dist/components/Icon/components/ChartArea.cjs.map +1 -1
  126. package/dist/components/Icon/components/ChartArea.js.map +1 -1
  127. package/dist/components/Icon/components/ChartBar.cjs.map +1 -1
  128. package/dist/components/Icon/components/ChartBar.js.map +1 -1
  129. package/dist/components/Icon/components/ChartLine.cjs.map +1 -1
  130. package/dist/components/Icon/components/ChartLine.js.map +1 -1
  131. package/dist/components/Icon/components/ChartPie.cjs.map +1 -1
  132. package/dist/components/Icon/components/ChartPie.js.map +1 -1
  133. package/dist/components/Icon/components/ChartTable.cjs.map +1 -1
  134. package/dist/components/Icon/components/ChartTable.js.map +1 -1
  135. package/dist/components/Icon/components/Chat.cjs.map +1 -1
  136. package/dist/components/Icon/components/Chat.js.map +1 -1
  137. package/dist/components/Icon/components/ChatSolid.cjs.map +1 -1
  138. package/dist/components/Icon/components/ChatSolid.js.map +1 -1
  139. package/dist/components/Icon/components/ChevronDown.cjs.map +1 -1
  140. package/dist/components/Icon/components/ChevronDown.js.map +1 -1
  141. package/dist/components/Icon/components/ChevronDownDouble.cjs.map +1 -1
  142. package/dist/components/Icon/components/ChevronDownDouble.js.map +1 -1
  143. package/dist/components/Icon/components/ChevronDownSolid.cjs.map +1 -1
  144. package/dist/components/Icon/components/ChevronDownSolid.js.map +1 -1
  145. package/dist/components/Icon/components/ChevronLeft.cjs.map +1 -1
  146. package/dist/components/Icon/components/ChevronLeft.js.map +1 -1
  147. package/dist/components/Icon/components/ChevronLeftDouble.cjs.map +1 -1
  148. package/dist/components/Icon/components/ChevronLeftDouble.js.map +1 -1
  149. package/dist/components/Icon/components/ChevronLeftSolid.cjs.map +1 -1
  150. package/dist/components/Icon/components/ChevronLeftSolid.js.map +1 -1
  151. package/dist/components/Icon/components/ChevronRight.cjs.map +1 -1
  152. package/dist/components/Icon/components/ChevronRight.js.map +1 -1
  153. package/dist/components/Icon/components/ChevronRightDouble.cjs.map +1 -1
  154. package/dist/components/Icon/components/ChevronRightDouble.js.map +1 -1
  155. package/dist/components/Icon/components/ChevronRightSolid.cjs.map +1 -1
  156. package/dist/components/Icon/components/ChevronRightSolid.js.map +1 -1
  157. package/dist/components/Icon/components/ChevronUp.cjs.map +1 -1
  158. package/dist/components/Icon/components/ChevronUp.js.map +1 -1
  159. package/dist/components/Icon/components/ChevronUpDouble.cjs.map +1 -1
  160. package/dist/components/Icon/components/ChevronUpDouble.js.map +1 -1
  161. package/dist/components/Icon/components/ChevronUpSolid.cjs.map +1 -1
  162. package/dist/components/Icon/components/ChevronUpSolid.js.map +1 -1
  163. package/dist/components/Icon/components/CircleInformation.cjs.map +1 -1
  164. package/dist/components/Icon/components/CircleInformation.js.map +1 -1
  165. package/dist/components/Icon/components/CircleMinus.cjs.map +1 -1
  166. package/dist/components/Icon/components/CircleMinus.js.map +1 -1
  167. package/dist/components/Icon/components/CirclePlus.cjs.map +1 -1
  168. package/dist/components/Icon/components/CirclePlus.js.map +1 -1
  169. package/dist/components/Icon/components/CircleQuestionmark.cjs.map +1 -1
  170. package/dist/components/Icon/components/CircleQuestionmark.js.map +1 -1
  171. package/dist/components/Icon/components/CircleTick.cjs.map +1 -1
  172. package/dist/components/Icon/components/CircleTick.js.map +1 -1
  173. package/dist/components/Icon/components/CircleWarning.cjs.map +1 -1
  174. package/dist/components/Icon/components/CircleWarning.js.map +1 -1
  175. package/dist/components/Icon/components/Clamp.cjs.map +1 -1
  176. package/dist/components/Icon/components/Clamp.js.map +1 -1
  177. package/dist/components/Icon/components/ClampOpen.cjs.map +1 -1
  178. package/dist/components/Icon/components/ClampOpen.js.map +1 -1
  179. package/dist/components/Icon/components/ClickToPay.cjs.map +1 -1
  180. package/dist/components/Icon/components/ClickToPay.js.map +1 -1
  181. package/dist/components/Icon/components/Close.cjs.map +1 -1
  182. package/dist/components/Icon/components/Close.js.map +1 -1
  183. package/dist/components/Icon/components/ColumnFreeze.cjs.map +1 -1
  184. package/dist/components/Icon/components/ColumnFreeze.js.map +1 -1
  185. package/dist/components/Icon/components/ColumnUnfreeze.cjs.map +1 -1
  186. package/dist/components/Icon/components/ColumnUnfreeze.js.map +1 -1
  187. package/dist/components/Icon/components/Columns.cjs.map +1 -1
  188. package/dist/components/Icon/components/Columns.js.map +1 -1
  189. package/dist/components/Icon/components/ConnectionEnable.cjs.map +1 -1
  190. package/dist/components/Icon/components/ConnectionEnable.js.map +1 -1
  191. package/dist/components/Icon/components/ConnectionRevoke.cjs.map +1 -1
  192. package/dist/components/Icon/components/ConnectionRevoke.js.map +1 -1
  193. package/dist/components/Icon/components/Contacts.cjs.map +1 -1
  194. package/dist/components/Icon/components/Contacts.js.map +1 -1
  195. package/dist/components/Icon/components/Copy.cjs.map +1 -1
  196. package/dist/components/Icon/components/Copy.js.map +1 -1
  197. package/dist/components/Icon/components/Courses.cjs.map +1 -1
  198. package/dist/components/Icon/components/Courses.js.map +1 -1
  199. package/dist/components/Icon/components/Credit.cjs.map +1 -1
  200. package/dist/components/Icon/components/Credit.js.map +1 -1
  201. package/dist/components/Icon/components/Delete.cjs.map +1 -1
  202. package/dist/components/Icon/components/Delete.js.map +1 -1
  203. package/dist/components/Icon/components/DeletePermanently.cjs.map +1 -1
  204. package/dist/components/Icon/components/DeletePermanently.js.map +1 -1
  205. package/dist/components/Icon/components/Depecriate.cjs.map +1 -1
  206. package/dist/components/Icon/components/Depecriate.js.map +1 -1
  207. package/dist/components/Icon/components/Developer.cjs.map +1 -1
  208. package/dist/components/Icon/components/Developer.js.map +1 -1
  209. package/dist/components/Icon/components/DistributionTemplate.cjs.map +1 -1
  210. package/dist/components/Icon/components/DistributionTemplate.js.map +1 -1
  211. package/dist/components/Icon/components/Document.cjs.map +1 -1
  212. package/dist/components/Icon/components/Document.js.map +1 -1
  213. package/dist/components/Icon/components/DocumentApprove.cjs.map +1 -1
  214. package/dist/components/Icon/components/DocumentApprove.js.map +1 -1
  215. package/dist/components/Icon/components/DocumentCreateEntry.cjs.map +1 -1
  216. package/dist/components/Icon/components/DocumentCreateEntry.js.map +1 -1
  217. package/dist/components/Icon/components/DocumentCut.cjs.map +1 -1
  218. package/dist/components/Icon/components/DocumentCut.js.map +1 -1
  219. package/dist/components/Icon/components/DocumentError.cjs.map +1 -1
  220. package/dist/components/Icon/components/DocumentError.js.map +1 -1
  221. package/dist/components/Icon/components/DocumentIsolatePage.cjs.map +1 -1
  222. package/dist/components/Icon/components/DocumentIsolatePage.js.map +1 -1
  223. package/dist/components/Icon/components/DocumentMerge.cjs.map +1 -1
  224. package/dist/components/Icon/components/DocumentMerge.js.map +1 -1
  225. package/dist/components/Icon/components/DocumentMove.cjs.map +1 -1
  226. package/dist/components/Icon/components/DocumentMove.js.map +1 -1
  227. package/dist/components/Icon/components/DocumentPreview.cjs.map +1 -1
  228. package/dist/components/Icon/components/DocumentPreview.js.map +1 -1
  229. package/dist/components/Icon/components/DocumentReceived.cjs.map +1 -1
  230. package/dist/components/Icon/components/DocumentReceived.js.map +1 -1
  231. package/dist/components/Icon/components/DocumentRejectedRequest.cjs.map +1 -1
  232. package/dist/components/Icon/components/DocumentRejectedRequest.js.map +1 -1
  233. package/dist/components/Icon/components/DocumentSigned.cjs.map +1 -1
  234. package/dist/components/Icon/components/DocumentSigned.js.map +1 -1
  235. package/dist/components/Icon/components/DocumentSignedSolid.cjs.map +1 -1
  236. package/dist/components/Icon/components/DocumentSignedSolid.js.map +1 -1
  237. package/dist/components/Icon/components/DocumentSplit.cjs.map +1 -1
  238. package/dist/components/Icon/components/DocumentSplit.js.map +1 -1
  239. package/dist/components/Icon/components/DocumentTime.cjs.map +1 -1
  240. package/dist/components/Icon/components/DocumentTime.js.map +1 -1
  241. package/dist/components/Icon/components/Download.cjs.map +1 -1
  242. package/dist/components/Icon/components/Download.js.map +1 -1
  243. package/dist/components/Icon/components/Drag.cjs.map +1 -1
  244. package/dist/components/Icon/components/Drag.js.map +1 -1
  245. package/dist/components/Icon/components/ECopedia.cjs.map +1 -1
  246. package/dist/components/Icon/components/ECopedia.js.map +1 -1
  247. package/dist/components/Icon/components/Edit.cjs.map +1 -1
  248. package/dist/components/Icon/components/Edit.js.map +1 -1
  249. package/dist/components/Icon/components/EditSimple.cjs.map +1 -1
  250. package/dist/components/Icon/components/EditSimple.js.map +1 -1
  251. package/dist/components/Icon/components/EllipsisHorizontal.cjs.map +1 -1
  252. package/dist/components/Icon/components/EllipsisHorizontal.js.map +1 -1
  253. package/dist/components/Icon/components/EllipsisVertical.cjs.map +1 -1
  254. package/dist/components/Icon/components/EllipsisVertical.js.map +1 -1
  255. package/dist/components/Icon/components/EntriesOnAccount.cjs.map +1 -1
  256. package/dist/components/Icon/components/EntriesOnAccount.js.map +1 -1
  257. package/dist/components/Icon/components/EntriesOpen.cjs.map +1 -1
  258. package/dist/components/Icon/components/EntriesOpen.js.map +1 -1
  259. package/dist/components/Icon/components/EntriesWarning.cjs.map +1 -1
  260. package/dist/components/Icon/components/EntriesWarning.js.map +1 -1
  261. package/dist/components/Icon/components/EntryTypeCustomerInvoice.cjs.map +1 -1
  262. package/dist/components/Icon/components/EntryTypeCustomerInvoice.js.map +1 -1
  263. package/dist/components/Icon/components/EntryTypeCustomerPayment.cjs.map +1 -1
  264. package/dist/components/Icon/components/EntryTypeCustomerPayment.js.map +1 -1
  265. package/dist/components/Icon/components/EntryTypeJournalEntry.cjs.map +1 -1
  266. package/dist/components/Icon/components/EntryTypeJournalEntry.js.map +1 -1
  267. package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.cjs.map +1 -1
  268. package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.js.map +1 -1
  269. package/dist/components/Icon/components/EntryTypeSupplierInvoice.cjs.map +1 -1
  270. package/dist/components/Icon/components/EntryTypeSupplierInvoice.js.map +1 -1
  271. package/dist/components/Icon/components/EntryTypeSupplierPayment.cjs.map +1 -1
  272. package/dist/components/Icon/components/EntryTypeSupplierPayment.js.map +1 -1
  273. package/dist/components/Icon/components/Envelope.cjs.map +1 -1
  274. package/dist/components/Icon/components/Envelope.js.map +1 -1
  275. package/dist/components/Icon/components/EnvelopeApproved.cjs.map +1 -1
  276. package/dist/components/Icon/components/EnvelopeApproved.js.map +1 -1
  277. package/dist/components/Icon/components/EnvelopeSolid.cjs.map +1 -1
  278. package/dist/components/Icon/components/EnvelopeSolid.js.map +1 -1
  279. package/dist/components/Icon/components/ExpandView.cjs.map +1 -1
  280. package/dist/components/Icon/components/ExpandView.js.map +1 -1
  281. package/dist/components/Icon/components/Expenses.cjs.map +1 -1
  282. package/dist/components/Icon/components/Expenses.js.map +1 -1
  283. package/dist/components/Icon/components/Experiment.cjs.map +1 -1
  284. package/dist/components/Icon/components/Experiment.js.map +1 -1
  285. package/dist/components/Icon/components/Export.cjs.map +1 -1
  286. package/dist/components/Icon/components/Export.js.map +1 -1
  287. package/dist/components/Icon/components/ExportToExcel.cjs.map +1 -1
  288. package/dist/components/Icon/components/ExportToExcel.js.map +1 -1
  289. package/dist/components/Icon/components/ExportToPdf.cjs.map +1 -1
  290. package/dist/components/Icon/components/ExportToPdf.js.map +1 -1
  291. package/dist/components/Icon/components/EyeOff.cjs.map +1 -1
  292. package/dist/components/Icon/components/EyeOff.js.map +1 -1
  293. package/dist/components/Icon/components/EyeOn.cjs.map +1 -1
  294. package/dist/components/Icon/components/EyeOn.js.map +1 -1
  295. package/dist/components/Icon/components/Filter.cjs.map +1 -1
  296. package/dist/components/Icon/components/Filter.js.map +1 -1
  297. package/dist/components/Icon/components/FilterSolid.cjs.map +1 -1
  298. package/dist/components/Icon/components/FilterSolid.js.map +1 -1
  299. package/dist/components/Icon/components/FontSize.cjs.map +1 -1
  300. package/dist/components/Icon/components/FontSize.js.map +1 -1
  301. package/dist/components/Icon/components/GraphSolid.cjs.map +1 -1
  302. package/dist/components/Icon/components/GraphSolid.js.map +1 -1
  303. package/dist/components/Icon/components/Hash.cjs.map +1 -1
  304. package/dist/components/Icon/components/Hash.js.map +1 -1
  305. package/dist/components/Icon/components/HeightExtraTall.cjs.map +1 -1
  306. package/dist/components/Icon/components/HeightExtraTall.js.map +1 -1
  307. package/dist/components/Icon/components/HeightMedium.cjs.map +1 -1
  308. package/dist/components/Icon/components/HeightMedium.js.map +1 -1
  309. package/dist/components/Icon/components/HeightShort.cjs.map +1 -1
  310. package/dist/components/Icon/components/HeightShort.js.map +1 -1
  311. package/dist/components/Icon/components/HeightTall.cjs.map +1 -1
  312. package/dist/components/Icon/components/HeightTall.js.map +1 -1
  313. package/dist/components/Icon/components/House.cjs.map +1 -1
  314. package/dist/components/Icon/components/House.js.map +1 -1
  315. package/dist/components/Icon/components/HouseSolid.cjs.map +1 -1
  316. package/dist/components/Icon/components/HouseSolid.js.map +1 -1
  317. package/dist/components/Icon/components/Id.cjs.map +1 -1
  318. package/dist/components/Icon/components/Id.js.map +1 -1
  319. package/dist/components/Icon/components/Images.cjs.map +1 -1
  320. package/dist/components/Icon/components/Images.js.map +1 -1
  321. package/dist/components/Icon/components/Import.cjs.map +1 -1
  322. package/dist/components/Icon/components/Import.js.map +1 -1
  323. package/dist/components/Icon/components/Inbox.cjs.map +1 -1
  324. package/dist/components/Icon/components/Inbox.js.map +1 -1
  325. package/dist/components/Icon/components/InboxEinvoicing.cjs.map +1 -1
  326. package/dist/components/Icon/components/InboxEinvoicing.js.map +1 -1
  327. package/dist/components/Icon/components/InboxScanning.cjs.map +1 -1
  328. package/dist/components/Icon/components/InboxScanning.js.map +1 -1
  329. package/dist/components/Icon/components/InboxSmart.cjs.map +1 -1
  330. package/dist/components/Icon/components/InboxSmart.js.map +1 -1
  331. package/dist/components/Icon/components/Info.cjs.map +1 -1
  332. package/dist/components/Icon/components/Info.js.map +1 -1
  333. package/dist/components/Icon/components/Inventory.cjs.map +1 -1
  334. package/dist/components/Icon/components/Inventory.js.map +1 -1
  335. package/dist/components/Icon/components/InventoryMatrix.cjs.map +1 -1
  336. package/dist/components/Icon/components/InventoryMatrix.js.map +1 -1
  337. package/dist/components/Icon/components/JournalPro.cjs.map +1 -1
  338. package/dist/components/Icon/components/JournalPro.js.map +1 -1
  339. package/dist/components/Icon/components/Layout.cjs.map +1 -1
  340. package/dist/components/Icon/components/Layout.js.map +1 -1
  341. package/dist/components/Icon/components/LayoutBoth.cjs.map +1 -1
  342. package/dist/components/Icon/components/LayoutBoth.js.map +1 -1
  343. package/dist/components/Icon/components/LayoutFirst.cjs.map +1 -1
  344. package/dist/components/Icon/components/LayoutFirst.js.map +1 -1
  345. package/dist/components/Icon/components/LayoutLast.cjs.map +1 -1
  346. package/dist/components/Icon/components/LayoutLast.js.map +1 -1
  347. package/dist/components/Icon/components/LayoutNone.cjs.map +1 -1
  348. package/dist/components/Icon/components/LayoutNone.js.map +1 -1
  349. package/dist/components/Icon/components/LedgerCard.cjs.map +1 -1
  350. package/dist/components/Icon/components/LedgerCard.js.map +1 -1
  351. package/dist/components/Icon/components/LedgerCardCustomerReminder.cjs.map +1 -1
  352. package/dist/components/Icon/components/LedgerCardCustomerReminder.js.map +1 -1
  353. package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.cjs.map +1 -1
  354. package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.js.map +1 -1
  355. package/dist/components/Icon/components/LedgerCardObsoleteStock.cjs.map +1 -1
  356. package/dist/components/Icon/components/LedgerCardObsoleteStock.js.map +1 -1
  357. package/dist/components/Icon/components/LedgerCardOpeningEntry.cjs.map +1 -1
  358. package/dist/components/Icon/components/LedgerCardOpeningEntry.js.map +1 -1
  359. package/dist/components/Icon/components/LedgerCardReservedEntry.cjs.map +1 -1
  360. package/dist/components/Icon/components/LedgerCardReservedEntry.js.map +1 -1
  361. package/dist/components/Icon/components/LedgerCardShrinkagePilferage.cjs.map +1 -1
  362. package/dist/components/Icon/components/LedgerCardShrinkagePilferage.js.map +1 -1
  363. package/dist/components/Icon/components/LedgerCardStockAdjustment.cjs.map +1 -1
  364. package/dist/components/Icon/components/LedgerCardStockAdjustment.js.map +1 -1
  365. package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.cjs.map +1 -1
  366. package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.js.map +1 -1
  367. package/dist/components/Icon/components/Lightbulb.cjs.map +1 -1
  368. package/dist/components/Icon/components/Lightbulb.js.map +1 -1
  369. package/dist/components/Icon/components/Line.cjs.map +1 -1
  370. package/dist/components/Icon/components/Line.js.map +1 -1
  371. package/dist/components/Icon/components/LinkExternal.cjs.map +1 -1
  372. package/dist/components/Icon/components/LinkExternal.js.map +1 -1
  373. package/dist/components/Icon/components/List.cjs.map +1 -1
  374. package/dist/components/Icon/components/List.js.map +1 -1
  375. package/dist/components/Icon/components/ListBulleted.cjs.map +1 -1
  376. package/dist/components/Icon/components/ListBulleted.js.map +1 -1
  377. package/dist/components/Icon/components/ListSearch.cjs.map +1 -1
  378. package/dist/components/Icon/components/ListSearch.js.map +1 -1
  379. package/dist/components/Icon/components/Location.cjs.map +1 -1
  380. package/dist/components/Icon/components/Location.js.map +1 -1
  381. package/dist/components/Icon/components/Lock.cjs.map +1 -1
  382. package/dist/components/Icon/components/Lock.js.map +1 -1
  383. package/dist/components/Icon/components/LockOpen.cjs.map +1 -1
  384. package/dist/components/Icon/components/LockOpen.js.map +1 -1
  385. package/dist/components/Icon/components/Log.cjs.map +1 -1
  386. package/dist/components/Icon/components/Log.js.map +1 -1
  387. package/dist/components/Icon/components/LogOut.cjs.map +1 -1
  388. package/dist/components/Icon/components/LogOut.js.map +1 -1
  389. package/dist/components/Icon/components/Market.cjs.map +1 -1
  390. package/dist/components/Icon/components/Market.js.map +1 -1
  391. package/dist/components/Icon/components/MastercardOs.cjs.map +1 -1
  392. package/dist/components/Icon/components/MastercardOs.js.map +1 -1
  393. package/dist/components/Icon/components/MatchAmount.cjs.map +1 -1
  394. package/dist/components/Icon/components/MatchAmount.js.map +1 -1
  395. package/dist/components/Icon/components/MatchEntries.cjs.map +1 -1
  396. package/dist/components/Icon/components/MatchEntries.js.map +1 -1
  397. package/dist/components/Icon/components/Menu.cjs.map +1 -1
  398. package/dist/components/Icon/components/Menu.js.map +1 -1
  399. package/dist/components/Icon/components/Mileage.cjs.map +1 -1
  400. package/dist/components/Icon/components/Mileage.js.map +1 -1
  401. package/dist/components/Icon/components/ModalResize.cjs.map +1 -1
  402. package/dist/components/Icon/components/ModalResize.js.map +1 -1
  403. package/dist/components/Icon/components/ModalShrink.cjs.map +1 -1
  404. package/dist/components/Icon/components/ModalShrink.js.map +1 -1
  405. package/dist/components/Icon/components/More.cjs.map +1 -1
  406. package/dist/components/Icon/components/More.js.map +1 -1
  407. package/dist/components/Icon/components/MoreSolid.cjs.map +1 -1
  408. package/dist/components/Icon/components/MoreSolid.js.map +1 -1
  409. package/dist/components/Icon/components/Move.cjs.map +1 -1
  410. package/dist/components/Icon/components/Move.js.map +1 -1
  411. package/dist/components/Icon/components/NavigationList.cjs.map +1 -1
  412. package/dist/components/Icon/components/NavigationList.js.map +1 -1
  413. package/dist/components/Icon/components/Note.cjs.map +1 -1
  414. package/dist/components/Icon/components/Note.js.map +1 -1
  415. package/dist/components/Icon/components/NoteFollowUp.cjs.map +1 -1
  416. package/dist/components/Icon/components/NoteFollowUp.js.map +1 -1
  417. package/dist/components/Icon/components/NoteRead.cjs.map +1 -1
  418. package/dist/components/Icon/components/NoteRead.js.map +1 -1
  419. package/dist/components/Icon/components/NovemberFirst.cjs.map +1 -1
  420. package/dist/components/Icon/components/NovemberFirst.js.map +1 -1
  421. package/dist/components/Icon/components/Numbers.cjs.map +1 -1
  422. package/dist/components/Icon/components/Numbers.js.map +1 -1
  423. package/dist/components/Icon/components/PartialPaymentScheduled.cjs.map +1 -1
  424. package/dist/components/Icon/components/PartialPaymentScheduled.js.map +1 -1
  425. package/dist/components/Icon/components/PartnerApi.cjs.map +1 -1
  426. package/dist/components/Icon/components/PartnerApi.js.map +1 -1
  427. package/dist/components/Icon/components/PaymentPaid.cjs.map +1 -1
  428. package/dist/components/Icon/components/PaymentPaid.js.map +1 -1
  429. package/dist/components/Icon/components/PaymentUnpaid.cjs.map +1 -1
  430. package/dist/components/Icon/components/PaymentUnpaid.js.map +1 -1
  431. package/dist/components/Icon/components/Period.cjs.map +1 -1
  432. package/dist/components/Icon/components/Period.js.map +1 -1
  433. package/dist/components/Icon/components/Person.cjs.map +1 -1
  434. package/dist/components/Icon/components/Person.js.map +1 -1
  435. package/dist/components/Icon/components/PersonChange.cjs.map +1 -1
  436. package/dist/components/Icon/components/PersonChange.js.map +1 -1
  437. package/dist/components/Icon/components/PersonMinus.cjs.map +1 -1
  438. package/dist/components/Icon/components/PersonMinus.js.map +1 -1
  439. package/dist/components/Icon/components/PersonPlus.cjs.map +1 -1
  440. package/dist/components/Icon/components/PersonPlus.js.map +1 -1
  441. package/dist/components/Icon/components/PersonSolid.cjs.map +1 -1
  442. package/dist/components/Icon/components/PersonSolid.js.map +1 -1
  443. package/dist/components/Icon/components/PersonTick.cjs.map +1 -1
  444. package/dist/components/Icon/components/PersonTick.js.map +1 -1
  445. package/dist/components/Icon/components/Phone.cjs.map +1 -1
  446. package/dist/components/Icon/components/Phone.js.map +1 -1
  447. package/dist/components/Icon/components/PhoneSolid.cjs.map +1 -1
  448. package/dist/components/Icon/components/PhoneSolid.js.map +1 -1
  449. package/dist/components/Icon/components/Play.cjs.map +1 -1
  450. package/dist/components/Icon/components/Play.js.map +1 -1
  451. package/dist/components/Icon/components/PlusMinus.cjs.map +1 -1
  452. package/dist/components/Icon/components/PlusMinus.js.map +1 -1
  453. package/dist/components/Icon/components/Print.cjs.map +1 -1
  454. package/dist/components/Icon/components/Print.js.map +1 -1
  455. package/dist/components/Icon/components/ProcessPayment.cjs.map +1 -1
  456. package/dist/components/Icon/components/ProcessPayment.js.map +1 -1
  457. package/dist/components/Icon/components/ProductLedgerCard.cjs.map +1 -1
  458. package/dist/components/Icon/components/ProductLedgerCard.js.map +1 -1
  459. package/dist/components/Icon/components/Profile.cjs.map +1 -1
  460. package/dist/components/Icon/components/Profile.js.map +1 -1
  461. package/dist/components/Icon/components/ProjectCards.cjs.map +1 -1
  462. package/dist/components/Icon/components/ProjectCards.js.map +1 -1
  463. package/dist/components/Icon/components/Projects.cjs.map +1 -1
  464. package/dist/components/Icon/components/Projects.js.map +1 -1
  465. package/dist/components/Icon/components/QuestionMark.cjs.map +1 -1
  466. package/dist/components/Icon/components/QuestionMark.js.map +1 -1
  467. package/dist/components/Icon/components/QuestionMarkBold.cjs.map +1 -1
  468. package/dist/components/Icon/components/QuestionMarkBold.js.map +1 -1
  469. package/dist/components/Icon/components/Quicklinks.cjs.map +1 -1
  470. package/dist/components/Icon/components/Quicklinks.js.map +1 -1
  471. package/dist/components/Icon/components/RatingBankruptcy.cjs.map +1 -1
  472. package/dist/components/Icon/components/RatingBankruptcy.js.map +1 -1
  473. package/dist/components/Icon/components/RatingPaymentProblems.cjs.map +1 -1
  474. package/dist/components/Icon/components/RatingPaymentProblems.js.map +1 -1
  475. package/dist/components/Icon/components/Reconciled.cjs.map +1 -1
  476. package/dist/components/Icon/components/Reconciled.js.map +1 -1
  477. package/dist/components/Icon/components/Refresh.cjs.map +1 -1
  478. package/dist/components/Icon/components/Refresh.js.map +1 -1
  479. package/dist/components/Icon/components/Remove.cjs.map +1 -1
  480. package/dist/components/Icon/components/Remove.js.map +1 -1
  481. package/dist/components/Icon/components/Report.cjs.map +1 -1
  482. package/dist/components/Icon/components/Report.js.map +1 -1
  483. package/dist/components/Icon/components/ReportSolid.cjs.map +1 -1
  484. package/dist/components/Icon/components/ReportSolid.js.map +1 -1
  485. package/dist/components/Icon/components/Restore.cjs.map +1 -1
  486. package/dist/components/Icon/components/Restore.js.map +1 -1
  487. package/dist/components/Icon/components/RotateLeft.cjs.map +1 -1
  488. package/dist/components/Icon/components/RotateLeft.js.map +1 -1
  489. package/dist/components/Icon/components/RotateRight.cjs.map +1 -1
  490. package/dist/components/Icon/components/RotateRight.js.map +1 -1
  491. package/dist/components/Icon/components/Sales.cjs.map +1 -1
  492. package/dist/components/Icon/components/Sales.js.map +1 -1
  493. package/dist/components/Icon/components/Search.cjs.map +1 -1
  494. package/dist/components/Icon/components/Search.js.map +1 -1
  495. package/dist/components/Icon/components/SearchBold.cjs.map +1 -1
  496. package/dist/components/Icon/components/SearchBold.js.map +1 -1
  497. package/dist/components/Icon/components/Secure.cjs.map +1 -1
  498. package/dist/components/Icon/components/Secure.js.map +1 -1
  499. package/dist/components/Icon/components/SecureTick.cjs.map +1 -1
  500. package/dist/components/Icon/components/SecureTick.js.map +1 -1
  501. package/dist/components/Icon/components/Settings.cjs.map +1 -1
  502. package/dist/components/Icon/components/Settings.js.map +1 -1
  503. package/dist/components/Icon/components/SettingsSolid.cjs.map +1 -1
  504. package/dist/components/Icon/components/SettingsSolid.js.map +1 -1
  505. package/dist/components/Icon/components/Shortcuts.cjs.map +1 -1
  506. package/dist/components/Icon/components/Shortcuts.js.map +1 -1
  507. package/dist/components/Icon/components/ShowAll.cjs.map +1 -1
  508. package/dist/components/Icon/components/ShowAll.js.map +1 -1
  509. package/dist/components/Icon/components/ShowLess.cjs.map +1 -1
  510. package/dist/components/Icon/components/ShowLess.js.map +1 -1
  511. package/dist/components/Icon/components/ShowMore.cjs.map +1 -1
  512. package/dist/components/Icon/components/ShowMore.js.map +1 -1
  513. package/dist/components/Icon/components/ShowTemplate.cjs.map +1 -1
  514. package/dist/components/Icon/components/ShowTemplate.js.map +1 -1
  515. package/dist/components/Icon/components/Sliders.cjs.map +1 -1
  516. package/dist/components/Icon/components/Sliders.js.map +1 -1
  517. package/dist/components/Icon/components/Smartpay.cjs.map +1 -1
  518. package/dist/components/Icon/components/Smartpay.js.map +1 -1
  519. package/dist/components/Icon/components/SortBy.cjs.map +1 -1
  520. package/dist/components/Icon/components/SortBy.js.map +1 -1
  521. package/dist/components/Icon/components/Star.cjs.map +1 -1
  522. package/dist/components/Icon/components/Star.js.map +1 -1
  523. package/dist/components/Icon/components/StarSolid.cjs.map +1 -1
  524. package/dist/components/Icon/components/StarSolid.js.map +1 -1
  525. package/dist/components/Icon/components/Subscriptions.cjs.map +1 -1
  526. package/dist/components/Icon/components/Subscriptions.js.map +1 -1
  527. package/dist/components/Icon/components/SystemEntries.cjs.map +1 -1
  528. package/dist/components/Icon/components/SystemEntries.js.map +1 -1
  529. package/dist/components/Icon/components/Tag.cjs.map +1 -1
  530. package/dist/components/Icon/components/Tag.js.map +1 -1
  531. package/dist/components/Icon/components/TemplateOverride.cjs.map +1 -1
  532. package/dist/components/Icon/components/TemplateOverride.js.map +1 -1
  533. package/dist/components/Icon/components/Templates.cjs.map +1 -1
  534. package/dist/components/Icon/components/Templates.js.map +1 -1
  535. package/dist/components/Icon/components/ThumbBoth.cjs.map +1 -1
  536. package/dist/components/Icon/components/ThumbBoth.js.map +1 -1
  537. package/dist/components/Icon/components/ThumbDown.cjs.map +1 -1
  538. package/dist/components/Icon/components/ThumbDown.js.map +1 -1
  539. package/dist/components/Icon/components/ThumbDownSolid.cjs.map +1 -1
  540. package/dist/components/Icon/components/ThumbDownSolid.js.map +1 -1
  541. package/dist/components/Icon/components/ThumbUp.cjs.map +1 -1
  542. package/dist/components/Icon/components/ThumbUp.js.map +1 -1
  543. package/dist/components/Icon/components/ThumbUpSolid.cjs.map +1 -1
  544. package/dist/components/Icon/components/ThumbUpSolid.js.map +1 -1
  545. package/dist/components/Icon/components/Tick.cjs.map +1 -1
  546. package/dist/components/Icon/components/Tick.js.map +1 -1
  547. package/dist/components/Icon/components/TickBold.cjs.map +1 -1
  548. package/dist/components/Icon/components/TickBold.js.map +1 -1
  549. package/dist/components/Icon/components/Time.cjs.map +1 -1
  550. package/dist/components/Icon/components/Time.js.map +1 -1
  551. package/dist/components/Icon/components/Transfer.cjs.map +1 -1
  552. package/dist/components/Icon/components/Transfer.js.map +1 -1
  553. package/dist/components/Icon/components/TransferCancel.cjs.map +1 -1
  554. package/dist/components/Icon/components/TransferCancel.js.map +1 -1
  555. package/dist/components/Icon/components/TransferLocked.cjs.map +1 -1
  556. package/dist/components/Icon/components/TransferLocked.js.map +1 -1
  557. package/dist/components/Icon/components/Undo.cjs.map +1 -1
  558. package/dist/components/Icon/components/Undo.js.map +1 -1
  559. package/dist/components/Icon/components/Undock.cjs.map +1 -1
  560. package/dist/components/Icon/components/Undock.js.map +1 -1
  561. package/dist/components/Icon/components/Unreconciled.cjs.map +1 -1
  562. package/dist/components/Icon/components/Unreconciled.js.map +1 -1
  563. package/dist/components/Icon/components/Wallet.cjs.map +1 -1
  564. package/dist/components/Icon/components/Wallet.js.map +1 -1
  565. package/dist/components/Icon/components/Warning.cjs.map +1 -1
  566. package/dist/components/Icon/components/Warning.js.map +1 -1
  567. package/dist/components/Icon/components/Webshop.cjs.map +1 -1
  568. package/dist/components/Icon/components/Webshop.js.map +1 -1
  569. package/dist/components/Icon/components/Website.cjs.map +1 -1
  570. package/dist/components/Icon/components/Website.js.map +1 -1
  571. package/dist/components/Icon/components/Workflow.cjs.map +1 -1
  572. package/dist/components/Icon/components/Workflow.js.map +1 -1
  573. package/dist/components/Icon/components/WorkflowTemplateBasic.cjs.map +1 -1
  574. package/dist/components/Icon/components/WorkflowTemplateBasic.js.map +1 -1
  575. package/dist/components/Icon/components/Zoom.cjs.map +1 -1
  576. package/dist/components/Icon/components/Zoom.js.map +1 -1
  577. package/dist/components/Input/Input.cjs.map +1 -1
  578. package/dist/components/Input/Input.d.ts +14 -8
  579. package/dist/components/Input/Input.js.map +1 -1
  580. package/dist/components/LegacyComponents/Button/Button.cjs.map +1 -1
  581. package/dist/components/LegacyComponents/Button/Button.d.ts +13 -13
  582. package/dist/components/LegacyComponents/Button/Button.js.map +1 -1
  583. package/dist/components/LegacyComponents/Button/util.cjs.map +1 -1
  584. package/dist/components/LegacyComponents/Button/util.d.ts +2 -2
  585. package/dist/components/LegacyComponents/Button/util.js.map +1 -1
  586. package/dist/components/LegacyComponents/IconButton/IconButton.cjs.map +1 -1
  587. package/dist/components/LegacyComponents/IconButton/IconButton.d.ts +15 -15
  588. package/dist/components/LegacyComponents/IconButton/IconButton.js.map +1 -1
  589. package/dist/components/List/List.cjs.map +1 -1
  590. package/dist/components/List/List.d.ts +3 -3
  591. package/dist/components/List/List.js.map +1 -1
  592. package/dist/components/List/components/Collapsible.cjs.map +1 -1
  593. package/dist/components/List/components/Collapsible.d.ts +2 -2
  594. package/dist/components/List/components/Collapsible.js.map +1 -1
  595. package/dist/components/List/components/Group.cjs.map +1 -1
  596. package/dist/components/List/components/Group.d.ts +2 -2
  597. package/dist/components/List/components/Group.js.map +1 -1
  598. package/dist/components/List/components/Item.cjs.map +1 -1
  599. package/dist/components/List/components/Item.d.ts +7 -7
  600. package/dist/components/List/components/Item.js.map +1 -1
  601. package/dist/components/List/components/Toggle.cjs.map +1 -1
  602. package/dist/components/List/components/Toggle.js.map +1 -1
  603. package/dist/components/Listbox/ScrollableList.cjs.map +1 -1
  604. package/dist/components/Listbox/ScrollableList.d.ts +4 -2
  605. package/dist/components/Listbox/ScrollableList.js.map +1 -1
  606. package/dist/components/Listbox/util.cjs.map +1 -1
  607. package/dist/components/Listbox/util.d.ts +9 -5
  608. package/dist/components/Listbox/util.js.map +1 -1
  609. package/dist/components/Menu/Context.cjs.map +1 -1
  610. package/dist/components/Menu/Context.d.ts +2 -2
  611. package/dist/components/Menu/Context.js.map +1 -1
  612. package/dist/components/Menu/Menu.cjs.map +1 -1
  613. package/dist/components/Menu/Menu.d.ts +1 -1
  614. package/dist/components/Menu/Menu.js.map +1 -1
  615. package/dist/components/Menu/components/Content.cjs.map +1 -1
  616. package/dist/components/Menu/components/Content.js.map +1 -1
  617. package/dist/components/Menu/components/Item.cjs.map +1 -1
  618. package/dist/components/Menu/components/Item.d.ts +2 -2
  619. package/dist/components/Menu/components/Item.js.map +1 -1
  620. package/dist/components/Menu/components/RadioGroup.cjs.map +1 -1
  621. package/dist/components/Menu/components/RadioGroup.js.map +1 -1
  622. package/dist/components/Navigation2/components/Group.cjs.map +1 -1
  623. package/dist/components/Navigation2/components/Group.d.ts +2 -2
  624. package/dist/components/Navigation2/components/Group.js.map +1 -1
  625. package/dist/components/Navigation2/components/Link.cjs.map +1 -1
  626. package/dist/components/Navigation2/components/Link.d.ts +2 -2
  627. package/dist/components/Navigation2/components/Link.js.map +1 -1
  628. package/dist/components/OverflowGroup/OverflowGroup.cjs.map +1 -1
  629. package/dist/components/OverflowGroup/OverflowGroup.js.map +1 -1
  630. package/dist/components/Pagination/PageNumbers.cjs.map +1 -1
  631. package/dist/components/Pagination/PageNumbers.d.ts +2 -1
  632. package/dist/components/Pagination/PageNumbers.js.map +1 -1
  633. package/dist/components/Popover/Popover.cjs.map +1 -1
  634. package/dist/components/Popover/Popover.d.ts +2 -2
  635. package/dist/components/Popover/Popover.js.map +1 -1
  636. package/dist/components/Progress/Progress.cjs.map +1 -1
  637. package/dist/components/Progress/Progress.d.ts +1 -1
  638. package/dist/components/Progress/Progress.js.map +1 -1
  639. package/dist/components/Provider/Provider.cjs.map +1 -1
  640. package/dist/components/Provider/Provider.d.ts +1 -1
  641. package/dist/components/Provider/Provider.js.map +1 -1
  642. package/dist/components/RadioGroup/RadioGroup.cjs.map +1 -1
  643. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  644. package/dist/components/Report/Report.cjs.map +1 -1
  645. package/dist/components/Report/Report.d.ts +1 -1
  646. package/dist/components/Report/Report.js.map +1 -1
  647. package/dist/components/SearchInput2/SearchInput2.cjs.map +1 -1
  648. package/dist/components/SearchInput2/SearchInput2.d.ts +1 -1
  649. package/dist/components/SearchInput2/SearchInput2.js.map +1 -1
  650. package/dist/components/Select/useSelect.cjs.map +1 -1
  651. package/dist/components/Select/useSelect.d.ts +2 -2
  652. package/dist/components/Select/useSelect.js.map +1 -1
  653. package/dist/components/Select2/Select2.cjs +1 -3
  654. package/dist/components/Select2/Select2.cjs.map +1 -1
  655. package/dist/components/Select2/Select2.d.ts +5 -5
  656. package/dist/components/Select2/Select2.js +1 -3
  657. package/dist/components/Select2/Select2.js.map +1 -1
  658. package/dist/components/Select2/components/Context.cjs.map +1 -1
  659. package/dist/components/Select2/components/Context.d.ts +3 -3
  660. package/dist/components/Select2/components/Context.js.map +1 -1
  661. package/dist/components/Select2/components/Option.cjs.map +1 -1
  662. package/dist/components/Select2/components/Option.d.ts +7 -7
  663. package/dist/components/Select2/components/Option.js.map +1 -1
  664. package/dist/components/Select2/components/Search.d.ts +7 -4
  665. package/dist/components/Select2/components/Trigger.cjs +6 -5
  666. package/dist/components/Select2/components/Trigger.cjs.map +1 -1
  667. package/dist/components/Select2/components/Trigger.js +6 -5
  668. package/dist/components/Select2/components/Trigger.js.map +1 -1
  669. package/dist/components/Select2/types.d.ts +1 -1
  670. package/dist/components/Table3/Table3.cjs.map +1 -1
  671. package/dist/components/Table3/Table3.d.ts +1 -1
  672. package/dist/components/Table3/Table3.js.map +1 -1
  673. package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.cjs.map +1 -1
  674. package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.d.ts +1 -1
  675. package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  676. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.cjs.map +1 -1
  677. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  678. package/dist/components/Table3/components/Columns/Cell/EditingDisplayCell.cjs.map +1 -1
  679. package/dist/components/Table3/components/Columns/Cell/EditingDisplayCell.d.ts +2 -1
  680. package/dist/components/Table3/components/Columns/Cell/EditingDisplayCell.js.map +1 -1
  681. package/dist/components/Table3/components/Editing/Alert.cjs +9 -3
  682. package/dist/components/Table3/components/Editing/Alert.cjs.map +1 -1
  683. package/dist/components/Table3/components/Editing/Alert.js +9 -3
  684. package/dist/components/Table3/components/Editing/Alert.js.map +1 -1
  685. package/dist/components/Table3/components/Row/Editing/TemporaryRow.cjs.map +1 -1
  686. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +1 -1
  687. package/dist/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  688. package/dist/components/Table3/features/useEditingState.cjs +14 -6
  689. package/dist/components/Table3/features/useEditingState.cjs.map +1 -1
  690. package/dist/components/Table3/features/useEditingState.d.ts +24 -6
  691. package/dist/components/Table3/features/useEditingState.js +14 -6
  692. package/dist/components/Table3/features/useEditingState.js.map +1 -1
  693. package/dist/components/Table3/features/useTableEditing.d.ts +28 -7
  694. package/dist/components/Tabs/components/TabList.cjs.map +1 -1
  695. package/dist/components/Tabs/components/TabList.js.map +1 -1
  696. package/dist/components/Tabs/components/Trigger.cjs.map +1 -1
  697. package/dist/components/Tabs/components/Trigger.d.ts +2 -2
  698. package/dist/components/Tabs/components/Trigger.js.map +1 -1
  699. package/dist/components/Toast/Toast.cjs.map +1 -1
  700. package/dist/components/Toast/Toast.d.ts +1 -1
  701. package/dist/components/Toast/Toast.js.map +1 -1
  702. package/dist/components/Toast/Toaster.cjs.map +1 -1
  703. package/dist/components/Toast/Toaster.d.ts +1 -1
  704. package/dist/components/Toast/Toaster.js.map +1 -1
  705. package/dist/components/Toast/util.cjs.map +1 -1
  706. package/dist/components/Toast/util.d.ts +2 -1
  707. package/dist/components/Toast/util.js.map +1 -1
  708. package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
  709. package/dist/components/Tooltip/Tooltip.d.ts +2 -2
  710. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  711. package/dist/components/Truncate/Truncate.cjs.map +1 -1
  712. package/dist/components/Truncate/Truncate.d.ts +5 -2
  713. package/dist/components/Truncate/Truncate.js.map +1 -1
  714. package/dist/hooks/useBoundingClientRectListener.cjs.map +1 -1
  715. package/dist/hooks/useBoundingClientRectListener.d.ts +1 -1
  716. package/dist/hooks/useBoundingClientRectListener.js.map +1 -1
  717. package/dist/hooks/useIntersectionObserver.cjs.map +1 -1
  718. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  719. package/dist/hooks/useIntersectionObserver.js.map +1 -1
  720. package/dist/hooks/useMergedRef.cjs.map +1 -1
  721. package/dist/hooks/useMergedRef.js.map +1 -1
  722. package/dist/hooks/useResizeObserver.cjs.map +1 -1
  723. package/dist/hooks/useResizeObserver.d.ts +1 -1
  724. package/dist/hooks/useResizeObserver.js.map +1 -1
  725. package/dist/primitives/Button.cjs.map +1 -1
  726. package/dist/primitives/Button.d.ts +2 -2
  727. package/dist/primitives/Button.js.map +1 -1
  728. package/dist/primitives/Listbox2/components/Option.d.ts +1 -1
  729. package/dist/primitives/Sortable/components/Item.cjs.map +1 -1
  730. package/dist/primitives/Sortable/components/Item.js.map +1 -1
  731. package/dist/primitives/Table/Core/Table.cjs.map +1 -1
  732. package/dist/primitives/Table/Core/Table.d.ts +2 -2
  733. package/dist/primitives/Table/Core/Table.js.map +1 -1
  734. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.cjs.map +1 -1
  735. package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  736. package/dist/primitives/Table/Core/components/Columns/Cell/util.cjs.map +1 -1
  737. package/dist/primitives/Table/Core/components/Columns/Cell/util.d.ts +1 -1
  738. package/dist/primitives/Table/Core/components/Columns/Cell/util.js.map +1 -1
  739. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.cjs.map +1 -1
  740. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  741. package/dist/primitives/Table/Core/components/Footer/Footer.cjs.map +1 -1
  742. package/dist/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  743. package/dist/primitives/Table/Core/components/Header/Header.cjs.map +1 -1
  744. package/dist/primitives/Table/Core/components/Header/Header.d.ts +1 -1
  745. package/dist/primitives/Table/Core/components/Header/Header.js.map +1 -1
  746. package/dist/primitives/Table/Core/components/Header/components/Menu.cjs.map +1 -1
  747. package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -1
  748. package/dist/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  749. package/dist/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.cjs.map +1 -1
  750. package/dist/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.d.ts +1 -1
  751. package/dist/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  752. package/dist/primitives/Table/Core/components/Toolbar/Toolbar.cjs.map +1 -1
  753. package/dist/primitives/Table/Core/components/Toolbar/Toolbar.d.ts +1 -1
  754. package/dist/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
  755. package/dist/primitives/Table/Core/features/useTableRenderer.cjs.map +1 -1
  756. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  757. package/dist/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  758. package/dist/primitives/Table/Core/types.d.ts +3 -3
  759. package/dist/primitives/Table/Core/useTable.cjs.map +1 -1
  760. package/dist/primitives/Table/Core/useTable.d.ts +4 -4
  761. package/dist/primitives/Table/Core/useTable.js.map +1 -1
  762. package/dist/primitives/Table/types.cjs.map +1 -1
  763. package/dist/primitives/Table/types.d.ts +15 -15
  764. package/dist/primitives/Table/types.js.map +1 -1
  765. package/dist/primitives/Table/useTableManager/features/useTableRowSelection.d.ts +1 -1
  766. package/dist/primitives/Table/useTableManager/types.d.ts +2 -2
  767. package/dist/primitives/Table/useTableManager/util/setup.cjs +2 -2
  768. package/dist/primitives/Table/useTableManager/util/setup.cjs.map +1 -1
  769. package/dist/primitives/Table/useTableManager/util/setup.js +2 -2
  770. package/dist/primitives/Table/useTableManager/util/setup.js.map +1 -1
  771. package/dist/types.cjs.map +1 -1
  772. package/dist/types.d.ts +1 -1
  773. package/dist/types.js.map +1 -1
  774. package/package.json +8 -15
@@ -1 +1 @@
1
- {"version":3,"file":"useEditingState.cjs","sources":["../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import type { Table as ReactTable, Cell as ReactTableCell, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { nanoid } from 'nanoid';\nimport React from 'react';\n\nimport { useLocalization } from '../../Provider/Localization';\nimport type {\n Table3EditingChangeHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string | undefined;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n dirty: Record<string, boolean>;\n };\n // we store row indexes because due to server loading, we don't always have all data available\n // so we can't determine an index from a row id\n // note: if the row click button in the error Alert is removed, indexes can be removed here\n indexes: Record<string, number>;\n temporaryRows: TType[];\n // unified state for all row statuses\n statuses: Record<string, EditingSaveState>;\n};\ntype EditingStateAction =\n | {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'complete'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'insertTemporaryRow';\n rowId: string;\n payload?: any;\n }\n | {\n type: 'forceValidate';\n payload?: any;\n };\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, index, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, action.rowId, row, Object),\n dirty: setWith(state.changes.dirty, action.rowId, true, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${action.rowId}.${columnId}`);\n\n const rowChanges = changes[action.rowId];\n\n // if there are no changes left, remove the row\n if (rowChanges && !Object.keys(rowChanges).length) {\n return reducer(state, { type: 'removeRow', rowId: action.rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${action.rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${action.rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${action.rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, index, moveReasons, original, value } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${action.rowId}.cells`,\n cellErrors ?? state.changes.errors[action.rowId]?.cells,\n Object\n ),\n originals: setWith(\n state.changes.originals,\n action.rowId,\n original ?? state.changes.originals[action.rowId],\n Object\n ),\n moveReasons: setWith(\n state.changes.moveReasons,\n action.rowId,\n moveReasons ?? state.changes.moveReasons[action.rowId],\n Object\n ),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, action.rowId),\n errors: omit(state.changes.errors, action.rowId),\n moveReasons: omit(state.changes.moveReasons, action.rowId),\n originals: omit(state.changes.originals, action.rowId),\n dirty: omit(state.changes.dirty, action.rowId),\n },\n indexes: omit(state.indexes, action.rowId),\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor as keyof TType] !== action.rowId),\n };\n }\n\n case 'complete': {\n const { changes, handleDiscard } = payload;\n\n if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {\n return {\n ...state,\n changes: {\n ...state.changes,\n originals: setWith(\n state.changes.originals,\n action.rowId,\n { ...state.changes.originals[action.rowId], ...changes },\n Object\n ),\n },\n };\n }\n\n // bit hacky for now, but editing needs a rewrite\n if (typeof handleDiscard === 'function') {\n handleDiscard();\n }\n\n return state;\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n\n if (status) {\n return {\n ...state,\n statuses: setWith(state.statuses, action.rowId, status, Object),\n };\n }\n // Remove status\n return {\n ...state,\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, action.rowId, errors, Object),\n },\n };\n }\n\n case 'insertTemporaryRow': {\n const { index, value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n originals: setWith(state.changes.originals, action.rowId, value, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'forceValidate': {\n const { newState } = payload;\n\n return {\n ...state,\n ...newState,\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },\n indexes: {},\n temporaryRows: [],\n statuses: {},\n });\n\n // rows\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as keyof TType];\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string): EditingSaveState | undefined {\n return state.statuses[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function showSavedStatus(rowId: string) {\n setRowStatus(rowId, 'saved');\n\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n }\n\n function insertTemporaryRow<T extends TType>(data: Partial<T>, rowIndex: number) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'insertTemporaryRow',\n rowId: newRowId,\n payload: { index: rowIndex, value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId as keyof TType]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n index: rowIndex,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(\n cell: ReactTableCell<T, unknown>,\n rowIndex: number,\n nextValue: any,\n shouldRunUpdaters = true,\n shouldRunValidation = true\n ) {\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n const changes =\n nextValue === undefined\n ? { ...state.changes.rows[cell.row.id] }\n : { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue };\n\n const original = cell.row.original;\n\n if (!Object.keys(changes).length) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...original,\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...original,\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...changes, ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation - if there are changes, and if there is an original stored\n let validationErrors: Record<string, string> = {};\n\n if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {\n // merge with the original so we get a full row\n const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n index: rowIndex,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n original,\n },\n });\n }\n\n async function forceValidate<T extends TType>(table: ReactTable<T>) {\n if (validator && table.getRowModel().rows.length) {\n const newState: EditingState<TType> = { ...state };\n const returnIds: string[] = [];\n\n await Promise.all(\n table.getRowModel().rows.map(async (row, index) => {\n const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };\n\n if (rowWithChanges) {\n const cellErrors = await validator(rowWithChanges);\n\n if (cellErrors) {\n // prep row (it might be new or it might have changes already)\n newState.changes.dirty[row.id] = true;\n newState.changes.originals[row.id] = row.original;\n newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };\n newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };\n newState.statuses[row.id] = 'errored';\n newState.indexes[row.id] = index;\n\n newState.changes.errors[row.id] = {\n cells: cellErrors,\n row: newState.changes.errors[row.id]?.row ?? undefined,\n shouldShowErrorAlert: newState.changes.errors[row.id]?.shouldShowErrorAlert ?? false,\n } as EditingError;\n\n const rowChanges = newState.changes.rows[row.id];\n\n // ensure each errored cell actually has a change\n Object.keys(cellErrors).forEach(columnId => {\n if (rowChanges !== undefined) {\n rowChanges[columnId as keyof TType] = rowWithChanges[columnId as keyof TType];\n }\n });\n\n returnIds.push(row.id);\n }\n }\n })\n );\n\n dispatch({\n type: 'forceValidate',\n payload: {\n newState,\n },\n });\n\n return returnIds;\n }\n\n return [];\n }\n\n // general\n function getErrors() {\n return Object.keys(state.changes.errors);\n }\n\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = getErrors();\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n index: state.indexes[rowId],\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.statuses).filter(status => status === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n if (!handleSave) {\n // oxlint-disable-next-line no-console\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n if (!state.changes.dirty[rowId]) {\n discardChanges(rowId, table);\n continue;\n }\n\n const status = getRowStatus(rowId);\n\n try {\n const rowChanges = JSON.parse(JSON.stringify(changes[rowId] ?? {}));\n\n // don't try to save if - already saving, or there are known errors\n if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...rowChanges };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n // oxlint-disable-next-line no-await-in-loop\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n // oxlint-disable-next-line no-await-in-loop\n await handleSave(changeSet);\n\n complete(rowId, table, rowChanges);\n showSavedStatus(rowId);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n // oxlint-disable-next-line no-console\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n async function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n if (rowId.startsWith(TEMPORARY_ROW_ID_PREFIX)) {\n table.resetRowPinning(true);\n }\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n\n if (typeof handleDiscard === 'function') {\n await handleDiscard();\n }\n }\n\n function complete<T extends TType>(rowId: string, table: ReactTable<T>, changes: Partial<T>) {\n const handleDiscard = async () => {\n await discardChanges(rowId, table);\n };\n\n dispatch({\n type: 'complete',\n rowId,\n payload: { rowIdentityAccessor, changes, handleDiscard },\n });\n }\n\n function getState() {\n return state;\n }\n\n return {\n getState,\n // row\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n forceValidate,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrors,\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n insertTemporaryRow,\n temporaryRows: state.temporaryRows,\n isDirty: hasChanges() || state.temporaryRows.length > 0,\n };\n}\n"],"names":["useLocalization","TEMPORARY_ROW_ID_PREFIX","nanoid","state","willRowMove","rowId","isTemporaryRow","handleDiscard"],"mapp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AAAA,YAAA;AAAA,UAC1B,CACH;AAAA,QACL;AAEA,qBAAaA,QAAO,SAAS;AAC7B,oBAAY;AAAA,MAChB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,iBAAe,eAAgC,OAAe,OAAsB;AAEhF,QAAI,MAAM,WAAWJ,QAAAA,uBAAuB,GAAG;AAC3C,YAAM,gBAAgB,IAAI;AAAA,IAC9B;AAEA,aAAS;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,SAAS,EAAE,oBAAA;AAAA,IAAoB,CAClC;AAED,QAAI,OAAO,kBAAkB,YAAY;AACrC,YAAM,cAAA;AAAA,IACV;AAAA,EACJ;AAEA,WAAS,SAA0B,OAAe,OAAsB,SAAqB;AACzF,UAAMM,iBAAgB,YAAY;AAC9B,YAAM,eAAe,OAAO,KAAK;AAAA,IACrC;AAEA,aAAS;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,SAAS,EAAE,qBAAqB,SAAS,eAAAA,eAAAA;AAAAA,IAAc,CAC1D;AAAA,EACL;AAEA,WAAS,WAAW;AAChB,WAAO;AAAA,EACX;AAEA,SAAO;AAAA,IACH;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA,eAAe,MAAM;AAAA,IACrB,SAAS,WAAA,KAAgB,MAAM,cAAc,SAAS;AAAA,EAAA;AAE9D;;"}
1
+ {"version":3,"file":"useEditingState.cjs","sources":["../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import type { Table as ReactTable, Cell as ReactTableCell, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { nanoid } from 'nanoid';\nimport React from 'react';\n\nimport { useLocalization } from '../../Provider/Localization';\nimport type {\n Table3EditingChangeHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string | undefined;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n dirty: Record<string, boolean>;\n };\n // we store row indexes because due to server loading, we don't always have all data available\n // so we can't determine an index from a row id\n // note: if the row click button in the error Alert is removed, indexes can be removed here\n indexes: Record<string, number>;\n temporaryRows: TType[];\n // unified state for all row statuses\n statuses: Record<string, EditingSaveState>;\n};\ntype EditingStateAction =\n | {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'complete'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'insertTemporaryRow';\n rowId: string;\n payload?: any;\n }\n | {\n type: 'forceValidate';\n payload?: any;\n };\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, index, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, action.rowId, row, Object),\n dirty: setWith(state.changes.dirty, action.rowId, true, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${action.rowId}.${columnId}`);\n\n const rowChanges = changes[action.rowId];\n\n // if there are no changes left, remove the row\n if (rowChanges && !Object.keys(rowChanges).length) {\n return reducer(state, { type: 'removeRow', rowId: action.rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${action.rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${action.rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${action.rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, index, moveReasons, original, value } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${action.rowId}.cells`,\n cellErrors ?? state.changes.errors[action.rowId]?.cells,\n Object\n ),\n originals: setWith(\n state.changes.originals,\n action.rowId,\n original ?? state.changes.originals[action.rowId],\n Object\n ),\n moveReasons: setWith(\n state.changes.moveReasons,\n action.rowId,\n moveReasons ?? state.changes.moveReasons[action.rowId],\n Object\n ),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, action.rowId),\n errors: omit(state.changes.errors, action.rowId),\n moveReasons: omit(state.changes.moveReasons, action.rowId),\n originals: omit(state.changes.originals, action.rowId),\n dirty: omit(state.changes.dirty, action.rowId),\n },\n indexes: omit(state.indexes, action.rowId),\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor as keyof TType] !== action.rowId),\n };\n }\n\n case 'complete': {\n const { changes, handleDiscard } = payload;\n\n if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {\n return {\n ...state,\n changes: {\n ...state.changes,\n originals: setWith(\n state.changes.originals,\n action.rowId,\n { ...state.changes.originals[action.rowId], ...changes },\n Object\n ),\n },\n };\n }\n\n // bit hacky for now, but editing needs a rewrite\n if (typeof handleDiscard === 'function') {\n handleDiscard();\n }\n\n return state;\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n\n if (status) {\n return {\n ...state,\n statuses: setWith(state.statuses, action.rowId, status, Object),\n };\n }\n // Remove status\n return {\n ...state,\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, action.rowId, errors, Object),\n },\n };\n }\n\n case 'insertTemporaryRow': {\n const { index, value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n originals: setWith(state.changes.originals, action.rowId, value, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'forceValidate': {\n const { newState } = payload;\n\n return {\n ...state,\n ...newState,\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer<EditingState<TType>, [EditingStateAction]>(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },\n indexes: {},\n temporaryRows: [],\n statuses: {},\n });\n\n // rows\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as keyof TType] as string;\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string): EditingSaveState | undefined {\n return state.statuses[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function showSavedStatus(rowId: string) {\n setRowStatus(rowId, 'saved');\n\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n }\n\n function insertTemporaryRow<T extends TType>(data: Partial<T>, rowIndex: number) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'insertTemporaryRow',\n rowId: newRowId,\n payload: { index: rowIndex, value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId as keyof TType]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n index: rowIndex,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id as keyof TType];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(\n cell: ReactTableCell<T, unknown>,\n rowIndex: number,\n nextValue: any,\n shouldRunUpdaters = true,\n shouldRunValidation = true\n ) {\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n // keyed by runtime column id, so a string-keyed record rather than Partial<TType>\n const changes: Record<string, unknown> =\n nextValue === undefined\n ? { ...state.changes.rows[cell.row.id] }\n : { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue };\n\n const original = cell.row.original;\n\n if (!Object.keys(changes).length) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...original,\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...original,\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...changes, ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation - if there are changes, and if there is an original stored\n let validationErrors: Record<string, string> = {};\n\n if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {\n // merge with the original so we get a full row\n const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n index: rowIndex,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n original,\n },\n });\n }\n\n async function forceValidate<T extends TType>(table: ReactTable<T>) {\n if (validator && table.getRowModel().rows.length) {\n const newState: EditingState<TType> = { ...state };\n const returnIds: string[] = [];\n\n await Promise.all(\n table.getRowModel().rows.map(async (row, index) => {\n const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };\n\n if (rowWithChanges) {\n const cellErrors = await validator(rowWithChanges);\n\n if (cellErrors) {\n // prep row (it might be new or it might have changes already)\n newState.changes.dirty[row.id] = true;\n newState.changes.originals[row.id] = row.original;\n newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };\n newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };\n newState.statuses[row.id] = 'errored';\n newState.indexes[row.id] = index;\n\n newState.changes.errors[row.id] = {\n cells: cellErrors,\n row: newState.changes.errors[row.id]?.row ?? undefined,\n shouldShowErrorAlert: newState.changes.errors[row.id]?.shouldShowErrorAlert ?? false,\n } as EditingError;\n\n const rowChanges = newState.changes.rows[row.id];\n\n // ensure each errored cell actually has a change\n Object.keys(cellErrors).forEach(columnId => {\n if (rowChanges !== undefined) {\n rowChanges[columnId as keyof TType] = rowWithChanges[columnId as keyof TType];\n }\n });\n\n returnIds.push(row.id);\n }\n }\n })\n );\n\n dispatch({\n type: 'forceValidate',\n payload: {\n newState,\n },\n });\n\n return returnIds;\n }\n\n return [];\n }\n\n // general\n function getErrors() {\n return Object.keys(state.changes.errors);\n }\n\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = getErrors();\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).flatMap(rowId => {\n const errors = state.changes.errors[rowId];\n\n // hasRowErrorsShownInAlert already guarantees this, the check is here to narrow the type\n if (!errors) {\n return [];\n }\n\n return [\n {\n rowId,\n index: state.indexes[rowId],\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors,\n },\n ];\n });\n }\n\n function hasSaved() {\n return !!Object.values(state.statuses).filter(status => status === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n if (!handleSave) {\n // oxlint-disable-next-line no-console\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n if (!state.changes.dirty[rowId]) {\n discardChanges(rowId, table);\n continue;\n }\n\n const status = getRowStatus(rowId);\n\n try {\n const rowChanges = JSON.parse(JSON.stringify(changes[rowId] ?? {}));\n\n // don't try to save if - already saving, or there are known errors\n if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...(state.changes.originals[rowId] as object), ...rowChanges };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n // oxlint-disable-next-line no-await-in-loop\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n // oxlint-disable-next-line no-await-in-loop\n await handleSave(changeSet);\n\n complete(rowId, table, rowChanges);\n showSavedStatus(rowId);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n // oxlint-disable-next-line no-console\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n async function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n if (rowId.startsWith(TEMPORARY_ROW_ID_PREFIX)) {\n table.resetRowPinning(true);\n }\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n\n if (typeof handleDiscard === 'function') {\n await handleDiscard();\n }\n }\n\n function complete<T extends TType>(rowId: string, table: ReactTable<T>, changes: Partial<T>) {\n const handleDiscard = async () => {\n await discardChanges(rowId, table);\n };\n\n dispatch({\n type: 'complete',\n rowId,\n payload: { rowIdentityAccessor, changes, handleDiscard },\n });\n }\n\n function getState() {\n return state;\n }\n\n return {\n getState,\n // row\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n forceValidate,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrors,\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n insertTemporaryRow,\n temporaryRows: state.temporaryRows,\n isDirty: hasChanges() || state.temporaryRows.length > 0,\n };\n}\n"],"names":["useLocalization","TEMPORARY_ROW_ID_PREFIX","nanoid","state","willRowMove","rowId","isTemporaryRow","handleDiscard"],"mappings":";;;;;;;;AAeA,MAAM,oCAAoC;AA8C1C,SAAS,QAAyB,OAA4B,QAA4B;AACtF,QAAM,EAAE,MAAM,QAAA,IAAY;AAE1B,UAAQ,MAAA;AAAA,IACJ,KAAK,gBAAgB;AACjB,YAAM,EAAE,UAAU,OAAO,KAAK,UAAU;AACxC,aAAO;AAAA,QACH,GAAG;AAAA,QACH,SAAS;AAAA,UACL,GAAG,MAAM;AAAA,UACT,MAAM,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,MAAM;AAAA,UAC9E,WAAW,QAAQ,MAAM,QAAQ,WAAW,OAAO,OAAO,KAAK,MAAM;AAAA,UACrE,OAAO,QAAQ,MAAM,QAAQ,OAAO,OAAO,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,QAElE,SAAS,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM;AAAA,MAAA;AAAA,IAEnE;AAAA,IAEA,KAAK,mBAAmB;AACpB,YAAM,EAAE,UAAU,oBAAA,IAAwB;AAC1C,YAAM,UAAU,KAAK,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAK,IAAI,QAAQ,EAAE;AAEtE,YAAM,aAAa,QAAQ,OAAO,KAAK;AAGvC,UAAI,cAAc,CAAC,OAAO,KAA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O;AAAA,IACH;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA,eAAe,MAAM;AAAA,IACrB,SAAS,WAAA,KAAgB,MAAM,cAAc,SAAS;AAAA,EAAA;AAE9D;;"}
@@ -1,11 +1,29 @@
1
1
  import { Table as ReactTable, Cell as ReactTableCell } from '@tanstack/react-table';
2
2
  import { Table3EditingChangeHandler, Table3EditingDiscardHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
3
+ type EditingError = {
4
+ row: string | undefined;
5
+ cells: Record<string, string>;
6
+ shouldShowErrorAlert: boolean;
7
+ };
8
+ type EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;
3
9
  type EditingSaveState = 'saving' | 'saved' | 'errored';
4
10
  type EditingChangeset<TType = unknown> = Partial<TType>;
11
+ type EditingState<TType = unknown> = {
12
+ changes: {
13
+ rows: Record<string, EditingChangeset<TType>>;
14
+ errors: Record<string, EditingError>;
15
+ moveReasons: Record<string, EditingRowMoveReason>;
16
+ originals: Record<string, TType>;
17
+ dirty: Record<string, boolean>;
18
+ };
19
+ indexes: Record<string, number>;
20
+ temporaryRows: TType[];
21
+ statuses: Record<string, EditingSaveState>;
22
+ };
5
23
  export declare function usePendingChangesState<TType = unknown>(handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, handleDiscard: Table3EditingDiscardHandler | undefined, rowIdentityAccessor: keyof TType, validator: Table3EditingValidatorFn<TType> | undefined): {
6
- getState: () => any;
7
- getRowValue: (rowId: string) => any;
8
- getRowMoveReason: (rowId: string) => {} | undefined;
24
+ getState: () => EditingState<TType>;
25
+ getRowValue: (rowId: string) => Partial<TType> | undefined;
26
+ getRowMoveReason: (rowId: string) => "search" | "filter" | "sorting" | undefined;
9
27
  hasRowErrors: (rowId: string) => boolean;
10
28
  hasRowErrorsShownInAlert: (rowId: string) => boolean;
11
29
  hasTemporaryRowErrors: <T extends TType>() => boolean;
@@ -19,16 +37,16 @@ export declare function usePendingChangesState<TType = unknown>(handleSave: Tabl
19
37
  getErrors: () => string[];
20
38
  getErrorsShownInAlert: <T extends TType>() => {
21
39
  rowId: string;
22
- index: any;
40
+ index: number | undefined;
23
41
  changes: EditingChangeset<T>;
24
- errors: any;
42
+ errors: EditingError;
25
43
  }[];
26
44
  hasChanges: (rowId?: string) => boolean;
27
45
  saveChanges: <T extends TType>(table: ReactTable<T>, rowId?: string | undefined) => Promise<boolean>;
28
46
  discardChanges: <T extends TType>(rowId: string, table: ReactTable<T>) => Promise<void>;
29
47
  hasSaved: () => boolean;
30
48
  insertTemporaryRow: <T extends TType>(data: Partial<T>, rowIndex: number) => string;
31
- temporaryRows: any;
49
+ temporaryRows: TType[];
32
50
  isDirty: boolean;
33
51
  };
34
52
  export {};
@@ -355,12 +355,20 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
355
355
  if (!rowsWithErrors.length) {
356
356
  return [];
357
357
  }
358
- return rowsWithErrors.filter(hasRowErrorsShownInAlert).map((rowId) => ({
359
- rowId,
360
- index: state.indexes[rowId],
361
- changes: state.changes.rows[rowId],
362
- errors: state.changes.errors[rowId]
363
- }));
358
+ return rowsWithErrors.filter(hasRowErrorsShownInAlert).flatMap((rowId) => {
359
+ const errors = state.changes.errors[rowId];
360
+ if (!errors) {
361
+ return [];
362
+ }
363
+ return [
364
+ {
365
+ rowId,
366
+ index: state.indexes[rowId],
367
+ changes: state.changes.rows[rowId],
368
+ errors
369
+ }
370
+ ];
371
+ });
364
372
  }
365
373
  function hasSaved() {
366
374
  return !!Object.values(state.statuses).filter((status) => status === "saved").length;
@@ -1 +1 @@
1
- {"version":3,"file":"useEditingState.js","sources":["../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import type { Table as ReactTable, Cell as ReactTableCell, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { nanoid } from 'nanoid';\nimport React from 'react';\n\nimport { useLocalization } from '../../Provider/Localization';\nimport type {\n Table3EditingChangeHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string | undefined;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n dirty: Record<string, boolean>;\n };\n // we store row indexes because due to server loading, we don't always have all data available\n // so we can't determine an index from a row id\n // note: if the row click button in the error Alert is removed, indexes can be removed here\n indexes: Record<string, number>;\n temporaryRows: TType[];\n // unified state for all row statuses\n statuses: Record<string, EditingSaveState>;\n};\ntype EditingStateAction =\n | {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'complete'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'insertTemporaryRow';\n rowId: string;\n payload?: any;\n }\n | {\n type: 'forceValidate';\n payload?: any;\n };\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, index, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, action.rowId, row, Object),\n dirty: setWith(state.changes.dirty, action.rowId, true, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${action.rowId}.${columnId}`);\n\n const rowChanges = changes[action.rowId];\n\n // if there are no changes left, remove the row\n if (rowChanges && !Object.keys(rowChanges).length) {\n return reducer(state, { type: 'removeRow', rowId: action.rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${action.rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${action.rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${action.rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, index, moveReasons, original, value } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${action.rowId}.cells`,\n cellErrors ?? state.changes.errors[action.rowId]?.cells,\n Object\n ),\n originals: setWith(\n state.changes.originals,\n action.rowId,\n original ?? state.changes.originals[action.rowId],\n Object\n ),\n moveReasons: setWith(\n state.changes.moveReasons,\n action.rowId,\n moveReasons ?? state.changes.moveReasons[action.rowId],\n Object\n ),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, action.rowId),\n errors: omit(state.changes.errors, action.rowId),\n moveReasons: omit(state.changes.moveReasons, action.rowId),\n originals: omit(state.changes.originals, action.rowId),\n dirty: omit(state.changes.dirty, action.rowId),\n },\n indexes: omit(state.indexes, action.rowId),\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor as keyof TType] !== action.rowId),\n };\n }\n\n case 'complete': {\n const { changes, handleDiscard } = payload;\n\n if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {\n return {\n ...state,\n changes: {\n ...state.changes,\n originals: setWith(\n state.changes.originals,\n action.rowId,\n { ...state.changes.originals[action.rowId], ...changes },\n Object\n ),\n },\n };\n }\n\n // bit hacky for now, but editing needs a rewrite\n if (typeof handleDiscard === 'function') {\n handleDiscard();\n }\n\n return state;\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n\n if (status) {\n return {\n ...state,\n statuses: setWith(state.statuses, action.rowId, status, Object),\n };\n }\n // Remove status\n return {\n ...state,\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, action.rowId, errors, Object),\n },\n };\n }\n\n case 'insertTemporaryRow': {\n const { index, value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n originals: setWith(state.changes.originals, action.rowId, value, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'forceValidate': {\n const { newState } = payload;\n\n return {\n ...state,\n ...newState,\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },\n indexes: {},\n temporaryRows: [],\n statuses: {},\n });\n\n // rows\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as keyof TType];\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string): EditingSaveState | undefined {\n return state.statuses[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function showSavedStatus(rowId: string) {\n setRowStatus(rowId, 'saved');\n\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n }\n\n function insertTemporaryRow<T extends TType>(data: Partial<T>, rowIndex: number) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'insertTemporaryRow',\n rowId: newRowId,\n payload: { index: rowIndex, value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId as keyof TType]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n index: rowIndex,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(\n cell: ReactTableCell<T, unknown>,\n rowIndex: number,\n nextValue: any,\n shouldRunUpdaters = true,\n shouldRunValidation = true\n ) {\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n const changes =\n nextValue === undefined\n ? { ...state.changes.rows[cell.row.id] }\n : { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue };\n\n const original = cell.row.original;\n\n if (!Object.keys(changes).length) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...original,\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...original,\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...changes, ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation - if there are changes, and if there is an original stored\n let validationErrors: Record<string, string> = {};\n\n if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {\n // merge with the original so we get a full row\n const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n index: rowIndex,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n original,\n },\n });\n }\n\n async function forceValidate<T extends TType>(table: ReactTable<T>) {\n if (validator && table.getRowModel().rows.length) {\n const newState: EditingState<TType> = { ...state };\n const returnIds: string[] = [];\n\n await Promise.all(\n table.getRowModel().rows.map(async (row, index) => {\n const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };\n\n if (rowWithChanges) {\n const cellErrors = await validator(rowWithChanges);\n\n if (cellErrors) {\n // prep row (it might be new or it might have changes already)\n newState.changes.dirty[row.id] = true;\n newState.changes.originals[row.id] = row.original;\n newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };\n newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };\n newState.statuses[row.id] = 'errored';\n newState.indexes[row.id] = index;\n\n newState.changes.errors[row.id] = {\n cells: cellErrors,\n row: newState.changes.errors[row.id]?.row ?? undefined,\n shouldShowErrorAlert: newState.changes.errors[row.id]?.shouldShowErrorAlert ?? false,\n } as EditingError;\n\n const rowChanges = newState.changes.rows[row.id];\n\n // ensure each errored cell actually has a change\n Object.keys(cellErrors).forEach(columnId => {\n if (rowChanges !== undefined) {\n rowChanges[columnId as keyof TType] = rowWithChanges[columnId as keyof TType];\n }\n });\n\n returnIds.push(row.id);\n }\n }\n })\n );\n\n dispatch({\n type: 'forceValidate',\n payload: {\n newState,\n },\n });\n\n return returnIds;\n }\n\n return [];\n }\n\n // general\n function getErrors() {\n return Object.keys(state.changes.errors);\n }\n\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = getErrors();\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n index: state.indexes[rowId],\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.statuses).filter(status => status === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n if (!handleSave) {\n // oxlint-disable-next-line no-console\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n if (!state.changes.dirty[rowId]) {\n discardChanges(rowId, table);\n continue;\n }\n\n const status = getRowStatus(rowId);\n\n try {\n const rowChanges = JSON.parse(JSON.stringify(changes[rowId] ?? {}));\n\n // don't try to save if - already saving, or there are known errors\n if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...rowChanges };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n // oxlint-disable-next-line no-await-in-loop\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n // oxlint-disable-next-line no-await-in-loop\n await handleSave(changeSet);\n\n complete(rowId, table, rowChanges);\n showSavedStatus(rowId);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n // oxlint-disable-next-line no-console\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n async function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n if (rowId.startsWith(TEMPORARY_ROW_ID_PREFIX)) {\n table.resetRowPinning(true);\n }\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n\n if (typeof handleDiscard === 'function') {\n await handleDiscard();\n }\n }\n\n function complete<T extends TType>(rowId: string, table: ReactTable<T>, changes: Partial<T>) {\n const handleDiscard = async () => {\n await discardChanges(rowId, table);\n };\n\n dispatch({\n type: 'complete',\n rowId,\n payload: { rowIdentityAccessor, changes, handleDiscard },\n });\n }\n\n function getState() {\n return state;\n }\n\n return {\n getState,\n // row\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n forceValidate,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrors,\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n insertTemporaryRow,\n temporaryRows: state.temporaryRows,\n isDirty: hasChanges() || state.temporaryRows.length > 0,\n };\n}\n"],"names":["React","state","rowId","handleDiscard"],"mappings":";;;;;;AAeA,MAAM,oCAAoC;AA8C1C,SAAS,QAAyB,OAA4B,QAA4B;AACtF,QAAM,EAAE,MAAM,QAAA,IAAY;AAE1B,UAAQ,MAAA;AAAA,IACJ,KAAK,gBAAgB;AACjB,YAAM,EAAE,UAAU,OAAO,KAAK,UAAU;AACxC,aAAO;AAAA,QACH,GAAG;AAAA,QACH,SAAS;AAAA,UACL,GAAG,MAAM;AAAA,UACT,MAAM,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,MAAM;AAAA,UAC9E,WAAW,QAAQ,MAAM,QAAQ,WAAW,OAAO,OAAO,KAAK,MAAM;AAAA,UACrE,OAAO,QAAQ,MAAM,QAAQ,OAAO,OAAO,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,QAElE,SAAS,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM;AAAA,MAAA;AAAA,IAEnE;AAAA,IAEA,KAAK,mBAAmB;AACpB,YAAM,EAAE,UAAU,oBAAA,IAAwB;AAC1C,YAAM,UAAU,KAAK,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAK,IAAI,QAAQ,EAAE;AAEtE,YAAM,aAAa,QAAQ,OAAO,KAAK;AAGvC,UAAI,cAAc,CAAC,OAAO,KAAK,UAAU,EAAE,QAAQ;AAC/C,eAAO,QAAQ,OAAO,EAAE,MAAM,aAAa,OAAO,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;AAAA;AAAA,IAEA;AAAA,IACA,eAAe,MAAM;AAAA,IACrB,SAAS,WAAA,KAAgB,MAAM,cAAc,SAAS;AAAA,EAAA;AAE9D;"}
1
+ {"version":3,"file":"useEditingState.js","sources":["../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import type { Table as ReactTable, Cell as ReactTableCell, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { nanoid } from 'nanoid';\nimport React from 'react';\n\nimport { useLocalization } from '../../Provider/Localization';\nimport type {\n Table3EditingChangeHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string | undefined;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n dirty: Record<string, boolean>;\n };\n // we store row indexes because due to server loading, we don't always have all data available\n // so we can't determine an index from a row id\n // note: if the row click button in the error Alert is removed, indexes can be removed here\n indexes: Record<string, number>;\n temporaryRows: TType[];\n // unified state for all row statuses\n statuses: Record<string, EditingSaveState>;\n};\ntype EditingStateAction =\n | {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'complete'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'insertTemporaryRow';\n rowId: string;\n payload?: any;\n }\n | {\n type: 'forceValidate';\n payload?: any;\n };\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, index, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${action.rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, action.rowId, row, Object),\n dirty: setWith(state.changes.dirty, action.rowId, true, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${action.rowId}.${columnId}`);\n\n const rowChanges = changes[action.rowId];\n\n // if there are no changes left, remove the row\n if (rowChanges && !Object.keys(rowChanges).length) {\n return reducer(state, { type: 'removeRow', rowId: action.rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${action.rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${action.rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${action.rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, index, moveReasons, original, value } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${action.rowId}.cells`,\n cellErrors ?? state.changes.errors[action.rowId]?.cells,\n Object\n ),\n originals: setWith(\n state.changes.originals,\n action.rowId,\n original ?? state.changes.originals[action.rowId],\n Object\n ),\n moveReasons: setWith(\n state.changes.moveReasons,\n action.rowId,\n moveReasons ?? state.changes.moveReasons[action.rowId],\n Object\n ),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, action.rowId),\n errors: omit(state.changes.errors, action.rowId),\n moveReasons: omit(state.changes.moveReasons, action.rowId),\n originals: omit(state.changes.originals, action.rowId),\n dirty: omit(state.changes.dirty, action.rowId),\n },\n indexes: omit(state.indexes, action.rowId),\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor as keyof TType] !== action.rowId),\n };\n }\n\n case 'complete': {\n const { changes, handleDiscard } = payload;\n\n if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[action.rowId])) {\n return {\n ...state,\n changes: {\n ...state.changes,\n originals: setWith(\n state.changes.originals,\n action.rowId,\n { ...state.changes.originals[action.rowId], ...changes },\n Object\n ),\n },\n };\n }\n\n // bit hacky for now, but editing needs a rewrite\n if (typeof handleDiscard === 'function') {\n handleDiscard();\n }\n\n return state;\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n\n if (status) {\n return {\n ...state,\n statuses: setWith(state.statuses, action.rowId, status, Object),\n };\n }\n // Remove status\n return {\n ...state,\n statuses: omit(state.statuses, action.rowId),\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, action.rowId, errors, Object),\n },\n };\n }\n\n case 'insertTemporaryRow': {\n const { index, value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, action.rowId, value, Object),\n originals: setWith(state.changes.originals, action.rowId, value, Object),\n },\n indexes: setWith(state.indexes, action.rowId, index, Object),\n };\n }\n\n case 'forceValidate': {\n const { newState } = payload;\n\n return {\n ...state,\n ...newState,\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer<EditingState<TType>, [EditingStateAction]>(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, dirty: {} },\n indexes: {},\n temporaryRows: [],\n statuses: {},\n });\n\n // rows\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as keyof TType] as string;\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string): EditingSaveState | undefined {\n return state.statuses[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function showSavedStatus(rowId: string) {\n setRowStatus(rowId, 'saved');\n\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n }\n\n function insertTemporaryRow<T extends TType>(data: Partial<T>, rowIndex: number) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${nanoid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'insertTemporaryRow',\n rowId: newRowId,\n payload: { index: rowIndex, value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId as keyof TType]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n index: rowIndex,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id as keyof TType];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(\n cell: ReactTableCell<T, unknown>,\n rowIndex: number,\n nextValue: any,\n shouldRunUpdaters = true,\n shouldRunValidation = true\n ) {\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n // keyed by runtime column id, so a string-keyed record rather than Partial<TType>\n const changes: Record<string, unknown> =\n nextValue === undefined\n ? { ...state.changes.rows[cell.row.id] }\n : { ...state.changes.rows[cell.row.id], [cell.column.id]: nextValue };\n\n const original = cell.row.original;\n\n if (!Object.keys(changes).length) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...original,\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...original,\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...changes, ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation - if there are changes, and if there is an original stored\n let validationErrors: Record<string, string> = {};\n\n if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {\n // merge with the original so we get a full row\n const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n index: rowIndex,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n original,\n },\n });\n }\n\n async function forceValidate<T extends TType>(table: ReactTable<T>) {\n if (validator && table.getRowModel().rows.length) {\n const newState: EditingState<TType> = { ...state };\n const returnIds: string[] = [];\n\n await Promise.all(\n table.getRowModel().rows.map(async (row, index) => {\n const rowWithChanges = { ...row.original, ...state.changes.rows[row.id] };\n\n if (rowWithChanges) {\n const cellErrors = await validator(rowWithChanges);\n\n if (cellErrors) {\n // prep row (it might be new or it might have changes already)\n newState.changes.dirty[row.id] = true;\n newState.changes.originals[row.id] = row.original;\n newState.changes.moveReasons[row.id] = { ...newState.changes.moveReasons[row.id] };\n newState.changes.rows[row.id] = { ...newState.changes.rows[row.id] };\n newState.statuses[row.id] = 'errored';\n newState.indexes[row.id] = index;\n\n newState.changes.errors[row.id] = {\n cells: cellErrors,\n row: newState.changes.errors[row.id]?.row ?? undefined,\n shouldShowErrorAlert: newState.changes.errors[row.id]?.shouldShowErrorAlert ?? false,\n } as EditingError;\n\n const rowChanges = newState.changes.rows[row.id];\n\n // ensure each errored cell actually has a change\n Object.keys(cellErrors).forEach(columnId => {\n if (rowChanges !== undefined) {\n rowChanges[columnId as keyof TType] = rowWithChanges[columnId as keyof TType];\n }\n });\n\n returnIds.push(row.id);\n }\n }\n })\n );\n\n dispatch({\n type: 'forceValidate',\n payload: {\n newState,\n },\n });\n\n return returnIds;\n }\n\n return [];\n }\n\n // general\n function getErrors() {\n return Object.keys(state.changes.errors);\n }\n\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = getErrors();\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).flatMap(rowId => {\n const errors = state.changes.errors[rowId];\n\n // hasRowErrorsShownInAlert already guarantees this, the check is here to narrow the type\n if (!errors) {\n return [];\n }\n\n return [\n {\n rowId,\n index: state.indexes[rowId],\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors,\n },\n ];\n });\n }\n\n function hasSaved() {\n return !!Object.values(state.statuses).filter(status => status === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const state = tableMeta.editing.getState();\n\n if (!handleSave) {\n // oxlint-disable-next-line no-console\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n if (!state.changes.dirty[rowId]) {\n discardChanges(rowId, table);\n continue;\n }\n\n const status = getRowStatus(rowId);\n\n try {\n const rowChanges = JSON.parse(JSON.stringify(changes[rowId] ?? {}));\n\n // don't try to save if - already saving, or there are known errors\n if (!Object.keys(rowChanges).length || status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...(state.changes.originals[rowId] as object), ...rowChanges };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n // oxlint-disable-next-line no-await-in-loop\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n // oxlint-disable-next-line no-await-in-loop\n await handleSave(changeSet);\n\n complete(rowId, table, rowChanges);\n showSavedStatus(rowId);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n // oxlint-disable-next-line no-console\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n async function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n if (rowId.startsWith(TEMPORARY_ROW_ID_PREFIX)) {\n table.resetRowPinning(true);\n }\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n\n if (typeof handleDiscard === 'function') {\n await handleDiscard();\n }\n }\n\n function complete<T extends TType>(rowId: string, table: ReactTable<T>, changes: Partial<T>) {\n const handleDiscard = async () => {\n await discardChanges(rowId, table);\n };\n\n dispatch({\n type: 'complete',\n rowId,\n payload: { rowIdentityAccessor, changes, handleDiscard },\n });\n }\n\n function getState() {\n return state;\n }\n\n return {\n getState,\n // row\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n forceValidate,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrors,\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n insertTemporaryRow,\n temporaryRows: state.temporaryRows,\n isDirty: hasChanges() || state.temporaryRows.length > 0,\n };\n}\n"],"names":["React","state","rowId","handleDiscard"],"mappings":";;;;;;AAeA,MAAM,oCAAoC;AA8C1C,SAAS,QAAyB,OAA4B,QAA4B;AACtF,QAAM,EAAE,MAAM,QAAA,IAAY;AAE1B,UAAQ,MAAA;AAAA,IACJ,KAAK,gBAAgB;AACjB,YAAM,EAAE,UAAU,OAAO,KAAK,UAAU;AACxC,aAAO;AAAA,QACH,GAAG;AAAA,QACH,SAAS;AAAA,UACL,GAAG,MAAM;AAAA,UACT,MAAM,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,MAAM;AAAA,UAC9E,WAAW,QAAQ,MAAM,QAAQ,WAAW,OAAO,OAAO,KAAK,MAAM;AAAA,UACrE,OAAO,QAAQ,MAAM,QAAQ,OAAO,OAAO,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,QAElE,SAAS,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM;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AAe,OAAO,KAAK;AAAA,IACrC;AAEA,aAAS;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,SAAS,EAAE,qBAAqB,SAAS,eAAAA,eAAAA;AAAAA,IAAc,CAC1D;AAAA,EACL;AAEA,WAAS,WAAW;AAChB,WAAO;AAAA,EACX;AAEA,SAAO;AAAA,IACH;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA,eAAe,MAAM;AAAA,IACrB,SAAS,WAAA,KAAgB,MAAM,cAAc,SAAS;AAAA,EAAA;AAE9D;"}
@@ -3,9 +3,26 @@ import { default as React } from 'react';
3
3
  import { TableEventHandler } from '../../../primitives/Table/types';
4
4
  import { Table3EditingChangeHandler, Table3EditingCreateHandler, Table3EditingDiscardHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
5
5
  export declare function useTableEditing<TType = unknown>(isEnabled: boolean | undefined, defaultToggleEditing: boolean | undefined, handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, handleCreate: Table3EditingCreateHandler<TType> | undefined, handleDiscard: Table3EditingDiscardHandler | undefined, rowIdentityAccessor: keyof TType | undefined, validator: Table3EditingValidatorFn<TType> | undefined, showEditingActions?: boolean, onEvent?: TableEventHandler | undefined): {
6
- getState: () => any;
7
- getRowValue: (rowId: string) => any;
8
- getRowMoveReason: (rowId: string) => {} | undefined;
6
+ getState: () => {
7
+ changes: {
8
+ rows: Record<string, Partial<TType>>;
9
+ errors: Record<string, {
10
+ row: string | undefined;
11
+ cells: Record<string, string>;
12
+ shouldShowErrorAlert: boolean;
13
+ }>;
14
+ moveReasons: Record<string, {
15
+ [x: string]: "search" | "filter" | "sorting";
16
+ }>;
17
+ originals: Record<string, TType>;
18
+ dirty: Record<string, boolean>;
19
+ };
20
+ indexes: Record<string, number>;
21
+ temporaryRows: TType[];
22
+ statuses: Record<string, "saving" | "saved" | "errored">;
23
+ };
24
+ getRowValue: (rowId: string) => Partial<TType> | undefined;
25
+ getRowMoveReason: (rowId: string) => "search" | "filter" | "sorting" | undefined;
9
26
  hasRowErrors: (rowId: string) => boolean;
10
27
  hasRowErrorsShownInAlert: (rowId: string) => boolean;
11
28
  hasTemporaryRowErrors: <T extends TType>() => boolean;
@@ -19,16 +36,20 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
19
36
  getErrors: () => string[];
20
37
  getErrorsShownInAlert: <T extends TType>() => {
21
38
  rowId: string;
22
- index: any;
39
+ index: number | undefined;
23
40
  changes: Partial<T>;
24
- errors: any;
41
+ errors: {
42
+ row: string | undefined;
43
+ cells: Record<string, string>;
44
+ shouldShowErrorAlert: boolean;
45
+ };
25
46
  }[];
26
47
  hasChanges: (rowId?: string) => boolean;
27
48
  saveChanges: <T extends TType>(table: ReactTable<T>, rowId?: string | undefined) => Promise<boolean>;
28
49
  discardChanges: <T extends TType>(rowId: string, table: ReactTable<T>) => Promise<void>;
29
50
  hasSaved: () => boolean;
30
51
  insertTemporaryRow: <T extends TType>(data: Partial<T>, rowIndex: number) => string;
31
- temporaryRows: any;
52
+ temporaryRows: TType[];
32
53
  isDirty: boolean;
33
54
  isEnabled: boolean;
34
55
  isEditing: boolean;
@@ -39,5 +60,5 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
39
60
  lastFocusedCellIndex: number | undefined;
40
61
  setLastFocusedCellIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
41
62
  createRow: <T extends TType>(table: ReactTable<T>, row?: Partial<T>) => Promise<void>;
42
- createRowButtonRef: React.RefObject<HTMLButtonElement>;
63
+ createRowButtonRef: React.RefObject<HTMLButtonElement | null>;
43
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TabList.cjs","sources":["../../../../src/components/Tabs/components/TabList.tsx"],"sourcesContent":["import { useFocusManager } from '@react-aria/focus';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport { LegacyButton } from '../../LegacyComponents/Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\nimport { TabContext } from '../Context';\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst focusManagerOptions = {\n wrap: true,\n tabbable: false,\n accept: (element: Element) => {\n return element.getAttribute('role') === 'tab';\n },\n};\n\nexport const TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn(\n 'm-0 mb-4 flex flex-row border-gray-200 print:hidden',\n 'aria-orientation-horizontal:border-b',\n 'aria-orientation-vertical:m-0 aria-orientation-vertical:mr-4 aria-orientation-vertical:flex-col aria-orientation-vertical:border-r',\n props.className\n );\n\n const context = React.useContext(TabContext);\n const focusManager = useFocusManager();\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (context.orientation === 'horizontal') {\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n } else if (context.orientation === 'vertical') {\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n }\n };\n\n return (\n <div\n {...otherProps}\n aria-orientation={context?.orientation}\n role=\"tablist\"\n className={className}\n ref={ref}\n onKeyDown={handleKeyDown}>\n <OverflowGroup\n wrapChild\n className='w-full [[aria-orientation=\"vertical\"]_&]:flex-col'\n moreButton={(text: string) => <LegacyButton>{text}</LegacyButton>}>\n {React.Children.toArray(children).filter(child => {\n if (React.isValidElement(child)) {\n return !child.props.h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AAA,QACV,YAAY,CAAC,SAAiB,sBAAA,cAACC,OAAAA,oBAAc,IAAK;AAAA,MAAA;AAAA,MACjD,MAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAA,UAAS;AAC9C,YAAI,MAAM,eAAe,KAAK,GAAG;AAC7B,iBAAO,CAAC,MAAM,MAAM;AAAA,QACxB;AAEA,eAAO;AAAA,MACX,CAAC;AAAA,IAAA;AAAA,EACL;AAGZ,CAAC;;"}
1
+ {"version":3,"file":"TabList.cjs","sources":["../../../../src/components/Tabs/components/TabList.tsx"],"sourcesContent":["import { useFocusManager } from '@react-aria/focus';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport { LegacyButton } from '../../LegacyComponents/Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\nimport { TabContext } from '../Context';\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst focusManagerOptions = {\n wrap: true,\n tabbable: false,\n accept: (element: Element) => {\n return element.getAttribute('role') === 'tab';\n },\n};\n\nexport const TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn(\n 'm-0 mb-4 flex flex-row border-gray-200 print:hidden',\n 'aria-orientation-horizontal:border-b',\n 'aria-orientation-vertical:m-0 aria-orientation-vertical:mr-4 aria-orientation-vertical:flex-col aria-orientation-vertical:border-r',\n props.className\n );\n\n const context = React.useContext(TabContext);\n const focusManager = useFocusManager();\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (context.orientation === 'horizontal') {\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n } else if (context.orientation === 'vertical') {\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n }\n };\n\n return (\n <div\n {...otherProps}\n aria-orientation={context?.orientation}\n role=\"tablist\"\n className={className}\n ref={ref}\n onKeyDown={handleKeyDown}>\n <OverflowGroup\n wrapChild\n className='w-full [[aria-orientation=\"vertical\"]_&]:flex-col'\n moreButton={(text: string) => <LegacyButton>{text}</LegacyButton>}>\n {React.Children.toArray(children).filter(child => {\n if (React.isValidElement<{ hidden?: boolean }>(child)) {\n return !child.props.hidden;\n }\n\n return true;\n })}\n </OverflowGroup>\n </div>\n );\n});\n"],"names":["TabContext","useFocusManager","OverflowGroup","LegacyButton"],"mappings":";;;;;;;;AAUA,MAAM,sBAAsB;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,CAAC,YAAqB;AAC1B,WAAO,QAAQ,aAAa,MAAM,MAAM;AAAA,EAC5C;AACJ;AAEO,MAAM,UAAU,MAAM,WAAW,SAAS,IAAI,OAAqB,KAAgC;AACtG,QAAM,EAAE,UAAU,GAAG,WAAA,IAAe;AACpC,QAAM,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EAAA;AAGV,QAAM,UAAU,MAAM,WAAWA,kBAAU;AAC3C,QAAM,eAAeC,MAAAA,gBAAA;AAErB,QAAM,gBAAgB,CAAC,UAA+B;AAClD,QAAI,QAAQ,gBAAgB,cAAc;AACtC,UAAI,MAAM,QAAQ,cAAc;AAC5B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAAA,IACJ,WAAW,QAAQ,gBAAgB,YAAY;AAC3C,UAAI,MAAM,QAAQ,WAAW;AACzB,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAAA,IACJ;AAAA,EACJ;AAEA,SACI,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,oBAAkB,SAAS;AAAA,MAC3B,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IAAA;AAAA,IACX,sBAAA;AAAA,MAACC,cAAAA;AAAAA,MAAA;AAAA,QACG,WAAS;AAAA,QACT,WAAU;AAAA,QACV,YAAY,CAAC,SAAiB,sBAAA,cAACC,OAAAA,oBAAc,IAAK;AAAA,MAAA;AAAA,MACjD,MAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAA,UAAS;AAC9C,YAAI,MAAM,eAAqC,KAAK,GAAG;AACnD,iBAAO,CAAC,MAAM,MAAM;AAAA,QACxB;AAEA,eAAO;AAAA,MACX,CAAC;AAAA,IAAA;AAAA,EACL;AAGZ,CAAC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TabList.js","sources":["../../../../src/components/Tabs/components/TabList.tsx"],"sourcesContent":["import { useFocusManager } from '@react-aria/focus';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport { LegacyButton } from '../../LegacyComponents/Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\nimport { TabContext } from '../Context';\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst focusManagerOptions = {\n wrap: true,\n tabbable: false,\n accept: (element: Element) => {\n return element.getAttribute('role') === 'tab';\n },\n};\n\nexport const TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn(\n 'm-0 mb-4 flex flex-row border-gray-200 print:hidden',\n 'aria-orientation-horizontal:border-b',\n 'aria-orientation-vertical:m-0 aria-orientation-vertical:mr-4 aria-orientation-vertical:flex-col aria-orientation-vertical:border-r',\n props.className\n );\n\n const context = React.useContext(TabContext);\n const focusManager = useFocusManager();\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (context.orientation === 'horizontal') {\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n } else if (context.orientation === 'vertical') {\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n }\n };\n\n return (\n <div\n {...otherProps}\n aria-orientation={context?.orientation}\n role=\"tablist\"\n className={className}\n ref={ref}\n onKeyDown={handleKeyDown}>\n <OverflowGroup\n wrapChild\n className='w-full [[aria-orientation=\"vertical\"]_&]:flex-col'\n moreButton={(text: string) => <LegacyButton>{text}</LegacyButton>}>\n {React.Children.toArray(children).filter(child => {\n if (React.isValidElement(child)) {\n return !child.props.hidden;\n }\n\n return true;\n })}\n </OverflowGroup>\n </div>\n );\n});\n"],"names":["React"],"mappings":";;;;;;AAUA,MAAM,sBAAsB;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,CAAC,YAAqB;AAC1B,WAAO,QAAQ,aAAa,MAAM,MAAM;AAAA,EAC5C;AACJ;AAEO,MAAM,UAAUA,eAAM,WAAW,SAAS,IAAI,OAAqB,KAAgC;AACtG,QAAM,EAAE,UAAU,GAAG,WAAA,IAAe;AACpC,QAAM,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EAAA;AAGV,QAAM,UAAUA,eAAM,WAAW,UAAU;AAC3C,QAAM,eAAe,gBAAA;AAErB,QAAM,gBAAgB,CAAC,UAA+B;AAClD,QAAI,QAAQ,gBAAgB,cAAc;AACtC,UAAI,MAAM,QAAQ,cAAc;AAC5B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAAA,IACJ,WAAW,QAAQ,gBAAgB,YAAY;AAC3C,UAAI,MAAM,QAAQ,WAAW;AACzB,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAAA,IACJ;AAAA,EACJ;AAEA,SACIA,+BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,oBAAkB,SAAS;AAAA,MAC3B,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IAAA;AAAA,IACXA,+BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,WAAS;AAAA,QACT,WAAU;AAAA,QACV,YAAY,CAAC,SAAiBA,+BAAA,cAAC,oBAAc,IAAK;AAAA,MAAA;AAAA,MACjDA,eAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAA,UAAS;AAC9C,YAAIA,eAAM,eAAe,KAAK,GAAG;AAC7B,iBAAO,CAAC,MAAM,MAAM;AAAA,QACxB;AAEA,eAAO;AAAA,MACX,CAAC;AAAA,IAAA;AAAA,EACL;AAGZ,CAAC;"}
1
+ {"version":3,"file":"TabList.js","sources":["../../../../src/components/Tabs/components/TabList.tsx"],"sourcesContent":["import { useFocusManager } from '@react-aria/focus';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport { LegacyButton } from '../../LegacyComponents/Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\nimport { TabContext } from '../Context';\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst focusManagerOptions = {\n wrap: true,\n tabbable: false,\n accept: (element: Element) => {\n return element.getAttribute('role') === 'tab';\n },\n};\n\nexport const TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn(\n 'm-0 mb-4 flex flex-row border-gray-200 print:hidden',\n 'aria-orientation-horizontal:border-b',\n 'aria-orientation-vertical:m-0 aria-orientation-vertical:mr-4 aria-orientation-vertical:flex-col aria-orientation-vertical:border-r',\n props.className\n );\n\n const context = React.useContext(TabContext);\n const focusManager = useFocusManager();\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (context.orientation === 'horizontal') {\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n } else if (context.orientation === 'vertical') {\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusManager?.focusPrevious(focusManagerOptions);\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusManager?.focusNext(focusManagerOptions);\n }\n }\n };\n\n return (\n <div\n {...otherProps}\n aria-orientation={context?.orientation}\n role=\"tablist\"\n className={className}\n ref={ref}\n onKeyDown={handleKeyDown}>\n <OverflowGroup\n wrapChild\n className='w-full [[aria-orientation=\"vertical\"]_&]:flex-col'\n moreButton={(text: string) => <LegacyButton>{text}</LegacyButton>}>\n {React.Children.toArray(children).filter(child => {\n if (React.isValidElement<{ hidden?: boolean }>(child)) {\n return !child.props.hidden;\n }\n\n return true;\n })}\n </OverflowGroup>\n </div>\n );\n});\n"],"names":["React"],"mappings":";;;;;;AAUA,MAAM,sBAAsB;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,CAAC,YAAqB;AAC1B,WAAO,QAAQ,aAAa,MAAM,MAAM;AAAA,EAC5C;AACJ;AAEO,MAAM,UAAUA,eAAM,WAAW,SAAS,IAAI,OAAqB,KAAgC;AACtG,QAAM,EAAE,UAAU,GAAG,WAAA,IAAe;AACpC,QAAM,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EAAA;AAGV,QAAM,UAAUA,eAAM,WAAW,UAAU;AAC3C,QAAM,eAAe,gBAAA;AAErB,QAAM,gBAAgB,CAAC,UAA+B;AAClD,QAAI,QAAQ,gBAAgB,cAAc;AACtC,UAAI,MAAM,QAAQ,cAAc;AAC5B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAAA,IACJ,WAAW,QAAQ,gBAAgB,YAAY;AAC3C,UAAI,MAAM,QAAQ,WAAW;AACzB,cAAM,eAAA;AACN,sBAAc,cAAc,mBAAmB;AAAA,MACnD;AAEA,UAAI,MAAM,QAAQ,aAAa;AAC3B,cAAM,eAAA;AACN,sBAAc,UAAU,mBAAmB;AAAA,MAC/C;AAAA,IACJ;AAAA,EACJ;AAEA,SACIA,+BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,oBAAkB,SAAS;AAAA,MAC3B,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IAAA;AAAA,IACXA,+BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,WAAS;AAAA,QACT,WAAU;AAAA,QACV,YAAY,CAAC,SAAiBA,+BAAA,cAAC,oBAAc,IAAK;AAAA,MAAA;AAAA,MACjDA,eAAM,SAAS,QAAQ,QAAQ,EAAE,OAAO,CAAA,UAAS;AAC9C,YAAIA,eAAM,eAAqC,KAAK,GAAG;AACnD,iBAAO,CAAC,MAAM,MAAM;AAAA,QACxB;AAEA,eAAO;AAAA,MACX,CAAC;AAAA,IAAA;AAAA,EACL;AAGZ,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Trigger.cjs","sources":["../../../../src/components/Tabs/components/Trigger.tsx"],"sourcesContent":["import cn from 'clsx';\nimport React from 'react';\n\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { getButtonClasses } from '../../LegacyComponents/Button/util';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { TabContext } from '../Context';\n\nimport { createPanelId, createTriggerId } from './utils';\n\nexport type TabTriggerProps = React.HTMLAttributes<HTMLButtonElement> & {\n /**\n * A unique value that associates the trigger with a content.\n */\n id: string;\n /**\n * When true, prevents the user from interacting with the tab.\n */\n disabled?: boolean;\n /** A tooltip to show when hovering over the trigger */\n tooltip?: string | JSX.Element;\n};\n\nexport const TabTrigger = React.forwardRef(function Tab(props: TabTriggerProps, forwardedRef: React.Ref<HTMLButtonElement>) {\n const { children, id, disabled, tooltip, ...otherProps } = props;\n const context = React.useContext(TabContext);\n const ref = useMergedRef<HTMLButtonElement>(forwardedRef);\n\n const triggerClassName = cn(\n props.className,\n 'group relative p-0.5 outline-none disabled:cursor-not-allowed disabled:text-black/50',\n // horizontal\n '[[aria-orientation=\"horizontal\"]_&]:pb-1',\n // vertical\n '[[aria-orientation=\"vertical\"]_&]:pr-1'\n );\n const buttonClassName = cn(\n getButtonClasses(),\n 'pointer-events-none rounded px-3 group-focus-visible:yt-focus-inset group-enabled:group-hover:bg-gray-100 group-enabled:group-hover:text-black'\n );\n const activeClassName = cn(\n 'pointer-events-none absolute z-[1] hidden bg-blue-500 group-aria-selected:flex',\n // horizontal\n '[[aria-orientation=\"horizontal\"]_&]:bottom-0 [[aria-orientation=\"horizontal\"]_&]:left-0 [[aria-orientation=\"horizontal\"]_&]:right-0 [[aria-orientation=\"horizontal\"]_&]:h-0.5 [[aria-orientation=\"horizontal\"]_&]:rounded-t-sm',\n // vertical\n '[[aria-orientation=\"vertical\"]_&]:bottom-0 [[aria-orientation=\"vertical\"]_&]:right-0 [[aria-orientation=\"vertical\"]_&]:top-0 [[aria-orientation=\"vertical\"]_&]:w-0.5 [[aria-orientation=\"vertical\"]_&]:rounded-l-sm'\n );\n\n const triggerId = createTriggerId(context.baseId, id);\n const panelId = createPanelId(context.baseId, id);\n\n const trigger = (\n <button\n {...otherProps}\n aria-selected={id === context?.activeTabId}\n aria-controls={panelId}\n id={triggerId}\n role=\"tab\"\n type=\"button\"\n className={triggerClassName}\n disabled={disabled}\n onFocus={() => context.onChange(id)}\n ref={ref}\n tabIndex={context?.activeTabId !== undefined ? (id === context?.activeTabId ? 0 : -1) : 0}>\n <span className={buttonClassName}>{children}</span>\n <span className={activeClassName} />\n </button>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{trigger}</Tooltip>;\n }\n\n return trigger;\n});\n"],"names":["TabContext","useMergedRef","getButtonClasses","createTriggerId","createPanelId","Tooltip"],"mappings":";;;;;;;;;AAuBO,MAAM,aAAa,MAAM,WAAW,SAAS,IAAI,OAAwB,cAA4C;AACxH,QAAM,EAAE,UAAU,IAAI,UAAU,SAAS,GAAG,eAAe;AAC3D,QAAM,UAAU,MAAM,WAAWA,kBAAU;AAC3C,QAAM,MAAMC,aAAAA,aAAgC,YAAY;AAExD,QAAM,mBAAmB;AAAA,IACrB,MAAM;AAAA,IACN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EAAA;AAEJ,QAAM,kBAAkB;AAAA,IACpBC,sBAAA;AAAA,IACA;AAAA,EAAA;AAEJ,QAAM,kBAAkB;AAAA,IACpB;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EAAA;AAGJ,QAAM,YAAYC,MAAAA,gBAAgB,QAAQ,QAAQ,EAAE;AACpD,QAAM,UAAUC,MAAAA,cAAc,QAAQ,QAAQ,EAAE;AAEhD,QAAM,UACF,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,iBAAe,OAAO,SAAS;AAAA,MAC/B,iBAAe;AAAA,MACf,IAAI;AAAA,MACJ,MAAK;AAAA,MACL,MAAK;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA,SAAS,MAAM,QAAQ,SAAS,EAAE;AAAA,MAClC;AAAA,MACA,UAAU,SAAS,gBAAgB,SAAa,OAAO,SAAS,cAAc,IAAI,KAAM;AAAA,IAAA;AAAA,IACxF,sBAAA,cAAC,QAAA,EAAK,WAAW,gBAAA,GAAkB,QAAS;AAAA,IAC5C,sBAAA,cAAC,QAAA,EAAK,WAAW,gBAAA,CAAiB;AAAA,EAAA;AAI1C,MAAI,SAAS;AACT,WAAO,sBAAA,cAACC,QAAAA,SAAA,EAAQ,OAAO,QAAA,GAAU,OAAQ;AAAA,EAC7C;AAEA,SAAO;AACX,CAAC;;"}
1
+ {"version":3,"file":"Trigger.cjs","sources":["../../../../src/components/Tabs/components/Trigger.tsx"],"sourcesContent":["import cn from 'clsx';\nimport React from 'react';\n\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { getButtonClasses } from '../../LegacyComponents/Button/util';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { TabContext } from '../Context';\n\nimport { createPanelId, createTriggerId } from './utils';\n\nexport type TabTriggerProps = React.HTMLAttributes<HTMLButtonElement> & {\n /**\n * A unique value that associates the trigger with a content.\n */\n id: string;\n /**\n * When true, prevents the user from interacting with the tab.\n */\n disabled?: boolean;\n /** A tooltip to show when hovering over the trigger */\n tooltip?: string | React.JSX.Element;\n};\n\nexport const TabTrigger = React.forwardRef(function Tab(props: TabTriggerProps, forwardedRef: React.Ref<HTMLButtonElement>) {\n const { children, id, disabled, tooltip, ...otherProps } = props;\n const context = React.useContext(TabContext);\n const ref = useMergedRef<HTMLButtonElement>(forwardedRef);\n\n const triggerClassName = cn(\n props.className,\n 'group relative p-0.5 outline-none disabled:cursor-not-allowed disabled:text-black/50',\n // horizontal\n '[[aria-orientation=\"horizontal\"]_&]:pb-1',\n // vertical\n '[[aria-orientation=\"vertical\"]_&]:pr-1'\n );\n const buttonClassName = cn(\n getButtonClasses(),\n 'pointer-events-none rounded px-3 group-focus-visible:yt-focus-inset group-enabled:group-hover:bg-gray-100 group-enabled:group-hover:text-black'\n );\n const activeClassName = cn(\n 'pointer-events-none absolute z-[1] hidden bg-blue-500 group-aria-selected:flex',\n // horizontal\n '[[aria-orientation=\"horizontal\"]_&]:bottom-0 [[aria-orientation=\"horizontal\"]_&]:left-0 [[aria-orientation=\"horizontal\"]_&]:right-0 [[aria-orientation=\"horizontal\"]_&]:h-0.5 [[aria-orientation=\"horizontal\"]_&]:rounded-t-sm',\n // vertical\n '[[aria-orientation=\"vertical\"]_&]:bottom-0 [[aria-orientation=\"vertical\"]_&]:right-0 [[aria-orientation=\"vertical\"]_&]:top-0 [[aria-orientation=\"vertical\"]_&]:w-0.5 [[aria-orientation=\"vertical\"]_&]:rounded-l-sm'\n );\n\n const triggerId = createTriggerId(context.baseId, id);\n const panelId = createPanelId(context.baseId, id);\n\n const trigger = (\n <button\n {...otherProps}\n aria-selected={id === context?.activeTabId}\n aria-controls={panelId}\n id={triggerId}\n role=\"tab\"\n type=\"button\"\n className={triggerClassName}\n disabled={disabled}\n onFocus={() => context.onChange(id)}\n ref={ref}\n tabIndex={context?.activeTabId !== undefined ? (id === context?.activeTabId ? 0 : -1) : 0}>\n <span className={buttonClassName}>{children}</span>\n <span className={activeClassName} />\n </button>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{trigger}</Tooltip>;\n }\n\n return trigger;\n});\n"],"names":["TabContext","useMergedRef","getButtonClasses","createTriggerId","createPanelId","Tooltip"],"mappings":";;;;;;;;;AAuBO,MAAM,aAAa,MAAM,WAAW,SAAS,IAAI,OAAwB,cAA4C;AACxH,QAAM,EAAE,UAAU,IAAI,UAAU,SAAS,GAAG,eAAe;AAC3D,QAAM,UAAU,MAAM,WAAWA,kBAAU;AAC3C,QAAM,MAAMC,aAAAA,aAAgC,YAAY;AAExD,QAAM,mBAAmB;AAAA,IACrB,MAAM;AAAA,IACN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EAAA;AAEJ,QAAM,kBAAkB;AAAA,IACpBC,sBAAA;AAAA,IACA;AAAA,EAAA;AAEJ,QAAM,kBAAkB;AAAA,IACpB;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EAAA;AAGJ,QAAM,YAAYC,MAAAA,gBAAgB,QAAQ,QAAQ,EAAE;AACpD,QAAM,UAAUC,MAAAA,cAAc,QAAQ,QAAQ,EAAE;AAEhD,QAAM,UACF,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,iBAAe,OAAO,SAAS;AAAA,MAC/B,iBAAe;AAAA,MACf,IAAI;AAAA,MACJ,MAAK;AAAA,MACL,MAAK;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA,SAAS,MAAM,QAAQ,SAAS,EAAE;AAAA,MAClC;AAAA,MACA,UAAU,SAAS,gBAAgB,SAAa,OAAO,SAAS,cAAc,IAAI,KAAM;AAAA,IAAA;AAAA,IACxF,sBAAA,cAAC,QAAA,EAAK,WAAW,gBAAA,GAAkB,QAAS;AAAA,IAC5C,sBAAA,cAAC,QAAA,EAAK,WAAW,gBAAA,CAAiB;AAAA,EAAA;AAI1C,MAAI,SAAS;AACT,WAAO,sBAAA,cAACC,QAAAA,SAAA,EAAQ,OAAO,QAAA,GAAU,OAAQ;AAAA,EAC7C;AAEA,SAAO;AACX,CAAC;;"}
@@ -9,7 +9,7 @@ export type TabTriggerProps = React.HTMLAttributes<HTMLButtonElement> & {
9
9
  */
10
10
  disabled?: boolean;
11
11
  /** A tooltip to show when hovering over the trigger */
12
- tooltip?: string | JSX.Element;
12
+ tooltip?: string | React.JSX.Element;
13
13
  };
14
14
  export declare const TabTrigger: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLButtonElement> & {
15
15
  /**
@@ -21,5 +21,5 @@ export declare const TabTrigger: React.ForwardRefExoticComponent<React.HTMLAttri
21
21
  */
22
22
  disabled?: boolean;
23
23
  /** A tooltip to show when hovering over the trigger */
24
- tooltip?: string | JSX.Element;
24
+ tooltip?: string | React.JSX.Element;
25
25
  } & React.RefAttributes<HTMLButtonElement>>;