@economic/taco 2.45.0-alpha.1 → 2.45.0-create.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/AlertDialog/components/Content.d.ts +1 -1
- package/dist/components/Calendar/Calendar.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Dialog/components/Content.d.ts +1 -1
- package/dist/components/Dialog/components/DialogDrawer.d.ts +2 -2
- package/dist/components/Drawer/components/Content.d.ts +2 -2
- package/dist/components/Header/components/Agreement/Badge.d.ts +1 -1
- package/dist/components/Header/components/Agreement/Display.d.ts +2 -2
- package/dist/components/Header/components/Agreement/Item.d.ts +2 -2
- package/dist/components/Header/components/AgreementSelector.d.ts +2 -2
- package/dist/components/Header/components/Button.d.ts +1 -1
- package/dist/components/HoverCard/HoverCard.d.ts +1 -1
- package/dist/components/Icon/components/AccountPreview.d.ts +1 -1
- package/dist/components/Icon/components/Accounting.d.ts +1 -1
- package/dist/components/Icon/components/AccountingYear.d.ts +1 -1
- package/dist/components/Icon/components/AccountingYearCancel.d.ts +1 -1
- package/dist/components/Icon/components/AiChatSolid.d.ts +1 -1
- package/dist/components/Icon/components/AiStars.d.ts +1 -1
- package/dist/components/Icon/components/ArrowBottom.d.ts +1 -1
- package/dist/components/Icon/components/ArrowDown.d.ts +1 -1
- package/dist/components/Icon/components/ArrowEnd.d.ts +1 -1
- package/dist/components/Icon/components/ArrowLeft.d.ts +1 -1
- package/dist/components/Icon/components/ArrowRight.d.ts +1 -1
- package/dist/components/Icon/components/ArrowStart.d.ts +1 -1
- package/dist/components/Icon/components/ArrowTop.d.ts +1 -1
- package/dist/components/Icon/components/ArrowUp.d.ts +1 -1
- package/dist/components/Icon/components/Attach.d.ts +1 -1
- package/dist/components/Icon/components/AttachAuto.d.ts +1 -1
- package/dist/components/Icon/components/AttachCancel.d.ts +1 -1
- package/dist/components/Icon/components/AttachWarning.d.ts +1 -1
- package/dist/components/Icon/components/Autotext.d.ts +1 -1
- package/dist/components/Icon/components/AutotextInsert.d.ts +1 -1
- package/dist/components/Icon/components/Basic.d.ts +1 -1
- package/dist/components/Icon/components/BasicTabs.d.ts +1 -1
- package/dist/components/Icon/components/BellSolid.d.ts +1 -1
- package/dist/components/Icon/components/Book.d.ts +1 -1
- package/dist/components/Icon/components/Booking.d.ts +1 -1
- package/dist/components/Icon/components/Budget.d.ts +1 -1
- package/dist/components/Icon/components/Calendar.d.ts +1 -1
- package/dist/components/Icon/components/CashAccount.d.ts +1 -1
- package/dist/components/Icon/components/CashReports.d.ts +1 -1
- package/dist/components/Icon/components/ChartArea.d.ts +1 -1
- package/dist/components/Icon/components/ChartBar.d.ts +1 -1
- package/dist/components/Icon/components/ChartLine.d.ts +1 -1
- package/dist/components/Icon/components/ChartPie.d.ts +1 -1
- package/dist/components/Icon/components/ChartTable.d.ts +1 -1
- package/dist/components/Icon/components/Chat.d.ts +1 -1
- package/dist/components/Icon/components/ChatSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDown.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDownDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDownSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeft.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeftDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeftSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRight.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRightDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRightSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUp.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUpDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUpSolid.d.ts +1 -1
- package/dist/components/Icon/components/CircleClose.d.ts +1 -1
- package/dist/components/Icon/components/CircleInformation.d.ts +1 -1
- package/dist/components/Icon/components/CircleMinus.d.ts +1 -1
- package/dist/components/Icon/components/CirclePlus.d.ts +1 -1
- package/dist/components/Icon/components/CircleQuestionmark.d.ts +1 -1
- package/dist/components/Icon/components/CircleTick.d.ts +1 -1
- package/dist/components/Icon/components/CircleWarning.d.ts +1 -1
- package/dist/components/Icon/components/Clamp.d.ts +1 -1
- package/dist/components/Icon/components/ClampOpen.d.ts +1 -1
- package/dist/components/Icon/components/Close.d.ts +1 -1
- package/dist/components/Icon/components/ColumnFreeze.d.ts +1 -1
- package/dist/components/Icon/components/ColumnUnfreeze.d.ts +1 -1
- package/dist/components/Icon/components/Columns.d.ts +1 -1
- package/dist/components/Icon/components/ConnectionEnable.d.ts +1 -1
- package/dist/components/Icon/components/ConnectionRevoke.d.ts +1 -1
- package/dist/components/Icon/components/Contacts.d.ts +1 -1
- package/dist/components/Icon/components/Copy.d.ts +1 -1
- package/dist/components/Icon/components/Courses.d.ts +1 -1
- package/dist/components/Icon/components/Credit.d.ts +1 -1
- package/dist/components/Icon/components/Delete.d.ts +1 -1
- package/dist/components/Icon/components/DeletePermanently.d.ts +1 -1
- package/dist/components/Icon/components/Depecriate.d.ts +1 -1
- package/dist/components/Icon/components/Developer.d.ts +1 -1
- package/dist/components/Icon/components/DistributionTemplate.d.ts +1 -1
- package/dist/components/Icon/components/Document.d.ts +1 -1
- package/dist/components/Icon/components/DocumentApprove.d.ts +1 -1
- package/dist/components/Icon/components/DocumentCreateEntry.d.ts +1 -1
- package/dist/components/Icon/components/DocumentCut.d.ts +1 -1
- package/dist/components/Icon/components/DocumentError.d.ts +1 -1
- package/dist/components/Icon/components/DocumentIsolatePage.d.ts +1 -1
- package/dist/components/Icon/components/DocumentMerge.d.ts +1 -1
- package/dist/components/Icon/components/DocumentMove.d.ts +1 -1
- package/dist/components/Icon/components/DocumentPreview.d.ts +1 -1
- package/dist/components/Icon/components/DocumentReceived.d.ts +1 -1
- package/dist/components/Icon/components/DocumentRejectedRequest.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSigned.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSignedSolid.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSplit.d.ts +1 -1
- package/dist/components/Icon/components/DocumentTime.d.ts +1 -1
- package/dist/components/Icon/components/Download.d.ts +1 -1
- package/dist/components/Icon/components/Drag.d.ts +1 -1
- package/dist/components/Icon/components/ECopedia.d.ts +1 -1
- package/dist/components/Icon/components/Edit.d.ts +1 -1
- package/dist/components/Icon/components/EditSimple.d.ts +1 -1
- package/dist/components/Icon/components/EllipsisHorizontal.d.ts +1 -1
- package/dist/components/Icon/components/EllipsisVertical.d.ts +1 -1
- package/dist/components/Icon/components/EntriesOnAccount.d.ts +1 -1
- package/dist/components/Icon/components/EntriesOpen.d.ts +1 -1
- package/dist/components/Icon/components/EntriesWarning.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeCustomerPayment.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeJournalEntry.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeSupplierInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeSupplierPayment.d.ts +1 -1
- package/dist/components/Icon/components/Envelope.d.ts +1 -1
- package/dist/components/Icon/components/EnvelopeApproved.d.ts +1 -1
- package/dist/components/Icon/components/EnvelopeSolid.d.ts +1 -1
- package/dist/components/Icon/components/ExpandView.d.ts +1 -1
- package/dist/components/Icon/components/Expenses.d.ts +1 -1
- package/dist/components/Icon/components/Export.d.ts +1 -1
- package/dist/components/Icon/components/ExportToExcel.d.ts +1 -1
- package/dist/components/Icon/components/ExportToPdf.d.ts +1 -1
- package/dist/components/Icon/components/EyeOff.d.ts +1 -1
- package/dist/components/Icon/components/EyeOn.d.ts +1 -1
- package/dist/components/Icon/components/Filter.d.ts +1 -1
- package/dist/components/Icon/components/FilterSolid.d.ts +1 -1
- package/dist/components/Icon/components/FontSize.d.ts +1 -1
- package/dist/components/Icon/components/GraphSolid.d.ts +1 -1
- package/dist/components/Icon/components/Hash.d.ts +1 -1
- package/dist/components/Icon/components/HeightExtraTall.d.ts +1 -1
- package/dist/components/Icon/components/HeightMedium.d.ts +1 -1
- package/dist/components/Icon/components/HeightShort.d.ts +1 -1
- package/dist/components/Icon/components/HeightTall.d.ts +1 -1
- package/dist/components/Icon/components/House.d.ts +1 -1
- package/dist/components/Icon/components/HouseSolid.d.ts +1 -1
- package/dist/components/Icon/components/Id.d.ts +1 -1
- package/dist/components/Icon/components/Images.d.ts +1 -1
- package/dist/components/Icon/components/Import.d.ts +1 -1
- package/dist/components/Icon/components/Inbox.d.ts +1 -1
- package/dist/components/Icon/components/InboxEinvoicing.d.ts +1 -1
- package/dist/components/Icon/components/InboxScanning.d.ts +1 -1
- package/dist/components/Icon/components/InboxSmart.d.ts +1 -1
- package/dist/components/Icon/components/Info.d.ts +1 -1
- package/dist/components/Icon/components/Inventory.d.ts +1 -1
- package/dist/components/Icon/components/InventoryMatrix.d.ts +1 -1
- package/dist/components/Icon/components/JournalPro.d.ts +1 -1
- package/dist/components/Icon/components/Layout.d.ts +1 -1
- package/dist/components/Icon/components/LayoutBoth.d.ts +1 -1
- package/dist/components/Icon/components/LayoutFirst.d.ts +1 -1
- package/dist/components/Icon/components/LayoutLast.d.ts +1 -1
- package/dist/components/Icon/components/LayoutNone.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCard.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardCustomerReminder.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardObsoleteStock.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardOpeningEntry.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardReservedEntry.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardShrinkagePilferage.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardStockAdjustment.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.d.ts +1 -1
- package/dist/components/Icon/components/Lightbulb.d.ts +1 -1
- package/dist/components/Icon/components/Line.d.ts +1 -1
- package/dist/components/Icon/components/LinkExternal.d.ts +1 -1
- package/dist/components/Icon/components/List.d.ts +1 -1
- package/dist/components/Icon/components/ListBulleted.d.ts +1 -1
- package/dist/components/Icon/components/ListSearch.d.ts +1 -1
- package/dist/components/Icon/components/Location.d.ts +1 -1
- package/dist/components/Icon/components/Lock.d.ts +1 -1
- package/dist/components/Icon/components/LockOpen.d.ts +1 -1
- package/dist/components/Icon/components/Log.d.ts +1 -1
- package/dist/components/Icon/components/LogOut.d.ts +1 -1
- package/dist/components/Icon/components/Market.d.ts +1 -1
- package/dist/components/Icon/components/MastercardOs.d.ts +1 -1
- package/dist/components/Icon/components/MatchAmount.d.ts +1 -1
- package/dist/components/Icon/components/MatchEntries.d.ts +1 -1
- package/dist/components/Icon/components/Menu.d.ts +1 -1
- package/dist/components/Icon/components/Mileage.d.ts +1 -1
- package/dist/components/Icon/components/ModalResize.d.ts +1 -1
- package/dist/components/Icon/components/ModalShrink.d.ts +1 -1
- package/dist/components/Icon/components/More.d.ts +1 -1
- package/dist/components/Icon/components/MoreSolid.d.ts +1 -1
- package/dist/components/Icon/components/Move.d.ts +1 -1
- package/dist/components/Icon/components/NavigationList.d.ts +1 -1
- package/dist/components/Icon/components/Note.d.ts +1 -1
- package/dist/components/Icon/components/NoteFollowUp.d.ts +1 -1
- package/dist/components/Icon/components/NoteRead.d.ts +1 -1
- package/dist/components/Icon/components/NovemberFirst.d.ts +1 -1
- package/dist/components/Icon/components/Numbers.d.ts +1 -1
- package/dist/components/Icon/components/PartnerApi.d.ts +1 -1
- package/dist/components/Icon/components/PaymentPaid.d.ts +1 -1
- package/dist/components/Icon/components/PaymentUnpaid.d.ts +1 -1
- package/dist/components/Icon/components/Period.d.ts +1 -1
- package/dist/components/Icon/components/PersonChange.d.ts +1 -1
- package/dist/components/Icon/components/PersonMinus.d.ts +1 -1
- package/dist/components/Icon/components/PersonPlus.d.ts +1 -1
- package/dist/components/Icon/components/PersonTick.d.ts +1 -1
- package/dist/components/Icon/components/Phone.d.ts +1 -1
- package/dist/components/Icon/components/PhoneSolid.d.ts +1 -1
- package/dist/components/Icon/components/Play.d.ts +1 -1
- package/dist/components/Icon/components/PlusMinus.d.ts +1 -1
- package/dist/components/Icon/components/Print.d.ts +1 -1
- package/dist/components/Icon/components/ProcessPayment.d.ts +1 -1
- package/dist/components/Icon/components/ProductLedgerCard.d.ts +1 -1
- package/dist/components/Icon/components/Profile.d.ts +1 -1
- package/dist/components/Icon/components/ProjectCards.d.ts +1 -1
- package/dist/components/Icon/components/Projects.d.ts +1 -1
- package/dist/components/Icon/components/QuestionMark.d.ts +1 -1
- package/dist/components/Icon/components/QuestionMarkBold.d.ts +1 -1
- package/dist/components/Icon/components/Quicklinks.d.ts +1 -1
- package/dist/components/Icon/components/RatingBankruptcy.d.ts +1 -1
- package/dist/components/Icon/components/RatingPaymentProblems.d.ts +1 -1
- package/dist/components/Icon/components/Reconciled.d.ts +1 -1
- package/dist/components/Icon/components/Refresh.d.ts +1 -1
- package/dist/components/Icon/components/Report.d.ts +1 -1
- package/dist/components/Icon/components/ReportSolid.d.ts +1 -1
- package/dist/components/Icon/components/Restore.d.ts +1 -1
- package/dist/components/Icon/components/RotateLeft.d.ts +1 -1
- package/dist/components/Icon/components/RotateRight.d.ts +1 -1
- package/dist/components/Icon/components/Sales.d.ts +1 -1
- package/dist/components/Icon/components/Search.d.ts +1 -1
- package/dist/components/Icon/components/SearchBold.d.ts +1 -1
- package/dist/components/Icon/components/Secure.d.ts +1 -1
- package/dist/components/Icon/components/SecureTick.d.ts +1 -1
- package/dist/components/Icon/components/Settings.d.ts +1 -1
- package/dist/components/Icon/components/SettingsSolid.d.ts +1 -1
- package/dist/components/Icon/components/Shortcuts.d.ts +1 -1
- package/dist/components/Icon/components/ShowAll.d.ts +1 -1
- package/dist/components/Icon/components/ShowLess.d.ts +1 -1
- package/dist/components/Icon/components/ShowMore.d.ts +1 -1
- package/dist/components/Icon/components/ShowTemplate.d.ts +1 -1
- package/dist/components/Icon/components/Sliders.d.ts +1 -1
- package/dist/components/Icon/components/Smartpay.d.ts +1 -1
- package/dist/components/Icon/components/SortBy.d.ts +1 -1
- package/dist/components/Icon/components/Star.d.ts +1 -1
- package/dist/components/Icon/components/StarSolid.d.ts +1 -1
- package/dist/components/Icon/components/Subscriptions.d.ts +1 -1
- package/dist/components/Icon/components/SystemEntries.d.ts +1 -1
- package/dist/components/Icon/components/Tag.d.ts +1 -1
- package/dist/components/Icon/components/TemplateOverride.d.ts +1 -1
- package/dist/components/Icon/components/Templates.d.ts +1 -1
- package/dist/components/Icon/components/ThumbBoth.d.ts +1 -1
- package/dist/components/Icon/components/ThumbDown.d.ts +1 -1
- package/dist/components/Icon/components/ThumbDownSolid.d.ts +1 -1
- package/dist/components/Icon/components/ThumbUp.d.ts +1 -1
- package/dist/components/Icon/components/ThumbUpSolid.d.ts +1 -1
- package/dist/components/Icon/components/Tick.d.ts +1 -1
- package/dist/components/Icon/components/TickBold.d.ts +1 -1
- package/dist/components/Icon/components/Time.d.ts +1 -1
- package/dist/components/Icon/components/Transfer.d.ts +1 -1
- package/dist/components/Icon/components/TransferCancel.d.ts +1 -1
- package/dist/components/Icon/components/TransferLocked.d.ts +1 -1
- package/dist/components/Icon/components/Undo.d.ts +1 -1
- package/dist/components/Icon/components/Undock.d.ts +1 -1
- package/dist/components/Icon/components/Unreconciled.d.ts +1 -1
- package/dist/components/Icon/components/Warning.d.ts +1 -1
- package/dist/components/Icon/components/Webshop.d.ts +1 -1
- package/dist/components/Icon/components/Website.d.ts +1 -1
- package/dist/components/Icon/components/Workflow.d.ts +1 -1
- package/dist/components/Icon/components/WorkflowTemplateBasic.d.ts +1 -1
- package/dist/components/Icon/components/Zoom.d.ts +1 -1
- package/dist/components/IconButton/IconButton.d.ts +2 -2
- package/dist/components/Input/Input.d.ts +2 -2
- package/dist/components/Input/util.d.ts +1 -11
- package/dist/components/Layout/components/Sidebar.d.ts +2 -14
- package/dist/components/Layout/components/Top.d.ts +4 -4
- package/dist/components/List/List.d.ts +7 -7
- package/dist/components/List/components/Button.d.ts +1 -1
- package/dist/components/List/components/Collapsible.d.ts +1 -1
- package/dist/components/List/components/Group.d.ts +1 -1
- package/dist/components/List/components/Item.d.ts +1 -1
- package/dist/components/List/components/Link.d.ts +1 -1
- package/dist/components/List/components/Toggle.d.ts +2 -2
- package/dist/components/Listbox/Listbox.d.ts +2 -2
- package/dist/components/Listbox/ScrollableList.d.ts +1 -1
- package/dist/components/Listbox/util.d.ts +2 -2
- package/dist/components/Menu/components/Checkbox.d.ts +1 -1
- package/dist/components/Menu/components/Content.d.ts +2 -2
- package/dist/components/Menu/components/Item.d.ts +8 -8
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Menu/components/RadioGroup.d.ts +1 -1
- package/dist/components/Menu/components/SubMenu.d.ts +1 -1
- package/dist/components/Menu/components/Trigger.d.ts +1 -1
- package/dist/components/Navigation2/components/Group.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Provider/Localization.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/ScrollArea/ScrollArea.d.ts +2 -2
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select2/components/All.d.ts +2 -2
- package/dist/components/Select2/components/Collection.d.ts +1 -1
- package/dist/components/Select2/components/Create.d.ts +1 -1
- package/dist/components/Select2/components/Edit.d.ts +2 -2
- package/dist/components/Select2/components/Group.d.ts +1 -1
- package/dist/components/Select2/components/Option.d.ts +1 -1
- package/dist/components/Select2/components/Search.d.ts +3 -3
- package/dist/components/Select2/components/Trigger.d.ts +1 -1
- package/dist/components/Select2/hooks/useChildren.d.ts +2 -2
- package/dist/components/Shortcut/Shortcut.d.ts +1 -1
- package/dist/components/Table3/Table3.d.ts +2 -14
- package/dist/components/Table3/components/Columns/Cell/Cell.d.ts +2 -2
- package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.d.ts +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.d.ts +2 -2
- package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +3 -4
- package/dist/components/Table3/components/Editing/Alert.d.ts +1 -1
- package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
- package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +13 -0
- package/dist/components/Table3/components/Row/Editing/SaveStatus.d.ts +2 -2
- package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +12 -0
- package/dist/components/Table3/components/Row/Row.d.ts +2 -2
- package/dist/components/Table3/components/Toolbar/Editing/Editing.d.ts +1 -1
- package/dist/components/Table3/features/useEditingState.d.ts +29 -0
- package/dist/components/Table3/features/useTableEditing.d.ts +24 -36
- package/dist/components/Table3/types.d.ts +23 -8
- package/dist/components/Table3/useTable3.d.ts +6 -0
- package/dist/components/Table3/util/editing.d.ts +0 -1
- package/dist/components/Tag/Tag.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tour/Tour.d.ts +3 -3
- package/dist/components/Truncate/Truncate.d.ts +1 -1
- package/dist/esm/index.css +6 -2
- package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +17 -17
- package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +3 -3
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Avatar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +3 -5
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js +2 -2
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +4 -4
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js +10 -11
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +2 -0
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +21 -7
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +24 -6
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +5 -36
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +88 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +93 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +5 -7
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +514 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +16 -406
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +37 -32
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +21 -7
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +3 -28
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toast.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tour/Tour.js +3 -3
- package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useIntersectionObserver.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +18 -0
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js +0 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +3 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +9 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +6 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Goto.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Resizer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/SortIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +1 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +9 -7
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.css +6 -2
- package/dist/primitives/BubbleSelect.d.ts +1 -1
- package/dist/primitives/Collection/components/Root.d.ts +2 -0
- package/dist/primitives/Sortable/components/Container.d.ts +2 -2
- package/dist/primitives/Sortable/components/Item.d.ts +1 -2
- package/dist/primitives/Sortable/components/List.d.ts +1 -1
- package/dist/primitives/Table/Core/Table.d.ts +3 -2
- package/dist/primitives/Table/Core/components/Body/Body.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Body/util.d.ts +4 -4
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/Cell.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +5 -3
- package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +3 -3
- package/dist/primitives/Table/Core/components/Footer/Summary.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/Header.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Header/components/Goto.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/components/SortIndicator.d.ts +3 -3
- package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Row/Row.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Search/Search.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Settings/Settings.d.ts +2 -2
- package/dist/primitives/Table/types.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +1 -1
- package/dist/taco.cjs.development.js +925 -682
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +2 -1
- package/package.json +12 -12
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useEditingState.js","sources":["../../../../../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, Cell as ReactTableCell } from '@tanstack/react-table';\nimport { v4 as uuid } from 'uuid';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { willRowMove } from '../util/editing';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { useLocalization } from '../../Provider/Localization';\n\nexport const TEMPORARY_ROW_ID_PREFIX = 'temp-';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n status: Record<string, EditingSaveState>;\n };\n temporaryRows: TType[];\n};\ntype EditingStateAction = {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'createRow';\n rowId: string;\n payload?: any;\n};\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, rowId, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, rowId, row, Object),\n },\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${rowId}.${columnId}`);\n\n // if there are no changes left, remove the row\n if (!Object.keys(changes[rowId]).length) {\n return reducer(state, { type: 'removeRow', rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, moveReasons, original, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${rowId}.cells`,\n cellErrors ?? state.changes.errors.cells[rowId],\n Object\n ),\n originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),\n moveReasons: setWith(\n state.changes.moveReasons,\n rowId,\n moveReasons ?? state.changes.moveReasons[rowId],\n Object\n ),\n // status can be undefined, so don't use ??\n status: setWith(state.changes.status, rowId, undefined, Object),\n },\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, rowId),\n errors: omit(state.changes.errors, rowId),\n moveReasons: omit(state.changes.moveReasons, rowId),\n originals: omit(state.changes.originals, rowId),\n status: omit(state.changes.status, rowId),\n },\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId),\n };\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId),\n },\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, rowId, errors, Object),\n },\n };\n }\n\n case 'createRow': {\n const { value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n originals: setWith(state.changes.originals, rowId, value, Object),\n },\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },\n temporaryRows: [],\n });\n\n // rows\n async function setRowValue<T extends TType>(rowId: string, original: T, value: Partial<T>) {\n let cellErrors;\n\n if (validator) {\n const row = { ...original, ...value } as T;\n cellErrors = ((await validator(row)) ?? {}) as Record<string, string>;\n }\n\n dispatch({\n type: 'updateRow',\n rowId,\n payload: { cellErrors, original, value },\n });\n }\n\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function getRowStatus(rowId: string) {\n return state.changes.status[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n async function createRow<T extends TType>(data: Partial<T>) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'createRow',\n rowId: newRowId,\n payload: { value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number) {\n const changes = state.changes.rows[cell.row.id];\n\n if (!changes) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function') {\n const previousRowValue = {\n ...state.changes.originals[cell.row.id],\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...state.changes.originals[cell.row.id],\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...state.changes.rows[cell.row.id], ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation\n let validationErrors: Record<string, string> = {};\n\n if (validator) {\n const nextRowValue = { ...state.changes.originals[cell.row.id], ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n },\n });\n }\n\n // general\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = Object.keys(state.changes.errors);\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.changes.status).filter(value => value === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n const status = getRowStatus(rowId);\n\n try {\n // don't try to save if - already saving, or there are known errors\n if (status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...changes[rowId] };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (changeSet[rowIdentityAccessor as string]?.startsWith(TEMPORARY_ROW_ID_PREFIX)) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n discardChanges(rowId, table);\n\n // show the saved status, then remove it after a delay\n setRowStatus(rowId, 'saved');\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n table.resetRowPinning(true);\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n }\n\n return {\n // row\n setRowValue,\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n getRowStatus,\n setRowStatus,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n createRow,\n temporaryRows: state.temporaryRows,\n };\n}\n"],"names":["TEMPORARY_ROW_ID_PREFIX","DELAY_BEFORE_REMOVING_SAVE_STATUS","reducer","state","action","type","rowId","payload","columnId","row","value","changes","rows","setWith","Object","originals","rowIdentityAccessor","omit","keys","length","errors","moveReasons","cellErrors","original","cells","status","undefined","temporaryRows","filter","concat","usePendingChangesState","handleSave","handleChange","validator","saveChanges","table","console","warn","Promise","resolve","completed","_temp9","_forOf","getRowStatus","_catch","_changeSet$rowIdentit","_temp8","_result","_exit","changeSet","then","discardChanges","setRowStatus","setTimeout","startsWith","_temp7","error","_error$response","ReferenceError","TypeError","response","rowError","Error","_error$response2","message","data","_error$response3","dispatch","shouldShowErrorAlert","_result3","e","reject","onCellChanged","cell","rowIndex","cellsToActOn","column","id","updatesForOtherCells","allCells","_getAllCellsByColumnId","forEach","accessor","validationErrors","nextCellErrors","nextMoveReasons","_allCells$accessor","getIsSorted","reason","willRowMove","nextChanges","localization","_state$changes$errors8","_temp3","nextRowValue","_validator2","_temp4","_temp5","previousRowValue","_handleChange","_temp6","createRow","newRowId","uuid","setRowValue","_temp","_validator","_temp2","useLocalization","React","useReducer","getRowValue","_state$changes$rows$r","_state$changes$rows","getRowMoveReason","_Object$values$","values","_state$changes$moveRe","_state$changes$moveRe2","hasRowErrors","_state$changes$errors","_state$changes$errors2","_state$changes$errors3","hasRowErrorsShownInAlert","_state$changes$errors4","setCellValue","getCellValue","_state$changes$rows2","_state$changes$rows2$","getCellError","_state$changes$errors5","_state$changes$errors6","_state$changes$errors7","getErrorsShownInAlert","rowsWithErrors","map","hasSaved","hasChanges","resetRowPinning"],"mappings":";;;;;;;;MASaA,uBAAuB,GAAG;AAEvC,MAAMC,iCAAiC,GAAG,IAAI;AAkC9C,SAASC,OAAOA,CAAkBC,KAA0B,EAAEC,MAA0B;EACpF,MAAM;IAAEC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AAG,CAACjI,KAAK,KAAK;MACjEA,KAAK;MACLK,OAAO,EAAER,KAAK,CAACQ,OAAO,CAACC,IAAI,CAACN,KAAK,CAAwB;MACzDc,MAAM,EAAEjB,KAAK,CAACQ,OAAO,CAACS,MAAM,CAACd,KAAK;KACrC,CAAC,CAAC;;EAGP,SAASkI,QAAQA;IACb,OAAO,CAAC,CAAC1H,MAAM,CAACsG,MAAM,CAACjH,KAAK,CAACQ,OAAO,CAACc,MAAM,CAAC,CAACG,MAAM,CAAClB,KAAK,IAAIA,KAAK,KAAK,OAAO,CAAC,CAACS,MAAM;;EAG1F,SAASsH,UAAUA,CAACnI,KAAc;IAC9B,OAAOA,KAAK,GAAG,CAAC,CAACH,KAAK,CAACQ,OAAO,CAACC,IAAI,CAACN,KAAK,CAAC,GAAG,CAAC,CAACQ,MAAM,CAACI,IAAI,CAACf,KAAK,CAACQ,OAAO,CAACC,IAAI,CAAC,CAACO,MAAM;;EA+FzF,SAASgC,cAAcA,CAAkB7C,KAAa,EAAE6B,KAAoB;;IAExEA,KAAK,CAACuG,eAAe,CAAC,IAAI,CAAC;IAE3BvE,QAAQ,CAAC;MACL9D,IAAI,EAAE,WAAW;MACjBC,KAAK;MACLC,OAAO,EAAE;QAAES;;KACd,CAAC;;EAGN,OAAO;;IAEHwF,WAAW;IACXO,WAAW;IACXG,gBAAgB;IAChBK,YAAY;IACZI,wBAAwB;IACxBhF,YAAY;IACZS,YAAY;;IAEZyE,YAAY;IACZC,YAAY;IACZG,YAAY;IACZzD,aAAa;;IAEb6D,qBAAqB;IACrBI,UAAU;IACVvG,WAAW;IACXiB,cAAc;IACdqF,QAAQ;;IAERnC,SAAS;IACT1E,aAAa,EAAExB,KAAK,CAACwB;GACxB;AACL;;;;"}
|
@@ -1,29 +1,25 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import {
|
3
|
-
import { useLocalization } from '../../Provider/Localization.js';
|
4
|
-
import { _forOf, _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
5
|
-
import { willRowMove } from '../util/editing.js';
|
6
|
-
import { debounce } from 'lodash-es';
|
2
|
+
import { usePendingChangesState } from './useEditingState.js';
|
7
3
|
|
8
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, validator) {
|
4
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentityAccessor, validator) {
|
9
5
|
// used to switch the table into editing mode
|
10
|
-
const [isEditing,
|
6
|
+
const [isEditing, setEditing] = React__default.useState(false);
|
11
7
|
// used to switch the editing between "detailed" mode
|
12
8
|
const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
|
13
9
|
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
14
|
-
const [lastFocusedCellIndex, setLastFocusedCellIndex] =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
10
|
+
const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
|
11
|
+
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
|
12
|
+
function toggleEditing(enabled, table) {
|
13
|
+
if (!enabled) {
|
14
|
+
// save
|
15
|
+
pendingChangesFns.saveChanges(table);
|
16
|
+
// reset detailed mode
|
17
|
+
toggleDetailedMode(false);
|
18
|
+
// reset the last index back to the first focusable element, when editing gets turned off
|
19
|
+
setLastFocusedCellIndex(undefined);
|
20
|
+
}
|
21
|
+
setEditing(enabled);
|
22
|
+
}
|
27
23
|
return {
|
28
24
|
isEnabled,
|
29
25
|
isEditing,
|
@@ -35,392 +31,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, validator)
|
|
35
31
|
...pendingChangesFns
|
36
32
|
};
|
37
33
|
}
|
38
|
-
function usePendingChanges(isEnabled, handleSave, handleChange, validator) {
|
39
|
-
const saveChanges = function (rowId = undefined) {
|
40
|
-
try {
|
41
|
-
let _exit = false;
|
42
|
-
if (!handleSave) {
|
43
|
-
console.warn('Tried to save, but Table has no onEditingSave handler');
|
44
|
-
return Promise.resolve();
|
45
|
-
}
|
46
|
-
// we save back to pendingChanges, so make a copy of it's state when save was triggered
|
47
|
-
const changesToSave = rowId ? {
|
48
|
-
[rowId]: pendingChanges[rowId]
|
49
|
-
} : {
|
50
|
-
...pendingChanges
|
51
|
-
};
|
52
|
-
const changes = Object.keys(changesToSave);
|
53
|
-
return Promise.resolve(function () {
|
54
|
-
if (changes.length) {
|
55
|
-
return _forOf(changes, function (rowId) {
|
56
|
-
const pendingChange = changesToSave[rowId];
|
57
|
-
const changeSet = getChangesetFromChanges(pendingChange);
|
58
|
-
return _catch(function () {
|
59
|
-
function _temp3(_result) {
|
60
|
-
return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
|
61
|
-
// cleanup changes, we don't need them after saving
|
62
|
-
resetChanges(rowId);
|
63
|
-
setRowSaveStatus(rowId, 'complete');
|
64
|
-
});
|
65
|
-
}
|
66
|
-
if (getRowSaveStatus(rowId) === 'pending') {
|
67
|
-
_exit = true;
|
68
|
-
return;
|
69
|
-
}
|
70
|
-
// set saving = true
|
71
|
-
setRowSaveStatus(rowId, 'pending');
|
72
|
-
// re-run validation, maybe a cell is already invalid but has never been blurred
|
73
|
-
const _temp2 = function () {
|
74
|
-
if (validator) {
|
75
|
-
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
76
|
-
if (errors && Object.keys(errors).length) {
|
77
|
-
throw errors;
|
78
|
-
}
|
79
|
-
});
|
80
|
-
}
|
81
|
-
}();
|
82
|
-
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2); // send new data to the server
|
83
|
-
}, function (error) {
|
84
|
-
// the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
|
85
|
-
// this code handles those errors and maps them either to row errors or cell specific errors
|
86
|
-
let rowError;
|
87
|
-
let cellErrors;
|
88
|
-
if (typeof error === 'string') {
|
89
|
-
rowError = error;
|
90
|
-
} else if (error instanceof Error) {
|
91
|
-
var _error$response;
|
92
|
-
rowError = error.message;
|
93
|
-
// most of our apis return error objects within this shape
|
94
|
-
if (typeof ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) === 'object') {
|
95
|
-
var _error$response2;
|
96
|
-
cellErrors = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data;
|
97
|
-
}
|
98
|
-
} else if (typeof error === 'object') {
|
99
|
-
cellErrors = error;
|
100
|
-
}
|
101
|
-
if (rowError || cellErrors) {
|
102
|
-
setPendingChanges(currentChanges => {
|
103
|
-
const nextChanges = {
|
104
|
-
...currentChanges
|
105
|
-
};
|
106
|
-
nextChanges[rowId]._meta.errors = {
|
107
|
-
row: rowError,
|
108
|
-
cells: cellErrors,
|
109
|
-
shouldShowErrorAlert: true
|
110
|
-
};
|
111
|
-
return nextChanges;
|
112
|
-
});
|
113
|
-
}
|
114
|
-
setRowSaveStatus(rowId, undefined);
|
115
|
-
});
|
116
|
-
}, function () {
|
117
|
-
return _exit;
|
118
|
-
});
|
119
|
-
}
|
120
|
-
}());
|
121
|
-
} catch (e) {
|
122
|
-
return Promise.reject(e);
|
123
|
-
}
|
124
|
-
};
|
125
|
-
const validateCell = function (cell) {
|
126
|
-
try {
|
127
|
-
if (!validator || !isEnabled) {
|
128
|
-
return Promise.resolve();
|
129
|
-
}
|
130
|
-
const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);
|
131
|
-
// only validate if the cell being blurred actually has any changes
|
132
|
-
const _temp = function () {
|
133
|
-
if (cell.column.id in changeSet) {
|
134
|
-
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
135
|
-
setPendingChanges(currentChanges => {
|
136
|
-
const nextChanges = {
|
137
|
-
...currentChanges
|
138
|
-
};
|
139
|
-
nextChanges[cell.row.id]._meta = {
|
140
|
-
...nextChanges[cell.row.id]._meta,
|
141
|
-
errors: {
|
142
|
-
...nextChanges[cell.row.id]._meta.errors,
|
143
|
-
cells: errors,
|
144
|
-
shouldShowErrorAlert: !Object.keys(errors).length ? false : nextChanges[cell.row.id]._meta.errors.shouldShowErrorAlert
|
145
|
-
}
|
146
|
-
};
|
147
|
-
return nextChanges;
|
148
|
-
});
|
149
|
-
});
|
150
|
-
}
|
151
|
-
}();
|
152
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
153
|
-
} catch (e) {
|
154
|
-
return Promise.reject(e);
|
155
|
-
}
|
156
|
-
};
|
157
|
-
const setCellValue = function (cell, change, rowIndex) {
|
158
|
-
try {
|
159
|
-
const changes = {
|
160
|
-
[cell.column.id]: change
|
161
|
-
};
|
162
|
-
setPendingChanges(currentChanges => {
|
163
|
-
const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes, localization);
|
164
|
-
pendingChangesUpdater.syncCellChanges(nextChanges);
|
165
|
-
return nextChanges;
|
166
|
-
});
|
167
|
-
pendingChangesUpdater.runCellUpdates(changes, cell, rowIndex);
|
168
|
-
return Promise.resolve();
|
169
|
-
} catch (e) {
|
170
|
-
return Promise.reject(e);
|
171
|
-
}
|
172
|
-
};
|
173
|
-
const addCreatedRowChangeset = function (row) {
|
174
|
-
try {
|
175
|
-
const cells = row.getAllCells();
|
176
|
-
setPendingChanges(currentChanges => {
|
177
|
-
return cells.reduce((changes, cell) => {
|
178
|
-
if (cell.getValue()) {
|
179
|
-
var _currentChanges$cell$, _currentChanges$cell$2, _currentChanges$cell$3;
|
180
|
-
return {
|
181
|
-
...changes,
|
182
|
-
[cell.row.id]: {
|
183
|
-
...changes[cell.row.id],
|
184
|
-
[cell.column.id]: cell.getValue(),
|
185
|
-
_meta: {
|
186
|
-
...((_currentChanges$cell$ = currentChanges[cell.row.id]) === null || _currentChanges$cell$ === void 0 ? void 0 : _currentChanges$cell$._meta),
|
187
|
-
original: cell.row.original,
|
188
|
-
moveReason: {
|
189
|
-
...((_currentChanges$cell$2 = currentChanges[cell.row.id]) === null || _currentChanges$cell$2 === void 0 ? void 0 : _currentChanges$cell$2._meta.moveReason)
|
190
|
-
},
|
191
|
-
errors: {
|
192
|
-
...((_currentChanges$cell$3 = currentChanges[cell.row.id]) === null || _currentChanges$cell$3 === void 0 ? void 0 : _currentChanges$cell$3._meta.errors)
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
196
|
-
};
|
197
|
-
} else {
|
198
|
-
return changes;
|
199
|
-
}
|
200
|
-
}, currentChanges);
|
201
|
-
});
|
202
|
-
return Promise.resolve();
|
203
|
-
} catch (e) {
|
204
|
-
return Promise.reject(e);
|
205
|
-
}
|
206
|
-
};
|
207
|
-
const localization = useLocalization();
|
208
|
-
const [pendingChanges, setPendingChanges] = React__default.useState({});
|
209
|
-
// we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted
|
210
|
-
const [saveStates, setSaveState] = React__default.useState({});
|
211
|
-
function getCellValue(cell) {
|
212
|
-
var _pendingChanges$cell$;
|
213
|
-
return (_pendingChanges$cell$ = pendingChanges[cell.row.id]) === null || _pendingChanges$cell$ === void 0 ? void 0 : _pendingChanges$cell$[cell.column.id];
|
214
|
-
}
|
215
|
-
function getCellError(cell) {
|
216
|
-
var _pendingChanges$cell$2, _pendingChanges$cell$3, _pendingChanges$cell$4;
|
217
|
-
return (_pendingChanges$cell$2 = pendingChanges[cell.row.id]) === null || _pendingChanges$cell$2 === void 0 ? void 0 : (_pendingChanges$cell$3 = _pendingChanges$cell$2._meta.errors) === null || _pendingChanges$cell$3 === void 0 ? void 0 : (_pendingChanges$cell$4 = _pendingChanges$cell$3.cells) === null || _pendingChanges$cell$4 === void 0 ? void 0 : _pendingChanges$cell$4[cell.column.id];
|
218
|
-
}
|
219
|
-
const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);
|
220
|
-
function hasRowErrors(rowId) {
|
221
|
-
var _pendingChanges$rowId, _pendingChanges$rowId2, _pendingChanges$rowId3, _pendingChanges$rowId4, _pendingChanges$rowId5;
|
222
|
-
if (!isEnabled) {
|
223
|
-
return false;
|
224
|
-
}
|
225
|
-
return !!((_pendingChanges$rowId = pendingChanges[rowId]) !== null && _pendingChanges$rowId !== void 0 && (_pendingChanges$rowId2 = _pendingChanges$rowId._meta.errors) !== null && _pendingChanges$rowId2 !== void 0 && _pendingChanges$rowId2.row) || !!Object.keys((_pendingChanges$rowId3 = (_pendingChanges$rowId4 = pendingChanges[rowId]) === null || _pendingChanges$rowId4 === void 0 ? void 0 : (_pendingChanges$rowId5 = _pendingChanges$rowId4._meta.errors) === null || _pendingChanges$rowId5 === void 0 ? void 0 : _pendingChanges$rowId5.cells) !== null && _pendingChanges$rowId3 !== void 0 ? _pendingChanges$rowId3 : {}).length;
|
226
|
-
}
|
227
|
-
function hasRowErrorsSeen(rowId) {
|
228
|
-
var _pendingChanges$rowId6;
|
229
|
-
if (!isEnabled) {
|
230
|
-
return false;
|
231
|
-
}
|
232
|
-
return hasRowErrors(rowId) && !!((_pendingChanges$rowId6 = pendingChanges[rowId]._meta.errors) !== null && _pendingChanges$rowId6 !== void 0 && _pendingChanges$rowId6.shouldShowErrorAlert);
|
233
|
-
}
|
234
|
-
function getRowPendingChange(rowId) {
|
235
|
-
const rowPendingChanges = pendingChanges[rowId];
|
236
|
-
if (rowPendingChanges) {
|
237
|
-
const {
|
238
|
-
_meta,
|
239
|
-
...pendingChange
|
240
|
-
} = rowPendingChanges;
|
241
|
-
return pendingChange;
|
242
|
-
}
|
243
|
-
return undefined;
|
244
|
-
}
|
245
|
-
function getRowSaveStatus(rowId) {
|
246
|
-
if (!isEnabled) {
|
247
|
-
return false;
|
248
|
-
}
|
249
|
-
return saveStates[rowId];
|
250
|
-
}
|
251
|
-
function setRowSaveStatus(rowId, status) {
|
252
|
-
setSaveState(currentStates => {
|
253
|
-
const nextStates = {
|
254
|
-
...currentStates
|
255
|
-
};
|
256
|
-
if (status) {
|
257
|
-
nextStates[rowId] = status;
|
258
|
-
} else {
|
259
|
-
delete nextStates[rowId];
|
260
|
-
}
|
261
|
-
return nextStates;
|
262
|
-
});
|
263
|
-
}
|
264
|
-
function getRowMoveReason(rowId) {
|
265
|
-
var _pendingChanges$rowId7;
|
266
|
-
return (_pendingChanges$rowId7 = pendingChanges[rowId]) !== null && _pendingChanges$rowId7 !== void 0 && _pendingChanges$rowId7._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;
|
267
|
-
}
|
268
|
-
function hasChanges(rowId) {
|
269
|
-
if (!isEnabled) {
|
270
|
-
return false;
|
271
|
-
}
|
272
|
-
return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;
|
273
|
-
}
|
274
|
-
function hasAlertErrors() {
|
275
|
-
if (!isEnabled) {
|
276
|
-
return false;
|
277
|
-
}
|
278
|
-
return !!getAlertErrors().length;
|
279
|
-
}
|
280
|
-
function getAlertErrors() {
|
281
|
-
return Object.keys(pendingChanges).filter(hasRowErrorsSeen).map(rowId => ({
|
282
|
-
rowId,
|
283
|
-
pendingChange: pendingChanges[rowId]
|
284
|
-
}));
|
285
|
-
}
|
286
|
-
function resetChanges(rowId) {
|
287
|
-
setPendingChanges(currentChanges => {
|
288
|
-
const nextChanges = {
|
289
|
-
...currentChanges
|
290
|
-
};
|
291
|
-
delete nextChanges[rowId];
|
292
|
-
return nextChanges;
|
293
|
-
});
|
294
|
-
}
|
295
|
-
function getCompletedRowsCount() {
|
296
|
-
return Object.values(saveStates).filter(value => value === 'complete').length;
|
297
|
-
}
|
298
|
-
return {
|
299
|
-
getCellValue,
|
300
|
-
getCellError,
|
301
|
-
setCellValue,
|
302
|
-
validateCell,
|
303
|
-
addCreatedRowChangeset,
|
304
|
-
hasChanges,
|
305
|
-
hasAlertErrors,
|
306
|
-
getAlertErrors,
|
307
|
-
saveChanges,
|
308
|
-
resetChanges,
|
309
|
-
hasRowErrors,
|
310
|
-
hasRowErrorsSeen,
|
311
|
-
getRowPendingChange,
|
312
|
-
getRowSaveStatus,
|
313
|
-
setRowSaveStatus,
|
314
|
-
getRowMoveReason,
|
315
|
-
getCompletedRowsCount
|
316
|
-
};
|
317
|
-
}
|
318
|
-
function useLastFocusedCellIndex() {
|
319
|
-
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
320
|
-
const lastFocusedCellIndexRef = React__default.useRef(undefined);
|
321
|
-
const setLastFocusedCellIndex = React__default.useCallback(index => {
|
322
|
-
lastFocusedCellIndexRef.current = index;
|
323
|
-
}, []);
|
324
|
-
return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];
|
325
|
-
}
|
326
|
-
function usePendingChangesUpdater(handleChange, setPendingChanges) {
|
327
|
-
const localization = useLocalization();
|
328
|
-
const updatersRef = React__default.useRef({});
|
329
|
-
const runCellUpdates = React__default.useCallback(debounce(function (changes, cell, rowIndex) {
|
330
|
-
try {
|
331
|
-
const _temp4 = function () {
|
332
|
-
if (typeof handleChange === 'function') {
|
333
|
-
const previousValues = {
|
334
|
-
...cell.row.original,
|
335
|
-
...getChangesetFromChanges(updatersRef.current[cell.row.id])
|
336
|
-
};
|
337
|
-
const nextValues = {
|
338
|
-
...previousValues,
|
339
|
-
...changes
|
340
|
-
};
|
341
|
-
return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues)).then(function (updates) {
|
342
|
-
if (updates && Object.keys(updates).length) {
|
343
|
-
setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates, localization));
|
344
|
-
}
|
345
|
-
});
|
346
|
-
}
|
347
|
-
}();
|
348
|
-
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
|
349
|
-
} catch (e) {
|
350
|
-
return Promise.reject(e);
|
351
|
-
}
|
352
|
-
}, 250), []);
|
353
|
-
function syncCellChanges(changes) {
|
354
|
-
updatersRef.current = changes;
|
355
|
-
}
|
356
|
-
return {
|
357
|
-
syncCellChanges,
|
358
|
-
runCellUpdates
|
359
|
-
};
|
360
|
-
}
|
361
|
-
function createPendingChangesSetter(currentChanges, row, rowIndex, changes, localization) {
|
362
|
-
var _currentChanges$row$i, _currentChanges$row$i2, _currentChanges$row$i3;
|
363
|
-
// prepare
|
364
|
-
const nextChanges = {
|
365
|
-
...currentChanges
|
366
|
-
};
|
367
|
-
const rowChanges = {
|
368
|
-
...currentChanges[row.id],
|
369
|
-
_meta: {
|
370
|
-
...((_currentChanges$row$i = currentChanges[row.id]) === null || _currentChanges$row$i === void 0 ? void 0 : _currentChanges$row$i._meta),
|
371
|
-
original: row.original,
|
372
|
-
moveReason: {
|
373
|
-
...((_currentChanges$row$i2 = currentChanges[row.id]) === null || _currentChanges$row$i2 === void 0 ? void 0 : _currentChanges$row$i2._meta.moveReason)
|
374
|
-
},
|
375
|
-
errors: {
|
376
|
-
...((_currentChanges$row$i3 = currentChanges[row.id]) === null || _currentChanges$row$i3 === void 0 ? void 0 : _currentChanges$row$i3._meta.errors)
|
377
|
-
}
|
378
|
-
}
|
379
|
-
};
|
380
|
-
// run changes
|
381
|
-
const cells = row._getAllCellsByColumnId();
|
382
|
-
for (const [accessor, change] of Object.entries(changes)) {
|
383
|
-
// update if the change is different to the original (saved) value,
|
384
|
-
// otherwise remove any change - no point saving the same value
|
385
|
-
if (change !== row.original[accessor]) {
|
386
|
-
rowChanges[accessor] = change;
|
387
|
-
// consumers sometimes include properties in onEditingChange that aren't rendered as columns, we need to guard against that.
|
388
|
-
// eslint-disable-next-line no-prototype-builtins
|
389
|
-
if (cells.hasOwnProperty(accessor)) {
|
390
|
-
// determine if the row will move position based on this change, and save why it will move
|
391
|
-
const reason = willRowMove(cells[accessor], change, rowIndex, localization);
|
392
|
-
if (reason) {
|
393
|
-
rowChanges._meta.moveReason[accessor] = reason;
|
394
|
-
} else {
|
395
|
-
delete rowChanges._meta.moveReason[accessor];
|
396
|
-
}
|
397
|
-
}
|
398
|
-
} else {
|
399
|
-
delete rowChanges[accessor];
|
400
|
-
delete rowChanges._meta.moveReason[accessor];
|
401
|
-
}
|
402
|
-
}
|
403
|
-
// set changes
|
404
|
-
// or delete if there are no changes left, so that we don't store changes with unchanged data
|
405
|
-
if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {
|
406
|
-
nextChanges[row.id] = rowChanges;
|
407
|
-
} else {
|
408
|
-
delete nextChanges[row.id];
|
409
|
-
}
|
410
|
-
return nextChanges;
|
411
|
-
}
|
412
|
-
function getChangesetFromChanges(changes) {
|
413
|
-
// extract the original data from the row changes
|
414
|
-
const {
|
415
|
-
_meta,
|
416
|
-
...changeset
|
417
|
-
} = changes !== null && changes !== void 0 ? changes : {};
|
418
|
-
// and mix them in with the changes, ready to send to the server
|
419
|
-
return {
|
420
|
-
...(_meta === null || _meta === void 0 ? void 0 : _meta.original),
|
421
|
-
...changeset
|
422
|
-
};
|
423
|
-
}
|
424
34
|
|
425
35
|
export { useTableEditing };
|
426
36
|
//# sourceMappingURL=useTableEditing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, Row as ReactTableRow } from '@tanstack/react-table';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { willRowMove } from '../util/editing';\nimport { debounce } from 'lodash';\nimport { Localization, useLocalization } from '../../Provider/Localization';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, toggleEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();\n\n // store pending changes for each row\n // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes\n // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved\n const pendingChangesFns = usePendingChanges<TType>(isEnabled, handleSave, handleChange, validator);\n\n useGlobalKeyDown(isEnabled && isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n pendingChangesFns.saveChanges();\n });\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n };\n}\n\ntype SaveState = 'pending' | 'complete';\nexport type PendingChange<TType = unknown> = Partial<TType> & {\n _meta: {\n original: TType;\n moveReason: Record<string, 'search' | 'sorting' | 'filter'>;\n errors: {\n row: string;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n };\n status?: SaveState;\n };\n};\n\ntype PendingChanges<TType = unknown> = Record<string, PendingChange<TType>>;\nfunction usePendingChanges<TType = unknown>(\n isEnabled: boolean,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [pendingChanges, setPendingChanges] = React.useState<PendingChanges<TType>>({});\n // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted\n const [saveStates, setSaveState] = React.useState<Record<string, SaveState>>({});\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return pendingChanges[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return pendingChanges[cell.row.id]?._meta.errors?.cells?.[cell.column.id];\n }\n\n async function addCreatedRowChangeset(row: ReactTableRow<unknown>) {\n const cells = row.getAllCells();\n\n setPendingChanges((currentChanges: any) => {\n return cells.reduce((changes, cell) => {\n if (cell.getValue()) {\n return {\n ...changes,\n [cell.row.id]: {\n ...changes[cell.row.id],\n [cell.column.id]: cell.getValue(),\n _meta: {\n ...currentChanges[cell.row.id]?._meta,\n original: cell.row.original,\n moveReason: {\n ...currentChanges[cell.row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[cell.row.id]?._meta.errors,\n },\n },\n },\n };\n } else {\n return changes;\n }\n }, currentChanges);\n });\n }\n const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);\n\n async function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, change: unknown, rowIndex: number) {\n const changes = {\n [cell.column.id]: change,\n } as Partial<T>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = createPendingChangesSetter<T>(\n currentChanges as PendingChanges<T>,\n cell.row,\n rowIndex,\n changes,\n localization\n );\n pendingChangesUpdater.syncCellChanges(nextChanges);\n return nextChanges;\n });\n pendingChangesUpdater.runCellUpdates<T>(changes, cell, rowIndex);\n }\n\n async function validateCell<T extends TType>(cell: ReactTableCell<T, unknown>) {\n if (!validator || !isEnabled) {\n return;\n }\n\n const changeSet: any = getChangesetFromChanges(pendingChanges[cell.row.id]);\n\n // only validate if the cell being blurred actually has any changes\n if (cell.column.id in changeSet) {\n const errors = ((await validator(changeSet)) ?? {}) as Record<string, string>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[cell.row.id]._meta = {\n ...nextChanges[cell.row.id]._meta,\n errors: {\n ...nextChanges[cell.row.id]._meta.errors,\n cells: errors,\n shouldShowErrorAlert: !Object.keys(errors).length\n ? false\n : nextChanges[cell.row.id]._meta.errors.shouldShowErrorAlert,\n },\n };\n return nextChanges;\n });\n }\n }\n\n function hasRowErrors(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return (\n !!pendingChanges[rowId]?._meta.errors?.row || !!Object.keys(pendingChanges[rowId]?._meta.errors?.cells ?? {}).length\n );\n }\n\n function hasRowErrorsSeen(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return hasRowErrors(rowId) && !!pendingChanges[rowId]._meta.errors?.shouldShowErrorAlert;\n }\n function getRowPendingChange(rowId: string) {\n const rowPendingChanges = pendingChanges[rowId];\n\n if (rowPendingChanges) {\n const { _meta, ...pendingChange } = rowPendingChanges;\n\n return pendingChange;\n }\n\n return undefined;\n }\n\n function getRowSaveStatus(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return saveStates[rowId];\n }\n\n function setRowSaveStatus(rowId: string, status: 'pending' | 'complete' | undefined) {\n setSaveState(currentStates => {\n const nextStates = { ...currentStates };\n\n if (status) {\n nextStates[rowId] = status;\n } else {\n delete nextStates[rowId];\n }\n\n return nextStates;\n });\n }\n\n function getRowMoveReason(rowId: string) {\n return pendingChanges[rowId]?._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;\n }\n\n function hasChanges(rowId?: string) {\n if (!isEnabled) {\n return false;\n }\n\n return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;\n }\n\n function hasAlertErrors() {\n if (!isEnabled) {\n return false;\n }\n return !!getAlertErrors().length;\n }\n\n function getAlertErrors<T extends TType>() {\n return Object.keys(pendingChanges)\n .filter(hasRowErrorsSeen)\n .map(rowId => ({ rowId, pendingChange: pendingChanges[rowId] as PendingChange<T> }));\n }\n\n function resetChanges(rowId: string) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n delete nextChanges[rowId];\n return nextChanges;\n });\n }\n\n async function saveChanges(rowId: string | undefined = undefined) {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return;\n }\n\n // we save back to pendingChanges, so make a copy of it's state when save was triggered\n const changesToSave = rowId ? { [rowId]: pendingChanges[rowId] } : { ...pendingChanges };\n const changes = Object.keys(changesToSave);\n\n if (changes.length) {\n for (const rowId of changes) {\n const pendingChange = changesToSave[rowId];\n\n const changeSet = getChangesetFromChanges(pendingChange);\n try {\n if (getRowSaveStatus(rowId) === 'pending') return;\n\n // set saving = true\n setRowSaveStatus(rowId, 'pending');\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n resetChanges(rowId);\n setRowSaveStatus(rowId, 'complete');\n } catch (error) {\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: any;\n let cellErrors: any;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n };\n return nextChanges;\n });\n }\n\n setRowSaveStatus(rowId, undefined);\n }\n }\n }\n }\n\n function getCompletedRowsCount() {\n return Object.values(saveStates).filter(value => value === 'complete').length;\n }\n\n return {\n getCellValue,\n getCellError,\n setCellValue,\n validateCell,\n addCreatedRowChangeset,\n hasChanges,\n hasAlertErrors,\n getAlertErrors,\n saveChanges,\n resetChanges,\n hasRowErrors,\n hasRowErrorsSeen,\n getRowPendingChange,\n getRowSaveStatus,\n setRowSaveStatus,\n getRowMoveReason,\n getCompletedRowsCount,\n };\n}\n\nfunction useLastFocusedCellIndex(): [number | undefined, (index: number | undefined) => void] {\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const lastFocusedCellIndexRef = React.useRef<number | undefined>(undefined);\n const setLastFocusedCellIndex = React.useCallback((index: number | undefined) => {\n lastFocusedCellIndexRef.current = index;\n }, []);\n\n return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];\n}\n\nfunction usePendingChangesUpdater<TType = unknown>(\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n setPendingChanges: React.Dispatch<React.SetStateAction<PendingChanges<TType>>>\n) {\n const localization = useLocalization();\n const updatersRef = React.useRef<PendingChanges<TType>>({});\n\n const runCellUpdates = React.useCallback(\n debounce(async function <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) {\n if (typeof handleChange === 'function') {\n const previousValues = {\n ...cell.row.original,\n ...getChangesetFromChanges(updatersRef.current[cell.row.id]),\n };\n const nextValues = {\n ...previousValues,\n ...changes,\n };\n const updates = await handleChange(cell.column.id, (changes as any)[cell.column.id], nextValues, previousValues);\n\n if (updates && Object.keys(updates).length) {\n setPendingChanges(currentChanges =>\n createPendingChangesSetter(\n currentChanges,\n cell.row as unknown as ReactTableRow<TType>,\n rowIndex,\n updates,\n localization\n )\n );\n }\n }\n }, 250),\n []\n ) as unknown as <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) => Promise<void>;\n\n function syncCellChanges<T extends TType>(changes: PendingChanges<T>) {\n updatersRef.current = changes;\n }\n\n return {\n syncCellChanges,\n runCellUpdates,\n };\n}\n\nfunction createPendingChangesSetter<TType = unknown>(\n currentChanges: PendingChanges<TType>,\n row: ReactTableRow<TType>,\n rowIndex: number,\n changes: Partial<TType>,\n localization: Localization\n) {\n // prepare\n const nextChanges: PendingChanges<TType> = { ...currentChanges };\n const rowChanges = {\n ...currentChanges[row.id],\n _meta: {\n ...currentChanges[row.id]?._meta,\n original: row.original,\n moveReason: {\n ...currentChanges[row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[row.id]?._meta.errors,\n },\n },\n } as PendingChange<TType>;\n\n // run changes\n const cells = row._getAllCellsByColumnId();\n\n for (const [accessor, change] of Object.entries(changes)) {\n // update if the change is different to the original (saved) value,\n // otherwise remove any change - no point saving the same value\n if (change !== (row.original as any)[accessor]) {\n (rowChanges as PendingChange)[accessor] = change;\n\n // consumers sometimes include properties in onEditingChange that aren't rendered as columns, we need to guard against that.\n // eslint-disable-next-line no-prototype-builtins\n if (cells.hasOwnProperty(accessor)) {\n // determine if the row will move position based on this change, and save why it will move\n const reason = willRowMove(cells[accessor], change, rowIndex, localization);\n\n if (reason) {\n rowChanges._meta.moveReason[accessor] = reason;\n } else {\n delete rowChanges._meta.moveReason[accessor];\n }\n }\n } else {\n delete rowChanges[accessor];\n delete rowChanges._meta.moveReason[accessor];\n }\n }\n\n // set changes\n // or delete if there are no changes left, so that we don't store changes with unchanged data\n if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {\n nextChanges[row.id] = rowChanges;\n } else {\n delete nextChanges[row.id];\n }\n\n return nextChanges;\n}\n\nfunction getChangesetFromChanges<TType = unknown>(changes: PendingChange<TType>): TType {\n // extract the original data from the row changes\n const { _meta, ...changeset } = changes ?? {};\n // and mix them in with the changes, ready to send to the server\n return { ..._meta?.original, ...changeset };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","validator","isEditing","toggleEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","useLastFocusedCellIndex","pendingChangesFns","usePendingChanges","useGlobalKeyDown","key","meta","shift","undefined","event","preventDefault","saveChanges","rowId","console","warn","Promise","resolve","changesToSave","pendingChanges","changes","Object","keys","length","_forOf","pendingChange","changeSet","getChangesetFromChanges","_catch","_temp3","_result","_exit","then","resetChanges","setRowSaveStatus","getRowSaveStatus","_temp2","errors","error","rowError","cellErrors","Error","_error$response","message","response","data","_error$response2","setPendingChanges","currentChanges","nextChanges","_meta","row","cells","shouldShowErrorAlert","e","reject","validateCell","cell","id","_temp","column","setCellValue","change","rowIndex","createPendingChangesSetter","localization","pendingChangesUpdater","syncCellChanges","runCellUpdates","addCreatedRowChangeset","getAllCells","reduce","getValue","_currentChanges$cell$","_currentChanges$cell$2","_currentChanges$cell$3","original","moveReason","useLocalization","saveStates","setSaveState","getCellValue","_pendingChanges$cell$","getCellError","_pendingChanges$cell$2","_pendingChanges$cell$3","_pendingChanges$cell$4","usePendingChangesUpdater","hasRowErrors","_pendingChanges$rowId","_pendingChanges$rowId2","_pendingChanges$rowId3","_pendingChanges$rowId4","_pendingChanges$rowId5","hasRowErrorsSeen","_pendingChanges$rowId6","getRowPendingChange","rowPendingChanges","status","currentStates","nextStates","getRowMoveReason","_pendingChanges$rowId7","values","hasChanges","hasAlertErrors","getAlertErrors","filter","map","getCompletedRowsCount","value","lastFocusedCellIndexRef","useRef","useCallback","index","current","updatersRef","debounce","previousValues","nextValues","updates","_temp4","rowChanges","_currentChanges$row$i","_currentChanges$row$i2","_currentChanges$row$i3","_getAllCellsByColumnId","accessor","entries","hasOwnProperty","reason","willRowMove","k","changeset"],"mappings":";;;;;;;SAQgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,YAA2D,EAC3DC,SAAsD;;EAGtD,MAAM,CAACC,SAAS,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGxD,MAAM,CAACC,cAAc,EAAEC,kBAAkB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGlE,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGC,uBAAuB,EAAE;;;;EAKjF,MAAMC,iBAAiB,GAAGC,iBAAiB,CAAQd,SAAS,EAAEC,UAAU,EAAEC,YAAY,EAAEC,SAAS,CAAC;EAElGY,gBAAgB,CAACf,SAAS,IAAII,SAAS,GAAG;IAAEY,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE,IAAI;IAAEC,KAAK,EAAE;GAAO,GAAGC,SAAS,EAAEC,KAAK;IAC/FA,KAAK,CAACC,cAAc,EAAE;IACtBR,iBAAiB,CAACS,WAAW,EAAE;GAClC,CAAC;EAEF,OAAO;IACHtB,SAAS;IACTI,SAAS;IACTI,cAAc;IACdC,kBAAkB,EAAET,SAAS,GAAGS,kBAAkB,GAAG,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AC;;;;;EAMpD,IAAI1G,MAAM,CAACC,IAAI,CAACoG,UAAU,CAAC,CAACf,MAAM,CAACyB,CAAC,IAAIA,CAAC,KAAK,OAAO,CAAC,CAAC7G,MAAM,EAAE;IAC3D0B,WAAW,CAACE,GAAG,CAACO,EAAE,CAAC,GAAGgE,UAAU;GACnC,MAAM;IACH,OAAOzE,WAAW,CAACE,GAAG,CAACO,EAAE,CAAC;;EAG9B,OAAOT,WAAW;AACtB;AAEA,SAAStB,uBAAuBA,CAAkBP,OAA6B;;EAE3E,MAAM;IAAE8B,KAAK;IAAE,GAAGmF;GAAW,GAAGjH,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE;;EAE7C,OAAO;IAAE,IAAG8B,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE0B,QAAQ;IAAE,GAAGyD;GAAW;AAC/C;;;;"}
|
1
|
+
{"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { usePendingChangesState } from './useEditingState';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n rowIdentityAccessor: keyof TType | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, setEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = React.useState<number | undefined>(undefined);\n\n const pendingChangesFns = usePendingChangesState<TType>(\n handleSave,\n handleChange,\n rowIdentityAccessor as keyof TType,\n validator\n );\n\n function toggleEditing<T extends TType>(enabled: React.SetStateAction<boolean>, table: ReactTable<T>) {\n if (!enabled) {\n // save\n pendingChangesFns.saveChanges(table);\n // reset detailed mode\n toggleDetailedMode(false);\n // reset the last index back to the first focusable element, when editing gets turned off\n setLastFocusedCellIndex(undefined);\n }\n\n setEditing(enabled);\n }\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","rowIdentityAccessor","validator","isEditing","setEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","undefined","pendingChangesFns","usePendingChangesState","toggleEditing","enabled","table","saveChanges"],"mappings":";;;SAKgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,YAA2D,EAC3DC,mBAA4C,EAC5CC,SAAsD;;EAGtD,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGrD,MAAM,CAACC,cAAc,EAAEC,kBAAkB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGlE,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAqBK,SAAS,CAAC;EAErG,MAAMC,iBAAiB,GAAGC,sBAAsB,CAC5Cd,UAAU,EACVC,YAAY,EACZC,mBAAkC,EAClCC,SAAS,CACZ;EAED,SAASY,aAAaA,CAAkBC,OAAsC,EAAEC,KAAoB;IAChG,IAAI,CAACD,OAAO,EAAE;;MAEVH,iBAAiB,CAACK,WAAW,CAACD,KAAK,CAAC;;MAEpCR,kBAAkB,CAAC,KAAK,CAAC;;MAEzBE,uBAAuB,CAACC,SAAS,CAAC;;IAGtCP,UAAU,CAACW,OAAO,CAAC;;EAGvB,OAAO;IACHjB,SAAS;IACTK,SAAS;IACTI,cAAc;IACdC,kBAAkB,EAAEV,SAAS,GAAGU,kBAAkB,GAAG,MAAMG,SAAS;IACpEG,aAAa,EAAEhB,SAAS,GAAGgB,aAAa,GAAG,MAAMH,SAAS;IAC1DF,oBAAoB;IACpBC,uBAAuB;IACvB,GAAGE;GACN;AACL;;;;"}
|