@economic/taco 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/components/Card/Card.d.ts +7 -7
- package/dist/esm/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/components/Backdrop/Backdrop.js.map +1 -1
- package/dist/esm/components/Badge/Badge.js.map +1 -1
- package/dist/esm/components/Banner/Banner.js.map +1 -1
- package/dist/esm/components/Banner/util.js.map +1 -1
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Button/util.js.map +1 -1
- package/dist/esm/components/Calendar/Calendar.js.map +1 -1
- package/dist/esm/components/Card/Card.js +19 -4
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/components/Dialog/Context.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
- package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
- package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
- package/dist/esm/components/Field/Field.js.map +1 -1
- package/dist/esm/components/Form/Form.js.map +1 -1
- package/dist/esm/components/Group/Group.js.map +1 -1
- package/dist/esm/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/esm/components/Icon/Icon.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountPreview.js.map +1 -1
- package/dist/esm/components/Icon/components/Accounting.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountingYear.js.map +1 -1
- package/dist/esm/components/Icon/components/AccountingYearCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowBottom.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowEnd.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowRight.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowStart.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowTop.js.map +1 -1
- package/dist/esm/components/Icon/components/ArrowUp.js.map +1 -1
- package/dist/esm/components/Icon/components/Attach.js.map +1 -1
- package/dist/esm/components/Icon/components/AttachAuto.js.map +1 -1
- package/dist/esm/components/Icon/components/AttachCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/Autotext.js.map +1 -1
- package/dist/esm/components/Icon/components/AutotextInsert.js.map +1 -1
- package/dist/esm/components/Icon/components/Basic.js.map +1 -1
- package/dist/esm/components/Icon/components/BasicTabs.js.map +1 -1
- package/dist/esm/components/Icon/components/BellSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Book.js.map +1 -1
- package/dist/esm/components/Icon/components/Booking.js.map +1 -1
- package/dist/esm/components/Icon/components/Budget.js.map +1 -1
- package/dist/esm/components/Icon/components/Calendar.js.map +1 -1
- package/dist/esm/components/Icon/components/CashAccount.js.map +1 -1
- package/dist/esm/components/Icon/components/CashReports.js.map +1 -1
- package/dist/esm/components/Icon/components/Chat.js.map +1 -1
- package/dist/esm/components/Icon/components/ChatSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDownDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronDownSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronLeftDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronRight.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronRightDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUp.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUpDouble.js.map +1 -1
- package/dist/esm/components/Icon/components/ChevronUpSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/CircleClose.js +6 -6
- package/dist/esm/components/Icon/components/CircleClose.js.map +1 -1
- package/dist/esm/components/Icon/components/CircleMinus.js.map +1 -1
- package/dist/esm/components/Icon/components/CirclePlus.js.map +1 -1
- package/dist/esm/components/Icon/components/CircleTick.js.map +1 -1
- package/dist/esm/components/Icon/components/Clamp.js.map +1 -1
- package/dist/esm/components/Icon/components/ClampOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/Close.js.map +1 -1
- package/dist/esm/components/Icon/components/ConnectionEnable.js.map +1 -1
- package/dist/esm/components/Icon/components/ConnectionRevoke.js.map +1 -1
- package/dist/esm/components/Icon/components/Contacts.js.map +1 -1
- package/dist/esm/components/Icon/components/Copy.js.map +1 -1
- package/dist/esm/components/Icon/components/Courses.js.map +1 -1
- package/dist/esm/components/Icon/components/Credit.js.map +1 -1
- package/dist/esm/components/Icon/components/Delete.js.map +1 -1
- package/dist/esm/components/Icon/components/DeletePermanently.js.map +1 -1
- package/dist/esm/components/Icon/components/Depecriate.js.map +1 -1
- package/dist/esm/components/Icon/components/Developer.js.map +1 -1
- package/dist/esm/components/Icon/components/DistributionTemplate.js.map +1 -1
- package/dist/esm/components/Icon/components/Document.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentApprove.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentCreateEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentCut.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentError.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentIsolatePage.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentMerge.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentMove.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentPreview.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentReceived.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentRejectedRequest.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentSplit.js.map +1 -1
- package/dist/esm/components/Icon/components/DocumentTime.js.map +1 -1
- package/dist/esm/components/Icon/components/Download.js.map +1 -1
- package/dist/esm/components/Icon/components/Drag.js.map +1 -1
- package/dist/esm/components/Icon/components/ECopedia.js.map +1 -1
- package/dist/esm/components/Icon/components/ESignature.js.map +1 -1
- package/dist/esm/components/Icon/components/Edit.js.map +1 -1
- package/dist/esm/components/Icon/components/EllipsisHorizontal.js.map +1 -1
- package/dist/esm/components/Icon/components/EllipsisVertical.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesOnAccount.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/EntriesWarning.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeCustomerPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeJournalEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeManualCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeSupplierInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/EntryTypeSupplierPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/Envelope.js.map +1 -1
- package/dist/esm/components/Icon/components/EnvelopeApproved.js.map +1 -1
- package/dist/esm/components/Icon/components/ExpandView.js.map +1 -1
- package/dist/esm/components/Icon/components/Expenses.js.map +1 -1
- package/dist/esm/components/Icon/components/Export.js.map +1 -1
- package/dist/esm/components/Icon/components/ExportToExcel.js.map +1 -1
- package/dist/esm/components/Icon/components/ExportToPdf.js.map +1 -1
- package/dist/esm/components/Icon/components/Filter.js.map +1 -1
- package/dist/esm/components/Icon/components/FilterSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/GraphSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Hash.js.map +1 -1
- package/dist/esm/components/Icon/components/Home.js.map +1 -1
- package/dist/esm/components/Icon/components/Images.js.map +1 -1
- package/dist/esm/components/Icon/components/Import.js.map +1 -1
- package/dist/esm/components/Icon/components/Inbox.js.map +1 -1
- package/dist/esm/components/Icon/components/InboxEinvoicing.js.map +1 -1
- package/dist/esm/components/Icon/components/InboxScanning.js.map +1 -1
- package/dist/esm/components/Icon/components/InboxSmart.js.map +1 -1
- package/dist/esm/components/Icon/components/Info.js.map +1 -1
- package/dist/esm/components/Icon/components/Inventory.js.map +1 -1
- package/dist/esm/components/Icon/components/InventoryMatrix.js.map +1 -1
- package/dist/esm/components/Icon/components/JournalPro.js.map +1 -1
- package/dist/esm/components/Icon/components/Layout.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutBoth.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutFirst.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutLast.js.map +1 -1
- package/dist/esm/components/Icon/components/LayoutNone.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCard.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardCustomerReminder.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardManualCustomerInvoice.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardObsoleteStock.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardOpeningEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardReservedEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardShrinkagePilferage.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardStockAdjustment.js.map +1 -1
- package/dist/esm/components/Icon/components/LedgerCardTransferredOpeningEntry.js.map +1 -1
- package/dist/esm/components/Icon/components/Lightbulb.js.map +1 -1
- package/dist/esm/components/Icon/components/Line.js.map +1 -1
- package/dist/esm/components/Icon/components/List.js.map +1 -1
- package/dist/esm/components/Icon/components/ListBulleted.js.map +1 -1
- package/dist/esm/components/Icon/components/ListSearch.js.map +1 -1
- package/dist/esm/components/Icon/components/LockOpen.js.map +1 -1
- package/dist/esm/components/Icon/components/Log.js.map +1 -1
- package/dist/esm/components/Icon/components/Market.js.map +1 -1
- package/dist/esm/components/Icon/components/MatchAmount.js.map +1 -1
- package/dist/esm/components/Icon/components/MatchEntries.js.map +1 -1
- package/dist/esm/components/Icon/components/Mileage.js.map +1 -1
- package/dist/esm/components/Icon/components/ModalResize.js.map +1 -1
- package/dist/esm/components/Icon/components/ModalShrink.js.map +1 -1
- package/dist/esm/components/Icon/components/More.js.map +1 -1
- package/dist/esm/components/Icon/components/MoreSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Move.js.map +1 -1
- package/dist/esm/components/Icon/components/NavigationList.js.map +1 -1
- package/dist/esm/components/Icon/components/Note.js.map +1 -1
- package/dist/esm/components/Icon/components/NoteFollowUp.js.map +1 -1
- package/dist/esm/components/Icon/components/NoteRead.js.map +1 -1
- package/dist/esm/components/Icon/components/PartnerApi.js.map +1 -1
- package/dist/esm/components/Icon/components/Period.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonChange.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonMinus.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonPlus.js.map +1 -1
- package/dist/esm/components/Icon/components/PersonTick.js.map +1 -1
- package/dist/esm/components/Icon/components/Play.js.map +1 -1
- package/dist/esm/components/Icon/components/PlusMinus.js.map +1 -1
- package/dist/esm/components/Icon/components/Print.js.map +1 -1
- package/dist/esm/components/Icon/components/ProcessPayment.js.map +1 -1
- package/dist/esm/components/Icon/components/ProductLedgerCard.js.map +1 -1
- package/dist/esm/components/Icon/components/ProjectCards.js.map +1 -1
- package/dist/esm/components/Icon/components/Projects.js.map +1 -1
- package/dist/esm/components/Icon/components/Quicklinks.js.map +1 -1
- package/dist/esm/components/Icon/components/RatingBankruptcy.js.map +1 -1
- package/dist/esm/components/Icon/components/RatingPaymentProblems.js.map +1 -1
- package/dist/esm/components/Icon/components/Reconciled.js.map +1 -1
- package/dist/esm/components/Icon/components/Refresh.js.map +1 -1
- package/dist/esm/components/Icon/components/Report.js.map +1 -1
- package/dist/esm/components/Icon/components/ReportSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Restore.js.map +1 -1
- package/dist/esm/components/Icon/components/RotateLeft.js.map +1 -1
- package/dist/esm/components/Icon/components/RotateRight.js.map +1 -1
- package/dist/esm/components/Icon/components/Sales.js.map +1 -1
- package/dist/esm/components/Icon/components/Search.js.map +1 -1
- package/dist/esm/components/Icon/components/SearchBold.js.map +1 -1
- package/dist/esm/components/Icon/components/Secure.js.map +1 -1
- package/dist/esm/components/Icon/components/SecureTick.js.map +1 -1
- package/dist/esm/components/Icon/components/Settings.js.map +1 -1
- package/dist/esm/components/Icon/components/SettingsSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Shortcuts.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowAll.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowLess.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowMore.js.map +1 -1
- package/dist/esm/components/Icon/components/ShowTemplate.js.map +1 -1
- package/dist/esm/components/Icon/components/Sliders.js.map +1 -1
- package/dist/esm/components/Icon/components/Smartpay.js.map +1 -1
- package/dist/esm/components/Icon/components/SortBy.js.map +1 -1
- package/dist/esm/components/Icon/components/Spinner.js.map +1 -1
- package/dist/esm/components/Icon/components/Star.js.map +1 -1
- package/dist/esm/components/Icon/components/StarSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Subscriptions.js.map +1 -1
- package/dist/esm/components/Icon/components/SystemEntries.js.map +1 -1
- package/dist/esm/components/Icon/components/Tag.js.map +1 -1
- package/dist/esm/components/Icon/components/TemplateOverride.js.map +1 -1
- package/dist/esm/components/Icon/components/Templates.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbBoth.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbDown.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbDownSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbUp.js.map +1 -1
- package/dist/esm/components/Icon/components/ThumbUpSolid.js.map +1 -1
- package/dist/esm/components/Icon/components/Tick.js.map +1 -1
- package/dist/esm/components/Icon/components/Time.js.map +1 -1
- package/dist/esm/components/Icon/components/Transfer.js.map +1 -1
- package/dist/esm/components/Icon/components/TransferCancel.js.map +1 -1
- package/dist/esm/components/Icon/components/TransferLocked.js.map +1 -1
- package/dist/esm/components/Icon/components/Undock.js.map +1 -1
- package/dist/esm/components/Icon/components/Unreconciled.js.map +1 -1
- package/dist/esm/components/Icon/components/Warning.js.map +1 -1
- package/dist/esm/components/Icon/components/Webshop.js.map +1 -1
- package/dist/esm/components/Icon/components/Website.js.map +1 -1
- package/dist/esm/components/Icon/components/Workflow.js.map +1 -1
- package/dist/esm/components/Icon/components/Zoom.js.map +1 -1
- package/dist/esm/components/Icon/components/index.js.map +1 -1
- package/dist/esm/components/IconButton/IconButton.js.map +1 -1
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Input/util.js.map +1 -1
- package/dist/esm/components/Listbox/Listbox.js.map +1 -1
- package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/components/Listbox/useListbox.js.map +1 -1
- package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -1
- package/dist/esm/components/Listbox/useTypeahead.js.map +1 -1
- package/dist/esm/components/Listbox/util.js.map +1 -1
- package/dist/esm/components/Menu/Context.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Menu/components/Checkbox.js.map +1 -1
- package/dist/esm/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/components/Menu/components/Header.js.map +1 -1
- package/dist/esm/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/components/Menu/components/Link.js.map +1 -1
- package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -1
- package/dist/esm/components/Menu/components/Separator.js.map +1 -1
- package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
- package/dist/esm/components/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/PageNumbers.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/usePagination.js.map +1 -1
- package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -1
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/Popover/Primitives.js.map +1 -1
- package/dist/esm/components/Progress/Progress.js.map +1 -1
- package/dist/esm/components/Provider/Provider.js.map +1 -1
- package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/useSelect.js.map +1 -1
- package/dist/esm/components/Spinner/Spinner.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Table/components/BaseTable.js.map +1 -1
- package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -1
- package/dist/esm/components/Table/components/Table.js.map +1 -1
- package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
- package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/components/Table/util/renderRow.js.map +1 -1
- package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -1
- package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
- package/dist/esm/components/Table/util.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/components/Toast/Toast.js.map +1 -1
- package/dist/esm/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/components/Toast/util.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Tour/Tour.js.map +1 -1
- package/dist/esm/components/Treeview/Treeview.js.map +1 -1
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/esm/primitives/Button.js.map +1 -1
- package/dist/esm/utils/date.js.map +1 -1
- package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -1
- package/dist/esm/utils/hooks/useDraggable.js.map +1 -1
- package/dist/esm/utils/hooks/useDropTarget.js.map +1 -1
- package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -1
- package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -1
- package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -1
- package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -1
- package/dist/esm/utils/hooks/useTimer.js.map +1 -1
- package/dist/esm/utils/input.js.map +1 -1
- package/dist/esm/utils/mergeRefs.js.map +1 -1
- package/dist/esm/utils/taillwind.js.map +1 -1
- package/dist/taco.cjs.development.js +122 -108
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +18 -8
- package/types.json +37 -8
package/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
[](https://travis-ci.com/e-conomic/taco)
|
2
|
-
|
3
1
|
# @economic/taco
|
4
2
|
|
5
3
|
> UI React component library
|
@@ -7,7 +5,7 @@
|
|
7
5
|
## Usage
|
8
6
|
|
9
7
|
```bash
|
10
|
-
npm install @economic/taco
|
8
|
+
npm install --save @economic/taco
|
11
9
|
```
|
12
10
|
|
13
11
|
```javascript
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { MenuProps } from '../..';
|
3
|
+
export declare type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {
|
4
|
+
noPadding?: boolean;
|
5
|
+
};
|
3
6
|
export declare type CardProps = React.HTMLAttributes<HTMLDivElement> & {
|
4
7
|
/** Title of the Card */
|
5
|
-
title: React.ReactElement;
|
8
|
+
title: string | React.ReactElement;
|
6
9
|
/** Menu component associated with the Card */
|
7
10
|
menu?: (props: Partial<MenuProps>) => JSX.Element;
|
8
11
|
};
|
9
|
-
export declare const Card: React.ForwardRefExoticComponent<
|
10
|
-
|
11
|
-
|
12
|
-
/** Menu component associated with the Card */
|
13
|
-
menu?: ((props: Partial<MenuProps>) => JSX.Element) | undefined;
|
14
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
12
|
+
export declare const Card: React.ForwardRefExoticComponent<CardProps> & {
|
13
|
+
Content: React.ForwardRefExoticComponent<CardContentProps>;
|
14
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { Icon } from '../Icon/Icon';\n\ntype AccordionContext = {\n as: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nconst AccordionContext = React.createContext<AccordionContext>({\n as: 'h2',\n});\n\nexport type AccordionTriggerProps = React.HTMLAttributes<HTMLElement>;\n\nconst StyledTrigger = React.forwardRef(function AccordionStyledTrigger(\n props: AccordionPrimitive.AccordionTriggerProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const isExpanded = !!props['aria-expanded'];\n\n const className = cn(\n 'w-full inline-flex justify-between items-center align-middle',\n 'focus:rounded-sm focus:border-blue focus:yt-focus',\n props.className\n );\n\n return (\n <button {...props} ref={ref} className={className}>\n {props.children}\n <Icon name={isExpanded ? 'chevron-up' : 'chevron-down'} />\n </button>\n );\n});\n\nconst Trigger = React.forwardRef(function AccordionTrigger(props: AccordionTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const { children } = props;\n const { as: Heading } = React.useContext(AccordionContext);\n\n return (\n <AccordionPrimitive.Header asChild>\n <Heading className=\"my-3\">\n <AccordionPrimitive.Trigger ref={ref} asChild>\n <StyledTrigger>{children}</StyledTrigger>\n </AccordionPrimitive.Trigger>\n </Heading>\n </AccordionPrimitive.Header>\n );\n});\n\nexport type AccordionContentProps = React.HTMLAttributes<HTMLElement>;\nconst Content = React.forwardRef(function AccordionContent(props: AccordionContentProps, ref: React.Ref<HTMLDivElement>) {\n return <AccordionPrimitive.Content {...props} ref={ref} />;\n});\n\nexport type AccordionItemProps = React.HTMLAttributes<HTMLDivElement> & {\n id: string;\n disabled?: boolean;\n};\nconst Item = (props: AccordionItemProps) => {\n const { id, ...otherProps } = props;\n return <AccordionPrimitive.Item {...otherProps} value={id} />;\n};\n\ntype AccordionBaseProps = {\n children: React.ReactNode[];\n\n /** Change what heading element accordion regions will render */\n as?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n /** Additional classes for Accordion root element */\n className?: string;\n};\n\nexport interface AccordionUncontrolledProps extends AccordionBaseProps {\n /** Default expanded accordion(s) */\n defaultId: string | string[];\n\n id?: never;\n onChange?: never;\n}\n\nexport interface AccordionMultipleControlledProps extends AccordionBaseProps {\n /** Expanded accordions */\n id: string[];\n\n /** onChange function to receive ids of expanded accordions */\n onChange: (id: string[]) => void;\n\n defaultId?: never;\n}\nexport interface AccordionSingleControlledProps extends AccordionBaseProps {\n /** Expanded accordion */\n id: string;\n\n /** onChange function to receive id of expanded accordion */\n onChange: (id: string) => void;\n\n defaultId?: never;\n}\n\nexport type AccordionProps = AccordionUncontrolledProps | AccordionMultipleControlledProps | AccordionSingleControlledProps;\n\nexport const Accordion = (props: AccordionProps) => {\n const { id, defaultId, onChange, as = 'h2', ...otherProps } = props;\n const context = React.useMemo(() => ({ as }), [as]);\n\n let valueProps;\n\n if (defaultId) {\n valueProps = {\n defaultValue: defaultId || undefined,\n };\n } else {\n valueProps = {\n onValueChange: onChange,\n value: id || undefined,\n };\n }\n\n const type = Array.isArray(valueProps.defaultValue) || Array.isArray(valueProps.value) ? 'multiple' : 'single';\n const className = cn('divide-y divide-grey', props.className);\n\n return (\n <AccordionContext.Provider value={context}>\n <AccordionPrimitive.Root {...otherProps} {...valueProps} data-taco=\"accordion\" className={className} type={type} />\n </AccordionContext.Provider>\n );\n};\n\nAccordion.Item = Item;\nAccordion.Trigger = Trigger;\nAccordion.Content = Content;\n"],"names":["AccordionContext","React","createContext","as","StyledTrigger","forwardRef","AccordionStyledTrigger","props","ref","isExpanded","className","cn","children","Icon","name","Trigger","AccordionTrigger","useContext","Heading","AccordionPrimitive","asChild","Content","AccordionContent","Item","id","otherProps","value","Accordion","defaultId","onChange","context","useMemo","valueProps","defaultValue","undefined","onValueChange","type","Array","isArray","Provider"],"mappings":";;;;;;;;AAQA,IAAMA,gBAAgB,gBAAGC,cAAK,CAACC,aAAN,CAAsC;
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { Icon } from '../Icon/Icon';\n\ntype AccordionContext = {\n as: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nconst AccordionContext = React.createContext<AccordionContext>({\n as: 'h2',\n});\n\nexport type AccordionTriggerProps = React.HTMLAttributes<HTMLElement>;\n\nconst StyledTrigger = React.forwardRef(function AccordionStyledTrigger(\n props: AccordionPrimitive.AccordionTriggerProps,\n ref: React.Ref<HTMLButtonElement>\n) {\n const isExpanded = !!props['aria-expanded'];\n\n const className = cn(\n 'w-full inline-flex justify-between items-center align-middle',\n 'focus:rounded-sm focus:border-blue focus:yt-focus',\n props.className\n );\n\n return (\n <button {...props} ref={ref} className={className}>\n {props.children}\n <Icon name={isExpanded ? 'chevron-up' : 'chevron-down'} />\n </button>\n );\n});\n\nconst Trigger = React.forwardRef(function AccordionTrigger(props: AccordionTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const { children } = props;\n const { as: Heading } = React.useContext(AccordionContext);\n\n return (\n <AccordionPrimitive.Header asChild>\n <Heading className=\"my-3\">\n <AccordionPrimitive.Trigger ref={ref} asChild>\n <StyledTrigger>{children}</StyledTrigger>\n </AccordionPrimitive.Trigger>\n </Heading>\n </AccordionPrimitive.Header>\n );\n});\n\nexport type AccordionContentProps = React.HTMLAttributes<HTMLElement>;\nconst Content = React.forwardRef(function AccordionContent(props: AccordionContentProps, ref: React.Ref<HTMLDivElement>) {\n return <AccordionPrimitive.Content {...props} ref={ref} />;\n});\n\nexport type AccordionItemProps = React.HTMLAttributes<HTMLDivElement> & {\n id: string;\n disabled?: boolean;\n};\nconst Item = (props: AccordionItemProps) => {\n const { id, ...otherProps } = props;\n return <AccordionPrimitive.Item {...otherProps} value={id} />;\n};\n\ntype AccordionBaseProps = {\n children: React.ReactNode[];\n\n /** Change what heading element accordion regions will render */\n as?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n /** Additional classes for Accordion root element */\n className?: string;\n};\n\nexport interface AccordionUncontrolledProps extends AccordionBaseProps {\n /** Default expanded accordion(s) */\n defaultId: string | string[];\n\n id?: never;\n onChange?: never;\n}\n\nexport interface AccordionMultipleControlledProps extends AccordionBaseProps {\n /** Expanded accordions */\n id: string[];\n\n /** onChange function to receive ids of expanded accordions */\n onChange: (id: string[]) => void;\n\n defaultId?: never;\n}\nexport interface AccordionSingleControlledProps extends AccordionBaseProps {\n /** Expanded accordion */\n id: string;\n\n /** onChange function to receive id of expanded accordion */\n onChange: (id: string) => void;\n\n defaultId?: never;\n}\n\nexport type AccordionProps = AccordionUncontrolledProps | AccordionMultipleControlledProps | AccordionSingleControlledProps;\n\nexport const Accordion = (props: AccordionProps) => {\n const { id, defaultId, onChange, as = 'h2', ...otherProps } = props;\n const context = React.useMemo(() => ({ as }), [as]);\n\n let valueProps;\n\n if (defaultId) {\n valueProps = {\n defaultValue: defaultId || undefined,\n };\n } else {\n valueProps = {\n onValueChange: onChange,\n value: id || undefined,\n };\n }\n\n const type = Array.isArray(valueProps.defaultValue) || Array.isArray(valueProps.value) ? 'multiple' : 'single';\n const className = cn('divide-y divide-grey', props.className);\n\n return (\n <AccordionContext.Provider value={context}>\n <AccordionPrimitive.Root {...otherProps} {...valueProps} data-taco=\"accordion\" className={className} type={type} />\n </AccordionContext.Provider>\n );\n};\n\nAccordion.Item = Item;\nAccordion.Trigger = Trigger;\nAccordion.Content = Content;\n"],"names":["AccordionContext","React","createContext","as","StyledTrigger","forwardRef","AccordionStyledTrigger","props","ref","isExpanded","className","cn","children","Icon","name","Trigger","AccordionTrigger","useContext","Heading","AccordionPrimitive","asChild","Content","AccordionContent","Item","id","otherProps","value","Accordion","defaultId","onChange","context","useMemo","valueProps","defaultValue","undefined","onValueChange","type","Array","isArray","Provider"],"mappings":";;;;;;;;AAQA,IAAMA,gBAAgB,gBAAGC,cAAK,CAACC,aAAN,CAAsC;EAC3DC,EAAE,EAAE;AADuD,CAAtC,CAAzB;AAMA,IAAMC,aAAa,gBAAGH,cAAK,CAACI,UAAN,CAAiB,SAASC,sBAAT,CACnCC,KADmC,EAEnCC,GAFmC;EAInC,IAAMC,UAAU,GAAG,CAAC,CAACF,KAAK,CAAC,eAAD,CAA1B;EAEA,IAAMG,SAAS,GAAGC,EAAE,CAChB,8DADgB,EAEhB,mDAFgB,EAGhBJ,KAAK,CAACG,SAHU,CAApB;EAMA,OACIT,4BAAA,SAAA,oBAAYM;IAAOC,GAAG,EAAEA;IAAKE,SAAS,EAAEA;IAAxC,EACKH,KAAK,CAACK,QADX,EAEIX,4BAAA,CAACY,IAAD;IAAMC,IAAI,EAAEL,UAAU,GAAG,YAAH,GAAkB;GAAxC,CAFJ,CADJ;AAMH,CAlBqB,CAAtB;AAoBA,IAAMM,OAAO,gBAAGd,cA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,OAAN,CAAc;IAAA,OAAO;MAAE5B,EAAE,EAAFA;KAAT;GAAd,EAA8B,CAACA,EAAD,CAA9B,CAAhB;EAEA,IAAI6B,UAAJ;;EAEA,IAAIJ,SAAJ,EAAe;IACXI,UAAU,GAAG;MACTC,YAAY,EAAEL,SAAS,IAAIM;KAD/B;GADJ,MAIO;IACHF,UAAU,GAAG;MACTG,aAAa,EAAEN,QADN;MAETH,KAAK,EAAEF,EAAE,IAAIU;KAFjB;;;EAMJ,IAAME,IAAI,GAAGC,KAAK,CAACC,OAAN,CAAcN,UAAU,CAACC,YAAzB,KAA0CI,KAAK,CAACC,OAAN,CAAcN,UAAU,CAACN,KAAzB,CAA1C,GAA4E,UAA5E,GAAyF,QAAtG;EACA,IAAMhB,SAAS,GAAGC,EAAE,CAAC,sBAAD,EAAyBJ,KAAK,CAACG,SAA/B,CAApB;EAEA,OACIT,4BAAA,CAACD,gBAAgB,CAACuC,QAAlB;IAA2Bb,KAAK,EAAEI;GAAlC,EACI7B,4BAAA,CAACkB,IAAD,oBAA6BM,YAAgBO;iBAAsB;IAAYtB,SAAS,EAAEA;IAAW0B,IAAI,EAAEA;IAA3G,CADJ,CADJ;AAKH;AAEDT,SAAS,CAACJ,IAAV,GAAiBA,IAAjB;AACAI,SAAS,CAACZ,OAAV,GAAoBA,OAApB;AACAY,SAAS,CAACN,OAAV,GAAoBA,OAApB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Backdrop.js","sources":["../../../../src/components/Backdrop/Backdrop.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nexport type BackdropProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Backdrop = React.forwardRef<HTMLDivElement, BackdropProps>(function Backdrop(props, ref) {\n const className = cn(\n 'fixed inset-0 cursor-default overflow-y-auto bg-[rgba(50,46,62,0.8)] aria-hidden:hidden z-[996]',\n props.className\n );\n\n return <div {...props} className={className} ref={ref} />;\n});\n"],"names":["Backdrop","React","props","ref","className","cn"],"mappings":";;;IAKaA,QAAQ,gBAAGC,UAAA,CAAgD,SAASD,QAAT,CAAkBE,KAAlB,EAAyBC,GAAzB;
|
1
|
+
{"version":3,"file":"Backdrop.js","sources":["../../../../src/components/Backdrop/Backdrop.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nexport type BackdropProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Backdrop = React.forwardRef<HTMLDivElement, BackdropProps>(function Backdrop(props, ref) {\n const className = cn(\n 'fixed inset-0 cursor-default overflow-y-auto bg-[rgba(50,46,62,0.8)] aria-hidden:hidden z-[996]',\n props.className\n );\n\n return <div {...props} className={className} ref={ref} />;\n});\n"],"names":["Backdrop","React","props","ref","className","cn"],"mappings":";;;IAKaA,QAAQ,gBAAGC,UAAA,CAAgD,SAASD,QAAT,CAAkBE,KAAlB,EAAyBC,GAAzB;EACpE,IAAMC,SAAS,GAAGC,EAAE,CAChB,iGADgB,EAEhBH,KAAK,CAACE,SAFU,CAApB;EAKA,OAAOH,aAAA,MAAA,oBAASC;IAAOE,SAAS,EAAEA;IAAWD,GAAG,EAAEA;IAA3C,CAAP;AACH,CAPuB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';\nimport { State } from '../../types';\nimport { getStateClasses, getOutlineClasses } from '../../utils/taillwind';\nimport './Badge.css';\n\nexport type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {\n /** Content should be a numerical value or tag/status like text **/\n children: React.ReactNode;\n /** Show compact version **/\n compact?: boolean;\n /** Show outlined version **/\n outline?: boolean;\n /** State will change the style of the badge **/\n state?: State;\n};\n\nexport const Badge = React.forwardRef(function Badge(props: BadgeProps, ref: React.Ref<HTMLSpanElement>) {\n const { children, compact = false, outline = false, state, ...otherProps } = props;\n const className = cn(\n 'rounded-full border font-bold text-xs uppercase overflow-hidden whitespace-nowrap inline-flex items-center justify-center h-5',\n {\n [getOutlineClasses(state)]: outline,\n [`border-transparent ${getStateClasses(state)}`]: !outline,\n 'h-2 w-2 min-w-0': compact,\n 'h-5 py-0 px-1.5': !compact, // custom padding keeps single digits in a perfect circle\n },\n props.className\n );\n\n return (\n <span\n {...otherProps}\n aria-atomic=\"true\"\n aria-live=\"polite\"\n className={className}\n data-taco=\"badge\"\n ref={ref}\n role=\"status\"\n title={props['aria-label']}\n >\n {compact ? <VisuallyHidden>{children}</VisuallyHidden> : children}\n </span>\n );\n});\n"],"names":["Badge","React","props","ref","children","compact","outline","state","otherProps","className","cn","getOutlineClasses","getStateClasses","role","title","VisuallyHidden"],"mappings":";;;;;;;IAkBaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;;;
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';\nimport { State } from '../../types';\nimport { getStateClasses, getOutlineClasses } from '../../utils/taillwind';\nimport './Badge.css';\n\nexport type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {\n /** Content should be a numerical value or tag/status like text **/\n children: React.ReactNode;\n /** Show compact version **/\n compact?: boolean;\n /** Show outlined version **/\n outline?: boolean;\n /** State will change the style of the badge **/\n state?: State;\n};\n\nexport const Badge = React.forwardRef(function Badge(props: BadgeProps, ref: React.Ref<HTMLSpanElement>) {\n const { children, compact = false, outline = false, state, ...otherProps } = props;\n const className = cn(\n 'rounded-full border font-bold text-xs uppercase overflow-hidden whitespace-nowrap inline-flex items-center justify-center h-5',\n {\n [getOutlineClasses(state)]: outline,\n [`border-transparent ${getStateClasses(state)}`]: !outline,\n 'h-2 w-2 min-w-0': compact,\n 'h-5 py-0 px-1.5': !compact, // custom padding keeps single digits in a perfect circle\n },\n props.className\n );\n\n return (\n <span\n {...otherProps}\n aria-atomic=\"true\"\n aria-live=\"polite\"\n className={className}\n data-taco=\"badge\"\n ref={ref}\n role=\"status\"\n title={props['aria-label']}\n >\n {compact ? <VisuallyHidden>{children}</VisuallyHidden> : children}\n </span>\n );\n});\n"],"names":["Badge","React","props","ref","children","compact","outline","state","otherProps","className","cn","getOutlineClasses","getStateClasses","role","title","VisuallyHidden"],"mappings":";;;;;;;IAkBaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;;;EAClC,IAAQC,QAAR,GAA6EF,KAA7E,CAAQE,QAAR;uBAA6EF,KAA7E,CAAkBG,OAAlB;MAAkBA,OAAlB,+BAA4B,KAA5B;uBAA6EH,KAA7E,CAAmCI,OAAnC;MAAmCA,OAAnC,+BAA6C,KAA7C;MAAoDC,KAApD,GAA6EL,KAA7E,CAAoDK,KAApD;MAA8DC,UAA9D,iCAA6EN,KAA7E;;EACA,IAAMO,SAAS,GAAGC,EAAE,CAChB,+HADgB,iBAGXC,iBAAiB,CAACJ,KAAD,CAHN,IAGgBD,OAHhB,8BAIWM,eAAe,CAACL,KAAD,CAJ1B,IAIsC,CAACD,OAJvC,MAKZ,iBALY,IAKOD,OALP,MAMZ,iBANY,IAMO,CAACA,OANR,QAQhBH,KAAK,CAACO,SARU,CAApB;EAWA,OACIR,aAAA,OAAA,oBACQO;mBACQ;iBACF;IACVC,SAAS,EAAEA;iBACD;IACVN,GAAG,EAAEA;IACLU,IAAI,EAAC;IACLC,KAAK,EAAEZ,KAAK,CAAC,YAAD;IARhB,EAUKG,OAAO,GAAGJ,aAAA,CAACc,cAAD,MAAA,EAAiBX,QAAjB,CAAH,GAAiDA,QAV7D,CADJ;AAcH,CA3BoB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Banner.js","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { State } from '../../types';\nimport { getBannerIcon } from './util';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type BannerProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Content can be any react element, for e.g. a `div` */\n children: React.ReactNode;\n /** State will change the icon displayed in banner */\n state: State;\n onClose?: () => void;\n};\n\nexport const Banner = React.forwardRef(function Banner(props: BannerProps, ref: React.Ref<HTMLDivElement>) {\n const { children, state, onClose } = props;\n const className = cn('bg-white relative flex items-center gap-2 py-2 px-4 leading-6 shadow-md z-10', props.className);\n\n return (\n <div className={className} data-taco=\"banner\" ref={ref}>\n {getBannerIcon(state)}\n {children}\n {onClose ? (\n <IconButton className=\"ml-auto -mr-2 self-start\" icon=\"close\" appearance=\"discrete\" onClick={onClose} />\n ) : null}\n </div>\n );\n});\n"],"names":["Banner","React","props","ref","children","state","onClose","className","cn","getBannerIcon","IconButton","icon","appearance","onClick"],"mappings":";;;;;IAcaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CAAgBE,KAAhB,EAAoCC,GAApC;
|
1
|
+
{"version":3,"file":"Banner.js","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { State } from '../../types';\nimport { getBannerIcon } from './util';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type BannerProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Content can be any react element, for e.g. a `div` */\n children: React.ReactNode;\n /** State will change the icon displayed in banner */\n state: State;\n onClose?: () => void;\n};\n\nexport const Banner = React.forwardRef(function Banner(props: BannerProps, ref: React.Ref<HTMLDivElement>) {\n const { children, state, onClose } = props;\n const className = cn('bg-white relative flex items-center gap-2 py-2 px-4 leading-6 shadow-md z-10', props.className);\n\n return (\n <div className={className} data-taco=\"banner\" ref={ref}>\n {getBannerIcon(state)}\n {children}\n {onClose ? (\n <IconButton className=\"ml-auto -mr-2 self-start\" icon=\"close\" appearance=\"discrete\" onClick={onClose} />\n ) : null}\n </div>\n );\n});\n"],"names":["Banner","React","props","ref","children","state","onClose","className","cn","getBannerIcon","IconButton","icon","appearance","onClick"],"mappings":";;;;;IAcaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CAAgBE,KAAhB,EAAoCC,GAApC;EACnC,IAAQC,QAAR,GAAqCF,KAArC,CAAQE,QAAR;MAAkBC,KAAlB,GAAqCH,KAArC,CAAkBG,KAAlB;MAAyBC,OAAzB,GAAqCJ,KAArC,CAAyBI,OAAzB;EACA,IAAMC,SAAS,GAAGC,EAAE,CAAC,8EAAD,EAAiFN,KAAK,CAACK,SAAvF,CAApB;EAEA,OACIN,aAAA,MAAA;IAAKM,SAAS,EAAEA;iBAAqB;IAASJ,GAAG,EAAEA;GAAnD,EACKM,aAAa,CAACJ,KAAD,CADlB,EAEKD,QAFL,EAGKE,OAAO,GACJL,aAAA,CAACS,UAAD;IAAYH,SAAS,EAAC;IAA2BI,IAAI,EAAC;IAAQC,UAAU,EAAC;IAAWC,OAAO,EAAEP;GAA7F,CADI,GAEJ,IALR,CADJ;AASH,CAbqB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../src/components/Banner/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Icon } from '../Icon/Icon';\nimport { State } from '../../types';\n\nexport const getBannerIcon = (type: State): JSX.Element | null => {\n switch (type) {\n case 'success':\n return <Icon name=\"tick\" className=\"yt-green-solid mt-1 self-start rounded-full\" />;\n\n case 'error':\n return <Icon name=\"warning\" className=\"yt-red-solid mt-1 self-start rounded-full\" />;\n\n case 'warning':\n return <Icon name=\"warning\" className=\"yt-yellow-solid mt-1 self-start rounded-full\" />;\n\n case 'information':\n return <Icon name=\"info\" className=\"yt-blue-solid mt-1 self-start rounded-full\" />;\n\n default:\n return null;\n }\n};\n"],"names":["getBannerIcon","type","React","Icon","name","className"],"mappings":";;;IAIaA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD;
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../src/components/Banner/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Icon } from '../Icon/Icon';\nimport { State } from '../../types';\n\nexport const getBannerIcon = (type: State): JSX.Element | null => {\n switch (type) {\n case 'success':\n return <Icon name=\"tick\" className=\"yt-green-solid mt-1 self-start rounded-full\" />;\n\n case 'error':\n return <Icon name=\"warning\" className=\"yt-red-solid mt-1 self-start rounded-full\" />;\n\n case 'warning':\n return <Icon name=\"warning\" className=\"yt-yellow-solid mt-1 self-start rounded-full\" />;\n\n case 'information':\n return <Icon name=\"info\" className=\"yt-blue-solid mt-1 self-start rounded-full\" />;\n\n default:\n return null;\n }\n};\n"],"names":["getBannerIcon","type","React","Icon","name","className"],"mappings":";;;IAIaA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD;EACzB,QAAQA,IAAR;IACI,KAAK,SAAL;MACI,OAAOC,4BAAA,CAACC,IAAD;QAAMC,IAAI,EAAC;QAAOC,SAAS,EAAC;OAA5B,CAAP;;IAEJ,KAAK,OAAL;MACI,OAAOH,4BAAA,CAACC,IAAD;QAAMC,IAAI,EAAC;QAAUC,SAAS,EAAC;OAA/B,CAAP;;IAEJ,KAAK,SAAL;MACI,OAAOH,4BAAA,CAACC,IAAD;QAAMC,IAAI,EAAC;QAAUC,SAAS,EAAC;OAA/B,CAAP;;IAEJ,KAAK,aAAL;MACI,OAAOH,4BAAA,CAACC,IAAD;QAAMC,IAAI,EAAC;QAAOC,SAAS,EAAC;OAA5B,CAAP;;IAEJ;MACI,OAAO,IAAP;;AAEX;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButton } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n let children = otherProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof otherProps.menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n return createButton({ ...otherProps, children, 'data-taco': 'button' }, className, ref);\n});\n"],"names":["Button","React","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","children","menu","Array","isArray","Icon","key","name","createButton"],"mappings":";;;;;;;IAqCaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CACnCE,KADmC,EAEnCC,GAFmC;
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButton } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n let children = otherProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof otherProps.menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n return createButton({ ...otherProps, children, 'data-taco': 'button' }, className, ref);\n});\n"],"names":["Button","React","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","children","menu","Array","isArray","Icon","key","name","createButton"],"mappings":";;;;;;;IAqCaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CACnCE,KADmC,EAEnCC,GAFmC;EAInC,IAAQC,KAAR,GAAiCF,KAAjC,CAAQE,KAAR;MAAkBC,UAAlB,iCAAiCH,KAAjC;;EACA,IAAMI,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EADA,EAEhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,CAFJ,EAGhB,cAHgB,EAIhB;IACI,iCAAiCR,KAAK,CAACS,QAD3C;IAEI,wCAAwC,CAACT,KAAK,CAACS,QAFnD;IAGI,UAAUP;GAPE,EAShBF,KAAK,CAACI,SATU,CAApB;EAYA,IAAIM,QAAQ,GAAGP,UAAU,CAACO,QAA1B;;EAGA,IAAI,OAAOP,UAAU,CAACQ,IAAlB,KAA2B,UAA/B,EAA2C;IACvCD,QAAQ,GAAGE,KAAK,CAACC,OAAN,CAAcH,QAAd,cACDA,QADC,GACSX,aAAA,CAACe,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CADT,KAEL,CAACN,QAAD,EAAWX,aAAA,CAACe,IAAD;MAAMC,GAAG,EAAC;MAAeC,IAAI,EAAC;KAA9B,CAAX,CAFN;;;EAKJ,OAAOC,YAAY,cAAMd,UAAN;IAAkBO,QAAQ,EAARA,QAAlB;IAA4B,aAAa;MAAYN,SAArD,EAAgEH,GAAhE,CAAnB;AACH,CA3BqB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../src/components/Button/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `yt-blue-solid focus:bg-blue focus:text-white focus:yt-focus active:bg-blue-dark active:text-white hover:bg-blue-light hover:text-white hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white disabled:hover:yt-blue-solid disabled:hover:hover:border-blue`;\n\n case 'danger':\n return `yt-red-solid focus:bg-red focus:text-white focus:yt-focus-red active:bg-red-dark active:text-white hover:bg-red-light hover:text-white hover:focus:bg-red-light hover:focus:text-white disabled:hover:yt-red-solid`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT)] text-blue focus:bg-transparent focus:text-blue active:bg-blue-lightest focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-dark hover:bg-blue-lightest hover:shadow-[inset_0_0_0_1px_theme(colors.blue.light)] hover:text-blue-light hover:focus:bg-blue-lightest hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.light),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-light`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-darkest hover:focus:text-grey-darkest disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue focus:yt-focus active:text-blue-dark hover:text-blue-light hover:focus:text-blue-light disabled:hover:yt-transparent`;\n }\n\n default:\n return `yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid`;\n }\n};\n\nexport const createButton = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { dialog, hanger, menu, popover, tooltip, ...otherProps } = props;\n\n let button = <ButtonPrimitive.Button {...otherProps} className={className} ref={ref} />;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button, appearance: otherProps.appearance });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n if (tooltip) {\n button = <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButton","props","className","ref","dialog","hanger","menu","popover","tooltip","otherProps","button","React","ButtonPrimitive","trigger","appearance","anchor","Tooltip","title"],"mappings":";;;;;;IAKaA,gBAAgB,GAAG,SAAnBA,gBAAmB;
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../src/components/Button/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `yt-blue-solid focus:bg-blue focus:text-white focus:yt-focus active:bg-blue-dark active:text-white hover:bg-blue-light hover:text-white hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white disabled:hover:yt-blue-solid disabled:hover:hover:border-blue`;\n\n case 'danger':\n return `yt-red-solid focus:bg-red focus:text-white focus:yt-focus-red active:bg-red-dark active:text-white hover:bg-red-light hover:text-white hover:focus:bg-red-light hover:focus:text-white disabled:hover:yt-red-solid`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT)] text-blue focus:bg-transparent focus:text-blue active:bg-blue-lightest focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-dark hover:bg-blue-lightest hover:shadow-[inset_0_0_0_1px_theme(colors.blue.light)] hover:text-blue-light hover:focus:bg-blue-lightest hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.light),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-light`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-darkest hover:focus:text-grey-darkest disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue focus:yt-focus active:text-blue-dark hover:text-blue-light hover:focus:text-blue-light disabled:hover:yt-transparent`;\n }\n\n default:\n return `yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid`;\n }\n};\n\nexport const createButton = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { dialog, hanger, menu, popover, tooltip, ...otherProps } = props;\n\n let button = <ButtonPrimitive.Button {...otherProps} className={className} ref={ref} />;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button, appearance: otherProps.appearance });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n if (tooltip) {\n button = <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButton","props","className","ref","dialog","hanger","menu","popover","tooltip","otherProps","button","React","ButtonPrimitive","trigger","appearance","anchor","Toolt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KAAkB,UAAtB,EAAkC;IAC9BK,MAAM,GAAGL,MAAM,CAAC;MAAEU,MAAM,EAAEL;KAAX,CAAf;;;EAGJ,IAAIF,OAAJ,EAAa;IACTE,MAAM,GAAGC,4BAAA,CAACK,OAAD;MAASC,KAAK,EAAET;KAAhB,EAA0BE,MAA1B,CAAT;;;EAGJ,OAAOA,MAAP;AACH;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Calendar.js","sources":["../../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport ReactDayPicker, { NavbarElementProps, DayModifiers } from 'react-day-picker';\nimport { useLocalization } from '../Provider/Provider';\nimport './Calendar.css';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type CalendarTextsActions = {\n /** Aria-label for previous month action button */\n previousMonth: string;\n /** Aria-label for next month action button */\n nextMonth: string;\n /** Aria-label for previous year action button */\n previousYear: string;\n /** Aria-label for next year action button */\n nextYear: string;\n /** Text displayed within today action button */\n today: string;\n};\n\nexport type CalendarTexts = {\n /** Text and aria-label for action buttons in Calendar */\n actions: CalendarTextsActions;\n /** Text abbreviation for months in Calendar's header, starting with January */\n months: string[];\n /** Text abbreviation for days in Calendar's header, starting with Sunday */\n weekdaysShort: string[];\n};\n\nconst renderDay = (day: Date, modifiers: DayModifiers): React.ReactNode =>\n modifiers.disabled ? <span className=\"dot\" /> : day.getDate();\n\n/** @internal */\ntype CustomNavbarElementProps = NavbarElementProps & {\n showYearControls?: boolean;\n onMonthChange: (month: Date) => void;\n value?: Date;\n};\n\nconst thisYear = new Date().getFullYear();\nconst years: number[] = [];\n\nfor (let i = thisYear - 10; i <= thisYear + 10; i += 1) {\n years.push(i);\n}\n\nconst Navbar = React.memo(\n ({ onMonthChange, onNextClick, onPreviousClick, value = new Date() }: CustomNavbarElementProps): JSX.Element => {\n const {\n texts: {\n calendar: { actions, months },\n },\n } = useLocalization();\n\n const handleChange = function handleChange(event) {\n const { year, month } = event.target.form;\n onMonthChange(new Date(year.value, month.value));\n };\n\n return (\n <div className=\"mb-2 flex items-center justify-between\">\n <form className=\"inline-flex space-x-1\">\n <select className=\"h-8 px-2\" name=\"month\" onChange={handleChange} value={value.getMonth()}>\n {months.map((month, i) => (\n <option key={month} value={i}>\n {month}\n </option>\n ))}\n </select>\n <select className=\"h-8 px-2\" name=\"year\" onChange={handleChange} value={value.getFullYear()}>\n {years.map(year => (\n <option key={year} value={year}>\n {String(year)}\n </option>\n ))}\n </select>\n </form>\n <div>\n <IconButton\n appearance=\"discrete\"\n icon=\"chevron-left\"\n aria-label={actions.previousMonth}\n onClick={() => onPreviousClick()}\n rounded\n />\n <IconButton\n appearance=\"discrete\"\n icon=\"chevron-right\"\n aria-label={actions.nextMonth}\n onClick={() => onNextClick()}\n rounded\n />\n </div>\n </div>\n );\n }\n);\n\nexport type CalendarProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'value'> & {\n /** Handler called when a day is clicked in calendar */\n onChange: (date: Date, event?: React.MouseEvent<HTMLDivElement>) => void;\n value?: Date;\n};\n\nexport const Calendar = React.forwardRef(function Calendar(props: CalendarProps, ref: React.Ref<ReactDayPicker>) {\n const { onChange: handleChange, value, ...otherProps } = props;\n const { locale, texts } = useLocalization();\n const [visibleMonth, setVisibleMonth] = React.useState(value ?? new Date());\n\n React.useEffect(() => {\n if (visibleMonth !== value) {\n setVisibleMonth(value ?? new Date());\n }\n }, [value]);\n\n const handleDayClick = (date, modifiers, event) => {\n if (modifiers.outside || modifiers.disabled) {\n return;\n }\n\n handleChange(date, event);\n };\n\n const handleCalendarClickToday = (): void => {\n const today = new Date();\n\n // set to midday to avoid UTC offset causing dates to be mismatched server side\n today.setHours(12);\n today.setMinutes(0);\n today.setSeconds(0);\n\n handleChange(today);\n };\n\n const className = cn('flex bg-white text-xs p-4', otherProps.className);\n\n return (\n <div data-taco=\"calendar\">\n <ReactDayPicker\n {...otherProps}\n className={className}\n month={visibleMonth}\n selectedDays={value}\n locale={locale.substring(0, 2)}\n firstDayOfWeek={1}\n months={texts.calendar.months}\n weekdaysShort={texts.calendar.weekdaysShort}\n navbarElement={navProps => <Navbar {...navProps} onMonthChange={setVisibleMonth} value={visibleMonth} />}\n onDayClick={handleDayClick}\n onMonthChange={setVisibleMonth}\n onTodayButtonClick={handleCalendarClickToday}\n captionElement={() => null}\n todayButton={texts.calendar.actions.today}\n showOutsideDays\n renderDay={renderDay}\n numberOfMonths={1}\n ref={ref}\n />\n </div>\n );\n});\n"],"names":["renderDay","day","modifiers","disabled","React","className","getDate","thisYear","Date","getFullYear","years","i","push","Navbar","onMonthChange","onNextClick","onPreviousClick","value","useLocalization","texts","calendar","actions","months","handleChange","event","target","form","year","month","name","onChange","getMonth","map","key","String","IconButton","appearance","icon","previousMonth","onClick","rounded","nextMonth","Calendar","props","ref","otherProps","locale","visibleMonth","setVisibleMonth","handleDayClick","date","outside","handleCalendarClickToday","today","setHours","setMinutes","setSeconds","cn","ReactDayPicker","selectedDays","substring","firstDayOfWeek","weekdaysShort","navbarElement","navProps","onDayClick","onTodayButtonClick","captionElement","todayButton","showOutsideDays","numberOfMonths"],"mappings":";;;;;;;;;AA6BA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAYC,SAAZ;AAAA,SACdA,SAAS,CAACC,QAAV,GAAqBC,aAAA,OAAA;AAAMC,IAAAA,SAAS,EAAC;GAAhB,CAArB,GAAgDJ,GAAG,CAACK,OAAJ,EADlC;AAAA,CAAlB;;AAUA,IAAMC,QAAQ,gBAAG,IAAIC,IAAJ,GAAWC,WAAX,EAAjB;AACA,IAAMC,KAAK,GAAa,EAAxB;;AAEA,KAAK,IAAIC,CAAC,GAAGJ,QAAQ,GAAG,EAAxB,EAA4BI,CAAC,IAAIJ,QAAQ,GAAG,EAA5C,EAAgDI,CAAC,IAAI,CAArD,EAAwD;AACpDD,EAAAA,KAAK,CAACE,IAAN,CAAWD,CAAX;AACH;;AAED,IAAME,MAAM,gB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,EAAE;AAAA,aAAM,IAAN;AAAA;AAChBC,IAAAA,WAAW,EAAEjD,KAAK,CAACC,QAAN,CAAeC,OAAf,CAAuBgC;AACpCgB,IAAAA,eAAe;AACfrE,IAAAA,SAAS,EAAEA;AACXsE,IAAAA,cAAc,EAAE;AAChB1B,IAAAA,GAAG,EAAEA;IAlBT,CADJ,CADJ;AAwBH,CAxDuB;;;;"}
|
1
|
+
{"version":3,"file":"Calendar.js","sources":["../../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport ReactDayPicker, { NavbarElementProps, DayModifiers } from 'react-day-picker';\nimport { useLocalization } from '../Provider/Provider';\nimport './Calendar.css';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type CalendarTextsActions = {\n /** Aria-label for previous month action button */\n previousMonth: string;\n /** Aria-label for next month action button */\n nextMonth: string;\n /** Aria-label for previous year action button */\n previousYear: string;\n /** Aria-label for next year action button */\n nextYear: string;\n /** Text displayed within today action button */\n today: string;\n};\n\nexport type CalendarTexts = {\n /** Text and aria-label for action buttons in Calendar */\n actions: CalendarTextsActions;\n /** Text abbreviation for months in Calendar's header, starting with January */\n months: string[];\n /** Text abbreviation for days in Calendar's header, starting with Sunday */\n weekdaysShort: string[];\n};\n\nconst renderDay = (day: Date, modifiers: DayModifiers): React.ReactNode =>\n modifiers.disabled ? <span className=\"dot\" /> : day.getDate();\n\n/** @internal */\ntype CustomNavbarElementProps = NavbarElementProps & {\n showYearControls?: boolean;\n onMonthChange: (month: Date) => void;\n value?: Date;\n};\n\nconst thisYear = new Date().getFullYear();\nconst years: number[] = [];\n\nfor (let i = thisYear - 10; i <= thisYear + 10; i += 1) {\n years.push(i);\n}\n\nconst Navbar = React.memo(\n ({ onMonthChange, onNextClick, onPreviousClick, value = new Date() }: CustomNavbarElementProps): JSX.Element => {\n const {\n texts: {\n calendar: { actions, months },\n },\n } = useLocalization();\n\n const handleChange = function handleChange(event) {\n const { year, month } = event.target.form;\n onMonthChange(new Date(year.value, month.value));\n };\n\n return (\n <div className=\"mb-2 flex items-center justify-between\">\n <form className=\"inline-flex space-x-1\">\n <select className=\"h-8 px-2\" name=\"month\" onChange={handleChange} value={value.getMonth()}>\n {months.map((month, i) => (\n <option key={month} value={i}>\n {month}\n </option>\n ))}\n </select>\n <select className=\"h-8 px-2\" name=\"year\" onChange={handleChange} value={value.getFullYear()}>\n {years.map(year => (\n <option key={year} value={year}>\n {String(year)}\n </option>\n ))}\n </select>\n </form>\n <div>\n <IconButton\n appearance=\"discrete\"\n icon=\"chevron-left\"\n aria-label={actions.previousMonth}\n onClick={() => onPreviousClick()}\n rounded\n />\n <IconButton\n appearance=\"discrete\"\n icon=\"chevron-right\"\n aria-label={actions.nextMonth}\n onClick={() => onNextClick()}\n rounded\n />\n </div>\n </div>\n );\n }\n);\n\nexport type CalendarProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'value'> & {\n /** Handler called when a day is clicked in calendar */\n onChange: (date: Date, event?: React.MouseEvent<HTMLDivElement>) => void;\n value?: Date;\n};\n\nexport const Calendar = React.forwardRef(function Calendar(props: CalendarProps, ref: React.Ref<ReactDayPicker>) {\n const { onChange: handleChange, value, ...otherProps } = props;\n const { locale, texts } = useLocalization();\n const [visibleMonth, setVisibleMonth] = React.useState(value ?? new Date());\n\n React.useEffect(() => {\n if (visibleMonth !== value) {\n setVisibleMonth(value ?? new Date());\n }\n }, [value]);\n\n const handleDayClick = (date, modifiers, event) => {\n if (modifiers.outside || modifiers.disabled) {\n return;\n }\n\n handleChange(date, event);\n };\n\n const handleCalendarClickToday = (): void => {\n const today = new Date();\n\n // set to midday to avoid UTC offset causing dates to be mismatched server side\n today.setHours(12);\n today.setMinutes(0);\n today.setSeconds(0);\n\n handleChange(today);\n };\n\n const className = cn('flex bg-white text-xs p-4', otherProps.className);\n\n return (\n <div data-taco=\"calendar\">\n <ReactDayPicker\n {...otherProps}\n className={className}\n month={visibleMonth}\n selectedDays={value}\n locale={locale.substring(0, 2)}\n firstDayOfWeek={1}\n months={texts.calendar.months}\n weekdaysShort={texts.calendar.weekdaysShort}\n navbarElement={navProps => <Navbar {...navProps} onMonthChange={setVisibleMonth} value={visibleMonth} />}\n onDayClick={handleDayClick}\n onMonthChange={setVisibleMonth}\n onTodayButtonClick={handleCalendarClickToday}\n captionElement={() => null}\n todayButton={texts.calendar.actions.today}\n showOutsideDays\n renderDay={renderDay}\n numberOfMonths={1}\n ref={ref}\n />\n </div>\n );\n});\n"],"names":["renderDay","day","modifiers","disabled","React","className","getDate","thisYear","Date","getFullYear","years","i","push","Navbar","onMonthChange","onNextClick","onPreviousClick","value","useLocalization","texts","calendar","actions","months","handleChange","event","target","form","year","month","name","onChange","getMonth","map","key","String","IconButton","appearance","icon","previousMonth","onClick","rounded","nextMonth","Calendar","props","ref","otherProps","locale","visibleMonth","setVisibleMonth","handleDayClick","date","outside","handleCalendarClickToday","today","setHours","setMinutes","setSeconds","cn","ReactDayPicker","selectedDays","substring","firstDayOfWeek","weekdaysShort","navbarElement","navProps","onDayClick","onTodayButtonClick","captionElement","todayButton","showOutsideDays","numberOfMonths"],"mappings":";;;;;;;;;AA6BA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAYC,SAAZ;EAAA,OACdA,SAAS,CAACC,QAAV,GAAqBC,aAAA,OAAA;IAAMC,SAAS,EAAC;GAAhB,CAArB,GAAgDJ,GAAG,CAACK,OAAJ,EADlC;AAAA,CAAlB;;AAUA,IAAMC,QAAQ,gBAAG,IAAIC,IAAJ,GAAWC,WAAX,EAAjB;AACA,IAAMC,KAAK,GAAa,EAAxB;;AAEA,KAAK,IAAIC,CAAC,GAAGJ,QAAQ,GAAG,EAAxB,EAA4BI,CAAC,IAAIJ,QAAQ,GAAG,EAA5C,EAAgDI,CAAC,IAAI,CAArD,EAAwD;EACpDD,KAAK,CAACE,IAAN,CAAWD,CAAX;AACH;;AAED,IAAME,MAAM,gBAAGT,IAAA,CACX;MAAGU,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AGA6C,KAAK,CAACC,QAAN,CAAe,EAAf;IACAD,KAAK,CAACE,UAAN,CAAiB,CAAjB;IACAF,KAAK,CAACG,UAAN,CAAiB,CAAjB;IAEAjC,YAAY,CAAC8B,KAAD,CAAZ;GARJ;;EAWA,IAAMhD,SAAS,GAAGoD,EAAE,CAAC,2BAAD,EAA8BZ,UAAU,CAACxC,SAAzC,CAApB;EAEA,OACID,aAAA,MAAA;iBAAe;GAAf,EACIA,aAAA,CAACsD,cAAD,oBACQb;IACJxC,SAAS,EAAEA;IACXuB,KAAK,EAAEmB;IACPY,YAAY,EAAE1C;IACd6B,MAAM,EAAEA,MAAM,CAACc,SAAP,CAAiB,CAAjB,EAAoB,CAApB;IACRC,cAAc,EAAE;IAChBvC,MAAM,EAAEH,KAAK,CAACC,QAAN,CAAeE;IACvBwC,aAAa,EAAE3C,KAAK,CAACC,QAAN,CAAe0C;IAC9BC,aAAa,EAAE,uBAAAC,QAAQ;MAAA,OAAI5D,aAAA,CAACS,MAAD,oBAAYmD;QAAUlD,aAAa,EAAEkC;QAAiB/B,KAAK,EAAE8B;QAA7D,CAAJ;;IACvBkB,UAAU,EAAEhB;IACZnC,aAAa,EAAEkC;IACfkB,kBAAkB,EAAEd;IACpBe,cAAc,EAAE;MAAA,OAAM,IAAN;;IAChBC,WAAW,EAAEjD,KAAK,CAACC,QAAN,CAAeC,OAAf,CAAuBgC;IACpCgB,eAAe;IACfrE,SAAS,EAAEA;IACXsE,cAAc,EAAE;IAChB1B,GAAG,EAAEA;IAlBT,CADJ,CADJ;AAwBH,CAxDuB;;;;"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
1
2
|
import { forwardRef, createElement } from 'react';
|
2
3
|
import cn from 'classnames';
|
3
4
|
import '../Icon/components/index.js';
|
@@ -50,19 +51,32 @@ import '../Switch/Switch.js';
|
|
50
51
|
import '../Tour/Tour.js';
|
51
52
|
import '../../utils/hooks/useOnClickOutside.js';
|
52
53
|
|
54
|
+
var _excluded = ["noPadding"];
|
55
|
+
var Content = /*#__PURE__*/forwardRef(function CardContent(externalProps, ref) {
|
56
|
+
var noPadding = externalProps.noPadding,
|
57
|
+
props = _objectWithoutPropertiesLoose(externalProps, _excluded);
|
58
|
+
|
59
|
+
var className = cn('flex-grow overflow-auto', {
|
60
|
+
'mx-4 mb-4': !noPadding
|
61
|
+
}, props.className);
|
62
|
+
return createElement("div", Object.assign({}, props, {
|
63
|
+
className: className,
|
64
|
+
ref: ref
|
65
|
+
}));
|
66
|
+
});
|
53
67
|
var Card = /*#__PURE__*/forwardRef(function Card(props, ref) {
|
54
68
|
var title = props.title,
|
55
69
|
menu = props.menu,
|
56
70
|
children = props.children;
|
57
|
-
var className = cn('bg-white
|
71
|
+
var className = cn('bg-white flex flex-col rounded-xl shadow-[0px_0px_1px_rgba(0,0,0,0.1),0px_6px_18px_rgba(47,51,68,0.2)]', props.className);
|
58
72
|
return createElement("div", {
|
59
73
|
className: className,
|
60
74
|
"data-taco": "card",
|
61
75
|
ref: ref
|
62
|
-
}, createElement("
|
63
|
-
className: "flex"
|
76
|
+
}, createElement("div", {
|
77
|
+
className: "mx-4 mt-4 mb-2 flex"
|
64
78
|
}, title && createElement("h4", {
|
65
|
-
className: "flex-grow text-left"
|
79
|
+
className: "mb-0 flex-grow text-left"
|
66
80
|
}, title), menu ? createElement(IconButton, {
|
67
81
|
icon: "ellipsis-horizontal",
|
68
82
|
appearance: "discrete",
|
@@ -70,6 +84,7 @@ var Card = /*#__PURE__*/forwardRef(function Card(props, ref) {
|
|
70
84
|
className: "-mt-[4px]"
|
71
85
|
}) : null), children);
|
72
86
|
});
|
87
|
+
Card.Content = Content;
|
73
88
|
|
74
89
|
export { Card };
|
75
90
|
//# sourceMappingURL=Card.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nimport { MenuProps, IconButton } from '../..';\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children } = props;\n const className = cn(\n 'bg-white
|
1
|
+
{"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nimport { MenuProps, IconButton } from '../..';\n\nexport type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {\n noPadding?: boolean;\n};\n\nconst Content = React.forwardRef<HTMLDivElement, CardContentProps>(function CardContent(externalProps, ref) {\n const { noPadding, ...props } = externalProps;\n const className = cn(\n 'flex-grow overflow-auto',\n {\n 'mx-4 mb-4': !noPadding,\n },\n props.className\n );\n return <div {...props} className={className} ref={ref} />;\n});\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: string | React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children } = props;\n const className = cn(\n 'bg-white flex flex-col rounded-xl shadow-[0px_0px_1px_rgba(0,0,0,0.1),0px_6px_18px_rgba(47,51,68,0.2)]',\n props.className\n );\n\n return (\n <div className={className} data-taco=\"card\" ref={ref}>\n <div className=\"mx-4 mt-4 mb-2 flex\">\n {title && <h4 className=\"mb-0 flex-grow text-left\">{title}</h4>}\n {menu ? <IconButton icon=\"ellipsis-horizontal\" appearance=\"discrete\" menu={menu} className=\"-mt-[4px]\" /> : null}\n </div>\n {children}\n </div>\n );\n}) as React.ForwardRefExoticComponent<CardProps> & {\n Content: React.ForwardRefExoticComponent<CardContentProps>;\n};\nCard.Content = Content;\n"],"names":["Content","React","CardContent","externalProps","ref","noPadding","props","className","cn","Card","title","menu","children","IconButton","icon","appearance"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,OAAO,gBAAGC,UAAA,CAAmD,SAASC,WAAT,CAAqBC,aAArB,EAAoCC,GAApC;EAC/D,IAAQC,SAAR,GAAgCF,aAAhC,CAAQE,SAAR;MAAsBC,KAAtB,iCAAgCH,aAAhC;;EACA,IAAMI,SAAS,GAAGC,EAAE,CAChB,yBADgB,EAEhB;IACI,aAAa,CAACH;GAHF,EAKhBC,KAAK,CAACC,SALU,CAApB;EAOA,OAAON,aAAA,MAAA,oBAASK;IAAOC,SAAS,EAAEA;IAAWH,GAAG,EAAEA;IAA3C,CAAP;AACH,CAVe,CAAhB;IAmBaK,IAAI,gBAAGR,UAAA,CAA4C,SAASQ,IAAT,CAAcH,KAAd,EAAqBF,GAArB;EAC5D,IAAQM,KAAR,GAAkCJ,KAAlC,CAAQI,KAAR;MAAeC,IAAf,GAAkCL,KAAlC,CAAeK,IAAf;MAAqBC,QAArB,GAAkCN,KAAlC,CAAqBM,QAArB;EACA,IAAML,SAAS,GAAGC,EAAE,CAChB,wGADgB,EAEhBF,KAAK,CAACC,SAFU,CAApB;EAKA,OACIN,aAAA,MAAA;IAAKM,SAAS,EAAEA;iBAAqB;IAAOH,GAAG,EAAEA;GAAjD,EACIH,aAAA,MAAA;IAAKM,SAAS,EAAC;GAAf,EACKG,KAAK,IAAIT,aAAA,KAAA;IAAIM,SAAS,EAAC;GAAd,EAA0CG,KAA1C,CADd,EAEKC,IAAI,GAAGV,aAAA,CAACY,UAAD;IAAYC,IAAI,EAAC;IAAsBC,UAAU,EAAC;IAAWJ,IAAI,EAAEA;IAAMJ,SAAS,EAAC;GAAnF,CAAH,GAAuG,IAFhH,CADJ,EAKKK,QALL,CADJ;AASH,CAhBmB;AAmBpBH,IAAI,CAACT,OAAL,GAAeA,OAAf;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { Icon } from '../Icon/Icon';\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /* Increases visual prominenance of the checkbox */\n highlighted?: boolean;\n /**\n * Indeterminate state should only be used with sub-checkboxes. The indeterminate state is shown if not all\n * sub-checkboxes are selected. This only affects the style, changing the icon in the checkbox.\n */\n indeterminate?: boolean;\n /* Whether the checkbox is in an invalid state */\n invalid?: boolean;\n /** Label for the checkbox */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledCheckboxProps extends CheckboxBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledCheckboxProps extends CheckboxBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type CheckboxProps = UncontrolledCheckboxProps | ControlledCheckboxProps;\n\nexport const Checkbox = React.forwardRef(function Checkbox(props: CheckboxProps, ref: React.Ref<HTMLButtonElement>) {\n const { checked, highlighted, indeterminate, invalid, label, onChange, ...otherProps } = props;\n\n const className = cn(\n 'bg-white h-5 w-5 border rounded text-sm flex-shrink-0 self-start mt-[0.1rem] focus:yt-focus', //hover:shadow-[0_0_0_1px_rgba(235,235,235,1)]\n props.className,\n {\n 'border-grey-dark text-blue hover:text-blue-light focus:border-blue focus:hover:border-blue-light':\n !props.disabled && !invalid,\n 'border-grey text-blue-light cursor-not-allowed': props.disabled,\n 'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,\n 'border-red text-red hover:text-red-light hover:border-red-light focus:border-red focus:hover:border-red-light':\n invalid && !props.disabled,\n }\n );\n\n let handleChange: ((checked: CheckedState) => void) | undefined;\n\n if (onChange) {\n handleChange = (checked: CheckedState) => onChange(checked === 'indeterminate' ? false : checked);\n }\n\n const element = (\n <CheckboxPrimitive.Root\n {...otherProps}\n data-taco=\"checkbox\"\n checked={indeterminate ? 'indeterminate' : checked}\n className={className}\n onCheckedChange={handleChange}\n ref={ref}\n >\n <CheckboxPrimitive.Indicator className=\"flex h-full w-full\">\n <Icon name={indeterminate ? 'line' : 'tick'} className=\"!h-full !w-full\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n\n if (label) {\n const labelClassName = cn(\n 'flex items-center cursor-pointer gap-2',\n {\n 'cursor-not-allowed text-grey-dark': props.disabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n {element}\n {label}\n </label>\n );\n }\n\n return element;\n});\n"],"names":["Checkbox","React","props","ref","checked","highlighted","indeterminate","invalid","label","onChange","otherProps","className","cn","disabled","handleChange","element","CheckboxPrimitive","onCheckedChange","Icon","name","labelClassName"],"mappings":";;;;;;;IAwCaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { Icon } from '../Icon/Icon';\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /* Increases visual prominenance of the checkbox */\n highlighted?: boolean;\n /**\n * Indeterminate state should only be used with sub-checkboxes. The indeterminate state is shown if not all\n * sub-checkboxes are selected. This only affects the style, changing the icon in the checkbox.\n */\n indeterminate?: boolean;\n /* Whether the checkbox is in an invalid state */\n invalid?: boolean;\n /** Label for the checkbox */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledCheckboxProps extends CheckboxBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledCheckboxProps extends CheckboxBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type CheckboxProps = UncontrolledCheckboxProps | ControlledCheckboxProps;\n\nexport const Checkbox = React.forwardRef(function Checkbox(props: CheckboxProps, ref: React.Ref<HTMLButtonElement>) {\n const { checked, highlighted, indeterminate, invalid, label, onChange, ...otherProps } = props;\n\n const className = cn(\n 'bg-white h-5 w-5 border rounded text-sm flex-shrink-0 self-start mt-[0.1rem] focus:yt-focus', //hover:shadow-[0_0_0_1px_rgba(235,235,235,1)]\n props.className,\n {\n 'border-grey-dark text-blue hover:text-blue-light focus:border-blue focus:hover:border-blue-light':\n !props.disabled && !invalid,\n 'border-grey text-blue-light cursor-not-allowed': props.disabled,\n 'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,\n 'border-red text-red hover:text-red-light hover:border-red-light focus:border-red focus:hover:border-red-light':\n invalid && !props.disabled,\n }\n );\n\n let handleChange: ((checked: CheckedState) => void) | undefined;\n\n if (onChange) {\n handleChange = (checked: CheckedState) => onChange(checked === 'indeterminate' ? false : checked);\n }\n\n const element = (\n <CheckboxPrimitive.Root\n {...otherProps}\n data-taco=\"checkbox\"\n checked={indeterminate ? 'indeterminate' : checked}\n className={className}\n onCheckedChange={handleChange}\n ref={ref}\n >\n <CheckboxPrimitive.Indicator className=\"flex h-full w-full\">\n <Icon name={indeterminate ? 'line' : 'tick'} className=\"!h-full !w-full\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n\n if (label) {\n const labelClassName = cn(\n 'flex items-center cursor-pointer gap-2',\n {\n 'cursor-not-allowed text-grey-dark': props.disabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n {element}\n {label}\n </label>\n );\n }\n\n return element;\n});\n"],"names":["Checkbox","React","props","ref","checked","highlighted","indeterminate","invalid","label","onChange","otherProps","className","cn","disabled","handleChange","element","CheckboxPrimitive","onCheckedChange","Icon","name","labelClassName"],"mappings":";;;;;;;IAwCaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;EACrC,IAAQC,OAAR,GAAyFF,KAAzF,CAAQE,OAAR;MAAiBC,WAAjB,GAAyFH,KAAzF,CAAiBG,WAAjB;MAA8BC,aAA9B,GAAyFJ,KAAzF,CAA8BI,aAA9B;MAA6CC,OAA7C,GAAyFL,KAAzF,CAA6CK,OAA7C;MAAsDC,KAAtD,GAAyFN,KAAzF,CAAsDM,KAAtD;MAA6DC,QAA7D,GAAyFP,KAAzF,CAA6DO,QAA7D;MAA0EC,UAA1E,iCAAyFR,KAAzF;;EAEA,IAAMS,SAAS,GAAGC,EAAE,CAChB,6FADgB;EAEhBV,KAAK,CAACS,SAFU,EAGhB;IACI,oGACI,CAACT,KAAK,CAACW,QAAP,IAAmB,CAACN,OAF5B;IAGI,kDAAkDL,KAAK,CAACW,QAH5D;IAII,gEAAgER,WAJpE;IAKI,iHACIE,OAAO,IAAI,CAACL,KAAK,CAACW;GATV,CAApB;EAaA,IAAIC,YAAJ;;EAEA,IAAIL,QAAJ,EAAc;IACVK,YAAY,GAAG,sBAACV,OAAD;MAAA,OAA2BK,QAAQ,CAACL,OAAO,KAAK,eAAZ,GAA8B,KAA9B,GAAsCA,OAAvC,CAAnC;KAAf;;;EAGJ,IAAMW,OAAO,GACTd,aAAA,CAACe,IAAD,oBACQN;iBACM;IACVN,OAAO,EAAEE,aAAa,GAAG,eAAH,GAAqBF;IAC3CO,SAAS,EAAEA;IACXM,eAAe,EAAEH;IACjBX,GAAG,EAAEA;IANT,EAQIF,aAAA,CAACe,SAAD;IAA6BL,SAAS,EAAC;GAAvC,EACIV,aAAA,CAACiB,IAAD;IAAMC,IAAI,EAAEb,aAAa,GAAG,MAAH,GAAY;IAAQK,SAAS,EAAC;GAAvD,CADJ,CARJ,CADJ;;EAeA,IAAIH,KAAJ,EAAW;IACP,IAAMY,cAAc,GAAGR,EAAE,CACrB,wCADqB,EAErB;MACI,qCAAqCV,KAAK,CAACW;KAH1B,EAKrBX,KAAK,CAACS,SALe,CAAzB;IAQA,OACIV,aAAA,QAAA;MAAOU,SAAS,EAAES;KAAlB,EACKL,OADL,EAEKP,KAFL,CADJ;;;EAQJ,OAAOO,OAAP;AACH,CAvDuB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Input, InputProps } from '../Input/Input';\nimport { useCombobox } from './useCombobox';\nimport { ScrollableList, ScrollableListItem, ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { IconButton } from '../IconButton/IconButton';\nimport './Combobox.css';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { useLocalization } from '../Provider/Provider';\n\nexport type ComboboxTexts = {\n /* Tooltip shown for the dialog button */\n tooltip: string;\n};\n\nexport type ComboboxItem = ScrollableListItem;\nexport type ComboboxValue = ScrollableListItemValue;\n\ntype ComboboxBaseProps = Omit<InputProps, 'defaultValue' | 'button' | 'onChange' | 'value'> & {\n /** Array of options in combobox */\n data?: ComboboxItem[];\n /**\n * Initial value of the input in combobox.\n * This is used when combobox is mounted, if no value is provided.\n * *Note* that combobox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ComboboxValue;\n /** Set what value should have an empty option in combobox */\n emptyValue?: ComboboxValue;\n /** Draws attention to the combobox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Displays loading state in listbox */\n loading?: boolean;\n /**\n * Handler called when user chooses an option from the provided suggestions.\n * Suggestions will be calculated based on the input value.\n * There are two ways to choose an option: either click on it, or navigate using keyboard and press `enter`\n */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Handler called when the user enters a query **/\n onSearch?: (query: string) => void | Promise<void>;\n /** Value of the input in combobox */\n value?: ComboboxValue;\n};\n\ninterface InlineComboboxProps extends ComboboxBaseProps {\n dialog?: never;\n /**\n * Combobox will display its data when input is clicked/focused, even if the input is empty.\n * *Note* that default combobox will display matching data only when user starts typing in input.\n */\n inline: boolean; // Example 3 on https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html\n}\n\ninterface DialogComboboxProps extends ComboboxBaseProps {\n dialog: (props: Partial<DialogProps>) => JSX.Element;\n inline?: never;\n}\n\nexport type ComboboxProps = InlineComboboxProps | DialogComboboxProps;\n\nexport const Combobox = React.forwardRef(function Combobox(props: ComboboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, dialog, style, ...otherProps } = props;\n const { combobox, button, input, popover, list } = useCombobox(otherProps, ref);\n const internalRef = React.useRef<HTMLDivElement>(null);\n const { texts } = useLocalization();\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn(\n 'inline-flex relative',\n {\n 'yt-combobox--inline': props.inline,\n },\n externalClassName\n );\n\n return (\n <span className={className} data-taco=\"combobox\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Anchor asChild ref={internalRef}>\n <div {...combobox} className=\"inline w-full\" ref={ref}>\n <Input\n {...input}\n autoComplete=\"off\"\n button={\n props.inline ? (\n <IconButton\n appearance=\"discrete\"\n className=\"!border-l-0 focus:!border-none focus:!shadow-none active:!border-none\"\n icon={popover.open ? 'chevron-up' : 'chevron-down'}\n onClick={() => {\n popover.onOpenChange(true);\n input.ref.current?.focus();\n }}\n tabIndex={-1}\n />\n ) : dialog ? (\n <IconButton\n icon=\"list-search\"\n disabled={props.readOnly || props.disabled}\n dialog={dialog}\n onFocus={(event: React.FocusEvent<HTMLButtonElement>) => {\n // Prevents the default focus behaviour of showing the tooltip, on parent tooltip element\n event.preventDefault();\n input.ref.current?.focus();\n }}\n ref={button.ref}\n tabIndex={-1}\n tooltip={texts.combobox.tooltip}\n />\n ) : undefined\n }\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Content\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n }}\n sideOffset={4}\n >\n <ScrollableList\n {...list}\n className={cn('!border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]')}\n style={{ minWidth: selectDimensions?.width }}\n tabIndex={popover.open ? 0 : -1}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </span>\n );\n});\n"],"names":["Combobox","React","props","ref","externalClassName","className","dialog","style","otherProps","useCombobox","combobox","button","input","popover","list","internalRef","useLocalization","texts","selectDimensions","useBoundingClientRectListener","cn","inline","PopoverPrimitive","asChild","Input","autoComplete","IconButton","appearance","icon","open","onClick","onOpenChange","current","focus","tabIndex","disabled","readOnly","onFocus","event","preventDefault","tooltip","undefined","align","onOpenAutoFocus","sideOffset","ScrollableList","minWidth","width"],"mappings":";;;;;;;;;;;;IA+DaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;
|
1
|
+
{"version":3,"file":"Combobox.js","sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Input, InputProps } from '../Input/Input';\nimport { useCombobox } from './useCombobox';\nimport { ScrollableList, ScrollableListItem, ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { IconButton } from '../IconButton/IconButton';\nimport './Combobox.css';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { useLocalization } from '../Provider/Provider';\n\nexport type ComboboxTexts = {\n /* Tooltip shown for the dialog button */\n tooltip: string;\n};\n\nexport type ComboboxItem = ScrollableListItem;\nexport type ComboboxValue = ScrollableListItemValue;\n\ntype ComboboxBaseProps = Omit<InputProps, 'defaultValue' | 'button' | 'onChange' | 'value'> & {\n /** Array of options in combobox */\n data?: ComboboxItem[];\n /**\n * Initial value of the input in combobox.\n * This is used when combobox is mounted, if no value is provided.\n * *Note* that combobox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ComboboxValue;\n /** Set what value should have an empty option in combobox */\n emptyValue?: ComboboxValue;\n /** Draws attention to the combobox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Displays loading state in listbox */\n loading?: boolean;\n /**\n * Handler called when user chooses an option from the provided suggestions.\n * Suggestions will be calculated based on the input value.\n * There are two ways to choose an option: either click on it, or navigate using keyboard and press `enter`\n */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Handler called when the user enters a query **/\n onSearch?: (query: string) => void | Promise<void>;\n /** Value of the input in combobox */\n value?: ComboboxValue;\n};\n\ninterface InlineComboboxProps extends ComboboxBaseProps {\n dialog?: never;\n /**\n * Combobox will display its data when input is clicked/focused, even if the input is empty.\n * *Note* that default combobox will display matching data only when user starts typing in input.\n */\n inline: boolean; // Example 3 on https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html\n}\n\ninterface DialogComboboxProps extends ComboboxBaseProps {\n dialog: (props: Partial<DialogProps>) => JSX.Element;\n inline?: never;\n}\n\nexport type ComboboxProps = InlineComboboxProps | DialogComboboxProps;\n\nexport const Combobox = React.forwardRef(function Combobox(props: ComboboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, dialog, style, ...otherProps } = props;\n const { combobox, button, input, popover, list } = useCombobox(otherProps, ref);\n const internalRef = React.useRef<HTMLDivElement>(null);\n const { texts } = useLocalization();\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn(\n 'inline-flex relative',\n {\n 'yt-combobox--inline': props.inline,\n },\n externalClassName\n );\n\n return (\n <span className={className} data-taco=\"combobox\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Anchor asChild ref={internalRef}>\n <div {...combobox} className=\"inline w-full\" ref={ref}>\n <Input\n {...input}\n autoComplete=\"off\"\n button={\n props.inline ? (\n <IconButton\n appearance=\"discrete\"\n className=\"!border-l-0 focus:!border-none focus:!shadow-none active:!border-none\"\n icon={popover.open ? 'chevron-up' : 'chevron-down'}\n onClick={() => {\n popover.onOpenChange(true);\n input.ref.current?.focus();\n }}\n tabIndex={-1}\n />\n ) : dialog ? (\n <IconButton\n icon=\"list-search\"\n disabled={props.readOnly || props.disabled}\n dialog={dialog}\n onFocus={(event: React.FocusEvent<HTMLButtonElement>) => {\n // Prevents the default focus behaviour of showing the tooltip, on parent tooltip element\n event.preventDefault();\n input.ref.current?.focus();\n }}\n ref={button.ref}\n tabIndex={-1}\n tooltip={texts.combobox.tooltip}\n />\n ) : undefined\n }\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Content\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n }}\n sideOffset={4}\n >\n <ScrollableList\n {...list}\n className={cn('!border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]')}\n style={{ minWidth: selectDimensions?.width }}\n tabIndex={popover.open ? 0 : -1}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </span>\n );\n});\n"],"names":["Combobox","React","props","ref","externalClassName","className","dialog","style","otherProps","useCombobox","combobox","button","input","popover","list","internalRef","useLocalization","texts","selectDimensions","useBoundingClientRectListener","cn","inline","PopoverPrimitive","asChild","Input","autoComplete","IconButton","appearance","icon","open","onClick","onOpenChange","current","focus","tabIndex","disabled","readOnly","onFocus","event","preventDefault","tooltip","undef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VuB,IAAI,EAAEf,OAAO,CAACgB,IAAR,GAAe,YAAf,GAA8B;MACpCC,OAAO,EAAE;;;QACLjB,OAAO,CAACkB,YAAR,CAAqB,IAArB;QACA,sBAAAnB,KAAK,CAACT,GAAN,CAAU6B,OAAV,0EAAmBC,KAAnB;;MAEJC,QAAQ,EAAE,CAAC;KARf,CADJ,GAWI5B,MAAM,GACNL,aAAA,CAACyB,UAAD;MACIE,IAAI,EAAC;MACLO,QAAQ,EAAEjC,KAAK,CAACkC,QAAN,IAAkBlC,KAAK,CAACiC;MAClC7B,MAAM,EAAEA;MACR+B,OAAO,EAAE,iBAACC,KAAD;;;;QAELA,KAAK,CAACC,cAAN;QACA,uBAAA3B,KAAK,CAACT,GAAN,CAAU6B,OAAV,4EAAmBC,KAAnB;;MAEJ9B,GAAG,EAAEQ,MAAM,CAACR;MACZ+B,QAAQ,EAAE,CAAC;MACXM,OAAO,EAAEvB,KAAK,CAACP,QAAN,CAAe8B;KAX5B,CADM,GAcNC;IA7BZ,CADJ,CADJ,CADJ,EAqCIxC,aAAA,CAACqB,OAAD;IACIoB,KAAK,EAAC;IACNC,eAAe,EAAE,yBAAAL,KAAK;MAClBA,KAAK,CAACC,cAAN;;IAEJK,UAAU,EAAE;GALhB,EAOI3C,aAAA,CAAC4C,cAAD,oBACQ/B;IACJT,SAAS,EAAEe,EAAE,CAAC,uEAAD;IACbb,KAAK,EAAE;MAAEuC,QAAQ,EAAE5B,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAE6B;;IACrCb,QAAQ,EAAErB,OAAO,CAACgB,IAAR,GAAe,CAAf,GAAmB,CAAC;IAJlC,CAPJ,CArCJ,CADJ,CADJ;AAwDH,CAtEuB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCombobox.js","sources":["../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.keyCode) {\n case keycode('backspace'): {\n return;\n }\n\n case keycode('escape'): {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case keycode('down'):\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current) {\n buttonRef.current.click();\n }\n }\n break;\n\n case keycode('up'):\n case keycode('home'):\n case keycode('end'): {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n const initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ref","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","inline","onChange","onClick","onKeyDown","onSearch","readOnly","props","inputRef","useProxiedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","undefined","getIndexFromValue","currentIndex","setCurrentIndex","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","keyCode","keycode","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","id","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;;;;AAkBA,IAAMA,SAAS,gBAAGC,QAAQ,CAAC,UAAAC,CAAC;AAAA,SAAIA,CAAC,EAAL;AAAA,CAAF,EAAW,GAAX,CAA1B;;AAEA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,KAAD;AAAA,SAAgDC,MAAM,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,EAAV,CAAtD;AAAA,CAA5B;;IAUaE,WAAW,GAAG,SAAdA,WAAc,OAkBvBC,GAlBuB;MAGAC,sBAAnB;uBACAC;MAAMC,wCAAiB;MACvBC,oBAAAA;MACAC,gBAAAA;MAEAC,cAAAA;MAEAC,gBAAAA;MACAC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;MACAC,gBAAAA;MACAd,aAAAA;MACGe;;AAIP,MAAMC,QAAQ,GAAGC,aAAa,CAAmBd,GAAnB,CAA9B;AACA,MAAMe,SAAS,GAAGC,MAAA,CAAgC,IAAhC,CAAlB;AACA,MAAMC,OAAO,GAAGD,MAAA,CAA+B,IAA/B,CAAhB;;AACA,wBAAwBA,QAAA,CAAe,KAAf,CAAxB;AAAA,MAAOE,IAAP;AAAA,MAAaC,OAAb;;AACA,MAAMC,MAAM,GAAGJ,OAAA,CAAc;AAAA,WAAMK,EAAI,EAAV;AAAA,GAAd,EAA4B,EAA5B,CAAf;;AACA,yBAAoCL,QAAA,CAAuBpB,mBAAmB,CAACC,KAAD,CAA1C,CAApC;AAAA,MAAOyB,UAAP;AAAA,MAAmBC,aAAnB;;AACA,MAAMC,gBAAgB,GAAG,CAACd,QAAD,KAAc,CAACJ,MAAD,IAAYA,MAAM,IAAIgB,UAAU,KAAK1B,mBAAmB,CAACC,KAAD,CAAtE,CAAzB;AACA,MAAM4B,aAAa,GAAGC,gBAAgB,CAACvB,cAAD,CAAtC;AACA,MAA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K,EAALA,KAFG;AAGHG,IAAAA,IAAI,EAAJA,IAHG;AAIHI,IAAAA,MAAM,EAANA,MAJG;AAKHC,IAAAA,OAAO,EAAE;AACL1D,MAAAA,IAAI,EAAJA,IADK;AAEL2D,MAAAA,YAAY,EAAE1D;AAFT;AALN,GAAP;AAWH;;;;"}
|
1
|
+
{"version":3,"file":"useCombobox.js","sources":["../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.keyCode) {\n case keycode('backspace'): {\n return;\n }\n\n case keycode('escape'): {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case keycode('down'):\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current) {\n buttonRef.current.click();\n }\n }\n break;\n\n case keycode('up'):\n case keycode('home'):\n case keycode('end'): {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n const initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ref","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","inline","onChange","onClick","onKeyDown","onSearch","readOnly","props","inputRef","useProxiedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","undefined","getIndexFromValue","currentIndex","setCurrentIndex","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","keyCode","keycode","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","id","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;;;;AAkBA,IAAMA,SAAS,gBAAGC,QAAQ,CAAC,UAAAC,CAAC;EAAA,OAAIA,CAAC,EAAL;AAAA,CAAF,EAAW,GAAX,CAA1B;;AAEA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,KAAD;EAAA,OAAgDC,MAAM,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,EAAV,CAAtD;AAAA,CAA5B;;IAUaE,WAAW,GAAG,SAAdA,WAAc,OAkBvBC,GAlBuB;MAGAC,sBAAnB;uBACAC;MAAMC,wCAAiB;MACvBC,oBAAAA;MACAC,gBAAAA;MAEAC,cAAAA;MAEAC,gBAAAA;MACAC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;MACAC,gBAAAA;MACAd,aAAAA;MACGe;;EAIP,IAAMC,QAAQ,GAAGC,aAAa,CAAmBd,GAAnB,CAA9B;EACA,IAAMe,SAAS,GAAGC,MAAA,CAAgC,IAAhC,CAAlB;EACA,IAAMC,OAAO,GAAGD,MAAA,CAA+B,IAA/B,CAAhB;;EACA,sBAAwBA,QAAA,CAAe,KAAf,CAAxB;MAAOE,IAAP;MAAaC,OAAb;;EACA,IAAMC,MAAM,GAAGJ,OAAA,CAAc;IAAA,OAAMK,EAAI,EAAV;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M,QAAd,GAAyB2C,iBAAzB,GAA6C1B,SAZhD;IAaPpB,OAAO,EAAE,CAACH,QAAD,IAAa,CAACM,QAAd,GAAyB4C,gBAAzB,GAA4C3B,SAb9C;IAcPnB,SAAS,EAAE,CAACJ,QAAD,IAAa,CAACM,QAAd,GAAyB6C,kBAAzB,GAA8C5B,SAdlD;IAePjB,QAAQ,EAARA,QAfO;IAgBPX,GAAG,EAAEa,QAhBE;IAiBPyD,IAAI,EAAE,MAjBC;IAkBPzE,KAAK,EAAEyB,UAAF,aAAEA,UAAF,cAAEA,UAAF,GAAgB;IAlBzB;;EAqBA,IAAMiD,IAAI,GAA+B;IACrC,mBAAmBtE,cADkB;IAErCC,IAAI,EAAJA,IAFqC;IAGrCG,QAAQ,EAARA,QAHqC;IAIrCmE,EAAE,EAAEpD,MAJiC;IAKrCb,QAAQ,EAAEyD,mBAL2B;IAMrCxD,OAAO,EAAEyD,kBAN4B;IAOrCjE,GAAG,EAAEiB,OAPgC;IAQrCwD,aAAa,EAAE,KARsB;IASrCC,QAAQ,EAAE,CAAC,CAT0B;IAUrC7E,KAAK,EAAEiC;GAVX;EAaA,IAAM6C,MAAM,GAAG;IACX3E,GAAG,EAAEe;GADT;EAIA,OAAO;IACHmD,QAAQ,EAARA,QADG;IAEHE,KAAK,EAALA,KAFG;IAGHG,IAAI,EAAJA,IAHG;IAIHI,MAAM,EAANA,MAJG;IAKHC,OAAO,EAAE;MACL1D,IAAI,EAAJA,IADK;MAEL2D,YAAY,EAAE1D;;GAPtB;AAWH;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Datepicker.js","sources":["../../../../src/components/Datepicker/Datepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Calendar, CalendarProps } from '../Calendar/Calendar';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Provider';\nimport { useDatepicker } from './useDatepicker';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Popover } from '../Popover/Popover';\n\nexport type DatepickerTexts = {\n /** Aria-label for calendar */\n calendar: string;\n /** Clear button text */\n clear: string;\n /**\n * Aria-label for calendar icon button in the input.\n * Calendar will open when user clicks this icon button.\n */\n expand: string;\n /** Shortcut heading text */\n shortcuts: string;\n};\n\nexport type DatepickerProps = Omit<InputProps, 'value'> & {\n /** [Calendar](component:calendar) component associated with the DatePicker */\n calendar?: CalendarProps;\n /** List of shortcuts */\n shortcuts?: any;\n /** Title for the shortcuts panel */\n shortcutsText?: string;\n /** Handler to be called when the clear button is clicked */\n onReset?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * Date value of the calendar.\n * This will be displayed in DatePicker's input in the format given to the [Provider](component:provider) component\n */\n value?: Date;\n};\n\nexport const Datepicker = React.forwardRef(function Datepicker(props: DatepickerProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, onReset: handleReset, style, shortcuts, shortcutsText, ...otherProps } = props;\n const { calendar, input } = useDatepicker(otherProps, ref);\n const { texts } = useLocalization();\n const className = cn('inline-flex w-full text-black font-normal', externalClassName);\n\n return (\n <span className={className} data-taco=\"datepicker\" style={style}>\n <Input\n {...input}\n button={\n <Popover>\n <Popover.Trigger>\n <IconButton\n aria-label={texts.datepicker.expand}\n disabled={input.disabled || input.readOnly}\n icon=\"calendar\"\n />\n </Popover.Trigger>\n <Popover.Content>\n {({ close }) => (\n <div className=\"-m-3 flex\">\n <Calendar\n {...calendar}\n onChange={(date: Date, event?: React.MouseEvent<HTMLDivElement>) => {\n calendar.onChange(date, event);\n close();\n }}\n tabIndex={-1}\n />\n {shortcuts && (\n <div className=\"border-grey-dark flex flex-col border-l\">\n <span className=\"m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold\">\n {shortcutsText ?? texts.datepicker.shortcuts}\n </span>\n <ul>\n {shortcuts.map((shortcut, i) => (\n <li key={i}>\n <button\n className=\"hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs\"\n onClick={event => {\n event.persist();\n shortcut.onClick(event);\n close();\n }}\n >\n {shortcut.text}\n </button>\n </li>\n ))}\n </ul>\n {handleReset && (\n <button\n className=\"text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs\"\n onClick={event => {\n event.persist();\n handleReset(event);\n close();\n }}\n >\n {texts.datepicker.clear}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n </Popover.Content>\n </Popover>\n }\n />\n </span>\n );\n});\n"],"names":["Datepicker","React","props","ref","externalClassName","className","handleReset","onReset","style","shortcuts","shortcutsText","otherProps","useDatepicker","calendar","input","useLocalization","texts","cn","Input","button","Popover","Trigger","IconButton","datepicker","expand","disabled","readOnly","icon","Content","close","Calendar","onChange","date","event","tabIndex","map","shortcut","i","key","onClick","persist","text","clear"],"mappings":";;;;;;;;;;;IAuCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;
|
1
|
+
{"version":3,"file":"Datepicker.js","sources":["../../../../src/components/Datepicker/Datepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Calendar, CalendarProps } from '../Calendar/Calendar';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Provider';\nimport { useDatepicker } from './useDatepicker';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Popover } from '../Popover/Popover';\n\nexport type DatepickerTexts = {\n /** Aria-label for calendar */\n calendar: string;\n /** Clear button text */\n clear: string;\n /**\n * Aria-label for calendar icon button in the input.\n * Calendar will open when user clicks this icon button.\n */\n expand: string;\n /** Shortcut heading text */\n shortcuts: string;\n};\n\nexport type DatepickerProps = Omit<InputProps, 'value'> & {\n /** [Calendar](component:calendar) component associated with the DatePicker */\n calendar?: CalendarProps;\n /** List of shortcuts */\n shortcuts?: any;\n /** Title for the shortcuts panel */\n shortcutsText?: string;\n /** Handler to be called when the clear button is clicked */\n onReset?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * Date value of the calendar.\n * This will be displayed in DatePicker's input in the format given to the [Provider](component:provider) component\n */\n value?: Date;\n};\n\nexport const Datepicker = React.forwardRef(function Datepicker(props: DatepickerProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, onReset: handleReset, style, shortcuts, shortcutsText, ...otherProps } = props;\n const { calendar, input } = useDatepicker(otherProps, ref);\n const { texts } = useLocalization();\n const className = cn('inline-flex w-full text-black font-normal', externalClassName);\n\n return (\n <span className={className} data-taco=\"datepicker\" style={style}>\n <Input\n {...input}\n button={\n <Popover>\n <Popover.Trigger>\n <IconButton\n aria-label={texts.datepicker.expand}\n disabled={input.disabled || input.readOnly}\n icon=\"calendar\"\n />\n </Popover.Trigger>\n <Popover.Content>\n {({ close }) => (\n <div className=\"-m-3 flex\">\n <Calendar\n {...calendar}\n onChange={(date: Date, event?: React.MouseEvent<HTMLDivElement>) => {\n calendar.onChange(date, event);\n close();\n }}\n tabIndex={-1}\n />\n {shortcuts && (\n <div className=\"border-grey-dark flex flex-col border-l\">\n <span className=\"m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold\">\n {shortcutsText ?? texts.datepicker.shortcuts}\n </span>\n <ul>\n {shortcuts.map((shortcut, i) => (\n <li key={i}>\n <button\n className=\"hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs\"\n onClick={event => {\n event.persist();\n shortcut.onClick(event);\n close();\n }}\n >\n {shortcut.text}\n </button>\n </li>\n ))}\n </ul>\n {handleReset && (\n <button\n className=\"text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs\"\n onClick={event => {\n event.persist();\n handleReset(event);\n close();\n }}\n >\n {texts.datepicker.clear}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n </Popover.Content>\n </Popover>\n }\n />\n </span>\n );\n});\n"],"names":["Datepicker","React","props","ref","externalClassName","className","handleReset","onReset","style","shortcuts","shortcutsText","otherProps","useDatepicker","calendar","input","useLocalization","texts","cn","Input","button","Popover","Trigger","IconButton","datepicker","expand","disabled","readOnly","icon","Content","close","Calendar","onChange","date","event","tabIndex","map","shortcut","i","key","onClick","persist","text","clear"],"mappings":";;;;;;;;;;;IAuCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,IAAmBC,iBAAnB,GAA+GF,KAA/G,CAAQG,SAAR;MAA+CC,WAA/C,GAA+GJ,KAA/G,CAAsCK,OAAtC;MAA4DC,KAA5D,GAA+GN,KAA/G,CAA4DM,KAA5D;MAAmEC,SAAnE,GAA+GP,KAA/G,CAAmEO,SAAnE;MAA8EC,aAA9E,GAA+GR,KAA/G,CAA8EQ,aAA9E;MAAgGC,UAAhG,iCAA+GT,KAA/G;;EACA,qBAA4BU,aAAa,CAACD,UAAD,EAAaR,GAAb,CAAzC;MAAQU,QAAR,kBAAQA,QAAR;MAAkBC,KAAlB,kBAAkBA,KAAlB;;EACA,uBAAkBC,eAAe,EAAjC;MAAQC,KAAR,oBAAQA,KAAR;;EACA,IAAMX,SAAS,GAAGY,EAAE,CAAC,2CAAD,EAA8Cb,iBAA9C,CAApB;EAEA,OACIH,aAAA,OAAA;IAAMI,SAAS,EAAEA;iBAAqB;IAAaG,KAAK,EAAEA;GAA1D,EACIP,aAAA,CAACiB,KAAD,oBACQJ;IACJK,MAAM,EACFlB,aAAA,CAACmB,OAAD,MAAA,EACInB,aAAA,CAACmB,OAAO,CAACC,OAAT,MAAA,EACIpB,aAAA,CAACqB,UAAD;oBACgBN,KAAK,CAACO,UAAN,CAAiBC;MAC7BC,QAAQ,EAAEX,KAAK,CAACW,QAAN,IAAkBX,KAAK,CAACY;MAClCC,IAAI,EAAC;KAHT,CADJ,CADJ,EAQI1B,aAAA,CAACmB,OAAO,CAACQ,OAAT,MAAA,EACK;MAAA,IAAGC,KAAH,QAAGA,KAAH;MAAA,OACG5B,aAAA,MAAA;QAAKI,SAAS,EAAC;OAAf,EACIJ,aAAA,CAAC6B,QA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