@economic/taco 2.45.0-alpha.0 → 2.45.0-create.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/AlertDialog/components/Content.d.ts +1 -1
- package/dist/components/Calendar/Calendar.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Dialog/components/Content.d.ts +1 -1
- package/dist/components/Dialog/components/DialogDrawer.d.ts +2 -2
- package/dist/components/Drawer/components/Content.d.ts +2 -2
- package/dist/components/Header/components/Agreement/Badge.d.ts +1 -1
- package/dist/components/Header/components/Agreement/Display.d.ts +2 -2
- package/dist/components/Header/components/Agreement/Item.d.ts +2 -2
- package/dist/components/Header/components/AgreementSelector.d.ts +2 -2
- package/dist/components/Header/components/Button.d.ts +1 -1
- package/dist/components/HoverCard/HoverCard.d.ts +1 -1
- package/dist/components/Icon/components/AccountPreview.d.ts +1 -1
- package/dist/components/Icon/components/Accounting.d.ts +1 -1
- package/dist/components/Icon/components/AccountingYear.d.ts +1 -1
- package/dist/components/Icon/components/AccountingYearCancel.d.ts +1 -1
- package/dist/components/Icon/components/AiChatSolid.d.ts +1 -1
- package/dist/components/Icon/components/AiStars.d.ts +1 -1
- package/dist/components/Icon/components/ArrowBottom.d.ts +1 -1
- package/dist/components/Icon/components/ArrowDown.d.ts +1 -1
- package/dist/components/Icon/components/ArrowEnd.d.ts +1 -1
- package/dist/components/Icon/components/ArrowLeft.d.ts +1 -1
- package/dist/components/Icon/components/ArrowRight.d.ts +1 -1
- package/dist/components/Icon/components/ArrowStart.d.ts +1 -1
- package/dist/components/Icon/components/ArrowTop.d.ts +1 -1
- package/dist/components/Icon/components/ArrowUp.d.ts +1 -1
- package/dist/components/Icon/components/Attach.d.ts +1 -1
- package/dist/components/Icon/components/AttachAuto.d.ts +1 -1
- package/dist/components/Icon/components/AttachCancel.d.ts +1 -1
- package/dist/components/Icon/components/AttachWarning.d.ts +1 -1
- package/dist/components/Icon/components/Autotext.d.ts +1 -1
- package/dist/components/Icon/components/AutotextInsert.d.ts +1 -1
- package/dist/components/Icon/components/Basic.d.ts +1 -1
- package/dist/components/Icon/components/BasicTabs.d.ts +1 -1
- package/dist/components/Icon/components/BellSolid.d.ts +1 -1
- package/dist/components/Icon/components/Book.d.ts +1 -1
- package/dist/components/Icon/components/Booking.d.ts +1 -1
- package/dist/components/Icon/components/Budget.d.ts +1 -1
- package/dist/components/Icon/components/Calendar.d.ts +1 -1
- package/dist/components/Icon/components/CashAccount.d.ts +1 -1
- package/dist/components/Icon/components/CashReports.d.ts +1 -1
- package/dist/components/Icon/components/ChartArea.d.ts +1 -1
- package/dist/components/Icon/components/ChartBar.d.ts +1 -1
- package/dist/components/Icon/components/ChartLine.d.ts +1 -1
- package/dist/components/Icon/components/ChartPie.d.ts +1 -1
- package/dist/components/Icon/components/ChartTable.d.ts +1 -1
- package/dist/components/Icon/components/Chat.d.ts +1 -1
- package/dist/components/Icon/components/ChatSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDown.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDownDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronDownSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeft.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeftDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronLeftSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRight.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRightDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronRightSolid.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUp.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUpDouble.d.ts +1 -1
- package/dist/components/Icon/components/ChevronUpSolid.d.ts +1 -1
- package/dist/components/Icon/components/CircleClose.d.ts +1 -1
- package/dist/components/Icon/components/CircleInformation.d.ts +1 -1
- package/dist/components/Icon/components/CircleMinus.d.ts +1 -1
- package/dist/components/Icon/components/CirclePlus.d.ts +1 -1
- package/dist/components/Icon/components/CircleQuestionmark.d.ts +1 -1
- package/dist/components/Icon/components/CircleTick.d.ts +1 -1
- package/dist/components/Icon/components/CircleWarning.d.ts +1 -1
- package/dist/components/Icon/components/Clamp.d.ts +1 -1
- package/dist/components/Icon/components/ClampOpen.d.ts +1 -1
- package/dist/components/Icon/components/Close.d.ts +1 -1
- package/dist/components/Icon/components/ColumnFreeze.d.ts +1 -1
- package/dist/components/Icon/components/ColumnUnfreeze.d.ts +1 -1
- package/dist/components/Icon/components/Columns.d.ts +1 -1
- package/dist/components/Icon/components/ConnectionEnable.d.ts +1 -1
- package/dist/components/Icon/components/ConnectionRevoke.d.ts +1 -1
- package/dist/components/Icon/components/Contacts.d.ts +1 -1
- package/dist/components/Icon/components/Copy.d.ts +1 -1
- package/dist/components/Icon/components/Courses.d.ts +1 -1
- package/dist/components/Icon/components/Credit.d.ts +1 -1
- package/dist/components/Icon/components/Delete.d.ts +1 -1
- package/dist/components/Icon/components/DeletePermanently.d.ts +1 -1
- package/dist/components/Icon/components/Depecriate.d.ts +1 -1
- package/dist/components/Icon/components/Developer.d.ts +1 -1
- package/dist/components/Icon/components/DistributionTemplate.d.ts +1 -1
- package/dist/components/Icon/components/Document.d.ts +1 -1
- package/dist/components/Icon/components/DocumentApprove.d.ts +1 -1
- package/dist/components/Icon/components/DocumentCreateEntry.d.ts +1 -1
- package/dist/components/Icon/components/DocumentCut.d.ts +1 -1
- package/dist/components/Icon/components/DocumentError.d.ts +1 -1
- package/dist/components/Icon/components/DocumentIsolatePage.d.ts +1 -1
- package/dist/components/Icon/components/DocumentMerge.d.ts +1 -1
- package/dist/components/Icon/components/DocumentMove.d.ts +1 -1
- package/dist/components/Icon/components/DocumentPreview.d.ts +1 -1
- package/dist/components/Icon/components/DocumentReceived.d.ts +1 -1
- package/dist/components/Icon/components/DocumentRejectedRequest.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSigned.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSignedSolid.d.ts +1 -1
- package/dist/components/Icon/components/DocumentSplit.d.ts +1 -1
- package/dist/components/Icon/components/DocumentTime.d.ts +1 -1
- package/dist/components/Icon/components/Download.d.ts +1 -1
- package/dist/components/Icon/components/Drag.d.ts +1 -1
- package/dist/components/Icon/components/ECopedia.d.ts +1 -1
- package/dist/components/Icon/components/Edit.d.ts +1 -1
- package/dist/components/Icon/components/EditSimple.d.ts +1 -1
- package/dist/components/Icon/components/EllipsisHorizontal.d.ts +1 -1
- package/dist/components/Icon/components/EllipsisVertical.d.ts +1 -1
- package/dist/components/Icon/components/EntriesOnAccount.d.ts +1 -1
- package/dist/components/Icon/components/EntriesOpen.d.ts +1 -1
- package/dist/components/Icon/components/EntriesWarning.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeCustomerPayment.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeJournalEntry.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeManualCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeSupplierInvoice.d.ts +1 -1
- package/dist/components/Icon/components/EntryTypeSupplierPayment.d.ts +1 -1
- package/dist/components/Icon/components/Envelope.d.ts +1 -1
- package/dist/components/Icon/components/EnvelopeApproved.d.ts +1 -1
- package/dist/components/Icon/components/EnvelopeSolid.d.ts +1 -1
- package/dist/components/Icon/components/ExpandView.d.ts +1 -1
- package/dist/components/Icon/components/Expenses.d.ts +1 -1
- package/dist/components/Icon/components/Export.d.ts +1 -1
- package/dist/components/Icon/components/ExportToExcel.d.ts +1 -1
- package/dist/components/Icon/components/ExportToPdf.d.ts +1 -1
- package/dist/components/Icon/components/EyeOff.d.ts +1 -1
- package/dist/components/Icon/components/EyeOn.d.ts +1 -1
- package/dist/components/Icon/components/Filter.d.ts +1 -1
- package/dist/components/Icon/components/FilterSolid.d.ts +1 -1
- package/dist/components/Icon/components/FontSize.d.ts +1 -1
- package/dist/components/Icon/components/GraphSolid.d.ts +1 -1
- package/dist/components/Icon/components/Hash.d.ts +1 -1
- package/dist/components/Icon/components/HeightExtraTall.d.ts +1 -1
- package/dist/components/Icon/components/HeightMedium.d.ts +1 -1
- package/dist/components/Icon/components/HeightShort.d.ts +1 -1
- package/dist/components/Icon/components/HeightTall.d.ts +1 -1
- package/dist/components/Icon/components/House.d.ts +1 -1
- package/dist/components/Icon/components/HouseSolid.d.ts +1 -1
- package/dist/components/Icon/components/Id.d.ts +1 -1
- package/dist/components/Icon/components/Images.d.ts +1 -1
- package/dist/components/Icon/components/Import.d.ts +1 -1
- package/dist/components/Icon/components/Inbox.d.ts +1 -1
- package/dist/components/Icon/components/InboxEinvoicing.d.ts +1 -1
- package/dist/components/Icon/components/InboxScanning.d.ts +1 -1
- package/dist/components/Icon/components/InboxSmart.d.ts +1 -1
- package/dist/components/Icon/components/Info.d.ts +1 -1
- package/dist/components/Icon/components/Inventory.d.ts +1 -1
- package/dist/components/Icon/components/InventoryMatrix.d.ts +1 -1
- package/dist/components/Icon/components/JournalPro.d.ts +1 -1
- package/dist/components/Icon/components/Layout.d.ts +1 -1
- package/dist/components/Icon/components/LayoutBoth.d.ts +1 -1
- package/dist/components/Icon/components/LayoutFirst.d.ts +1 -1
- package/dist/components/Icon/components/LayoutLast.d.ts +1 -1
- package/dist/components/Icon/components/LayoutNone.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCard.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardCustomerReminder.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardManualCustomerInvoice.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardObsoleteStock.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardOpeningEntry.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardReservedEntry.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardShrinkagePilferage.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardStockAdjustment.d.ts +1 -1
- package/dist/components/Icon/components/LedgerCardTransferredOpeningEntry.d.ts +1 -1
- package/dist/components/Icon/components/Lightbulb.d.ts +1 -1
- package/dist/components/Icon/components/Line.d.ts +1 -1
- package/dist/components/Icon/components/LinkExternal.d.ts +1 -1
- package/dist/components/Icon/components/List.d.ts +1 -1
- package/dist/components/Icon/components/ListBulleted.d.ts +1 -1
- package/dist/components/Icon/components/ListSearch.d.ts +1 -1
- package/dist/components/Icon/components/Location.d.ts +1 -1
- package/dist/components/Icon/components/Lock.d.ts +1 -1
- package/dist/components/Icon/components/LockOpen.d.ts +1 -1
- package/dist/components/Icon/components/Log.d.ts +1 -1
- package/dist/components/Icon/components/LogOut.d.ts +1 -1
- package/dist/components/Icon/components/Market.d.ts +1 -1
- package/dist/components/Icon/components/MastercardOs.d.ts +1 -1
- package/dist/components/Icon/components/MatchAmount.d.ts +1 -1
- package/dist/components/Icon/components/MatchEntries.d.ts +1 -1
- package/dist/components/Icon/components/Menu.d.ts +1 -1
- package/dist/components/Icon/components/Mileage.d.ts +1 -1
- package/dist/components/Icon/components/ModalResize.d.ts +1 -1
- package/dist/components/Icon/components/ModalShrink.d.ts +1 -1
- package/dist/components/Icon/components/More.d.ts +1 -1
- package/dist/components/Icon/components/MoreSolid.d.ts +1 -1
- package/dist/components/Icon/components/Move.d.ts +1 -1
- package/dist/components/Icon/components/NavigationList.d.ts +1 -1
- package/dist/components/Icon/components/Note.d.ts +1 -1
- package/dist/components/Icon/components/NoteFollowUp.d.ts +1 -1
- package/dist/components/Icon/components/NoteRead.d.ts +1 -1
- package/dist/components/Icon/components/NovemberFirst.d.ts +1 -1
- package/dist/components/Icon/components/Numbers.d.ts +1 -1
- package/dist/components/Icon/components/PartnerApi.d.ts +1 -1
- package/dist/components/Icon/components/PaymentPaid.d.ts +1 -1
- package/dist/components/Icon/components/PaymentUnpaid.d.ts +1 -1
- package/dist/components/Icon/components/Period.d.ts +1 -1
- package/dist/components/Icon/components/PersonChange.d.ts +1 -1
- package/dist/components/Icon/components/PersonMinus.d.ts +1 -1
- package/dist/components/Icon/components/PersonPlus.d.ts +1 -1
- package/dist/components/Icon/components/PersonTick.d.ts +1 -1
- package/dist/components/Icon/components/Phone.d.ts +1 -1
- package/dist/components/Icon/components/PhoneSolid.d.ts +1 -1
- package/dist/components/Icon/components/Play.d.ts +1 -1
- package/dist/components/Icon/components/PlusMinus.d.ts +1 -1
- package/dist/components/Icon/components/Print.d.ts +1 -1
- package/dist/components/Icon/components/ProcessPayment.d.ts +1 -1
- package/dist/components/Icon/components/ProductLedgerCard.d.ts +1 -1
- package/dist/components/Icon/components/Profile.d.ts +1 -1
- package/dist/components/Icon/components/ProjectCards.d.ts +1 -1
- package/dist/components/Icon/components/Projects.d.ts +1 -1
- package/dist/components/Icon/components/QuestionMark.d.ts +1 -1
- package/dist/components/Icon/components/QuestionMarkBold.d.ts +1 -1
- package/dist/components/Icon/components/Quicklinks.d.ts +1 -1
- package/dist/components/Icon/components/RatingBankruptcy.d.ts +1 -1
- package/dist/components/Icon/components/RatingPaymentProblems.d.ts +1 -1
- package/dist/components/Icon/components/Reconciled.d.ts +1 -1
- package/dist/components/Icon/components/Refresh.d.ts +1 -1
- package/dist/components/Icon/components/Report.d.ts +1 -1
- package/dist/components/Icon/components/ReportSolid.d.ts +1 -1
- package/dist/components/Icon/components/Restore.d.ts +1 -1
- package/dist/components/Icon/components/RotateLeft.d.ts +1 -1
- package/dist/components/Icon/components/RotateRight.d.ts +1 -1
- package/dist/components/Icon/components/Sales.d.ts +1 -1
- package/dist/components/Icon/components/Search.d.ts +1 -1
- package/dist/components/Icon/components/SearchBold.d.ts +1 -1
- package/dist/components/Icon/components/Secure.d.ts +1 -1
- package/dist/components/Icon/components/SecureTick.d.ts +1 -1
- package/dist/components/Icon/components/Settings.d.ts +1 -1
- package/dist/components/Icon/components/SettingsSolid.d.ts +1 -1
- package/dist/components/Icon/components/Shortcuts.d.ts +1 -1
- package/dist/components/Icon/components/ShowAll.d.ts +1 -1
- package/dist/components/Icon/components/ShowLess.d.ts +1 -1
- package/dist/components/Icon/components/ShowMore.d.ts +1 -1
- package/dist/components/Icon/components/ShowTemplate.d.ts +1 -1
- package/dist/components/Icon/components/Sliders.d.ts +1 -1
- package/dist/components/Icon/components/Smartpay.d.ts +1 -1
- package/dist/components/Icon/components/SortBy.d.ts +1 -1
- package/dist/components/Icon/components/Star.d.ts +1 -1
- package/dist/components/Icon/components/StarSolid.d.ts +1 -1
- package/dist/components/Icon/components/Subscriptions.d.ts +1 -1
- package/dist/components/Icon/components/SystemEntries.d.ts +1 -1
- package/dist/components/Icon/components/Tag.d.ts +1 -1
- package/dist/components/Icon/components/TemplateOverride.d.ts +1 -1
- package/dist/components/Icon/components/Templates.d.ts +1 -1
- package/dist/components/Icon/components/ThumbBoth.d.ts +1 -1
- package/dist/components/Icon/components/ThumbDown.d.ts +1 -1
- package/dist/components/Icon/components/ThumbDownSolid.d.ts +1 -1
- package/dist/components/Icon/components/ThumbUp.d.ts +1 -1
- package/dist/components/Icon/components/ThumbUpSolid.d.ts +1 -1
- package/dist/components/Icon/components/Tick.d.ts +1 -1
- package/dist/components/Icon/components/TickBold.d.ts +1 -1
- package/dist/components/Icon/components/Time.d.ts +1 -1
- package/dist/components/Icon/components/Transfer.d.ts +1 -1
- package/dist/components/Icon/components/TransferCancel.d.ts +1 -1
- package/dist/components/Icon/components/TransferLocked.d.ts +1 -1
- package/dist/components/Icon/components/Undo.d.ts +1 -1
- package/dist/components/Icon/components/Undock.d.ts +1 -1
- package/dist/components/Icon/components/Unreconciled.d.ts +1 -1
- package/dist/components/Icon/components/Warning.d.ts +1 -1
- package/dist/components/Icon/components/Webshop.d.ts +1 -1
- package/dist/components/Icon/components/Website.d.ts +1 -1
- package/dist/components/Icon/components/Workflow.d.ts +1 -1
- package/dist/components/Icon/components/WorkflowTemplateBasic.d.ts +1 -1
- package/dist/components/Icon/components/Zoom.d.ts +1 -1
- package/dist/components/IconButton/IconButton.d.ts +2 -2
- package/dist/components/Input/Input.d.ts +2 -2
- package/dist/components/Input/util.d.ts +1 -11
- package/dist/components/Layout/components/Sidebar.d.ts +2 -14
- package/dist/components/Layout/components/Top.d.ts +2 -2
- package/dist/components/List/List.d.ts +7 -7
- package/dist/components/List/components/Button.d.ts +1 -1
- package/dist/components/List/components/Collapsible.d.ts +1 -1
- package/dist/components/List/components/Group.d.ts +1 -1
- package/dist/components/List/components/Item.d.ts +1 -1
- package/dist/components/List/components/Link.d.ts +1 -1
- package/dist/components/List/components/Toggle.d.ts +2 -2
- package/dist/components/Listbox/Listbox.d.ts +2 -2
- package/dist/components/Listbox/ScrollableList.d.ts +1 -1
- package/dist/components/Listbox/util.d.ts +2 -2
- package/dist/components/Menu/components/Checkbox.d.ts +1 -1
- package/dist/components/Menu/components/Content.d.ts +2 -2
- package/dist/components/Menu/components/Item.d.ts +8 -8
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Menu/components/RadioGroup.d.ts +1 -1
- package/dist/components/Menu/components/SubMenu.d.ts +1 -1
- package/dist/components/Menu/components/Trigger.d.ts +1 -1
- package/dist/components/Navigation2/components/Group.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Provider/Localization.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/ScrollArea/ScrollArea.d.ts +2 -2
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select2/components/All.d.ts +2 -2
- package/dist/components/Select2/components/Collection.d.ts +1 -1
- package/dist/components/Select2/components/Create.d.ts +1 -1
- package/dist/components/Select2/components/Edit.d.ts +2 -2
- package/dist/components/Select2/components/Group.d.ts +1 -1
- package/dist/components/Select2/components/Option.d.ts +1 -1
- package/dist/components/Select2/components/Search.d.ts +3 -3
- package/dist/components/Select2/components/Trigger.d.ts +1 -1
- package/dist/components/Select2/hooks/useChildren.d.ts +2 -2
- package/dist/components/Select2/utilities.d.ts +2 -0
- package/dist/components/Shortcut/Shortcut.d.ts +1 -1
- package/dist/components/Table3/Table3.d.ts +2 -14
- package/dist/components/Table3/components/Columns/Cell/Cell.d.ts +2 -2
- package/dist/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.d.ts +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.d.ts +2 -2
- package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +3 -4
- package/dist/components/Table3/components/Editing/Alert.d.ts +1 -1
- package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
- package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +13 -0
- package/dist/components/Table3/components/Row/Editing/SaveStatus.d.ts +2 -2
- package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +12 -0
- package/dist/components/Table3/components/Row/Row.d.ts +2 -2
- package/dist/components/Table3/components/Toolbar/Editing/Editing.d.ts +1 -1
- package/dist/components/Table3/features/useEditingState.d.ts +29 -0
- package/dist/components/Table3/features/useTableEditing.d.ts +24 -36
- package/dist/components/Table3/types.d.ts +23 -8
- package/dist/components/Table3/useTable3.d.ts +6 -0
- package/dist/components/Table3/util/editing.d.ts +0 -1
- package/dist/components/Tag/Tag.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tour/Tour.d.ts +3 -3
- package/dist/components/Truncate/Truncate.d.ts +1 -1
- package/dist/esm/index.css +6 -2
- package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +17 -17
- package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +3 -3
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Avatar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +3 -5
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +4 -4
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +29 -5
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js +10 -11
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +2 -0
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +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 +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/Select2/hooks/useChildren.js +1 -10
- package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/utilities.js +11 -1
- package/dist/esm/packages/taco/src/components/Select2/utilities.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +21 -7
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +24 -6
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +5 -36
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +88 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +93 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +5 -7
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +514 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +16 -406
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +37 -32
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +21 -7
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +3 -28
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toast.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tour/Tour.js +3 -3
- package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useIntersectionObserver.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +20 -4
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Container.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +3 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +9 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +6 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Goto.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Resizer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/SortIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +1 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +7 -4
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.css +6 -2
- package/dist/primitives/BubbleSelect.d.ts +1 -1
- package/dist/primitives/Collection/components/Root.d.ts +3 -1
- package/dist/primitives/Sortable/components/Container.d.ts +2 -2
- package/dist/primitives/Sortable/components/Item.d.ts +1 -2
- package/dist/primitives/Sortable/components/List.d.ts +1 -1
- package/dist/primitives/Table/Core/Table.d.ts +3 -2
- package/dist/primitives/Table/Core/components/Body/Body.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Columns/Cell/Cell.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +5 -3
- package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +3 -3
- package/dist/primitives/Table/Core/components/Footer/Summary.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/Header.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Header/components/Goto.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Header/components/SortIndicator.d.ts +3 -3
- package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Row/Row.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Search/Search.d.ts +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Settings/Settings.d.ts +2 -2
- package/dist/primitives/Table/types.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +1 -1
- package/dist/taco.cjs.development.js +960 -694
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +2 -1
- package/package.json +11 -11
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\nimport { getRadioClassnames } from './util';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn('self-start', getRadioClassnames(isDisabled, context.invalid));\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\nimport { getRadioClassnames } from './util';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn('self-start', getRadioClassnames(isDisabled, context.invalid));\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: ReactGroupBaseChild[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n radioGroupItemValues.push(child.props.value);\n }\n });\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n disabled,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start gap-y-2',\n {\n 'flex-wrap gap-x-4 ': otherProps.orientation === 'horizontal',\n 'flex-col': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","isDisabled","className","cn","getRadioClassnames","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;MAQaA,8BAA8B,GAAIC,KAA0B,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;MAE3FE,WAAW,GAAGA,CAACC,MAA6B,EAAEC,aAAqB,KAC5ED,MAAM,CAACE,IAAI,CAACL,KAAK,IAAID,8BAA8B,CAACC,KAAK,CAAC,KAAKI,aAAa;AAEhF,MAAME,iBAAiB,gBAAGC,aAAmB,CAAC;EAAEC,QAAQ,EAAE,KAAK;EAAEC,OAAO,EAAE;CAAO,CAAC;AAclF,MAAMC,cAAc,gBAAGH,UAAgB,CAAC,SAASG,cAAcA,CAACC,KAA0B,EAAEC,GAAiC;EACzH,MAAMC,OAAO,GAAGN,UAAgB,CAACD,iBAAiB,CAAC;EACnD,MAAM;IAAEQ,QAAQ;IAAEd,KA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,CAAC;AACDsB,UAAU,CAACE,IAAI,GAAG1B,cAAc;;;;"}
|
@@ -11,12 +11,12 @@ const Bar = props => {
|
|
11
11
|
className: className
|
12
12
|
}));
|
13
13
|
};
|
14
|
-
const Thumb =
|
14
|
+
const Thumb = props => /*#__PURE__*/React__default.createElement(Thumb$1, Object.assign({}, props, {
|
15
15
|
className: "flex-[1] rounded bg-black opacity-50"
|
16
|
-
});
|
17
|
-
const Corner =
|
16
|
+
}));
|
17
|
+
const Corner = props => /*#__PURE__*/React__default.createElement(Corner$1, Object.assign({}, props, {
|
18
18
|
className: "bg-grey-500"
|
19
|
-
});
|
19
|
+
}));
|
20
20
|
const ScrollArea = props => {
|
21
21
|
const {
|
22
22
|
children,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ScrollArea.js","sources":["../../../../../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';\n\nconst Bar =
|
1
|
+
{"version":3,"file":"ScrollArea.js","sources":["../../../../../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';\n\nconst Bar = props => {\n const className = cn(`flex select-none touch-none transition-colors hover:bg-grey`, {\n 'w-[7px] hover:w-[14px] mr-[2px] hover:px-[2px] hover:mr-0': props.orientation === 'vertical',\n 'flex-col h-[7px] hover:h-[14px] mb-[2px] hover:py-[2px] hover:mb-0': props.orientation === 'horizontal',\n });\n return <ScrollAreaPrimitive.Scrollbar {...props} className={className} />;\n};\n\nconst Thumb = props => <ScrollAreaPrimitive.Thumb {...props} className=\"flex-[1] rounded bg-black opacity-50\" />;\n\nconst Corner = props => <ScrollAreaPrimitive.Corner {...props} className=\"bg-grey-500\" />;\n\nexport type ScrollbarProps = Omit<ScrollAreaPrimitive.ScrollAreaProps, 'scrollHideDelay'>;\n\nexport const ScrollArea = (props: ScrollbarProps) => {\n const { children, ...otherProps } = props;\n\n return (\n <ScrollAreaPrimitive.Root {...otherProps} className={cn('overflow-hidden', props.className)} data-taco=\"scrollarea\">\n <ScrollAreaPrimitive.Viewport className=\"h-full w-full\">{children}</ScrollAreaPrimitive.Viewport>\n <Bar orientation=\"vertical\">\n <Thumb />\n </Bar>\n <Bar orientation=\"horizontal\">\n <Thumb />\n </Bar>\n <Corner />\n </ScrollAreaPrimitive.Root>\n );\n};\n"],"names":["Bar","props","className","cn","orientation","React","ScrollAreaPrimitive","Thumb","Corner","ScrollArea","children","otherProps"],"mappings":";;;;AAIA,MAAMA,GAAG,GAAGC,KAAK;EACb,MAAMC,SAAS,GAAGC,EAAE,CAAC,6DAA6D,EAAE;IAChF,2DAA2D,EAAEF,KAAK,CAACG,WAAW,KAAK,UAAU;IAC7F,oEAAoE,EAAEH,KAAK,CAACG,WAAW,KAAK;GAC/F,CAAC;EACF,oBAAOC,6BAACC,SAA6B,oBAAKL,KAAK;IAAEC,SAAS,EAAEA;KAAa;AAC7E,CAAC;AAED,MAAMK,KAAK,GAAGN,KAAK,iBAAII,6BAACC,OAAyB,oBAAKL,KAAK;EAAEC,SAAS,EAAC;GAAyC;AAEhH,MAAMM,MAAM,GAAGP,KAAK,iBAAII,6BAACC,QAA0B,oBAAKL,KAAK;EAAEC,SAAS,EAAC;GAAgB;MAI5EO,UAAU,GAAIR,KAAqB;EAC5C,MAAM;IAAES,QAAQ;IAAE,GAAGC;GAAY,GAAGV,KAAK;EAEzC,oBACII,6BAACC,IAAwB,oBAAKK,UAAU;IAAET,SAAS,EAAEC,EAAE,CAAC,iBAAiB,EAAEF,KAAK,CAACC,SAAS,CAAC;iBAAY;mBACnGG,6BAACC,QAA4B;IAACJ,SAAS,EAAC;KAAiBQ,QAAQ,CAAgC,eACjGL,6BAACL,GAAG;IAACI,WAAW,EAAC;kBACbC,6BAACE,KAAK,OAAG,CACP,eACNF,6BAACL,GAAG;IAACI,WAAW,EAAC;kBACbC,6BAACE,KAAK,OAAG,CACP,eACNF,6BAACG,MAAM,OAAG,CACa;AAEnC;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = Omit<ListboxProps, 'dialog'> &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, input, text, more = 0 } = useSelect(otherProps, ref);\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'h-8 text-left !pr-0', {\n 'border-blue-500': popover.open,\n 'select-text': otherProps.readOnly,\n });\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span className=\"flex-grow truncate text-left\">{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps: ListboxProps = {\n ...listbox,\n className: 'w-auto',\n invalid: undefined,\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.open ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Trigger {...button} className={inputClassname} ref={internalRef}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow truncate text-left\">{text}</span>}\n <span className=\"flex h-8 w-8 items-center justify-center\">\n <Icon className=\"pointer-events-none\" name={popover.open ? 'chevron-up' : 'chevron-down'} />\n </span>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content align=\"start\" sideOffset={4}>\n {props.multiselect ? <MultiListbox {...commonListboxProps} /> : <Listbox {...commonListboxProps} />}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <input {...input} className=\"hidden\" type=\"text\" />\n </PopoverPrimitive.Root>\n </span>\n );\n});\n\nexport const Select = React.forwardRef(function Select(props: SelectProps, ref: React.Ref<HTMLInputElement>) {\n const { editable, ...otherProps } = props;\n\n if (editable) {\n return <Combobox {...otherProps} dialog={undefined} inline ref={ref} />;\n }\n\n return <BaseSelect {...otherProps} ref={ref} />;\n});\n"],"names":["BaseSelect","React","props","ref","autoFocus","className","externalClassName","highlighted","style","otherProps","button","listbox","popover","input","text","more","useSelect","internalRef","selectDimensions","useBoundingClientRectListener","cn","readOnly","inputClassname","getInputClasses","open","current","focus","renderMultiSelection","Badge","commonListboxProps","invalid","undefined","minWidth","width","tabIndex","PopoverPrimitive","multiselect","Icon","name","align","sideOffset","MultiListbox","Listbox","type","Select","editable","Combobox","dialog","inline"],"mappings":";;;;;;;;;;;
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\n\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = Omit<ListboxProps, 'dialog'> &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, input, text, more = 0 } = useSelect(otherProps, ref);\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'h-8 text-left !pr-0', {\n 'border-blue-500': popover.open,\n 'select-text': otherProps.readOnly,\n });\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span className=\"flex-grow truncate text-left\">{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps: ListboxProps = {\n ...listbox,\n className: 'w-auto',\n invalid: undefined,\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.open ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Trigger {...button} className={inputClassname} ref={internalRef}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow truncate text-left\">{text}</span>}\n <span className=\"flex h-8 w-8 items-center justify-center\">\n <Icon className=\"pointer-events-none\" name={popover.open ? 'chevron-up' : 'chevron-down'} />\n </span>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content align=\"start\" sideOffset={4}>\n {props.multiselect ? <MultiListbox {...commonListboxProps} /> : <Listbox {...commonListboxProps} />}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <input {...input} className=\"hidden\" type=\"text\" />\n </PopoverPrimitive.Root>\n </span>\n );\n});\n\nexport const Select = React.forwardRef(function Select(props: SelectProps, ref: React.Ref<HTMLInputElement>) {\n const { editable, ...otherProps } = props;\n\n if (editable) {\n return <Combobox {...otherProps} dialog={undefined} inline ref={ref} />;\n }\n\n return <BaseSelect {...otherProps} ref={ref} />;\n});\n"],"names":["BaseSelect","React","props","ref","autoFocus","className","externalClassName","highlighted","style","otherProps","button","listbox","popover","input","text","more","useSelect","internalRef","selectDimensions","useBoundingClientRectListener","cn","readOnly","inputClassname","getInputClasses","open","current","focus","renderMultiSelection","Badge","commonListboxProps","invalid","undefined","minWidth","width","tabIndex","PopoverPrimitive","multiselect","Icon","name","align","sideOffset","MultiListbox","Listbox","type","Select","editable","Combobox","dialog","inline"],"mappings":";;;;;;;;;;;AAqCA,MAAMA,UAAU,gBAAGC,UAAgB,CAAC,SAASD,UAAUA,CAACE,KAAsB,EAAEC,GAAgC;EAC5G,MAAM;IAAEC,SAAS;IAAEC,SAAS,EAAEC,iBAAiB;IAAEC,WAAW;IAA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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,MAAMn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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,MAAMl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AE,GAAGG,SAAS;IAC/E,eAAe,EAAEnB,QAAQ,GAAG,MAAM,GAAGmB,SAAS;IAC9C3B,QAAQ,EAAEA,QAAQ;IAClBE,EAAE,EAAEsB,QAAQ;IACZlB,OAAO,EAAEiE,iBAAiB;IAC1BW,OAAO,EAAEV,iBAAiB;IAC1BnC,SAAS,EAAE,CAACrC,QAAQ,IAAI,CAACQ,QAAQ,GAAGwB,mBAAmB,GAAGL,SAAS;IACnElB,QAAQ;IACR0E,IAAI,EAAE;GACT;EAED,MAAMC,OAAO,GAAyB;IAClC,GAAGzE,UAAU;IACb,YAAY,EAAEf,SAAS;IACvB,iBAAiB,EAAEC,cAAc;IACjCC,IAAI;IACJE,QAAQ;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,CAAC,CAAC;;QAErCnB,OAAO,CAACD,IAAI,CAAC;;KAEpB;IACDqB,IAAI;IACJC;GACH;AACL;;;;"}
|
@@ -6,6 +6,7 @@ import { useLocalization } from '../Provider/Localization.js';
|
|
6
6
|
import { Button } from '../Button/Button.js';
|
7
7
|
import { Spinner } from '../Spinner/Spinner.js';
|
8
8
|
import { Root, Trigger, Portal, Content } from '@radix-ui/react-popover';
|
9
|
+
import { debounce } from '../../utils/debounce.js';
|
9
10
|
import { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener.js';
|
10
11
|
import { createCustomKeyboardEvent } from '../../utils/input.js';
|
11
12
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
@@ -16,7 +17,7 @@ import { Root as Root$1, createListboxValueSetter } from '../../primitives/Listb
|
|
16
17
|
import '../../primitives/Listbox2/components/Option.js';
|
17
18
|
import '../../primitives/Listbox2/components/Group.js';
|
18
19
|
import '../../primitives/Listbox2/components/Title.js';
|
19
|
-
import { createCollectionClassName, getFontSize } from './utilities.js';
|
20
|
+
import { createCollectionClassName, getFontSize, filterOption } from './utilities.js';
|
20
21
|
import { Select2Context } from './components/Context.js';
|
21
22
|
import { Option } from './components/Option.js';
|
22
23
|
import { Group } from './components/Group.js';
|
@@ -134,6 +135,26 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
134
135
|
createDialog,
|
135
136
|
createTriggerText
|
136
137
|
};
|
138
|
+
const hasInlineCreation = onCreate && !createDialog;
|
139
|
+
const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;
|
140
|
+
const visibleChildren = searchQuery === '' ? initialChildren : filteredChildren;
|
141
|
+
const selectOptions = searchQuery === '' ? flattenedChildren.map(child => child.props.value) : filteredChildren.map(child => isGroup(child) ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value) : child.props.value).flatMap(c => c) || [];
|
142
|
+
// support typeahead functionality when search isn't available
|
143
|
+
const queryTimeoutRef = React__default.useRef('');
|
144
|
+
const typeahead = debounce(function () {
|
145
|
+
if (!queryTimeoutRef.current) {
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
const matchedValueIndex = visibleChildren.findIndex(child => filterOption(child, queryTimeoutRef.current));
|
149
|
+
if (matchedValueIndex > -1) {
|
150
|
+
setValue(selectOptions[matchedValueIndex]);
|
151
|
+
}
|
152
|
+
queryTimeoutRef.current = '';
|
153
|
+
}, 200);
|
154
|
+
const setValueIfMatched = query => {
|
155
|
+
queryTimeoutRef.current = queryTimeoutRef.current + query;
|
156
|
+
typeahead();
|
157
|
+
};
|
137
158
|
const handleKeyDown = event => {
|
138
159
|
var _listboxRef$current;
|
139
160
|
if (open) {
|
@@ -142,6 +163,9 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
142
163
|
return;
|
143
164
|
} else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {
|
144
165
|
setOpen(true);
|
166
|
+
if (!hasSearch) {
|
167
|
+
setValueIfMatched(event.key);
|
168
|
+
}
|
145
169
|
}
|
146
170
|
// the focus should always remain on the input, so we forward events on to the listbox
|
147
171
|
(_listboxRef$current = listboxRef.current) === null || _listboxRef$current === void 0 ? void 0 : _listboxRef$current.dispatchEvent(createCustomKeyboardEvent(event));
|
@@ -168,6 +192,9 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
168
192
|
if (isAriaDirectionKey(event)) {
|
169
193
|
setShouldPauseHoverState(true);
|
170
194
|
}
|
195
|
+
if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {
|
196
|
+
setValueIfMatched(event.key);
|
197
|
+
}
|
171
198
|
};
|
172
199
|
const handleCloseAutoFocus = event => {
|
173
200
|
event.preventDefault();
|
@@ -185,7 +212,6 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
185
212
|
(_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
|
186
213
|
}
|
187
214
|
};
|
188
|
-
const selectOptions = searchQuery === '' ? flattenedChildren.map(child => child.props.value) : filteredChildren.map(child => isGroup(child) ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value) : child.props.value).flatMap(c => c) || [];
|
189
215
|
const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option));
|
190
216
|
const selectAllText = React__default.useMemo(() => {
|
191
217
|
if (searchQuery === '') {
|
@@ -217,8 +243,6 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
217
243
|
setValue(nextValue);
|
218
244
|
}
|
219
245
|
};
|
220
|
-
const hasInlineCreation = onCreate && !createDialog;
|
221
|
-
const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;
|
222
246
|
const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md ', {
|
223
247
|
'focus-within:yt-focus': !hasSearch,
|
224
248
|
'outline-none': hasSearch
|
@@ -285,7 +309,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
285
309
|
ref: listboxRef,
|
286
310
|
setValue: setValue,
|
287
311
|
value: value
|
288
|
-
},
|
312
|
+
}, /*#__PURE__*/React__default.createElement(Collection, null, visibleChildren), onCreate ? /*#__PURE__*/React__default.createElement(Create, {
|
289
313
|
onCreate: onCreate,
|
290
314
|
options: flattenedChildren
|
291
315
|
}) : null))))), /*#__PURE__*/React__default.createElement(ControlledHiddenField, {
|
@@ -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, 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';\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 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\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\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 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 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 hasInlineCreation = onCreate && !createDialog;\n const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;\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 {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\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","handleKeyDown","event","preventDefault","isElementInsideTable3OrReport","currentTarget","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","length","preselectedValues","filter","nextValue","subValue","hasInlineCreation","hasSearch","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","bubbleVal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8I,WAAW,GAAG9I,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG+I,MAAM,CAAC/I,KAAK,CAAC;;;IAIzD,oBACIxB,6BAACwK,YAAY;;MAAaxI,GAAG,EAAEuI,MAAM,CAACD,WAAW,CAAC;MAAEvJ,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEQ,KAAK,EAAE8I;OACtF7J,UAAU,KAAKC,SAAS,gBAAGV;MAAQwB,KAAK,EAAEf;MAAwB,GAAG,IAAI,EACzEsJ,OAAO,CAAC/D,GAAG,CAACU,MAAM,kBACf1G;MAAQgC,GAAG,EAAEuI,MAAM,CAAC7D,MAAM,CAAC;MAAElF,KAAK,EAAE+I,MAAM,CAAC7D,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACD3G,OAAO,CAAC0K,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\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,GAAGlC,cAAK,CAAC8B,OAAO,CAAC;IAClC,IAAID,WAAW,EAAE;MACb,OAAO,CAACA,WAAW,EAAE,GAAGxB,YAAY,CAAoB;;IAE5D,OAAOA,YAAY;GACtB,EAAE,CAACwB,WAAW,EAAExB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,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;;;;"}
|
@@ -11,20 +11,19 @@ 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
|
-
|
22
|
-
}, {});
|
23
|
-
options.forEach(option => {
|
14
|
+
let occurrences = {};
|
15
|
+
AVAILABLE_COLORS.filter(color => color !== 'transparent').forEach(color => {
|
16
|
+
occurrences = {
|
17
|
+
...occurrences,
|
18
|
+
[color]: 0
|
19
|
+
};
|
20
|
+
});
|
21
|
+
options.reduce((occurrences, option) => {
|
24
22
|
if (option.props.color) {
|
25
23
|
occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;
|
26
24
|
}
|
27
|
-
|
25
|
+
return occurrences;
|
26
|
+
}, occurrences);
|
28
27
|
const colors = Object.keys(occurrences);
|
29
28
|
if (colors.length) {
|
30
29
|
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';\
|
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 let occurrences = {};\n AVAILABLE_COLORS.filter(color => color !== 'transparent').forEach((color: Color) => {\n occurrences = { ...occurrences, [color]: 0 };\n });\n\n options.reduce((occurrences, option) => {\n if (option.props.color) {\n occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;\n }\n return occurrences;\n }, occurrences);\n\n const colors = Object.keys(occurrences);\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 => {\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 => 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","filter","color","forEach","reduce","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":";;;;;;;;;;;;MAmBaA,YAAY,GAAIC,OAAiD;EAC1E,IAAIC,WAAW,GAAG,EAAE;EACpBC,gBAAgB,CAACC,MAAM,CAACC,KAAK,IAAIA,KAAK,KAAK,aAAa,CAAC,CAACC,OAAO,CA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EA;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;IAAC7D,KAAK,EAAE2B,SAAS;IAAEoB,SAAS,EAAC;KAC5B9B,WAAW,CACV,CACP,CACN,CACE,CACF;AAEjB;;;;"}
|
@@ -166,6 +166,7 @@ const Colours = props => {
|
|
166
166
|
const {
|
167
167
|
color,
|
168
168
|
onChangeColor,
|
169
|
+
onClick,
|
169
170
|
onKeyDown
|
170
171
|
} = props;
|
171
172
|
const {
|
@@ -174,6 +175,7 @@ const Colours = props => {
|
|
174
175
|
return /*#__PURE__*/React__default.createElement(Root, {
|
175
176
|
"aria-label": texts.select2.chooseColor,
|
176
177
|
className: "grid grid-cols-4 gap-2 focus:outline-none",
|
178
|
+
onClick: onClick,
|
177
179
|
onKeyDown: onKeyDown,
|
178
180
|
onValueChange: color => onChangeColor(color),
|
179
181
|
value: color
|