@economic/taco 2.44.3 → 2.45.0-alpha.1
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 +4 -4
- package/dist/components/List/List.d.ts +7 -7
- package/dist/components/List/components/Button.d.ts +1 -1
- package/dist/components/List/components/Collapsible.d.ts +1 -1
- package/dist/components/List/components/Group.d.ts +1 -1
- package/dist/components/List/components/Item.d.ts +1 -1
- package/dist/components/List/components/Link.d.ts +1 -1
- package/dist/components/List/components/Toggle.d.ts +2 -2
- package/dist/components/Listbox/Listbox.d.ts +2 -2
- package/dist/components/Listbox/ScrollableList.d.ts +1 -1
- package/dist/components/Listbox/util.d.ts +2 -2
- package/dist/components/Menu/components/Checkbox.d.ts +1 -1
- package/dist/components/Menu/components/Content.d.ts +2 -2
- package/dist/components/Menu/components/Item.d.ts +8 -8
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Menu/components/RadioGroup.d.ts +1 -1
- package/dist/components/Menu/components/SubMenu.d.ts +1 -1
- package/dist/components/Menu/components/Trigger.d.ts +1 -1
- package/dist/components/Navigation2/components/Group.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/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 +2 -2
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +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 +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/useTableSearch.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.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 +3 -2
- 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/Body/util.d.ts +4 -4
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/Cell.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +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 +72 -48
- 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 +12 -14
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useSelect.js","sources":["../../../../../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { v4 as uuid } from 'uuid';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.PopoverProps, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${uuid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0].value);\n }\n }\n } else {\n if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0].value);\n }\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur'));\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, 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(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: open => {\n if (!open && onBlur) {\n onBlur(createCustomEvent('blur'));\n }\n setOpen(open);\n },\n },\n text,\n more,\n };\n};\n"],"names":["useSelect","ariaLabel","ariaLabelledBy","data","defaultValue","disabled","emptyValue","id","nativeId","multiselect","onBlur","onClick","onChange","readOnly","tabIndex","value","otherProps","ref","texts","useLocalization","flattenedData","useFlattenedData","listboxInputRef","useMergedRef","open","setOpen","React","uuid","inputRef","buttonId","lastValue","setLastValue","undefined","findByValue","setInputValueByRef","current","length","handleButtonKeyDown","event","key","preventDefault","handleListboxKeyDown","onKeyDown","handleListboxClick","createCustomEvent","text","more","selectedValues","toString","split","filter","item","select","allOptionsSelected","_findByValue$text","_findByValue","icon","className","cn","props","handleInputChange","persist","_item$path$split","_item$path","target","detail","sanitizeItem","indexes","path","pop","lastPath","parents","map","i","join","find","handleButtonClick","handleButtonFocus","currentTarget","querySelector","_window$getSelection","_window$getSelection$","window","getSelection","selectAllChildren","call","button","onFocus","type","listbox","input","String","popover","onOpenChange"],"mappings":";;;;;;;;MAyBaA,SAAS,GAAGA,CACrB;EACI,YAAY,EAAEC,SAAS;EACvB,iBAAiB,EAAEC,cAAc;EACjCC,IAAI,GAAG,EAAE;EACTC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,EAAE,EAAEC,QAAQ;EACZC,WAAW;EACXC,MAAM;EACNC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,KAAK;EACL,GAAGC;CACO,EACdC,GAAgC;EAEhC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,aAAa,GAAGC,gBAAgB,CAAClB,IAAI,CAAC;EAC5C,MAAMmB,eAAe,GAAGC,YAAY,CAAmBN,GAAG,CAAC;EAC3D,MAAM,CAACO,IAAI,EAAEC,OAAO,CAAC,GAAGC,QAAc,CAAC,KAAK,CAAC;EAC7C,MAAMnB,EAAE,GAAGmB,OAAa,CAAC,MAAMlB,QAAQ,IAAI,UAAUmB,EAAI,EAAE,EAAE,EAAE,CAACnB,QAAQ,CAAC,CAAC;EAC1E,MAAMoB,QAAQ,GAAGF,MAAY,CAAmB,IAAI,CAAC;EACrD,MAAMG,QAAQ,GAAG,GAAGtB,EAAE,SAAS;;EAE/B,MAAM,CAACuB,SAAS,EAAEC,YAAY,CAAC,GAAGL,QAAc,CAAsCX,KAAK,CAAC;EAE5FW,SAAe,CAAC;IACZK,YAAY,CAAChB,KAAK,CAAC;GACtB,EAAE,CAACS,IAAI,CAAC,CAAC;EAEVE,SAAe,CAAC;IACZ,IAAIX,KAAK,KAAKiB,SAAS,EAAE;MACrB,IAAI5B,YAAY,KAAK4B,SAAS,IAAIC,WAAW,CAACb,a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MAAM;IACNC,OAAO,EAAEgC,kBAAkB;IAC3B/B,QAAQ,EAAE0B,KAAK;MACXJ,kBAAkB,CAACN,QAAQ,CAACO,OAAO,EAAEG,KAAK,CAAC0B,MAAM,CAACjD,KAAK,CAAC;KAC3D;IACD2B,SAAS,EAAED,oBAAoB;IAC/BxB,GAAG,EAAEK,eAAe;IACpBP;GACH;EAED,MAAM2E,KAAK,GAAuB;IAC9B9E,QAAQ,EAAEgD,iBAAiB;IAC3B3C,GAAG,EAAEW,QAAQ;IACbb,KAAK,EAAE4E,MAAM,CAAC5E,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;GAC5B;EAED,OAAO;IACHuE,MAAM;IACNG,OAAO;IACPC,KAAK;IACLE,OAAO,EAAE;MACLpE,IAAI;MACJqE,YAAY,EAAErE,IAAI;QACd,IAAI,CAACA,IAAI,IAAId,MAAM,EAAE;UACjBA,MAAM,CAACkC,iBAAiB,CAAC,MAAM,CAAC,CAAC;;QAErCnB,OAAO,CAACD,IAAI,CAAC;;KAEpB;IACDqB,IAAI;IACJC;GACH;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useSelect.js","sources":["../../../../../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { v4 as uuid } from 'uuid';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useLocalization } from '../Provider/Localization';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { createCustomEvent } from '../../utils/input';\n\ntype InternalButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\ntype InternalListboxProps = ListboxProps & { ref: React.ForwardedRef<HTMLInputElement> };\ntype InternalInputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.ForwardedRef<HTMLInputElement> };\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: InternalButtonProps;\n listbox: InternalListboxProps;\n input: InternalInputProps;\n popover: Pick<PopoverPrimitive.PopoverProps, 'onOpenChange' | 'open'>;\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onBlur,\n onClick,\n onChange,\n readOnly,\n tabIndex,\n value,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const flattenedData = useFlattenedData(data);\n const listboxInputRef = useMergedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${uuid()}`, [nativeId]);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (value === undefined) {\n if (defaultValue !== undefined && findByValue(flattenedData, defaultValue)) {\n setInputValueByRef(inputRef.current, defaultValue);\n } else {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0].value);\n }\n }\n } else {\n if (!multiselect && !findByValue(flattenedData, value)) {\n if (emptyValue !== undefined) {\n setInputValueByRef(inputRef.current, emptyValue);\n } else if (data.length > 0) {\n setInputValueByRef(inputRef.current, data[0].value);\n }\n }\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.key) {\n case 'Escape': {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(listboxInputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n if (onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === flattenedData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(flattenedData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(flattenedData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(flattenedData, 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(flattenedData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (readOnly) {\n event.preventDefault();\n }\n };\n\n // select the value text if the select is readonly\n const handleButtonFocus = (event: React.FocusEvent<HTMLButtonElement>) => {\n if (readOnly) {\n const value = event.currentTarget.querySelector(':first-child');\n\n if (value) {\n window.getSelection()?.selectAllChildren?.(value);\n }\n }\n };\n\n const button: InternalButtonProps = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n 'aria-readonly': readOnly ? 'true' : undefined,\n disabled: disabled,\n id: buttonId,\n onClick: handleButtonClick,\n onFocus: handleButtonFocus,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n tabIndex,\n type: 'button',\n };\n\n const listbox: InternalListboxProps = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onBlur,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(inputRef.current, event.target.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: listboxInputRef,\n value,\n };\n\n const input: InternalInputProps = {\n onChange: handleInputChange,\n ref: inputRef,\n value: String(value ?? ''),\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: open => {\n if (!open && onBlur) {\n onBlur(createCustomEvent('blur') as unknown as React.FocusEvent<HTMLElement, Element>);\n }\n setOpen(open);\n },\n },\n text,\n more,\n };\n};\n"],"names":["useSelect","ariaLabel","ariaLabelledBy","data","defaultValue","disabled","emptyValue","id","nativeId","multiselect","onBlur","onClick","onChange","readOnly","tabIndex","value","otherProps","ref","texts","useLocalization","flattenedData","useFlattenedData","listboxInputRef","useMergedRef","open","setOpen","React","uuid","inputRef","buttonId","lastValue","setLastValue","undefined","findByValue","setInputValueByRef","current","length","handleButtonKeyDown","event","key","preventDefault","handleListboxKeyDown","onKeyDown","handleListboxClick","createCustomEvent","text","more","selectedValues","toString","split","filter","item","select","allOptionsSelected","_findByValue$text","_findByValue","icon","className","cn","props","handleInputChange","persist","_item$path$split","_item$path","target","detail","sanitizeItem","indexes","path","pop","lastPath","parents","map","i","join","find","handleButtonClick","handleButtonFocus","currentTarget","querySelector","_window$getSelection","_window$getSelection$","window","getSelection","selectAllChildren","call","button","onFocus","type","listbox","input","String","popover","onOpenChange"],"mappings":";;;;;;;;MAyBaA,SAAS,GAAGA,CACrB;EACI,YAAY,EAAEC,SAAS;EACvB,iBAAiB,EAAEC,cAAc;EACjCC,IAAI,GAAG,EAAE;EACTC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,EAAE,EAAEC,QAAQ;EACZC,WAAW;EACXC,MAAM;EACNC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,KAAK;EACL,GAAGC;CACO,EACdC,GAAgC;EAEhC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,aAAa,GAAGC,gBAAgB,CAAClB,IAAI,CAAC;EAC5C,MAAMmB,eAAe,GAAGC,YAAY,CAAmBN,GAAG,CAAC;EAC3D,MAAM,CAACO,IAAI,EAAEC,OAAO,CAAC,GAAGC,QAAc,CAAC,KAAK,CAAC;EAC7C,MAAMnB,EAAE,GAAGmB,OAAa,CAAC,MAAMlB,QAAQ,IAAI,UAAUmB,EAAI,EAAE,EAAE,EAAE,CAACnB,QAAQ,CAAC,CAAC;EAC1E,MAAMoB,QAAQ,GAAGF,MAAY,CAAmB,IAAI,CAAC;EACrD,MAAMG,QAAQ,GAAG,GAAGtB,EAAE,SAAS;;EAE/B,MAAM,CAACuB,SAAS,EAAEC,YAAY,CAAC,GAAGL,QAAc,CAAsCX,KAAK,CAAC;EAE5FW,SAAe,CAAC;IACZK,YAAY,CAAChB,KAAK,CAAC;GACtB,EAAE,CAACS,IAAI,CAAC,CAAC;EAEVE,SAAe,CAAC;IACZ,IAAIX,KAAK,KAAKiB,SAAS,EAAE;MACrB,IAAI5B,YAAY,KAAK4B,SAAS,I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;IACRC,UAAU;IACVI,MAAM;IACNC,OAAO,EAAEgC,kBAAkB;IAC3B/B,QAAQ,EAAE0B,KAAK;MACXJ,kBAAkB,CAACN,QAAQ,CAACO,OAAO,EAAEG,KAAK,CAAC0B,MAAM,CAACjD,KAAK,CAAC;KAC3D;IACD2B,SAAS,EAAED,oBAAoB;IAC/BxB,GAAG,EAAEK,eAAe;IACpBP;GACH;EAED,MAAM2E,KAAK,GAAuB;IAC9B9E,QAAQ,EAAEgD,iBAAiB;IAC3B3C,GAAG,EAAEW,QAAQ;IACbb,KAAK,EAAE4E,MAAM,CAAC5E,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;GAC5B;EAED,OAAO;IACHuE,MAAM;IACNG,OAAO;IACPC,KAAK;IACLE,OAAO,EAAE;MACLpE,IAAI;MACJqE,YAAY,EAAErE,IAAI;QACd,IAAI,CAACA,IAAI,IAAId,MAAM,EAAE;UACjBA,MAAM,CAACkC,iBAAiB,CAAC,MAAM,CAAsD,CAAC;;QAE1FnB,OAAO,CAACD,IAAI,CAAC;;KAEpB;IACDqB,IAAI;IACJC;GACH;AACL;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2CreateDialogRenderer,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName, filterOption, getFontSize } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement, isElementInsideTable3OrReport } from '../../utils/dom';\nimport { FontSize, FontSizes } from '../../types';\nimport { Button } from '../Button/Button';\nimport { Spinner } from '../Spinner/Spinner';\nimport { debounce } from '../../utils/debounce';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 is loading the data **/\n loading?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Create dialog component, if specified, then create button will become always visible in the bottom of options dropdown,\n * when clicked, it will open create dialog and wait for 'onCreate' handler to be triggered from the dialog */\n createDialog?: Select2CreateDialogRenderer;\n /** Create button text */\n createTriggerText?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n fontSize,\n highlighted = false,\n invalid = false,\n loading,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n placeholder,\n readOnly = false,\n tags = false,\n value: prop,\n createDialog,\n createTriggerText,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n createDialog,\n createTriggerText,\n };\n\n const hasInlineCreation = onCreate && !createDialog;\n const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;\n const visibleChildren = searchQuery === '' ? initialChildren : filteredChildren;\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n // support typeahead functionality when search isn't available\n const queryTimeoutRef = React.useRef('');\n\n const typeahead = debounce(function () {\n if (!queryTimeoutRef.current) {\n return;\n }\n\n const matchedValueIndex = visibleChildren.findIndex(child =>\n filterOption(child as React.ReactElement<Select2OptionProps>, queryTimeoutRef.current)\n );\n\n if (matchedValueIndex > -1) {\n setValue(selectOptions[matchedValueIndex]);\n }\n\n queryTimeoutRef.current = '';\n }, 200);\n\n const setValueIfMatched = (query: string) => {\n queryTimeoutRef.current = queryTimeoutRef.current + query;\n typeahead();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (isElementInsideTable3OrReport(event.currentTarget)) {\n return;\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n\n if (!hasSearch) {\n setValueIfMatched(event.key);\n }\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n\n if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {\n setValueIfMatched(event.key);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn(\n 'border-grey-300 rounded border bg-white py-1.5 shadow-md ',\n {\n 'focus-within:yt-focus': !hasSearch,\n 'outline-none': hasSearch,\n },\n createCollectionClassName()\n );\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {hasSearch ? (\n <>\n <Search\n placeholder={hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {loading ? (\n <span className={cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))}>\n <span>\n <Spinner\n delay={0}\n className={cn('ml-3 mr-2 mt-1.5 h-5 w-5', {\n '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,\n '!h-4 !w-4': fontSize === FontSizes.medium,\n '!h-5 !w-5': fontSize === FontSizes.large,\n })}\n />\n </span>\n <span>{texts.listbox.loading}</span>\n </span>\n ) : flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n {texts.listbox.empty}\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5 focus-visible:outline-none\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n value={value}>\n <Collection>{visibleChildren}</Collection>\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","fontSize","highlighted","invalid","loading","multiple","name","onChange","onCreate","onDelete","onEdit","placeholder","readOnly","tags","value","prop","createDialog","createTriggerText","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","hasInlineCreation","hasSearch","length","visibleChildren","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","queryTimeoutRef","typeahead","debounce","current","matchedValueIndex","findIndex","filterOption","setValueIfMatched","query","handleKeyDown","event","preventDefault","isElementInsideTable3OrReport","currentTarget","ctrlKey","metaKey","test","_listboxRef$current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","onTabKeyPress","Button","appearance","onClick","getFontSize","Spinner","delay","FontSizes","small","medium","large","listbox","role","empty","customSelector","Collection","Create","options","ControlledHiddenField","parentRef","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4GMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,QAAQ;IACRC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,OAAO;IACPC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,WAAW;IACXC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACXC,YAAY;IACZC,iBAAiB;IACjB,GAAGC;GACN,GAAG1B,KAAK;EAET,MAAM2B,WAAW,GAAuD7B,cAAK,CAAC8B,OAAO,CAAC;IAClF,IAAIrB,UAAU,KAAKC,SAAS,IAAI,CAACK,QAAQ,EAAE;;MAEvC,oBAAOf,6BAAC+B,MAAM;QAACC,GAAG,EAAC,SAAS;QAAC5B,QAAQ,EAAC,EAAE;QAACoB,KAAK,EAAEf,UAAU;QAAEwB,SAAS,EAAC;QAAQ;;IAElF;GACH,EAAE,CAACxB,UAAU,EAAEM,QAAQ,CAAC,CAAC;EAE1B,MAAMmB,eAAe,GA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AY;;MAAajJ,GAAG,EAAEgJ,MAAM,CAACD,WAAW,CAAC;MAAEhK,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEQ,KAAK,EAAEuJ;OACtFtK,UAAU,KAAKC,SAAS,gBAAGV;MAAQwB,KAAK,EAAEf;MAAc,GAAG,IAAI,EAC/D+J,OAAO,CAACnG,GAAG,CAACiD,MAAM,kBACftH;MAAQgC,GAAG,EAAEgJ,MAAM,CAAC1D,MAAM,CAAC;MAAE9F,KAAK,EAAEwJ,MAAM,CAAC1D,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDvH,OAAO,CAACmL,WAAW,GAAG,SAAS;;;;"}
|
1
|
+
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2CreateDialogRenderer,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName, filterOption, getFontSize } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement, isElementInsideTable3OrReport } from '../../utils/dom';\nimport { FontSize, FontSizes } from '../../types';\nimport { Button } from '../Button/Button';\nimport { Spinner } from '../Spinner/Spinner';\nimport { debounce } from '../../utils/debounce';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 is loading the data **/\n loading?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Create dialog component, if specified, then create button will become always visible in the bottom of options dropdown,\n * when clicked, it will open create dialog and wait for 'onCreate' handler to be triggered from the dialog */\n createDialog?: Select2CreateDialogRenderer;\n /** Create button text */\n createTriggerText?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n fontSize,\n highlighted = false,\n invalid = false,\n loading,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n placeholder,\n readOnly = false,\n tags = false,\n value: prop,\n createDialog,\n createTriggerText,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n createDialog,\n createTriggerText,\n };\n\n const hasInlineCreation = onCreate && !createDialog;\n const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;\n const visibleChildren = searchQuery === '' ? initialChildren : filteredChildren;\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n // support typeahead functionality when search isn't available\n const queryTimeoutRef = React.useRef('');\n\n const typeahead = debounce(function () {\n if (!queryTimeoutRef.current) {\n return;\n }\n\n const matchedValueIndex = visibleChildren.findIndex(child =>\n filterOption(child as React.ReactElement<Select2OptionProps>, queryTimeoutRef.current)\n );\n\n if (matchedValueIndex > -1) {\n setValue(selectOptions[matchedValueIndex]);\n }\n\n queryTimeoutRef.current = '';\n }, 200);\n\n const setValueIfMatched = (query: string) => {\n queryTimeoutRef.current = queryTimeoutRef.current + query;\n typeahead();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (isElementInsideTable3OrReport(event.currentTarget)) {\n return;\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n\n if (!hasSearch) {\n setValueIfMatched(event.key);\n }\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n\n if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {\n setValueIfMatched(event.key);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn(\n 'border-grey-300 rounded border bg-white py-1.5 shadow-md ',\n {\n 'focus-within:yt-focus': !hasSearch,\n 'outline-none': hasSearch,\n },\n createCollectionClassName()\n );\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {hasSearch ? (\n <>\n <Search\n placeholder={hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {loading ? (\n <span className={cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))}>\n <span>\n <Spinner\n delay={0}\n className={cn('ml-3 mr-2 mt-1.5 h-5 w-5', {\n '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,\n '!h-4 !w-4': fontSize === FontSizes.medium,\n '!h-5 !w-5': fontSize === FontSizes.large,\n })}\n />\n </span>\n <span>{texts.listbox.loading}</span>\n </span>\n ) : flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n {texts.listbox.empty}\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5 focus-visible:outline-none\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n value={value}>\n <Collection>{visibleChildren}</Collection>\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\ntype ControlledHiddenFieldProps = {\n emptyValue: ListboxPrimitive.Listbox2OptionValue | undefined;\n multiple: boolean;\n name: string | undefined;\n options: Array<any>;\n parentRef: React.RefObject<HTMLButtonElement>;\n setValue: (nextValue: any) => void;\n value: Select2Value | undefined;\n};\n\nconst ControlledHiddenField = (props: ControlledHiddenFieldProps) => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue as string} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","fontSize","highlighted","invalid","loading","multiple","name","onChange","onCreate","onDelete","onEdit","placeholder","readOnly","tags","value","prop","createDialog","createTriggerText","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","hasInlineCreation","hasSearch","length","visibleChildren","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","queryTimeoutRef","typeahead","debounce","current","matchedValueIndex","findIndex","filterOption","setValueIfMatched","query","handleKeyDown","event","preventDefault","isElementInsideTable3OrReport","currentTarget","ctrlKey","metaKey","test","_listboxRef$current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","onTabKeyPress","Button","appearance","onClick","getFontSize","Spinner","delay","FontSizes","small","medium","large","listbox","role","empty","customSelector","Collection","Create","options","ControlledHiddenField","parentRef","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4GMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,QAAQ;IACRC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,OAAO;IACPC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,WAAW;IACXC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACXC,YAAY;IACZC,iBAAiB;IACjB,GAAGC;GACN,GAAG1B,KAAK;EAET,MAAM2B,WAAW,GAAuD7B,cAAK,CAAC8B,OAAO,CAAC;IAClF,IAAIrB,UAAU,KAAKC,SAAS,IAAI,CAACK,QAAQ,EAAE;;MAEvC,oBAAOf,6BAAC+B,MAAM;QAACC,GAAG,EAAC,SAAS;QAAC5B,QAAQ,EAAC,EAAE;QAACoB,KAAK,EAAEf,UAAU;QAAEwB,SAAS,EAAC;QAAQ;;IAElF;GACH,EAAE,CAACxB,UAAU,EAAEM,QAAQ,CAAC,CAAC;EAE1B,MAAMmB,eAAe,GAAGlC,cAAK,CAAC8B,OAAO,CAAC;IAClC,IAAID,WAAW,EAAE;MACb,OAAO,CAACA,WAA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,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEQ,KAAK,EAAEuJ;OACtFtK,UAAU,KAAKC,SAAS,gBAAGV;MAAQwB,KAAK,EAAEf;MAAwB,GAAG,IAAI,EACzE+J,OAAO,CAACnG,GAAG,CAACiD,MAAM,kBACftH;MAAQgC,GAAG,EAAEgJ,MAAM,CAAC1D,MAAM,CAAC;MAAE9F,KAAK,EAAEwJ,MAAM,CAAC1D,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDvH,OAAO,CAACmL,WAAW,GAAG,SAAS;;;;"}
|
@@ -11,19 +11,20 @@ import { createOptionClassName } from '../utilities.js';
|
|
11
11
|
import { useSelect2Context } from './Context.js';
|
12
12
|
|
13
13
|
const getNextColor = options => {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
const occurrences = AVAILABLE_COLORS.reduce((prev, color) => {
|
15
|
+
if (color !== 'transparent') {
|
16
|
+
return {
|
17
|
+
...prev,
|
18
|
+
[color]: 0
|
19
|
+
};
|
20
|
+
}
|
21
|
+
return prev;
|
22
|
+
}, {});
|
23
|
+
options.forEach(option => {
|
22
24
|
if (option.props.color) {
|
23
25
|
occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;
|
24
26
|
}
|
25
|
-
|
26
|
-
}, occurrences);
|
27
|
+
});
|
27
28
|
const colors = Object.keys(occurrences);
|
28
29
|
if (colors.length) {
|
29
30
|
return colors.sort((a, b) => occurrences[a] - occurrences[b])[0];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Create.js","sources":["../../../../../../../../src/components/Select2/components/Create.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport { Tag } from '../../Tag/Tag';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\nimport { AVAILABLE_COLORS } from '../../../utils/tailwind';\nimport { Select2CreateHandler } from '../types';\nimport { Icon } from '../../Icon/Icon';\nimport { Button } from '../../Button/Button';\n\nexport type CreateProps = {\n onCreate: Select2CreateHandler;\n options: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const getNextColor = (options: React.ReactElement<Select2OptionProps>[]): Color | undefined => {\n
|
1
|
+
{"version":3,"file":"Create.js","sources":["../../../../../../../../src/components/Select2/components/Create.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport { Tag } from '../../Tag/Tag';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\nimport { AVAILABLE_COLORS } from '../../../utils/tailwind';\nimport { Select2CreateHandler } from '../types';\nimport { Icon } from '../../Icon/Icon';\nimport { Button } from '../../Button/Button';\nimport { DialogProps } from '../../Dialog/Dialog';\n\nexport type CreateProps = {\n onCreate: Select2CreateHandler;\n options: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const getNextColor = (options: React.ReactElement<Select2OptionProps>[]): Color | undefined => {\n const occurrences = AVAILABLE_COLORS.reduce((prev, color: Color) => {\n if (color !== 'transparent') {\n return { ...prev, [color]: 0 };\n }\n return prev;\n }, {} as Record<Color, number>);\n\n options.forEach(option => {\n if (option.props.color) {\n occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;\n }\n });\n\n const colors = Object.keys(occurrences) as Color[];\n\n if (colors.length) {\n return colors.sort((a, b) => occurrences[a] - occurrences[b])[0] as Color;\n }\n\n return undefined;\n};\n\nexport const Create = (props: CreateProps) => {\n const { onCreate: handleCreate, options } = props;\n const { multiple, searchQuery, setOpen, setSearchQuery, setValidationError, setValue, createDialog, createTriggerText } =\n useSelect2Context();\n const { texts } = useLocalization();\n\n // determine what the next color tag should be based on color occurences\n const nextColor = React.useMemo(() => getNextColor(options), [options]);\n\n const onCreateDialogClose = React.useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n if (!createDialog && !searchQuery) {\n return null;\n }\n\n const create = async (value?: string | unknown) => {\n try {\n const item = await handleCreate(value, nextColor);\n setValue(item.value);\n\n if (multiple) {\n setSearchQuery('');\n } else {\n setOpen(false);\n }\n } catch (error) {\n setValidationError(error as Error);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (isAriaSelectionKey(event)) {\n event.currentTarget.click();\n }\n };\n\n const className = cn(createOptionClassName(), {\n '!w-[calc(100%_-_theme(spacing.3))] ml-1.5': !createDialog,\n 'leading-normal border-grey-300 h-9 border-t py-2.5 px-4 !-mb-1.5': !!createDialog,\n });\n\n const creationOptions = createDialog\n ? {\n dialog: (props: Partial<DialogProps>) =>\n createDialog({ ...props, onClose: onCreateDialogClose }, searchQuery, create),\n }\n : {\n onClick: () => create(searchQuery),\n };\n\n const createText = createTriggerText || texts.select2.create;\n\n return (\n <Button\n className={className}\n {...creationOptions}\n onKeyDown={handleKeyDown}\n appearance={createDialog ? 'discrete' : 'default'}>\n <span className=\"flex items-center gap-1.5\">\n {createDialog ? (\n <>\n <Icon className=\"text-xs\" name=\"circle-plus\" /> {createText}\n </>\n ) : (\n <>\n {createText}\n <Tag color={nextColor} className=\"cursor-pointer\">\n {searchQuery}\n </Tag>\n </>\n )}\n </span>\n </Button>\n );\n};\n"],"names":["getNextColor","options","occurrences","AVAILABLE_COLORS","reduce","prev","color","forEach","option","props","colors","Object","keys","length","sort","a","b","undefined","Create","onCreate","handleCreate","multiple","searchQuery","setOpen","setSearchQuery","setValidationError","setValue","createDialog","createTriggerText","useSelect2Context","texts","useLocalization","nextColor","React","useMemo","onCreateDialogClose","useCallback","create","value","Promise","resolve","then","item","error","_temp","e","reject","handleKeyDown","event","isAriaSelectionKey","currentTarget","click","className","cn","createOptionClassName","creationOptions","dialog","onClose","onClick","createText","select2","Button","onKeyDown","appearance","Icon","name","Tag"],"mappings":";;;;;;;;;;;;MAoBaA,YAAY,GAAIC,OAAiD;EAC1E,MAAMC,WAAW,GAAGC,gBAAgB,CAACC,MAAM,CAAC,CAACC,IAAI,EAAEC,KAAY;IAC3D,IAAIA,KAAK,KAAK,aAAa,EAAE;MACzB,OAAO;QAAE,GAAGD,IAAI;QAAE,CAACC,KAAK,GAAG;OAAG;;IAElC,OAAOD,IAAI;GACd,EAAE,EAA2B,CAAC;EAE/BJ,OAAO,CAACM,OAAO,CAACC,MAAM;IAClB,IAAIA,MAAM,CAACC,KAAK,CAACH,KAAK,EAAE;MACpBJ,WAAW,CAACM,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,GAAGJ,WAAW,CAACM,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,GAAGJ,WAAW,CAACM,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;;GAElH,CAAC;EAEF,MAAMI,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACV,WAAW,CAAY;EAElD,IAAIQ,MAAM,CAACG,MAAM,EAAE;IACf,OAAOH,MAAM,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKd,WAAW,CAACa,CAAC,CAAC,GAAGb,WAAW,CAACc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAU;;EAG7E,OAAOC,SAAS;AACpB;MAEaC,MAAM,GAAIT,KAAkB;EACrC,MAAM;IAAEU,QAAQ,EAAEC,YAAY;IAAEnB;GAAS,GAAGQ,KAAK;EACjD,MAAM;IAAEY,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC,QAAQ;IAAEC,YAAY;IAAEC;GAAmB,GACnHC,iBAAiB,EAAE;EACvB,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;;EAGnC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qB,EAAEb,WAAW,EAAEe,MAAM;GACnF,GACD;IACIqB,OAAO,EAAEA,MAAMrB,MAAM,CAACf,WAAW;GACpC;EAEP,MAAMqC,UAAU,GAAG/B,iBAAiB,IAAIE,KAAK,CAAC8B,OAAO,CAACvB,MAAM;EAE5D,oBACIJ,6BAAC4B,MAAM;IACHT,SAAS,EAAEA;KACPG,eAAe;IACnBO,SAAS,EAAEf,aAAa;IACxBgB,UAAU,EAAEpC,YAAY,GAAG,UAAU,GAAG;mBACxCM;IAAMmB,SAAS,EAAC;KACXzB,YAAY,iBACTM,yEACIA,6BAAC+B,IAAI;IAACZ,SAAS,EAAC,SAAS;IAACa,IAAI,EAAC;IAAgB,OAAEN,UAAU,CAC5D,kBAEH1B,4DACK0B,UAAU,eACX1B,6BAACiC,GAAG;IAAC5D,KAAK,EAAE0B,SAAS;IAAEoB,SAAS,EAAC;KAC5B9B,WAAW,CACV,CACP,CACN,CACE,CACF;AAEjB;;;;"}
|
@@ -166,7 +166,6 @@ const Colours = props => {
|
|
166
166
|
const {
|
167
167
|
color,
|
168
168
|
onChangeColor,
|
169
|
-
onClick,
|
170
169
|
onKeyDown
|
171
170
|
} = props;
|
172
171
|
const {
|
@@ -175,7 +174,6 @@ const Colours = props => {
|
|
175
174
|
return /*#__PURE__*/React__default.createElement(Root, {
|
176
175
|
"aria-label": texts.select2.chooseColor,
|
177
176
|
className: "grid grid-cols-4 gap-2 focus:outline-none",
|
178
|
-
onClick: onClick,
|
179
177
|
onKeyDown: onKeyDown,
|
180
178
|
onValueChange: color => onChangeColor(color),
|
181
179
|
value: color
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Edit.js","sources":["../../../../../../../../src/components/Select2/components/Edit.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroup from '@radix-ui/react-radio-group';\nimport { Button } from '../../Button/Button';\nimport { Input } from '../../Input/Input';\nimport { Popover, PopoverProps } from '../../Popover/Popover';\nimport { Icon } from '../../Icon/Icon';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { Group } from '../../Group/Group';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\nimport { AVAILABLE_COLORS, getSubtleColorShadeClasses } from '../../../utils/tailwind';\n\nexport type EditPopoverProps = PopoverProps & {\n color?: Color;\n text: string;\n value: Select2OptionValue;\n};\n\nexport const EditPopover = (props: EditPopoverProps) => {\n const { color: initialColor, text: initialName, value, ...popoverProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const { onDelete, onEdit, searchRef, ref: selectRef } = useSelect2Context();\n const { texts } = useLocalization();\n const [name, setName] = React.useState(initialName);\n const [color, setColor] = React.useState(initialColor);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n\n const handleInputChange = event => {\n setName(event.target.value);\n setValidationError(undefined);\n };\n\n const handleInputKeyDown = close => async event => {\n event.stopPropagation();\n\n if (event.key === 'Escape') {\n close();\n } else if (event.key === 'Enter') {\n handleSave(close)(event);\n }\n };\n\n const handleDelete = close => async event => {\n event.stopPropagation();\n close();\n\n if (onDelete) {\n await onDelete(value);\n }\n };\n\n const handleSave = close => async event => {\n if (onEdit && (name !== initialName || color !== initialColor)) {\n try {\n await onEdit(value, name, color);\n close();\n } catch (error) {\n event.preventDefault();\n event.stopPropagation();\n setValidationError(error as Error);\n ref.current?.focus();\n }\n } else {\n close();\n }\n };\n\n const handleCloseAutoFocus = event => {\n event.preventDefault();\n setName(initialName);\n setColor(initialColor);\n setValidationError(undefined);\n\n if (searchRef?.current) {\n searchRef.current?.focus();\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleInteractOutside = () => {\n setName(initialName);\n setColor(initialColor);\n };\n\n const preventKeyDownPropagation = event => {\n // Need to allow 'Escape', 'Tab', 'Shift + Tab' to support default focus and close behaviour of Radix Popover.\n if (event.key === 'Escape' || event.key === 'Tab' || (event.key === 'Tab' && event.shiftKey)) {\n return;\n } else {\n event.stopPropagation();\n }\n };\n\n const popoverContentKeyDown = event => {\n // Need to stop propagation of 'Tab', 'Shift + Tab' keys out of Popover content,\n // to avoid 'Tab' key execution on Option component and closing the dropdown.\n if (event.key === 'Tab' || (event.key === 'Tab' && event.shiftKey)) {\n event.stopPropagation();\n }\n };\n\n return (\n <Popover {...popoverProps}>\n <Popover.Content\n onCloseAutoFocus={handleCloseAutoFocus}\n onInteractOutside={handleInteractOutside}\n onClick={event => event.stopPropagation()}\n onKeyDown={popoverContentKeyDown}\n placement=\"right\"\n tabIndex={-1}\n className=\"focus:!shadow-none\">\n {({ close }) => (\n <>\n <div className=\"flex w-32 flex-col space-y-2\">\n {onEdit ? (\n <>\n <Field\n className={cn('!min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n invalid={!!validationError}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown(close)}\n ref={ref}\n value={name}\n />\n </Field>\n {initialColor ? (\n <>\n <h5>Colours</h5>\n <Colours\n color={color}\n onChangeColor={setColor}\n onKeyDown={preventKeyDownPropagation}\n />\n </>\n ) : null}\n <Group>\n <Button onClick={close}>{texts.select2.cancel}</Button>\n <Button appearance=\"primary\" onClick={handleSave(close)}>\n {texts.select2.save}\n </Button>\n </Group>\n </>\n ) : null}\n {onEdit && onDelete ? <hr /> : null}\n {onDelete ? (\n <button\n className=\"hover:text-grey-700 flex items-center justify-start gap-1\"\n onClick={handleDelete(close)}\n onKeyDown={preventKeyDownPropagation}>\n <Icon className=\"!h-5 !w-5\" name=\"delete-permanently\" /> {texts.select2.delete}\n </button>\n ) : null}\n </div>\n </>\n )}\n </Popover.Content>\n </Popover>\n );\n};\n\nconst Colours = props => {\n const { color, onChangeColor, onClick, onKeyDown } = props;\n const { texts } = useLocalization();\n\n return (\n <RadioGroup.Root\n aria-label={texts.select2.chooseColor}\n className=\"grid grid-cols-4 gap-2 focus:outline-none\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n onValueChange={color => onChangeColor(color)}\n value={color}>\n {AVAILABLE_COLORS.map((availableColor: string) => (\n <RadioGroup.Item\n aria-label={color}\n className={cn(\n 'flex h-6 w-6 cursor-pointer items-center justify-center rounded',\n getSubtleColorShadeClasses(availableColor as Color)\n )}\n key={availableColor}\n onFocus={() => onChangeColor(availableColor)}\n value={availableColor}>\n <RadioGroup.Indicator asChild>\n <Icon name=\"tick\" className=\"!h-5 !w-5\" />\n </RadioGroup.Indicator>\n </RadioGroup.Item>\n ))}\n </RadioGroup.Root>\n );\n};\n"],"names":["EditPopover","props","color","initialColor","text","initialName","value","popoverProps","ref","React","useRef","onDelete","onEdit","searchRef","selectRef","useSelect2Context","texts","useLocalization","name","setName","useState","setColor","validationError","setValidationError","handleInputChange","event","target","undefined","handleInputKeyDown","close","stopPropagation","key","handleSave","Promise","resolve","e","reject","handleDelete","_temp","then","_temp2","_catch","error","_ref$current","preventDefault","current","focus","_temp3","handleCloseAutoFocus","_searchRef$current","_selectRef$current","handleInteractOutside","preventKeyDownPropagation","shiftKey","popoverContentKeyDown","Popover","Content","onCloseAutoFocus","onInteractOutside","onClick","onKeyDown","placement","tabIndex","className","Field","cn","invalid","message","Input","onChange","Colours","onChangeColor","Group","Button","select2","cancel","appearance","save","Icon","delete","RadioGroup","chooseColor","onValueChange","AVAILABLE_COLORS","map","availableColor","getSubtleColorShadeClasses","onFocus","asChild"],"mappings":";;;;;;;;;;;;;;MAqBaA,WAAW,GAAIC,KAAuB;EAC/C,MAAM;IAAEC,KAAK,EAAEC,YAAY;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGN,KAAK;EAChF,MAAMO,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEL,GAAG,EAAEM;GAAW,GAAGC,iBAAiB,EAAE;EAC3E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;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AAC;IAC5CI,KAAK,EAAEJ;KACNiF,gBAAgB,CAACC,GAAG,CAAEC,cAAsB,kBACzC5E,6BAACuE,IAAe;kBACA9E,KAAK;IACjB6D,SAAS,EAAEE,EAAE,CACT,iEAAiE,EACjEqB,0BAA0B,CAACD,cAAuB,CAAC,CACtD;IACDtD,GAAG,EAAEsD,cAAc;IACnBE,OAAO,EAAEA,MAAMhB,aAAa,CAACc,cAAc,CAAC;IAC5C/E,KAAK,EAAE+E;kBACP5E,6BAACuE,SAAoB;IAACQ,OAAO;kBACzB/E,6BAACqE,IAAI;IAAC5D,IAAI,EAAC,MAAM;IAAC6C,SAAS,EAAC;IAAc,CACvB,CACT,CACrB,CAAC,CACY;AAE1B,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Edit.js","sources":["../../../../../../../../src/components/Select2/components/Edit.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroup from '@radix-ui/react-radio-group';\nimport { Button } from '../../Button/Button';\nimport { Input } from '../../Input/Input';\nimport { Popover, PopoverProps } from '../../Popover/Popover';\nimport { Icon } from '../../Icon/Icon';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { Group } from '../../Group/Group';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\nimport { AVAILABLE_COLORS, getSubtleColorShadeClasses } from '../../../utils/tailwind';\n\nexport type EditPopoverProps = PopoverProps & {\n color?: Color;\n text: string;\n value: Select2OptionValue;\n};\n\nexport const EditPopover = (props: EditPopoverProps) => {\n const { color: initialColor, text: initialName, value, ...popoverProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const { onDelete, onEdit, searchRef, ref: selectRef } = useSelect2Context();\n const { texts } = useLocalization();\n const [name, setName] = React.useState(initialName);\n const [color, setColor] = React.useState(initialColor);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setName(event.target.value);\n setValidationError(undefined);\n };\n\n const handleInputKeyDown = (close: () => void) => async (event: React.KeyboardEvent<HTMLInputElement>) => {\n event.stopPropagation();\n\n if (event.key === 'Escape') {\n close();\n } else if (event.key === 'Enter') {\n handleSave(close)(event);\n }\n };\n\n const handleDelete = (close: () => void) => async (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n close();\n\n if (onDelete) {\n await onDelete(value);\n }\n };\n\n const handleSave = (close: () => void) => async (event: any) => {\n if (onEdit && (name !== initialName || color !== initialColor)) {\n try {\n await onEdit(value, name, color);\n close();\n } catch (error) {\n event.preventDefault();\n event.stopPropagation();\n setValidationError(error as Error);\n ref.current?.focus();\n }\n } else {\n close();\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n setName(initialName);\n setColor(initialColor);\n setValidationError(undefined);\n\n if (searchRef?.current) {\n searchRef.current?.focus();\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleInteractOutside = () => {\n setName(initialName);\n setColor(initialColor);\n };\n\n const preventKeyDownPropagation = (event: React.KeyboardEvent) => {\n // Need to allow 'Escape', 'Tab', 'Shift + Tab' to support default focus and close behaviour of Radix Popover.\n if (event.key === 'Escape' || event.key === 'Tab' || (event.key === 'Tab' && event.shiftKey)) {\n return;\n } else {\n event.stopPropagation();\n }\n };\n\n const popoverContentKeyDown = (event: React.KeyboardEvent) => {\n // Need to stop propagation of 'Tab', 'Shift + Tab' keys out of Popover content,\n // to avoid 'Tab' key execution on Option component and closing the dropdown.\n if (event.key === 'Tab' || (event.key === 'Tab' && event.shiftKey)) {\n event.stopPropagation();\n }\n };\n\n return (\n <Popover {...popoverProps}>\n <Popover.Content\n onCloseAutoFocus={handleCloseAutoFocus}\n onInteractOutside={handleInteractOutside}\n onClick={event => event.stopPropagation()}\n onKeyDown={popoverContentKeyDown}\n placement=\"right\"\n tabIndex={-1}\n className=\"focus:!shadow-none\">\n {({ close }) => (\n <>\n <div className=\"flex w-32 flex-col space-y-2\">\n {onEdit ? (\n <>\n <Field\n className={cn('!min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n invalid={!!validationError}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown(close)}\n ref={ref}\n value={name}\n />\n </Field>\n {initialColor ? (\n <>\n <h5>Colours</h5>\n <Colours\n color={color}\n onChangeColor={setColor}\n onKeyDown={preventKeyDownPropagation}\n />\n </>\n ) : null}\n <Group>\n <Button onClick={close}>{texts.select2.cancel}</Button>\n <Button appearance=\"primary\" onClick={handleSave(close)}>\n {texts.select2.save}\n </Button>\n </Group>\n </>\n ) : null}\n {onEdit && onDelete ? <hr /> : null}\n {onDelete ? (\n <button\n className=\"hover:text-grey-700 flex items-center justify-start gap-1\"\n onClick={handleDelete(close)}\n onKeyDown={preventKeyDownPropagation}>\n <Icon className=\"!h-5 !w-5\" name=\"delete-permanently\" /> {texts.select2.delete}\n </button>\n ) : null}\n </div>\n </>\n )}\n </Popover.Content>\n </Popover>\n );\n};\n\ntype Props = {\n color: string | undefined;\n onChangeColor: React.Dispatch<React.SetStateAction<Color | undefined>>;\n onKeyDown: (event: React.KeyboardEvent) => void;\n};\nconst Colours = (props: Props) => {\n const { color, onChangeColor, onKeyDown } = props;\n const { texts } = useLocalization();\n\n return (\n <RadioGroup.Root\n aria-label={texts.select2.chooseColor}\n className=\"grid grid-cols-4 gap-2 focus:outline-none\"\n onKeyDown={onKeyDown}\n onValueChange={color => onChangeColor(color as Color)}\n value={color}>\n {AVAILABLE_COLORS.map((availableColor: string) => (\n <RadioGroup.Item\n aria-label={color}\n className={cn(\n 'flex h-6 w-6 cursor-pointer items-center justify-center rounded',\n getSubtleColorShadeClasses(availableColor as Color)\n )}\n key={availableColor}\n onFocus={() => onChangeColor(availableColor as Color)}\n value={availableColor}>\n <RadioGroup.Indicator asChild>\n <Icon name=\"tick\" className=\"!h-5 !w-5\" />\n </RadioGroup.Indicator>\n </RadioGroup.Item>\n ))}\n </RadioGroup.Root>\n );\n};\n"],"names":["EditPopover","props","color","initialColor","text","initialName","value","popoverProps","ref","React","useRef","onDelete","onEdit","searchRef","selectRef","useSelect2Context","texts","useLocalization","name","setName","useState","setColor","validationError","setValidationError","handleInputChange","event","target","undefined","handleInputKeyDown","close","stopPropagation","key","handleSave","Promise","resolve","e","reject","handleDelete","_temp","then","_temp2","_catch","error","_ref$current","preventDefault","current","focus","_temp3","handleCloseAutoFocus","_searchRef$current","_selectRef$current","handleInteractOutside","preventKeyDownPropagation","shiftKey","popoverContentKeyDown","Popover","Content","onCloseAutoFocus","onInteractOutside","onClick","onKeyDown","placement","tabIndex","className","Field","cn","invalid","message","Input","onChange","Colours","onChangeColor","Group","Button","select2","cancel","appearance","save","Icon","delete","RadioGroup","chooseColor","onValueChange","AVAILABLE_COLORS","map","availableColor","getSubtleColorShadeClasses","onFocus","asChild"],"mappings":";;;;;;;;;;;;;;MAqBaA,WAAW,GAAIC,KAAuB;EAC/C,MAAM;IAAEC,KAAK,EAAEC,YAAY;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGN,KAAK;EAChF,MAAMO,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEL,GAAG,EAAEM;GAAW,GAAGC,iBAAiB,EAAE;EAC3E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,cAAK,CAACW,QAAQ,CAACf,WAAW,CAAC;EACnD,MAAM,CAACH,KAAK,EAAEmB,QAAQ,CAAC,GAAGZ,cAAK,CAACW,QAAQ,CAACjB,YAAY,CAAC;EACtD,MAAM,CAACmB,eAAe,EAAEC,kBAAkB,CAAC,GAAGd,cAAK,CAACW,QAAQ,EAAqB;EAEjF,MAAMI,iBAAiB,GAAIC,KAA0C;IACjEN,O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qE,IAAI;IAAC5D,IAAI,EAAC,MAAM;IAAC6C,SAAS,EAAC;IAAc,CACvB,CACT,CACrB,CAAC,CACY;AAE1B,CAAC;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName, getFontSize } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\nimport { FontSize } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children' | 'prefix'> & {\n children: string;\n color?: Color;\n description?: string;\n fontSize?: FontSize;\n prefix?: IconName | JSX.Element;\n postfix?: IconName | JSX.Element;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, prefix, postfix, className: cName, ...otherProps } = props;\n const {\n fontSize,\n listboxRef,\n multiple,\n onDelete,\n onEdit,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), getFontSize(fontSize), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={prefix}>\n {children}\n </Tag>\n ) : (\n <>\n {prefix ? typeof prefix === 'string' ? <Icon name={prefix} /> : prefix : null}\n <span className=\"flex w-full justify-between\">\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n <span className=\"flex flex-col self-center\">\n {postfix ? typeof postfix === 'string' ? <Icon name={postfix} /> : postfix : null}\n </span>\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndexByElement(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","prefix","postfix","className","cName","otherProps","fontSize","listboxRef","multiple","onDelete","onEdit","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","getFontSize","hasValue","Array","isArray","length","undefined","isTag","handleClick","_selectRef$current","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","_props$textValue","_props$textValue2","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","icon","IconButton","appearance","isMobileDevice","_window","window","navigator","stopPropagation","_listboxRef$current","setActiveIndexByElement","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAwBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGT,KAAK;EAChG,MAAM;IACFU,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNb,GAAG,EAAEc,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC;GACH,GAAGC,iBAAiB,EAAE;EACvB,MAAMb,SAAS,GAAGc,EAAE,CAACC,qBAAqB,CAACL,qBAAqB,CAAC,EAAEM,WAAW,CAACb,QAAQ,CAAC,EAAEF,KAAK,CAAC;EAEhG,MAAMgB,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,GAAG,CAAC,CAACA,KAAK,CAACQ,MAAM,GAAGR,KAAK,KAAKS,SAAS;EAC5E,MAAMC,KAAK,GAAGX,IAAI,IAAI,CAAC,CAACf,KAAK;EAE7B,MAAM2B,WAAW,GAAGA;IAChB,IAAI,CAAClB,QAAQ,EAAE;MACXI,OAAO,CAAC,KAAK,CAAC;KACjB,MAAM;MAAA,IAAAe,kBAAA;MACH,CAAAA,kBAAA,GAAAhB,SAAS,CAACiB,OAAO,cAAAD,kBAAA,uBAAjBA,kBAAA,CAAmBE,KAAK,EAAE;;GAEjC;EAED,MAAMC,aAAa,GAAIC,KAA0B;IAC7C,IAAIC,kBAAkB,CAACD,KAAK,CAAC,EAAE;MAC3B,IAAI,CAACvB,QAAQ,IAAIuB,KAAK,CAACE,GAAG,KAAK,KAAK,EAAE;QAClCrB,OAAO,CAAC,KAAK,CAAC;;;GAGzB;EAED,MAAMsB,aAAa,GAAGpC,QAAQ,KAAK,EAAE;EAErC,MAAMqC,OAAO,GACTD,aAAa,KAAKxB,MAAM,IAAID,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName, getFontSize } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover, EditPopoverProps } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\nimport { FontSize } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children' | 'prefix'> & {\n children: string;\n color?: Color;\n description?: string;\n fontSize?: FontSize;\n prefix?: IconName | JSX.Element;\n postfix?: IconName | JSX.Element;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, prefix, postfix, className: cName, ...otherProps } = props;\n const {\n fontSize,\n listboxRef,\n multiple,\n onDelete,\n onEdit,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), getFontSize(fontSize), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? (popoverProps: Partial<EditPopoverProps>) => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={prefix}>\n {children}\n </Tag>\n ) : (\n <>\n {prefix ? typeof prefix === 'string' ? <Icon name={prefix} /> : prefix : null}\n <span className=\"flex w-full justify-between\">\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n <span className=\"flex flex-col self-center\">\n {postfix ? typeof postfix === 'string' ? <Icon name={postfix} /> : postfix : null}\n </span>\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndexByElement(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","prefix","postfix","className","cName","otherProps","fontSize","listboxRef","multiple","onDelete","onEdit","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","getFontSize","hasValue","Array","isArray","length","undefined","isTag","handleClick","_selectRef$current","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","_props$textValue","_props$textValue2","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","icon","IconButton","appearance","isMobileDevice","_window","window","navigator","stopPropagation","_listboxRef$current","setActiveIndexByElement","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAwBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGT,KAAK;EAChG,MAAM;IACFU,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNb,GAAG,EAAEc,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC;GACH,GAAGC,iBAAiB,EAAE;EACvB,MAAMb,SAAS,GAAGc,EAAE,CAACC,qBAAqB,CAACL,qBAAqB,CAAC,EAAEM,WAAW,CAACb,QAAQ,CAAC,EAAEF,KAAK,CAAC;EAEhG,MAAMgB,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,GAAG,CAAC,CAACA,KAAK,CAACQ,MAAM,GAAGR,KAAK,KAAKS,SAAS;EAC5E,MAAMC,KAAK,GAAGX,IAAI,IAAI,CAAC,CAACf,KAAK;EAE7B,MAAM2B,WAAW,GAAGA;IAChB,IAAI,CAAClB,QAAQ,EAAE;MACXI,OAAO,CAAC,KAAK,CAAC;KACjB,MAAM;MAAA,IAAAe,kBAAA;MACH,CAAAA,kBAAA,GAAAhB,SAAS,CAACiB,OAAO,cAAAD,kBAAA,uBAAjBA,kBAAA,CAAmBE,KAAK,E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GR,6BAACqD,IAAI;IAACC,IAAI,EAAE9C;IAAU,GAAGA,MAAM,GAAG,IAAI,eAC7ER;IAAMU,SAAS,EAAC;kBACZV;IAAMU,SAAS,EAAC;kBACZV,2CAAOK,QAAQ,CAAQ,EACtBE,WAAW,gBAAGP;IAAMU,SAAS,EAAC;KAAwCH,WAAW,CAAQ,GAAG,IAAI,CAC9F,eACPP;IAAMU,SAAS,EAAC;KACXD,OAAO,GAAG,OAAOA,OAAO,KAAK,QAAQ,gBAAGT,6BAACqD,IAAI;IAACC,IAAI,EAAE7C;IAAW,GAAGA,OAAO,GAAG,IAAI,CAC9E,CACJ,CACR,CACN,EACAiC,OAAO,iBACJ1C,6BAACyD,UAAU;IACPD,IAAI,EAAC,mBAAmB;IACxBE,UAAU,EAAC,UAAU;IACrBhD,SAAS,EAAEc,EAAE,CACT,6KAA6K,EAC7K;MACI,UAAU,EAAEmC,cAAc,EAAAC,OAAA,GAACC,MAAM,cAAAD,OAAA,uBAANA,OAAA,CAAQE,SAAS;KAC/C,CACJ;IACDX,OAAO,EAAEb,KAAK;;MACVA,KAAK,CAACyB,eAAe,EAAE;MACvBjD,UAAU,aAAVA,UAAU,wBAAAkD,mBAAA,GAAVlD,UAAU,CAAEqB,OAAO,cAAA6B,mBAAA,uBAAnBA,mBAAA,CAAqBC,uBAAuB,CAAC3B,KAAK,CAAC4B,aAAa,CAACC,aAA+B,CAAC;KACpG;IACDzB,OAAO,EAAEA,OAAO;IAChB0B,QAAQ,EAAE,CAAC;IACb,IACF,IAAI,CACc;AAElC,CAAC;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {\n onTabKeyPress: () => void;\n};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { onTabKeyPress, ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = event => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = event => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n onTabKeyPress();\n }\n\n if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n // forward navigation events onto the underlying collection - we want arrow keys to work from inside the filter input\n listboxRef?.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n return;\n }\n };\n\n return (\n <Field\n className={cn('mx-1.5 mb-1.5 !min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n {...otherProps}\n autoFocus\n invalid={!!validationError}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={ref}\n value={searchQuery}\n />\n </Field>\n );\n});\n"],"names":["Search","React","forwardRef","ListboxSearch","props","ref","onTabKeyPress","otherProps","listboxRef","searchQuery","setSearchQuery","setValidationError","validationError","setOpen","useSelect2Context","handleChange","event","undefined","target","value","handleKeyDown","key","isAriaSelectionKey","_listboxRef$current","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","Field","className","cn","invalid","message","Input","autoFocus","onChange","onKeyDown"],"mappings":";;;;;;;;MAYaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAuC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EAC1G,MAAM;IAAEC,aAAa;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAC9C,MAAM;IAAEI,UAAU;IAAEC,WAAW;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC,eAAe;IAAEC;GAAS,GAAGC,iBAAiB,EAAE;EAErH,MAAMC,YAAY,
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {\n onTabKeyPress: () => void;\n};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { onTabKeyPress, ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n onTabKeyPress();\n }\n\n if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n // forward navigation events onto the underlying collection - we want arrow keys to work from inside the filter input\n listboxRef?.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n return;\n }\n };\n\n return (\n <Field\n className={cn('mx-1.5 mb-1.5 !min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n {...otherProps}\n autoFocus\n invalid={!!validationError}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={ref}\n value={searchQuery}\n />\n </Field>\n );\n});\n"],"names":["Search","React","forwardRef","ListboxSearch","props","ref","onTabKeyPress","otherProps","listboxRef","searchQuery","setSearchQuery","setValidationError","validationError","setOpen","useSelect2Context","handleChange","event","undefined","target","value","handleKeyDown","key","isAriaSelectionKey","_listboxRef$current","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","Field","className","cn","invalid","message","Input","autoFocus","onChange","onKeyDown"],"mappings":";;;;;;;;MAYaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAuC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EAC1G,MAAM;IAAEC,aAAa;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAC9C,MAAM;IAAEI,UAAU;IAAEC,WAAW;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC,eAAe;IAAEC;GAAS,GAAGC,iBAAiB,EAAE;EAErH,MAAMC,YAAY,GAAIC,KAA0C;IAC5D,IAAIJ,eAAe,EAAE;MACjBD,kBAAkB,CAACM,SAAS,CAAC;;IAGjCP,cAAc,CAACM,KAAK,CAACE,MAAM,CAACC,KAAK,CAAC;GACrC;EAED,MAAMC,aAAa,GAAIJ,KAA0B;;IAE7C,IAAIA,KAAK,CAACK,GAAG,KAAK,GAAG,EAAE;MACnB;;;IAIJ,IAAIL,KAAK,CAACK,GAAG,KAAK,KAAK,EAAE;MACrBR,OAAO,CAAC,KAAK,CAAC;MACdP,aAAa,EAAE;;IAGnB,IAAIgB,kBAAkB,CAACN,KAAK,CAAC,IAAIA,KAAK,CAACK,GAAG,KAAK,WAAW,IAAIL,KAAK,CAACK,GAAG,KAAK,SAAS,EAAE;MAAA,IAAAE,mBAAA;MACnFP,KAAK,CAACQ,cAAc,EAAE;;MAEtBhB,UAAU,aAAVA,UAAU,wBAAAe,mBAAA,GAAVf,UAAU,CAAEiB,OAAO,cAAAF,mBAAA,uBAAnBA,mBAAA,CAAqBG,aAAa,CAACC,yBAAyB,CAACX,KAA8C,CAAC,CAAC;MAC7G;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