@economic/taco 0.0.22-alpha.0 → 0.0.23-alpha.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 (393) hide show
  1. package/README.md +84 -84
  2. package/dist/esm/components/Accordion/Accordion.js.map +1 -1
  3. package/dist/esm/components/Backdrop/Backdrop.js.map +1 -1
  4. package/dist/esm/components/Badge/Badge.js.map +1 -1
  5. package/dist/esm/components/Banner/Banner.js.map +1 -1
  6. package/dist/esm/components/Banner/util.js +1 -1
  7. package/dist/esm/components/Banner/util.js.map +1 -1
  8. package/dist/esm/components/Button/Button.js.map +1 -1
  9. package/dist/esm/components/Button/util.js +23 -18
  10. package/dist/esm/components/Button/util.js.map +1 -1
  11. package/dist/esm/components/Calendar/Calendar.js.map +1 -1
  12. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  13. package/dist/esm/components/Combobox/Combobox.js.map +1 -1
  14. package/dist/esm/components/Combobox/useCombobox.js +84 -64
  15. package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
  16. package/dist/esm/components/Datepicker/Datepicker.js.map +1 -1
  17. package/dist/esm/components/Datepicker/useDatepicker.js +34 -27
  18. package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -1
  19. package/dist/esm/components/Dialog/Context.js +4 -4
  20. package/dist/esm/components/Dialog/Context.js.map +1 -1
  21. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  22. package/dist/esm/components/Dialog/components/Content.js +44 -39
  23. package/dist/esm/components/Dialog/components/Content.js.map +1 -1
  24. package/dist/esm/components/Dialog/components/Drawer.js +3 -3
  25. package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
  26. package/dist/esm/components/Dialog/components/Extra.js +2 -2
  27. package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
  28. package/dist/esm/components/Dialog/components/Trigger.js +2 -2
  29. package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
  30. package/dist/esm/components/Field/Field.js.map +1 -1
  31. package/dist/esm/components/Form/Form.js +8 -6
  32. package/dist/esm/components/Form/Form.js.map +1 -1
  33. package/dist/esm/components/Group/Group.js +8 -6
  34. package/dist/esm/components/Group/Group.js.map +1 -1
  35. package/dist/esm/components/Hanger/Hanger.js +28 -23
  36. package/dist/esm/components/Hanger/Hanger.js.map +1 -1
  37. package/dist/esm/components/Icon/Icon.js +8 -7
  38. package/dist/esm/components/Icon/Icon.js.map +1 -1
  39. package/dist/esm/components/Icon/components/AccountPreview.js.map +1 -1
  40. package/dist/esm/components/Icon/components/Accounting.js.map +1 -1
  41. package/dist/esm/components/Icon/components/AccountingYear.js.map +1 -1
  42. package/dist/esm/components/Icon/components/AccountingYearCancel.js.map +1 -1
  43. package/dist/esm/components/Icon/components/ArrowBottom.js.map +1 -1
  44. package/dist/esm/components/Icon/components/ArrowDown.js.map +1 -1
  45. package/dist/esm/components/Icon/components/ArrowEnd.js.map +1 -1
  46. package/dist/esm/components/Icon/components/ArrowLeft.js.map +1 -1
  47. package/dist/esm/components/Icon/components/ArrowRight.js.map +1 -1
  48. package/dist/esm/components/Icon/components/ArrowStart.js.map +1 -1
  49. package/dist/esm/components/Icon/components/ArrowTop.js.map +1 -1
  50. package/dist/esm/components/Icon/components/ArrowUp.js.map +1 -1
  51. package/dist/esm/components/Icon/components/Attach.js.map +1 -1
  52. package/dist/esm/components/Icon/components/AttachAuto.js.map +1 -1
  53. package/dist/esm/components/Icon/components/AttachCancel.js.map +1 -1
  54. package/dist/esm/components/Icon/components/Autotext.js.map +1 -1
  55. package/dist/esm/components/Icon/components/AutotextInsert.js.map +1 -1
  56. package/dist/esm/components/Icon/components/Basic.js.map +1 -1
  57. package/dist/esm/components/Icon/components/BasicTabs.js.map +1 -1
  58. package/dist/esm/components/Icon/components/BellSolid.js.map +1 -1
  59. package/dist/esm/components/Icon/components/Book.js.map +1 -1
  60. package/dist/esm/components/Icon/components/Booking.js.map +1 -1
  61. package/dist/esm/components/Icon/components/Budget.js.map +1 -1
  62. package/dist/esm/components/Icon/components/Calendar.js.map +1 -1
  63. package/dist/esm/components/Icon/components/CashAccount.js.map +1 -1
  64. package/dist/esm/components/Icon/components/CashReports.js.map +1 -1
  65. package/dist/esm/components/Icon/components/Chat.js.map +1 -1
  66. package/dist/esm/components/Icon/components/ChatSolid.js.map +1 -1
  67. package/dist/esm/components/Icon/components/ChevronDown.js.map +1 -1
  68. package/dist/esm/components/Icon/components/ChevronDownDouble.js.map +1 -1
  69. package/dist/esm/components/Icon/components/ChevronDownSolid.js.map +1 -1
  70. package/dist/esm/components/Icon/components/ChevronLeft.js.map +1 -1
  71. package/dist/esm/components/Icon/components/ChevronLeftDouble.js.map +1 -1
  72. package/dist/esm/components/Icon/components/ChevronRight.js.map +1 -1
  73. package/dist/esm/components/Icon/components/ChevronRightDouble.js.map +1 -1
  74. package/dist/esm/components/Icon/components/ChevronUp.js.map +1 -1
  75. package/dist/esm/components/Icon/components/ChevronUpDouble.js.map +1 -1
  76. package/dist/esm/components/Icon/components/ChevronUpSolid.js.map +1 -1
  77. package/dist/esm/components/Icon/components/Clamp.js.map +1 -1
  78. package/dist/esm/components/Icon/components/ClampOpen.js.map +1 -1
  79. package/dist/esm/components/Icon/components/Close.js.map +1 -1
  80. package/dist/esm/components/Icon/components/ConnectionEnable.js.map +1 -1
  81. package/dist/esm/components/Icon/components/ConnectionRevoke.js.map +1 -1
  82. package/dist/esm/components/Icon/components/Contacts.js.map +1 -1
  83. package/dist/esm/components/Icon/components/Copy.js.map +1 -1
  84. package/dist/esm/components/Icon/components/Courses.js.map +1 -1
  85. package/dist/esm/components/Icon/components/Credit.js.map +1 -1
  86. package/dist/esm/components/Icon/components/Delete.js.map +1 -1
  87. package/dist/esm/components/Icon/components/DeletePermanently.js.map +1 -1
  88. package/dist/esm/components/Icon/components/Depecriate.js.map +1 -1
  89. package/dist/esm/components/Icon/components/Developer.js.map +1 -1
  90. package/dist/esm/components/Icon/components/DistributionTemplate.js.map +1 -1
  91. package/dist/esm/components/Icon/components/Document.js.map +1 -1
  92. package/dist/esm/components/Icon/components/DocumentApprove.js.map +1 -1
  93. package/dist/esm/components/Icon/components/DocumentCreateEntry.js.map +1 -1
  94. package/dist/esm/components/Icon/components/DocumentCut.js.map +1 -1
  95. package/dist/esm/components/Icon/components/DocumentError.js.map +1 -1
  96. package/dist/esm/components/Icon/components/DocumentIsolatePage.js.map +1 -1
  97. package/dist/esm/components/Icon/components/DocumentMerge.js.map +1 -1
  98. package/dist/esm/components/Icon/components/DocumentMove.js.map +1 -1
  99. package/dist/esm/components/Icon/components/DocumentPreview.js.map +1 -1
  100. package/dist/esm/components/Icon/components/DocumentReceived.js.map +1 -1
  101. package/dist/esm/components/Icon/components/DocumentRejectedRequest.js.map +1 -1
  102. package/dist/esm/components/Icon/components/DocumentSplit.js.map +1 -1
  103. package/dist/esm/components/Icon/components/DocumentTime.js.map +1 -1
  104. package/dist/esm/components/Icon/components/Download.js.map +1 -1
  105. package/dist/esm/components/Icon/components/Drag.js.map +1 -1
  106. package/dist/esm/components/Icon/components/ECopedia.js.map +1 -1
  107. package/dist/esm/components/Icon/components/ESignature.js.map +1 -1
  108. package/dist/esm/components/Icon/components/Edit.js.map +1 -1
  109. package/dist/esm/components/Icon/components/EllipsisHorizontal.js.map +1 -1
  110. package/dist/esm/components/Icon/components/EllipsisVertical.js.map +1 -1
  111. package/dist/esm/components/Icon/components/EntriesOnAccount.js.map +1 -1
  112. package/dist/esm/components/Icon/components/EntriesOpen.js.map +1 -1
  113. package/dist/esm/components/Icon/components/EntriesWarning.js.map +1 -1
  114. package/dist/esm/components/Icon/components/EntryTypeCustomerInvoice.js.map +1 -1
  115. package/dist/esm/components/Icon/components/EntryTypeCustomerPayment.js.map +1 -1
  116. package/dist/esm/components/Icon/components/EntryTypeJournalEntry.js.map +1 -1
  117. package/dist/esm/components/Icon/components/EntryTypeManualCustomerInvoice.js.map +1 -1
  118. package/dist/esm/components/Icon/components/EntryTypeSupplierInvoice.js.map +1 -1
  119. package/dist/esm/components/Icon/components/EntryTypeSupplierPayment.js.map +1 -1
  120. package/dist/esm/components/Icon/components/Envelope.js.map +1 -1
  121. package/dist/esm/components/Icon/components/EnvelopeApproved.js.map +1 -1
  122. package/dist/esm/components/Icon/components/ExpandView.js.map +1 -1
  123. package/dist/esm/components/Icon/components/Expenses.js.map +1 -1
  124. package/dist/esm/components/Icon/components/Export.js.map +1 -1
  125. package/dist/esm/components/Icon/components/ExportToExcel.js.map +1 -1
  126. package/dist/esm/components/Icon/components/ExportToPdf.js.map +1 -1
  127. package/dist/esm/components/Icon/components/Filter.js.map +1 -1
  128. package/dist/esm/components/Icon/components/FilterSolid.js.map +1 -1
  129. package/dist/esm/components/Icon/components/GraphSolid.js.map +1 -1
  130. package/dist/esm/components/Icon/components/Hash.js.map +1 -1
  131. package/dist/esm/components/Icon/components/Home.js.map +1 -1
  132. package/dist/esm/components/Icon/components/Images.js.map +1 -1
  133. package/dist/esm/components/Icon/components/Import.js.map +1 -1
  134. package/dist/esm/components/Icon/components/Inbox.js.map +1 -1
  135. package/dist/esm/components/Icon/components/InboxEinvoicing.js.map +1 -1
  136. package/dist/esm/components/Icon/components/InboxScanning.js.map +1 -1
  137. package/dist/esm/components/Icon/components/InboxSmart.js.map +1 -1
  138. package/dist/esm/components/Icon/components/Info.js.map +1 -1
  139. package/dist/esm/components/Icon/components/Inventory.js.map +1 -1
  140. package/dist/esm/components/Icon/components/InventoryMatrix.js.map +1 -1
  141. package/dist/esm/components/Icon/components/JournalPro.js.map +1 -1
  142. package/dist/esm/components/Icon/components/Layout.js.map +1 -1
  143. package/dist/esm/components/Icon/components/LayoutBoth.js.map +1 -1
  144. package/dist/esm/components/Icon/components/LayoutFirst.js.map +1 -1
  145. package/dist/esm/components/Icon/components/LayoutLast.js.map +1 -1
  146. package/dist/esm/components/Icon/components/LayoutNone.js.map +1 -1
  147. package/dist/esm/components/Icon/components/LedgerCard.js.map +1 -1
  148. package/dist/esm/components/Icon/components/LedgerCardCustomerReminder.js.map +1 -1
  149. package/dist/esm/components/Icon/components/LedgerCardManualCustomerInvoice.js.map +1 -1
  150. package/dist/esm/components/Icon/components/LedgerCardObsoleteStock.js.map +1 -1
  151. package/dist/esm/components/Icon/components/LedgerCardOpeningEntry.js.map +1 -1
  152. package/dist/esm/components/Icon/components/LedgerCardReservedEntry.js.map +1 -1
  153. package/dist/esm/components/Icon/components/LedgerCardShrinkagePilferage.js.map +1 -1
  154. package/dist/esm/components/Icon/components/LedgerCardStockAdjustment.js.map +1 -1
  155. package/dist/esm/components/Icon/components/LedgerCardTransferredOpeningEntry.js.map +1 -1
  156. package/dist/esm/components/Icon/components/Lightbulb.js.map +1 -1
  157. package/dist/esm/components/Icon/components/Line.js.map +1 -1
  158. package/dist/esm/components/Icon/components/List.js.map +1 -1
  159. package/dist/esm/components/Icon/components/ListBulleted.js.map +1 -1
  160. package/dist/esm/components/Icon/components/ListSearch.js.map +1 -1
  161. package/dist/esm/components/Icon/components/LockOpen.js.map +1 -1
  162. package/dist/esm/components/Icon/components/Log.js.map +1 -1
  163. package/dist/esm/components/Icon/components/Market.js.map +1 -1
  164. package/dist/esm/components/Icon/components/MatchAmount.js.map +1 -1
  165. package/dist/esm/components/Icon/components/MatchEntries.js.map +1 -1
  166. package/dist/esm/components/Icon/components/Mileage.js.map +1 -1
  167. package/dist/esm/components/Icon/components/Minus.js.map +1 -1
  168. package/dist/esm/components/Icon/components/ModalResize.js.map +1 -1
  169. package/dist/esm/components/Icon/components/ModalShrink.js.map +1 -1
  170. package/dist/esm/components/Icon/components/More.js.map +1 -1
  171. package/dist/esm/components/Icon/components/MoreSolid.js.map +1 -1
  172. package/dist/esm/components/Icon/components/Move.js.map +1 -1
  173. package/dist/esm/components/Icon/components/NavigationList.js.map +1 -1
  174. package/dist/esm/components/Icon/components/Note.js.map +1 -1
  175. package/dist/esm/components/Icon/components/NoteFollowUp.js.map +1 -1
  176. package/dist/esm/components/Icon/components/NoteRead.js.map +1 -1
  177. package/dist/esm/components/Icon/components/PartnerApi.js.map +1 -1
  178. package/dist/esm/components/Icon/components/Period.js.map +1 -1
  179. package/dist/esm/components/Icon/components/PersonChange.js.map +1 -1
  180. package/dist/esm/components/Icon/components/PersonMinus.js.map +1 -1
  181. package/dist/esm/components/Icon/components/PersonPlus.js.map +1 -1
  182. package/dist/esm/components/Icon/components/PersonTick.js.map +1 -1
  183. package/dist/esm/components/Icon/components/Play.js.map +1 -1
  184. package/dist/esm/components/Icon/components/PlusCircle.js.map +1 -1
  185. package/dist/esm/components/Icon/components/PlusMinus.js.map +1 -1
  186. package/dist/esm/components/Icon/components/Print.js.map +1 -1
  187. package/dist/esm/components/Icon/components/ProcessPayment.js.map +1 -1
  188. package/dist/esm/components/Icon/components/ProductLedgerCard.js.map +1 -1
  189. package/dist/esm/components/Icon/components/ProjectCards.js.map +1 -1
  190. package/dist/esm/components/Icon/components/Projects.js.map +1 -1
  191. package/dist/esm/components/Icon/components/Quicklinks.js.map +1 -1
  192. package/dist/esm/components/Icon/components/RatingBankruptcy.js.map +1 -1
  193. package/dist/esm/components/Icon/components/RatingPaymentProblems.js.map +1 -1
  194. package/dist/esm/components/Icon/components/Reconciled.js.map +1 -1
  195. package/dist/esm/components/Icon/components/Refresh.js.map +1 -1
  196. package/dist/esm/components/Icon/components/Report.js.map +1 -1
  197. package/dist/esm/components/Icon/components/ReportSolid.js.map +1 -1
  198. package/dist/esm/components/Icon/components/Restore.js.map +1 -1
  199. package/dist/esm/components/Icon/components/RotateLeft.js.map +1 -1
  200. package/dist/esm/components/Icon/components/RotateRight.js.map +1 -1
  201. package/dist/esm/components/Icon/components/Sales.js.map +1 -1
  202. package/dist/esm/components/Icon/components/Search.js.map +1 -1
  203. package/dist/esm/components/Icon/components/SearchBold.js.map +1 -1
  204. package/dist/esm/components/Icon/components/Secure.js.map +1 -1
  205. package/dist/esm/components/Icon/components/SecureTick.js.map +1 -1
  206. package/dist/esm/components/Icon/components/Settings.js.map +1 -1
  207. package/dist/esm/components/Icon/components/SettingsSolid.js.map +1 -1
  208. package/dist/esm/components/Icon/components/Shortcuts.js.map +1 -1
  209. package/dist/esm/components/Icon/components/ShowAll.js.map +1 -1
  210. package/dist/esm/components/Icon/components/ShowLess.js.map +1 -1
  211. package/dist/esm/components/Icon/components/ShowMore.js.map +1 -1
  212. package/dist/esm/components/Icon/components/ShowTemplate.js.map +1 -1
  213. package/dist/esm/components/Icon/components/Sliders.js.map +1 -1
  214. package/dist/esm/components/Icon/components/Smartpay.js.map +1 -1
  215. package/dist/esm/components/Icon/components/SortBy.js.map +1 -1
  216. package/dist/esm/components/Icon/components/Spinner.js.map +1 -1
  217. package/dist/esm/components/Icon/components/Star.js.map +1 -1
  218. package/dist/esm/components/Icon/components/StarSolid.js.map +1 -1
  219. package/dist/esm/components/Icon/components/Subscriptions.js.map +1 -1
  220. package/dist/esm/components/Icon/components/SystemEntries.js.map +1 -1
  221. package/dist/esm/components/Icon/components/Tag.js.map +1 -1
  222. package/dist/esm/components/Icon/components/TemplateOverride.js.map +1 -1
  223. package/dist/esm/components/Icon/components/Templates.js.map +1 -1
  224. package/dist/esm/components/Icon/components/ThumbBoth.js.map +1 -1
  225. package/dist/esm/components/Icon/components/ThumbDown.js.map +1 -1
  226. package/dist/esm/components/Icon/components/ThumbDownSolid.js.map +1 -1
  227. package/dist/esm/components/Icon/components/ThumbUp.js.map +1 -1
  228. package/dist/esm/components/Icon/components/ThumbUpSolid.js.map +1 -1
  229. package/dist/esm/components/Icon/components/Tick.js.map +1 -1
  230. package/dist/esm/components/Icon/components/TickCircle.js.map +1 -1
  231. package/dist/esm/components/Icon/components/Time.js.map +1 -1
  232. package/dist/esm/components/Icon/components/Transfer.js.map +1 -1
  233. package/dist/esm/components/Icon/components/TransferCancel.js.map +1 -1
  234. package/dist/esm/components/Icon/components/TransferLocked.js.map +1 -1
  235. package/dist/esm/components/Icon/components/Undock.js.map +1 -1
  236. package/dist/esm/components/Icon/components/Unreconciled.js.map +1 -1
  237. package/dist/esm/components/Icon/components/Warning.js.map +1 -1
  238. package/dist/esm/components/Icon/components/Webshop.js.map +1 -1
  239. package/dist/esm/components/Icon/components/Website.js.map +1 -1
  240. package/dist/esm/components/Icon/components/Workflow.js.map +1 -1
  241. package/dist/esm/components/Icon/components/Zoom.js.map +1 -1
  242. package/dist/esm/components/Icon/components/index.js +4 -4
  243. package/dist/esm/components/Icon/components/index.js.map +1 -1
  244. package/dist/esm/components/IconButton/IconButton.js +12 -10
  245. package/dist/esm/components/IconButton/IconButton.js.map +1 -1
  246. package/dist/esm/components/Input/Input.js +24 -26
  247. package/dist/esm/components/Input/Input.js.map +1 -1
  248. package/dist/esm/components/Input/util.js +8 -9
  249. package/dist/esm/components/Input/util.js.map +1 -1
  250. package/dist/esm/components/Listbox/Listbox.js +25 -24
  251. package/dist/esm/components/Listbox/Listbox.js.map +1 -1
  252. package/dist/esm/components/Listbox/ScrollableList.js +82 -63
  253. package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
  254. package/dist/esm/components/Listbox/useListbox.js +58 -49
  255. package/dist/esm/components/Listbox/useListbox.js.map +1 -1
  256. package/dist/esm/components/Listbox/useMultiListbox.js +91 -63
  257. package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -1
  258. package/dist/esm/components/Listbox/useTypeahead.js +9 -10
  259. package/dist/esm/components/Listbox/useTypeahead.js.map +1 -1
  260. package/dist/esm/components/Listbox/util.js +84 -48
  261. package/dist/esm/components/Listbox/util.js.map +1 -1
  262. package/dist/esm/components/Menu/Context.js +2 -2
  263. package/dist/esm/components/Menu/Context.js.map +1 -1
  264. package/dist/esm/components/Menu/Menu.js +42 -19
  265. package/dist/esm/components/Menu/Menu.js.map +1 -1
  266. package/dist/esm/components/Menu/components/Checkbox.js +9 -8
  267. package/dist/esm/components/Menu/components/Checkbox.js.map +1 -1
  268. package/dist/esm/components/Menu/components/Content.js +13 -10
  269. package/dist/esm/components/Menu/components/Content.js.map +1 -1
  270. package/dist/esm/components/Menu/components/Header.js +4 -4
  271. package/dist/esm/components/Menu/components/Header.js.map +1 -1
  272. package/dist/esm/components/Menu/components/Item.js +35 -34
  273. package/dist/esm/components/Menu/components/Item.js.map +1 -1
  274. package/dist/esm/components/Menu/components/Link.js +11 -10
  275. package/dist/esm/components/Menu/components/Link.js.map +1 -1
  276. package/dist/esm/components/Menu/components/RadioGroup.js +18 -16
  277. package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -1
  278. package/dist/esm/components/Menu/components/Separator.js +4 -4
  279. package/dist/esm/components/Menu/components/Separator.js.map +1 -1
  280. package/dist/esm/components/Menu/components/Trigger.js +5 -5
  281. package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
  282. package/dist/esm/components/Navigation/Navigation.js +44 -35
  283. package/dist/esm/components/Navigation/Navigation.js.map +1 -1
  284. package/dist/esm/components/Pagination/PageNumbers.js +28 -23
  285. package/dist/esm/components/Pagination/PageNumbers.js.map +1 -1
  286. package/dist/esm/components/Pagination/Pagination.js +56 -39
  287. package/dist/esm/components/Pagination/Pagination.js.map +1 -1
  288. package/dist/esm/components/Pagination/usePagination.js +21 -7
  289. package/dist/esm/components/Pagination/usePagination.js.map +1 -1
  290. package/dist/esm/components/Pagination/usePaginationShortcuts.js +9 -9
  291. package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -1
  292. package/dist/esm/components/Popover/Popover.js +34 -29
  293. package/dist/esm/components/Popover/Popover.js.map +1 -1
  294. package/dist/esm/components/Popover/Primitives.js +8 -7
  295. package/dist/esm/components/Popover/Primitives.js.map +1 -1
  296. package/dist/esm/components/Progress/Progress.js +15 -11
  297. package/dist/esm/components/Progress/Progress.js.map +1 -1
  298. package/dist/esm/components/Provider/Provider.js +18 -13
  299. package/dist/esm/components/Provider/Provider.js.map +1 -1
  300. package/dist/esm/components/RadioGroup/RadioGroup.js +57 -45
  301. package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
  302. package/dist/esm/components/SearchInput/SearchInput.js +11 -10
  303. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  304. package/dist/esm/components/Select/Select.js +31 -30
  305. package/dist/esm/components/Select/Select.js.map +1 -1
  306. package/dist/esm/components/Select/useSelect.js +82 -63
  307. package/dist/esm/components/Select/useSelect.js.map +1 -1
  308. package/dist/esm/components/Spinner/Spinner.js +19 -12
  309. package/dist/esm/components/Spinner/Spinner.js.map +1 -1
  310. package/dist/esm/components/Switch/Switch.js +10 -9
  311. package/dist/esm/components/Switch/Switch.js.map +1 -1
  312. package/dist/esm/components/Table/components/BaseTable.js +30 -23
  313. package/dist/esm/components/Table/components/BaseTable.js.map +1 -1
  314. package/dist/esm/components/Table/components/PaginatedTable.js +7 -3
  315. package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -1
  316. package/dist/esm/components/Table/components/Table.js +25 -18
  317. package/dist/esm/components/Table/components/Table.js.map +1 -1
  318. package/dist/esm/components/Table/components/WindowedTable.js +104 -88
  319. package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
  320. package/dist/esm/components/Table/hooks/plugins/useRowActions.js +146 -122
  321. package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -1
  322. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js +61 -57
  323. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -1
  324. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js +36 -39
  325. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
  326. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js +90 -80
  327. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  328. package/dist/esm/components/Table/hooks/useRowCreation.js +64 -29
  329. package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -1
  330. package/dist/esm/components/Table/hooks/useTable.js +141 -119
  331. package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
  332. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +15 -12
  333. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
  334. package/dist/esm/components/Table/util/renderColumn.js +10 -10
  335. package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
  336. package/dist/esm/components/Table/util/renderRow.js +46 -37
  337. package/dist/esm/components/Table/util/renderRow.js.map +1 -1
  338. package/dist/esm/components/Table/util/rowIndexPath.js +16 -14
  339. package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -1
  340. package/dist/esm/components/Table/util/sortTypes.js +31 -23
  341. package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
  342. package/dist/esm/components/Table/util.js +41 -29
  343. package/dist/esm/components/Table/util.js.map +1 -1
  344. package/dist/esm/components/Tabs/Tabs.js +27 -25
  345. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  346. package/dist/esm/components/Textarea/Textarea.js +9 -11
  347. package/dist/esm/components/Textarea/Textarea.js.map +1 -1
  348. package/dist/esm/components/Toast/Toast.js +21 -20
  349. package/dist/esm/components/Toast/Toast.js.map +1 -1
  350. package/dist/esm/components/Toast/Toaster.js +119 -90
  351. package/dist/esm/components/Toast/Toaster.js.map +1 -1
  352. package/dist/esm/components/Toast/util.js +2 -2
  353. package/dist/esm/components/Toast/util.js.map +1 -1
  354. package/dist/esm/components/Tooltip/Tooltip.js +8 -7
  355. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  356. package/dist/esm/components/Tour/Tour.js +50 -44
  357. package/dist/esm/components/Tour/Tour.js.map +1 -1
  358. package/dist/esm/components/Treeview/Treeview.js +36 -26
  359. package/dist/esm/components/Treeview/Treeview.js.map +1 -1
  360. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +1 -1
  361. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
  362. package/dist/esm/index.css +642 -642
  363. package/dist/esm/index.js +1 -1
  364. package/dist/esm/primitives/Button.js +13 -9
  365. package/dist/esm/primitives/Button.js.map +1 -1
  366. package/dist/esm/utils/date.js.map +1 -1
  367. package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -1
  368. package/dist/esm/utils/hooks/useDraggable.js +18 -16
  369. package/dist/esm/utils/hooks/useDraggable.js.map +1 -1
  370. package/dist/esm/utils/hooks/useDropTarget.js +10 -7
  371. package/dist/esm/utils/hooks/useDropTarget.js.map +1 -1
  372. package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -1
  373. package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -1
  374. package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -1
  375. package/dist/esm/utils/hooks/useProxiedRef.js +3 -3
  376. package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -1
  377. package/dist/esm/utils/hooks/useTimer.js +17 -9
  378. package/dist/esm/utils/hooks/useTimer.js.map +1 -1
  379. package/dist/esm/utils/input.js +11 -7
  380. package/dist/esm/utils/input.js.map +1 -1
  381. package/dist/esm/utils/mergeRefs.js +2 -2
  382. package/dist/esm/utils/mergeRefs.js.map +1 -1
  383. package/dist/esm/utils/taillwind.js +2 -2
  384. package/dist/esm/utils/taillwind.js.map +1 -1
  385. package/dist/index.css +642 -642
  386. package/dist/taco.cjs.development.js +2448 -2001
  387. package/dist/taco.cjs.development.js.map +1 -1
  388. package/dist/taco.cjs.production.min.js +1 -1
  389. package/dist/taco.cjs.production.min.js.map +1 -1
  390. package/dist/utils/tailwind.d.ts +1 -1
  391. package/package.json +2 -2
  392. package/plugins/tailwindcss-aria-attributes.js +73 -73
  393. package/tailwind.config.js +297 -297
@@ -1,103 +1,113 @@
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import React__default from 'react';
2
3
  import { Checkbox } from '../../../Checkbox/Checkbox.js';
3
4
  import { useRowSelect as useRowSelect$1 } from 'react-table';
4
5
 
5
- // this wraps react-table's internal useRowSelect hook
6
+ var _excluded = ["onChange"],
7
+ _excluded2 = ["onChange"];
6
8
 
7
- const toggleBetween = (fromRowIndex, toRowIndex) => {
8
- const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;
9
- const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;
9
+ var toggleBetween = function toggleBetween(fromRowIndex, toRowIndex) {
10
+ var fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;
11
+ var toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;
10
12
  return [fromIndex, toIndex];
11
13
  }; // react-table calls "index paths" row ids. we named them indexPaths to reduce confusion with natural ids
12
14
  // the selection hook usess react-table's row selection, so this hok references row.id - it is the index path
13
15
 
14
16
 
15
- const useRowSelect = onSelectedRows => {
16
- const plugin = hooks => {
17
+ var useRowSelect = function useRowSelect(onSelectedRows) {
18
+ var plugin = function plugin(hooks) {
17
19
  // eslint-disable-next-line react-hooks/rules-of-hooks
18
20
  useRowSelect$1(hooks);
19
21
 
20
22
  if (onSelectedRows) {
21
- const toggleRowSelected = (indexPath, checked) => onSelectedRows(state => {
22
- const nextState = { ...state
23
- };
24
-
25
- if (checked) {
26
- nextState[indexPath] = true;
27
- } else {
28
- delete nextState[indexPath];
29
- }
30
-
31
- return nextState;
32
- });
23
+ var toggleRowSelected = function toggleRowSelected(indexPath, checked) {
24
+ return onSelectedRows(function (state) {
25
+ var nextState = _extends({}, state);
26
+
27
+ if (checked) {
28
+ nextState[indexPath] = true;
29
+ } else {
30
+ delete nextState[indexPath];
31
+ }
32
+
33
+ return nextState;
34
+ });
35
+ };
33
36
 
34
- const prepareRow = row => {
35
- row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);
37
+ var prepareRow = function prepareRow(row) {
38
+ row.toggleRowSelected = function () {
39
+ return toggleRowSelected(row.id, !row.isSelected);
40
+ };
36
41
  };
37
42
 
38
43
  hooks.prepareRow.push(prepareRow); // eslint-disable-next-line react-hooks/rules-of-hooks
39
44
 
40
- const lastSelectedSortedIndex = React__default.useRef();
41
- hooks.visibleColumns.push(columns => [{
42
- id: 'selection',
43
- Header: ({
44
- getToggleAllRowsSelectedProps,
45
- rows
46
- }) => {
47
- const {
48
- onChange: _,
49
- ...props
50
- } = getToggleAllRowsSelectedProps();
51
-
52
- const onChange = checked => {
53
- if (checked) {
54
- // this intentionally only selects top level rows - sub rows add too much complexity
55
- onSelectedRows(Object.assign({}, Array(rows.length).fill(true)));
56
- } else {
57
- onSelectedRows({});
58
- }
59
- };
60
-
61
- return React__default.createElement(Checkbox, Object.assign({}, props, {
62
- onChange: onChange,
63
- className: "mt-px"
64
- }));
65
- },
66
- Cell: ({
67
- row,
68
- rows
69
- }) => {
70
- const {
71
- onChange: _,
72
- ...props
73
- } = row.getToggleRowSelectedProps(); // row.index refers to the index in the original data, not the current index
74
-
75
- const sortedIndex = rows.findIndex(r => r.index === row.index);
76
-
77
- const onClick = event => {
78
- if (event.shiftKey) {
79
- const [fromIndex, toIndex] = toggleBetween(lastSelectedSortedIndex.current || 0, sortedIndex);
80
-
81
- for (let i = fromIndex; i <= toIndex; i++) {
82
- toggleRowSelected(rows[i].id, true);
45
+ var lastSelectedSortedIndex = React__default.useRef();
46
+ hooks.visibleColumns.push(function (columns) {
47
+ return [{
48
+ id: 'selection',
49
+ Header: function Header(_ref) {
50
+ var getToggleAllRowsSelectedProps = _ref.getToggleAllRowsSelectedProps,
51
+ rows = _ref.rows;
52
+
53
+ var _getToggleAllRowsSele = getToggleAllRowsSelectedProps(),
54
+ props = _objectWithoutPropertiesLoose(_getToggleAllRowsSele, _excluded);
55
+
56
+ var onChange = function onChange(checked) {
57
+ if (checked) {
58
+ // this intentionally only selects top level rows - sub rows add too much complexity
59
+ onSelectedRows(Object.assign({}, Array(rows.length).fill(true)));
60
+ } else {
61
+ onSelectedRows({});
83
62
  }
84
- } else {
85
- toggleRowSelected(row.id, !props.checked);
86
- }
87
-
88
- lastSelectedSortedIndex.current = sortedIndex;
89
- };
90
-
91
- return React__default.createElement(Checkbox, Object.assign({}, props, {
92
- className: "mt-px",
93
- onClick: onClick,
94
- // this is necessary to remove console spam from eslint
95
- onChange: () => false
96
- }));
97
- },
98
- flex: '0 0 36px',
99
- className: 'flex-col justify-start !pb-0'
100
- }, ...columns]);
63
+ };
64
+
65
+ return React__default.createElement(Checkbox, Object.assign({}, props, {
66
+ onChange: onChange,
67
+ className: "mt-px"
68
+ }));
69
+ },
70
+ Cell: function Cell(_ref2) {
71
+ var row = _ref2.row,
72
+ rows = _ref2.rows;
73
+
74
+ var _row$getToggleRowSele = row.getToggleRowSelectedProps(),
75
+ props = _objectWithoutPropertiesLoose(_row$getToggleRowSele, _excluded2); // row.index refers to the index in the original data, not the current index
76
+
77
+
78
+ var sortedIndex = rows.findIndex(function (r) {
79
+ return r.index === row.index;
80
+ });
81
+
82
+ var onClick = function onClick(event) {
83
+ if (event.shiftKey) {
84
+ var _toggleBetween = toggleBetween(lastSelectedSortedIndex.current || 0, sortedIndex),
85
+ fromIndex = _toggleBetween[0],
86
+ toIndex = _toggleBetween[1];
87
+
88
+ for (var i = fromIndex; i <= toIndex; i++) {
89
+ toggleRowSelected(rows[i].id, true);
90
+ }
91
+ } else {
92
+ toggleRowSelected(row.id, !props.checked);
93
+ }
94
+
95
+ lastSelectedSortedIndex.current = sortedIndex;
96
+ };
97
+
98
+ return React__default.createElement(Checkbox, Object.assign({}, props, {
99
+ className: "mt-px",
100
+ onClick: onClick,
101
+ // this is necessary to remove console spam from eslint
102
+ onChange: function onChange() {
103
+ return false;
104
+ }
105
+ }));
106
+ },
107
+ flex: '0 0 36px',
108
+ className: 'flex-col justify-start !pb-0'
109
+ }].concat(columns);
110
+ });
101
111
  }
102
112
  };
103
113
 
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelect.js","sources":["../../../../../../src/components/Table/hooks/plugins/useRowSelect.tsx"],"sourcesContent":["// this wraps react-table's internal useRowSelect hook\r\nimport React from 'react';\r\nimport { useRowSelect as useBaseRowSelect, Row, PluginHook } from 'react-table';\r\nimport { Checkbox } from '../../../Checkbox/Checkbox';\r\nimport { SelectedRowsHandler } from '../../types';\r\n\r\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\r\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\r\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\r\n\r\n return [fromIndex, toIndex];\r\n};\r\n\r\n// react-table calls \"index paths\" row ids. we named them indexPaths to reduce confusion with natural ids\r\n// the selection hook usess react-table's row selection, so this hok references row.id - it is the index path\r\n\r\nexport const useRowSelect = (onSelectedRows: SelectedRowsHandler | undefined): PluginHook<{}> => {\r\n const plugin = (hooks: any): void => {\r\n // eslint-disable-next-line react-hooks/rules-of-hooks\r\n useBaseRowSelect(hooks);\r\n\r\n if (onSelectedRows) {\r\n const toggleRowSelected = (indexPath: string, checked: boolean): void =>\r\n onSelectedRows(state => {\r\n const nextState = { ...state };\r\n\r\n if (checked) {\r\n nextState[indexPath] = true;\r\n } else {\r\n delete nextState[indexPath];\r\n }\r\n\r\n return nextState;\r\n });\r\n\r\n const prepareRow = (row: any) => {\r\n row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);\r\n };\r\n\r\n hooks.prepareRow.push(prepareRow);\r\n\r\n // eslint-disable-next-line react-hooks/rules-of-hooks\r\n const lastSelectedSortedIndex = React.useRef();\r\n\r\n hooks.visibleColumns.push((columns: any) => [\r\n {\r\n id: 'selection',\r\n Header: ({ getToggleAllRowsSelectedProps, rows }: any) => {\r\n const { onChange: _, ...props } = getToggleAllRowsSelectedProps();\r\n\r\n const onChange = (checked): void => {\r\n if (checked) {\r\n // this intentionally only selects top level rows - sub rows add too much complexity\r\n onSelectedRows(Object.assign({}, Array(rows.length).fill(true)));\r\n } else {\r\n onSelectedRows({});\r\n }\r\n };\r\n\r\n return <Checkbox {...props} onChange={onChange} className=\"mt-px\" />;\r\n },\r\n Cell: ({ row, rows }: any) => {\r\n const { onChange: _, ...props } = row.getToggleRowSelectedProps();\r\n // row.index refers to the index in the original data, not the current index\r\n const sortedIndex = rows.findIndex((r: Row) => r.index === row.index);\r\n\r\n const onClick = (event: React.MouseEvent): void => {\r\n if (event.shiftKey) {\r\n const [fromIndex, toIndex] = toggleBetween(lastSelectedSortedIndex.current || 0, sortedIndex);\r\n\r\n for (let i = fromIndex; i <= toIndex; i++) {\r\n toggleRowSelected(rows[i].id, true);\r\n }\r\n } else {\r\n toggleRowSelected(row.id, !props.checked);\r\n }\r\n\r\n lastSelectedSortedIndex.current = sortedIndex;\r\n };\r\n\r\n return (\r\n <Checkbox\r\n {...props}\r\n className=\"mt-px\"\r\n onClick={onClick}\r\n // this is necessary to remove console spam from eslint\r\n onChange={() => false}\r\n />\r\n );\r\n },\r\n flex: '0 0 36px',\r\n className: 'flex-col justify-start !pb-0',\r\n },\r\n ...columns,\r\n ]);\r\n }\r\n };\r\n plugin.pluginName = 'useRowSelect';\r\n return plugin;\r\n};\r\n"],"names":["toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","useRowSelect","onSelectedRows","plugin","hooks","useBaseRowSelect","toggleRowSelected","indexPath","checked","state","nextState","prepareRow","row","id","isSelected","push","lastSelectedSortedIndex","React","useRef","visibleColumns","columns","Header","getToggleAllRowsSelectedProps","rows","onChange","_","props","Object","assign","Array","length","fill","Checkbox","className","Cell","getToggleRowSelectedProps","sortedIndex","findIndex","r","index","onClick","event","shiftKey","current","i","flex","pluginName"],"mappings":";;;;AAAA;;AAMA,MAAMA,aAAa,GAAG,CAACC,YAAD,EAAuBC,UAAvB;AAClB,QAAMC,SAAS,GAAGD,UAAU,GAAGD,YAAb,GAA4BC,UAA5B,GAAyCD,YAA3D;AACA,QAAMG,OAAO,GAAGF,UAAU,GAAGD,YAAb,GAA4BC,UAA5B,GAAyCD,YAAzD;AAEA,SAAO,CAACE,SAAD,EAAYC,OAAZ,CAAP;AACH,CALD;AAQA;;;MAEaC,YAAY,GAAIC,cAAD;AACxB,QAAMC,MAAM,GAAIC,KAAD;AACX;AACAC,IAAAA,cAAgB,CAACD,KAAD,CAAhB;;AAEA,QAA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AA5C;AAmDH;AACJ,GA/ED;;AAgFAjB,EAAAA,MAAM,CAAC2C,UAAP,GAAoB,cAApB;AACA,SAAO3C,MAAP;AACH;;;;"}
1
+ {"version":3,"file":"useRowSelect.js","sources":["../../../../../../src/components/Table/hooks/plugins/useRowSelect.tsx"],"sourcesContent":["// this wraps react-table's internal useRowSelect hook\nimport React from 'react';\nimport { useRowSelect as useBaseRowSelect, Row, PluginHook } from 'react-table';\nimport { Checkbox } from '../../../Checkbox/Checkbox';\nimport { SelectedRowsHandler } from '../../types';\n\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\n\n return [fromIndex, toIndex];\n};\n\n// react-table calls \"index paths\" row ids. we named them indexPaths to reduce confusion with natural ids\n// the selection hook usess react-table's row selection, so this hok references row.id - it is the index path\n\nexport const useRowSelect = (onSelectedRows: SelectedRowsHandler | undefined): PluginHook<{}> => {\n const plugin = (hooks: any): void => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useBaseRowSelect(hooks);\n\n if (onSelectedRows) {\n const toggleRowSelected = (indexPath: string, checked: boolean): void =>\n onSelectedRows(state => {\n const nextState = { ...state };\n\n if (checked) {\n nextState[indexPath] = true;\n } else {\n delete nextState[indexPath];\n }\n\n return nextState;\n });\n\n const prepareRow = (row: any) => {\n row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);\n };\n\n hooks.prepareRow.push(prepareRow);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const lastSelectedSortedIndex = React.useRef();\n\n hooks.visibleColumns.push((columns: any) => [\n {\n id: 'selection',\n Header: ({ getToggleAllRowsSelectedProps, rows }: any) => {\n const { onChange: _, ...props } = getToggleAllRowsSelectedProps();\n\n const onChange = (checked): void => {\n if (checked) {\n // this intentionally only selects top level rows - sub rows add too much complexity\n onSelectedRows(Object.assign({}, Array(rows.length).fill(true)));\n } else {\n onSelectedRows({});\n }\n };\n\n return <Checkbox {...props} onChange={onChange} className=\"mt-px\" />;\n },\n Cell: ({ row, rows }: any) => {\n const { onChange: _, ...props } = row.getToggleRowSelectedProps();\n // row.index refers to the index in the original data, not the current index\n const sortedIndex = rows.findIndex((r: Row) => r.index === row.index);\n\n const onClick = (event: React.MouseEvent): void => {\n if (event.shiftKey) {\n const [fromIndex, toIndex] = toggleBetween(lastSelectedSortedIndex.current || 0, sortedIndex);\n\n for (let i = fromIndex; i <= toIndex; i++) {\n toggleRowSelected(rows[i].id, true);\n }\n } else {\n toggleRowSelected(row.id, !props.checked);\n }\n\n lastSelectedSortedIndex.current = sortedIndex;\n };\n\n return (\n <Checkbox\n {...props}\n className=\"mt-px\"\n onClick={onClick}\n // this is necessary to remove console spam from eslint\n onChange={() => false}\n />\n );\n },\n flex: '0 0 36px',\n className: 'flex-col justify-start !pb-0',\n },\n ...columns,\n ]);\n }\n };\n plugin.pluginName = 'useRowSelect';\n return plugin;\n};\n"],"names":["toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","useRowSelect","onSelectedRows","plugin","hooks","useBaseRowSelect","toggleRowSelected","indexPath","checked","state","nextState","prepareRow","row","id","isSelected","push","lastSelectedSortedIndex","React","useRef","visibleColumns","columns","Header","getToggleAllRowsSelectedProps","rows","props","onChange","Object","assign","Array","length","fill","Checkbox","className","Cell","getToggleRowSelectedProps","sortedIndex","findIndex","r","index","onClick","event","shiftKey","current","i","flex","pluginName"],"mappings":";;;;;;;;AAMA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,YAAD,EAAuBC,UAAvB;AAClB,MAAMC,SAAS,GAAGD,UAAU,GAAGD,YAAb,GAA4BC,UAA5B,GAAyCD,YAA3D;AACA,MAAMG,OAAO,GAAGF,UAAU,GAAGD,YAAb,GAA4BC,UAA5B,GAAyCD,YAAzD;AAEA,SAAO,CAACE,SAAD,EAAYC,OAAZ,CAAP;AACH,CALD;AA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AA,OAAO,EAAEA;AACT;AACAd,cAAAA,QAAQ,EAAE;AAAA,uBAAM,KAAN;AAAA;cALd,CADJ;AASH,WA5CL;AA6CImB,UAAAA,IAAI,EAAE,UA7CV;AA8CIZ,UAAAA,SAAS,EAAE;AA9Cf,SADsB,SAiDnBZ,OAjDmB;AAAA,OAA1B;AAmDH;AACJ,GA/ED;;AAgFAjB,EAAAA,MAAM,CAAC0C,UAAP,GAAoB,cAApB;AACA,SAAO1C,MAAP;AACH;;;;"}
@@ -1,3 +1,4 @@
1
+ import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import React__default from 'react';
2
3
  import { v4 } from 'uuid';
3
4
  import set from 'lodash-es/set';
@@ -7,17 +8,27 @@ import get from 'lodash-es/get';
7
8
  import compact from 'lodash-es/compact';
8
9
  import pullAt from 'lodash-es/pullAt';
9
10
 
10
- const insertChildTableRow = (data, rowIndexPath = undefined, values = {}) => {
11
- const nexTRow = JSON.parse(JSON.stringify(data));
12
- let childRowIndexPath;
11
+ var insertChildTableRow = function insertChildTableRow(data, rowIndexPath, values) {
12
+ if (rowIndexPath === void 0) {
13
+ rowIndexPath = undefined;
14
+ }
15
+
16
+ if (values === void 0) {
17
+ values = {};
18
+ }
19
+
20
+ var nexTRow = JSON.parse(JSON.stringify(data));
21
+ var childRowIndexPath;
13
22
 
14
23
  if (rowIndexPath) {
15
24
  var _currentRow$subRows;
16
25
 
17
- const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);
18
- const currentRow = getByRowIndexPath(nexTRow, rowIndexes.join('.'));
19
- const nextSubRows = (_currentRow$subRows = currentRow === null || currentRow === void 0 ? void 0 : currentRow.subRows) !== null && _currentRow$subRows !== void 0 ? _currentRow$subRows : [];
20
- const path = rowIndexes.map(i => `[${i}]`).join('.subRows') + '.subRows';
26
+ var rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);
27
+ var currentRow = getByRowIndexPath(nexTRow, rowIndexes.join('.'));
28
+ var nextSubRows = (_currentRow$subRows = currentRow === null || currentRow === void 0 ? void 0 : currentRow.subRows) !== null && _currentRow$subRows !== void 0 ? _currentRow$subRows : [];
29
+ var path = rowIndexes.map(function (i) {
30
+ return "[" + i + "]";
31
+ }).join('.subRows') + '.subRows';
21
32
  nextSubRows.unshift(values);
22
33
  set(nexTRow, path, nextSubRows); // rebuild the new id
23
34
 
@@ -30,18 +41,22 @@ const insertChildTableRow = (data, rowIndexPath = undefined, values = {}) => {
30
41
 
31
42
  return [nexTRow, childRowIndexPath];
32
43
  };
33
- const removeChildTableRow = (data, rowIndexPath) => {
34
- const nexTRow = JSON.parse(JSON.stringify(data));
35
- const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);
36
- const rootIndex = Number(rowIndexes.shift());
44
+ var removeChildTableRow = function removeChildTableRow(data, rowIndexPath) {
45
+ var nexTRow = JSON.parse(JSON.stringify(data));
46
+ var rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);
47
+ var rootIndex = Number(rowIndexes.shift());
37
48
 
38
49
  if (rowIndexes.length) {
39
50
  // unset
40
- const unsetPath = rowIndexes.map(index => `subRows[${index}]`).join('.');
51
+ var unsetPath = rowIndexes.map(function (index) {
52
+ return "subRows[" + index + "]";
53
+ }).join('.');
41
54
  unset(nexTRow[rootIndex], unsetPath); // remove empty value from subRows
42
55
 
43
56
  rowIndexes.pop();
44
- const setPath = rowIndexes.length ? rowIndexes.map(index => `subRows[${index}]`).join('.') + '.subRows' : 'subRows';
57
+ var setPath = rowIndexes.length ? rowIndexes.map(function (index) {
58
+ return "subRows[" + index + "]";
59
+ }).join('.') + '.subRows' : 'subRows';
45
60
  set(nexTRow[rootIndex], setPath, compact(get(nexTRow[rootIndex], setPath)));
46
61
  } else {
47
62
  pullAt(nexTRow, rootIndex);
@@ -49,17 +64,26 @@ const removeChildTableRow = (data, rowIndexPath) => {
49
64
 
50
65
  return nexTRow;
51
66
  };
52
- const useTableRowCreation = (data, tableRef) => {
53
- const [internalData, setInternalData] = React__default.useState(JSON.parse(JSON.stringify(data)));
54
- const [activeRowIndexPath, setActiveRowIndexPath] = React__default.useState(undefined);
55
- React__default.useEffect(() => {
67
+ var useTableRowCreation = function useTableRowCreation(data, tableRef) {
68
+ var _React$useState = React__default.useState(JSON.parse(JSON.stringify(data))),
69
+ internalData = _React$useState[0],
70
+ setInternalData = _React$useState[1];
71
+
72
+ var _React$useState2 = React__default.useState(undefined),
73
+ activeRowIndexPath = _React$useState2[0],
74
+ setActiveRowIndexPath = _React$useState2[1];
75
+
76
+ React__default.useEffect(function () {
56
77
  if (activeRowIndexPath !== undefined) {
57
78
  // keep the same edit key, so that we don't remount the row/form
58
- const currentRow = getByRowIndexPath(internalData, activeRowIndexPath); // get the active creation rows parent
79
+ var currentRow = getByRowIndexPath(internalData, activeRowIndexPath); // get the active creation rows parent
59
80
 
60
- const parentId = getParentRowIndexPath(activeRowIndexPath); // insert a new empty row in the external data (with the same key)
81
+ var parentId = getParentRowIndexPath(activeRowIndexPath); // insert a new empty row in the external data (with the same key)
82
+
83
+ var _insertChildTableRow = insertChildTableRow(JSON.parse(JSON.stringify(data)), parentId, currentRow),
84
+ nexTRow = _insertChildTableRow[0],
85
+ newRowIndexPath = _insertChildTableRow[1]; // update and set that row as active, we basically just changed it's position in our internal data
61
86
 
62
- const [nexTRow, newRowIndexPath] = insertChildTableRow(JSON.parse(JSON.stringify(data)), parentId, currentRow); // update and set that row as active, we basically just changed it's position in our internal data
63
87
 
64
88
  setActiveRowIndexPath(newRowIndexPath);
65
89
  setInternalData(nexTRow);
@@ -72,12 +96,23 @@ const useTableRowCreation = (data, tableRef) => {
72
96
  }
73
97
  }, [JSON.stringify(data)]);
74
98
 
75
- const create = (rowIndexPath = undefined, values = {}) => {
76
- const _createKey = v4();
99
+ var create = function create(rowIndexPath, values) {
100
+ if (rowIndexPath === void 0) {
101
+ rowIndexPath = undefined;
102
+ }
103
+
104
+ if (values === void 0) {
105
+ values = {};
106
+ }
107
+
108
+ var _createKey = v4();
109
+
110
+ var _insertChildTableRow2 = insertChildTableRow(internalData, rowIndexPath, _extends({}, values, {
111
+ _createKey: _createKey
112
+ })),
113
+ nexTRow = _insertChildTableRow2[0],
114
+ newRowIndexPath = _insertChildTableRow2[1];
77
115
 
78
- const [nexTRow, newRowIndexPath] = insertChildTableRow(internalData, rowIndexPath, { ...values,
79
- _createKey
80
- });
81
116
  setActiveRowIndexPath(newRowIndexPath);
82
117
  setInternalData(nexTRow);
83
118
 
@@ -88,16 +123,16 @@ const useTableRowCreation = (data, tableRef) => {
88
123
  return newRowIndexPath;
89
124
  };
90
125
 
91
- const remove = rowIndexPath => {
92
- const nexTRow = removeChildTableRow(internalData, rowIndexPath);
126
+ var remove = function remove(rowIndexPath) {
127
+ var nexTRow = removeChildTableRow(internalData, rowIndexPath);
93
128
  setInternalData(nexTRow);
94
129
  setActiveRowIndexPath(undefined);
95
130
  };
96
131
 
97
132
  return {
98
133
  data: internalData,
99
- create,
100
- remove,
134
+ create: create,
135
+ remove: remove,
101
136
  isCreating: activeRowIndexPath !== undefined
102
137
  };
103
138
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useRowCreation.js","sources":["../../../../../src/components/Table/hooks/useRowCreation.tsx"],"sourcesContent":["import React from 'react';\r\nimport { v4 as uuid } from 'uuid';\r\nimport set from 'lodash/set';\r\nimport unset from 'lodash/unset';\r\nimport get from 'lodash/get';\r\nimport compact from 'lodash/compact';\r\nimport pullAt from 'lodash/pullAt';\r\n\r\nimport { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath } from '../util/rowIndexPath';\r\nimport { Row, RowIndexPath, TableRef } from '../types';\r\n\r\nexport const insertChildTableRow = <TRow,>(\r\n data: Row<TRow>[],\r\n rowIndexPath: RowIndexPath = undefined,\r\n values: any = {}\r\n): [Row<TRow>[], RowIndexPath] => {\r\n const nexTRow: Row<TRow>[] = JSON.parse(JSON.stringify(data));\r\n\r\n let childRowIndexPath;\r\n\r\n if (rowIndexPath) {\r\n const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);\r\n const currentRow = getByRowIndexPath(nexTRow, rowIndexes.join('.'));\r\n const nextSubRows = currentRow?.subRows ?? [];\r\n\r\n const path = rowIndexes.map(i => `[${i}]`).join('.subRows') + '.subRows';\r\n nextSubRows.unshift(values);\r\n set(nexTRow, path, nextSubRows);\r\n\r\n // rebuild the new id\r\n rowIndexes.push(0);\r\n childRowIndexPath = rowIndexes.join('.');\r\n } else {\r\n nexTRow.unshift(values);\r\n childRowIndexPath = '0';\r\n }\r\n\r\n return [nexTRow, childRowIndexPath];\r\n};\r\n\r\nexport const removeChildTableRow = <TRow,>(data: Row<TRow>[], rowIndexPath: RowIndexPath): Row<TRow>[] => {\r\n const nexTRow = JSON.parse(JSON.stringify(data));\r\n\r\n const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);\r\n const rootIndex = Number(rowIndexes.shift());\r\n\r\n if (rowIndexes.length) {\r\n // unset\r\n const unsetPath = rowIndexes.map(index => `subRows[${index}]`).join('.');\r\n unset(nexTRow[rootIndex], unsetPath);\r\n\r\n // remove empty value from subRows\r\n rowIndexes.pop();\r\n const setPath = rowIndexes.length ? rowIndexes.map(index => `subRows[${index}]`).join('.') + '.subRows' : 'subRows';\r\n set(nexTRow[rootIndex], setPath, compact(get(nexTRow[rootIndex], setPath)));\r\n } else {\r\n pullAt(nexTRow, rootIndex);\r\n }\r\n\r\n return nexTRow;\r\n};\r\n\r\nexport type useTableRowCreation<TRow> = {\r\n data: Row<TRow>[];\r\n create: (rowIndexPath: RowIndexPath, values?: object | undefined) => RowIndexPath;\r\n remove: (rowIndexPath: RowIndexPath) => void;\r\n isCreating: boolean;\r\n};\r\n\r\nexport const useTableRowCreation = <TRow,>(data: Row<TRow>[], tableRef: React.RefObject<TableRef>): useTableRowCreation<TRow> => {\r\n const [internalData, setInternalData] = React.useState(JSON.parse(JSON.stringify(data)));\r\n const [activeRowIndexPath, setActiveRowIndexPath] = React.useState<string | undefined>(undefined);\r\n\r\n React.useEffect(() => {\r\n if (activeRowIndexPath !== undefined) {\r\n // keep the same edit key, so that we don't remount the row/form\r\n const currentRow: any = getByRowIndexPath(internalData, activeRowIndexPath);\r\n\r\n // get the active creation rows parent\r\n const parentId = getParentRowIndexPath(activeRowIndexPath);\r\n\r\n // insert a new empty row in the external data (with the same key)\r\n const [nexTRow, newRowIndexPath] = insertChildTableRow(JSON.parse(JSON.stringify(data)), parentId, currentRow);\r\n\r\n // update and set that row as active, we basically just changed it's position in our internal data\r\n setActiveRowIndexPath(newRowIndexPath);\r\n setInternalData(nexTRow);\r\n\r\n if (tableRef?.current) {\r\n tableRef.current.instance.toggleRowEditing(currentRow?._createKey);\r\n }\r\n } else {\r\n setInternalData(data);\r\n }\r\n }, [JSON.stringify(data)]);\r\n\r\n const create = (rowIndexPath: RowIndexPath = undefined, values: object | undefined = {}): RowIndexPath => {\r\n const _createKey = uuid();\r\n const [nexTRow, newRowIndexPath] = insertChildTableRow(internalData, rowIndexPath, { ...values, _createKey });\r\n setActiveRowIndexPath(newRowIndexPath);\r\n setInternalData(nexTRow);\r\n\r\n if (tableRef?.current) {\r\n tableRef.current.instance.toggleRowEditing(_createKey);\r\n }\r\n\r\n return newRowIndexPath;\r\n };\r\n\r\n const remove = (rowIndexPath: any): void => {\r\n const nexTRow = removeChildTableRow(internalData, rowIndexPath);\r\n setInternalData(nexTRow);\r\n setActiveRowIndexPath(undefined);\r\n };\r\n\r\n return {\r\n data: internalData,\r\n create,\r\n remove,\r\n isCreating: activeRowIndexPath !== undefined,\r\n };\r\n};\r\n"],"names":["insertChildTableRow","data","rowIndexPath","undefined","values","nexTRow","JSON","parse","stringify","childRowIndexPath","rowIndexes","convertRowIndexPathToNumberArray","currentRow","getByRowIndexPath","join","nextSubRows","subRows","path","map","i","unshift","set","push","removeChildTableRow","rootIndex","Number","shift","length","unsetPath","index","unset","pop","setPath","compact","get","pullAt","useTableRowCreation","tableRef","internalData","setInternalData","React","useState","activeRowIndexPath","setActiveRowIndexPath","useEffect","parentId","getParentRowIndexPath","newRowIndexPath","current","instance","toggleRowEditing","_createKey","create","uuid","remove","isCreating"],"mappings":";;;;;;;;;MAWaA,mBAAmB,GAAG,CAC/BC,IAD+B,EAE/BC,eAA6BC,SAFE,EAG/BC,SAAc,EAHiB;AAK/B,QAAMC,OAAO,GAAgBC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAeP,IAAf,CAAX,CAA7B;AAEA,MAAIQ,iBAAJ;;AAEA,MAAIP,YAAJ,EAAkB;AAAA;;AACd,UAAMQ,UAAU,GAAGC,gCAAgC,CAACT,YAAD,CAAnD;AACA,UAAMU,UAAU,GAAGC,iBAAiB,CAACR,OAAD,EAAUK,UAAU,CAACI,IAAX,CAAgB,GAAhB,CAAV,CAApC;AACA,UAAMC,WAAW,0BAAGH,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEI,OAAf,qEAA0B,EAA3C;AAEA,UAAMC,IAAI,GAAGP,UAAU,CAACQ,GAAX,CAAeC,CAAC,QAAQA,IAAxB,EAA8BL,IAA9B,CAAmC,UAAnC,IAAiD,UAA9D;AACAC,IAAAA,WAAW,CAACK,OAAZ,CAAoBhB,MAApB;AACAiB,IAAAA,GAAG,CAAChB,OAAD,EAAUY,IAAV,EAAgBF,WAAhB,CAAH,CAPc;;AAUdL,IAAAA,UAAU,CAACY,IAAX,CAAgB,CAAhB;AACAb,IAAAA,iBAAiB,GAAGC,UAAU,CAACI,IAAX,CAAgB,GAAhB,CAApB;AACH,GAZD,MAYO;AACHT,IAAAA,OAAO,CAACe,OAAR,CAAgBhB,MAAhB;AACAK,IAAAA,iBAAiB,GAAG,GAApB;AACH;;AAED,SAAO,CAACJ,OAAD,EAAUI,iBAAV,CAAP;AACH;MAEYc,mBAAmB,GAAG,CAAQtB,IAAR,EAA2BC,YAA3B;AAC/B,QAAMG,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAeP,IAAf,CAAX,C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ED,WAAOJ,eAAP;AACH,GAXD;;AAaA,QAAMO,MAAM,GAAIpD,YAAD;AACX,UAAMG,OAAO,GAAGkB,mBAAmB,CAACe,YAAD,EAAepC,YAAf,CAAnC;AACAqC,IAAAA,eAAe,CAAClC,OAAD,CAAf;AACAsC,IAAAA,qBAAqB,CAACxC,SAAD,CAArB;AACH,GAJD;;AAMA,SAAO;AACHF,IAAAA,IAAI,EAAEqC,YADH;AAEHc,IAAAA,MAFG;AAGHE,IAAAA,MAHG;AAIHC,IAAAA,UAAU,EAAEb,kBAAkB,KAAKvC;AAJhC,GAAP;AAMH;;;;"}
1
+ {"version":3,"file":"useRowCreation.js","sources":["../../../../../src/components/Table/hooks/useRowCreation.tsx"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport set from 'lodash/set';\nimport unset from 'lodash/unset';\nimport get from 'lodash/get';\nimport compact from 'lodash/compact';\nimport pullAt from 'lodash/pullAt';\n\nimport { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath } from '../util/rowIndexPath';\nimport { Row, RowIndexPath, TableRef } from '../types';\n\nexport const insertChildTableRow = <TRow,>(\n data: Row<TRow>[],\n rowIndexPath: RowIndexPath = undefined,\n values: any = {}\n): [Row<TRow>[], RowIndexPath] => {\n const nexTRow: Row<TRow>[] = JSON.parse(JSON.stringify(data));\n\n let childRowIndexPath;\n\n if (rowIndexPath) {\n const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);\n const currentRow = getByRowIndexPath(nexTRow, rowIndexes.join('.'));\n const nextSubRows = currentRow?.subRows ?? [];\n\n const path = rowIndexes.map(i => `[${i}]`).join('.subRows') + '.subRows';\n nextSubRows.unshift(values);\n set(nexTRow, path, nextSubRows);\n\n // rebuild the new id\n rowIndexes.push(0);\n childRowIndexPath = rowIndexes.join('.');\n } else {\n nexTRow.unshift(values);\n childRowIndexPath = '0';\n }\n\n return [nexTRow, childRowIndexPath];\n};\n\nexport const removeChildTableRow = <TRow,>(data: Row<TRow>[], rowIndexPath: RowIndexPath): Row<TRow>[] => {\n const nexTRow = JSON.parse(JSON.stringify(data));\n\n const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);\n const rootIndex = Number(rowIndexes.shift());\n\n if (rowIndexes.length) {\n // unset\n const unsetPath = rowIndexes.map(index => `subRows[${index}]`).join('.');\n unset(nexTRow[rootIndex], unsetPath);\n\n // remove empty value from subRows\n rowIndexes.pop();\n const setPath = rowIndexes.length ? rowIndexes.map(index => `subRows[${index}]`).join('.') + '.subRows' : 'subRows';\n set(nexTRow[rootIndex], setPath, compact(get(nexTRow[rootIndex], setPath)));\n } else {\n pullAt(nexTRow, rootIndex);\n }\n\n return nexTRow;\n};\n\nexport type useTableRowCreation<TRow> = {\n data: Row<TRow>[];\n create: (rowIndexPath: RowIndexPath, values?: object | undefined) => RowIndexPath;\n remove: (rowIndexPath: RowIndexPath) => void;\n isCreating: boolean;\n};\n\nexport const useTableRowCreation = <TRow,>(data: Row<TRow>[], tableRef: React.RefObject<TableRef>): useTableRowCreation<TRow> => {\n const [internalData, setInternalData] = React.useState(JSON.parse(JSON.stringify(data)));\n const [activeRowIndexPath, setActiveRowIndexPath] = React.useState<string | undefined>(undefined);\n\n React.useEffect(() => {\n if (activeRowIndexPath !== undefined) {\n // keep the same edit key, so that we don't remount the row/form\n const currentRow: any = getByRowIndexPath(internalData, activeRowIndexPath);\n\n // get the active creation rows parent\n const parentId = getParentRowIndexPath(activeRowIndexPath);\n\n // insert a new empty row in the external data (with the same key)\n const [nexTRow, newRowIndexPath] = insertChildTableRow(JSON.parse(JSON.stringify(data)), parentId, currentRow);\n\n // update and set that row as active, we basically just changed it's position in our internal data\n setActiveRowIndexPath(newRowIndexPath);\n setInternalData(nexTRow);\n\n if (tableRef?.current) {\n tableRef.current.instance.toggleRowEditing(currentRow?._createKey);\n }\n } else {\n setInternalData(data);\n }\n }, [JSON.stringify(data)]);\n\n const create = (rowIndexPath: RowIndexPath = undefined, values: object | undefined = {}): RowIndexPath => {\n const _createKey = uuid();\n const [nexTRow, newRowIndexPath] = insertChildTableRow(internalData, rowIndexPath, { ...values, _createKey });\n setActiveRowIndexPath(newRowIndexPath);\n setInternalData(nexTRow);\n\n if (tableRef?.current) {\n tableRef.current.instance.toggleRowEditing(_createKey);\n }\n\n return newRowIndexPath;\n };\n\n const remove = (rowIndexPath: any): void => {\n const nexTRow = removeChildTableRow(internalData, rowIndexPath);\n setInternalData(nexTRow);\n setActiveRowIndexPath(undefined);\n };\n\n return {\n data: internalData,\n create,\n remove,\n isCreating: activeRowIndexPath !== undefined,\n };\n};\n"],"names":["insertChildTableRow","data","rowIndexPath","values","undefined","nexTRow","JSON","parse","stringify","childRowIndexPath","rowIndexes","convertRowIndexPathToNumberArray","currentRow","getByRowIndexPath","join","nextSubRows","subRows","path","map","i","unshift","set","push","removeChildTableRow","rootIndex","Number","shift","length","unsetPath","index","unset","pop","setPath","compact","get","pullAt","useTableRowCreation","tableRef","React","useState","internalData","setInternalData","activeRowIndexPath","setActiveRowIndexPath","useEffect","parentId","getParentRowIndexPath","newRowIndexPath","current","instance","toggleRowEditing","_createKey","create","uuid","remove","isCreating"],"mappings":";;;;;;;;;;IAWaA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAC/BC,IAD+B,EAE/BC,YAF+B,EAG/BC,MAH+B;MAE/BD;AAAAA,IAAAA,eAA6BE;;;MAC7BD;AAAAA,IAAAA,SAAc;;;AAEd,MAAME,OAAO,GAAgBC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAeP,IAAf,CAAX,CAA7B;AAEA,MAAIQ,iBAAJ;;AAEA,MAAIP,YAAJ,EAAkB;AAAA;;AACd,QAAMQ,UAAU,GAAGC,gCAAgC,CAACT,YAAD,CAAnD;AACA,QAAMU,UAAU,GAAGC,iBAAiB,CAACR,OAAD,EAAUK,UAAU,CAACI,IAAX,CAAgB,GAAhB,CAAV,CAApC;AACA,QAAMC,WAAW,0BAAGH,UAAH,aAAGA,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