@economic/taco 0.0.15-alpha.0 → 0.0.18-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -84
- package/dist/esm/components/Accordion/Accordion.js +3 -3
- package/dist/esm/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/components/Backdrop/Backdrop.js.map +1 -1
- package/dist/esm/components/Badge/Badge.js.map +1 -1
- package/dist/esm/components/Banner/Banner.js.map +1 -1
- package/dist/esm/components/Banner/util.js +1 -1
- package/dist/esm/components/Banner/util.js.map +1 -1
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Button/util.js +18 -23
- package/dist/esm/components/Button/util.js.map +1 -1
- package/dist/esm/components/Calendar/Calendar.js.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/components/Combobox/useCombobox.js +64 -84
- package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/components/Datepicker/useDatepicker.js +27 -34
- package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/components/Dialog/Context.js +3 -3
- package/dist/esm/components/Dialog/Context.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +1 -1
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/components/Content.js +39 -44
- package/dist/esm/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/components/Dialog/components/Drawer.js +3 -3
- package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
- package/dist/esm/components/Dialog/components/Extra.js +2 -2
- package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
- package/dist/esm/components/Dialog/components/Trigger.js +2 -2
- package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
- package/dist/esm/components/Field/Field.js.map +1 -1
- package/dist/esm/components/Form/Form.js.map +1 -1
- package/dist/esm/components/Group/Group.js.map +1 -1
- package/dist/esm/components/Hanger/Hanger.js +3 -3
- package/dist/esm/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/components/Icon/Icon.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountPreview.js.map +1 -1
- package/dist/esm/components/Icon/components/Accounting.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountingYear.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountingYearCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowBottom.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowEnd.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowRight.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowStart.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowTop.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowUp.js.map +1 -1
- package/dist/esm/components/Icon/components/Attach.js.map +1 -1
- package/dist/esm/components/Icon/components/AttachAuto.js.map +1 -1
- package/dist/esm/components/Icon/components/AttachCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/Autotext.js.map +1 -1
- package/dist/esm/components/Icon/components/AutotextInsert.js.map +1 -1
- package/dist/esm/components/Icon/components/Basic.js.map +1 -1
- package/dist/esm/components/Icon/components/BasicTabs.js.map +1 -1
- package/dist/esm/components/Icon/components/BellSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Book.js.map +1 -1
- package/dist/esm/components/Icon/components/Booking.js.map +1 -1
- package/dist/esm/components/Icon/components/Budget.js.map +1 -1
- package/dist/esm/components/Icon/components/Calendar.js.map +1 -1
- package/dist/esm/components/Icon/components/CashAccount.js.map +1 -1
- package/dist/esm/components/Icon/components/CashReports.js.map +1 -1
- package/dist/esm/components/Icon/components/Chat.js.map +1 -1
- package/dist/esm/components/Icon/components/ChatSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDownDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDownSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronLeftDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronRight.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronRightDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUp.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUpDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUpSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Clamp.js.map +1 -1
- package/dist/esm/components/Icon/components/ClampOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/Close.js.map +1 -1
- package/dist/esm/components/Icon/components/ConnectionEnable.js.map +1 -1
- package/dist/esm/components/Icon/components/ConnectionRevoke.js.map +1 -1
- package/dist/esm/components/Icon/components/Contacts.js.map +1 -1
- package/dist/esm/components/Icon/components/Copy.js.map +1 -1
- package/dist/esm/components/Icon/components/Courses.js.map +1 -1
- package/dist/esm/components/Icon/components/Credit.js.map +1 -1
- package/dist/esm/components/Icon/components/Delete.js.map +1 -1
- package/dist/esm/components/Icon/components/DeletePermanently.js.map +1 -1
- package/dist/esm/components/Icon/components/Depecriate.js.map +1 -1
- package/dist/esm/components/Icon/components/Developer.js.map +1 -1
- package/dist/esm/components/Icon/components/DistributionTemplate.js.map +1 -1
- package/dist/esm/components/Icon/components/Document.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentApprove.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentCreateEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentCut.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentError.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentIsolatePage.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentMerge.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentMove.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentPreview.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentReceived.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentRejectedRequest.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentSplit.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentTime.js.map +1 -1
- package/dist/esm/components/Icon/components/Download.js.map +1 -1
- package/dist/esm/components/Icon/components/Drag.js.map +1 -1
- package/dist/esm/components/Icon/components/ECopedia.js.map +1 -1
- package/dist/esm/components/Icon/components/ESignature.js.map +1 -1
- package/dist/esm/components/Icon/components/Edit.js.map +1 -1
- package/dist/esm/components/Icon/components/EllipsisHorizontal.js.map +1 -1
- package/dist/esm/components/Icon/components/EllipsisVertical.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesOnAccount.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesWarning.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeCustomerPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeJournalEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeManualCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeSupplierInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeSupplierPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/Envelope.js.map +1 -1
- package/dist/esm/components/Icon/components/EnvelopeApproved.js.map +1 -1
- package/dist/esm/components/Icon/components/ExpandView.js.map +1 -1
- package/dist/esm/components/Icon/components/Expenses.js.map +1 -1
- package/dist/esm/components/Icon/components/Export.js.map +1 -1
- package/dist/esm/components/Icon/components/ExportToExcel.js.map +1 -1
- package/dist/esm/components/Icon/components/ExportToExcelCopy.js.map +1 -1
- package/dist/esm/components/Icon/components/Filter.js.map +1 -1
- package/dist/esm/components/Icon/components/FilterSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/GraphSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Hash.js.map +1 -1
- package/dist/esm/components/Icon/components/Home.js.map +1 -1
- package/dist/esm/components/Icon/components/Images.js.map +1 -1
- package/dist/esm/components/Icon/components/Import.js.map +1 -1
- package/dist/esm/components/Icon/components/Inbox.js.map +1 -1
- package/dist/esm/components/Icon/components/InboxSmart.js.map +1 -1
- package/dist/esm/components/Icon/components/Info.js.map +1 -1
- package/dist/esm/components/Icon/components/Inventory.js.map +1 -1
- package/dist/esm/components/Icon/components/InventoryMatrix.js.map +1 -1
- package/dist/esm/components/Icon/components/JournalPro.js.map +1 -1
- package/dist/esm/components/Icon/components/Layout.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutBoth.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutFirst.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutLast.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutNone.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCard.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardCustomerReminder.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardManualCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardObsoleteStock.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardOpeningEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardReservedEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardShrinkagePilferage.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardStockAdjustment.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardTransferredOpeningEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/Lightbulb.js.map +1 -1
- package/dist/esm/components/Icon/components/Line.js.map +1 -1
- package/dist/esm/components/Icon/components/List.js.map +1 -1
- package/dist/esm/components/Icon/components/ListBulleted.js.map +1 -1
- package/dist/esm/components/Icon/components/ListSearch.js.map +1 -1
- package/dist/esm/components/Icon/components/LockOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/Log.js.map +1 -1
- package/dist/esm/components/Icon/components/Market.js.map +1 -1
- package/dist/esm/components/Icon/components/MatchAmount.js.map +1 -1
- package/dist/esm/components/Icon/components/MatchEntries.js.map +1 -1
- package/dist/esm/components/Icon/components/Mileage.js.map +1 -1
- package/dist/esm/components/Icon/components/Minus.js.map +1 -1
- package/dist/esm/components/Icon/components/ModalResize.js.map +1 -1
- package/dist/esm/components/Icon/components/ModalShrink.js.map +1 -1
- package/dist/esm/components/Icon/components/More.js.map +1 -1
- package/dist/esm/components/Icon/components/MoreSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Move.js.map +1 -1
- package/dist/esm/components/Icon/components/NavigationList.js.map +1 -1
- package/dist/esm/components/Icon/components/Note.js.map +1 -1
- package/dist/esm/components/Icon/components/NoteFollowUp.js.map +1 -1
- package/dist/esm/components/Icon/components/NoteRead.js.map +1 -1
- package/dist/esm/components/Icon/components/PartnerApi.js.map +1 -1
- package/dist/esm/components/Icon/components/Period.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonChange.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonMinus.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonPlus.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonTick.js.map +1 -1
- package/dist/esm/components/Icon/components/Play.js.map +1 -1
- package/dist/esm/components/Icon/components/PlusCircle.js.map +1 -1
- package/dist/esm/components/Icon/components/PlusMinus.js.map +1 -1
- package/dist/esm/components/Icon/components/Print.js.map +1 -1
- package/dist/esm/components/Icon/components/ProcessPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/ProductLedgerCard.js.map +1 -1
- package/dist/esm/components/Icon/components/ProjectCards.js.map +1 -1
- package/dist/esm/components/Icon/components/Projects.js.map +1 -1
- package/dist/esm/components/Icon/components/Quicklinks.js.map +1 -1
- package/dist/esm/components/Icon/components/RatingBankruptcy.js.map +1 -1
- package/dist/esm/components/Icon/components/RatingPaymentProblems.js.map +1 -1
- package/dist/esm/components/Icon/components/Reconciled.js.map +1 -1
- package/dist/esm/components/Icon/components/Refresh.js.map +1 -1
- package/dist/esm/components/Icon/components/Report.js.map +1 -1
- package/dist/esm/components/Icon/components/ReportSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Restore.js.map +1 -1
- package/dist/esm/components/Icon/components/RotateLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/RotateRight.js.map +1 -1
- package/dist/esm/components/Icon/components/Sales.js.map +1 -1
- package/dist/esm/components/Icon/components/Search.js.map +1 -1
- package/dist/esm/components/Icon/components/SearchBold.js.map +1 -1
- package/dist/esm/components/Icon/components/Secure.js.map +1 -1
- package/dist/esm/components/Icon/components/SecureTick.js.map +1 -1
- package/dist/esm/components/Icon/components/Settings.js.map +1 -1
- package/dist/esm/components/Icon/components/SettingsSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Shortcuts.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowAll.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowLess.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowMore.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowTemplate.js.map +1 -1
- package/dist/esm/components/Icon/components/Sliders.js.map +1 -1
- package/dist/esm/components/Icon/components/Smartpay.js.map +1 -1
- package/dist/esm/components/Icon/components/SortBy.js.map +1 -1
- package/dist/esm/components/Icon/components/Spinner.js.map +1 -1
- package/dist/esm/components/Icon/components/Star.js.map +1 -1
- package/dist/esm/components/Icon/components/StarSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Subscriptions.js.map +1 -1
- package/dist/esm/components/Icon/components/SystemEntries.js.map +1 -1
- package/dist/esm/components/Icon/components/Tag.js.map +1 -1
- package/dist/esm/components/Icon/components/TemplateOverride.js.map +1 -1
- package/dist/esm/components/Icon/components/Templates.js.map +1 -1
- package/dist/esm/components/Icon/components/Thumb.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbBoth.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbDownSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbUpSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Tick.js.map +1 -1
- package/dist/esm/components/Icon/components/TickCircle.js.map +1 -1
- package/dist/esm/components/Icon/components/Time.js.map +1 -1
- package/dist/esm/components/Icon/components/Transfer.js.map +1 -1
- package/dist/esm/components/Icon/components/TransferCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/TransferLocked.js.map +1 -1
- package/dist/esm/components/Icon/components/Undock.js.map +1 -1
- package/dist/esm/components/Icon/components/Unreconciled.js.map +1 -1
- package/dist/esm/components/Icon/components/Warning.js.map +1 -1
- package/dist/esm/components/Icon/components/Webshop.js.map +1 -1
- package/dist/esm/components/Icon/components/Website.js.map +1 -1
- package/dist/esm/components/Icon/components/Workflow.js.map +1 -1
- package/dist/esm/components/Icon/components/Zoom.js.map +1 -1
- package/dist/esm/components/Icon/components/index.js +4 -4
- package/dist/esm/components/Icon/components/index.js.map +1 -1
- package/dist/esm/components/IconButton/IconButton.js.map +1 -1
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Input/util.js +9 -8
- package/dist/esm/components/Input/util.js.map +1 -1
- package/dist/esm/components/Listbox/Listbox.js.map +1 -1
- package/dist/esm/components/Listbox/ScrollableList.js +63 -82
- package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/components/Listbox/useListbox.js +49 -58
- package/dist/esm/components/Listbox/useListbox.js.map +1 -1
- package/dist/esm/components/Listbox/useMultiListbox.js +63 -91
- package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -1
- package/dist/esm/components/Listbox/useTypeahead.js +10 -9
- package/dist/esm/components/Listbox/useTypeahead.js.map +1 -1
- package/dist/esm/components/Listbox/util.js +48 -84
- package/dist/esm/components/Listbox/util.js.map +1 -1
- package/dist/esm/components/Menu/Context.js +2 -2
- package/dist/esm/components/Menu/Context.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Menu/components/Checkbox.js +8 -9
- package/dist/esm/components/Menu/components/Checkbox.js.map +1 -1
- package/dist/esm/components/Menu/components/Content.js +10 -13
- package/dist/esm/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/components/Menu/components/Header.js +4 -4
- package/dist/esm/components/Menu/components/Header.js.map +1 -1
- package/dist/esm/components/Menu/components/Item.js +34 -35
- package/dist/esm/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/components/Menu/components/Link.js +18 -9
- package/dist/esm/components/Menu/components/Link.js.map +1 -1
- package/dist/esm/components/Menu/components/RadioGroup.js +16 -18
- package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -1
- package/dist/esm/components/Menu/components/Separator.js +4 -4
- package/dist/esm/components/Menu/components/Separator.js.map +1 -1
- package/dist/esm/components/Menu/components/Trigger.js +5 -5
- package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
- package/dist/esm/components/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/PageNumbers.js +23 -28
- package/dist/esm/components/Pagination/PageNumbers.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/usePagination.js +7 -21
- package/dist/esm/components/Pagination/usePagination.js.map +1 -1
- package/dist/esm/components/Pagination/usePaginationShortcuts.js +9 -9
- package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -1
- package/dist/esm/components/Popover/Popover.js +4 -4
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/Popover/Primitives.js +9 -10
- package/dist/esm/components/Popover/Primitives.js.map +1 -1
- package/dist/esm/components/Progress/Progress.js.map +1 -1
- package/dist/esm/components/Provider/Provider.js.map +1 -1
- package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/useSelect.js +63 -82
- package/dist/esm/components/Select/useSelect.js.map +1 -1
- package/dist/esm/components/Spinner/Spinner.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Table/components/BaseTable.js +23 -30
- package/dist/esm/components/Table/components/BaseTable.js.map +1 -1
- package/dist/esm/components/Table/components/PaginatedTable.js +3 -7
- package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -1
- package/dist/esm/components/Table/components/Table.js +18 -25
- package/dist/esm/components/Table/components/Table.js.map +1 -1
- package/dist/esm/components/Table/components/WindowedTable.js +88 -104
- package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js +122 -146
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js +57 -61
- package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowEditing.js +39 -36
- package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowSelect.js +80 -90
- package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/components/Table/hooks/useRowCreation.js +29 -64
- package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTable.js +119 -141
- package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +12 -15
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
- package/dist/esm/components/Table/util/renderColumn.js +10 -10
- package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/components/Table/util/renderRow.js +37 -46
- package/dist/esm/components/Table/util/renderRow.js.map +1 -1
- package/dist/esm/components/Table/util/rowIndexPath.js +14 -16
- package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -1
- package/dist/esm/components/Table/util/sortTypes.js +23 -31
- package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
- package/dist/esm/components/Table/util.js +29 -41
- package/dist/esm/components/Table/util.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/components/Toast/Toast.js +20 -21
- package/dist/esm/components/Toast/Toast.js.map +1 -1
- package/dist/esm/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/components/Toast/util.js +2 -2
- package/dist/esm/components/Toast/util.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Tour/Tour.js.map +1 -1
- package/dist/esm/components/Treeview/Treeview.js +3 -3
- package/dist/esm/components/Treeview/Treeview.js.map +1 -1
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/esm/index.css +642 -637
- package/dist/esm/index.js +1 -1
- package/dist/esm/primitives/Button.js +9 -13
- package/dist/esm/primitives/Button.js.map +1 -1
- package/dist/esm/utils/date.js.map +1 -1
- package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -1
- package/dist/esm/utils/hooks/useDraggable.js +16 -18
- package/dist/esm/utils/hooks/useDraggable.js.map +1 -1
- package/dist/esm/utils/hooks/useDropTarget.js +7 -10
- package/dist/esm/utils/hooks/useDropTarget.js.map +1 -1
- package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -1
- package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -1
- package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -1
- package/dist/esm/utils/hooks/useProxiedRef.js +3 -3
- package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -1
- package/dist/esm/utils/hooks/useTimer.js +9 -17
- package/dist/esm/utils/hooks/useTimer.js.map +1 -1
- package/dist/esm/utils/input.js +7 -11
- package/dist/esm/utils/input.js.map +1 -1
- package/dist/esm/utils/mergeRefs.js +2 -2
- package/dist/esm/utils/mergeRefs.js.map +1 -1
- package/dist/esm/utils/taillwind.js +2 -2
- package/dist/esm/utils/taillwind.js.map +1 -1
- package/dist/index.css +642 -637
- package/dist/taco.cjs.development.js +1514 -1833
- 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/package.json +2 -2
- package/plugins/tailwindcss-aria-attributes.js +73 -73
- package/tailwind.config.js +297 -297
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Listbox.js","sources":["../../../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useListbox } from './useListbox';\nimport { useMultiListbox } from './useMultiListbox';\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\nimport { State } from '../../types';\n\nexport type ListboxItem = ScrollableListItem;\nexport type ListboxValue = ScrollableListItemValue;\n\nexport type ListboxTexts = {\n /**\n * Text displayed in the listbox if no data provided.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n empty: string;\n /**\n * Text displayed in the listbox to indicate the data is loading.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading: string;\n /**\n * The first option displayed in a multiselect listbox that selects all available options.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n allOption: string;\n};\n\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\n /** Data indicating the options in listbox */\n data?: ListboxItem[];\n /**\n * Initial value of the listbox.\n * This is used when listbox is mounted, if no value is provided.\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ListboxValue;\n /** Set what value should have an empty option in listbox */\n emptyValue?: ListboxValue;\n /** Draws attention to the listbox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading?: boolean;\n /** State will change the style of the listbox */\n state?: State;\n /**\n * Value of the listbox representing the selected item.\n * It needs to be an existing value from the provided data\n */\n value?: ListboxValue;\n };\n\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{ ...list.style, maxHeight: 'calc(12rem + 2px)' /* (6 * option height) + listbox border */ }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useMultiListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{\n ...list.style,\n maxHeight: 'calc(12rem + 2px + 2px)' /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */,\n }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n"],"names":["Listbox","React","props","ref","externalClassName","className","otherProps","useListbox","list","input","cn","ScrollableList","style","maxHeight","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;;;;IAwDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACpC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,oBAAwBK,UAAU,CAACD,UA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as React from 'react';\r\nimport cn from 'classnames';\r\nimport { useListbox } from './useListbox';\r\nimport { useMultiListbox } from './useMultiListbox';\r\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\r\nimport { State } from '../../types';\r\n\r\nexport type ListboxItem = ScrollableListItem;\r\nexport type ListboxValue = ScrollableListItemValue;\r\n\r\nexport type ListboxTexts = {\r\n /**\r\n * Text displayed in the listbox if no data provided.\r\n * To read more about how to provide the text, see [Provider](component:provider) component\r\n */\r\n empty: string;\r\n /**\r\n * Text displayed in the listbox to indicate the data is loading.\r\n * Read more about how to provide the text in [Provider](component:provider) component\r\n */\r\n loading: string;\r\n /**\r\n * The first option displayed in a multiselect listbox that selects all available options.\r\n * Read more about how to provide the text in [Provider](component:provider) component\r\n */\r\n allOption: string;\r\n};\r\n\r\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\r\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\r\n /** Data indicating the options in listbox */\r\n data?: ListboxItem[];\r\n /**\r\n * Initial value of the listbox.\r\n * This is used when listbox is mounted, if no value is provided.\r\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\r\n */\r\n defaultValue?: ListboxValue;\r\n /** Set what value should have an empty option in listbox */\r\n emptyValue?: ListboxValue;\r\n /** Draws attention to the listbox by changing its style and making it visually prominent */\r\n highlighted?: boolean;\r\n /**\r\n * Shows a loading indicator with a text next to it.\r\n * Read more about how to provide the text in [Provider](component:provider) component\r\n */\r\n loading?: boolean;\r\n /** State will change the style of the listbox */\r\n state?: State;\r\n /**\r\n * Value of the listbox representing the selected item.\r\n * It needs to be an existing value from the provided data\r\n */\r\n value?: ListboxValue;\r\n };\r\n\r\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\r\n const { className: externalClassName, ...otherProps } = props;\r\n const { list, input } = useListbox(otherProps, ref);\r\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\r\n\r\n return (\r\n <span data-taco=\"listbox\" className={className}>\r\n <ScrollableList\r\n {...list}\r\n style={{ ...list.style, maxHeight: 'calc(12rem + 2px)' /* (6 * option height) + listbox border */ }}\r\n />\r\n <input {...input} className=\"hidden\" type=\"text\" />\r\n </span>\r\n );\r\n});\r\n\r\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\r\n const { className: externalClassName, ...otherProps } = props;\r\n const { list, input } = useMultiListbox(otherProps, ref);\r\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\r\n\r\n return (\r\n <span data-taco=\"listbox\" className={className}>\r\n <ScrollableList\r\n {...list}\r\n style={{\r\n ...list.style,\r\n maxHeight: 'calc(12rem + 2px + 2px)' /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */,\r\n }}\r\n />\r\n <input {...input} className=\"hidden\" type=\"text\" />\r\n </span>\r\n );\r\n});\r\n"],"names":["Listbox","React","props","ref","externalClassName","className","otherProps","useListbox","list","input","cn","ScrollableList","style","maxHeight","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;;;;IAwDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACpC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,oBAAwBK,UAAU,CAACD,UAAD,EAAaH,GAAb,CAAlC;AAAA,MAAQK,IAAR,eAAQA,IAAR;AAAA,MAAcC,KAAd,eAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;AAEA,SACIH,aAAA,OAAA;iBAAgB;AAAUI,IAAAA,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;AACJI,IAAAA,KAAK,eAAOJ,IAAI,CAACI,KAAZ;AAAmBC,MAAAA,SAAS,EAAE;AAAoB;;AAAlD;IAFT,CADJ,EAKIZ,aAAA,QAAA,oBAAWQ;AAAOJ,IAAAA,SAAS,EAAC;AAASS,IAAAA,IAAI,EAAC;IAA1C,CALJ,CADJ;AASH,CAdsB;IAgBVC,YAAY,gBAAGd,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACzC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,yBAAwBc,eAAe,CAACV,UAAD,EAAaH,GAAb,CAAvC;AAAA,MAAQK,IAAR,oBAAQA,IAAR;AAAA,MAAcC,KAAd,oBAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;AAEA,SACIH,aAAA,OAAA;iBAAgB;AAAUI,IAAAA,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;AACJI,IAAAA,KAAK,eACEJ,IAAI,CAACI,KADP;AAEDC,MAAAA,SAAS,EAAE;AAA0B;;AAFpC;IAFT,CADJ,EAQIZ,aAAA,QAAA,oBAAWQ;AAAOJ,IAAAA,SAAS,EAAC;AAASS,IAAAA,IAAI,EAAC;IAA1C,CARJ,CADJ;AAYH,CAjB2B;;;;"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
2
1
|
import { forwardRef, useMemo, createRef, useEffect, createElement } from 'react';
|
3
2
|
import cn from 'classnames';
|
4
3
|
import { Spinner } from '../Spinner/Spinner.js';
|
@@ -9,14 +8,10 @@ import { getInputClasses } from '../Input/util.js';
|
|
9
8
|
import { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation.js';
|
10
9
|
import { useListScrollTo } from '../../utils/hooks/useListScrollTo.js';
|
11
10
|
|
12
|
-
|
13
|
-
_excluded2 = ["children", "icon"];
|
14
|
-
var getId = function getId(id, value) {
|
15
|
-
return id + "_" + value;
|
16
|
-
};
|
11
|
+
const getId = (id, value) => `${id}_${value}`;
|
17
12
|
|
18
|
-
|
19
|
-
|
13
|
+
const getNextEnabledItem = (event, data, index) => {
|
14
|
+
const nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);
|
20
15
|
|
21
16
|
if (nextIndex) {
|
22
17
|
if (nextIndex === index) {
|
@@ -29,45 +24,40 @@ var getNextEnabledItem = function getNextEnabledItem(event, data, index) {
|
|
29
24
|
return nextIndex;
|
30
25
|
};
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
var _useListScrollTo = useListScrollTo(listRef, itemRefs),
|
63
|
-
scrollTo = _useListScrollTo.scrollTo;
|
64
|
-
|
65
|
-
useEffect(function () {
|
27
|
+
const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref) {
|
28
|
+
const {
|
29
|
+
data,
|
30
|
+
disabled,
|
31
|
+
highlighted,
|
32
|
+
id,
|
33
|
+
loading,
|
34
|
+
onChange: setCurrentIndex,
|
35
|
+
onClick,
|
36
|
+
onFocus,
|
37
|
+
onKeyDown,
|
38
|
+
readOnly,
|
39
|
+
scrollOnFocus = false,
|
40
|
+
state,
|
41
|
+
value: currentIndex,
|
42
|
+
multiselect,
|
43
|
+
selectedIndexes = [],
|
44
|
+
allOptionsSelected = false,
|
45
|
+
...otherProps
|
46
|
+
} = props;
|
47
|
+
const listRef = useProxiedRef(ref);
|
48
|
+
const itemRefs = useMemo(() => data.map(() => createRef()), [data]);
|
49
|
+
const {
|
50
|
+
texts
|
51
|
+
} = useLocalization();
|
52
|
+
const {
|
53
|
+
scrollTo
|
54
|
+
} = useListScrollTo(listRef, itemRefs);
|
55
|
+
useEffect(() => {
|
66
56
|
scrollTo(currentIndex);
|
67
57
|
}, [currentIndex]);
|
68
58
|
|
69
|
-
|
70
|
-
|
59
|
+
const handleKeyDown = event => {
|
60
|
+
const nextIndex = getNextEnabledItem(event, data, currentIndex);
|
71
61
|
|
72
62
|
if (nextIndex !== undefined && nextIndex !== currentIndex) {
|
73
63
|
event.preventDefault();
|
@@ -77,23 +67,21 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
|
|
77
67
|
|
78
68
|
if (onKeyDown) {
|
79
69
|
event.persist();
|
80
|
-
|
70
|
+
const index = nextIndex !== undefined ? nextIndex : currentIndex;
|
81
71
|
onKeyDown(event, index);
|
82
72
|
}
|
83
73
|
};
|
84
74
|
|
85
|
-
|
86
|
-
|
87
|
-
setCurrentIndex(index);
|
75
|
+
const handleClick = index => event => {
|
76
|
+
setCurrentIndex(index);
|
88
77
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
};
|
78
|
+
if (onClick) {
|
79
|
+
event.persist();
|
80
|
+
onClick(event, index);
|
81
|
+
}
|
94
82
|
};
|
95
83
|
|
96
|
-
|
84
|
+
const handleFocus = event => {
|
97
85
|
if (scrollOnFocus) {
|
98
86
|
scrollTo(currentIndex);
|
99
87
|
}
|
@@ -104,36 +92,33 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
|
|
104
92
|
}
|
105
93
|
};
|
106
94
|
|
107
|
-
|
95
|
+
const getOptionCheckedState = (optionValue, index) => {
|
108
96
|
if (optionValue === '#ALL-OPTIONS#') {
|
109
97
|
return allOptionsSelected;
|
110
98
|
} else if (!optionValue || !selectedIndexes) {
|
111
99
|
return false;
|
112
100
|
} else {
|
113
|
-
return selectedIndexes.findIndex(
|
114
|
-
return i === index;
|
115
|
-
}) !== -1;
|
101
|
+
return selectedIndexes.findIndex(i => i === index) !== -1;
|
116
102
|
}
|
117
103
|
};
|
118
104
|
|
119
|
-
|
105
|
+
const list = { ...otherProps,
|
120
106
|
className: cn('inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto', getInputClasses(props), {
|
121
107
|
'yt-list--multiselect': multiselect,
|
122
108
|
'pointer-events-none': disabled,
|
123
109
|
'cursor-not-allowed': disabled || readOnly
|
124
110
|
}, otherProps.className),
|
125
|
-
disabled
|
126
|
-
id
|
111
|
+
disabled,
|
112
|
+
id,
|
127
113
|
onFocus: !disabled && !readOnly ? handleFocus : undefined,
|
128
114
|
onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,
|
129
|
-
readOnly
|
115
|
+
readOnly,
|
130
116
|
ref: listRef,
|
131
117
|
role: 'listbox',
|
132
118
|
tabIndex: otherProps.tabIndex || 0
|
133
|
-
}
|
134
|
-
|
135
|
-
|
136
|
-
var depth = option.path ? option.path.split('.').length - 1 : 0;
|
119
|
+
};
|
120
|
+
const options = data.map((option, index) => {
|
121
|
+
const depth = option.path ? option.path.split('.').length - 1 : 0;
|
137
122
|
return {
|
138
123
|
'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,
|
139
124
|
'data-focused': currentIndex === index,
|
@@ -149,7 +134,7 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
|
|
149
134
|
ref: itemRefs[index],
|
150
135
|
role: 'option',
|
151
136
|
style: depth > 0 ? {
|
152
|
-
paddingLeft: depth + 1
|
137
|
+
paddingLeft: `${depth + 1}rem`
|
153
138
|
} : undefined
|
154
139
|
};
|
155
140
|
});
|
@@ -159,21 +144,17 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
|
|
159
144
|
className: "yt-list__empty"
|
160
145
|
}, createElement("span", null, createElement(Spinner, {
|
161
146
|
delay: 0
|
162
|
-
})), createElement("span", null, texts.listbox.loading)) : options.length ? options.map(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
},
|
174
|
-
className: "pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px"
|
175
|
-
}));
|
176
|
-
}) : createElement("li", {
|
147
|
+
})), createElement("span", null, texts.listbox.loading)) : options.length ? options.map(({
|
148
|
+
children,
|
149
|
+
icon,
|
150
|
+
...optionProps
|
151
|
+
}) => createElement("li", Object.assign({}, optionProps), icon, createElement("span", {
|
152
|
+
className: "flex-grow truncate text-left"
|
153
|
+
}, children), multiselect && createElement(Checkbox, {
|
154
|
+
checked: optionProps['aria-selected'],
|
155
|
+
onChange: () => null,
|
156
|
+
className: "pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px"
|
157
|
+
}))) : createElement("li", {
|
177
158
|
className: "yt-list__empty"
|
178
159
|
}, createElement("span", null, texts.listbox.empty)));
|
179
160
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ScrollableList.js","sources":["../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Provider';\nimport { State } from '../../types';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /** State will change the style of the scrollable list */\n state?: State;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n state,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useProxiedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue focus:border-blue',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKeycode","keyCode","length","disabled","ScrollableList","React","props","ref","loading","setCurrentIndex","onChange","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useProxiedRef","itemRefs","map","useLocalization","texts","useListScrollTo","scrollTo","handleKeyDown","undefined","preventDefault","persist","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","list","className","cn","getInputClasses","role","tabIndex","options","option","depth","path","split","String","children","text","hasChildren","icon","key","style","paddingLeft","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;;;;IA4FaA,KAAK,GAAG,SAARA,KAAQ,CAACC,EAAD,EAAaC,KAAb;AAAA,SAA2DD,EAA3D,SAAiEC,KAAjE;AAAA;;AAErB,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CACvBC,KADuB,EAEvBC,IAFuB,EAGvBC,KAHuB;AAKvB,MAAMC,SAAS,GAAGC,uBAAuB,CAACJ,KAAK,CAACK,OAAP,EAAgBJ,IAAI,CAACK,MAArB,EAA6BJ,KAA7B,CAAzC;;AAEA,MAAIC,SAAJ,EAAe;AACX,QAAIA,SAAS,KAAKD,KAAlB,EAAyB;AACrB,aAAOA,KAAP;AACH,KAFD,MAEO,IAAID,IAAI,CAACE,SAAD,CAAJ,IAAmBF,IAAI,CAACE,SAAD,CAAJ,CAAgBI,QAAvC,EAAiD;AACpD,aAAOR,kBAAkB,CAACC,KAAD,EAAQC,IAAR,EAAcE,SAAd,CAAzB;AACH;AACJ;;AAED,SAAOA,SAAP;AACH,CAhBD;;IAkBaK,cAAc,gBAAGC,UAAA,CAAiB,SAASD,cAAT,CAC3CE,KAD2C,EAE3CC,GAF2C;AAI3C,MACIV,IADJ,GAkBIS,KAlBJ,CACIT,IADJ;AAAA,MAE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AaG,IAAb,QAAaA,IAAb;AAAA,QAAsBO,WAAtB;;AAAA,WACRxD,aAAA,KAAA,oBAAQwD,YAAR,EACKP,IADL,EAEIjD,aAAA,OAAA;AAAMmC,MAAAA,SAAS,EAAC;KAAhB,EAAgDW,QAAhD,CAFJ,EAGKlC,WAAW,IACRZ,aAAA,CAACyD,QAAD;AACIC,MAAAA,OAAO,EAAEF,WAAW,CAAC,eAAD;AACpBnD,MAAAA,QAAQ,EAAE;AAAA,eAAM,IAAN;AAAA;AACV8B,MAAAA,SAAS,EAAC;KAHd,CAJR,CADQ;AAAA,GAAZ,CADA,GAeAnC,aAAA,KAAA;AAAImC,IAAAA,SAAS,EAAC;GAAd,EACInC,aAAA,OAAA,MAAA,EAAOqB,KAAK,CAACkC,OAAN,CAAcI,KAArB,CADJ,CAvBR,CADJ;AA8BH,CAhK6B;;;;"}
|
1
|
+
{"version":3,"file":"ScrollableList.js","sources":["../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport cn from 'classnames';\r\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\r\nimport { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation';\r\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\r\nimport './ScrollableList.css';\r\nimport { Spinner } from '../Spinner/Spinner';\r\nimport { useLocalization } from '../Provider/Provider';\r\nimport { State } from '../../types';\r\nimport { Checkbox } from '../Checkbox/Checkbox';\r\nimport { getInputClasses } from '../Input/util';\r\n\r\nexport type ScrollableListItemValue = string | number | boolean | null;\r\n\r\nexport type ScrollableListItem = {\r\n /**\r\n * Set whether the item is disabled.\r\n * This will both change the style and make the item unselectable\r\n */\r\n disabled?: boolean;\r\n /* Specifies whether the item has child items -- intended for internal use only */\r\n hasChildren?: boolean;\r\n /** Place an icon before the item's text */\r\n icon?: React.ReactElement;\r\n /* The index path to the item -- intended for internal use only */\r\n path?: string;\r\n /** Text describing the item */\r\n text: string | JSX.Element;\r\n /** Value of the item */\r\n value: ScrollableListItemValue;\r\n /** Child items to show hierarchical data */\r\n children?: ScrollableListItem[];\r\n};\r\n\r\n/** @internal */\r\nexport type ScrollableListProps = Omit<\r\n React.HTMLAttributes<HTMLUListElement>,\r\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\r\n> & {\r\n /** Data indicating the options in scrollable list */\r\n data: ScrollableListItem[];\r\n /** Sets the list to be disabled */\r\n disabled?: boolean;\r\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\r\n highlighted?: boolean;\r\n /** Set an id for the scrollable list */\r\n id: string;\r\n /**\r\n * Shows a loading indicator with a text next to it.\r\n * Read more about how to provide the text in `Provider` component.\r\n */\r\n loading?: boolean;\r\n /**\r\n * Handler called when current active/selected option changes in a scrollable list.\r\n * @param index indicates the index of the current active option\r\n */\r\n onChange: (index: number) => void;\r\n /** Handler called when option is clicked */\r\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\r\n /**\r\n * Set whether the selected item should be scrolled into view when listbox is focused.\r\n * Default value is `false`\r\n */\r\n scrollOnFocus?: boolean;\r\n /** Handler called when a key is pressed */\r\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\r\n /* Sets the list to read only mode */\r\n readOnly?: boolean;\r\n /** State will change the style of the scrollable list */\r\n state?: State;\r\n /**\r\n * Value of the scrollable list representing the selected item.\r\n * It needs to be an existing value from the provided data.\r\n */\r\n value: number | undefined;\r\n /**\r\n * Allows to select multiple items from the list\r\n */\r\n multiselect?: boolean;\r\n /**\r\n * Contains the currently selected values when multiselect mode is ON.\r\n */\r\n selectedIndexes?: number[];\r\n /**\r\n * True when all available (not disabled) options are selected\r\n */\r\n allOptionsSelected?: boolean;\r\n};\r\n\r\n/** @internal */\r\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\r\n\r\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\r\n\r\nconst getNextEnabledItem = (\r\n event: React.KeyboardEvent<HTMLElement>,\r\n data: ScrollableListItem[],\r\n index: number | undefined\r\n): number | undefined => {\r\n const nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);\r\n\r\n if (nextIndex) {\r\n if (nextIndex === index) {\r\n return index;\r\n } else if (data[nextIndex] && data[nextIndex].disabled) {\r\n return getNextEnabledItem(event, data, nextIndex);\r\n }\r\n }\r\n\r\n return nextIndex;\r\n};\r\n\r\nexport const ScrollableList = React.forwardRef(function ScrollableList(\r\n props: ScrollableListProps,\r\n ref: React.Ref<HTMLUListElement>\r\n) {\r\n const {\r\n data,\r\n disabled,\r\n highlighted,\r\n id,\r\n loading,\r\n onChange: setCurrentIndex,\r\n onClick,\r\n onFocus,\r\n onKeyDown,\r\n readOnly,\r\n scrollOnFocus = false,\r\n state,\r\n value: currentIndex,\r\n multiselect,\r\n selectedIndexes = [],\r\n allOptionsSelected = false,\r\n ...otherProps\r\n } = props;\r\n const listRef = useProxiedRef<HTMLUListElement>(ref);\r\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\r\n const { texts } = useLocalization();\r\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\r\n\r\n React.useEffect(() => {\r\n scrollTo(currentIndex);\r\n }, [currentIndex]);\r\n\r\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\r\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\r\n\r\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\r\n event.preventDefault();\r\n scrollTo(nextIndex);\r\n setCurrentIndex(nextIndex);\r\n }\r\n\r\n if (onKeyDown) {\r\n event.persist();\r\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\r\n onKeyDown(event, index);\r\n }\r\n };\r\n\r\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\r\n setCurrentIndex(index);\r\n\r\n if (onClick) {\r\n event.persist();\r\n onClick(event, index);\r\n }\r\n };\r\n\r\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\r\n if (scrollOnFocus) {\r\n scrollTo(currentIndex);\r\n }\r\n\r\n if (onFocus) {\r\n event.persist();\r\n onFocus(event);\r\n }\r\n };\r\n\r\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\r\n if (optionValue === '#ALL-OPTIONS#') {\r\n return allOptionsSelected;\r\n } else if (!optionValue || !selectedIndexes) {\r\n return false;\r\n } else {\r\n return selectedIndexes.findIndex(i => i === index) !== -1;\r\n }\r\n };\r\n\r\n const list: React.HTMLAttributes<HTMLUListElement> &\r\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\r\n ...otherProps,\r\n className: cn(\r\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\r\n getInputClasses(props),\r\n {\r\n 'yt-list--multiselect': multiselect,\r\n 'pointer-events-none': disabled,\r\n 'cursor-not-allowed': disabled || readOnly,\r\n },\r\n otherProps.className\r\n ),\r\n disabled,\r\n id,\r\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\r\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\r\n readOnly,\r\n ref: listRef,\r\n role: 'listbox',\r\n tabIndex: otherProps.tabIndex || 0,\r\n };\r\n\r\n const options = data.map((option, index) => {\r\n const depth = option.path ? option.path.split('.').length - 1 : 0;\r\n\r\n return {\r\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\r\n 'data-focused': currentIndex === index,\r\n children: option.text,\r\n className: cn(\r\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue focus:border-blue',\r\n {\r\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\r\n }\r\n ),\r\n disabled: option.disabled,\r\n icon: option.icon,\r\n id: getId(id, option.value),\r\n key: getId(id, option.value),\r\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\r\n ref: itemRefs[index],\r\n role: 'option',\r\n style:\r\n depth > 0\r\n ? {\r\n paddingLeft: `${depth + 1}rem`,\r\n }\r\n : undefined,\r\n };\r\n });\r\n\r\n return (\r\n <ul {...list} data-taco=\"scrollable-list\">\r\n {loading ? (\r\n <li className=\"yt-list__empty\">\r\n <span>\r\n <Spinner delay={0} />\r\n </span>\r\n <span>{texts.listbox.loading}</span>\r\n </li>\r\n ) : options.length ? (\r\n options.map(({ children, icon, ...optionProps }) => (\r\n <li {...optionProps}>\r\n {icon}\r\n <span className=\"flex-grow truncate text-left\">{children}</span>\r\n {multiselect && (\r\n <Checkbox\r\n checked={optionProps['aria-selected']}\r\n onChange={() => null}\r\n className=\"pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px\"\r\n />\r\n )}\r\n </li>\r\n ))\r\n ) : (\r\n <li className=\"yt-list__empty\">\r\n <span>{texts.listbox.empty}</span>\r\n </li>\r\n )}\r\n </ul>\r\n );\r\n});\r\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKeycode","keyCode","length","disabled","ScrollableList","React","props","ref","highlighted","loading","onChange","setCurrentIndex","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","state","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useProxiedRef","itemRefs","map","texts","useLocalization","scrollTo","useListScrollTo","handleKeyDown","undefined","preventDefault","persist","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","list","className","cn","getInputClasses","role","tabIndex","options","option","depth","path","split","String","children","text","hasChildren","icon","key","style","paddingLeft","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;MA4FaA,KAAK,GAAG,CAACC,EAAD,EAAaC,KAAb,QAA2DD,MAAMC;;AAEtF,MAAMC,kBAAkB,GAAG,CACvBC,KADuB,EAEvBC,IAFuB,EAGvBC,KAHuB;AAKvB,QAAMC,SAAS,GAAGC,uBAAuB,CAACJ,KAAK,CAACK,OAAP,EAAgBJ,IAAI,CAACK,MAArB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AAAMqC,IAAAA,SAAS,EAAC;GAAhB,EAAgDW,QAAhD,CAFJ,EAGKlC,WAAW,IACRd,aAAA,CAAC2D,QAAD;AACIC,IAAAA,OAAO,EAAEF,WAAW,CAAC,eAAD;AACpBrD,IAAAA,QAAQ,EAAE,MAAM;AAChBgC,IAAAA,SAAS,EAAC;GAHd,CAJR,CADJ,CADA,GAeArC,aAAA,KAAA;AAAIqC,IAAAA,SAAS,EAAC;GAAd,EACIrC,aAAA,OAAA,MAAA,EAAOsB,KAAK,CAACmC,OAAN,CAAcI,KAArB,CADJ,CAvBR,CADJ;AA8BH,CAhK6B;;;;"}
|
@@ -1,45 +1,39 @@
|
|
1
|
-
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
2
1
|
import { useMemo, useEffect } from 'react';
|
3
2
|
import { v4 } from 'uuid';
|
4
3
|
import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
|
5
4
|
import { useFlattenedData, getIndexFromValue, getActiveDescendant, setInputValueByRef, findByValue, sanitizeItem } from './util.js';
|
6
5
|
import { useTypeahead } from './useTypeahead.js';
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
23
|
-
|
24
|
-
var data = useFlattenedData(emptyValue !== undefined ? [{
|
7
|
+
const useListbox = ({
|
8
|
+
data: externalData = [],
|
9
|
+
defaultValue,
|
10
|
+
disabled,
|
11
|
+
emptyValue,
|
12
|
+
id: nativeId,
|
13
|
+
name,
|
14
|
+
onChange,
|
15
|
+
onFocus,
|
16
|
+
onKeyDown,
|
17
|
+
value = emptyValue,
|
18
|
+
...otherProps
|
19
|
+
}, ref) => {
|
20
|
+
const data = useFlattenedData(emptyValue !== undefined ? [{
|
25
21
|
text: '',
|
26
22
|
value: emptyValue
|
27
|
-
}]
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
var setInputValueByIndex = function setInputValueByIndex(index) {
|
23
|
+
}, ...externalData] : externalData);
|
24
|
+
const id = useMemo(() => nativeId || v4(), [nativeId]);
|
25
|
+
const inputRef = useProxiedRef(ref);
|
26
|
+
const currentIndex = value !== undefined ? getIndexFromValue(data, value) : undefined;
|
27
|
+
const {
|
28
|
+
getNextIndex
|
29
|
+
} = useTypeahead({
|
30
|
+
data,
|
31
|
+
currentIndex
|
32
|
+
});
|
33
|
+
|
34
|
+
const setInputValueByIndex = index => {
|
41
35
|
if (index !== undefined) {
|
42
|
-
|
36
|
+
const option = data[index];
|
43
37
|
|
44
38
|
if (option && !option.disabled) {
|
45
39
|
setInputValueByRef(inputRef.current, option.value);
|
@@ -47,14 +41,14 @@ var useListbox = function useListbox(_ref, ref) {
|
|
47
41
|
}
|
48
42
|
};
|
49
43
|
|
50
|
-
|
44
|
+
const handleListboxChange = index => {
|
51
45
|
setInputValueByIndex(index);
|
52
46
|
};
|
53
47
|
|
54
|
-
useEffect(
|
48
|
+
useEffect(() => {
|
55
49
|
if (data.length && currentIndex === undefined) {
|
56
50
|
if (defaultValue !== undefined) {
|
57
|
-
|
51
|
+
const defaultValueIndex = getIndexFromValue(data, defaultValue);
|
58
52
|
|
59
53
|
if (defaultValueIndex !== undefined) {
|
60
54
|
setInputValueByIndex(defaultValueIndex);
|
@@ -65,11 +59,11 @@ var useListbox = function useListbox(_ref, ref) {
|
|
65
59
|
}
|
66
60
|
}, [data]);
|
67
61
|
|
68
|
-
|
69
|
-
|
62
|
+
const handleListboxKeyDown = event => {
|
63
|
+
const charKey = String.fromCharCode(event.keyCode);
|
70
64
|
|
71
65
|
if (charKey.match(/(\w)/g)) {
|
72
|
-
|
66
|
+
const nextIndex = getNextIndex(charKey);
|
73
67
|
|
74
68
|
if (nextIndex > -1 && nextIndex !== currentIndex) {
|
75
69
|
setInputValueByIndex(nextIndex);
|
@@ -84,7 +78,7 @@ var useListbox = function useListbox(_ref, ref) {
|
|
84
78
|
}
|
85
79
|
};
|
86
80
|
|
87
|
-
|
81
|
+
const handleListboxFocus = event => {
|
88
82
|
if (currentIndex === undefined && data.length) {
|
89
83
|
setInputValueByIndex(0);
|
90
84
|
}
|
@@ -95,26 +89,24 @@ var useListbox = function useListbox(_ref, ref) {
|
|
95
89
|
}
|
96
90
|
};
|
97
91
|
|
98
|
-
|
92
|
+
const handleInputChange = event => {
|
99
93
|
event.persist();
|
100
94
|
|
101
95
|
if (onChange) {
|
102
96
|
var _item$path$split, _item$path;
|
103
97
|
|
104
|
-
|
98
|
+
const item = findByValue(data, event.target.value);
|
105
99
|
event.detail = sanitizeItem(item);
|
106
|
-
|
100
|
+
const indexes = (_item$path$split = item === null || item === void 0 ? void 0 : (_item$path = item.path) === null || _item$path === void 0 ? void 0 : _item$path.split('.')) !== null && _item$path$split !== void 0 ? _item$path$split : [];
|
107
101
|
|
108
102
|
if (indexes.length > 1) {
|
109
103
|
// we don't want to map the current item
|
110
104
|
indexes.pop(); // we need to rebuild the path as we map
|
111
105
|
|
112
|
-
|
113
|
-
event.detail.parents = indexes.map(
|
106
|
+
let lastPath;
|
107
|
+
event.detail.parents = indexes.map(i => {
|
114
108
|
lastPath = lastPath ? [lastPath, i].join('.') : i;
|
115
|
-
return sanitizeItem(data.find(
|
116
|
-
return i.path === lastPath;
|
117
|
-
}));
|
109
|
+
return sanitizeItem(data.find(i => i.path === lastPath));
|
118
110
|
});
|
119
111
|
}
|
120
112
|
|
@@ -122,29 +114,28 @@ var useListbox = function useListbox(_ref, ref) {
|
|
122
114
|
}
|
123
115
|
};
|
124
116
|
|
125
|
-
|
117
|
+
const list = { ...otherProps,
|
126
118
|
'aria-activedescendant': getActiveDescendant(data, currentIndex, id),
|
127
|
-
data
|
128
|
-
disabled
|
129
|
-
id
|
119
|
+
data,
|
120
|
+
disabled,
|
121
|
+
id,
|
130
122
|
onChange: handleListboxChange,
|
131
123
|
onFocus: handleListboxFocus,
|
132
124
|
onKeyDown: handleListboxKeyDown,
|
133
125
|
scrollOnFocus: true,
|
134
126
|
tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,
|
135
127
|
value: currentIndex
|
136
|
-
}
|
137
|
-
|
138
|
-
|
139
|
-
name: name,
|
128
|
+
};
|
129
|
+
const input = {
|
130
|
+
name,
|
140
131
|
onChange: handleInputChange,
|
141
132
|
ref: inputRef,
|
142
133
|
tabIndex: -1,
|
143
134
|
value: value === undefined || value === null ? '' : value
|
144
135
|
};
|
145
136
|
return {
|
146
|
-
list
|
147
|
-
input
|
137
|
+
list,
|
138
|
+
input
|
148
139
|
};
|
149
140
|
};
|
150
141
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useListbox.js","sources":["../../../../src/components/Listbox/useListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { ListboxProps } from './Listbox';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { setInputValueByRef, getIndexFromValue, findByValue, getActiveDescendant, useFlattenedData, sanitizeItem } from './util';\nimport { ScrollableListProps } from './ScrollableList';\nimport { useTypeahead } from './useTypeahead';\n\ntype useListbox = {\n list: ScrollableListProps;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\n};\n\nexport const useListbox = (\n {\n data: externalData = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n name,\n onChange,\n onFocus,\n onKeyDown,\n value = emptyValue,\n ...otherProps\n }: ListboxProps,\n ref: React.Ref<HTMLInputElement>\n): useListbox => {\n const data = useFlattenedData(emptyValue !== undefined ? [{ text: '', value: emptyValue }, ...externalData] : externalData);\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const currentIndex = value !== undefined ? getIndexFromValue(data, value) : undefined;\n const { getNextIndex } = useTypeahead({ data, currentIndex });\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value);\n }\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setInputValueByIndex(index);\n };\n\n React.useEffect(() => {\n if (data.length && currentIndex === undefined) {\n if (defaultValue !== undefined) {\n const defaultValueIndex = getIndexFromValue(data, defaultValue);\n\n if (defaultValueIndex !== undefined) {\n setInputValueByIndex(defaultValueIndex);\n }\n } else {\n setInputValueByIndex(0);\n }\n }\n }, [data]);\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n const charKey = String.fromCharCode(event.keyCode);\n\n if (charKey.match(/(\\w)/g)) {\n const nextIndex = getNextIndex(charKey);\n\n if (nextIndex > -1 && nextIndex !== currentIndex) {\n setInputValueByIndex(nextIndex);\n }\n return;\n }\n\n if (onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\n if (currentIndex === undefined && data.length) {\n setInputValueByIndex(0);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(data, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(data.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const list: ScrollableListProps = {\n ...otherProps,\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\n data,\n disabled,\n id,\n onChange: handleListboxChange,\n onFocus: handleListboxFocus,\n onKeyDown: handleListboxKeyDown,\n scrollOnFocus: true,\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\n value: currentIndex,\n };\n\n const input = {\n name,\n onChange: handleInputChange,\n ref: inputRef,\n tabIndex: -1,\n value: value === undefined || value === null ? '' : value,\n };\n\n return { list, input };\n};\n"],"names":["useListbox","
|
1
|
+
{"version":3,"file":"useListbox.js","sources":["../../../../src/components/Listbox/useListbox.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport { v4 as uuid } from 'uuid';\r\nimport { ListboxProps } from './Listbox';\r\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\r\nimport { setInputValueByRef, getIndexFromValue, findByValue, getActiveDescendant, useFlattenedData, sanitizeItem } from './util';\r\nimport { ScrollableListProps } from './ScrollableList';\r\nimport { useTypeahead } from './useTypeahead';\r\n\r\ntype useListbox = {\r\n list: ScrollableListProps;\r\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\r\n};\r\n\r\nexport const useListbox = (\r\n {\r\n data: externalData = [],\r\n defaultValue,\r\n disabled,\r\n emptyValue,\r\n id: nativeId,\r\n name,\r\n onChange,\r\n onFocus,\r\n onKeyDown,\r\n value = emptyValue,\r\n ...otherProps\r\n }: ListboxProps,\r\n ref: React.Ref<HTMLInputElement>\r\n): useListbox => {\r\n const data = useFlattenedData(emptyValue !== undefined ? [{ text: '', value: emptyValue }, ...externalData] : externalData);\r\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\r\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\r\n const currentIndex = value !== undefined ? getIndexFromValue(data, value) : undefined;\r\n const { getNextIndex } = useTypeahead({ data, currentIndex });\r\n\r\n const setInputValueByIndex = (index: number | undefined): void => {\r\n if (index !== undefined) {\r\n const option = data[index];\r\n\r\n if (option && !option.disabled) {\r\n setInputValueByRef(inputRef.current, option.value);\r\n }\r\n }\r\n };\r\n\r\n const handleListboxChange = (index: number): void => {\r\n setInputValueByIndex(index);\r\n };\r\n\r\n React.useEffect(() => {\r\n if (data.length && currentIndex === undefined) {\r\n if (defaultValue !== undefined) {\r\n const defaultValueIndex = getIndexFromValue(data, defaultValue);\r\n\r\n if (defaultValueIndex !== undefined) {\r\n setInputValueByIndex(defaultValueIndex);\r\n }\r\n } else {\r\n setInputValueByIndex(0);\r\n }\r\n }\r\n }, [data]);\r\n\r\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\r\n const charKey = String.fromCharCode(event.keyCode);\r\n\r\n if (charKey.match(/(\\w)/g)) {\r\n const nextIndex = getNextIndex(charKey);\r\n\r\n if (nextIndex > -1 && nextIndex !== currentIndex) {\r\n setInputValueByIndex(nextIndex);\r\n }\r\n return;\r\n }\r\n\r\n if (onKeyDown) {\r\n event.persist();\r\n onKeyDown(event);\r\n }\r\n };\r\n\r\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\r\n if (currentIndex === undefined && data.length) {\r\n setInputValueByIndex(0);\r\n }\r\n\r\n if (onFocus) {\r\n event.persist();\r\n onFocus(event);\r\n }\r\n };\r\n\r\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\r\n event.persist();\r\n\r\n if (onChange) {\r\n const item = findByValue(data, event.target.value);\r\n (event as any).detail = sanitizeItem(item);\r\n\r\n const indexes = item?.path?.split('.') ?? [];\r\n\r\n if (indexes.length > 1) {\r\n // we don't want to map the current item\r\n indexes.pop();\r\n // we need to rebuild the path as we map\r\n let lastPath: string;\r\n\r\n (event as any).detail.parents = indexes.map(i => {\r\n lastPath = lastPath ? [lastPath, i].join('.') : i;\r\n return sanitizeItem(data.find(i => i.path === lastPath));\r\n });\r\n }\r\n\r\n onChange(event);\r\n }\r\n };\r\n\r\n const list: ScrollableListProps = {\r\n ...otherProps,\r\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\r\n data,\r\n disabled,\r\n id,\r\n onChange: handleListboxChange,\r\n onFocus: handleListboxFocus,\r\n onKeyDown: handleListboxKeyDown,\r\n scrollOnFocus: true,\r\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\r\n value: currentIndex,\r\n };\r\n\r\n const input = {\r\n name,\r\n onChange: handleInputChange,\r\n ref: inputRef,\r\n tabIndex: -1,\r\n value: value === undefined || value === null ? '' : value,\r\n };\r\n\r\n return { list, input };\r\n};\r\n"],"names":["useListbox","data","externalData","defaultValue","disabled","emptyValue","id","nativeId","name","onChange","onFocus","onKeyDown","value","otherProps","ref","useFlattenedData","undefined","text","React","uuid","inputRef","useProxiedRef","currentIndex","getIndexFromValue","getNextIndex","useTypeahead","setInputValueByIndex","index","option","setInputValueByRef","current","handleListboxChange","length","defaultValueIndex","handleListboxKeyDown","event","charKey","String","fromCharCode","keyCode","match","nextIndex","persist","handleListboxFocus","handleInputChange","item","findByValue","target","detail","sanitizeItem","indexes","path","split","pop","lastPath","parents","map","i","join","find","list","getActiveDescendant","scrollOnFocus","tabIndex","input"],"mappings":";;;;;;MAaaA,UAAU,GAAG,CACtB;AACIC,EAAAA,IAAI,EAAEC,YAAY,GAAG,EADzB;AAEIC,EAAAA,YAFJ;AAGIC,EAAAA,QAHJ;AAIIC,EAAAA,UAJJ;AAKIC,EAAAA,EAAE,EAAEC,QALR;AAMIC,EAAAA,IANJ;AAOIC,EAAAA,QAPJ;AAQIC,EAAAA,OARJ;AASIC,EAAAA,SATJ;AAUIC,EAAAA,KAAK,GAAGP,UAVZ;AAWI,KAAGQ;AAXP,CADsB,EActBC,GAdsB;AAgBtB,QAAMb,IAAI,GAAGc,gBAAgB,CAACV,UAAU,KAAKW,SAAf,GAA2B,CAAC;AAAEC,IAAAA,IAAI,EAAE,EAAR;AAAYL,IAAAA,KAAK,EAAEP;AAAnB,GAAD,EAAkC,GAAGH,YAArC,CAA3B,GAAgFA,YAAjF,CAA7B;AACA,QAAMI,EAAE,GAAGY,OAAA,CAA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