@economic/taco 1.0.5 → 1.0.6
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.
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +35 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/esm/components/Accordion/Accordion.js +93 -0
- package/dist/esm/components/Accordion/Accordion.js.map +1 -0
- package/dist/esm/components/Backdrop/Backdrop.js +13 -0
- package/dist/esm/components/Backdrop/Backdrop.js.map +1 -0
- package/dist/esm/components/Badge/Badge.js +32 -0
- package/dist/esm/components/Badge/Badge.js.map +1 -0
- package/dist/esm/components/Banner/Banner.js +24 -0
- package/dist/esm/components/Banner/Banner.js.map +1 -0
- package/dist/esm/components/Banner/util.js +36 -0
- package/dist/esm/components/Banner/util.js.map +1 -0
- package/dist/esm/components/Button/Button.js +36 -0
- package/dist/esm/components/Button/Button.js.map +1 -0
- package/dist/esm/components/Button/util.js +77 -0
- package/dist/esm/components/Button/util.js.map +1 -0
- package/dist/esm/components/Calendar/Calendar.js +152 -0
- package/dist/esm/components/Calendar/Calendar.js.map +1 -0
- package/dist/esm/components/Checkbox/Checkbox.js +58 -0
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/esm/components/Combobox/Combobox.js +89 -0
- package/dist/esm/components/Combobox/Combobox.js.map +1 -0
- package/dist/esm/components/Combobox/useCombobox.js +285 -0
- package/dist/esm/components/Combobox/useCombobox.js.map +1 -0
- package/dist/esm/components/Datepicker/Datepicker.js +75 -0
- package/dist/esm/components/Datepicker/Datepicker.js.map +1 -0
- package/dist/esm/components/Datepicker/useDatepicker.js +88 -0
- package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -0
- package/dist/esm/components/Dialog/Context.js +26 -0
- package/dist/esm/components/Dialog/Context.js.map +1 -0
- package/dist/esm/components/Dialog/Dialog.js +98 -0
- package/dist/esm/components/Dialog/Dialog.js.map +1 -0
- package/dist/esm/components/Dialog/components/Content.js +135 -0
- package/dist/esm/components/Dialog/components/Content.js.map +1 -0
- package/dist/esm/components/Dialog/components/Drawer.js +42 -0
- package/dist/esm/components/Dialog/components/Drawer.js.map +1 -0
- package/dist/esm/components/Dialog/components/Extra.js +15 -0
- package/dist/esm/components/Dialog/components/Extra.js.map +1 -0
- package/dist/esm/components/Dialog/components/Trigger.js +15 -0
- package/dist/esm/components/Dialog/components/Trigger.js.map +1 -0
- package/dist/esm/components/Field/Field.js +33 -0
- package/dist/esm/components/Field/Field.js.map +1 -0
- package/dist/esm/components/Form/Form.js +22 -0
- package/dist/esm/components/Form/Form.js.map +1 -0
- package/dist/esm/components/Group/Group.js +20 -0
- package/dist/esm/components/Group/Group.js.map +1 -0
- package/dist/esm/components/Hanger/Hanger.js +104 -0
- package/dist/esm/components/Hanger/Hanger.js.map +1 -0
- package/dist/esm/components/HoverCard/HoverCard.js +33 -0
- package/dist/esm/components/HoverCard/HoverCard.js.map +1 -0
- package/dist/esm/components/Icon/Icon.js +30 -0
- package/dist/esm/components/Icon/Icon.js.map +1 -0
- package/dist/esm/components/Icon/components/AccountPreview.js +18 -0
- package/dist/esm/components/Icon/components/AccountPreview.js.map +1 -0
- package/dist/esm/components/Icon/components/Accounting.js +18 -0
- package/dist/esm/components/Icon/components/Accounting.js.map +1 -0
- package/dist/esm/components/Icon/components/AccountingYear.js +18 -0
- package/dist/esm/components/Icon/components/AccountingYear.js.map +1 -0
- package/dist/esm/components/Icon/components/AccountingYearCancel.js +18 -0
- package/dist/esm/components/Icon/components/AccountingYearCancel.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowBottom.js +18 -0
- package/dist/esm/components/Icon/components/ArrowBottom.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowDown.js +18 -0
- package/dist/esm/components/Icon/components/ArrowDown.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowEnd.js +18 -0
- package/dist/esm/components/Icon/components/ArrowEnd.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowLeft.js +18 -0
- package/dist/esm/components/Icon/components/ArrowLeft.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowRight.js +18 -0
- package/dist/esm/components/Icon/components/ArrowRight.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowStart.js +18 -0
- package/dist/esm/components/Icon/components/ArrowStart.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowTop.js +18 -0
- package/dist/esm/components/Icon/components/ArrowTop.js.map +1 -0
- package/dist/esm/components/Icon/components/ArrowUp.js +18 -0
- package/dist/esm/components/Icon/components/ArrowUp.js.map +1 -0
- package/dist/esm/components/Icon/components/Attach.js +18 -0
- package/dist/esm/components/Icon/components/Attach.js.map +1 -0
- package/dist/esm/components/Icon/components/AttachAuto.js +18 -0
- package/dist/esm/components/Icon/components/AttachAuto.js.map +1 -0
- package/dist/esm/components/Icon/components/AttachCancel.js +18 -0
- package/dist/esm/components/Icon/components/AttachCancel.js.map +1 -0
- package/dist/esm/components/Icon/components/Autotext.js +18 -0
- package/dist/esm/components/Icon/components/Autotext.js.map +1 -0
- package/dist/esm/components/Icon/components/AutotextInsert.js +18 -0
- package/dist/esm/components/Icon/components/AutotextInsert.js.map +1 -0
- package/dist/esm/components/Icon/components/Basic.js +18 -0
- package/dist/esm/components/Icon/components/Basic.js.map +1 -0
- package/dist/esm/components/Icon/components/BasicTabs.js +18 -0
- package/dist/esm/components/Icon/components/BasicTabs.js.map +1 -0
- package/dist/esm/components/Icon/components/BellSolid.js +18 -0
- package/dist/esm/components/Icon/components/BellSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Book.js +18 -0
- package/dist/esm/components/Icon/components/Book.js.map +1 -0
- package/dist/esm/components/Icon/components/Booking.js +18 -0
- package/dist/esm/components/Icon/components/Booking.js.map +1 -0
- package/dist/esm/components/Icon/components/Budget.js +18 -0
- package/dist/esm/components/Icon/components/Budget.js.map +1 -0
- package/dist/esm/components/Icon/components/Calendar.js +18 -0
- package/dist/esm/components/Icon/components/Calendar.js.map +1 -0
- package/dist/esm/components/Icon/components/CashAccount.js +17 -0
- package/dist/esm/components/Icon/components/CashAccount.js.map +1 -0
- package/dist/esm/components/Icon/components/CashReports.js +18 -0
- package/dist/esm/components/Icon/components/CashReports.js.map +1 -0
- package/dist/esm/components/Icon/components/Chat.js +18 -0
- package/dist/esm/components/Icon/components/Chat.js.map +1 -0
- package/dist/esm/components/Icon/components/ChatSolid.js +18 -0
- package/dist/esm/components/Icon/components/ChatSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronDown.js +18 -0
- package/dist/esm/components/Icon/components/ChevronDown.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronDownDouble.js +18 -0
- package/dist/esm/components/Icon/components/ChevronDownDouble.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronDownSolid.js +18 -0
- package/dist/esm/components/Icon/components/ChevronDownSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronLeft.js +18 -0
- package/dist/esm/components/Icon/components/ChevronLeft.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronLeftDouble.js +18 -0
- package/dist/esm/components/Icon/components/ChevronLeftDouble.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronRight.js +18 -0
- package/dist/esm/components/Icon/components/ChevronRight.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronRightDouble.js +18 -0
- package/dist/esm/components/Icon/components/ChevronRightDouble.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronUp.js +18 -0
- package/dist/esm/components/Icon/components/ChevronUp.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronUpDouble.js +18 -0
- package/dist/esm/components/Icon/components/ChevronUpDouble.js.map +1 -0
- package/dist/esm/components/Icon/components/ChevronUpSolid.js +18 -0
- package/dist/esm/components/Icon/components/ChevronUpSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/CircleClose.js +19 -0
- package/dist/esm/components/Icon/components/CircleClose.js.map +1 -0
- package/dist/esm/components/Icon/components/CircleMinus.js +18 -0
- package/dist/esm/components/Icon/components/CircleMinus.js.map +1 -0
- package/dist/esm/components/Icon/components/CirclePlus.js +18 -0
- package/dist/esm/components/Icon/components/CirclePlus.js.map +1 -0
- package/dist/esm/components/Icon/components/CircleTick.js +18 -0
- package/dist/esm/components/Icon/components/CircleTick.js.map +1 -0
- package/dist/esm/components/Icon/components/Clamp.js +18 -0
- package/dist/esm/components/Icon/components/Clamp.js.map +1 -0
- package/dist/esm/components/Icon/components/ClampOpen.js +18 -0
- package/dist/esm/components/Icon/components/ClampOpen.js.map +1 -0
- package/dist/esm/components/Icon/components/Close.js +18 -0
- package/dist/esm/components/Icon/components/Close.js.map +1 -0
- package/dist/esm/components/Icon/components/ConnectionEnable.js +17 -0
- package/dist/esm/components/Icon/components/ConnectionEnable.js.map +1 -0
- package/dist/esm/components/Icon/components/ConnectionRevoke.js +17 -0
- package/dist/esm/components/Icon/components/ConnectionRevoke.js.map +1 -0
- package/dist/esm/components/Icon/components/Contacts.js +18 -0
- package/dist/esm/components/Icon/components/Contacts.js.map +1 -0
- package/dist/esm/components/Icon/components/Copy.js +18 -0
- package/dist/esm/components/Icon/components/Copy.js.map +1 -0
- package/dist/esm/components/Icon/components/Courses.js +17 -0
- package/dist/esm/components/Icon/components/Courses.js.map +1 -0
- package/dist/esm/components/Icon/components/Credit.js +18 -0
- package/dist/esm/components/Icon/components/Credit.js.map +1 -0
- package/dist/esm/components/Icon/components/Delete.js +18 -0
- package/dist/esm/components/Icon/components/Delete.js.map +1 -0
- package/dist/esm/components/Icon/components/DeletePermanently.js +18 -0
- package/dist/esm/components/Icon/components/DeletePermanently.js.map +1 -0
- package/dist/esm/components/Icon/components/Depecriate.js +18 -0
- package/dist/esm/components/Icon/components/Depecriate.js.map +1 -0
- package/dist/esm/components/Icon/components/Developer.js +18 -0
- package/dist/esm/components/Icon/components/Developer.js.map +1 -0
- package/dist/esm/components/Icon/components/DistributionTemplate.js +18 -0
- package/dist/esm/components/Icon/components/DistributionTemplate.js.map +1 -0
- package/dist/esm/components/Icon/components/Document.js +17 -0
- package/dist/esm/components/Icon/components/Document.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentApprove.js +18 -0
- package/dist/esm/components/Icon/components/DocumentApprove.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentCreateEntry.js +18 -0
- package/dist/esm/components/Icon/components/DocumentCreateEntry.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentCut.js +18 -0
- package/dist/esm/components/Icon/components/DocumentCut.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentError.js +18 -0
- package/dist/esm/components/Icon/components/DocumentError.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentIsolatePage.js +18 -0
- package/dist/esm/components/Icon/components/DocumentIsolatePage.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentMerge.js +18 -0
- package/dist/esm/components/Icon/components/DocumentMerge.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentMove.js +18 -0
- package/dist/esm/components/Icon/components/DocumentMove.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentPreview.js +18 -0
- package/dist/esm/components/Icon/components/DocumentPreview.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentReceived.js +17 -0
- package/dist/esm/components/Icon/components/DocumentReceived.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentRejectedRequest.js +17 -0
- package/dist/esm/components/Icon/components/DocumentRejectedRequest.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentSplit.js +18 -0
- package/dist/esm/components/Icon/components/DocumentSplit.js.map +1 -0
- package/dist/esm/components/Icon/components/DocumentTime.js +18 -0
- package/dist/esm/components/Icon/components/DocumentTime.js.map +1 -0
- package/dist/esm/components/Icon/components/Download.js +18 -0
- package/dist/esm/components/Icon/components/Download.js.map +1 -0
- package/dist/esm/components/Icon/components/Drag.js +18 -0
- package/dist/esm/components/Icon/components/Drag.js.map +1 -0
- package/dist/esm/components/Icon/components/ECopedia.js +18 -0
- package/dist/esm/components/Icon/components/ECopedia.js.map +1 -0
- package/dist/esm/components/Icon/components/ESignature.js +18 -0
- package/dist/esm/components/Icon/components/ESignature.js.map +1 -0
- package/dist/esm/components/Icon/components/Edit.js +18 -0
- package/dist/esm/components/Icon/components/Edit.js.map +1 -0
- package/dist/esm/components/Icon/components/EllipsisHorizontal.js +18 -0
- package/dist/esm/components/Icon/components/EllipsisHorizontal.js.map +1 -0
- package/dist/esm/components/Icon/components/EllipsisVertical.js +18 -0
- package/dist/esm/components/Icon/components/EllipsisVertical.js.map +1 -0
- package/dist/esm/components/Icon/components/EntriesOnAccount.js +18 -0
- package/dist/esm/components/Icon/components/EntriesOnAccount.js.map +1 -0
- package/dist/esm/components/Icon/components/EntriesOpen.js +18 -0
- package/dist/esm/components/Icon/components/EntriesOpen.js.map +1 -0
- package/dist/esm/components/Icon/components/EntriesWarning.js +18 -0
- package/dist/esm/components/Icon/components/EntriesWarning.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeCustomerInvoice.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeCustomerInvoice.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeCustomerPayment.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeCustomerPayment.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeJournalEntry.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeJournalEntry.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeManualCustomerInvoice.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeManualCustomerInvoice.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeSupplierInvoice.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeSupplierInvoice.js.map +1 -0
- package/dist/esm/components/Icon/components/EntryTypeSupplierPayment.js +18 -0
- package/dist/esm/components/Icon/components/EntryTypeSupplierPayment.js.map +1 -0
- package/dist/esm/components/Icon/components/Envelope.js +18 -0
- package/dist/esm/components/Icon/components/Envelope.js.map +1 -0
- package/dist/esm/components/Icon/components/EnvelopeApproved.js +18 -0
- package/dist/esm/components/Icon/components/EnvelopeApproved.js.map +1 -0
- package/dist/esm/components/Icon/components/ExpandView.js +18 -0
- package/dist/esm/components/Icon/components/ExpandView.js.map +1 -0
- package/dist/esm/components/Icon/components/Expenses.js +18 -0
- package/dist/esm/components/Icon/components/Expenses.js.map +1 -0
- package/dist/esm/components/Icon/components/Export.js +18 -0
- package/dist/esm/components/Icon/components/Export.js.map +1 -0
- package/dist/esm/components/Icon/components/ExportToExcel.js +18 -0
- package/dist/esm/components/Icon/components/ExportToExcel.js.map +1 -0
- package/dist/esm/components/Icon/components/ExportToPdf.js +18 -0
- package/dist/esm/components/Icon/components/ExportToPdf.js.map +1 -0
- package/dist/esm/components/Icon/components/Filter.js +18 -0
- package/dist/esm/components/Icon/components/Filter.js.map +1 -0
- package/dist/esm/components/Icon/components/FilterSolid.js +18 -0
- package/dist/esm/components/Icon/components/FilterSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/GraphSolid.js +18 -0
- package/dist/esm/components/Icon/components/GraphSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Hash.js +18 -0
- package/dist/esm/components/Icon/components/Hash.js.map +1 -0
- package/dist/esm/components/Icon/components/Home.js +18 -0
- package/dist/esm/components/Icon/components/Home.js.map +1 -0
- package/dist/esm/components/Icon/components/Images.js +18 -0
- package/dist/esm/components/Icon/components/Images.js.map +1 -0
- package/dist/esm/components/Icon/components/Import.js +18 -0
- package/dist/esm/components/Icon/components/Import.js.map +1 -0
- package/dist/esm/components/Icon/components/Inbox.js +20 -0
- package/dist/esm/components/Icon/components/Inbox.js.map +1 -0
- package/dist/esm/components/Icon/components/InboxEinvoicing.js +20 -0
- package/dist/esm/components/Icon/components/InboxEinvoicing.js.map +1 -0
- package/dist/esm/components/Icon/components/InboxScanning.js +20 -0
- package/dist/esm/components/Icon/components/InboxScanning.js.map +1 -0
- package/dist/esm/components/Icon/components/InboxSmart.js +20 -0
- package/dist/esm/components/Icon/components/InboxSmart.js.map +1 -0
- package/dist/esm/components/Icon/components/Info.js +18 -0
- package/dist/esm/components/Icon/components/Info.js.map +1 -0
- package/dist/esm/components/Icon/components/Inventory.js +18 -0
- package/dist/esm/components/Icon/components/Inventory.js.map +1 -0
- package/dist/esm/components/Icon/components/InventoryMatrix.js +18 -0
- package/dist/esm/components/Icon/components/InventoryMatrix.js.map +1 -0
- package/dist/esm/components/Icon/components/JournalPro.js +18 -0
- package/dist/esm/components/Icon/components/JournalPro.js.map +1 -0
- package/dist/esm/components/Icon/components/Layout.js +18 -0
- package/dist/esm/components/Icon/components/Layout.js.map +1 -0
- package/dist/esm/components/Icon/components/LayoutBoth.js +18 -0
- package/dist/esm/components/Icon/components/LayoutBoth.js.map +1 -0
- package/dist/esm/components/Icon/components/LayoutFirst.js +18 -0
- package/dist/esm/components/Icon/components/LayoutFirst.js.map +1 -0
- package/dist/esm/components/Icon/components/LayoutLast.js +18 -0
- package/dist/esm/components/Icon/components/LayoutLast.js.map +1 -0
- package/dist/esm/components/Icon/components/LayoutNone.js +18 -0
- package/dist/esm/components/Icon/components/LayoutNone.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCard.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCard.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardCustomerReminder.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardCustomerReminder.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardManualCustomerInvoice.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardManualCustomerInvoice.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardObsoleteStock.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardObsoleteStock.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardOpeningEntry.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardOpeningEntry.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardReservedEntry.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardReservedEntry.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardShrinkagePilferage.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardShrinkagePilferage.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardStockAdjustment.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardStockAdjustment.js.map +1 -0
- package/dist/esm/components/Icon/components/LedgerCardTransferredOpeningEntry.js +18 -0
- package/dist/esm/components/Icon/components/LedgerCardTransferredOpeningEntry.js.map +1 -0
- package/dist/esm/components/Icon/components/Lightbulb.js +18 -0
- package/dist/esm/components/Icon/components/Lightbulb.js.map +1 -0
- package/dist/esm/components/Icon/components/Line.js +18 -0
- package/dist/esm/components/Icon/components/Line.js.map +1 -0
- package/dist/esm/components/Icon/components/List.js +18 -0
- package/dist/esm/components/Icon/components/List.js.map +1 -0
- package/dist/esm/components/Icon/components/ListBulleted.js +18 -0
- package/dist/esm/components/Icon/components/ListBulleted.js.map +1 -0
- package/dist/esm/components/Icon/components/ListSearch.js +18 -0
- package/dist/esm/components/Icon/components/ListSearch.js.map +1 -0
- package/dist/esm/components/Icon/components/LockOpen.js +18 -0
- package/dist/esm/components/Icon/components/LockOpen.js.map +1 -0
- package/dist/esm/components/Icon/components/Log.js +18 -0
- package/dist/esm/components/Icon/components/Log.js.map +1 -0
- package/dist/esm/components/Icon/components/Market.js +18 -0
- package/dist/esm/components/Icon/components/Market.js.map +1 -0
- package/dist/esm/components/Icon/components/MatchAmount.js +18 -0
- package/dist/esm/components/Icon/components/MatchAmount.js.map +1 -0
- package/dist/esm/components/Icon/components/MatchEntries.js +18 -0
- package/dist/esm/components/Icon/components/MatchEntries.js.map +1 -0
- package/dist/esm/components/Icon/components/Mileage.js +18 -0
- package/dist/esm/components/Icon/components/Mileage.js.map +1 -0
- package/dist/esm/components/Icon/components/ModalResize.js +18 -0
- package/dist/esm/components/Icon/components/ModalResize.js.map +1 -0
- package/dist/esm/components/Icon/components/ModalShrink.js +18 -0
- package/dist/esm/components/Icon/components/ModalShrink.js.map +1 -0
- package/dist/esm/components/Icon/components/More.js +18 -0
- package/dist/esm/components/Icon/components/More.js.map +1 -0
- package/dist/esm/components/Icon/components/MoreSolid.js +18 -0
- package/dist/esm/components/Icon/components/MoreSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Move.js +18 -0
- package/dist/esm/components/Icon/components/Move.js.map +1 -0
- package/dist/esm/components/Icon/components/NavigationList.js +18 -0
- package/dist/esm/components/Icon/components/NavigationList.js.map +1 -0
- package/dist/esm/components/Icon/components/Note.js +18 -0
- package/dist/esm/components/Icon/components/Note.js.map +1 -0
- package/dist/esm/components/Icon/components/NoteFollowUp.js +18 -0
- package/dist/esm/components/Icon/components/NoteFollowUp.js.map +1 -0
- package/dist/esm/components/Icon/components/NoteRead.js +18 -0
- package/dist/esm/components/Icon/components/NoteRead.js.map +1 -0
- package/dist/esm/components/Icon/components/PartnerApi.js +18 -0
- package/dist/esm/components/Icon/components/PartnerApi.js.map +1 -0
- package/dist/esm/components/Icon/components/Period.js +18 -0
- package/dist/esm/components/Icon/components/Period.js.map +1 -0
- package/dist/esm/components/Icon/components/PersonChange.js +18 -0
- package/dist/esm/components/Icon/components/PersonChange.js.map +1 -0
- package/dist/esm/components/Icon/components/PersonMinus.js +18 -0
- package/dist/esm/components/Icon/components/PersonMinus.js.map +1 -0
- package/dist/esm/components/Icon/components/PersonPlus.js +18 -0
- package/dist/esm/components/Icon/components/PersonPlus.js.map +1 -0
- package/dist/esm/components/Icon/components/PersonTick.js +18 -0
- package/dist/esm/components/Icon/components/PersonTick.js.map +1 -0
- package/dist/esm/components/Icon/components/Play.js +18 -0
- package/dist/esm/components/Icon/components/Play.js.map +1 -0
- package/dist/esm/components/Icon/components/PlusMinus.js +18 -0
- package/dist/esm/components/Icon/components/PlusMinus.js.map +1 -0
- package/dist/esm/components/Icon/components/Print.js +18 -0
- package/dist/esm/components/Icon/components/Print.js.map +1 -0
- package/dist/esm/components/Icon/components/ProcessPayment.js +18 -0
- package/dist/esm/components/Icon/components/ProcessPayment.js.map +1 -0
- package/dist/esm/components/Icon/components/ProductLedgerCard.js +18 -0
- package/dist/esm/components/Icon/components/ProductLedgerCard.js.map +1 -0
- package/dist/esm/components/Icon/components/ProjectCards.js +18 -0
- package/dist/esm/components/Icon/components/ProjectCards.js.map +1 -0
- package/dist/esm/components/Icon/components/Projects.js +18 -0
- package/dist/esm/components/Icon/components/Projects.js.map +1 -0
- package/dist/esm/components/Icon/components/Quicklinks.js +18 -0
- package/dist/esm/components/Icon/components/Quicklinks.js.map +1 -0
- package/dist/esm/components/Icon/components/RatingBankruptcy.js +18 -0
- package/dist/esm/components/Icon/components/RatingBankruptcy.js.map +1 -0
- package/dist/esm/components/Icon/components/RatingPaymentProblems.js +18 -0
- package/dist/esm/components/Icon/components/RatingPaymentProblems.js.map +1 -0
- package/dist/esm/components/Icon/components/Reconciled.js +18 -0
- package/dist/esm/components/Icon/components/Reconciled.js.map +1 -0
- package/dist/esm/components/Icon/components/Refresh.js +17 -0
- package/dist/esm/components/Icon/components/Refresh.js.map +1 -0
- package/dist/esm/components/Icon/components/Report.js +18 -0
- package/dist/esm/components/Icon/components/Report.js.map +1 -0
- package/dist/esm/components/Icon/components/ReportSolid.js +18 -0
- package/dist/esm/components/Icon/components/ReportSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Restore.js +18 -0
- package/dist/esm/components/Icon/components/Restore.js.map +1 -0
- package/dist/esm/components/Icon/components/RotateLeft.js +17 -0
- package/dist/esm/components/Icon/components/RotateLeft.js.map +1 -0
- package/dist/esm/components/Icon/components/RotateRight.js +17 -0
- package/dist/esm/components/Icon/components/RotateRight.js.map +1 -0
- package/dist/esm/components/Icon/components/Sales.js +18 -0
- package/dist/esm/components/Icon/components/Sales.js.map +1 -0
- package/dist/esm/components/Icon/components/Search.js +18 -0
- package/dist/esm/components/Icon/components/Search.js.map +1 -0
- package/dist/esm/components/Icon/components/SearchBold.js +18 -0
- package/dist/esm/components/Icon/components/SearchBold.js.map +1 -0
- package/dist/esm/components/Icon/components/Secure.js +18 -0
- package/dist/esm/components/Icon/components/Secure.js.map +1 -0
- package/dist/esm/components/Icon/components/SecureTick.js +18 -0
- package/dist/esm/components/Icon/components/SecureTick.js.map +1 -0
- package/dist/esm/components/Icon/components/Settings.js +18 -0
- package/dist/esm/components/Icon/components/Settings.js.map +1 -0
- package/dist/esm/components/Icon/components/SettingsSolid.js +18 -0
- package/dist/esm/components/Icon/components/SettingsSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Shortcuts.js +18 -0
- package/dist/esm/components/Icon/components/Shortcuts.js.map +1 -0
- package/dist/esm/components/Icon/components/ShowAll.js +18 -0
- package/dist/esm/components/Icon/components/ShowAll.js.map +1 -0
- package/dist/esm/components/Icon/components/ShowLess.js +18 -0
- package/dist/esm/components/Icon/components/ShowLess.js.map +1 -0
- package/dist/esm/components/Icon/components/ShowMore.js +18 -0
- package/dist/esm/components/Icon/components/ShowMore.js.map +1 -0
- package/dist/esm/components/Icon/components/ShowTemplate.js +18 -0
- package/dist/esm/components/Icon/components/ShowTemplate.js.map +1 -0
- package/dist/esm/components/Icon/components/Sliders.js +18 -0
- package/dist/esm/components/Icon/components/Sliders.js.map +1 -0
- package/dist/esm/components/Icon/components/Smartpay.js +18 -0
- package/dist/esm/components/Icon/components/Smartpay.js.map +1 -0
- package/dist/esm/components/Icon/components/SortBy.js +18 -0
- package/dist/esm/components/Icon/components/SortBy.js.map +1 -0
- package/dist/esm/components/Icon/components/Spinner.js +21 -0
- package/dist/esm/components/Icon/components/Spinner.js.map +1 -0
- package/dist/esm/components/Icon/components/Star.js +18 -0
- package/dist/esm/components/Icon/components/Star.js.map +1 -0
- package/dist/esm/components/Icon/components/StarSolid.js +18 -0
- package/dist/esm/components/Icon/components/StarSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Subscriptions.js +18 -0
- package/dist/esm/components/Icon/components/Subscriptions.js.map +1 -0
- package/dist/esm/components/Icon/components/SystemEntries.js +18 -0
- package/dist/esm/components/Icon/components/SystemEntries.js.map +1 -0
- package/dist/esm/components/Icon/components/Tag.js +18 -0
- package/dist/esm/components/Icon/components/Tag.js.map +1 -0
- package/dist/esm/components/Icon/components/TemplateOverride.js +18 -0
- package/dist/esm/components/Icon/components/TemplateOverride.js.map +1 -0
- package/dist/esm/components/Icon/components/Templates.js +18 -0
- package/dist/esm/components/Icon/components/Templates.js.map +1 -0
- package/dist/esm/components/Icon/components/ThumbBoth.js +18 -0
- package/dist/esm/components/Icon/components/ThumbBoth.js.map +1 -0
- package/dist/esm/components/Icon/components/ThumbDown.js +18 -0
- package/dist/esm/components/Icon/components/ThumbDown.js.map +1 -0
- package/dist/esm/components/Icon/components/ThumbDownSolid.js +18 -0
- package/dist/esm/components/Icon/components/ThumbDownSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/ThumbUp.js +18 -0
- package/dist/esm/components/Icon/components/ThumbUp.js.map +1 -0
- package/dist/esm/components/Icon/components/ThumbUpSolid.js +18 -0
- package/dist/esm/components/Icon/components/ThumbUpSolid.js.map +1 -0
- package/dist/esm/components/Icon/components/Tick.js +18 -0
- package/dist/esm/components/Icon/components/Tick.js.map +1 -0
- package/dist/esm/components/Icon/components/Time.js +18 -0
- package/dist/esm/components/Icon/components/Time.js.map +1 -0
- package/dist/esm/components/Icon/components/Transfer.js +18 -0
- package/dist/esm/components/Icon/components/Transfer.js.map +1 -0
- package/dist/esm/components/Icon/components/TransferCancel.js +24 -0
- package/dist/esm/components/Icon/components/TransferCancel.js.map +1 -0
- package/dist/esm/components/Icon/components/TransferLocked.js +18 -0
- package/dist/esm/components/Icon/components/TransferLocked.js.map +1 -0
- package/dist/esm/components/Icon/components/Undock.js +18 -0
- package/dist/esm/components/Icon/components/Undock.js.map +1 -0
- package/dist/esm/components/Icon/components/Unreconciled.js +18 -0
- package/dist/esm/components/Icon/components/Unreconciled.js.map +1 -0
- package/dist/esm/components/Icon/components/Warning.js +17 -0
- package/dist/esm/components/Icon/components/Warning.js.map +1 -0
- package/dist/esm/components/Icon/components/Webshop.js +18 -0
- package/dist/esm/components/Icon/components/Webshop.js.map +1 -0
- package/dist/esm/components/Icon/components/Website.js +18 -0
- package/dist/esm/components/Icon/components/Website.js.map +1 -0
- package/dist/esm/components/Icon/components/Workflow.js +17 -0
- package/dist/esm/components/Icon/components/Workflow.js.map +1 -0
- package/dist/esm/components/Icon/components/Zoom.js +18 -0
- package/dist/esm/components/Icon/components/Zoom.js.map +1 -0
- package/dist/esm/components/Icon/components/index.js +414 -0
- package/dist/esm/components/Icon/components/index.js.map +1 -0
- package/dist/esm/components/IconButton/IconButton.js +35 -0
- package/dist/esm/components/IconButton/IconButton.js.map +1 -0
- package/dist/esm/components/Input/Input.js +85 -0
- package/dist/esm/components/Input/Input.js.map +1 -0
- package/dist/esm/components/Input/util.js +22 -0
- package/dist/esm/components/Input/util.js.map +1 -0
- package/dist/esm/components/Listbox/Listbox.js +58 -0
- package/dist/esm/components/Listbox/Listbox.js.map +1 -0
- package/dist/esm/components/Listbox/ScrollableList.js +174 -0
- package/dist/esm/components/Listbox/ScrollableList.js.map +1 -0
- package/dist/esm/components/Listbox/useListbox.js +145 -0
- package/dist/esm/components/Listbox/useListbox.js.map +1 -0
- package/dist/esm/components/Listbox/useMultiListbox.js +196 -0
- package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -0
- package/dist/esm/components/Listbox/useTypeahead.js +28 -0
- package/dist/esm/components/Listbox/useTypeahead.js.map +1 -0
- package/dist/esm/components/Listbox/util.js +150 -0
- package/dist/esm/components/Listbox/util.js.map +1 -0
- package/dist/esm/components/Menu/Context.js +9 -0
- package/dist/esm/components/Menu/Context.js.map +1 -0
- package/dist/esm/components/Menu/Menu.js +74 -0
- package/dist/esm/components/Menu/Menu.js.map +1 -0
- package/dist/esm/components/Menu/components/Checkbox.js +31 -0
- package/dist/esm/components/Menu/components/Checkbox.js.map +1 -0
- package/dist/esm/components/Menu/components/Content.js +50 -0
- package/dist/esm/components/Menu/components/Content.js.map +1 -0
- package/dist/esm/components/Menu/components/Header.js +38 -0
- package/dist/esm/components/Menu/components/Header.js.map +1 -0
- package/dist/esm/components/Menu/components/Item.js +140 -0
- package/dist/esm/components/Menu/components/Item.js.map +1 -0
- package/dist/esm/components/Menu/components/Link.js +39 -0
- package/dist/esm/components/Menu/components/Link.js.map +1 -0
- package/dist/esm/components/Menu/components/RadioGroup.js +48 -0
- package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -0
- package/dist/esm/components/Menu/components/Separator.js +35 -0
- package/dist/esm/components/Menu/components/Separator.js.map +1 -0
- package/dist/esm/components/Menu/components/Trigger.js +33 -0
- package/dist/esm/components/Menu/components/Trigger.js.map +1 -0
- package/dist/esm/components/Navigation/Navigation.js +125 -0
- package/dist/esm/components/Navigation/Navigation.js.map +1 -0
- package/dist/esm/components/Pagination/PageNumbers.js +50 -0
- package/dist/esm/components/Pagination/PageNumbers.js.map +1 -0
- package/dist/esm/components/Pagination/Pagination.js +103 -0
- package/dist/esm/components/Pagination/Pagination.js.map +1 -0
- package/dist/esm/components/Pagination/usePagination.js +15 -0
- package/dist/esm/components/Pagination/usePagination.js.map +1 -0
- package/dist/esm/components/Pagination/usePaginationShortcuts.js +50 -0
- package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -0
- package/dist/esm/components/Popover/Popover.js +84 -0
- package/dist/esm/components/Popover/Popover.js.map +1 -0
- package/dist/esm/components/Popover/Primitives.js +41 -0
- package/dist/esm/components/Popover/Primitives.js.map +1 -0
- package/dist/esm/components/Progress/Progress.js +32 -0
- package/dist/esm/components/Progress/Progress.js.map +1 -0
- package/dist/esm/components/Provider/Provider.js +105 -0
- package/dist/esm/components/Provider/Provider.js.map +1 -0
- package/dist/esm/components/RadioGroup/RadioGroup.js +106 -0
- package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/esm/components/SearchInput/SearchInput.js +95 -0
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -0
- package/dist/esm/components/Select/Select.js +100 -0
- package/dist/esm/components/Select/Select.js.map +1 -0
- package/dist/esm/components/Select/useSelect.js +212 -0
- package/dist/esm/components/Select/useSelect.js.map +1 -0
- package/dist/esm/components/Spinner/Spinner.js +48 -0
- package/dist/esm/components/Spinner/Spinner.js.map +1 -0
- package/dist/esm/components/Switch/Switch.js +37 -0
- package/dist/esm/components/Switch/Switch.js.map +1 -0
- package/dist/esm/components/Table/components/BaseTable.js +48 -0
- package/dist/esm/components/Table/components/BaseTable.js.map +1 -0
- package/dist/esm/components/Table/components/PaginatedTable.js +16 -0
- package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -0
- package/dist/esm/components/Table/components/Table.js +56 -0
- package/dist/esm/components/Table/components/Table.js.map +1 -0
- package/dist/esm/components/Table/components/WindowedTable.js +186 -0
- package/dist/esm/components/Table/components/WindowedTable.js.map +1 -0
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js +236 -0
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -0
- package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js +129 -0
- package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -0
- package/dist/esm/components/Table/hooks/plugins/useRowEditing.js +100 -0
- package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -0
- package/dist/esm/components/Table/hooks/plugins/useRowSelect.js +108 -0
- package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -0
- package/dist/esm/components/Table/hooks/useRowCreation.js +106 -0
- package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -0
- package/dist/esm/components/Table/hooks/useTable.js +217 -0
- package/dist/esm/components/Table/hooks/useTable.js.map +1 -0
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +132 -0
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -0
- package/dist/esm/components/Table/util/renderColumn.js +40 -0
- package/dist/esm/components/Table/util/renderColumn.js.map +1 -0
- package/dist/esm/components/Table/util/renderRow.js +101 -0
- package/dist/esm/components/Table/util/renderRow.js.map +1 -0
- package/dist/esm/components/Table/util/rowIndexPath.js +57 -0
- package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -0
- package/dist/esm/components/Table/util/sortTypes.js +82 -0
- package/dist/esm/components/Table/util/sortTypes.js.map +1 -0
- package/dist/esm/components/Table/util.js +99 -0
- package/dist/esm/components/Table/util.js.map +1 -0
- package/dist/esm/components/Tabs/Tabs.js +69 -0
- package/dist/esm/components/Tabs/Tabs.js.map +1 -0
- package/dist/esm/components/Textarea/Textarea.js +39 -0
- package/dist/esm/components/Textarea/Textarea.js.map +1 -0
- package/dist/esm/components/Toast/Toast.js +79 -0
- package/dist/esm/components/Toast/Toast.js.map +1 -0
- package/dist/esm/components/Toast/Toaster.js +163 -0
- package/dist/esm/components/Toast/Toaster.js.map +1 -0
- package/dist/esm/components/Toast/util.js +46 -0
- package/dist/esm/components/Toast/util.js.map +1 -0
- package/dist/esm/components/Tooltip/Tooltip.js +32 -0
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/esm/components/Tour/Tour.js +142 -0
- package/dist/esm/components/Tour/Tour.js.map +1 -0
- package/dist/esm/components/Treeview/Treeview.js +73 -0
- package/dist/esm/components/Treeview/Treeview.js.map +1 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +11 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/esm/index.css +661 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/primitives/Button.js +21 -0
- package/dist/esm/primitives/Button.js.map +1 -0
- package/dist/esm/utils/date.js +98 -0
- package/dist/esm/utils/date.js.map +1 -0
- package/dist/esm/utils/hooks/useBoundingClientRectListener.js +50 -0
- package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -0
- package/dist/esm/utils/hooks/useDraggable.js +42 -0
- package/dist/esm/utils/hooks/useDraggable.js.map +1 -0
- package/dist/esm/utils/hooks/useDropTarget.js +38 -0
- package/dist/esm/utils/hooks/useDropTarget.js.map +1 -0
- package/dist/esm/utils/hooks/useListKeyboardNavigation.js +58 -0
- package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -0
- package/dist/esm/utils/hooks/useListScrollTo.js +38 -0
- package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js +27 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -0
- package/dist/esm/utils/hooks/useProxiedRef.js +18 -0
- package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -0
- package/dist/esm/utils/hooks/useTimer.js +50 -0
- package/dist/esm/utils/hooks/useTimer.js.map +1 -0
- package/dist/esm/utils/input.js +49 -0
- package/dist/esm/utils/input.js.map +1 -0
- package/dist/esm/utils/mergeRefs.js +14 -0
- package/dist/esm/utils/mergeRefs.js.map +1 -0
- package/dist/esm/utils/taillwind.js +41 -0
- package/dist/esm/utils/taillwind.js.map +1 -0
- package/dist/taco.cjs.development.js +458 -552
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +2 -0
- package/dist/taco.cjs.production.min.js.map +1 -0
- package/package.json +2 -2
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRowActions.js","sources":["../../../../../../src/components/Table/hooks/plugins/useRowActions.tsx"],"sourcesContent":["import React from 'react';\r\nimport { PluginHook } from 'react-table';\r\nimport { InView } from 'react-intersection-observer';\r\nimport keycode from 'keycode';\r\nimport { sanitizeRowProps } from '../../util';\r\nimport { IconButton } from '../../../IconButton/IconButton';\r\nimport { LocalizationTexts } from '../../../Provider/Provider';\r\nimport { Menu } from '../../../Menu/Menu';\r\nimport { RowAction, RowActionHandler, TableRow } from '../../types';\r\n\r\nconst actionGroupClassName = '-mt-1 -mb-1 h-8 flex';\r\n\r\nconst hasActions = (inlineEditingUniqueId: any, handlers: any, actions: RowActionHandler<any>[] | undefined): number => {\r\n return (\r\n !!actions ||\r\n handlers.onRowCreate ||\r\n handlers.onRowCopy ||\r\n handlers.onRowDelete ||\r\n !!inlineEditingUniqueId ||\r\n handlers.onRowEdit\r\n );\r\n};\r\n\r\nconst getActions = (\r\n actions: RowActionHandler<any>[] | undefined,\r\n row: TableRow<any> | undefined = undefined\r\n): [RowAction<any>[], RowAction<any>[]] => {\r\n const primary: RowAction<any>[] = [];\r\n const secondary: RowAction<any>[] = [];\r\n\r\n if (actions) {\r\n let visibleActions = actions.filter(x => !!x);\r\n\r\n if (row) {\r\n visibleActions = visibleActions.filter((action: RowAction<any>) => {\r\n if (action.visible !== undefined) {\r\n if (typeof action.visible === 'function') {\r\n return action.visible(row);\r\n }\r\n\r\n return action.visible;\r\n }\r\n\r\n return true;\r\n });\r\n }\r\n\r\n visibleActions.forEach((action: RowAction<any>) => {\r\n if (action.showOnRow) {\r\n primary.push(action);\r\n } else {\r\n secondary.push(action);\r\n }\r\n });\r\n }\r\n\r\n return [primary, secondary];\r\n};\r\n\r\nconst getLength = (inlineEditingUniqueId: any, handlers: any, actions: RowActionHandler<any>[] | undefined): number => {\r\n const [primaryActions, secondaryActions] = getActions(actions);\r\n\r\n let length = primaryActions.length + (secondaryActions.length ? 1 : 0);\r\n\r\n if (handlers.onRowCreate) {\r\n length++;\r\n }\r\n\r\n if (handlers.onRowCopy) {\r\n length++;\r\n }\r\n\r\n if (handlers.onRowDelete) {\r\n length++;\r\n }\r\n\r\n if (!!inlineEditingUniqueId || handlers.onRowEdit) {\r\n length++;\r\n\r\n if (length < 2) {\r\n length++;\r\n }\r\n }\r\n\r\n return length;\r\n};\r\n\r\nconst getActionProps = (action: RowAction<any>, row: TableRow<any>) => {\r\n return {\r\n 'aria-label': typeof action.tooltip === 'function' ? action.tooltip(row) : action.tooltip,\r\n disabled: typeof action.disabled === 'function' ? action.disabled(row) : action.disabled,\r\n onClick: (event: React.MouseEvent<HTMLElement>) => {\r\n action.onClick(row, event);\r\n },\r\n };\r\n};\r\n\r\nconst EditModeActions = () => {\r\n React.useEffect(() => {\r\n const listener = (event: any) => {\r\n if (event.keyCode === keycode('escape') && event.target?.form?.reset) {\r\n event.preventDefault();\r\n event.target.form.reset();\r\n }\r\n };\r\n\r\n document.addEventListener('keydown', listener);\r\n\r\n return () => {\r\n document.removeEventListener('keydown', listener);\r\n };\r\n }, []);\r\n\r\n return (\r\n <div className={actionGroupClassName}>\r\n <IconButton appearance=\"primary\" icon=\"tick\" type=\"submit\" className=\"mr-2\" />\r\n <IconButton appearance=\"ghost\" icon=\"close\" type=\"reset\" />\r\n </div>\r\n );\r\n};\r\n\r\nexport const useRowActions = <T extends {}>(\r\n inlineEditingUniqueId: keyof T | undefined,\r\n handlers: any,\r\n actions: RowActionHandler<T>[] | undefined,\r\n rowExpansionRenderer: any,\r\n texts: LocalizationTexts,\r\n windowed = false\r\n): PluginHook<{}> => {\r\n const inlineEditing = !!inlineEditingUniqueId;\r\n const actionsLength = getLength(inlineEditingUniqueId, handlers, actions);\r\n\r\n const plugin = (hooks: any): void => {\r\n if (hasActions(inlineEditingUniqueId, handlers, actions)) {\r\n hooks.visibleColumns.push((columns: any) => [\r\n ...columns,\r\n {\r\n id: '_actions',\r\n className: 'flex justify-end px-1 overflow-visible',\r\n flex: `0 0 calc((${actionsLength} * 2rem) + .5rem)`,\r\n Cell: ({ row }: any) => {\r\n if (row.isEditing) {\r\n return <EditModeActions />;\r\n }\r\n\r\n const sanitizedRow = sanitizeRowProps(row, rowExpansionRenderer);\r\n const [primaryActions, secondaryActions] = getActions(actions, sanitizedRow);\r\n\r\n const output = (\r\n <>\r\n {handlers.onRowCreate && (\r\n <IconButton\r\n appearance=\"discrete\"\r\n icon=\"circle-plus\"\r\n aria-label={texts.table.newSubRow}\r\n tooltip={texts.table.newSubRow}\r\n disabled={inlineEditing && !row.canEdit}\r\n onClick={(event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n event.persist();\r\n row.setActive();\r\n\r\n if (!row.isExpanded) {\r\n row.toggleRowExpanded();\r\n }\r\n\r\n handlers.onRowCreate(sanitizedRow, event);\r\n }}\r\n />\r\n )}\r\n {(inlineEditing || handlers.onRowEdit) && (\r\n <IconButton\r\n appearance=\"discrete\"\r\n icon=\"edit\"\r\n aria-label={texts.table.edit}\r\n tooltip={texts.table.edit}\r\n disabled={inlineEditing && !row.canEdit}\r\n onClick={(event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n row.setActive();\r\n\r\n if (inlineEditing) {\r\n row.toggleRowEditing();\r\n } else if (handlers.onRowEdit) {\r\n event.persist();\r\n handlers.onRowEdit(sanitizedRow, event);\r\n }\r\n }}\r\n />\r\n )}\r\n {handlers.onRowCopy && (\r\n <IconButton\r\n appearance=\"discrete\"\r\n icon=\"copy\"\r\n aria-label={texts.table.copy}\r\n tooltip={texts.table.copy}\r\n disabled={inlineEditing && !row.canEdit}\r\n onClick={(event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n event.persist();\r\n row.setActive();\r\n handlers.onRowCopy(sanitizedRow, event);\r\n }}\r\n />\r\n )}\r\n {handlers.onRowDelete && (\r\n <IconButton\r\n appearance=\"discrete\"\r\n icon=\"delete\"\r\n aria-label={texts.table.del}\r\n tooltip={texts.table.del}\r\n disabled={inlineEditing && !row.canEdit}\r\n onClick={(event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n event.persist();\r\n row.setActive();\r\n handlers.onRowDelete(sanitizedRow, event);\r\n }}\r\n />\r\n )}\r\n {primaryActions.map((action: RowAction<T>, index: number) => (\r\n <IconButton\r\n {...getActionProps(action, sanitizedRow)}\r\n key={index}\r\n appearance=\"discrete\"\r\n icon={typeof action.icon === 'function' ? action.icon(sanitizedRow) : action.icon}\r\n tooltip={\r\n typeof action.tooltip === 'function' ? action.tooltip(sanitizedRow) : action.tooltip\r\n }\r\n />\r\n ))}\r\n {secondaryActions.length ? (\r\n <Menu>\r\n <Menu.Trigger>\r\n <IconButton\r\n appearance=\"discrete\"\r\n icon=\"ellipsis-vertical\"\r\n aria-label={texts.table.actions}\r\n tooltip={texts.table.actions}\r\n disabled={inlineEditing && !row.canEdit}\r\n onClick={(event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n row.setActive();\r\n }}\r\n />\r\n </Menu.Trigger>\r\n <Menu.Content>\r\n {secondaryActions.map((action: RowAction<T>, index: number) => (\r\n <Menu.Item\r\n key={index}\r\n icon={\r\n typeof action.icon === 'function'\r\n ? action.icon(sanitizedRow)\r\n : action.icon\r\n }\r\n {...getActionProps(action, sanitizedRow)}\r\n >\r\n {typeof action.text === 'function' ? action.text(sanitizedRow) : action.text}\r\n </Menu.Item>\r\n ))}\r\n </Menu.Content>\r\n </Menu>\r\n ) : null}\r\n </>\r\n );\r\n\r\n if (windowed) {\r\n return <div className={actionGroupClassName}>{output}</div>;\r\n }\r\n\r\n return (\r\n <InView rootMargin=\"100px 0px\">\r\n {({ inView, ref }) => (\r\n <div className={actionGroupClassName} ref={ref}>\r\n {inView ? output : null}\r\n </div>\r\n )}\r\n </InView>\r\n );\r\n },\r\n },\r\n ]);\r\n }\r\n };\r\n plugin.pluginName = 'useRowActions';\r\n return plugin;\r\n};\r\n"],"names":["actionGroupClassName","hasActions","inlineEditingUniqueId","handlers","actions","onRowCreate","onRowCopy","onRowDelete","onRowEdit","getActions","row","undefined","primary","secondary","visibleActions","filter","x","action","visible","forEach","showOnRow","push","getLength","primaryActions","secondaryActions","length","getActionProps","tooltip","disabled","onClick","event","EditModeActions","React","useEffect","listener","keyCode","keycode","target","form","reset","preventDefault","document","addEventListener","removeEventListener","className","IconButton","appearance","icon","type","useRowActions","rowExpansionRenderer","texts","windowed","inlineEditing","actionsLength","plugin","hooks","visibleColumns","columns","id","flex","Cell","isEditing","sanitizedRow","sanitizeRowProps","output","table","newSubRow","canEdit","stopPropagation","persist","setActive","isExpanded","toggleRowExpanded","edit","toggleRowEditing","copy","del","map","index","key","Menu","Trigger","Content","Item","text","InView","rootMargin","inView","ref","pluginName"],"mappings":";;;;;;;AAUA,MAAMA,oBAAoB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d,KAAuB,UAAvB,GACM9B,MAAM,CAAC8B,IAAP,CAAYgB,YAAZ,CADN,GAEM9C,MAAM,CAAC8B;aAEbrB,cAAc,CAACT,MAAD,EAAS8C,YAAT,EAPtB,EASK,OAAO9C,MAAM,CAACoE,IAAd,KAAuB,UAAvB,GAAoCpE,MAAM,CAACoE,IAAP,CAAYtB,YAAZ,CAApC,GAAgE9C,MAAM,CAACoE,IAT5E,CADH,CADL,CAdJ,CADH,GA+BG,IAjHR,CADJ;;AAsHA,cAAIjC,QAAJ,EAAc;AACV,mBAAOpB,4BAAA,MAAA;AAAKY,cAAAA,SAAS,EAAE5C;aAAhB,EAAuCiE,MAAvC,CAAP;AACH;;AAED,iBACIjC,4BAAA,CAACsD,MAAD;AAAQC,YAAAA,UAAU,EAAC;WAAnB,EACK,CAAC;AAAEC,YAAAA,MAAF;AAAUC,YAAAA;AAAV,WAAD,KACGzD,4BAAA,MAAA;AAAKY,YAAAA,SAAS,EAAE5C;AAAsByF,YAAAA,GAAG,EAAEA;WAA3C,EACKD,MAAM,GAAGvB,MAAH,GAAY,IADvB,CAFR,CADJ;AASH;AA/IL,OAFwC,CAA5C;AAoJH;AACJ,GAvJD;;AAwJAV,EAAAA,MAAM,CAACmC,UAAP,GAAoB,eAApB;AACA,SAAOnC,MAAP;AACH;;;;"}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { Icon } from '../../../Icon/Icon.js';
|
3
|
+
import { actions } from 'react-table';
|
4
|
+
import { sanitizeRowProps } from '../../util.js';
|
5
|
+
|
6
|
+
const pluginName = 'useRowDraggable';
|
7
|
+
actions.resetRowDragging = 'resetRowDragging';
|
8
|
+
actions.toggleRowDragging = 'toggleRowDragging';
|
9
|
+
|
10
|
+
function reducer(state, action) {
|
11
|
+
if (action.type === actions.init) {
|
12
|
+
return {
|
13
|
+
draggingRowIndexPath: null,
|
14
|
+
...state
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
if (action.type === actions.resetRowDragging) {
|
19
|
+
return { ...state,
|
20
|
+
draggingRowIndexPath: null
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
if (action.type === actions.toggleRowDragging) {
|
25
|
+
const {
|
26
|
+
indexPath
|
27
|
+
} = action;
|
28
|
+
return { ...state,
|
29
|
+
draggingRowIndexPath: indexPath
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
return state;
|
34
|
+
}
|
35
|
+
|
36
|
+
const prepareRow = (row, {
|
37
|
+
instance
|
38
|
+
}) => {
|
39
|
+
row.toggleRowDragging = () => {
|
40
|
+
if (instance.state.draggingRowIndexPath === row.id) {
|
41
|
+
instance.dispatch({
|
42
|
+
type: actions.resetRowDragging
|
43
|
+
});
|
44
|
+
} else {
|
45
|
+
instance.dispatch({
|
46
|
+
type: actions.toggleRowDragging,
|
47
|
+
indexPath: row.id
|
48
|
+
});
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
if (instance.state.draggingRowIndexPath) {
|
53
|
+
var _instance$state$selec;
|
54
|
+
|
55
|
+
row.isDragging = instance.state.draggingRowIndexPath === row.id || !!((_instance$state$selec = instance.state.selectedRowIds) !== null && _instance$state$selec !== void 0 && _instance$state$selec[row.id]);
|
56
|
+
} else {
|
57
|
+
row.isDragging = false;
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
const visibleColumns = columns => {
|
62
|
+
return [{
|
63
|
+
id: 'draggable',
|
64
|
+
className: 'yt-table__cell--draggable flex-col px-0',
|
65
|
+
Cell: () => React__default.createElement(Icon, {
|
66
|
+
name: "drag",
|
67
|
+
className: "text-grey-darkest invisible w-[20px] cursor-grab"
|
68
|
+
}),
|
69
|
+
flex: '0 0 20px'
|
70
|
+
}, ...columns];
|
71
|
+
};
|
72
|
+
|
73
|
+
const getRowProps = onRowDrag => (props, {
|
74
|
+
instance,
|
75
|
+
row
|
76
|
+
}) => {
|
77
|
+
const onDragStart = event => {
|
78
|
+
event.persist();
|
79
|
+
row.toggleRowDragging();
|
80
|
+
const indexPaths = [row.id, ...Object.keys(instance.state.selectedRowIds)];
|
81
|
+
const data = instance.rows.filter(r => indexPaths.includes(r.id)).map(sanitizeRowProps);
|
82
|
+
|
83
|
+
const showPlaceholder = placeholder => {
|
84
|
+
const element = window.document.createElement('div');
|
85
|
+
element.id = 'yt-table__drag__placeholder';
|
86
|
+
element.innerText = placeholder;
|
87
|
+
window.document.body.appendChild(element);
|
88
|
+
|
89
|
+
if (typeof DataTransfer.prototype.setDragImage === 'function') {
|
90
|
+
event.dataTransfer.setDragImage(element, 0, 20);
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
onRowDrag(data, showPlaceholder, event);
|
95
|
+
};
|
96
|
+
|
97
|
+
const onDragEnd = () => {
|
98
|
+
const element = document.getElementById('yt-table__drag__placeholder');
|
99
|
+
|
100
|
+
if (element && element.parentNode) {
|
101
|
+
element.parentNode.removeChild(element);
|
102
|
+
}
|
103
|
+
|
104
|
+
row.toggleRowDragging();
|
105
|
+
};
|
106
|
+
|
107
|
+
return [props, {
|
108
|
+
draggable: true,
|
109
|
+
onDragStart,
|
110
|
+
onDragEnd
|
111
|
+
}];
|
112
|
+
};
|
113
|
+
|
114
|
+
const useRowDraggable = onRowDrag => {
|
115
|
+
const plugin = hooks => {
|
116
|
+
if (onRowDrag) {
|
117
|
+
hooks.stateReducers.push(reducer);
|
118
|
+
hooks.prepareRow.push(prepareRow);
|
119
|
+
hooks.visibleColumns.push(visibleColumns);
|
120
|
+
hooks.getRowProps.push(getRowProps(onRowDrag));
|
121
|
+
}
|
122
|
+
};
|
123
|
+
|
124
|
+
plugin.pluginName = pluginName;
|
125
|
+
return plugin;
|
126
|
+
};
|
127
|
+
|
128
|
+
export { useRowDraggable };
|
129
|
+
//# sourceMappingURL=useRowDraggable.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRowDraggable.js","sources":["../../../../../../src/components/Table/hooks/plugins/useRowDraggable.tsx"],"sourcesContent":["import React from 'react';\r\nimport { actions, PluginHook } from 'react-table';\r\nimport { Icon } from '../../../Icon/Icon';\r\nimport { RowDragHandler } from '../../types';\r\nimport { sanitizeRowProps } from '../../util';\r\n\r\nconst pluginName = 'useRowDraggable';\r\n\r\nactions.resetRowDragging = 'resetRowDragging';\r\nactions.toggleRowDragging = 'toggleRowDragging';\r\n\r\nfunction reducer(state: any, action: any): object {\r\n if (action.type === actions.init) {\r\n return {\r\n draggingRowIndexPath: null,\r\n ...state,\r\n };\r\n }\r\n\r\n if (action.type === actions.resetRowDragging) {\r\n return {\r\n ...state,\r\n draggingRowIndexPath: null,\r\n };\r\n }\r\n\r\n if (action.type === actions.toggleRowDragging) {\r\n const { indexPath } = action;\r\n return {\r\n ...state,\r\n draggingRowIndexPath: indexPath,\r\n };\r\n }\r\n\r\n return state;\r\n}\r\n\r\nconst prepareRow = (row: any, { instance }: any): void => {\r\n row.toggleRowDragging = () => {\r\n if (instance.state.draggingRowIndexPath === row.id) {\r\n instance.dispatch({ type: actions.resetRowDragging });\r\n } else {\r\n instance.dispatch({ type: actions.toggleRowDragging, indexPath: row.id });\r\n }\r\n };\r\n\r\n if (instance.state.draggingRowIndexPath) {\r\n row.isDragging = instance.state.draggingRowIndexPath === row.id || !!instance.state.selectedRowIds?.[row.id];\r\n } else {\r\n row.isDragging = false;\r\n }\r\n};\r\n\r\nconst visibleColumns = (columns: any) => {\r\n return [\r\n {\r\n id: 'draggable',\r\n className: 'yt-table__cell--draggable flex-col px-0',\r\n Cell: () => <Icon name=\"drag\" className=\"text-grey-darkest invisible w-[20px] cursor-grab\" />,\r\n flex: '0 0 20px',\r\n },\r\n ...columns,\r\n ];\r\n};\r\n\r\nconst getRowProps =\r\n (onRowDrag: RowDragHandler<any>) =>\r\n (props: any, { instance, row }: any) => {\r\n const onDragStart = (event: React.DragEvent): void => {\r\n event.persist();\r\n row.toggleRowDragging();\r\n\r\n const indexPaths = [row.id, ...Object.keys(instance.state.selectedRowIds)];\r\n const data = instance.rows.filter((r: any) => indexPaths.includes(r.id)).map(sanitizeRowProps);\r\n\r\n const showPlaceholder = (placeholder: string) => {\r\n const element = window.document.createElement('div');\r\n element.id = 'yt-table__drag__placeholder';\r\n element.innerText = placeholder;\r\n window.document.body.appendChild(element);\r\n\r\n if (typeof DataTransfer.prototype.setDragImage === 'function') {\r\n event.dataTransfer.setDragImage(element, 0, 20);\r\n }\r\n };\r\n\r\n onRowDrag(data, showPlaceholder, event);\r\n };\r\n\r\n const onDragEnd = (): void => {\r\n const element: HTMLElement | null = document.getElementById('yt-table__drag__placeholder');\r\n\r\n if (element && element.parentNode) {\r\n element.parentNode.removeChild(element);\r\n }\r\n\r\n row.toggleRowDragging();\r\n };\r\n\r\n return [\r\n props,\r\n {\r\n draggable: true,\r\n onDragStart,\r\n onDragEnd,\r\n },\r\n ];\r\n };\r\n\r\nexport const useRowDraggable = (onRowDrag: RowDragHandler<any> | undefined): PluginHook<{}> => {\r\n const plugin = (hooks: any): void => {\r\n if (onRowDrag) {\r\n hooks.stateReducers.push(reducer);\r\n hooks.prepareRow.push(prepareRow);\r\n hooks.visibleColumns.push(visibleColumns);\r\n hooks.getRowProps.push(getRowProps(onRowDrag));\r\n }\r\n };\r\n plugin.pluginName = pluginName;\r\n\r\n return plugin;\r\n};\r\n"],"names":["pluginName","actions","resetRowDragging","toggleRowDragging","reducer","state","action","type","init","draggingRowIndexPath","indexPath","prepareRow","row","instance","id","dispatch","isDragging","selectedRowIds","visibleColumns","columns","className","Cell","React","Icon","name","flex","getRowProps","onRowDrag","props","onDragStart","event","persist","indexPaths","Object","keys","data","rows","filter","r","includes","map","sanitizeRowProps","showPlaceholder","placeholder","element","window","document","createElement","innerText","body","appendChild","DataTransfer","prototype","setDragImage","dataTransfer","onDragEnd","getElementById","parentNode","removeChild","draggable","useRowDraggable","plugin","hooks","stateReducers","push"],"mappings":";;;;;AAMA,MAAMA,UAAU,GAAG,iBAAnB;AAEAC,OAAO,CAACC,gBAAR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@@ -0,0 +1,100 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { actions } from 'react-table';
|
3
|
+
|
4
|
+
const pluginName = 'useRowEditing';
|
5
|
+
actions.resetRowEditing = 'resetRowEditing';
|
6
|
+
actions.toggleRowEditing = 'toggleRowEditing';
|
7
|
+
actions.toggleEditing = 'toggleEditing';
|
8
|
+
|
9
|
+
function reducer(state, action) {
|
10
|
+
if (action.type === actions.init) {
|
11
|
+
return {
|
12
|
+
allowEditing: true,
|
13
|
+
editingRowUniqueId: null,
|
14
|
+
...state
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
if (action.type === actions.resetRowEditing || action.type === actions.resetPage || action.type === actions.gotoPage) {
|
19
|
+
return { ...state,
|
20
|
+
editingRowUniqueId: null
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
if (action.type === actions.toggleRowEditing) {
|
25
|
+
const {
|
26
|
+
id
|
27
|
+
} = action;
|
28
|
+
return { ...state,
|
29
|
+
editingRowUniqueId: id
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
if (action.type === actions.toggleEditing) {
|
34
|
+
return { ...state,
|
35
|
+
allowEditing: !state.allowEditing
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
return state;
|
40
|
+
}
|
41
|
+
|
42
|
+
function useInstance(instance) {
|
43
|
+
const {
|
44
|
+
dispatch
|
45
|
+
} = instance;
|
46
|
+
const resetRowEditing = React__default.useCallback(() => {
|
47
|
+
dispatch({
|
48
|
+
type: actions.resetRowEditing
|
49
|
+
});
|
50
|
+
}, [dispatch]);
|
51
|
+
const toggleRowEditing = React__default.useCallback(id => {
|
52
|
+
dispatch({
|
53
|
+
type: actions.toggleRowEditing,
|
54
|
+
id
|
55
|
+
});
|
56
|
+
}, [dispatch]);
|
57
|
+
const toggleEditing = React__default.useCallback(() => {
|
58
|
+
dispatch({
|
59
|
+
type: actions.toggleEditing
|
60
|
+
});
|
61
|
+
}, [dispatch]);
|
62
|
+
Object.assign(instance, {
|
63
|
+
resetRowEditing,
|
64
|
+
toggleRowEditing,
|
65
|
+
toggleEditing
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
const prepareRow = uniqueId => (row, {
|
70
|
+
instance
|
71
|
+
}) => {
|
72
|
+
const id = row.original[uniqueId];
|
73
|
+
|
74
|
+
row.toggleRowEditing = () => {
|
75
|
+
if (instance.state.editingRowUniqueId === id) {
|
76
|
+
instance.resetRowEditing();
|
77
|
+
} else {
|
78
|
+
instance.toggleRowEditing(id);
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
row.isEditing = row.original._createKey ? instance.state.editingRowUniqueId === row.original._createKey : instance.state.editingRowUniqueId === id;
|
83
|
+
row.canEdit = instance.state.allowEditing && (row.isEditing || !instance.state.editingRowUniqueId);
|
84
|
+
};
|
85
|
+
|
86
|
+
const useRowEditing = uniqueId => {
|
87
|
+
const plugin = hooks => {
|
88
|
+
if (uniqueId) {
|
89
|
+
hooks.stateReducers.push(reducer);
|
90
|
+
hooks.useInstance.push(useInstance);
|
91
|
+
hooks.prepareRow.push(prepareRow(uniqueId));
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
plugin.pluginName = pluginName;
|
96
|
+
return plugin;
|
97
|
+
};
|
98
|
+
|
99
|
+
export { useRowEditing };
|
100
|
+
//# sourceMappingURL=useRowEditing.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRowEditing.js","sources":["../../../../../../src/components/Table/hooks/plugins/useRowEditing.tsx"],"sourcesContent":["import React from 'react';\r\nimport { actions, PluginHook } from 'react-table';\r\n\r\nconst pluginName = 'useRowEditing';\r\n\r\nactions.resetRowEditing = 'resetRowEditing';\r\nactions.toggleRowEditing = 'toggleRowEditing';\r\nactions.toggleEditing = 'toggleEditing';\r\n\r\nfunction reducer(state: any, action: any): object {\r\n if (action.type === actions.init) {\r\n return {\r\n allowEditing: true,\r\n editingRowUniqueId: null,\r\n ...state,\r\n };\r\n }\r\n\r\n if (action.type === actions.resetRowEditing || action.type === actions.resetPage || action.type === actions.gotoPage) {\r\n return {\r\n ...state,\r\n editingRowUniqueId: null,\r\n };\r\n }\r\n\r\n if (action.type === actions.toggleRowEditing) {\r\n const { id } = action;\r\n return {\r\n ...state,\r\n editingRowUniqueId: id,\r\n };\r\n }\r\n\r\n if (action.type === actions.toggleEditing) {\r\n return {\r\n ...state,\r\n allowEditing: !state.allowEditing,\r\n };\r\n }\r\n\r\n return state;\r\n}\r\n\r\nfunction useInstance(instance: any): void {\r\n const { dispatch } = instance;\r\n\r\n const resetRowEditing = React.useCallback(() => {\r\n dispatch({ type: actions.resetRowEditing });\r\n }, [dispatch]);\r\n\r\n const toggleRowEditing = React.useCallback(\r\n id => {\r\n dispatch({ type: actions.toggleRowEditing, id });\r\n },\r\n [dispatch]\r\n );\r\n\r\n const toggleEditing = React.useCallback(() => {\r\n dispatch({ type: actions.toggleEditing });\r\n }, [dispatch]);\r\n\r\n Object.assign(instance, {\r\n resetRowEditing,\r\n toggleRowEditing,\r\n toggleEditing,\r\n });\r\n}\r\n\r\nconst prepareRow =\r\n <T extends {}>(uniqueId: keyof T) =>\r\n (row: any, { instance }: any): void => {\r\n const id = row.original[uniqueId];\r\n\r\n row.toggleRowEditing = () => {\r\n if (instance.state.editingRowUniqueId === id) {\r\n instance.resetRowEditing();\r\n } else {\r\n instance.toggleRowEditing(id);\r\n }\r\n };\r\n\r\n row.isEditing = row.original._createKey\r\n ? instance.state.editingRowUniqueId === row.original._createKey\r\n : instance.state.editingRowUniqueId === id;\r\n row.canEdit = instance.state.allowEditing && (row.isEditing || !instance.state.editingRowUniqueId);\r\n };\r\n\r\nexport const useRowEditing = <T extends {}>(uniqueId: keyof T | undefined): PluginHook<{}> => {\r\n const plugin = (hooks: any): void => {\r\n if (uniqueId) {\r\n hooks.stateReducers.push(reducer);\r\n hooks.useInstance.push(useInstance);\r\n hooks.prepareRow.push(prepareRow<T>(uniqueId));\r\n }\r\n };\r\n plugin.pluginName = pluginName;\r\n\r\n return plugin;\r\n};\r\n"],"names":["pluginName","actions","resetRowEditing","toggleRowEditing","toggleEditing","reducer","state","action","type","init","allowEditing","editingRowUniqueId","resetPage","gotoPage","id","useInstance","instance","dispatch","React","useCallback","Object","assign","prepareRow","uniqueId","row","original","isEditing","_createKey","canEdit","useRowEditing","plugin","hooks","stateReducers","push"],"mappings":";;;AAGA,MAAMA,UAAU,GAAG,eAAnB;AAEAC,OAAO,CAACC,eAAR,GAA0B,iBAA1B;AACAD,OAAO,CAACE,gBAAR,GAA2B,kBAA3B;AACAF,OAAO,CAACG,aAAR,GAAwB,eAAxB;;AAEA,SAASC,OAAT,CAAiBC,KAAjB,EAA6BC,MAA7B;AACI,MAAIA,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACQ,IAA5B,EAAkC;AAC9B,WAAO;AACHC,MAAAA,YAAY,EAAE,IADX;AAEHC,MAAAA,kBAAkB,EAAE,IAFjB;AAGH,SAAGL;AAHA,KAAP;AAKH;;AAED,MAAIC,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACC,eAAxB,IAA2CK,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACW,SAAnE,IAAgFL,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACY,QAA5G,EAAsH;AAClH,WAAO,EACH,GAAGP,KADA;AAEHK,MAAAA,kBAAkB,EAAE;AAFjB,KAAP;AAIH;;AAED,MAAIJ,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACE,gBAA5B,EAA8C;AAC1C,UAAM;AAAEW,MAAAA;AAAF,QAASP,MAAf;AACA,WAAO,EACH,GAAGD,KADA;AAEHK,MAAAA,kBAAkB,EAAEG;AAFjB,KAAP;AAIH;;AAED,MAAIP,MAAM,CAACC,IAAP,KAAgBP,OAAO,CAACG,aAA5B,EAA2C;AACvC,WAAO,EACH,GAAGE,KADA;AAEHI,MAAAA,YAAY,EAAE,CAACJ,KAAK,CAACI;AAFlB,K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AJ,GAAgBF,GAAG,CAACC,QAAJ,CAAaE,UAAb,GACVX,QAAQ,CAACV,KAAT,CAAeK,kBAAf,KAAsCa,GAAG,CAACC,QAAJ,CAAaE,UADzC,GAEVX,QAAQ,CAACV,KAAT,CAAeK,kBAAf,KAAsCG,EAF5C;AAGAU,EAAAA,GAAG,CAACI,OAAJ,GAAcZ,QAAQ,CAACV,KAAT,CAAeI,YAAf,KAAgCc,GAAG,CAACE,SAAJ,IAAiB,CAACV,QAAQ,CAACV,KAAT,CAAeK,kBAAjE,CAAd;AACH,CAjBL;;MAmBakB,aAAa,GAAkBN,QAAf;AACzB,QAAMO,MAAM,GAAIC,KAAD;AACX,QAAIR,QAAJ,EAAc;AACVQ,MAAAA,KAAK,CAACC,aAAN,CAAoBC,IAApB,CAAyB5B,OAAzB;AACA0B,MAAAA,KAAK,CAAChB,WAAN,CAAkBkB,IAAlB,CAAuBlB,WAAvB;AACAgB,MAAAA,KAAK,CAACT,UAAN,CAAiBW,IAAjB,CAAsBX,UAAU,CAAIC,QAAJ,CAAhC;AACH;AACJ,GAND;;AAOAO,EAAAA,MAAM,CAAC9B,UAAP,GAAoBA,UAApB;AAEA,SAAO8B,MAAP;AACH;;;;"}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { Checkbox } from '../../../Checkbox/Checkbox.js';
|
3
|
+
import { useRowSelect as useRowSelect$1 } from 'react-table';
|
4
|
+
|
5
|
+
// this wraps react-table's internal useRowSelect hook
|
6
|
+
|
7
|
+
const toggleBetween = (fromRowIndex, toRowIndex) => {
|
8
|
+
const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;
|
9
|
+
const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;
|
10
|
+
return [fromIndex, toIndex];
|
11
|
+
}; // react-table calls "index paths" row ids. we named them indexPaths to reduce confusion with natural ids
|
12
|
+
// the selection hook usess react-table's row selection, so this hok references row.id - it is the index path
|
13
|
+
|
14
|
+
|
15
|
+
const useRowSelect = onSelectedRows => {
|
16
|
+
const plugin = hooks => {
|
17
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
18
|
+
useRowSelect$1(hooks);
|
19
|
+
|
20
|
+
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
|
+
});
|
33
|
+
|
34
|
+
const prepareRow = row => {
|
35
|
+
row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);
|
36
|
+
};
|
37
|
+
|
38
|
+
hooks.prepareRow.push(prepareRow); // eslint-disable-next-line react-hooks/rules-of-hooks
|
39
|
+
|
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
|
+
}));
|
64
|
+
},
|
65
|
+
Cell: ({
|
66
|
+
row,
|
67
|
+
rows
|
68
|
+
}) => {
|
69
|
+
const {
|
70
|
+
onChange: _,
|
71
|
+
...props
|
72
|
+
} = row.getToggleRowSelectedProps(); // row.index refers to the index in the original data, not the current index
|
73
|
+
|
74
|
+
const sortedIndex = rows.findIndex(r => r.index === row.index);
|
75
|
+
|
76
|
+
const onClick = event => {
|
77
|
+
if (event.shiftKey) {
|
78
|
+
const [fromIndex, toIndex] = toggleBetween(lastSelectedSortedIndex.current || 0, sortedIndex);
|
79
|
+
|
80
|
+
for (let i = fromIndex; i <= toIndex; i++) {
|
81
|
+
toggleRowSelected(rows[i].id, true);
|
82
|
+
}
|
83
|
+
} else {
|
84
|
+
toggleRowSelected(row.id, !props.checked);
|
85
|
+
}
|
86
|
+
|
87
|
+
lastSelectedSortedIndex.current = sortedIndex;
|
88
|
+
};
|
89
|
+
|
90
|
+
return React__default.createElement(Checkbox, Object.assign({}, props, {
|
91
|
+
className: "mt-2.5",
|
92
|
+
onClick: onClick,
|
93
|
+
// this is necessary to remove console spam from eslint
|
94
|
+
onChange: () => false
|
95
|
+
}));
|
96
|
+
},
|
97
|
+
flex: '0 0 36px',
|
98
|
+
className: 'flex-col justify-start !py-0'
|
99
|
+
}, ...columns]);
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
plugin.pluginName = 'useRowSelect';
|
104
|
+
return plugin;
|
105
|
+
};
|
106
|
+
|
107
|
+
export { useRowSelect };
|
108
|
+
//# sourceMappingURL=useRowSelect.js.map
|
@@ -0,0 +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} />;\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-2.5\"\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 !py-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","Cell","getToggleRowSelectedProps","sortedIndex","findIndex","r","index","onClick","event","shiftKey","current","i","className","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,QAAIF,cAAJ,EAAoB;AAChB,YAAMI,iBAAiB,GAAG,CAACC,SAAD,EAAoBC,OAApB,KACtBN,cAAc,CAACO,KAAK;AAChB,cAAMC,SAAS,GAAG,EAAE,GAAGD;AAAL,SAAlB;;AAEA,YA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
|
+
import set from 'lodash-es/set';
|
4
|
+
import { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath } from '../util/rowIndexPath.js';
|
5
|
+
import unset from 'lodash-es/unset';
|
6
|
+
import get from 'lodash-es/get';
|
7
|
+
import compact from 'lodash-es/compact';
|
8
|
+
import pullAt from 'lodash-es/pullAt';
|
9
|
+
|
10
|
+
const insertChildTableRow = (data, rowIndexPath = undefined, values = {}) => {
|
11
|
+
const nexTRow = JSON.parse(JSON.stringify(data));
|
12
|
+
let childRowIndexPath;
|
13
|
+
|
14
|
+
if (rowIndexPath) {
|
15
|
+
var _currentRow$subRows;
|
16
|
+
|
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';
|
21
|
+
nextSubRows.unshift(values);
|
22
|
+
set(nexTRow, path, nextSubRows); // rebuild the new id
|
23
|
+
|
24
|
+
rowIndexes.push(0);
|
25
|
+
childRowIndexPath = rowIndexes.join('.');
|
26
|
+
} else {
|
27
|
+
nexTRow.unshift(values);
|
28
|
+
childRowIndexPath = '0';
|
29
|
+
}
|
30
|
+
|
31
|
+
return [nexTRow, childRowIndexPath];
|
32
|
+
};
|
33
|
+
const removeChildTableRow = (data, rowIndexPath) => {
|
34
|
+
const nexTRow = JSON.parse(JSON.stringify(data));
|
35
|
+
const rowIndexes = convertRowIndexPathToNumberArray(rowIndexPath);
|
36
|
+
const rootIndex = Number(rowIndexes.shift());
|
37
|
+
|
38
|
+
if (rowIndexes.length) {
|
39
|
+
// unset
|
40
|
+
const unsetPath = rowIndexes.map(index => `subRows[${index}]`).join('.');
|
41
|
+
unset(nexTRow[rootIndex], unsetPath); // remove empty value from subRows
|
42
|
+
|
43
|
+
rowIndexes.pop();
|
44
|
+
const setPath = rowIndexes.length ? rowIndexes.map(index => `subRows[${index}]`).join('.') + '.subRows' : 'subRows';
|
45
|
+
set(nexTRow[rootIndex], setPath, compact(get(nexTRow[rootIndex], setPath)));
|
46
|
+
} else {
|
47
|
+
pullAt(nexTRow, rootIndex);
|
48
|
+
}
|
49
|
+
|
50
|
+
return nexTRow;
|
51
|
+
};
|
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(() => {
|
56
|
+
if (activeRowIndexPath !== undefined) {
|
57
|
+
// 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
|
59
|
+
|
60
|
+
const parentId = getParentRowIndexPath(activeRowIndexPath); // insert a new empty row in the external data (with the same key)
|
61
|
+
|
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
|
+
|
64
|
+
setActiveRowIndexPath(newRowIndexPath);
|
65
|
+
setInternalData(nexTRow);
|
66
|
+
|
67
|
+
if (tableRef !== null && tableRef !== void 0 && tableRef.current) {
|
68
|
+
tableRef.current.instance.toggleRowEditing(currentRow === null || currentRow === void 0 ? void 0 : currentRow._createKey);
|
69
|
+
}
|
70
|
+
} else {
|
71
|
+
setInternalData(data);
|
72
|
+
}
|
73
|
+
}, [JSON.stringify(data)]);
|
74
|
+
|
75
|
+
const create = (rowIndexPath = undefined, values = {}) => {
|
76
|
+
const _createKey = v4();
|
77
|
+
|
78
|
+
const [nexTRow, newRowIndexPath] = insertChildTableRow(internalData, rowIndexPath, { ...values,
|
79
|
+
_createKey
|
80
|
+
});
|
81
|
+
setActiveRowIndexPath(newRowIndexPath);
|
82
|
+
setInternalData(nexTRow);
|
83
|
+
|
84
|
+
if (tableRef !== null && tableRef !== void 0 && tableRef.current) {
|
85
|
+
tableRef.current.instance.toggleRowEditing(_createKey);
|
86
|
+
}
|
87
|
+
|
88
|
+
return newRowIndexPath;
|
89
|
+
};
|
90
|
+
|
91
|
+
const remove = rowIndexPath => {
|
92
|
+
const nexTRow = removeChildTableRow(internalData, rowIndexPath);
|
93
|
+
setInternalData(nexTRow);
|
94
|
+
setActiveRowIndexPath(undefined);
|
95
|
+
};
|
96
|
+
|
97
|
+
return {
|
98
|
+
data: internalData,
|
99
|
+
create,
|
100
|
+
remove,
|
101
|
+
isCreating: activeRowIndexPath !== undefined
|
102
|
+
};
|
103
|
+
};
|
104
|
+
|
105
|
+
export { insertChildTableRow, removeChildTableRow, useTableRowCreation };
|
106
|
+
//# sourceMappingURL=useRowCreation.js.map
|
@@ -0,0 +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"],"mapp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