@economic/taco 2.44.1 → 2.45.0-alpha.0
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 +11 -1
- package/dist/components/Layout/components/Sidebar.d.ts +14 -2
- package/dist/components/Layout/components/Top.d.ts +2 -2
- 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/RadioGroup/RadioGroup.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/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 +2 -2
- package/dist/components/Table3/components/Editing/Alert.d.ts +1 -1
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +2 -2
- package/dist/components/Table3/components/Row/Editing/SaveStatus.d.ts +2 -2
- 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/useTableEditing.d.ts +2 -2
- package/dist/components/Table3/util/editing.d.ts +1 -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/packages/taco/src/components/Accordion/Accordion.js +14 -6
- 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 +5 -3
- 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.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +7 -1
- 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/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/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 +11 -10
- 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 +0 -2
- 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/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/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +1 -1
- 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/Row.js +4 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +5 -2
- 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/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/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/Internal/Expansion.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/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 +3 -1
- 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.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/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.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.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.map +1 -1
- package/dist/primitives/BubbleSelect.d.ts +1 -1
- package/dist/primitives/Sortable/components/Container.d.ts +2 -2
- package/dist/primitives/Sortable/components/Item.d.ts +2 -1
- package/dist/primitives/Sortable/components/List.d.ts +1 -1
- package/dist/primitives/Table/Core/Table.d.ts +2 -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/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 +2 -2
- 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/Core/features/useTableStyle.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +1 -1
- package/dist/taco.cjs.development.js +63 -40
- 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 +1 -1
- package/package.json +11 -13
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Settings.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Menu } from '../../../../../../../components/Menu/Menu';\nimport { HideOrOrderPopover } from './HideOrOrderPopover';\nimport { getSettings } from '../../../../../useTableManager/util/settings';\nimport { FontSizes } from '../../../../../../../types';\nimport { IconName } from '../../../../../../../components/Icon/Icon';\nimport { TableCustomSettingsRenderer } from '../../../../../types';\n\nexport type SettingsProps<TType = unknown> = {\n customSettings?: TableCustomSettingsRenderer;\n table: ReactTable<TType>;\n};\n\nexport function Settings<TType = unknown>(props: SettingsProps<TType>) {\n const { customSettings, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const canHideOrOrder = table.options.enableHiding || tableMeta.columnOrdering.isEnabled;\n const canChangeFontSize = tableMeta.fontSize.isEnabled;\n const canChangeRowHeight = tableMeta.rowHeight.isEnabled;\n\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'columnSettings': {\n if (canHideOrOrder) {\n popoverElement = popoverProps => (\n <HideOrOrderPopover {...popoverProps} open onChange={handleClosePopover} table={table} />\n );\n }\n }\n }\n }\n\n return (\n <IconButton\n aria-label={texts.table.otherOptions.tooltip}\n icon=\"sliders\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <Menu {...menuProps}>\n <Menu.Content align=\"end\">\n {canHideOrOrder ? (\n <Menu.Item icon=\"columns\" onClick={() => setPopover('columnSettings')}>\n {texts.table.columnSettings.button}\n </Menu.Item>\n ) : null}\n {canHideOrOrder && (canChangeRowHeight || canChangeFontSize || customSettings) ? (\n <Menu.Separator />\n ) : null}\n {canChangeRowHeight ? (\n <Menu.Item\n icon={`height-${tableMeta.rowHeight.height}` as IconName}\n subMenu={() => <RowHeightMenuItem tableMeta={tableMeta} />}>\n {texts.table.rowHeight.tooltip}\n </Menu.Item>\n ) : null}\n {canChangeFontSize ? (\n <Menu.Item icon=\"font-size\" subMenu={() => <FontSizeMenuItem tableMeta={tableMeta} />}>\n {texts.table.fontSize.tooltip}\n </Menu.Item>\n ) : null}\n\n {customSettings ? (\n <>\n {canChangeRowHeight || canChangeFontSize ? <Menu.Separator /> : null}\n {customSettings(getSettings(table)).map((item, index) => (\n <React.Fragment key={index}>{item}</React.Fragment>\n ))}\n </>\n ) : null}\n </Menu.Content>\n </Menu>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n tooltip={texts.table.otherOptions.tooltip}\n />\n );\n}\n\nfunction FontSizeMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.fontSize.setSize as any} value={tableMeta.fontSize.size}>\n <Menu.RadioGroup.Item value={FontSizes.small}>{texts.table.fontSize.sizes.small}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value={FontSizes.medium}>{texts.table.fontSize.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item disabled={tableMeta.rowHeight.height === 'short'} value={FontSizes.large}>\n {texts.table.fontSize.sizes.large}\n </Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n\nfunction RowHeightMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.rowHeight.setHeight as any} value={tableMeta.rowHeight.height}>\n <Menu.RadioGroup.Item value=\"short\">{texts.table.rowHeight.sizes.short}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"medium\">{texts.table.rowHeight.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"tall\">{texts.table.rowHeight.sizes.tall}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"extra-tall\">{texts.table.rowHeight.sizes.extraTall}</Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n"],"names":["Settings","props","customSettings","table","texts","useLocalization","tableMeta","options","meta","canHideOrOrder","enableHiding","columnOrdering","isEnabled","canChangeFontSize","fontSize","canChangeRowHeight","rowHeight","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","popoverProps","HideOrOrderPopover","open","onChange","IconButton","otherOptions","tooltip","icon","menu","menuProps","Menu","Content","align","Item","onClick","columnSettings","button","Separator","height","subMenu","RowHeightMenuItem","FontSizeMenuItem","getSettings","map","item","index","Fragment","key","onClickCapture","event","preventDefault","SubMenu","RadioGroup","setSize","value","size","FontSizes","small","sizes","medium","disabled","large","setHeight","short","tall","extraTall"],"mappings":";;;;;;;;SAgBgBA,QAAQA,CAAkBC,KAA2B;EACjE,MAAM;IAAEC,cAAc;IAAEC;GAAO,GAAGF,KAAK;EACvC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAA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D,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAActD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACO,SAAS,CAAwB,CACzF,CACP;AAEvB;;;;"}
|
1
|
+
{"version":3,"file":"Settings.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Menu } from '../../../../../../../components/Menu/Menu';\nimport { HideOrOrderPopover } from './HideOrOrderPopover';\nimport { getSettings } from '../../../../../useTableManager/util/settings';\nimport { FontSizes } from '../../../../../../../types';\nimport { IconName } from '../../../../../../../components/Icon/Icon';\nimport { TableCustomSettingsRenderer } from '../../../../../types';\nimport { PopoverProps } from '../../../../../../../components/Popover/Popover';\n\nexport type SettingsProps<TType = unknown> = {\n customSettings?: TableCustomSettingsRenderer;\n table: ReactTable<TType>;\n};\n\nexport function Settings<TType = unknown>(props: SettingsProps<TType>) {\n const { customSettings, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const canHideOrOrder = table.options.enableHiding || tableMeta.columnOrdering.isEnabled;\n const canChangeFontSize = tableMeta.fontSize.isEnabled;\n const canChangeRowHeight = tableMeta.rowHeight.isEnabled;\n\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'columnSettings': {\n if (canHideOrOrder) {\n popoverElement = (popoverProps: PopoverProps) => (\n <HideOrOrderPopover {...popoverProps} open onChange={handleClosePopover} table={table} />\n );\n }\n }\n }\n }\n\n return (\n <IconButton\n aria-label={texts.table.otherOptions.tooltip}\n icon=\"sliders\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <Menu {...menuProps}>\n <Menu.Content align=\"end\">\n {canHideOrOrder ? (\n <Menu.Item icon=\"columns\" onClick={() => setPopover('columnSettings')}>\n {texts.table.columnSettings.button}\n </Menu.Item>\n ) : null}\n {canHideOrOrder && (canChangeRowHeight || canChangeFontSize || customSettings) ? (\n <Menu.Separator />\n ) : null}\n {canChangeRowHeight ? (\n <Menu.Item\n icon={`height-${tableMeta.rowHeight.height}` as IconName}\n subMenu={() => <RowHeightMenuItem tableMeta={tableMeta} />}>\n {texts.table.rowHeight.tooltip}\n </Menu.Item>\n ) : null}\n {canChangeFontSize ? (\n <Menu.Item icon=\"font-size\" subMenu={() => <FontSizeMenuItem tableMeta={tableMeta} />}>\n {texts.table.fontSize.tooltip}\n </Menu.Item>\n ) : null}\n\n {customSettings ? (\n <>\n {canChangeRowHeight || canChangeFontSize ? <Menu.Separator /> : null}\n {customSettings(getSettings(table)).map((item, index) => (\n <React.Fragment key={index}>{item}</React.Fragment>\n ))}\n </>\n ) : null}\n </Menu.Content>\n </Menu>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n tooltip={texts.table.otherOptions.tooltip}\n />\n );\n}\n\nfunction FontSizeMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.fontSize.setSize as any} value={tableMeta.fontSize.size}>\n <Menu.RadioGroup.Item value={FontSizes.small}>{texts.table.fontSize.sizes.small}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value={FontSizes.medium}>{texts.table.fontSize.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item disabled={tableMeta.rowHeight.height === 'short'} value={FontSizes.large}>\n {texts.table.fontSize.sizes.large}\n </Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n\nfunction RowHeightMenuItem<TType = unknown>({ tableMeta }: { tableMeta: ReactTableMeta<TType> }) {\n const { texts } = useLocalization();\n\n return (\n <Menu.SubMenu>\n <Menu.RadioGroup onChange={tableMeta.rowHeight.setHeight as any} value={tableMeta.rowHeight.height}>\n <Menu.RadioGroup.Item value=\"short\">{texts.table.rowHeight.sizes.short}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"medium\">{texts.table.rowHeight.sizes.medium}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"tall\">{texts.table.rowHeight.sizes.tall}</Menu.RadioGroup.Item>\n <Menu.RadioGroup.Item value=\"extra-tall\">{texts.table.rowHeight.sizes.extraTall}</Menu.RadioGroup.Item>\n </Menu.RadioGroup>\n </Menu.SubMenu>\n );\n}\n"],"names":["Settings","props","customSettings","table","texts","useLocalization","tableMeta","options","meta","canHideOrOrder","enableHiding","columnOrdering","isEnabled","canChangeFontSize","fontSize","canChangeRowHeight","rowHeight","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","popoverProps","HideOrOrderPopover","open","onChange","IconButton","otherOptions","tooltip","icon","menu","menuProps","Menu","Content","align","Item","onClick","columnSettings","button","Separator","height","subMenu","RowHeightMenuItem","FontSizeMenuItem","getSettings","map","item","index","Fragment","key","onClickCapture","event","preventDefault","SubMenu","RadioGroup","setSize","value","size","FontSizes","small","sizes","medium","disabled","large","setHeight","short","tall","extraTall"],"mappings":";;;;;;;;SAiBgBA,QAAQA,CAAkBC,KAA2B;EACjE,MAAM;IAAEC,cAAc;IAAEC;GAAO,GAAGF,KAAK;EACvC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAE7D,MAAMC,cAAc,GAAGN,KAAK,CAACI,OAAO,CAACG,YAAY,IAAIJ,SAAS,CAACK,cAAc,CAACC,SAAS;EACvF,MAAMC,iBAAiB,GAAGP,SAAS,CAACQ,QAAQ,CAACF,SAAS;EACtD,MAAMG,kBAAkB,GA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AS3D,KAAK,CAACD,KAAK,CAACW,QAAQ,CAACgD,KAAK,CAACC,MAAM,CAAwB,eACzG5C,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAAC2B,QAAQ,EAAE1D,SAAS,CAACU,SAAS,CAAC0B,MAAM,KAAK,OAAO;IAAEgB,KAAK,EAAEE,SAAS,CAACK;KACpF7D,KAAK,CAACD,KAAK,CAACW,QAAQ,CAACgD,KAAK,CAACG,KAAK,CACd,CACT,CACP;AAEvB;AAEA,SAASrB,iBAAiBA,CAAkB;EAAEtC;CAAiD;EAC3F,MAAM;IAAEF;GAAO,GAAGC,eAAe,EAAE;EAEnC,oBACIc,6BAACe,IAAI,CAACqB,OAAO,qBACTpC,6BAACe,IAAI,CAACsB,UAAU;IAAC7B,QAAQ,EAAErB,SAAS,CAACU,SAAS,CAACkD,SAAgB;IAAER,KAAK,EAAEpD,SAAS,CAACU,SAAS,CAAC0B;kBACxFvB,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAStD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACK,KAAK,CAAwB,eAC9FhD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAUtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACC,MAAM,CAAwB,eAChG5C,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAAQtD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACM,IAAI,CAAwB,eAC5FjD,6BAACe,IAAI,CAACsB,UAAU,CAACnB,IAAI;IAACqB,KAAK,EAAC;KAActD,KAAK,CAACD,KAAK,CAACa,SAAS,CAAC8C,KAAK,CAACO,SAAS,CAAwB,CACzF,CACP;AAEvB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n // column groups offset the bottom padding :shrug:, multiplying by 1.5 ensures the bottom padding remains\n // consistent when there are groups and when there aren't. 1.5 is relatively arbitrary, but it gives alignment\n const scrollPaddingEnd = ROW_HEIGHT_ESTIMATES.medium * (table.getHeaderGroups().length > 1 ? 1.5 : 1);\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: tableMeta.footer.isEnabled ? scrollPaddingEnd * 2 : scrollPaddingEnd,\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n if (rows.length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n range => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["useTableRenderer","renderers","table","tableRef","defaultRowActiveIndex","tableMeta","options","meta","rows","getRowModel","isTableRowGrouped","_table$getState$group","getState","grouping","length","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","ROW_HEIGHT_ESTIMATES","medium","scrollPaddingEnd","getHeaderGroups","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","footer","isEnabled","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","height","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","rowHeight","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;SAagBA,gBAAgBA,CAC5BC,SAAmC,EACnCC,KAAwB,EACxBC,QAAmC,EACnCC,qBAA0C;;EAE1C,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,IAAI,GAAGN,KAAK,CAACO,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,iBAAiB,GAAG,CAAC,GAAAC,qBAAA,GA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GAAGC,CAAC,CAAC;GACzC,EACD,CAACS,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAGhF,cAAc,GAAGe,SAAS;AACtD;;;;"}
|
1
|
+
{"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n // column groups offset the bottom padding :shrug:, multiplying by 1.5 ensures the bottom padding remains\n // consistent when there are groups and when there aren't. 1.5 is relatively arbitrary, but it gives alignment\n const scrollPaddingEnd = ROW_HEIGHT_ESTIMATES.medium * (table.getHeaderGroups().length > 1 ? 1.5 : 1);\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: tableMeta.footer.isEnabled ? scrollPaddingEnd * 2 : scrollPaddingEnd,\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n if (rows.length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["useTableRenderer","renderers","table","tableRef","defaultRowActiveIndex","tableMeta","options","meta","rows","getRowModel","isTableRowGrouped","_table$getState$group","getState","grouping","length","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","ROW_HEIGHT_ESTIMATES","medium","scrollPaddingEnd","getHeaderGroups","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","footer","isEnabled","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","height","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","rowHeight","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;SAcgBA,gBAAgBA,CAC5BC,SAAmC,EACnCC,KAAwB,EACxBC,QAAmC,EACnCC,qBAA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C,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACxB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACS,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAGhF,cAAc,GAAGe,SAAS;AACtD;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAkHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string: any) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAkHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchAll(sorting, filters);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, _lastUsedFilters.current);\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(sorting, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(_lastUsedSorting.current, filters);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","_lastUsedPageIndex$cu2","handleFilter","_lastUsedPageIndex$cu3","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA2BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAAC,EAAE,CAAC;EAC7C,MAAMM,gBAAgB,GAAGP,cAAK,CAACC,MAAM,CAAoB,EAAE,CAAC;EAC5D,MAAMO,gBAAgB,GAAGR,cAAK,CAACC,MAAM,CAAsB,EAAE,CAAC;EAC9D,MAAMQ,eAAe,GAAGT,cAAK,CAACC,MAAM,EAAU;EAC9C,MAAMS,kBAAkB,GAAGV,cAAK,CAACC,MAAM,EAAU;EACjD,MAAMU,WAAW,GAAGX,cAAK,CAACC,MAAM,CAAC,KAAK,CAAC;EAEvC,MAAMW,QAAQ,aAAUC,SAAiB,EAAEC,OAA0B,EAAEC,OAA4B;IAAA;MAC/F,IAAIC,KAAK,GAAG,KAAK;;MAGjB,IACIL,WAAW,CAACM,OAAO,IACnBC,IAAI,CAACC,SAAS,CAACL,OAAO,CAAC,KAAKI,IAAI,CAACC,SAAS,CAACZ,gBAAgB,CAACU,OAAO,CAAC,IACpEC,IAAI,CAACC,SAAS,CAACJ,OAAO,CAAC,KAAKG,IAAI,CAACC,SAAS,CAACX,gBAAgB,CAACS,OAAO,CAA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,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDrC,eAAe,CAACQ,OAAO,GAAG6B,MAAM,IAAI5C,SAAS;;;MAE7C,OAAAkB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIhC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACkB,OAAO;IACtBoB,OAAO;IACPzB,QAAQ;IACRmC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB3C;GACH,EACDyC,UAAU,CACb;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchAll(sorting, filters);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, _lastUsedFilters.current);\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(sorting, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(_lastUsedSorting.current, filters);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","_lastUsedPageIndex$cu2","handleFilter","_lastUsedPageIndex$cu3","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA2BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAA0B,EAAE,CAAC;EACtE,MAAMM,gBAAgB,GAAGP,cAAK,CAACC,MAAM,CAAoB,EAAE,CAAC;EAC5D,MAAMO,gBAAgB,GAAGR,cAAK,CAACC,MAAM,CAAsB,EAAE,CAAC;EAC9D,MAAMQ,eAAe,GAAGT,cAAK,CAACC,MAAM,EAAU;EAC9C,MAAMS,kBAAkB,GAAGV,cAAK,CAACC,MAAM,EAAU;EACjD,MAAMU,WAAW,GAAGX,cAAK,CAACC,MAAM,CAAC,KAAK,CAAC;EAEvC,MAAMW,QAAQ,aAA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eAAe,CAACQ,OAAO,EAAE;;QAEzBoB,OAAO,CAAC9B,gBAAgB,CAACU,OAAO,EAAEF,OAAO,CAAC;OAC7C,MAAM;QAAA,IAAA6B,sBAAA;;QAEHhC,QAAQ,EAAAgC,sBAAA,GAAClC,kBAAkB,CAACO,OAAO,cAAA2B,sBAAA,cAAAA,sBAAA,GAAI,CAAC,EAAErC,gBAAgB,CAACU,OAAO,EAAEF,OAAO,CAAC;;MAC/E,OAAAK,OAAA,CAAAC,OAAA;KACJ,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDrC,eAAe,CAACQ,OAAO,GAAG6B,MAAM,IAAI5C,SAAS;;;MAE7C,OAAAkB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIhC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACkB,OAAO;IACtBoB,OAAO;IACPzB,QAAQ;IACRmC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB3C;GACH,EACDyC,UAAU,CACb;AACL;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSettings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSettings.ts"],"sourcesContent":["import React from 'react';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nexport function useUniqueTableId(tableId: string) {\n const tacoSettings = useTacoSettings();\n return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;\n}\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nexport function useTableSettings(\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false,\n id: string,\n defaultSettings: TableSettings | undefined = {},\n onChangeSettings: TableSettingsHandler | undefined\n): [TableSettings, TableSettingsHandler] {\n const uniqueId = useUniqueTableId(id);\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n\n const [persistedSettings, _setPersistedSettings] = useLocalStorage<TableSettings>(\n hasSomeEnabledSettings ? uniqueId : undefined,\n removeDisabledSettings(defaultSettings, enabledSettings)\n );\n\n const setPersistedSettings = React.useCallback(\n (value: TableSettings) => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const sanitizedSettings = removeDisabledSettings(value, enabledSettings);\n _setPersistedSettings(sanitizedSettings);\n\n if (typeof onChangeSettings === 'function') {\n onChangeSettings(sanitizedSettings);\n }\n },\n [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]\n );\n\n if (!hasSomeEnabledSettings) {\n return [defaultSettings, () => undefined];\n }\n\n return [persistedSettings, setPersistedSettings];\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting]) {\n delete sanitizedSettings[setting];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["DEFAULT_ENABLED_OPTIONS","columnOrder","columnPinning","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","grouping","rowHeight","sorting","useUniqueTableId","tableId","tacoSettings","useTacoSettings","uniqueUserIdentifier","useEnabledSettings","isEnabled","React","useMemo","Object","keys","reduce","o","key","options","values","some","useTableSettings","id","defaultSettings","onChangeSettings","uniqueId","enabledSettings","hasSomeEnabledSettings","persistedSettings","_setPersistedSettings","useLocalStorage","undefined","removeDisabledSettings","setPersistedSettings","useCallback","value","sanitizedSettings","JSON","stringify","settings","forEach","setting"],"mappings":";;;;AAKA,MAAMA,uBAAuB,GAAG;EAC5BC,WAAW,EAAE,IAAI;EACjBC,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,+BAA+B,EAAE,IAAI;EACrCC,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE;CACZ;SAEeC,gBAAgBA,CAACC,OAAe;EAC5C,MAAMC,YAAY,GAAGC,eAAe,EAAE;EACtC,OAAO,QAAQD,YAAY,CAACE,oBAAoB,UAAUH,OAAO,WAAW;AAChF;AAEA,SAASI,kBAAkBA,CAACC,SAAwD;EAChF,OAAOC,cAAK,CAACC,OAAO,CAAC;IACjB,IAAIF,SAAS,KAAK,KAAK,EAAE;MACrB,OAAO,CACHG,MAAM,CAACC,IAAI,CAACpB,uBAAuB,CAAC,CAACqB,MAAM,CACvC,CAACC,CAAC,EAAEC,GAAG,MAAM;QAAE,GAAGD,CAAC;QAAE,CAACC,GAAG,GAAG;OAAO,CAAC,EACpC,EAAE,CACyB,EAC/B,KAAK,CACR;KACJ,MAAM,IAAIP,SAAS,KAAK,IAAI,EAAE;MAC3B,OAAO,CAAChB,uBAA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,eAA2C;EAChG,MAAMU,iBAAiB,GAAkB;IAAE,GAAGG;GAAU;EAExD1B,MAAM,CAACC,IAAI,CAACY,eAAe,CAAC,CAACc,OAAO,CAACC,OAAO;IACxC,IAAI,CAACf,eAAe,CAACe,
|
1
|
+
{"version":3,"file":"useTableSettings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSettings.ts"],"sourcesContent":["import React from 'react';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nexport function useUniqueTableId(tableId: string) {\n const tacoSettings = useTacoSettings();\n return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;\n}\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nexport function useTableSettings(\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false,\n id: string,\n defaultSettings: TableSettings | undefined = {},\n onChangeSettings: TableSettingsHandler | undefined\n): [TableSettings, TableSettingsHandler] {\n const uniqueId = useUniqueTableId(id);\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n\n const [persistedSettings, _setPersistedSettings] = useLocalStorage<TableSettings>(\n hasSomeEnabledSettings ? uniqueId : undefined,\n removeDisabledSettings(defaultSettings, enabledSettings)\n );\n\n const setPersistedSettings = React.useCallback(\n (value: TableSettings) => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const sanitizedSettings = removeDisabledSettings(value, enabledSettings);\n _setPersistedSettings(sanitizedSettings);\n\n if (typeof onChangeSettings === 'function') {\n onChangeSettings(sanitizedSettings);\n }\n },\n [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]\n );\n\n if (!hasSomeEnabledSettings) {\n return [defaultSettings, () => undefined];\n }\n\n return [persistedSettings, setPersistedSettings];\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting as keyof TableEnableSettingsOptions]) {\n delete sanitizedSettings[setting as keyof TableSettings];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["DEFAULT_ENABLED_OPTIONS","columnOrder","columnPinning","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","grouping","rowHeight","sorting","useUniqueTableId","tableId","tacoSettings","useTacoSettings","uniqueUserIdentifier","useEnabledSettings","isEnabled","React","useMemo","Object","keys","reduce","o","key","options","values","some","useTableSettings","id","defaultSettings","onChangeSettings","uniqueId","enabledSettings","hasSomeEnabledSettings","persistedSettings","_setPersistedSettings","useLocalStorage","undefined","removeDisabledSettings","setPersistedSettings","useCallback","value","sanitizedSettings","JSON","stringify","settings","forEach","setting"],"mappings":";;;;AAKA,MAAMA,uBAAuB,GAAG;EAC5BC,WAAW,EAAE,IAAI;EACjBC,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,+BAA+B,EAAE,IAAI;EACrCC,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,I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K,CAACuB,WAAW,CACzCC,KAAoB;IACjB,IAAI,CAACR,sBAAsB,EAAE;MACzB;;IAGJ,MAAMS,iBAAiB,GAAGJ,sBAAsB,CAACG,KAAK,EAAET,eAAe,CAAC;IACxEG,qBAAqB,CAACO,iBAAiB,CAAC;IAExC,IAAI,OAAOZ,gBAAgB,KAAK,UAAU,EAAE;MACxCA,gBAAgB,CAACY,iBAAiB,CAAC;;GAE1C,EACD,CAACT,sBAAsB,EAAEH,gBAAgB,EAAEa,IAAI,CAACC,SAAS,CAACZ,eAAe,CAAC,CAAC,CAC9E;EAED,IAAI,CAACC,sBAAsB,EAAE;IACzB,OAAO,CAACJ,eAAe,EAAE,MAAMQ,SAAS,CAAC;;EAG7C,OAAO,CAACH,iBAAiB,EAAEK,oBAAoB,CAAC;AACpD;AAEA,SAASD,sBAAsBA,CAACO,QAAuB,EAAEb,eAA2C;EAChG,MAAMU,iBAAiB,GAAkB;IAAE,GAAGG;GAAU;EAExD1B,MAAM,CAACC,IAAI,CAACY,eAAe,CAAC,CAACc,OAAO,CAACC,OAAO;IACxC,IAAI,CAACf,eAAe,CAACe,OAA2C,CAAC,EAAE;MAC/D,OAAOL,iBAAiB,CAACK,OAA8B,CAAC;;GAE/D,CAAC;EAEF,OAAOL,iBAAiB;AAC5B;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableSettingsHandler } from '../../types';\nimport { getSettings } from '../util/settings';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n onChangeSettings: TableSettingsHandler | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n onChangeSettings(getSettings(table));\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n table.options.enableGlobalFilter,\n meta.fontSize.size,\n //state.grouping,\n meta.rowHeight.height,\n //state.globalFilter,\n state.sorting,\n ]);\n}\n"],"names":["useTableSettingsListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnOrder","columnPinning","columnSizing","columnVisibility","enableGlobalFilter","fontSize","size","rowHeight","height","sorting"],"mappings":";;;SAKgBA,wBAAwBA,CACpCC,KAAwB,EACxBC,gBAAkD;EAElD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,
|
1
|
+
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableSettingsHandler } from '../../types';\nimport { getSettings } from '../util/settings';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n onChangeSettings: TableSettingsHandler | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler: NodeJS.Timeout;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n onChangeSettings(getSettings(table));\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n table.options.enableGlobalFilter,\n meta.fontSize.size,\n //state.grouping,\n meta.rowHeight.height,\n //state.globalFilter,\n state.sorting,\n ]);\n}\n"],"names":["useTableSettingsListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnOrder","columnPinning","columnSizing","columnVisibility","enableGlobalFilter","fontSize","size","rowHeight","height","sorting"],"mappings":";;;SAKgBA,wBAAwBA,CACpCC,KAAwB,EACxBC,gBAAkD;EAElD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAuB;IAE3B,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;;QAEjBR,gBAAgB,CAACS,WAAW,CAACV,KAAK,CAAC,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMW,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECJ,KAAK,CAACQ,WAAW,EACjBR,KAAK,CAACS,aAAa,EACnBT,KAAK,CAACU,YAAY,EAClBV,KAAK,CAACW,gBAAgB,EACtBf,KAAK,CAACG,OAAO,CAACa,kBAAkB,EAChCd,IAAI,CAACe,QAAQ,CAACC,IAAI;;EAElBhB,IAAI,CAACiB,SAAS,CAACC,MAAM;;EAErBhB,KAAK,CAACiB,OAAO,CAChB,CAAC;AACN;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler
|
1
|
+
{"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerFn, TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler: TableShortcutHandlerFn<TType>;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as TableShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(rowActive?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);\n}\n"],"names":["useTableShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","rowActive","rowActiveIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,KAAwB,EACxBC,SAA4C;EAE5C,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IACjD,MAAMU,cAAc,GAA0C,EAAE;;IAGhE,IAAIV,SAAS,IAAIO,YAAY,CAACI,MAAM,IAAIV,IAAI,CAACW,SAAS,CAACC,cAAc,KAAKC,SAAS,EAAE;MACjF,MAAMF,SAAS,GAAGT,IAAI,CAACF,IAAI,CAACW,SAAS,CAACC,cAAc,CAAC;MAErDN,YAAY,CAACQ,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGjB,SAAS,CAACgB,GAAG,CAAC;QAE9B,IAAIE,cAA6C;QACjD,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA4C;UAClEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHf,IAAI,EAAEmB,aAAa,CAACnB,IAAI;YACxBoB,KAAK,EAAED,aAAa,CAACC;WACxB;;QAGLX,cAAc,CAACY,IAAI,CACfC,4BAA4B,CAACJ,qBAAqB,EAAEK,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBP,cAAc,CAACN,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEc,QAAQ,CAAC;SACtC,CAAC,CACL;OACJ,CAAC;;IAGNhB,cAAc,CAACK,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHP,cAAc,CAACK,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAACjB,SAAS,EAAEC,IAAI,CAACW,SAAS,CAACC,cAAc,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AAC/D;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityColumnId?: string;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityColumnId: props.rowIdentityColumnId,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityColumnId","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNL,KAAK,CAACc,eAAe,EACrBd,KAAK,CAACe,gBAAgB,CACzB;;EAGD,MAAMC,IAAI,IAAAC,WAAA,GAAGjB,KAAK,CAACgB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAInB,mBAAmB;EAC9C,MAAMoB,MAAM,IAAAC,aAAA,GAAGnB,KAAK,CAACkB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,G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EP,CAAC;;EAGFgB,oBAAoB,CAACN,QAAQ,CAAC;EAC9BO,sBAAsB,CAACP,QAAQ,EAAEzF,KAAK,CAACiG,cAAc,CAAC;EACtDC,wBAAwB,CAACT,QAAQ,CAAC;EAClCU,yBAAyB,CAACV,QAAQ,CAAC;EACnCW,4BAA4B,CAACX,QAAQ,EAAEzF,KAAK,CAACqG,WAAW,CAAC;EACzDC,sBAAsB,CAACb,QAAQ,EAAEzF,KAAK,CAACuG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDwB,wBAAwB,CAAChB,QAAQ,EAAE9E,WAAW,CAAC;EAC/C+F,yBAAyB,CAACjB,QAAQ,EAAEzF,KAAK,CAAC2G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAEzF,KAAK,CAAC6G,YAAY,CAAC;EAErD,OAAO;IACHvG,EAAE,EAAED,MAAM;IACVoF,QAAQ;IACRxF,IAAI,GAAA6G,qBAAA,GAAGrB,QAAQ,CAACjF,OAAO,CAACP,IAAI,cAAA6G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityColumnId?: string;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY: any[] = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityColumnId: props.rowIdentityColumnId,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityColumnId","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA;AACA,MAAMA,mBAAmB,GAAU,EAAE;SAErBC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNL,KAAK,CAACc,eAAe,EACrBd,KAAK,CAACe,gBAAgB,CACzB;;EAGD,MAAMC,IAAI,IAAAC,WAAA,GAAGjB,KAAK,CAACgB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAInB,mBAAmB;EAC9C,MAAMoB,MAAM,IAAAC,aAAA,GAAGnB,KAAK,CAACkB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OA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C3BG,SAAS;MACTG,YAAY;MACZG,MAAM;MACNI;;GAEP,CAAC;;EAGFgB,oBAAoB,CAACN,QAAQ,CAAC;EAC9BO,sBAAsB,CAACP,QAAQ,EAAEzF,KAAK,CAACiG,cAAc,CAAC;EACtDC,wBAAwB,CAACT,QAAQ,CAAC;EAClCU,yBAAyB,CAACV,QAAQ,CAAC;EACnCW,4BAA4B,CAACX,QAAQ,EAAEzF,KAAK,CAACqG,WAAW,CAAC;EACzDC,sBAAsB,CAACb,QAAQ,EAAEzF,KAAK,CAACuG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDwB,wBAAwB,CAAChB,QAAQ,EAAE9E,WAAW,CAAC;EAC/C+F,yBAAyB,CAACjB,QAAQ,EAAEzF,KAAK,CAAC2G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAEzF,KAAK,CAAC6G,YAAY,CAAC;EAErD,OAAO;IACHvG,EAAE,EAAED,MAAM;IACVoF,QAAQ;IACRxF,IAAI,GAAA6G,qBAAA,GAAGrB,QAAQ,CAACjF,OAAO,CAACP,IAAI,cAAA6G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { isWeakContains } from './filtering';\nimport { getDataTypeProperties } from './dataTypes';\nimport { TableColumnDataType } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nconst flattenCellValue = (cellValue: object | string) => {\n return typeof cellValue === 'object' ? Object.values(cellValue).map(flattenCellValue) : cellValue;\n};\n\nexport function isMatched<TType = unknown>(\n searchQuery: string,\n cellValue: any,\n dataType: TableColumnDataType | undefined,\n localization: Localization\n) {\n if (typeof cellValue === 'object') {\n return flattenCellValue(cellValue)\n .flat(Infinity)\n .find(y => isWeakContains(y, searchQuery));\n } else {\n const cellValueAsString = String(cellValue ?? '');\n\n if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {\n return true;\n } else {\n const dataTypeProperties = getDataTypeProperties<TType>(dataType);\n\n if (dataTypeProperties.getDisplayValue) {\n const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });\n\n if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport function globalFilterFn<TType = unknown>(\n row: ReactTableRow<TType>,\n columnId: string,\n searchQuery: string,\n localization: Localization\n) {\n try {\n if (row.original) {\n const cellValue = row.original[columnId];\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n return isMatched(searchQuery, cellValue, dataType, localization);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n\nexport function resetHighlightedColumnIndexes<TType = unknown>(\n searchQuery: string | undefined,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (searchQuery) {\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n const rowGrouping = table.getState().grouping;\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n let allowSearch = true;\n\n if (rowGrouping?.length) {\n // if it's the grouped row, only allow search of the grouped column - because that's all that's visible\n if (row.getIsGrouped()) {\n allowSearch = column.getIsGrouped();\n }\n // otherwise for other rows, don't search the grouped column - because it isn't visible\n else if (rowGrouping.includes(column.id)) {\n allowSearch = false;\n }\n }\n\n if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {\n const cellValue = get(row.original, column.id);\n const dataType = column.columnDef.meta?.dataType;\n\n if (isMatched(searchQuery, cellValue, dataType, localization)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["flattenCellValue","cellValue","Object","values","map","isMatched","searchQuery","dataType","localization","flat","Infinity","find","y","isWeakContains","cellValueAsString","String","undefined","dataTypeProperties","getDataTypeProperties","getDisplayValue","cellDisplayValue","globalFilterFn","row","columnId","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","_getAllCellsByColumnId","column","columnDef","meta","resetHighlightedColumnIndexes","table","tableMeta","options","firstRowIndex","indexes","columns","getVisibleLeafColumns","rowGrouping","getState","grouping","getRowModel","rows","forEach","rowIndex","columnIndex","allowSearch","length","getIsGrouped","includes","id","getIsVisible","enableGlobalFilter","_column$columnDef$met","get","push","e","search","setHighlightedColumnIndexes","setCurrentHighlightColumnIndex","rowActive","setRowActiveIndex"],"mappings":";;;;AAOA,MAAMA,gBAAgB,GAAIC,SAA0B;EAChD,OAAO,OAAOA,SAAS,KAAK,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACF,SAAS,CAAC,CAACG,GAAG,CAACJ,gBAAgB,CAAC,GAAGC,SAAS;AACrG,CAAC;SAEeI,SAASA,CACrBC,WAAmB,EACnBL,SAAc,EACdM,QAAyC,EACzCC,YAA0B;EAE1B,IAAI,OAAOP,SAAS,KAAK,QAAQ,EAAE;IAC/B,OAAOD,gBAAgB,CAACC,SAAS,CAAC,CAC7BQ,IAAI,CAACC,QAAQ,CAAC,CACdC,IAAI,CAACC,CAAC,IAAIC,cAAc,CAACD,CAAC,EAAEN,WAAW,CAAC,CAAC;GACjD,MAAM;IACH,MAAMQ,iBAAiB,GAAGC,MAAM,CAACd,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IAEjD,IAAIa,iBAAiB,KAAKE,SAAS,IAAIH,cAAc,CAACC,iBAAiB,EAAER,WAAW,CAAC,EAAE;MACnF,OAAO,IAAI;KACd,MAAM;MACH,MAAMW,kBAAkB,GAAGC,qBAAqB,CAAQX,QAAQ,CAAC;MAEjE,IAAIU,kBAAkB,CAACE,eAAe,EAAE;QACpC,MAAMC,gBAAgB,GAAGH,kBAAkB,CAACE,eAAe,CAAClB,SAAS,EAAE;UAAEO;SAAc,CAAC;QAExF,IAAIY,gBAAgB,KAAKJ,SAAS,IAAIH,cAAc,CAACO,gBAAgB,EAAEd,WAAW,CAAC,EAAE;UACjF,OAAO,IAAI;;;;;EAM3B,OAAO,KAAK;AAChB;SAEgBe,cAAcA,CAC1BC,GAAyB,EACzBC,QAAgB,EAChBjB,WAAmB,EACnBE,YAA0B;EAE1B,IAAI;IACA,IAAIc,GAAG,CAACE,QAAQ,EAAE;MAAA,IAAAC,qBAAA,EAAAC,sBAAA;MACd,MAAMzB,SAAS,
|
1
|
+
{"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { isWeakContains } from './filtering';\nimport { getDataTypeProperties } from './dataTypes';\nimport { TableColumnDataType } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nconst flattenCellValue = (cellValue: object | string) => {\n return typeof cellValue === 'object' ? Object.values(cellValue).map(flattenCellValue) : cellValue;\n};\n\nexport function isMatched<TType = unknown>(\n searchQuery: string,\n cellValue: any,\n dataType: TableColumnDataType | undefined,\n localization: Localization\n) {\n if (typeof cellValue === 'object') {\n return flattenCellValue(cellValue)\n .flat(Infinity)\n .find(y => isWeakContains(y, searchQuery));\n } else {\n const cellValueAsString = String(cellValue ?? '');\n\n if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {\n return true;\n } else {\n const dataTypeProperties = getDataTypeProperties<TType>(dataType);\n\n if (dataTypeProperties.getDisplayValue) {\n const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });\n\n if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport function globalFilterFn<TType = unknown>(\n row: ReactTableRow<TType>,\n columnId: string,\n searchQuery: string,\n localization: Localization\n) {\n try {\n if (row.original) {\n const cellValue = (row.original as any)[columnId];\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n return isMatched(searchQuery, cellValue, dataType, localization);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n\nexport function resetHighlightedColumnIndexes<TType = unknown>(\n searchQuery: string | undefined,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (searchQuery) {\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n const rowGrouping = table.getState().grouping;\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n let allowSearch = true;\n\n if (rowGrouping?.length) {\n // if it's the grouped row, only allow search of the grouped column - because that's all that's visible\n if (row.getIsGrouped()) {\n allowSearch = column.getIsGrouped();\n }\n // otherwise for other rows, don't search the grouped column - because it isn't visible\n else if (rowGrouping.includes(column.id)) {\n allowSearch = false;\n }\n }\n\n if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {\n const cellValue = get(row.original, column.id);\n const dataType = column.columnDef.meta?.dataType;\n\n if (isMatched(searchQuery, cellValue, dataType, localization)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["flattenCellValue","cellValue","Object","values","map","isMatched","searchQuery","dataType","localization","flat","Infinity","find","y","isWeakContains","cellValueAsString","String","undefined","dataTypeProperties","getDataTypeProperties","getDisplayValue","cellDisplayValue","globalFilterFn","row","columnId","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","_getAllCellsByColumnId","column","columnDef","meta","resetHighlightedColumnIndexes","table","tableMeta","options","firstRowIndex","indexes","columns","getVisibleLeafColumns","rowGrouping","getState","grouping","getRowModel","rows","forEach","rowIndex","columnIndex","allowSearch","length","getIsGrouped","includes","id","getIsVisible","enableGlobalFilter","_column$columnDef$met","get","push","e","search","setHighlightedColumnIndexes","setCurrentHighlightColumnIndex","rowActive","setRowActiveIndex"],"mappings":";;;;AAOA,MAAMA,gBAAgB,GAAIC,SAA0B;EAChD,OAAO,OAAOA,SAAS,KAAK,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACF,SAAS,CAAC,CAACG,GAAG,CAACJ,gBAAgB,CAAC,GAAGC,SAAS;AACrG,CAAC;SAEeI,SAASA,CACrBC,WAAmB,EACnBL,SAAc,EACdM,QAAyC,EACzCC,YAA0B;EAE1B,IAAI,OAAOP,SAAS,KAAK,QAAQ,EAAE;IAC/B,OAAOD,gBAAgB,CAACC,SAAS,CAAC,CAC7BQ,IAAI,CAACC,QAAQ,CAAC,CACdC,IAAI,CAACC,CAAC,IAA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AAC,OAAOW,CAAC,EAAE;;;OAGf,CAAC;KACL,CAAC;IAEFxB,SAAS,CAACyB,MAAM,CAACC,2BAA2B,CAACvB,OAAO,CAAC;IAErD,IAAIA,OAAO,CAACY,MAAM,EAAE;MAChBb,aAAa,GAAGC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MAC7BH,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC,CAAC,CAAC;KACrD,MAAM;MACH3B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;GAEjE,MAAM;IACHiB,SAAS,CAACyB,MAAM,CAACC,2BAA2B,CAAC,EAAE,CAAC;IAChD1B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;EAG9D,IAAImB,aAAa,KAAKnB,SAAS,EAAE;IAC7BiB,SAAS,CAAC4B,SAAS,CAACC,iBAAiB,CAAC3B,aAAa,CAAC;;EAGxD,OAAOA,aAAa;AACxB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data:
|
1
|
+
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data: Record<string, any>) {\n return Object.keys(data).reduce((accum, key) => {\n if (isInternalColumn(key)) {\n return accum;\n }\n\n return {\n ...accum,\n [key]: data[key],\n };\n }, {});\n}\n"],"names":["getSettings","table","meta","options","state","getState","columnOrder","columnOrdering","isEnabled","undefined","columnPinning","columnSizing","ignoreInternalColumns","columnVisibility","enableHiding","excludeUnmatchedRecordsInSearch","enableGlobalFilter","fontSize","size","rowHeight","height","sorting","data","Object","keys","reduce","accum","key","isInternalColumn"],"mappings":";;SAGgBA,WAAWA,CAAkBC,KAAwB;EACjE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGH,KAAK,CAACI,QAAQ,EAAE;EAE9B,OAAO;;;IAGHC,WAAW,EAAEJ,IAAI,CAACK,cAAc,CAACC,SAAS,GAAGJ,KAAK,CAACE,WAAW,GAAGG,SAAS;IAC1EC,aAAa,EAAEN,KAAK,CAACM,aAAa;IAClCC,YAAY,EAAEC,qBAAqB,CAACR,KAAK,CAACO,YAAY,CAAC;IACvDE,gBAAgB,EAAEZ,KAAK,CAACE,OAAO,CAACW,YAAY,GAAGV,KAAK,CAACS,gBAAgB,GAAGJ,SAAS;IACjFM,+BAA+B,EAAEd,KAAK,CAACE,OAAO,CAACa,kBAAkB;IACjEC,QAAQ,EAAEf,IAAI,CAACe,QAAQ,CAACT,SAAS,GAAGN,IAAI,CAACe,QAAQ,CAACC,IAAI,GAAGT,SAAS;;IAElEU,SAAS,EAAEjB,IAAI,CAACiB,SAAS,CAACX,SAAS,GAAGN,IAAI,CAACiB,SAAS,CAACC,MAAM,GAAGX,SAAS;;IAEvEY,OAAO,EAAEjB,KAAK,CAACiB;GAClB;AACL;SAEgBT,qBAAqBA,CAACU,IAAyB;EAC3D,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG;IACvC,IAAIC,gBAAgB,CAACD,GAAG,CAAC,EAAE;MACvB,OAAOD,KAAK;;IAGhB,OAAO;MACH,GAAGA,KAAK;MACR,CAACC,GAAG,GAAGL,IAAI,CAACK,GAAG;KAClB;GACJ,EAAE,EAAE,CAAC;AACV;;;;"}
|